diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs index 20310a3..f98b395 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs @@ -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;") diff --git a/src/FluentAssertions.Analyzers/Tips/FluentAssertionsAnalyzer.cs b/src/FluentAssertions.Analyzers/Tips/FluentAssertionsAnalyzer.cs index 278b8b7..b63b97c 100644 --- a/src/FluentAssertions.Analyzers/Tips/FluentAssertionsAnalyzer.cs +++ b/src/FluentAssertions.Analyzers/Tips/FluentAssertionsAnalyzer.cs @@ -334,7 +334,8 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, FluentAs } } - if (invocation.TryGetFirstDescendent(out var propertyBeforeShould)) + var argument = invocation.Arguments[0].Value.UnwrapConversion(); + if (argument is IPropertyReferenceOperation propertyBeforeShould) { switch (propertyBeforeShould.Property.Name) {