-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unused parameter analyzer shouldn't warn for methods that only throw #66535
Unused parameter analyzer shouldn't warn for methods that only throw #66535
Conversation
await TestDiagnosticMissingAsync( | ||
@"public class Class | ||
{ | ||
public void Method(int [|x|]) => throw new System.Exception(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test that makes sure it still reports if there's more than just a throw?
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CodeStyle; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.FlowAnalysis.SymbolUsageAnalysis; | ||
using Microsoft.CodeAnalysis.LanguageService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed?
...s/RemoveUnusedParametersAndValues/CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a test like:
public class C
{
public C() => throw new System.Exception();
}
I'm expecting the cast to fail in C# implementation. It should probably be BaseMethodDeclarationSyntax
, but even then, I'm not sure if it can fail. Similar thing to VB, though it won't crash due to TryCast
usage, but could lead to unintended behavior.
It looks like the analyzer currently doesn't support local functions, but it would be good to add a test to make sure things still work properly if local functions are supported in future.
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
Fixes #65275