Skip to content

Commit

Permalink
Merge pull request #5062 from Youssef1313/dead-condition
Browse files Browse the repository at this point in the history
Remove dead condition
  • Loading branch information
genlu authored May 4, 2021
2 parents a91b132 + 4b13390 commit 7639d20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,11 @@ private void AnalyzeArgument(OperationAnalysisContext context)
return;
}

if (argument.Parameter == null)
{
return;
}

var stringText = (string)argument.Value.ConstantValue.Value;

var matchingParameter = argument.Parameter;

switch (matchingParameter.Name)
// argument.Parameter will not be null here. The only case for it to be null is an __arglist argument, for which
// the argument type will not be of SpecialType.System_String.
switch (argument.Parameter.Name)
{
case ParamName:
var parametersInScope = GetParametersInScope(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ public class UseNameofInPlaceOfStringTests
{
#region Unit tests for no analyzer diagnostic

[Fact]
[WorkItem(3023, "https://github.com/dotnet/roslyn-analyzers/issues/3023")]
public async Task NoDiagnostic_ArgList()
{
await VerifyCS.VerifyAnalyzerAsync(@"
public class C
{
public void M(__arglist)
{
M(__arglist());
}
}");
}

[Fact]
public async Task NoDiagnostic_NoArguments()
{
Expand Down

0 comments on commit 7639d20

Please sign in to comment.