dotnet/roslyn

Add an option for c# override generation (ignoring expression bodied members)

开放

#38,514 创建于 2019年9月5日

 (3 条评论) (0 个反应) (0 位负责人)C# (4,257 个派生)batch import
Area-IDEDeveloper CommunityIDE-CodeStylehelp wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

This issue has been moved from a ticket on Developer Community.


when override SomeVirtualOrAbstractMethod is expanded, and Options->Text Editor->C#->Code Style->Use expression body for methods is set to "When on single line", the generated piece of code looks like this:

protected override SomeVirtualOrAbstractMethod() => base. SomeVirtualOrAbstractMethod();

this is (in most cases) not wanted, since the reason to override a method is to add custom behaviour (and usually also call the base class)

Thus the suggestion should be that an option is added to explicitely have the override expansion generated normal member bodies, generating this code:

protected override SomeVirtualOrAbstractMethod()
{
    base. SomeVirtualOrAbstractMethod();
}

Original Comments

Jane Wu [MSFT] on 8/16/2019, 00:30 AM:

贡献者指南