Skip to content
This repository has been archived by the owner. It is now read-only.

Fix spurious 0154 diagnostics #343

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public override void VisitConstructorDeclaration(ConstructorDeclarationSyntax no
if (node.ParameterList.Parameters.Count == 0)
return;

Analyze(node.ParameterList.Parameters, new SyntaxNode[] { node.Body, node.Initializer }, node.Kind());
Analyze(node.ParameterList.Parameters, new SyntaxNode[] { node.Body, node.ExpressionBody, node.Initializer }, node.Kind());
}

public override void VisitAnonymousMethodExpression(AnonymousMethodExpressionSyntax node)
Expand Down
20 changes: 20 additions & 0 deletions Tests/CSharp/Diagnostics/UnusedParameterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,26 @@ void TestMethod (int a, int b, int c)
Console.WriteLine(b);
Console.WriteLine(c);
}
}";
Analyze<UnusedParameterAnalyzer>(input);
}

[Fact]
public void UnusedParameterInExpressionBodiedConstructor()
{
var input = @"
class TestClass {
public TestClass(int $i$) => "";
}";
Analyze<UnusedParameterAnalyzer>(input);
}

[Fact]
public void UsedParameterInExpressionBodiedConstructor()
{
var input = @"
class TestClass {
public TestClass(int i) => i.ToString();
}";
Analyze<UnusedParameterAnalyzer>(input);
}
Expand Down