diff --git a/src/FluentAssertions.Analyzers.Tests/CodeFixVerifierArguments.cs b/src/FluentAssertions.Analyzers.Tests/CodeFixVerifierArguments.cs index 8bc7319..d67276c 100644 --- a/src/FluentAssertions.Analyzers.Tests/CodeFixVerifierArguments.cs +++ b/src/FluentAssertions.Analyzers.Tests/CodeFixVerifierArguments.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; +using System.Linq; using FluentAssertions.Analyzers.TestUtils; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Testing; namespace FluentAssertions.Analyzers.Tests; @@ -26,10 +28,28 @@ public CodeFixVerifierArguments() { } CodeFixProviders.Add(new TCodeFixProvider()); return this; } - + public CodeFixVerifierArguments WithFixedSources(params string[] fixedSources) { FixedSources.AddRange(fixedSources); return this; } +} + +public class CodeFixVerifierNewArguments + where TAnalyzer : DiagnosticAnalyzer, new() + where TCodeFix : CodeFixProvider, new() +{ + public List Sources { get; } = new(); + public List FixedSources { get; } = new(); + public List PackageReferences { get; } = new(); + public DiagnosticResult ExpectedDiagnostic { get; private set; } + + public CodeFixVerifierNewArguments(DiagnosticResult expectedDiagnostic) => ExpectedDiagnostic = expectedDiagnostic; + + public CodeFixVerifierNewArguments WithPackages(params PackageReference[] packages) + { + PackageReferences.AddRange(packages.Select(x => new PackageIdentity(x.Name, x.Version))); + return this; + } } \ No newline at end of file diff --git a/src/FluentAssertions.Analyzers.Tests/DiagnosticResult.cs b/src/FluentAssertions.Analyzers.Tests/DiagnosticResult.cs index 3b6e4f6..4a3dfdd 100644 --- a/src/FluentAssertions.Analyzers.Tests/DiagnosticResult.cs +++ b/src/FluentAssertions.Analyzers.Tests/DiagnosticResult.cs @@ -33,7 +33,7 @@ public DiagnosticResultLocation(string path, int line, int column) /// /// Struct that stores information about a Diagnostic appearing in a source /// - public struct DiagnosticResult + public struct LegacyDiagnosticResult { private DiagnosticResultLocation[] locations; diff --git a/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs b/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs index 7714f0e..eabdcb4 100644 --- a/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs +++ b/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs @@ -12,6 +12,9 @@ using System.Threading; using Microsoft.CodeAnalysis.Simplification; using Microsoft.CodeAnalysis.Formatting; +using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Testing; +using System.Threading.Tasks; namespace FluentAssertions.Analyzers.Tests { @@ -20,6 +23,13 @@ namespace FluentAssertions.Analyzers.Tests /// public static class DiagnosticVerifier { + private class CodeFixVerifier : CSharpCodeFixVerifier + where TAnalyzer : DiagnosticAnalyzer, new() + where TCodeFix : CodeFixProvider, new() + { + + } + #region CodeFixVerifier public static void VerifyCSharpFix(string oldSource, string newSource) @@ -38,6 +48,28 @@ public static void VerifyCSharpFix(string public static void VerifyFix(CodeFixVerifierArguments arguments) => VerifyFix(arguments, arguments.DiagnosticAnalyzers.Single(), arguments.CodeFixProviders.Single(), arguments.FixedSources.Single()); + public static async Task VerifyFixAsync(CodeFixVerifierNewArguments arguments) + where TAnalyzer : DiagnosticAnalyzer, new() + where TCodeFix : CodeFixProvider, new() + { + var test = new CSharpCodeFixTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages(arguments.PackageReferences.ToImmutableArray()), + ExpectedDiagnostics = { arguments.ExpectedDiagnostic }, + }; + foreach (var source in arguments.Sources) + { + test.TestState.Sources.Add(source); + } + foreach (var fixedSource in arguments.FixedSources) + { + test.FixedState.Sources.Add(fixedSource); + } + + // TODO: add support for diagnostics (merge test code-fixers with test analyzers). + await test.RunAsync(); + } + public static void VerifyNoFix(CodeFixVerifierArguments arguments) => VerifyNoFix(arguments, arguments.DiagnosticAnalyzers.Single(), arguments.CodeFixProviders.Single()); private static void VerifyNoFix(CsProjectArguments arguments, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider) @@ -274,20 +306,6 @@ private static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer #region Verifier wrappers - /// - /// Called to test a C# DiagnosticAnalyzer when applied on the single inputted string as a source - /// Note: input a DiagnosticResult for each Diagnostic expected - /// - /// A class in the form of a string to run the analyzer on - /// DiagnosticResults that should appear after the analyzer is run on the source - public static void VerifyCSharpDiagnostic(string source, params DiagnosticResult[] expected) where TDiagnosticAnalyzer : DiagnosticAnalyzer, new() - { - VerifyDiagnostic(new DiagnosticVerifierArguments() - .WithDiagnosticAnalyzer() - .WithSources(source) - .WithExpectedDiagnostics(expected)); - } - public static void VerifyDiagnostic(DiagnosticVerifierArguments arguments) { var project = CsProjectGenerator.CreateProject(arguments); @@ -297,7 +315,7 @@ public static void VerifyDiagnostic(DiagnosticVerifierArguments arguments) VerifyDiagnosticResults(diagnostics, arguments.DiagnosticAnalyzers.ToArray(), arguments.ExpectedDiagnostics.ToArray()); } - public static void VerifyCSharpDiagnosticUsingAllAnalyzers(string source, params DiagnosticResult[] expected) + public static void VerifyCSharpDiagnosticUsingAllAnalyzers(string source, params LegacyDiagnosticResult[] expected) { VerifyDiagnostic(new DiagnosticVerifierArguments() .WithAllAnalyzers() @@ -310,7 +328,7 @@ public static void VerifyCSharpDiagnosticUsingAllAnalyzers(string source, params #region Actual comparisons and verifications - private static void VerifyDiagnosticResults(IEnumerable actualResults, DiagnosticAnalyzer[] analyzers, params DiagnosticResult[] expectedResults) + private static void VerifyDiagnosticResults(IEnumerable actualResults, DiagnosticAnalyzer[] analyzers, params LegacyDiagnosticResult[] expectedResults) { int expectedCount = expectedResults.Length; int actualCount = actualResults.Count(); diff --git a/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifierArguments.cs b/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifierArguments.cs index e37052c..599da23 100644 --- a/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifierArguments.cs +++ b/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifierArguments.cs @@ -6,7 +6,7 @@ namespace FluentAssertions.Analyzers.Tests; public class DiagnosticVerifierArguments : CsProjectArguments { - public List ExpectedDiagnostics { get; } = new(); + public List ExpectedDiagnostics { get; } = new(); public List DiagnosticAnalyzers { get; } = new(); @@ -25,7 +25,7 @@ public DiagnosticVerifierArguments WithAllAnalyzers() return this; } - public DiagnosticVerifierArguments WithExpectedDiagnostics(params DiagnosticResult[] expectedDiagnostics) + public DiagnosticVerifierArguments WithExpectedDiagnostics(params LegacyDiagnosticResult[] expectedDiagnostics) { ExpectedDiagnostics.AddRange(expectedDiagnostics); return this; diff --git a/src/FluentAssertions.Analyzers.Tests/FluentAssertions.Analyzers.Tests.csproj b/src/FluentAssertions.Analyzers.Tests/FluentAssertions.Analyzers.Tests.csproj index f80a8a4..3ea0327 100644 --- a/src/FluentAssertions.Analyzers.Tests/FluentAssertions.Analyzers.Tests.csproj +++ b/src/FluentAssertions.Analyzers.Tests/FluentAssertions.Analyzers.Tests.csproj @@ -16,6 +16,8 @@ + + diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/AsyncVoidTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/AsyncVoidTests.cs index 59907a1..4253738 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/AsyncVoidTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/AsyncVoidTests.cs @@ -37,7 +37,7 @@ public void AssignAsyncVoidLambdaToAction_TestAnalyzer(string assertion) { var source = GenerateCode.AsyncFunctionStatement(assertion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = AsyncVoidAnalyzer.DiagnosticId, Message = AsyncVoidAnalyzer.Message, @@ -59,10 +59,7 @@ public void AssignAsyncVoidLambdaToAction_TestAnalyzer(string assertion) [NotImplemented] public void AssignAsyncVoidLambdaToAction_TestCodeFix(string oldAssertion, string newAssertion) { - var oldSource = GenerateCode.AsyncFunctionStatement(oldAssertion); - var newSource = GenerateCode.AsyncFunctionStatement(newAssertion); - - DiagnosticVerifier.VerifyCSharpFix(oldSource, newSource); + // no-op } } } diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs index f98b395..07057d6 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs @@ -1,6 +1,9 @@ using System.Text; +using System.Threading.Tasks; using FluentAssertions.Analyzers.TestUtils; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace FluentAssertions.Analyzers.Tests @@ -8,13 +11,16 @@ namespace FluentAssertions.Analyzers.Tests [TestClass] public class CollectionTests { - [DataTestMethod] - [AssertionDiagnostic("actual.Any().Should().BeTrue({0});")] - [AssertionDiagnostic("actual.AsEnumerable().Any().Should().BeTrue({0}).And.ToString();")] - [AssertionDiagnostic("actual.ToList().Any().Should().BeTrue({0}).And.ToString();")] - [AssertionDiagnostic("actual.ToArray().Any().Should().BeTrue({0}).And.ToString();")] - [Implemented] - public void ExpressionBodyAssertion_TestAnalyzer(string assertion) => VerifyCSharpDiagnosticExpressionBody(assertion, DiagnosticMetadata.CollectionShouldNotBeEmpty_AnyShouldBeTrue); + private static CodeFixVerifierNewArguments CreateCodeFixArguments(string source, string expected, DiagnosticMetadata metadata, LinePosition location) + => new CodeFixVerifierNewArguments(new DiagnosticResult(FluentAssertionsAnalyzer.DiagnosticId, DiagnosticSeverity.Info) + .WithMessage(metadata.Message) + .WithLocation(location) + ) + { + Sources = { source }, + FixedSources = { expected }, + + }.WithPackages(PackageReference.FluentAssertions_6_12_0); [DataTestMethod] [AssertionCodeFix( @@ -30,7 +36,15 @@ public class CollectionTests oldAssertion: "actual.ToArray().Any().Should().BeTrue({0}).And.ToString();", newAssertion: "actual.ToArray().Should().NotBeEmpty({0}).And.ToString();")] [Implemented] - public void ExpressionBodyAssertion_TestCodeFix(string oldAssertion, string newAssertion) => VerifyCSharpFixExpressionBody(oldAssertion, newAssertion); + public async Task ExpressionBodyAssertion_TestCodeFix(string oldAssertion, string newAssertion) + { + var oldSource = GenerateCode.GenericIListExpressionBodyAssertion(oldAssertion); + var newSource = GenerateCode.GenericIListExpressionBodyAssertion(newAssertion); + + var arguments = CreateCodeFixArguments(oldSource, newSource, DiagnosticMetadata.CollectionShouldNotBeEmpty_AnyShouldBeTrue, new LinePosition(9, 15)); + + await DiagnosticVerifier.VerifyFixAsync(arguments); + } [DataTestMethod] [AssertionDiagnostic("actual.Any().Should().BeTrue({0});")] @@ -634,7 +648,7 @@ public void CollectionShouldContainSingle_TestAnalyzer_GenericIEnumerableShouldR { var source = GenerateCode.GenericIEnumerableAssertion(assertion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = DiagnosticMetadata.CollectionShouldContainSingle_ShouldHaveCount1.Message, @@ -1023,7 +1037,7 @@ private void VerifyCSharpDiagnosticCodeBlock(string sourceAssertion, DiagnosticM { var source = GenerateCode.GenericIListCodeBlockAssertion(sourceAssertion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = metadata.Message, @@ -1040,7 +1054,7 @@ private void VerifyCSharpDiagnosticExpressionBody(string sourceAssertion, Diagno { var source = GenerateCode.GenericIListExpressionBodyAssertion(sourceAssertion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, VisitorName = metadata.Name, @@ -1057,7 +1071,7 @@ private void VerifyArrayCSharpDiagnosticCodeBlock(string sourceAssertion, Diagno { var source = GenerateCode.GenericArrayCodeBlockAssertion(sourceAssertion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = metadata.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/DictionaryTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/DictionaryTests.cs index ce5fb5b..9c685da 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/DictionaryTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/DictionaryTests.cs @@ -188,7 +188,7 @@ private void VerifyCSharpDiagnostic(string sourceAssersion, DiagnosticMetadata m { var source = GenerateCode.GenericIDictionaryAssertion(sourceAssersion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = metadata.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/ExceptionsTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/ExceptionsTests.cs index 668fd75..0dc9b08 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/ExceptionsTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/ExceptionsTests.cs @@ -283,7 +283,7 @@ private void VerifyCSharpDiagnostic(string sourceAssertion, DiagnosticMetadata m { var source = GenerateCode.ExceptionAssertion(sourceAssertion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = metadata.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/MsTestTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/MsTestTests.cs index e6ed475..1b165d7 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/MsTestTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/MsTestTests.cs @@ -1,13 +1,47 @@ using FluentAssertions.Analyzers.TestUtils; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Testing; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.Collections.Immutable; using System.Text; +using System.Threading.Tasks; namespace FluentAssertions.Analyzers.Tests.Tips { [TestClass] public class MsTestTests { + private class AllAnalyzersTest : AnalyzerTest + { + protected override string DefaultFileExt => "cs"; + public override string Language => LanguageNames.CSharp; + private readonly AnalyzerOptions analyzerOptions; + public AllAnalyzersTest(IDictionary analyzerConfigOptions = null) + { + analyzerOptions = analyzerConfigOptions != null ? new AnalyzerOptions(ImmutableArray.Empty, new TestAnalyzerConfigOptionsProvider(analyzerConfigOptions)) : null; + } + + protected override CompilationOptions CreateCompilationOptions() => new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true); + protected override ParseOptions CreateParseOptions() => new CSharpParseOptions(LanguageVersion.Latest, DocumentationMode.Diagnose); + protected override IEnumerable GetDiagnosticAnalyzers() => CodeAnalyzersUtils.GetAllAnalyzers(); + + protected override AnalyzerOptions GetAnalyzerOptions(Project project) => analyzerOptions ?? project.AnalyzerOptions; + } + + private class MsTestAnalyzerTest : Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerTest + { + private readonly AnalyzerOptions analyzerOptions; + public MsTestAnalyzerTest(IDictionary values = null) + { + analyzerOptions = values != null ? new AnalyzerOptions(ImmutableArray.Empty, new TestAnalyzerConfigOptionsProvider(values)) : null; + } + + protected override AnalyzerOptions GetAnalyzerOptions(Project project) => analyzerOptions; + } + [TestMethod] [Implemented] public void SupportExcludingMethods() @@ -866,7 +900,7 @@ private void VerifyCSharpDiagnostic(string source) .WithAllAnalyzers() .WithSources(source) .WithPackageReferences(PackageReference.FluentAssertions_6_12_0, PackageReference.MSTestTestFramework_3_1_1) - .WithExpectedDiagnostics(new DiagnosticResult + .WithExpectedDiagnostics(new LegacyDiagnosticResult { Id = AssertAnalyzer.MSTestsRule.Id, Message = AssertAnalyzer.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/NullConditionalAssertionTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/NullConditionalAssertionTests.cs index 457b203..583a0ec 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/NullConditionalAssertionTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/NullConditionalAssertionTests.cs @@ -22,7 +22,7 @@ public void NullConditionalMayNotExecuteTest(string assertion) .WithDiagnosticAnalyzer() .WithSources(Code(assertion)) .WithPackageReferences(PackageReference.FluentAssertions_6_12_0) - .WithExpectedDiagnostics(new DiagnosticResult + .WithExpectedDiagnostics(new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = DiagnosticMetadata.NullConditionalMayNotExecute.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/NumericTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/NumericTests.cs index f03d444..c1abda5 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/NumericTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/NumericTests.cs @@ -115,7 +115,7 @@ private void VerifyCSharpDiagnostic(string sourceAssertion, DiagnosticMetadata m .WithSources(source) .WithAllAnalyzers() .WithPackageReferences(PackageReference.FluentAssertions_6_12_0) - .WithExpectedDiagnostics(new DiagnosticResult + .WithExpectedDiagnostics(new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = metadata.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/NunitTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/NunitTests.cs index accdd80..7ad9022 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/NunitTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/NunitTests.cs @@ -1954,7 +1954,7 @@ private void VerifyDiagnostic(string source, PackageReference nunit) .WithAllAnalyzers() .WithSources(source) .WithPackageReferences(PackageReference.FluentAssertions_6_12_0, nunit) - .WithExpectedDiagnostics(new DiagnosticResult + .WithExpectedDiagnostics(new LegacyDiagnosticResult { Id = AssertAnalyzer.NUnitRule.Id, Message = AssertAnalyzer.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs index 9392530..0fbfe68 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs @@ -313,7 +313,7 @@ public static void True(bool input) .WithSources(source, globalUsings) .WithAllAnalyzers() .WithPackageReferences(PackageReference.XunitAssert_2_5_1, PackageReference.FluentAssertions_6_12_0) - .WithExpectedDiagnostics(new DiagnosticResult() + .WithExpectedDiagnostics(new LegacyDiagnosticResult() { Id = AssertAnalyzer.XunitRule.Id, Message = AssertAnalyzer.Message, @@ -360,7 +360,7 @@ public class TestType3 .WithSources(source) .WithAllAnalyzers() .WithPackageReferences(PackageReference.FluentAssertions_6_12_0) - .WithExpectedDiagnostics(new DiagnosticResult() + .WithExpectedDiagnostics(new LegacyDiagnosticResult() { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = DiagnosticMetadata.CollectionShouldNotBeEmpty_AnyShouldBeTrue.Message, @@ -439,7 +439,7 @@ public class MyCollectionType { }"; .WithSources(source) .WithAllAnalyzers() .WithPackageReferences(PackageReference.FluentAssertions_6_12_0) - .WithExpectedDiagnostics(new DiagnosticResult() + .WithExpectedDiagnostics(new LegacyDiagnosticResult() { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = DiagnosticMetadata.NullConditionalMayNotExecute.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/ShouldEqualsTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/ShouldEqualsTests.cs index 814344a..9b874f0 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/ShouldEqualsTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/ShouldEqualsTests.cs @@ -103,7 +103,7 @@ public void ShouldEquals_ShouldEqual_EnumerableType_TestCodeFix() private void VerifyCSharpDiagnosticExpressionBody(string sourceAssertion, int line, int column, DiagnosticMetadata metadata) { var source = GenerateCode.ObjectStatement(sourceAssertion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = metadata.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/StringTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/StringTests.cs index 0db386b..248a3c0 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/StringTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/StringTests.cs @@ -179,7 +179,7 @@ private void VerifyCSharpDiagnostic(string sourceAssertion, DiagnosticMetadata m { var source = GenerateCode.StringAssertion(sourceAssertion); - DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult + DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult { Id = FluentAssertionsAnalyzer.DiagnosticId, Message = metadata.Message, diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/XunitTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/XunitTests.cs index 26bc9fe..a6e7a5f 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/XunitTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/XunitTests.cs @@ -789,7 +789,7 @@ private void VerifyCSharpDiagnostic(string methodArguments, string assertion) .WithAllAnalyzers() .WithSources(source) .WithPackageReferences(PackageReference.FluentAssertions_6_12_0, PackageReference.XunitAssert_2_5_1) - .WithExpectedDiagnostics(new DiagnosticResult + .WithExpectedDiagnostics(new LegacyDiagnosticResult { Id = AssertAnalyzer.XunitRule.Id, Message = AssertAnalyzer.Message,