From 280b11ab84d8ee27827064f058d95a52c8b83a29 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 21 Jun 2023 08:41:22 -0500 Subject: [PATCH] Apply suggestions from code review --- .../OrderingRules/SA1212CSharp9UnitTests.cs | 16 +++++++--------- .../SA1212PropertyAccessorsMustFollowOrder.cs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1212CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1212CSharp9UnitTests.cs index 39837749c..9c0dfe925 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1212CSharp9UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1212CSharp9UnitTests.cs @@ -5,8 +5,8 @@ namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.CSharp8.OrderingRules; - using StyleCop.Analyzers.Test.Verifiers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1212PropertyAccessorsMustFollowOrder, @@ -30,13 +30,12 @@ public class Foo public int Prop { get; init; } }"; - var test = new CSharpTest + await new CSharpTest { TestCode = testCode, FixedCode = fixedCode, - ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50, - }; - await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); } [Fact] @@ -81,13 +80,12 @@ public int Prop } }"; - var test = new CSharpTest + await new CSharpTest { TestCode = testCode, FixedCode = fixedCode, - ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50, - }; - await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1212PropertyAccessorsMustFollowOrder.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1212PropertyAccessorsMustFollowOrder.cs index a4b135697..a2285c411 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1212PropertyAccessorsMustFollowOrder.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1212PropertyAccessorsMustFollowOrder.cs @@ -100,7 +100,7 @@ private static void AnalyzeProperty(SyntaxNodeAnalysisContext context, BasePrope return; } - if ((accessors[0].Kind() == SyntaxKind.SetAccessorDeclaration || accessors[0].Kind() == SyntaxKindEx.InitAccessorDeclaration) && + if ((accessors[0].Kind() is SyntaxKind.SetAccessorDeclaration or SyntaxKindEx.InitAccessorDeclaration) && accessors[1].Kind() == SyntaxKind.GetAccessorDeclaration) { context.ReportDiagnostic(Diagnostic.Create(Descriptor, accessors[0].GetLocation()));