dotnet/roslyn

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

Aperta

#38.514 aperta il 5 set 2019

 (3 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEDeveloper CommunityIDE-CodeStylehelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

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:

Guida contributor