dotnet/roslyn
在 GitHub 查看Generate overrides attempts to override methods that are not supported in C#/VB
Open
#20,954 创建于 2017年7月18日
Area-CompilersConcept-Diagnostic ClarityFeature Requesthelp wanted
仓库指标
- Star
- (20,414 star)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 256 个 PR)
描述
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);
}