dotnet/roslyn
View on GitHubGenerate overrides attempts to override methods that are not supported in C#/VB
Open
#20,954 opened on Jul 18, 2017
Area-CompilersConcept-Diagnostic ClarityFeature Requesthelp wanted
Repository metrics
- Stars
- (20,414 stars)
- PR merge metrics
- (Avg merge 6d 17h) (256 merged PRs in 30d)
Description
Version Used: 26717.1.d15rel
Steps to Reproduce: Scenario B07 - Generate overrides Generate overrides tries to override methods containing modopts and generates code that won't compile. It shouldn't offer to override these methods.
- Create a Managed C++ dll with the following code:
using namespace System;
public ref class Test
{
public:
virtual int TestFunc(const Test a)
{
return 0;
}
};
- Create a C# Console app with following code:
public class Test2 : Test
{
}
- Reference the dll create in step 1.
- "Generate overrides" on Test2
Expected Behavior:
Generate overrides shouldn't offer to override TestFunc.
Actual Behavior:
TestFunc shows up as a function available to generate an override for and the parameter list is missing.
If you go ahead and generate the override, this is the resulting (incorrect) code:
public override int TestFunc(object a)
{
return base.TestFunc(a);
}