diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 831d039b64..1f95b27bf6 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "3.0.0", + "version": "4.2.0", "commands": [ "dotnet-cake" ] diff --git a/.editorconfig b/.editorconfig index 4dfeb2b533..3a12f63c44 100644 --- a/.editorconfig +++ b/.editorconfig @@ -23,3 +23,8 @@ indent_size = 4 [*.{yml,yaml}] indent_size = 2 + +[tests/**/*.cs] +dotnet_diagnostic.RS1038.severity = none +dotnet_diagnostic.RS1041.severity = none +dotnet_diagnostic.RS1042.severity = none diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 103608c881..14aed7e897 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,6 @@ - -name: 'Build' +name: "Build" env: - DotNetVersion: "9.0.100-preview.6.24328.19" + DotNetVersion: "9.0.101" DotNetVersion2: "8.0.303" DotNetVersion3: "7.0.410" DotNetVersion4: "6.0.203" # This is the last version Mono supports. It is used for our Mono CI tests. @@ -19,7 +18,7 @@ on: - master - feature/* tags: - - '*' + - "*" workflow_dispatch: jobs: build: @@ -27,22 +26,14 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, windows-2022, macos-12] - name: 'Build' + os: [ubuntu-20.04, windows-2022, macos-13] + name: "Build" steps: - name: Checkout uses: actions/checkout@v2 with: - clean: 'false' - fetch-depth: '0' - - # TODO: Need to figure out the correct way to install mono on linux / mac - # Currently the latest image has mono 6.12 - # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md - # - name: 🔨 Use Mono ${{ env.MonoVersion }} SDK - # uses: maxim-lobanov/setup-xamarin@v1 - # with: - # mono-version: ${{ env.MonoVersion }} + clean: "false" + fetch-depth: "0" - name: Setup NuGet.exe uses: nuget/setup-nuget@v1 @@ -71,41 +62,41 @@ jobs: dotnet cake --configuration=Release --verbosity=Verbose --target=CI --publish-all --archive - name: ⬆ Publish Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 continue-on-error: true if: ${{ always() }} with: - name: 'logs - ${{ github.workflow }} ${{ matrix.os }}' - path: '${{ env.Artifacts }}/logs/' + name: "logs - ${{ github.workflow }} ${{ matrix.os }}" + path: "${{ env.Artifacts }}/logs/" - name: ⬆ Publish Packages - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 continue-on-error: true if: ${{ always() }} with: - name: 'packages' - path: '${{ env.Artifacts }}/package/' + name: "packages" + path: "${{ env.Artifacts }}/package/" - name: ⬆ Publish Deployment - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 continue-on-error: true if: ${{ always() }} with: - name: 'deployment' - path: '${{ env.Artifacts }}/deployment/' + name: "deployment" + path: "${{ env.Artifacts }}/deployment/" - name: ⬆ Publish NuGet - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 continue-on-error: true if: ${{ always() }} with: - name: 'nuget' - path: '${{ env.Artifacts }}/nuget/' + name: "nuget" + path: "${{ env.Artifacts }}/nuget/" - name: ⬆ Publish Scripts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 continue-on-error: true if: ${{ always() }} with: - name: 'scripts - ${{ matrix.os }}' - path: '${{ env.Artifacts }}/scripts/' + name: "scripts - ${{ matrix.os }}" + path: "${{ env.Artifacts }}/scripts/" diff --git a/.github/workflows/tests-net6.yml b/.github/workflows/tests-net6.yml index dd1abc62ab..b81ec771f6 100644 --- a/.github/workflows/tests-net6.yml +++ b/.github/workflows/tests-net6.yml @@ -1,7 +1,6 @@ - -name: 'Tests net6.0' +name: "Tests net6.0" env: - DotNetVersion: "9.0.100-preview.6.24328.19" + DotNetVersion: "9.0.101" DotNetVersion2: "8.0.303" DotNetVersion3: "7.0.410" DotNetVersion4: "6.0.203" # This is the last version Mono supports. It is used for our Mono CI tests. @@ -19,7 +18,7 @@ on: - master - feature/* tags: - - '*' + - "*" workflow_dispatch: jobs: build: @@ -27,25 +26,17 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, windows-2022, macos-12] + os: [ubuntu-20.04, windows-2022, macos-13] testProjects: - OmniSharp.MSBuild.Tests,OmniSharp.Roslyn.CSharp.Tests,OmniSharp.DotNetTest.Tests,OmniSharp.Cake.Tests - OmniSharp.Lsp.Tests,OmniSharp.Script.Tests,OmniSharp.Tests,OmniSharp.Stdio.Tests,OmniSharp.Http.Tests - name: 'Test' + name: "Test" steps: - name: Checkout uses: actions/checkout@v2 with: - clean: 'false' - fetch-depth: '0' - - # TODO: Need to figure out the correct way to install mono on linux / mac - # Currently the latest image has mono 6.12 - # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md - # - name: 🔨 Use Mono ${{ env.MonoVersion }} SDK - # uses: maxim-lobanov/setup-xamarin@v1 - # with: - # mono-version: ${{ env.MonoVersion }} + clean: "false" + fetch-depth: "0" - name: Setup NuGet.exe uses: nuget/setup-nuget@v1 @@ -82,9 +73,9 @@ jobs: TEST_PROJECT: ${{ matrix.testProjects }} - name: ⬆ Publish Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 continue-on-error: true if: ${{ always() }} with: - name: 'logs - ${{ github.workflow }} ${{ matrix.os }}' - path: '${{ env.Artifacts }}/logs/' + name: "logs - ${{ github.workflow }} ${{ matrix.os }}" + path: "${{ env.Artifacts }}/logs/" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 97ff146410..2a7e21de61 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,6 @@ - -name: 'Tests' +name: "Tests" env: - DotNetVersion: "9.0.100-preview.6.24328.19" + DotNetVersion: "9.0.101" DotNetVersion2: "8.0.303" DotNetVersion3: "7.0.410" DotNetVersion4: "6.0.203" # This is the last version Mono supports. It is used for our Mono CI tests. @@ -19,7 +18,7 @@ on: - master - feature/* tags: - - '*' + - "*" workflow_dispatch: jobs: build: @@ -27,25 +26,17 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, windows-2022, macos-12] + os: [ubuntu-20.04, windows-2022, macos-13] testProjects: - OmniSharp.MSBuild.Tests,OmniSharp.Roslyn.CSharp.Tests,OmniSharp.DotNetTest.Tests,OmniSharp.Cake.Tests - OmniSharp.Lsp.Tests,OmniSharp.Script.Tests,OmniSharp.Tests,OmniSharp.Stdio.Tests,OmniSharp.Http.Tests - name: 'Test' + name: "Test" steps: - name: Checkout uses: actions/checkout@v2 with: - clean: 'false' - fetch-depth: '0' - - # TODO: Need to figure out the correct way to install mono on linux / mac - # Currently the latest image has mono 6.12 - # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md - # - name: 🔨 Use Mono ${{ env.MonoVersion }} SDK - # uses: maxim-lobanov/setup-xamarin@v1 - # with: - # mono-version: ${{ env.MonoVersion }} + clean: "false" + fetch-depth: "0" - name: Setup NuGet.exe uses: nuget/setup-nuget@v1 @@ -82,9 +73,9 @@ jobs: TEST_PROJECT: ${{ matrix.testProjects }} - name: ⬆ Publish Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 continue-on-error: true if: ${{ always() }} with: - name: 'logs - ${{ github.workflow }} ${{ matrix.os }}' - path: '${{ env.Artifacts }}/logs/' + name: "logs - ${{ github.workflow }} ${{ matrix.os }}" + path: "${{ env.Artifacts }}/logs/" diff --git a/.pipelines/init.yml b/.pipelines/init.yml index a44c330558..4af3c00879 100644 --- a/.pipelines/init.yml +++ b/.pipelines/init.yml @@ -1,7 +1,7 @@ parameters: # Configuration: Release Verbosity: Normal - DotNetVersion: "8.0.201" + DotNetVersion: "8.0.303" CakeVersion: "1.1.0" NuGetVersion: "5.7.0" MonoVersion: "" diff --git a/Directory.Packages.props b/Directory.Packages.props index 35f2d16dd4..5977aa3523 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,8 +8,8 @@ 8.0.0 17.8.0 17.3.2 - 6.11.0-rc.110 - 4.12.0-1.24358.3 + 6.13.0-rc.95 + 4.13.0-3.24620.4 2.6.1 @@ -17,9 +17,9 @@ - + - + @@ -43,7 +43,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -88,7 +88,7 @@ - + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 395ed76d5d..8adb258226 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,7 +18,7 @@ resources: variables: Verbosity: Diagnostic DotNetVersion: "8.0.303" - CakeVersion: "3.0.0" + CakeVersion: "4.2.0" NuGetVersion: "6.5.0" GitVersionVersion: "5.0.1" MonoVersion: "6.12.0" @@ -91,7 +91,7 @@ stages: - job: macOS pool: - vmImage: "macos-12" + vmImage: "macos-13" dependsOn: GitVersion steps: - template: ./.pipelines/init.yml diff --git a/build.json b/build.json index 380e357bfc..ca061e1357 100644 --- a/build.json +++ b/build.json @@ -5,7 +5,7 @@ "6.0.203", "7.0.410", "8.0.303", - "9.0.100-preview.6.24328.19" + "9.0.101" ], "RequiredMonoVersion": "6.6.0", "DownloadURL": "https://roslynomnisharp.blob.core.windows.net/ext", diff --git a/global.json b/global.json index 7ec84ad344..419f2c3844 100644 --- a/global.json +++ b/global.json @@ -3,4 +3,4 @@ "version": "8.0.303", "rollForward": "latestMinor" } -} \ No newline at end of file +} diff --git a/src/OmniSharp.Abstractions/Configuration.cs b/src/OmniSharp.Abstractions/Configuration.cs index 3fd36a2469..6041f77589 100644 --- a/src/OmniSharp.Abstractions/Configuration.cs +++ b/src/OmniSharp.Abstractions/Configuration.cs @@ -4,7 +4,7 @@ internal static class Configuration { public static bool ZeroBasedIndices = false; - public const string RoslynVersion = "4.12.0.0"; + public const string RoslynVersion = "4.13.0.0"; public const string RoslynPublicKeyToken = "31bf3856ad364e35"; public readonly static string RoslynFeatures = GetRoslynAssemblyFullName("Microsoft.CodeAnalysis.Features"); diff --git a/src/OmniSharp.Host/WorkspaceInitializer.cs b/src/OmniSharp.Host/WorkspaceInitializer.cs index 273a213bdc..9d82116f46 100644 --- a/src/OmniSharp.Host/WorkspaceInitializer.cs +++ b/src/OmniSharp.Host/WorkspaceInitializer.cs @@ -1,6 +1,8 @@ using System; using System.Composition.Hosting; using System.Linq; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ImplementType; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Options; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -33,6 +35,7 @@ public static void Initialize(IServiceProvider serviceProvider, CompositionHost logger.LogDebug("Starting with OmniSharp options: {options}", options.CurrentValue); ProvideWorkspaceOptions(compositionHost, workspace, options, logger, omnisharpEnvironment); + ProvideFallbackAnalyzerConfigOptions(workspace, options, logger); // when configuration options change // run workspace options providers automatically @@ -40,6 +43,7 @@ public static void Initialize(IServiceProvider serviceProvider, CompositionHost { logger.LogDebug("OmniSharp options changed: {options}", options.CurrentValue); ProvideWorkspaceOptions(compositionHost, workspace, options, logger, omnisharpEnvironment); + ProvideFallbackAnalyzerConfigOptions(workspace, options, logger); }); var projectSystems = compositionHost.GetExports(); @@ -100,5 +104,53 @@ private static void ProvideWorkspaceOptions( } } } + + private static void ProvideFallbackAnalyzerConfigOptions( + OmniSharpWorkspace workspace, + IOptionsMonitor options, + ILogger logger) + { + logger.LogInformation($"Updating the solution's fallback AnalyzerConfigOptions."); + OmniSharpSolutionAnalyzerConfigOptionsUpdater.UpdateOptions(workspace, ToOmniSharpEditorConfigOptions(options.CurrentValue)); + } + + private static OmniSharpEditorConfigOptions ToOmniSharpEditorConfigOptions(OmniSharpOptions options) + { + var lineFormattingOptions = new OmniSharpLineFormattingOptions + { + NewLine = options.FormattingOptions.NewLine, + UseTabs = options.FormattingOptions.UseTabs, + TabSize = options.FormattingOptions.TabSize, + IndentationSize = options.FormattingOptions.IndentationSize, + }; + + var implementTypeOptions = new OmniSharpImplementTypeOptions + { + InsertionBehavior = ToOmniSharpInsertionBehavior(options.ImplementTypeOptions.InsertionBehavior), + PropertyGenerationBehavior = ToOmniSharpPropertyGenerationBehavior(options.ImplementTypeOptions.PropertyGenerationBehavior), + }; + + return new OmniSharpEditorConfigOptions + { + LineFormattingOptions = lineFormattingOptions, + ImplementTypeOptions = implementTypeOptions, + }; + + static OmniSharpImplementTypeInsertionBehavior ToOmniSharpInsertionBehavior(ImplementTypeInsertionBehavior insertionBehavior) + => insertionBehavior switch + { + ImplementTypeInsertionBehavior.WithOtherMembersOfTheSameKind => OmniSharpImplementTypeInsertionBehavior.WithOtherMembersOfTheSameKind, + ImplementTypeInsertionBehavior.AtTheEnd => OmniSharpImplementTypeInsertionBehavior.AtTheEnd, + _ => throw new ArgumentException(nameof(insertionBehavior)) + }; + + static OmniSharpImplementTypePropertyGenerationBehavior ToOmniSharpPropertyGenerationBehavior(ImplementTypePropertyGenerationBehavior propertyGenerationBehavior) + => propertyGenerationBehavior switch + { + ImplementTypePropertyGenerationBehavior.PreferThrowingProperties => OmniSharpImplementTypePropertyGenerationBehavior.PreferThrowingProperties, + ImplementTypePropertyGenerationBehavior.PreferAutoProperties => OmniSharpImplementTypePropertyGenerationBehavior.PreferAutoProperties, + _ => throw new ArgumentException(nameof(propertyGenerationBehavior)) + }; + } } } diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RunFixAllCodeActionService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RunFixAllCodeActionService.cs index 68999640df..a980ae73d6 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RunFixAllCodeActionService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RunFixAllCodeActionService.cs @@ -15,7 +15,6 @@ using OmniSharp.Abstractions.Models.V1.FixAll; using OmniSharp.Mef; using OmniSharp.Options; -using OmniSharp.Roslyn.CodeActions; using OmniSharp.Roslyn.CSharp.Services.Refactoring.V2; using OmniSharp.Roslyn.CSharp.Workers.Diagnostics; using OmniSharp.Services; @@ -140,8 +139,6 @@ private async Task FixSpecificDiagnosticIdAsync(Document document, str _logger.LogTrace("{0} is still present in the document. Getting fixes.", diagnosticId); - var codeActionOptions = CodeActionOptionsFactory.Create(Options); - CodeAction action = null; var context = OmniSharpCodeFixContextFactory.CreateCodeFixContext( document, @@ -154,7 +151,6 @@ private async Task FixSpecificDiagnosticIdAsync(Document document, str action = a; } }, - codeActionOptions, cancellationToken); await codeFixProvider.RegisterCodeFixesAsync(context).ConfigureAwait(false); @@ -176,7 +172,6 @@ private async Task FixSpecificDiagnosticIdAsync(Document document, str action?.EquivalenceKey, ImmutableArray.Create(diagnosticId), _fixAllDiagnosticProvider, - _ => codeActionOptions, cancellationToken); _logger.LogTrace("Finding FixAll fix for {0}.", diagnosticId); diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs index 7e6f996b54..b947c99de2 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs @@ -20,7 +20,6 @@ using OmniSharp.Models; using OmniSharp.Models.V2.CodeActions; using OmniSharp.Options; -using OmniSharp.Roslyn.CodeActions; using OmniSharp.Roslyn.CSharp.Helpers; using OmniSharp.Roslyn.CSharp.Services.Diagnostics; using OmniSharp.Roslyn.CSharp.Workers.Diagnostics; @@ -137,8 +136,6 @@ private async Task CollectCodeFixesActions(Document document, TextSpan span, Lis private async Task AppendFixesAsync(Document document, TextSpan span, IEnumerable diagnostics, List<(CodeAction CodeAction, string CodeActionKind)> codeActions) { - var codeActionOptions = CodeActionOptionsFactory.Create(Options); - foreach (var codeFixProvider in GetSortedCodeFixProviders(document)) { var fixableDiagnostics = diagnostics.Where(d => HasFix(codeFixProvider, d.Id)).ToImmutableArray(); @@ -150,7 +147,6 @@ private async Task AppendFixesAsync(Document document, TextSpan span, IEnumerabl span, fixableDiagnostics, (a, _) => codeActions.Add((a, CodeActionKind.QuickFix)), - codeActionOptions, CancellationToken.None); try @@ -184,7 +180,6 @@ private bool HasFix(CodeFixProvider codeFixProvider, string diagnosticId) private async Task CollectRefactoringActions(Document document, TextSpan span, List<(CodeAction CodeAction, string CodeActionKind)> codeActions) { - var codeActionOptions = CodeActionOptionsFactory.Create(Options); var availableRefactorings = OrderedCodeRefactoringProviders.Value; foreach (var codeRefactoringProvider in availableRefactorings) @@ -211,7 +206,6 @@ private async Task CollectRefactoringActions(Document document, TextSpan span, L } codeActions.Add((a, kind)); }, - codeActionOptions, CancellationToken.None); await codeRefactoringProvider.ComputeRefactoringsAsync(context); diff --git a/src/OmniSharp.Roslyn.CSharp/Workers/Refactoring/FixUsingsWorker.cs b/src/OmniSharp.Roslyn.CSharp/Workers/Refactoring/FixUsingsWorker.cs index c92d524a5f..0be3964fed 100644 --- a/src/OmniSharp.Roslyn.CSharp/Workers/Refactoring/FixUsingsWorker.cs +++ b/src/OmniSharp.Roslyn.CSharp/Workers/Refactoring/FixUsingsWorker.cs @@ -13,7 +13,6 @@ using Microsoft.CodeAnalysis.Text; using OmniSharp.Models; using OmniSharp.Options; -using OmniSharp.Roslyn.CodeActions; using OmniSharp.Roslyn.CSharp.Services.CodeActions; using OmniSharp.Services; @@ -246,7 +245,6 @@ private async Task> GetCodeFixOperationsAsyn var context = OmniSharpCodeFixContextFactory.CreateCodeFixContext( document, span, diagnostics, registerCodeFix: (a, d) => codeFixes.Add(a), - CodeActionOptionsFactory.Create(_options), cancellationToken: CancellationToken.None); // Note: We're intentionally not checking CodeFixProvider.FixableDiagnosticIds here. diff --git a/src/OmniSharp.Roslyn/Utilities/CodeActionOptionsFactory.cs b/src/OmniSharp.Roslyn/Utilities/CodeActionOptionsFactory.cs deleted file mode 100644 index 08887f1628..0000000000 --- a/src/OmniSharp.Roslyn/Utilities/CodeActionOptionsFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CodeActions; -using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ImplementType; -using OmniSharp.Options; - -namespace OmniSharp.Roslyn.CodeActions -{ - internal static class CodeActionOptionsFactory - { - public static OmniSharpCodeActionOptions Create(OmniSharpOptions options) - => new OmniSharpCodeActionOptions( - new OmniSharpImplementTypeOptions( - (OmniSharpImplementTypeInsertionBehavior)options.ImplementTypeOptions.InsertionBehavior, - (OmniSharpImplementTypePropertyGenerationBehavior)options.ImplementTypeOptions.PropertyGenerationBehavior), - OmniSharpLineFormattingOptionsProvider.CreateFromOptions(options)); - } -} diff --git a/src/OmniSharp.Roslyn/Utilities/ShadowCopyAnalyzerAssemblyLoader.cs b/src/OmniSharp.Roslyn/Utilities/ShadowCopyAnalyzerAssemblyLoader.cs index a1bfd24717..6a518e1233 100644 --- a/src/OmniSharp.Roslyn/Utilities/ShadowCopyAnalyzerAssemblyLoader.cs +++ b/src/OmniSharp.Roslyn/Utilities/ShadowCopyAnalyzerAssemblyLoader.cs @@ -5,6 +5,8 @@ namespace OmniSharp.Roslyn.Utilities { public static class ShadowCopyAnalyzerAssemblyLoader { - public static readonly IAnalyzerAssemblyLoader Instance = OmnisharpAnalyzerAssemblyLoaderFactory.CreateShadowCopyAnalyzerAssemblyLoader(); + public static readonly IAnalyzerAssemblyLoader Instance = CreateShadowCopyLoader(); + + public static IAnalyzerAssemblyLoader CreateShadowCopyLoader() => OmnisharpAnalyzerAssemblyLoaderFactory.CreateShadowCopyAnalyzerAssemblyLoader(); } } diff --git a/src/OmniSharp.Roslyn/WorkspaceServices/ExtractClassWorkspaceService.cs b/src/OmniSharp.Roslyn/WorkspaceServices/ExtractClassWorkspaceService.cs index eed75d08ab..279f777ab8 100644 --- a/src/OmniSharp.Roslyn/WorkspaceServices/ExtractClassWorkspaceService.cs +++ b/src/OmniSharp.Roslyn/WorkspaceServices/ExtractClassWorkspaceService.cs @@ -16,7 +16,7 @@ public ExtractClassWorkspaceService() { } - public Task GetExtractClassOptionsAsync(Document document, INamedTypeSymbol originalType, ImmutableArray selectedMembers) + public OmniSharpExtractClassOptions GetExtractClassOptions(Document document, INamedTypeSymbol originalType, ImmutableArray selectedMembers) { var symbolsToUse = selectedMembers.IsEmpty ? originalType.GetMembers().Where(member => member switch @@ -29,7 +29,7 @@ public Task GetExtractClassOptionsAsync(Document d var memberAnalysisResults = symbolsToUse.Select(m => new OmniSharpExtractClassMemberAnalysisResult(m, makeAbstract: false)).ToImmutableArray(); const string name = "NewBaseType"; - return Task.FromResult(new OmniSharpExtractClassOptions($"{name}.cs", name, true, memberAnalysisResults)); + return new OmniSharpExtractClassOptions($"{name}.cs", name, true, memberAnalysisResults); } } } diff --git a/src/OmniSharp.Roslyn/WorkspaceServices/ExtractInterfaceWorkspaceService.cs b/src/OmniSharp.Roslyn/WorkspaceServices/ExtractInterfaceWorkspaceService.cs index 113c6e36a5..4dd5825d4a 100644 --- a/src/OmniSharp.Roslyn/WorkspaceServices/ExtractInterfaceWorkspaceService.cs +++ b/src/OmniSharp.Roslyn/WorkspaceServices/ExtractInterfaceWorkspaceService.cs @@ -16,14 +16,14 @@ public ExtractInterfaceWorkspaceService() { } - public Task GetExtractInterfaceOptionsAsync(List extractableMembers, string defaultInterfaceName) + public OmniSharpExtractInterfaceOptionsResult GetExtractInterfaceOptions(List extractableMembers, string defaultInterfaceName) { - return Task.FromResult(new OmniSharpExtractInterfaceOptionsResult( + return new OmniSharpExtractInterfaceOptionsResult( isCancelled: false, extractableMembers.ToImmutableArray(), defaultInterfaceName, $"{defaultInterfaceName}.cs", - OmniSharpExtractInterfaceOptionsResult.OmniSharpExtractLocation.SameFile)); + OmniSharpExtractInterfaceOptionsResult.OmniSharpExtractLocation.SameFile); } } } diff --git a/src/OmniSharp.Roslyn/WorkspaceServices/NotificationWorkspaceService.cs b/src/OmniSharp.Roslyn/WorkspaceServices/NotificationWorkspaceService.cs new file mode 100644 index 0000000000..5ef1e023f8 --- /dev/null +++ b/src/OmniSharp.Roslyn/WorkspaceServices/NotificationWorkspaceService.cs @@ -0,0 +1,25 @@ +using System.Composition; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification; + +namespace OmniSharp +{ + [Shared] + [Export(typeof(IOmniSharpNotificationService))] + internal class NotificationWorkspaceService : IOmniSharpNotificationService + { + [ImportingConstructor] + public NotificationWorkspaceService() + { + } + + public bool ConfirmMessageBox(string message, string title = null, OmniSharpNotificationSeverity severity = OmniSharpNotificationSeverity.Warning) + { + return true; + } + + public void SendNotification(string message, string title = null, OmniSharpNotificationSeverity severity = OmniSharpNotificationSeverity.Warning) + { + return; + } + } +} diff --git a/src/OmniSharp.Script/ScriptProjectProvider.cs b/src/OmniSharp.Script/ScriptProjectProvider.cs index 5df64ab1db..3d577b76bb 100644 --- a/src/OmniSharp.Script/ScriptProjectProvider.cs +++ b/src/OmniSharp.Script/ScriptProjectProvider.cs @@ -25,7 +25,7 @@ public class ScriptProjectProvider private const string IgnoreCorLibraryDuplicatedTypesField = "IgnoreCorLibraryDuplicatedTypes"; private const string RuntimeMetadataReferenceResolverType = "Microsoft.CodeAnalysis.Scripting.Hosting.RuntimeMetadataReferenceResolver"; private const string ResolverField = "_resolver"; - private const string FileReferenceProviderField = "_fileReferenceProvider"; + private const string CreateFromFileFuncField = "_createFromFileFunc"; // aligned with CSI.exe // https://github.com/dotnet/roslyn/blob/version-3.2.0/src/Interactive/csi/csi.desktop.rsp @@ -248,8 +248,8 @@ private void InjectXMLDocumentationProviderIntoRuntimeMetadataReferenceResolver( if (runtimeMetadataReferenceResolverValue != null) { var runtimeMetadataReferenceResolverType = typeof(CommandLineScriptGlobals).GetTypeInfo().Assembly.GetType(RuntimeMetadataReferenceResolverType); - var fileReferenceProviderField = runtimeMetadataReferenceResolverType?.GetField(FileReferenceProviderField, BindingFlags.Instance | BindingFlags.NonPublic); - fileReferenceProviderField.SetValue(runtimeMetadataReferenceResolverValue, new Func((path, properties) => + var createFromFileFuncField = runtimeMetadataReferenceResolverType?.GetField(CreateFromFileFuncField, BindingFlags.Instance | BindingFlags.NonPublic); + createFromFileFuncField.SetValue(runtimeMetadataReferenceResolverValue, new Func((path, properties) => { var documentationFile = Path.ChangeExtension(path, ".xml"); var documentationProvider = File.Exists(documentationFile) diff --git a/test-assets/test-projects/AntlrGeneratedFiles/Test.csproj b/test-assets/test-projects/AntlrGeneratedFiles/Test.csproj index 1b5e60c302..33bf99bff7 100644 --- a/test-assets/test-projects/AntlrGeneratedFiles/Test.csproj +++ b/test-assets/test-projects/AntlrGeneratedFiles/Test.csproj @@ -1,7 +1,7 @@ Exe - netcoreapp2.0 + net6.0 @@ -16,4 +16,4 @@ - \ No newline at end of file + diff --git a/test-assets/test-projects/CSharpAndFSharp/csharp-console/csharp-console.csproj b/test-assets/test-projects/CSharpAndFSharp/csharp-console/csharp-console.csproj index af64f07386..4769beb54a 100644 --- a/test-assets/test-projects/CSharpAndFSharp/csharp-console/csharp-console.csproj +++ b/test-assets/test-projects/CSharpAndFSharp/csharp-console/csharp-console.csproj @@ -6,7 +6,7 @@ Exe - netcoreapp2.0 + net6.0 diff --git a/test-assets/test-projects/MSTestProject/MSTestProject.csproj b/test-assets/test-projects/MSTestProject/MSTestProject.csproj index 9b99d6a4f2..6cd6dc69e0 100644 --- a/test-assets/test-projects/MSTestProject/MSTestProject.csproj +++ b/test-assets/test-projects/MSTestProject/MSTestProject.csproj @@ -5,9 +5,9 @@ - - - + + + diff --git a/test-assets/test-projects/NUnitTestProject/NUnitTestProject.csproj b/test-assets/test-projects/NUnitTestProject/NUnitTestProject.csproj index f20d3a62b8..739e4e0620 100644 --- a/test-assets/test-projects/NUnitTestProject/NUnitTestProject.csproj +++ b/test-assets/test-projects/NUnitTestProject/NUnitTestProject.csproj @@ -5,9 +5,9 @@ - - - + + + diff --git a/test-assets/test-projects/Net80Project/global.json b/test-assets/test-projects/Net80Project/global.json index 4ce8f1ee66..7cc48a4e22 100644 --- a/test-assets/test-projects/Net80Project/global.json +++ b/test-assets/test-projects/Net80Project/global.json @@ -2,4 +2,4 @@ "sdk": { "version": "8.0.303" } -} \ No newline at end of file +} diff --git a/test-assets/test-projects/Net90Project/global.json b/test-assets/test-projects/Net90Project/global.json index d2da1deed6..5879450d69 100644 --- a/test-assets/test-projects/Net90Project/global.json +++ b/test-assets/test-projects/Net90Project/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "9.0.100-preview.6.24328.19" + "version": "9.0.101" } -} \ No newline at end of file +} diff --git a/test-assets/test-projects/ProjectWithSdkProperty/ProjectWithSdkProperty.csproj b/test-assets/test-projects/ProjectWithSdkProperty/ProjectWithSdkProperty.csproj index f5028bf9db..cda04dc701 100644 --- a/test-assets/test-projects/ProjectWithSdkProperty/ProjectWithSdkProperty.csproj +++ b/test-assets/test-projects/ProjectWithSdkProperty/ProjectWithSdkProperty.csproj @@ -2,6 +2,6 @@ Exe - netcoreapp2.0 + net6.0 - \ No newline at end of file + diff --git a/test-assets/test-projects/XunitTestProject/XunitTestProject.csproj b/test-assets/test-projects/XunitTestProject/XunitTestProject.csproj index 6992809036..dd9d983d46 100644 --- a/test-assets/test-projects/XunitTestProject/XunitTestProject.csproj +++ b/test-assets/test-projects/XunitTestProject/XunitTestProject.csproj @@ -5,9 +5,9 @@ - - - + + + diff --git a/tests/OmniSharp.DotNetTest.Tests/RunTestsInContextTests.cs b/tests/OmniSharp.DotNetTest.Tests/RunTestsInContextTests.cs index 0da017472c..4e9337d5ba 100644 --- a/tests/OmniSharp.DotNetTest.Tests/RunTestsInContextTests.cs +++ b/tests/OmniSharp.DotNetTest.Tests/RunTestsInContextTests.cs @@ -133,9 +133,9 @@ public async Task InvokeInTestBody(int line, int column, string projectName) [InlineData(12, 26, NUnitTestProject, 2)] [InlineData(13, 26, NUnitTestProject, 2)] - [InlineData(21, 28, MSTestProject, 3)] - [InlineData(17, 17, MSTestProject, 3)] - [InlineData(18, 17, MSTestProject, 3)] + [InlineData(21, 28, MSTestProject, 2)] + [InlineData(17, 17, MSTestProject, 2)] + [InlineData(18, 17, MSTestProject, 2)] public async Task InvokeParameterizedTest(int line, int column, string projectName, int expectedNumTests) { var response = await RunDotNetTestAsync( @@ -197,26 +197,26 @@ public async Task InvokeParameterizedTest(int line, int column, string projectNa [InlineData(76, 0, NUnitTestProject, 4)] // Class Header - [InlineData(6, 4, MSTestProject, 10)] - [InlineData(6, 13, MSTestProject, 10)] - [InlineData(6, 17, MSTestProject, 10)] - [InlineData(7, 0, MSTestProject, 10)] - [InlineData(7, 4, MSTestProject, 10)] + [InlineData(6, 4, MSTestProject, 8)] + [InlineData(6, 13, MSTestProject, 8)] + [InlineData(6, 17, MSTestProject, 8)] + [InlineData(7, 0, MSTestProject, 8)] + [InlineData(7, 4, MSTestProject, 8)] // Before [TestMethod] - [InlineData(10, 7, MSTestProject, 10)] + [InlineData(10, 7, MSTestProject, 8)] // After closing brace - [InlineData(14, 9, MSTestProject, 10)] + [InlineData(14, 9, MSTestProject, 8)] // Between test methods - [InlineData(15, 0, MSTestProject, 10)] + [InlineData(15, 0, MSTestProject, 8)] // In non-test method - [InlineData(54, 0, MSTestProject, 10)] + [InlineData(54, 0, MSTestProject, 8)] // In non-test method - [InlineData(63, 0, MSTestProject, 10)] + [InlineData(63, 0, MSTestProject, 8)] public async Task NoContainingMethodInvokesClass(int line, int column, string projectName, int expectedNumTests) { var response = await RunDotNetTestAsync( diff --git a/tests/OmniSharp.Lsp.Tests/OmniSharpSemanticTokensHandlerFacts.cs b/tests/OmniSharp.Lsp.Tests/OmniSharpSemanticTokensHandlerFacts.cs index 2326a0494e..4989f79a7c 100644 --- a/tests/OmniSharp.Lsp.Tests/OmniSharpSemanticTokensHandlerFacts.cs +++ b/tests/OmniSharp.Lsp.Tests/OmniSharpSemanticTokensHandlerFacts.cs @@ -1,19 +1,19 @@ using System; +using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Text; +using OmniSharp.Extensions.LanguageServer.Protocol.Client; +using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Lsp.Tests; -using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Models.SemanticHighlight; using OmniSharp.Models.V2; using TestUtility; using Xunit; using Xunit.Abstractions; using Range = OmniSharp.Models.V2.Range; -using System.Collections.Generic; -using System.IO; -using OmniSharp.Extensions.LanguageServer.Protocol.Client; namespace OmniSharp.Roslyn.CSharp.Tests { @@ -165,7 +165,7 @@ public async Task C2() { Operator("="), String("\"hello\""), Punctuation(";"), - Keyword("await"), + ControlKeyword("await"), ControlKeyword("foreach"), Punctuation("("), Keyword("var"), diff --git a/tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs b/tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs index 37c1cdc6d2..440304e278 100644 --- a/tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs +++ b/tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs @@ -16,13 +16,11 @@ public abstract class AbstractMSBuildTestFixture : AbstractTestFixture, IDisposa { private readonly IAssemblyLoader _assemblyLoader; private readonly IMSBuildLocator _msbuildLocator; - private readonly IAnalyzerAssemblyLoader _analyzerAssemblyLoader; public AbstractMSBuildTestFixture(ITestOutputHelper output) : base(output) { _assemblyLoader = new AssemblyLoader(this.LoggerFactory); - _analyzerAssemblyLoader = ShadowCopyAnalyzerAssemblyLoader.Instance; // Since we can only load MSBuild once into our process we need to include // prerelease version so that our .NET 7 tests will pass. @@ -47,7 +45,7 @@ protected OmniSharpTestHost CreateMSBuildTestHost(string path, IEnumerable GetResponse( diff --git a/tests/TestUtility/TestServiceProvider.cs b/tests/TestUtility/TestServiceProvider.cs index c14088dac5..b92cff1a09 100644 --- a/tests/TestUtility/TestServiceProvider.cs +++ b/tests/TestUtility/TestServiceProvider.cs @@ -87,7 +87,7 @@ public static IServiceProvider Create( var configuration = CreateConfiguration(configurationData); var msbuildLocator = CreateMSBuildLocator(loggerFactory, assemblyLoader, configurationData); var sharedTextWriter = CreateSharedTextWriter(testOutput); - var analyzerAssemblyLoader = ShadowCopyAnalyzerAssemblyLoader.Instance; + var analyzerAssemblyLoader = ShadowCopyAnalyzerAssemblyLoader.CreateShadowCopyLoader(); return new TestServiceProvider( environment, loggerFactory, assemblyLoader, analyzerAssemblyLoader, sharedTextWriter, diff --git a/tools/packages.config b/tools/packages.config index ce93b9a314..47b4bec102 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,7 +1,7 @@ - +