Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OmniSharp ExternalAccess #52907

Merged
merged 17 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Roslyn.sln
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ 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
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
Expand Down Expand Up @@ -1272,6 +1278,18 @@ 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
{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
Expand Down Expand Up @@ -1495,6 +1513,9 @@ 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}
{3829F774-33F2-41E9-B568-AE555004FC62} = {8977A560-45C2-4EC2-A849-97335B382C74}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29}
Expand Down
5 changes: 5 additions & 0 deletions docs/ide/external-access.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 3 additions & 1 deletion eng/config/PublishData.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -303,4 +305,4 @@
"channels": []
}
}
}
}
1 change: 1 addition & 0 deletions eng/targets/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<VisualStudioDebuggerKey>$(VisualStudioKey)</VisualStudioDebuggerKey>
<XamarinKey>002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df</XamarinKey>
<UnitTestingKey>$(VisualStudioKey)</UnitTestingKey>
<OmniSharpKey>0024000004800000940000000602000000240000525341310004000001000100917302efc152e6464679d4625bd9989e12d4662a9eaadf284d04992881c0e7b16e756e63ef200a02c4054d4d31e21b9aa0b0b873bcefca8cd42ec583a3db509665c9b22318ceceec581663fc07e2422bb2135539ba8a517c209ac175fff07c5af10cef636e04cae91d28f51fcde5d14c1a9bfed06e096cf977fd0d60002a3ea6</OmniSharpKey>
</PropertyGroup>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Rebuild.UnitTests" />
<InternalsVisibleTo Include="Roslyn.Test.PdbUtilities" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Workspaces" />
<!-- BEGIN External Access -->
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor" />
<!-- END External Access -->
<!-- BEGIN MONODEVELOP
Expand Down Expand Up @@ -71,4 +72,4 @@
<Import Project="..\..\..\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems" Label="Shared" />
<Import Project="..\..\..\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems" Label="Shared" />
<Import Project="..\..\..\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems" Label="Shared" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Test.Utilities2" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.TypeScript.EditorFeatures" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.TypeScript" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" />
<InternalsVisibleTo Include="Roslyn.Services.Editor.TypeScript.UnitTests" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<IDocumentationCommentFormattingService>();
return DocCommentConverter.ConvertToRegularComments(node, formattingService, cancellationToken);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>

<IsPackable>true</IsPackable>
<PackageId>Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp</PackageId>
<PackageDescription>
A supporting package for OmniSharp:
https://github.com/OmniSharp/omnisharp-roslyn
</PackageDescription>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests" />
<!--
⚠ ONLY OMNISHARP ASSEMBLIES MAY BE ADDED HERE ⚠
-->
<InternalsVisibleTo Include="OmniSharp.Roslyn.CSharp" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.Roslyn.CSharp.Tests" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.DotNetTest" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.DotNetTest.Tests" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.LanguageServerProtocol" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.Lsp.Tests" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.MSBuild" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.MSBuild.Tests" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.Script" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.Script.Tests" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.Cake" Key="$(OmniSharpKey)" />
<InternalsVisibleTo Include="OmniSharp.CakeTests" Key="$(OmniSharpKey)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
<ProjectReference Include="..\..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" />
<ProjectReference Include="..\..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" />
<ProjectReference Include="..\..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" />
<ProjectReference Include="..\OmniSharp\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj" />
</ItemGroup>

<ItemGroup>
<PublicAPI Include="PublicAPI.Shipped.txt" />
<PublicAPI Include="PublicAPI.Unshipped.txt" />
</ItemGroup>

</Project>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -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<CodeAction> GetNestedCodeActions(this CodeAction codeAction)
=> codeAction.NestedCodeActions;
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<string>? roles = null,
OptionSet? options = null,
CancellationToken cancellationToken = default)
=> completionService.GetCompletionsInternalAsync(document, caretPosition, trigger, roles, options, cancellationToken);

public static Task<CompletionChange> 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<bool?> ShowItemsFromUnimportedNamespaces = (PerLanguageOption<bool?>)CompletionOptions.ShowItemsFromUnimportedNamespaces;
}
}
Original file line number Diff line number Diff line change
@@ -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<IDocumentationCommentSnippetService>();
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<IDocumentationCommentSnippetService>();
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<IDocumentationCommentSnippetService>();
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<IDocumentationCommentSnippetService>();
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
{
/// <summary>
/// The span in the original text that should be replaced with the documentation comment.
/// </summary>
public TextSpan SpanToReplace { get; }

/// <summary>
/// The documentation comment text to replace the span with
/// </summary>
public string SnippetText { get; }

/// <summary>
/// The offset within <see cref="SnippetText"/> where the caret should be positioned after replacement
/// </summary>
public int CaretOffset { get; }

internal OmniSharpDocumentationCommentSnippet(TextSpan spanToReplace, string snippetText, int caretOffset)
{
SpanToReplace = spanToReplace;
SnippetText = snippetText;
CaretOffset = caretOffset;
}
}
}
Loading