diff --git a/Analyzers/Akade.IndexedSet.Analyzers.Test/SimpleAnalyzerTests.cs b/Analyzers/Akade.IndexedSet.Analyzers.Test/SimpleAnalyzerTests.cs index 012d834..4f62edd 100644 --- a/Analyzers/Akade.IndexedSet.Analyzers.Test/SimpleAnalyzerTests.cs +++ b/Analyzers/Akade.IndexedSet.Analyzers.Test/SimpleAnalyzerTests.cs @@ -64,4 +64,29 @@ public async Task Do_not_use_block_bodied_lambda_Async() await VerifyCS.VerifyAnalyzerAsync(code, name); } + + [TestMethod] + public async Task No_diagnostic_reported_for_concurrent_set_update() + { + string code = $$""" + using Akade.IndexedSet; + using Akade.IndexedSet.Concurrency; + + + ConcurrentIndexedSet test = new[]{5,10,20}.ToIndexedSet() + .WithIndex(x => x) + .BuildConcurrent(); + + test.Update(set => { + set.Add(1); + set.Add(2); + }); + test.Update((set, state) => { + set.Add(3); + set.Add(4); + }, 8); + """; + + await VerifyCS.VerifyAnalyzerAsync(code); + } } diff --git a/Analyzers/Akade.IndexedSet.Analyzers/IndexNamingRulesAnalyzer.cs b/Analyzers/Akade.IndexedSet.Analyzers/IndexNamingRulesAnalyzer.cs index 8312687..a55f145 100644 --- a/Analyzers/Akade.IndexedSet.Analyzers/IndexNamingRulesAnalyzer.cs +++ b/Analyzers/Akade.IndexedSet.Analyzers/IndexNamingRulesAnalyzer.cs @@ -80,7 +80,8 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context) && namedType.IsGenericType && _relevantTypes.Contains(namedType.OriginalDefinition)) { - if (node.ArgumentList.Arguments.FirstOrDefault()?.Expression is LambdaExpressionSyntax lambda) + if (node.ArgumentList.Arguments.FirstOrDefault()?.Expression is LambdaExpressionSyntax lambda + && !IsExcludedMethod(memberAccess.Name.Identifier)) { CheckParameterName(context, lambda); CheckForParenthesized(context, lambda); @@ -90,6 +91,11 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context) } } + private bool IsExcludedMethod(SyntaxToken identifier) + { + return identifier.ValueText is "Update"; + } + private void CheckForBlockBodiedLambda(SyntaxNodeAnalysisContext context, LambdaExpressionSyntax lambda) { if (lambda.Block != null)