From c7203c29feaa27d9600eefaa16f124c8d2d88634 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 13:25:57 -0700 Subject: [PATCH 01/18] Add Microsoft.CodeAnalysis.ExternalAccess.OmniSharp package. (cherry picked from commit 979231a6a92278e9135618190b06e57c1b8f4cf4) --- Roslyn.sln | 14 ++++++ eng/config/PublishData.json | 4 +- ...rosoft.CodeAnalysis.CSharp.Features.csproj | 3 +- .../Microsoft.CodeAnalysis.Features.csproj | 2 + ...sis.ExternalAccess.OmniSharp.CSharp.csproj | 45 +++++++++++++++++++ .../OmniSharp.CSharp/PublicAPI.Shipped.txt | 0 .../OmniSharp.CSharp/PublicAPI.Unshipped.txt | 1 + ...deAnalysis.ExternalAccess.OmniSharp.csproj | 45 +++++++++++++++++++ .../Microsoft.CodeAnalysis.Workspaces.csproj | 2 + 9 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 src/Tools/ExternalAccess/OmniSharp.CSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj create mode 100644 src/Tools/ExternalAccess/OmniSharp.CSharp/PublicAPI.Shipped.txt create mode 100644 src/Tools/ExternalAccess/OmniSharp.CSharp/PublicAPI.Unshipped.txt create mode 100644 src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj diff --git a/Roslyn.sln b/Roslyn.sln index 303f630b773cb..e2e09fc05cbf6 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -489,6 +489,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Rebu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests", "src\Tools\ExternalAccess\RazorTest\Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests.csproj", "{BB987FFC-B758-4F73-96A3-923DE8DCFF1A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp", "src\Tools\ExternalAccess\OmniSharp\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj", "{1B73FB08-9A17-497E-97C5-FA312867D51B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp", "src\Tools\ExternalAccess\OmniSharp.CSharp\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj", "{AE976DE9-811D-4C86-AEBB-DCDC1226D754}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 @@ -1272,6 +1276,14 @@ Global {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Release|Any CPU.Build.0 = Release|Any CPU + {1B73FB08-9A17-497E-97C5-FA312867D51B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B73FB08-9A17-497E-97C5-FA312867D51B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1B73FB08-9A17-497E-97C5-FA312867D51B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1B73FB08-9A17-497E-97C5-FA312867D51B}.Release|Any CPU.Build.0 = Release|Any CPU + {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1495,6 +1507,8 @@ Global {B7D29559-4360-434A-B9B9-2C0612287999} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {21B49277-E55A-45EF-8818-744BCD6CB732} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {BB987FFC-B758-4F73-96A3-923DE8DCFF1A} = {8977A560-45C2-4EC2-A849-97335B382C74} + {1B73FB08-9A17-497E-97C5-FA312867D51B} = {8977A560-45C2-4EC2-A849-97335B382C74} + {AE976DE9-811D-4C86-AEBB-DCDC1226D754} = {8977A560-45C2-4EC2-A849-97335B382C74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29} diff --git a/eng/config/PublishData.json b/eng/config/PublishData.json index 0936de7f4023b..07769aa046fbf 100644 --- a/eng/config/PublishData.json +++ b/eng/config/PublishData.json @@ -48,6 +48,7 @@ "Microsoft.CodeAnalysis.ExternalAccess.FSharp": "vs-impl", "Microsoft.CodeAnalysis.ExternalAccess.IntelliTrace": "vs-impl", "Microsoft.CodeAnalysis.ExternalAccess.ProjectSystem": "vs-impl", + "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp": "arcade", "Microsoft.CodeAnalysis.ExternalAccess.Razor": "vs-impl", "Microsoft.CodeAnalysis.ExternalAccess.TypeScript": "vs-impl", "Microsoft.CodeAnalysis.ExternalAccess.UnitTesting": "vs-impl", @@ -103,6 +104,7 @@ "Microsoft.CodeAnalysis.ExternalAccess.FSharp": "arcade", "Microsoft.CodeAnalysis.ExternalAccess.IntelliTrace": "arcade", "Microsoft.CodeAnalysis.ExternalAccess.ProjectSystem": "arcade", + "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp": "arcade", "Microsoft.CodeAnalysis.ExternalAccess.Razor": "arcade", "Microsoft.CodeAnalysis.ExternalAccess.TypeScript": "arcade", "Microsoft.CodeAnalysis.ExternalAccess.UnitTesting": "arcade", @@ -292,4 +294,4 @@ "channels": [] } } -} \ No newline at end of file +} diff --git a/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj b/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj index 47d616b13cae2..6fe8f3304f2ae 100644 --- a/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj +++ b/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj @@ -26,6 +26,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Tools/ExternalAccess/OmniSharp.CSharp/PublicAPI.Shipped.txt b/src/Tools/ExternalAccess/OmniSharp.CSharp/PublicAPI.Shipped.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Tools/ExternalAccess/OmniSharp.CSharp/PublicAPI.Unshipped.txt b/src/Tools/ExternalAccess/OmniSharp.CSharp/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp.CSharp/PublicAPI.Unshipped.txt @@ -0,0 +1 @@ + diff --git a/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj b/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj new file mode 100644 index 0000000000000..7e6f6352fade1 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj @@ -0,0 +1,45 @@ + + + + netstandard2.0 + + true + Microsoft.CodeAnalysis.ExternalAccess.OmniSharp + + A supporting package for OmniSharp: + https://github.com/OmniSharp/omnisharp-roslyn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index 88a57c943ccb0..ff7df6fcbc602 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -118,6 +118,8 @@ + + From d6b59a248d10160034f96c5a86eb2b4a77b53eb0 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 13:44:15 -0700 Subject: [PATCH 02/18] Add OmniSharpBlockStructureService and supporting types. (cherry picked from commit 4ffbfe4dc6b147fb3e603660552efc990ecfe283) --- .../OmniSharp/PublicAPI.Shipped.txt | 0 .../OmniSharp/PublicAPI.Unshipped.txt | 1 + .../OmniSharp/Structure/OmniSharpBlockSpan.cs | 72 +++++++++++++++++++ .../Structure/OmniSharpBlockStructure.cs | 20 ++++++ .../OmniSharpBlockStructureOptions.cs | 19 +++++ .../OmniSharpBlockStructureService.cs | 30 ++++++++ .../Structure/OmniSharpBlockTypes.cs | 33 +++++++++ 7 files changed, 175 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/PublicAPI.Shipped.txt create mode 100644 src/Tools/ExternalAccess/OmniSharp/PublicAPI.Unshipped.txt create mode 100644 src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockSpan.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructure.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructureOptions.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructureService.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockTypes.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/PublicAPI.Shipped.txt b/src/Tools/ExternalAccess/OmniSharp/PublicAPI.Shipped.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Tools/ExternalAccess/OmniSharp/PublicAPI.Unshipped.txt b/src/Tools/ExternalAccess/OmniSharp/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/PublicAPI.Unshipped.txt @@ -0,0 +1 @@ + diff --git a/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockSpan.cs b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockSpan.cs new file mode 100644 index 0000000000000..5489df595309c --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockSpan.cs @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure +{ + internal readonly struct OmniSharpBlockSpan + { + private const string Ellipses = "..."; + + /// + /// Whether or not this span can be collapsed. + /// + public bool IsCollapsible { get; } + + /// + /// The span of text to collapse. + /// + public TextSpan TextSpan { get; } + + /// + /// The span of text to display in the hint on mouse hover. + /// + public TextSpan HintSpan { get; } + + /// + /// The text to display inside the collapsed region. + /// + public string BannerText { get; } + + /// + /// Whether or not this region should be automatically collapsed when the 'Collapse to Definitions' command is invoked. + /// + public bool AutoCollapse { get; } + + /// + /// Whether this region should be collapsed by default when a file is opened the first time. + /// + public bool IsDefaultCollapsed { get; } + + public string Type { get; } + + public OmniSharpBlockSpan( + string type, bool isCollapsible, TextSpan textSpan, string bannerText = Ellipses, bool autoCollapse = false, bool isDefaultCollapsed = false) + : this(type, isCollapsible, textSpan, textSpan, bannerText, autoCollapse, isDefaultCollapsed) + { + } + + public OmniSharpBlockSpan( + string type, bool isCollapsible, TextSpan textSpan, TextSpan hintSpan, string bannerText = Ellipses, bool autoCollapse = false, bool isDefaultCollapsed = false) + { + TextSpan = textSpan; + BannerText = bannerText; + HintSpan = hintSpan; + AutoCollapse = autoCollapse; + IsDefaultCollapsed = isDefaultCollapsed; + IsCollapsible = isCollapsible; + Type = type; + } + + public override string ToString() + { + return this.TextSpan != this.HintSpan + ? $"{{Span={TextSpan}, HintSpan={HintSpan}, BannerText=\"{BannerText}\", AutoCollapse={AutoCollapse}, IsDefaultCollapsed={IsDefaultCollapsed}}}" + : $"{{Span={TextSpan}, BannerText=\"{BannerText}\", AutoCollapse={AutoCollapse}, IsDefaultCollapsed={IsDefaultCollapsed}}}"; + } + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructure.cs b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructure.cs new file mode 100644 index 0000000000000..688dae9307494 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructure.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using System.Collections.Immutable; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure +{ + internal sealed class OmniSharpBlockStructure + { + public ImmutableArray Spans { get; } + + public OmniSharpBlockStructure(ImmutableArray spans) + { + Spans = spans; + } + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructureOptions.cs b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructureOptions.cs new file mode 100644 index 0000000000000..e2ea39bb9534c --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructureOptions.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Structure; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure +{ + internal static class OmniSharpBlockStructureOptions + { + public static readonly PerLanguageOption ShowBlockStructureGuidesForCommentsAndPreprocessorRegions = (PerLanguageOption)BlockStructureOptions.ShowBlockStructureGuidesForCommentsAndPreprocessorRegions; + + public static readonly PerLanguageOption ShowOutliningForCommentsAndPreprocessorRegions = (PerLanguageOption)BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions; + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructureService.cs b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructureService.cs new file mode 100644 index 0000000000000..7b56f4a38cf46 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockStructureService.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Structure; +using Microsoft.CodeAnalysis.Shared.Extensions; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure +{ + internal static class OmniSharpBlockStructureService + { + public static async Task GetBlockStructureAsync(Document document, CancellationToken cancellationToken) + { + var service = document.GetRequiredLanguageService(); + var blockStructure = await service.GetBlockStructureAsync(document, cancellationToken).ConfigureAwait(false); + if (blockStructure != null) + { + return new OmniSharpBlockStructure(blockStructure.Spans.SelectAsArray(x => new OmniSharpBlockSpan(x.Type, x.IsCollapsible, x.TextSpan, x.HintSpan, x.BannerText, x.AutoCollapse, x.IsDefaultCollapsed))); + } + else + { + return null; + } + } + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockTypes.cs b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockTypes.cs new file mode 100644 index 0000000000000..c738d35e77385 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Structure/OmniSharpBlockTypes.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using Microsoft.CodeAnalysis.Structure; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure +{ + internal static class OmniSharpBlockTypes + { + // Basic types. + public static string Nonstructural => BlockTypes.Nonstructural; + + // Trivstatic + public static string Comment => BlockTypes.Comment; + public static string PreprocessorRegion => BlockTypes.PreprocessorRegion; + + // Top static declarations. + public static string Imports => BlockTypes.Imports; + public static string Namespace => BlockTypes.Namespace; + public static string Type => BlockTypes.Type; + public static string Member => BlockTypes.Member; + + // Statstatic and expressions. + public static string Statement => BlockTypes.Statement; + public static string Conditional => BlockTypes.Conditional; + public static string Loop => BlockTypes.Loop; + + public static string Expression => BlockTypes.Expression; + } +} From 5a08faa5a363e6b9006f5362d9579f600db77e5f Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 13:55:07 -0700 Subject: [PATCH 03/18] Add IOmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService (cherry picked from commit 253846b3979510b20eb8316dc2ccc0c07e3ee1a6) --- ...eActionOperationFactoryWorkspaceService.cs | 15 +++++++++ ...eActionOperationFactoryWorkspaceService.cs | 32 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/CodeRefactorings/WorkspaceServices/IOmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/Internal/CodeRefactorings/WorkspaceServices/OmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/CodeRefactorings/WorkspaceServices/IOmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs b/src/Tools/ExternalAccess/OmniSharp/CodeRefactorings/WorkspaceServices/IOmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs new file mode 100644 index 0000000000000..6172afce6fe85 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/CodeRefactorings/WorkspaceServices/IOmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using Microsoft.CodeAnalysis.CodeActions; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CodeRefactorings.WorkspaceServices +{ + interface IOmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService + { + CodeActionOperation CreateSymbolRenamedOperation(ISymbol symbol, string newName, Solution startingSolution, Solution updatedSolution); + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Internal/CodeRefactorings/WorkspaceServices/OmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs b/src/Tools/ExternalAccess/OmniSharp/Internal/CodeRefactorings/WorkspaceServices/OmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs new file mode 100644 index 0000000000000..6b441873fb405 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Internal/CodeRefactorings/WorkspaceServices/OmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Composition; +using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeActions.WorkspaceServices; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CodeRefactorings.WorkspaceServices; +using Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Internal.CodeRefactorings.WorkspaceServices +{ + [Shared] + [ExportWorkspaceService(typeof(ISymbolRenamedCodeActionOperationFactoryWorkspaceService))] + class OmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService : ISymbolRenamedCodeActionOperationFactoryWorkspaceService + { + private readonly IOmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService _service; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public OmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService(IOmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService service) + { + _service = service; + } + + public CodeActionOperation CreateSymbolRenamedOperation(ISymbol symbol, string newName, Solution startingSolution, Solution updatedSolution) + { + return _service.CreateSymbolRenamedOperation(symbol, newName, startingSolution, updatedSolution); + } + } +} From 85140eedeb054edbf501eb5d590ef6e4c4d474ba Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 14:11:46 -0700 Subject: [PATCH 04/18] Add OmniSharpPickMembersService (cherry picked from commit af971c02664e047c858f7fbeb65108c733d98893) --- .../OmniSharpPickMembersService.cs | 33 +++++++++++++ .../IOmniSharpPickMembersService.cs | 48 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/Internal/PickMembers/OmniSharpPickMembersService.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/PickMembers/IOmniSharpPickMembersService.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/Internal/PickMembers/OmniSharpPickMembersService.cs b/src/Tools/ExternalAccess/OmniSharp/Internal/PickMembers/OmniSharpPickMembersService.cs new file mode 100644 index 0000000000000..eb509d9ee8ddc --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Internal/PickMembers/OmniSharpPickMembersService.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Immutable; +using System.Composition; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.PickMembers; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.PickMembers; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Internal.PickMembers +{ + [Shared] + [ExportWorkspaceService(typeof(IPickMembersService), ServiceLayer.Host)] + internal class OmniSharpPickMembersService : IPickMembersService + { + private readonly IOmniSharpPickMembersService _omniSharpPickMembersService; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public OmniSharpPickMembersService(IOmniSharpPickMembersService omniSharpPickMembersService) + { + _omniSharpPickMembersService = omniSharpPickMembersService; + } + + public PickMembersResult PickMembers(string title, ImmutableArray members, ImmutableArray options = default, bool selectAll = true) + { + var result = _omniSharpPickMembersService.PickMembers(title, members, options.SelectAsArray(o => new OmniSharpPickMembersOption(o)), selectAll); + return new(result.Members, result.Options.SelectAsArray(o => o.PickMembersOptionInternal), result.SelectedAll); + } + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/PickMembers/IOmniSharpPickMembersService.cs b/src/Tools/ExternalAccess/OmniSharp/PickMembers/IOmniSharpPickMembersService.cs new file mode 100644 index 0000000000000..0ffe5cf8e6e2e --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/PickMembers/IOmniSharpPickMembersService.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.PickMembers; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.PickMembers +{ + internal interface IOmniSharpPickMembersService + { + OmniSharpPickMembersResult PickMembers( + string title, ImmutableArray members, + ImmutableArray options = default, + bool selectAll = true); + } + + internal class OmniSharpPickMembersOption + { + internal readonly PickMembersOption PickMembersOptionInternal; + + internal OmniSharpPickMembersOption(PickMembersOption pickMembersOption) + { + PickMembersOptionInternal = pickMembersOption; + } + + public string Id => PickMembersOptionInternal.Id; + public string Title => PickMembersOptionInternal.Title; + public bool Value { get => PickMembersOptionInternal.Value; set => PickMembersOptionInternal.Value = value; } + } + + internal class OmniSharpPickMembersResult + { + public readonly ImmutableArray Members; + public readonly ImmutableArray Options; + public readonly bool SelectedAll; + + public OmniSharpPickMembersResult( + ImmutableArray members, + ImmutableArray options, + bool selectedAll) + { + Members = members; + Options = options; + SelectedAll = selectedAll; + } + } +} From 747e4e6eb51a10fce9253cb427ddb18135b0c455 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 14:22:52 -0700 Subject: [PATCH 05/18] Add OmniSharpExtractClassOptionsService (cherry picked from commit ef9956d3dba53fe431d0a31d89b82ba43d4368cb) --- .../IOmniSharpExtractClassOptionsService.cs | 54 +++++++++++++++++++ .../OmniSharpExtractClassOptionsService.cs | 39 ++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/ExtractClass/IOmniSharpExtractClassOptionsService.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/Internal/ExtractClass/OmniSharpExtractClassOptionsService.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/ExtractClass/IOmniSharpExtractClassOptionsService.cs b/src/Tools/ExternalAccess/OmniSharp/ExtractClass/IOmniSharpExtractClassOptionsService.cs new file mode 100644 index 0000000000000..54faf1aea3097 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/ExtractClass/IOmniSharpExtractClassOptionsService.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Immutable; +using System.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ExtractClass +{ + internal interface IOmniSharpExtractClassOptionsService + { + Task GetExtractClassOptionsAsync(Document document, INamedTypeSymbol originalType, ISymbol? selectedMember); + } + + internal sealed class OmniSharpExtractClassOptions + { + public string FileName { get; } + public string TypeName { get; } + public bool SameFile { get; } + public ImmutableArray MemberAnalysisResults { get; } + + public OmniSharpExtractClassOptions( + string fileName, + string typeName, + bool sameFile, + ImmutableArray memberAnalysisResults) + { + FileName = fileName; + TypeName = typeName; + SameFile = sameFile; + MemberAnalysisResults = memberAnalysisResults; + } + } + internal sealed class OmniSharpExtractClassMemberAnalysisResult + { + /// + /// The member needs to be pulled up. + /// + public ISymbol Member { get; } + + /// + /// Whether to make the member abstract when added to the new class + /// + public bool MakeAbstract { get; } + + public OmniSharpExtractClassMemberAnalysisResult( + ISymbol member, + bool makeAbstract) + { + Member = member; + MakeAbstract = makeAbstract; + } + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Internal/ExtractClass/OmniSharpExtractClassOptionsService.cs b/src/Tools/ExternalAccess/OmniSharp/Internal/ExtractClass/OmniSharpExtractClassOptionsService.cs new file mode 100644 index 0000000000000..a60eda3cfa1d3 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Internal/ExtractClass/OmniSharpExtractClassOptionsService.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Composition; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ExtractClass; +using Microsoft.CodeAnalysis.ExtractClass; +using Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Internal.ExtractClass +{ + [Shared] + [ExportWorkspaceService(typeof(IExtractClassOptionsService))] + internal class OmniSharpExtractClassOptionsService : IExtractClassOptionsService + { + private readonly IOmniSharpExtractClassOptionsService _omniSharpExtractClassOptionsService; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public OmniSharpExtractClassOptionsService(IOmniSharpExtractClassOptionsService omniSharpExtractClassOptionsService) + { + _omniSharpExtractClassOptionsService = omniSharpExtractClassOptionsService; + } + + public async Task GetExtractClassOptionsAsync(Document document, INamedTypeSymbol originalType, ISymbol? selectedMember) + { + var result = await _omniSharpExtractClassOptionsService.GetExtractClassOptionsAsync(document, originalType, selectedMember).ConfigureAwait(false); + return result == null + ? null + : new ExtractClassOptions( + result.FileName, + result.TypeName, + result.SameFile, + result.MemberAnalysisResults.SelectAsArray(m => new ExtractClassMemberAnalysisResult(m.Member, m.MakeAbstract))); + } + } +} From c88cfaf51f744f35683fb6d7b945a81ebc01bc1d Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 14:44:29 -0700 Subject: [PATCH 06/18] Add OmniSharpExtractInterfaceOptionsService (cherry picked from commit 318d1d8a24e3c7092fde96dbb3161389d31d7409) --- ...OmniSharpExtractInterfaceOptionsService.cs | 42 +++++++++++++++++++ ...OmniSharpExtractInterfaceOptionsService.cs | 42 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/ExtractInterface/IOmniSharpExtractInterfaceOptionsService.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/Internal/ExtractInterface/OmniSharpExtractInterfaceOptionsService.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/ExtractInterface/IOmniSharpExtractInterfaceOptionsService.cs b/src/Tools/ExternalAccess/OmniSharp/ExtractInterface/IOmniSharpExtractInterfaceOptionsService.cs new file mode 100644 index 0000000000000..b0d0a1fcdcc3d --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/ExtractInterface/IOmniSharpExtractInterfaceOptionsService.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ExtractInterface +{ + internal interface IOmniSharpExtractInterfaceOptionsService + { + // OmniSharp only uses these two arguments from the full IExtractInterfaceOptionsService + Task GetExtractInterfaceOptionsAsync( + List extractableMembers, + string defaultInterfaceName); + } + + internal class OmniSharpExtractInterfaceOptionsResult + { + public enum OmniSharpExtractLocation + { + SameFile, + NewFile + } + + public bool IsCancelled { get; } + public ImmutableArray IncludedMembers { get; } + public string InterfaceName { get; } + public string FileName { get; } + public OmniSharpExtractLocation Location { get; } + + public OmniSharpExtractInterfaceOptionsResult(bool isCancelled, ImmutableArray includedMembers, string interfaceName, string fileName, OmniSharpExtractLocation location) + { + IsCancelled = isCancelled; + IncludedMembers = includedMembers; + InterfaceName = interfaceName; + Location = location; + FileName = fileName; + } + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Internal/ExtractInterface/OmniSharpExtractInterfaceOptionsService.cs b/src/Tools/ExternalAccess/OmniSharp/Internal/ExtractInterface/OmniSharpExtractInterfaceOptionsService.cs new file mode 100644 index 0000000000000..ffcb263fbf3d4 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Internal/ExtractInterface/OmniSharpExtractInterfaceOptionsService.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Composition; +using System.Text; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ExtractInterface; +using Microsoft.CodeAnalysis.ExtractInterface; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.LanguageServices; +using Microsoft.CodeAnalysis.Notification; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Internal.ExtractInterface +{ + [Shared] + [ExportWorkspaceService(typeof(IExtractInterfaceOptionsService))] + internal class OmniSharpExtractInterfaceOptionsService : IExtractInterfaceOptionsService + { + private readonly IOmniSharpExtractInterfaceOptionsService _omniSharpExtractInterfaceOptionsService; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public OmniSharpExtractInterfaceOptionsService(IOmniSharpExtractInterfaceOptionsService omniSharpExtractInterfaceOptionsService) + { + _omniSharpExtractInterfaceOptionsService = omniSharpExtractInterfaceOptionsService; + } + + public async Task GetExtractInterfaceOptionsAsync(ISyntaxFactsService syntaxFactsService, INotificationService notificationService, List extractableMembers, string defaultInterfaceName, List conflictingTypeNames, string defaultNamespace, string generatedNameTypeParameterSuffix, string languageName) + { + var result = await _omniSharpExtractInterfaceOptionsService.GetExtractInterfaceOptionsAsync(extractableMembers, defaultInterfaceName).ConfigureAwait(false); + return new( + result.IsCancelled, + result.IncludedMembers, + result.InterfaceName, + result.FileName, + (ExtractInterfaceOptionsResult.ExtractLocation)result.Location); + } + } +} From 8b0a3bef4b1e672ba3efa3bd8a6d8b0039b2ad1b Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 15:00:07 -0700 Subject: [PATCH 07/18] Add OmniSharpDocumentationCommentsSnippetService. (cherry picked from commit d5f494de90389e7ee513e75f7ae7317a89962b88) --- ...harpDocumentationCommentsSnippetService.cs | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/DocumentationComments/OmniSharpDocumentationCommentsSnippetService.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/DocumentationComments/OmniSharpDocumentationCommentsSnippetService.cs b/src/Tools/ExternalAccess/OmniSharp/DocumentationComments/OmniSharpDocumentationCommentsSnippetService.cs new file mode 100644 index 0000000000000..8524e662304f8 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/DocumentationComments/OmniSharpDocumentationCommentsSnippetService.cs @@ -0,0 +1,90 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using Microsoft.CodeAnalysis.DocumentationComments; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.DocumentationComments +{ + internal static class OmniSharpDocumentationCommentsSnippetService + { + public static OmniSharpDocumentationCommentSnippet? GetDocumentationCommentSnippetOnCharacterTyped( + Document document, + SyntaxTree syntaxTree, + SourceText text, + int position, + DocumentOptionSet options, + CancellationToken cancellationToken) + { + var service = document.GetRequiredLanguageService(); + return Translate(service.GetDocumentationCommentSnippetOnCharacterTyped(syntaxTree, text, position, options, cancellationToken)); + } + + public static OmniSharpDocumentationCommentSnippet? GetDocumentationCommentSnippetOnCommandInvoke( + Document document, + SyntaxTree syntaxTree, + SourceText text, + int position, + DocumentOptionSet options, + CancellationToken cancellationToken) + { + var service = document.GetRequiredLanguageService(); + return Translate(service.GetDocumentationCommentSnippetOnCommandInvoke(syntaxTree, text, position, options, cancellationToken)); + } + + public static OmniSharpDocumentationCommentSnippet? GetDocumentationCommentSnippetOnEnterTyped( + Document document, + SyntaxTree syntaxTree, + SourceText text, + int position, + DocumentOptionSet options, + CancellationToken cancellationToken) + { + var service = document.GetRequiredLanguageService(); + return Translate(service.GetDocumentationCommentSnippetOnEnterTyped(syntaxTree, text, position, options, cancellationToken)); + } + + public static OmniSharpDocumentationCommentSnippet? GetDocumentationCommentSnippetFromPreviousLine( + Document document, + DocumentOptionSet options, + TextLine currentLine, + TextLine previousLine) + { + var service = document.GetRequiredLanguageService(); + return Translate(service.GetDocumentationCommentSnippetFromPreviousLine(options, currentLine, previousLine)); + } + + private static OmniSharpDocumentationCommentSnippet? Translate(DocumentationCommentSnippet? result) + => result == null ? null : new(result.SpanToReplace, result.SnippetText, result.CaretOffset); + } + + internal sealed class OmniSharpDocumentationCommentSnippet + { + /// + /// The span in the original text that should be replaced with the documentation comment. + /// + public TextSpan SpanToReplace { get; } + + /// + /// The documentation comment text to replace the span with + /// + public string SnippetText { get; } + + /// + /// The offset within where the caret should be positioned after replacement + /// + public int CaretOffset { get; } + + internal OmniSharpDocumentationCommentSnippet(TextSpan spanToReplace, string snippetText, int caretOffset) + { + SpanToReplace = spanToReplace; + SnippetText = snippetText; + CaretOffset = caretOffset; + } + } +} From 2ed59995b0b71f1807e2f4cd30cbf4b8a8c5403a Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 15:11:42 -0700 Subject: [PATCH 08/18] Add OmniSharpMetadataAsSourceHelpers (cherry picked from commit 6a1c39ec69bce5a8afb6c946d1ea4f20f1fea1d2) --- .../OmniSharpMetadataAsSourceHelpers.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceHelpers.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceHelpers.cs b/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceHelpers.cs new file mode 100644 index 0000000000000..70de160045285 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceHelpers.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.CodeAnalysis.MetadataAsSource; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.MetadataAsSource +{ + internal static class OmniSharpMetadataAsSourceHelpers + { + public static string GetAssemblyInfo(IAssemblySymbol assemblySymbol) + => MetadataAsSourceHelpers.GetAssemblyInfo(assemblySymbol); + + public static string GetAssemblyDisplay(Compilation compilation, IAssemblySymbol assemblySymbol) + => MetadataAsSourceHelpers.GetAssemblyDisplay(compilation, assemblySymbol); + } +} From a5fd029bc0aefe08b5374d234dbdbd50740f5ed0 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 15:20:47 -0700 Subject: [PATCH 09/18] Add OmniSharpDocCommentConverter. (cherry picked from commit f6ddd0ba0ac94575811922f17fcd6fe2a1c4903b) --- .../OmniSharpDocCommentConverter.cs | 20 +++++++++++++++++++ ...deAnalysis.ExternalAccess.OmniSharp.csproj | 1 + 2 files changed, 21 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp.CSharp/DocumentationComments/OmniSharpDocCommentConverter.cs diff --git a/src/Tools/ExternalAccess/OmniSharp.CSharp/DocumentationComments/OmniSharpDocCommentConverter.cs b/src/Tools/ExternalAccess/OmniSharp.CSharp/DocumentationComments/OmniSharpDocCommentConverter.cs new file mode 100644 index 0000000000000..f0c79747cf881 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp.CSharp/DocumentationComments/OmniSharpDocCommentConverter.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using Microsoft.CodeAnalysis.CSharp.DocumentationComments; +using Microsoft.CodeAnalysis.DocumentationComments; +using Microsoft.CodeAnalysis.Shared.Extensions; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.DocumentationComments +{ + internal static class OmniSharpDocCommentConverter + { + public static SyntaxNode ConvertToRegularComments(SyntaxNode node, Project project, CancellationToken cancellationToken) + { + var formattingService = project.GetRequiredLanguageService(); + return DocCommentConverter.ConvertToRegularComments(node, formattingService, cancellationToken); + } + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj b/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj index 7e6f6352fade1..a9b255ea3f221 100644 --- a/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj +++ b/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj @@ -34,6 +34,7 @@ + From b23e2b501826e8d551f0a142e8b09b79aaf432c6 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 15:46:09 -0700 Subject: [PATCH 10/18] Add OmniSharpCompletionService (cherry picked from commit 08b911dff26c7b88cc29f06083f469cc078a650f) --- .../OmniSharpCompletionProviderNames.cs | 18 +++++++++ .../Completion/OmniSharpCompletionService.cs | 40 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp.CSharp/Completion/OmniSharpCompletionProviderNames.cs create mode 100644 src/Tools/ExternalAccess/OmniSharp/Completion/OmniSharpCompletionService.cs diff --git a/src/Tools/ExternalAccess/OmniSharp.CSharp/Completion/OmniSharpCompletionProviderNames.cs b/src/Tools/ExternalAccess/OmniSharp.CSharp/Completion/OmniSharpCompletionProviderNames.cs new file mode 100644 index 0000000000000..b2d6ed6a1ae9d --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp.CSharp/Completion/OmniSharpCompletionProviderNames.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.CodeAnalysis.CSharp.Completion.Providers; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.Completion +{ + internal static class OmniSharpCompletionProviderNames + { + internal static string ObjectCreationCompletionProvider = typeof(ObjectCreationCompletionProvider).FullName; + internal static string OverrideCompletionProvider = typeof(OverrideCompletionProvider).FullName; + internal static string PartialMethodCompletionProvider = typeof(PartialMethodCompletionProvider).FullName; + internal static string InternalsVisibleToCompletionProvider = typeof(InternalsVisibleToCompletionProvider).FullName; + internal static string TypeImportCompletionProvider = typeof(TypeImportCompletionProvider).FullName; + internal static string ExtensionMethodImportCompletionProvider = typeof(ExtensionMethodImportCompletionProvider).FullName; + } +} diff --git a/src/Tools/ExternalAccess/OmniSharp/Completion/OmniSharpCompletionService.cs b/src/Tools/ExternalAccess/OmniSharp/Completion/OmniSharpCompletionService.cs new file mode 100644 index 0000000000000..899e54d0d5238 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/Completion/OmniSharpCompletionService.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Immutable; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Completion +{ + internal static class OmniSharpCompletionService + { + public static Task<(CompletionList completionList, bool expandItemsAvailable)> GetCompletionsAsync( + this CompletionService completionService, + Document document, + int caretPosition, + CompletionTrigger trigger = default, + ImmutableHashSet? roles = null, + OptionSet? options = null, + CancellationToken cancellationToken = default) + => completionService.GetCompletionsInternalAsync(document, caretPosition, trigger, roles, options, cancellationToken); + + public static Task GetChangeAsync( + this CompletionService completionService, + Document document, + CompletionItem item, + TextSpan completionListSpan, + char? commitCharacter = null, + bool disallowAddingImports = false, + CancellationToken cancellationToken = default) + => completionService.GetChangeAsync(document, item, completionListSpan, commitCharacter, disallowAddingImports, cancellationToken); + + public static string GetProviderName(this CompletionItem completionItem) => completionItem.ProviderName; + + public static PerLanguageOption ShowItemsFromUnimportedNamespaces = (PerLanguageOption)CompletionOptions.ShowItemsFromUnimportedNamespaces; + } +} From 647d4222423cbff3c6e24754ae3a0e3da37cae55 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 15:56:23 -0700 Subject: [PATCH 11/18] Add OmniSharpMetadataAsSourceService (cherry picked from commit ccd1633622dcfce82316b6070a493ca13246958a) --- .../OmniSharpMetadataAsSourceHelpers.cs | 8 +++++ .../OmniSharpMetadataAsSourceService.cs | 30 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceService.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceHelpers.cs b/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceHelpers.cs index 70de160045285..8ccfbc90dd413 100644 --- a/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceHelpers.cs +++ b/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceHelpers.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.MetadataAsSource; namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.MetadataAsSource @@ -13,5 +15,11 @@ public static string GetAssemblyInfo(IAssemblySymbol assemblySymbol) public static string GetAssemblyDisplay(Compilation compilation, IAssemblySymbol assemblySymbol) => MetadataAsSourceHelpers.GetAssemblyDisplay(compilation, assemblySymbol); + + public static Task GetLocationInGeneratedSourceAsync(ISymbol symbol, Document generatedDocument, CancellationToken cancellationToken) + { + var symbolKey = SymbolKey.Create(symbol, cancellationToken); + return MetadataAsSourceHelpers.GetLocationInGeneratedSourceAsync(symbolKey, generatedDocument, cancellationToken); + } } } diff --git a/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceService.cs b/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceService.cs new file mode 100644 index 0000000000000..8b0c46170b18c --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/MetadataAsSource/OmniSharpMetadataAsSourceService.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.MetadataAsSource; +using Microsoft.CodeAnalysis.Shared.Extensions; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.MetadataAsSource +{ + internal static class OmniSharpMetadataAsSourceService + { + /// + /// Generates formatted source code containing general information about the symbol's + /// containing assembly, and the public, protected, and protected-or-internal interface of + /// which the given ISymbol is or is a part of into the given document + /// + /// The document to generate source into + /// The in which is resolved. + /// The symbol to generate source for + /// To cancel document operations + /// The updated document + public static Task AddSourceToAsync(Document document, Compilation symbolCompilation, ISymbol symbol, CancellationToken cancellationToken) + { + var service = document.GetRequiredLanguageService(); + return service.AddSourceToAsync(document, symbolCompilation, symbol, cancellationToken); + } + } +} From 6f703018ac8e889ba357c15dc8ab238fd48a7e31 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 16:03:14 -0700 Subject: [PATCH 12/18] Add OmniSharpCodeAction. (cherry picked from commit 697a9d2de525a55c5b82c4223530b45241737e5e) --- .../OmniSharp/CodeActions/OmniSharpCodeAction.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/CodeActions/OmniSharpCodeAction.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/CodeActions/OmniSharpCodeAction.cs b/src/Tools/ExternalAccess/OmniSharp/CodeActions/OmniSharpCodeAction.cs new file mode 100644 index 0000000000000..2ce633288986c --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/CodeActions/OmniSharpCodeAction.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.CodeActions; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CodeActions +{ + internal static class OmniSharpCodeAction + { + public static ImmutableArray GetNestedCodeActions(this CodeAction codeAction) + => codeAction.NestedCodeActions; + } +} From 00b6a9cec13bd3debc82495067d49bfa2a485f3d Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sun, 25 Apr 2021 16:19:49 -0700 Subject: [PATCH 13/18] Add OmniSharpImplementTypeOptions (cherry picked from commit d92b546057438b3e9856377711906d954ac0a108) --- .../OmniSharpImplementTypeOptions.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharp/ImplementType/OmniSharpImplementTypeOptions.cs diff --git a/src/Tools/ExternalAccess/OmniSharp/ImplementType/OmniSharpImplementTypeOptions.cs b/src/Tools/ExternalAccess/OmniSharp/ImplementType/OmniSharpImplementTypeOptions.cs new file mode 100644 index 0000000000000..121e0f7f342ec --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharp/ImplementType/OmniSharpImplementTypeOptions.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.CodeAnalysis.ImplementType; +using Microsoft.CodeAnalysis.Options; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ImplementType +{ + internal static class OmniSharpImplementTypeOptions + { + public static OmniSharpImplementTypeInsertionBehavior GetInsertionBehavior(OptionSet options, string language) + => (OmniSharpImplementTypeInsertionBehavior)options.GetOption(ImplementTypeOptions.InsertionBehavior, language); + + public static OptionSet SetInsertionBehavior(OptionSet options, string language, OmniSharpImplementTypeInsertionBehavior value) + => options.WithChangedOption(ImplementTypeOptions.InsertionBehavior, language, (ImplementTypeInsertionBehavior)value); + + public static OmniSharpImplementTypePropertyGenerationBehavior GetPropertyGenerationBehavior(OptionSet options, string language) + => (OmniSharpImplementTypePropertyGenerationBehavior)options.GetOption(ImplementTypeOptions.PropertyGenerationBehavior, language); + + public static OptionSet SetPropertyGenerationBehavior(OptionSet options, string language, OmniSharpImplementTypePropertyGenerationBehavior value) + => options.WithChangedOption(ImplementTypeOptions.PropertyGenerationBehavior, language, (ImplementTypePropertyGenerationBehavior)value); + } + + internal enum OmniSharpImplementTypeInsertionBehavior + { + WithOtherMembersOfTheSameKind = ImplementTypeInsertionBehavior.WithOtherMembersOfTheSameKind, + AtTheEnd = ImplementTypeInsertionBehavior.AtTheEnd, + } + + internal enum OmniSharpImplementTypePropertyGenerationBehavior + { + PreferThrowingProperties = ImplementTypePropertyGenerationBehavior.PreferThrowingProperties, + PreferAutoProperties = ImplementTypePropertyGenerationBehavior.PreferAutoProperties, + } +} From feacd335391325cfea6ec1f576b4d5e01125c633 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Wed, 28 Apr 2021 18:21:58 -0700 Subject: [PATCH 14/18] Add OmniSharp unit test package (cherry picked from commit bf24e97d05f5fe4b88f59bf3b2599876c3df4707) --- Roslyn.sln | 7 +++++++ ...crosoft.CodeAnalysis.Test.Utilities.csproj | 1 + .../Microsoft.CodeAnalysis.Features.csproj | 1 + ...sis.ExternalAccess.OmniSharp.CSharp.csproj | 1 + ...deAnalysis.ExternalAccess.OmniSharp.csproj | 1 + ....ExternalAccess.OmniSharp.UnitTests.csproj | 21 +++++++++++++++++++ .../Microsoft.CodeAnalysis.Workspaces.csproj | 1 + 7 files changed, 33 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharpTest/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests.csproj diff --git a/Roslyn.sln b/Roslyn.sln index e2e09fc05cbf6..82b47a0ce273e 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -493,6 +493,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Exte EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp", "src\Tools\ExternalAccess\OmniSharp.CSharp\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj", "{AE976DE9-811D-4C86-AEBB-DCDC1226D754}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests", "src\Tools\ExternalAccess\OmniSharpTest\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests.csproj", "{3829F774-33F2-41E9-B568-AE555004FC62}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 @@ -1284,6 +1286,10 @@ Global {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Debug|Any CPU.Build.0 = Debug|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Release|Any CPU.ActiveCfg = Release|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Release|Any CPU.Build.0 = Release|Any CPU + {3829F774-33F2-41E9-B568-AE555004FC62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3829F774-33F2-41E9-B568-AE555004FC62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3829F774-33F2-41E9-B568-AE555004FC62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3829F774-33F2-41E9-B568-AE555004FC62}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1509,6 +1515,7 @@ Global {BB987FFC-B758-4F73-96A3-923DE8DCFF1A} = {8977A560-45C2-4EC2-A849-97335B382C74} {1B73FB08-9A17-497E-97C5-FA312867D51B} = {8977A560-45C2-4EC2-A849-97335B382C74} {AE976DE9-811D-4C86-AEBB-DCDC1226D754} = {8977A560-45C2-4EC2-A849-97335B382C74} + {3829F774-33F2-41E9-B568-AE555004FC62} = {8977A560-45C2-4EC2-A849-97335B382C74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29} diff --git a/src/Compilers/Test/Core/Microsoft.CodeAnalysis.Test.Utilities.csproj b/src/Compilers/Test/Core/Microsoft.CodeAnalysis.Test.Utilities.csproj index c7d33bd09ac06..9bd2d660f996b 100644 --- a/src/Compilers/Test/Core/Microsoft.CodeAnalysis.Test.Utilities.csproj +++ b/src/Compilers/Test/Core/Microsoft.CodeAnalysis.Test.Utilities.csproj @@ -54,6 +54,7 @@ + diff --git a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj index 4c43a0d456d0b..3f12ca28d393e 100644 --- a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj +++ b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj @@ -88,6 +88,7 @@ + diff --git a/src/Tools/ExternalAccess/OmniSharp.CSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj b/src/Tools/ExternalAccess/OmniSharp.CSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj index 97e9f33cbff79..cd11f4c77a5c0 100644 --- a/src/Tools/ExternalAccess/OmniSharp.CSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj +++ b/src/Tools/ExternalAccess/OmniSharp.CSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj @@ -12,6 +12,7 @@ + diff --git a/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj b/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj index a9b255ea3f221..3cf0deb3d6617 100644 --- a/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj +++ b/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Tools/ExternalAccess/OmniSharpTest/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests.csproj b/src/Tools/ExternalAccess/OmniSharpTest/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests.csproj new file mode 100644 index 0000000000000..faa1126ba2319 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharpTest/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests.csproj @@ -0,0 +1,21 @@ + + + + + Library + Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests + net472 + + + + + + + + + + + + + + diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index ff7df6fcbc602..ce4e50284c83b 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -120,6 +120,7 @@ + From 34ed3863513b18209516a3b7e44a059eccdf54f6 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Wed, 28 Apr 2021 18:43:39 -0700 Subject: [PATCH 15/18] Add tests for all the enum types. (cherry picked from commit 2b118dd985402000251d25a0a61fe45b21182200) --- .../ExternalAccess/OmniSharpTest/EnumTests.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Tools/ExternalAccess/OmniSharpTest/EnumTests.cs diff --git a/src/Tools/ExternalAccess/OmniSharpTest/EnumTests.cs b/src/Tools/ExternalAccess/OmniSharpTest/EnumTests.cs new file mode 100644 index 0000000000000..a552f27c40fc6 --- /dev/null +++ b/src/Tools/ExternalAccess/OmniSharpTest/EnumTests.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ExtractInterface; +using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.ImplementType; +using Microsoft.CodeAnalysis.ExtractInterface; +using Microsoft.CodeAnalysis.ImplementType; +using Xunit; + +namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests +{ + public class EnumTests + { + [Theory] + [InlineData(typeof(ExtractInterfaceOptionsResult.ExtractLocation), + typeof(OmniSharpExtractInterfaceOptionsResult.OmniSharpExtractLocation))] + [InlineData(typeof(ImplementTypeInsertionBehavior), typeof(OmniSharpImplementTypeInsertionBehavior))] + [InlineData(typeof(ImplementTypePropertyGenerationBehavior), typeof(OmniSharpImplementTypePropertyGenerationBehavior))] + public void AssertEnumsInSync(Type internalType, Type externalType) + { + var internalValues = Enum.GetValues(internalType).Cast().ToArray(); + var internalNames = Enum.GetNames(internalType); + var externalValues = Enum.GetValues(externalType).Cast().ToArray(); + var externalNames = Enum.GetNames(externalType); + + Assert.Equal(internalValues, externalValues); + Assert.Equal(internalNames, externalNames); + } + } +} From 88b616fbfd12efa19f3839326aee208651541f74 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Sat, 1 May 2021 00:43:49 -0700 Subject: [PATCH 16/18] Add the OmniSharp signing public key. (cherry picked from commit bc92a473b0422bb42846d56219b39d3646f63225) --- eng/targets/Settings.props | 1 + ...sis.ExternalAccess.OmniSharp.CSharp.csproj | 24 ++++++++--------- ...deAnalysis.ExternalAccess.OmniSharp.csproj | 26 +++++++++---------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/eng/targets/Settings.props b/eng/targets/Settings.props index ddb10ff6c6988..d13ea0c630b6d 100644 --- a/eng/targets/Settings.props +++ b/eng/targets/Settings.props @@ -80,6 +80,7 @@ $(VisualStudioKey) 002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df $(VisualStudioKey) + 0024000004800000940000000602000000240000525341310004000001000100917302efc152e6464679d4625bd9989e12d4662a9eaadf284d04992881c0e7b16e756e63ef200a02c4054d4d31e21b9aa0b0b873bcefca8cd42ec583a3db509665c9b22318ceceec581663fc07e2422bb2135539ba8a517c209ac175fff07c5af10cef636e04cae91d28f51fcde5d14c1a9bfed06e096cf977fd0d60002a3ea6 - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj b/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj index 3cf0deb3d6617..91f25fc7b6bed 100644 --- a/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj +++ b/src/Tools/ExternalAccess/OmniSharp/Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj @@ -17,19 +17,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + From 3f25651eaccad62031c632ffc084722f690f35db Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Mon, 3 May 2021 17:54:39 -0700 Subject: [PATCH 17/18] Add external access doc. (cherry picked from commit 268f94d2707fdaccf5aa5f9153b7620ffa308c4a) --- docs/ide/external-access.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/ide/external-access.md diff --git a/docs/ide/external-access.md b/docs/ide/external-access.md new file mode 100644 index 0000000000000..e09926a4a1de6 --- /dev/null +++ b/docs/ide/external-access.md @@ -0,0 +1,5 @@ +# External Access Policies + +## OmniSharp + +When a change needs to be made to an API in the ExternalAccess.OmniSharp or ExternalAccess.OmniSharp.CSharp packages, ping @333fred, @JoeRobich, @filipw, or @david-driscoll as a heads up. Breaking changes are allowed, but please wait for acknowledgement and followup questions to ensure that we don't completely break OmniSharp scenarios. From 28955d0f02e5e369dbac824f167cd87c8fd1dfb3 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Tue, 4 May 2021 22:07:14 -0700 Subject: [PATCH 18/18] Fix up for 16.11 --- .../Internal/PickMembers/OmniSharpPickMembersService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tools/ExternalAccess/OmniSharp/Internal/PickMembers/OmniSharpPickMembersService.cs b/src/Tools/ExternalAccess/OmniSharp/Internal/PickMembers/OmniSharpPickMembersService.cs index eb509d9ee8ddc..61b8fab92f0e1 100644 --- a/src/Tools/ExternalAccess/OmniSharp/Internal/PickMembers/OmniSharpPickMembersService.cs +++ b/src/Tools/ExternalAccess/OmniSharp/Internal/PickMembers/OmniSharpPickMembersService.cs @@ -24,10 +24,10 @@ public OmniSharpPickMembersService(IOmniSharpPickMembersService omniSharpPickMem _omniSharpPickMembersService = omniSharpPickMembersService; } - public PickMembersResult PickMembers(string title, ImmutableArray members, ImmutableArray options = default, bool selectAll = true) + public PickMembersResult PickMembers(string title, ImmutableArray members, ImmutableArray options = default) { - var result = _omniSharpPickMembersService.PickMembers(title, members, options.SelectAsArray(o => new OmniSharpPickMembersOption(o)), selectAll); - return new(result.Members, result.Options.SelectAsArray(o => o.PickMembersOptionInternal), result.SelectedAll); + var result = _omniSharpPickMembersService.PickMembers(title, members, options.SelectAsArray(o => new OmniSharpPickMembersOption(o)), selectAll: true); + return new(result.Members, result.Options.SelectAsArray(o => o.PickMembersOptionInternal)); } } }