Skip to content

Conversation

@akhera99
Copy link
Member

Fixes #65275

@akhera99 akhera99 requested a review from a team as a code owner January 24, 2023 21:13
@ghost ghost added the Area-IDE label Jan 24, 2023
await TestDiagnosticMissingAsync(
@"public class Class
{
public void Method(int [|x|]) => throw new System.Exception();
Copy link
Contributor

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.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.FlowAnalysis.SymbolUsageAnalysis;
using Microsoft.CodeAnalysis.LanguageService;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed?

Copy link
Member

@Youssef1313 Youssef1313 left a 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.

@akhera99 akhera99 enabled auto-merge (squash) January 24, 2023 23:28
@akhera99 akhera99 merged commit 234e15d into dotnet:main Jan 25, 2023
@ghost ghost added this to the Next milestone Jan 25, 2023
@Cosifne Cosifne modified the milestones: Next, 17.6 P1 Jan 31, 2023
xtqqczze added a commit to xtqqczze/dotnet-runtime that referenced this pull request Jul 17, 2024
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
xtqqczze added a commit to xtqqczze/dotnet-runtime that referenced this pull request Jul 17, 2024
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
xtqqczze added a commit to xtqqczze/dotnet-runtime that referenced this pull request Jul 17, 2024
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
xtqqczze added a commit to xtqqczze/dotnet-runtime that referenced this pull request Jul 19, 2024
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
stephentoub pushed a commit to dotnet/runtime that referenced this pull request Jul 22, 2024
Since dotnet/roslyn#66535 `IDE0060` doesn't warn for throw-only methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDE0060 shouldn't warn for throw-only methods

4 participants