dotnet/roslyn

Generate overrides attempts to override methods that are not supported in C#/VB

Open

#20,954 创建于 2017年7月18日

在 GitHub 查看
 (5 评论) (0 反应) (0 负责人)C# (4,257 fork)batch import
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.

  1. 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;
    }
};
  1. Create a C# Console app with following code:
public class Test2 : Test
{
}
  1. Reference the dll create in step 1.
  2. "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);
    }

贡献者指南