diff --git a/CodeTiger.CodeAnalysis/Analyzers/Naming/SymbolNamingAnalyzer.cs b/CodeTiger.CodeAnalysis/Analyzers/Naming/SymbolNamingAnalyzer.cs index 84d023c..32d74a4 100644 --- a/CodeTiger.CodeAnalysis/Analyzers/Naming/SymbolNamingAnalyzer.cs +++ b/CodeTiger.CodeAnalysis/Analyzers/Naming/SymbolNamingAnalyzer.cs @@ -515,6 +515,9 @@ bool IsAllowableDiscard() case SyntaxKind.ParenthesizedLambdaExpression: case SyntaxKind.SimpleLambdaExpression: return "_".Equals(parameterNode.Identifier.ValueText, StringComparison.OrdinalIgnoreCase); + case SyntaxKind.ParameterList: + return parameterNode.Parent.Parent?.IsKind(SyntaxKind.ParenthesizedLambdaExpression) == true + && "_".Equals(parameterNode.Identifier.ValueText, StringComparison.OrdinalIgnoreCase); default: return false; } diff --git a/UnitTests/UnitTests.CodeTiger.CodeAnalysis/Analyzers/Naming/SymbolNamingAnalyzerTests.cs b/UnitTests/UnitTests.CodeTiger.CodeAnalysis/Analyzers/Naming/SymbolNamingAnalyzerTests.cs index 4d29d47..08ca5a7 100644 --- a/UnitTests/UnitTests.CodeTiger.CodeAnalysis/Analyzers/Naming/SymbolNamingAnalyzerTests.cs +++ b/UnitTests/UnitTests.CodeTiger.CodeAnalysis/Analyzers/Naming/SymbolNamingAnalyzerTests.cs @@ -1041,6 +1041,9 @@ public void DoSomething() { var dictionary = new ConcurrentDictionary(); dictionary.GetOrAdd(0, _ => "0"); + dictionary.GetOrAdd(0, (_) => "0"); + Action action = _ => { }; + Func func = (_) => true; } } } @@ -1050,7 +1053,7 @@ public void DoSomething() } [Fact] - public void ParameterWithDiscardNamesWhereNotAllowedProduceDiagnostics() + public void ParametersWithDiscardNamesWhereNotAllowedProduceDiagnostics() { string code = """ using System;