dotnet/roslyn

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

Offen

#38.514 geöffnet am 05.09.2019

 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-IDEDeveloper CommunityIDE-CodeStylehelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

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:

Contributor Guide