DotNetAnalyzers / AsyncUsageAnalyzers

Now superseded by Microsoft/vs-threading
https://github.com/Microsoft/vs-threading
Other
121 stars 18 forks source link

Refactor issue for ignoring a rule #55

Closed GeertvanHorrik closed 7 years ago

GeertvanHorrik commented 7 years ago

I am assuming that the alt + enter suppression is a feature by this analyzer.

When I have a method like this:

/// <summary>
/// some text
/// </summary>
public async void MyMethod()
{
}

And want to supress the warning, it puts the pragma above the documentation:

#pragma warning disable AvoidAsyncVoid // Avoid async void
/// <summary>
/// some text
/// </summary>
public async void MyMethod()
#pragma warning restore AvoidAsyncVoid // Avoid async void
{
}

I think it should be put above the method call:

/// <summary>
/// some text
/// </summary>
#pragma warning disable AvoidAsyncVoid // Avoid async void
public async void MyMethod()
#pragma warning restore AvoidAsyncVoid // Avoid async void
{
}
sharwell commented 7 years ago

@GeertvanHorrik This refactoring is actually implemented by the compiler itself, not by this project: https://github.com/dotnet/roslyn

That said, the request here is actually not allowed by the C# language (or at least not by the compiler). Preprocessor directives are not allowed to appear in documentation comments or between documentation comments and the next token. See dotnet/roslyn#96.