From 49de46b84ca4904af92d02613ea36488ed08cfc3 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Thu, 30 May 2024 15:12:04 -0700 Subject: [PATCH] update codeanalysistestingversion --- eng/Versions.props | 2 +- .../CSharpCodeFixVerifier`2+Test.cs | 4 +- .../CSharpCodeRefactoringVerifier`1+Test.cs | 6 +-- ...sualBasicCodeRefactoringVerifier`1+Test.cs | 6 +-- .../ConvertToRecordCodeRefactoringTests.cs | 41 +++++++++---------- .../ExtractClass/ExtractClassTests.cs | 4 +- ...ateEqualsAndGetHashCodeFromMembersTests.cs | 4 +- .../CSharpMoveStaticMembersTests.cs | 4 +- .../VisualBasicMoveStaticMembersTests.vb | 4 +- 9 files changed, 37 insertions(+), 38 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 7b9c7fd7f9bf..0aeab092e26c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -21,7 +21,7 @@ 3.11.0-beta1.23364.2 8.0.0-preview.23468.1 - 1.1.2-beta1.23411.1 + 1.1.2-beta1.24121.1 0.1.149-beta 4.6.0 diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs index d922fc3b1909..f3934bf39b5f 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs @@ -113,16 +113,18 @@ protected override CodeFixContext CreateCodeFixContext(Document document, TextSp protected override FixAllContext CreateFixAllContext( Document? document, + TextSpan? diagnosticSpan, Project project, CodeFixProvider codeFixProvider, FixAllScope scope, string? codeActionEquivalenceKey, IEnumerable diagnosticIds, + DiagnosticSeverity minimumSeverity, FixAllContext.DiagnosticProvider fixAllDiagnosticProvider, CancellationToken cancellationToken) => new(new FixAllState( fixAllProvider: NoOpFixAllProvider.Instance, - diagnosticSpan: null, + diagnosticSpan, document, project, codeFixProvider, diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs index dfc35b2f0b11..5ca02b4218d0 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs @@ -124,14 +124,14 @@ protected override CodeRefactoringContext CreateCodeRefactoringContext(Document private static readonly TestComposition s_editorFeaturesOOPComposition = EditorTestCompositions.EditorFeatures.WithTestHostParts(TestHost.OutOfProcess); - protected override Workspace CreateWorkspaceImpl() + protected override Task CreateWorkspaceImplAsync() { if (TestHost == TestHost.InProcess) - return base.CreateWorkspaceImpl(); + return base.CreateWorkspaceImplAsync(); var hostServices = s_editorFeaturesOOPComposition.GetHostServices(); var workspace = new AdhocWorkspace(hostServices); - return workspace; + return Task.FromResult(workspace); } #endif } diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs index 0cb743d549b7..e58d76af99f7 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs @@ -110,14 +110,14 @@ protected override CodeRefactoringContext CreateCodeRefactoringContext(Document private static readonly TestComposition s_editorFeaturesOOPComposition = EditorTestCompositions.EditorFeatures.WithTestHostParts(TestHost.OutOfProcess); - protected override Workspace CreateWorkspaceImpl() + protected override Task CreateWorkspaceImplAsync() { if (TestHost == TestHost.InProcess) - return base.CreateWorkspaceImpl(); + return base.CreateWorkspaceImplAsync(); var hostServices = s_editorFeaturesOOPComposition.GetHostServices(); var workspace = new AdhocWorkspace(hostServices); - return workspace; + return Task.FromResult(workspace); } #endif diff --git a/src/Features/CSharpTest/ConvertToRecord/ConvertToRecordCodeRefactoringTests.cs b/src/Features/CSharpTest/ConvertToRecord/ConvertToRecordCodeRefactoringTests.cs index c2ca67d47ceb..e70a4355c64f 100644 --- a/src/Features/CSharpTest/ConvertToRecord/ConvertToRecordCodeRefactoringTests.cs +++ b/src/Features/CSharpTest/ConvertToRecord/ConvertToRecordCodeRefactoringTests.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.ServiceModel.Syndication; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CSharp; @@ -4542,37 +4543,23 @@ public class C : [|B|] #endregion - private static void AddSolutionTransform(List> solutionTransforms) - { - solutionTransforms.Add((solution, projectId) => - { - var project = solution.GetProject(projectId)!; - - var compilationOptions = (CSharpCompilationOptions)project.CompilationOptions!; - // enable nullable - compilationOptions = compilationOptions.WithNullableContextOptions(NullableContextOptions.Enable); - solution = solution - .WithProjectCompilationOptions(projectId, compilationOptions) - .WithProjectMetadataReferences(projectId, TargetFrameworkUtil.GetReferences(TargetFramework.Net60)); - - return solution; - }); - } - private class RefactoringTest : VerifyCSRefactoring.Test { public RefactoringTest() { + ReferenceAssemblies = ReferenceAssemblies.Net.Net60; LanguageVersion = LanguageVersion.CSharp10; - AddSolutionTransform(SolutionTransforms); MarkupOptions = MarkupOptions.UseFirstDescriptor; } - protected override Workspace CreateWorkspaceImpl() + protected override CompilationOptions CreateCompilationOptions() { - var workspace = new AdhocWorkspace(); + var compilationOptions = (CSharpCompilationOptions)base.CreateCompilationOptions(); + + // enable nullable + compilationOptions = compilationOptions.WithNullableContextOptions(NullableContextOptions.Enable); - return workspace; + return compilationOptions; } } @@ -4596,8 +4583,18 @@ private class CodeFixTest : { public CodeFixTest() { + ReferenceAssemblies = ReferenceAssemblies.Net.Net60; LanguageVersion = LanguageVersion.CSharp10; - AddSolutionTransform(SolutionTransforms); + } + + protected override CompilationOptions CreateCompilationOptions() + { + var compilationOptions = (CSharpCompilationOptions)base.CreateCompilationOptions(); + + // enable nullable + compilationOptions = compilationOptions.WithNullableContextOptions(NullableContextOptions.Enable); + + return compilationOptions; } } diff --git a/src/Features/CSharpTest/ExtractClass/ExtractClassTests.cs b/src/Features/CSharpTest/ExtractClass/ExtractClassTests.cs index 39d6de3921b3..bf0d50cbbb15 100644 --- a/src/Features/CSharpTest/ExtractClass/ExtractClassTests.cs +++ b/src/Features/CSharpTest/ExtractClass/ExtractClassTests.cs @@ -48,11 +48,11 @@ protected override IEnumerable GetCodeRefactoringProvid return SpecializedCollections.SingletonEnumerable(new CSharpExtractClassCodeRefactoringProvider(service)); } - protected override Workspace CreateWorkspaceImpl() + protected override Task CreateWorkspaceImplAsync() { var unusedCompilationOptions = new CSharpCompilationOptions(OutputKind.NetModule); var unusedParseOptions = new CSharpParseOptions(LanguageVersion.CSharp1); - return TestWorkspace.Create(WorkspaceKind, LanguageNames.CSharp, unusedCompilationOptions, unusedParseOptions); + return Task.FromResult(TestWorkspace.Create(WorkspaceKind, LanguageNames.CSharp, unusedCompilationOptions, unusedParseOptions)); } } diff --git a/src/Features/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs b/src/Features/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs index 7be8166e8a50..ad045d21d1c9 100644 --- a/src/Features/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs +++ b/src/Features/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs @@ -37,7 +37,7 @@ private class TestWithDialog : VerifyCS.Test public ImmutableArray MemberNames; public Action> OptionsCallback; - protected override Workspace CreateWorkspaceImpl() + protected override Task CreateWorkspaceImplAsync() { // If we're a dialog test, then mixin our mock and initialize its values to the ones the test asked for. var workspace = new AdhocWorkspace(s_composition.GetHostServices()); @@ -46,7 +46,7 @@ protected override Workspace CreateWorkspaceImpl() service.MemberNames = MemberNames; service.OptionsCallback = OptionsCallback; - return workspace; + return Task.FromResult(workspace); } } diff --git a/src/Features/CSharpTest/MoveStaticMembers/CSharpMoveStaticMembersTests.cs b/src/Features/CSharpTest/MoveStaticMembers/CSharpMoveStaticMembersTests.cs index c3fc3b44e03d..c4ec18b11129 100644 --- a/src/Features/CSharpTest/MoveStaticMembers/CSharpMoveStaticMembersTests.cs +++ b/src/Features/CSharpTest/MoveStaticMembers/CSharpMoveStaticMembersTests.cs @@ -3420,7 +3420,7 @@ public Test( private readonly bool _testPreselection; - protected override Workspace CreateWorkspaceImpl() + protected override Task CreateWorkspaceImplAsync() { var hostServices = s_testServices.GetHostServices(); @@ -3432,7 +3432,7 @@ protected override Workspace CreateWorkspaceImpl() testOptionsService.CreateNew = _createNew; testOptionsService.ExpectedPrecheckedMembers = _testPreselection ? _selection : ImmutableArray.Empty; - return workspace; + return Task.FromResult(workspace); } } diff --git a/src/Features/VisualBasicTest/MoveStaticMembers/VisualBasicMoveStaticMembersTests.vb b/src/Features/VisualBasicTest/MoveStaticMembers/VisualBasicMoveStaticMembersTests.vb index 72238c6d39c5..88f31223d1d0 100644 --- a/src/Features/VisualBasicTest/MoveStaticMembers/VisualBasicMoveStaticMembersTests.vb +++ b/src/Features/VisualBasicTest/MoveStaticMembers/VisualBasicMoveStaticMembersTests.vb @@ -3065,7 +3065,7 @@ End Namespace" Private ReadOnly _newType As Boolean - Protected Overrides Function CreateWorkspaceImpl() As Workspace + Protected Overrides Function CreateWorkspaceImplAsync() As Task(Of Workspace) Dim hostServices = s_testServices.GetHostServices() Dim workspace = New AdhocWorkspace(hostServices) Dim optionsService = DirectCast(workspace.Services.GetRequiredService(Of IMoveStaticMembersOptionsService)(), TestMoveStaticMembersService) @@ -3079,7 +3079,7 @@ End Namespace" End If optionsService.CreateNew = _newType - Return workspace + Return Task.FromResult(Of Workspace)(workspace) End Function End Class