Skip to content

Commit

Permalink
bugfix: false positive on expressions containing Count (#384)
Browse files Browse the repository at this point in the history
* bugfix: false positive on expressions containing Count
  • Loading branch information
Meir017 authored Oct 7, 2024
1 parent 731954c commit 4893a34
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ public class CollectionTests
[AssertionDiagnostic(@"var array = new string[1, 1]; array.Length.Should().Be(0{0});")]
[AssertionDiagnostic(@"var array = new string[2, 2]; array.Length.Should().Be(0{0});")]
[AssertionDiagnostic(@"var array = new string[3, 3, 3]; array.Length.Should().Be(0{0});")]
[AssertionDiagnostic(@"int[] array1 = [1, 2, 3]; int[] array2 = [4, 5, 6]; int[] both = [..array1, ..array2]; (array1.Length + array2.Length).Should().Be(both.Length{0});")]
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/309")]
public void CollectionShouldHaveCount_LengthShouldBe_TestNoAnalyzer(string assertion) => DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(new StringBuilder()
.AppendLine("using System;")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, FluentAs

}
}
if (invocation.TryGetFirstDescendent<IPropertyReferenceOperation>(out var propertyBeforeShould))
var argument = invocation.Arguments[0].Value.UnwrapConversion();
if (argument is IPropertyReferenceOperation propertyBeforeShould)
{
switch (propertyBeforeShould.Property.Name)
{
Expand Down

0 comments on commit 4893a34

Please sign in to comment.