Skip to content

Commit

Permalink
Merge branch 'master' into minor-docs-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
filipw authored Sep 23, 2020
2 parents 3d65bc7 + 3ef6109 commit 594e7d6
Show file tree
Hide file tree
Showing 25 changed files with 681 additions and 154 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# Changelog
All changes to the project will be documented in this file.

## [1.37.2] - Not Yet Released
* Add support for new quick info endpoint when working with Cake (PR: [#1945](https://github.com/OmniSharp/omnisharp-roslyn/pull/1945))
* Add support for new completion endpoints when working with Cake ([#1939](https://github.com/OmniSharp/omnisharp-roslyn/issues/1939), PR: [#1944](https://github.com/OmniSharp/omnisharp-roslyn/pull/1944))

## [1.37.1] - 2020-09-01
* Ensure that all quickinfo sections have linebreaks between them, and don't add unecessary duplicate linebreaks (PR: [#1900](https://github.com/OmniSharp/omnisharp-roslyn/pull/1900))
* Support completion of unimported types (PR: [#1896](https://github.com/OmniSharp/omnisharp-roslyn/pull/1896))
* Exclude Misc project from InternalsVisibleTo completion (PR: [#1902](https://github.com/OmniSharp/omnisharp-roslyn/pull/1902))
* Ensure unimported things are sorted after imported things (PR: [#1903](https://github.com/OmniSharp/omnisharp-roslyn/pull/1903))
* Updated lsp library to fix issue with signature help, etc ([#1887](https://github.com/OmniSharp/omnisharp-roslyn/issues/1887), PR: [#1890](https://github.com/OmniSharp/omnisharp-roslyn/pull/1890))
* Correctly handle multiple reference aliases (PR: [#1905](https://github.com/OmniSharp/omnisharp-roslyn/pull/1905))
* Better handle completion when the display text is not in the final result (PR: [#1908](https://github.com/OmniSharp/omnisharp-roslyn/pull/1908))
* Correctly mark hover markup content as markdown ([#1906](https://github.com/OmniSharp/omnisharp-roslyn/issues/1906), PR: [#1909](https://github.com/OmniSharp/omnisharp-roslyn/pull/1909))
* Upgrade lsp ([#1898](https://github.com/OmniSharp/omnisharp-roslyn/issues/1898), PR: [#1911](https://github.com/OmniSharp/omnisharp-roslyn/pull/1911))
* Updated to ILSpy 6.1.0.5902 (PR: [#1913](https://github.com/OmniSharp/omnisharp-roslyn/pull/1913))
* Updated to NET 5.0 preview8 (PR: [#1916](https://github.com/OmniSharp/omnisharp-roslyn/pull/1916))
* Add HTTP Driver back to build.json (PR: [#1918](https://github.com/OmniSharp/omnisharp-roslyn/pull/1918))
* Use ExecutionPolicy Bypass when running powershell.exe (PR: [#1917](https://github.com/OmniSharp/omnisharp-roslyn/pull/1917))
* Update the package that Arch Linux users need to install (PR: [#1921](https://github.com/OmniSharp/omnisharp-roslyn/pull/1921))
* Updated the docs to mention .NET 4.7.2 targeting pack (PR: [#1922](https://github.com/OmniSharp/omnisharp-roslyn/pull/1922))
* Support for configurations remapping in solution files ([#1828](https://github.com/OmniSharp/omnisharp-roslyn/issues/1828), PR: [#1835](https://github.com/OmniSharp/omnisharp-roslyn/pull/1835))
* Only run dotnet --info once for the working directory (PR: [#1925](https://github.com/OmniSharp/omnisharp-roslyn/pull/1925))
* Update build tool versions for NET 5 RC1 (PR: [#1926](https://github.com/OmniSharp/omnisharp-roslyn/pull/1926))
* Update Roslyn to 3.8.0-3.20451.2 (PR: [#1927](https://github.com/OmniSharp/omnisharp-roslyn/pull/1927))

## [1.37.0] - 2020-08-18
* Update Roslyn version and tooling to match .NET 5 Preview8 (PR: [#1897](https://github.com/OmniSharp/omnisharp-roslyn/pull/1897))
* Updated lsp library to fix issue with signature help, etc (PR: [#1890](https://github.com/OmniSharp/omnisharp-roslyn/pull/1890))
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

OmniSharp is a .NET development platform based on [Roslyn](https://github.com/dotnet/roslyn) workspaces. It provides project dependencies and C# language services to various IDEs and plugins.

OmniSharp is built with the [.NET Core SDK](https://dot.net/) on Windows and [Mono](http://www.mono-project.com/) on OSX/Linux. It targets the _net472_ target framework. For platforms other than Windows, OmniSharp ships with an _embedded Mono_ which is based on version _5.18.0_, includes MSBuild _16.3.0_ and is provisioned during the build script. If _Mono_ is globally installed on the system, OmniSharp will prefer it over the embedded version, however version _>=6.4.0_ is required (the lowest version with at least MSBuild _16.3.0_).
OmniSharp is built with the [.NET Core SDK](https://dot.net/) on Windows and [Mono](http://www.mono-project.com/) on OSX/Linux. It targets the _net472_ target framework. For platforms other than Windows, OmniSharp ships with an _embedded Mono_ which is based on version _6.10.0_, includes MSBuild _16.8.0_ and is provisioned during the build script. If _Mono_ is globally installed on the system, OmniSharp will prefer it over the embedded version, however version _>=6.4.0_ is required (the lowest version with at least MSBuild _16.3.0_).

For Arch Linux users, you need package [mono-msbuild](https://www.archlinux.org/packages/community/x86_64/mono-msbuild/) (>= 16.3).

Expand Down Expand Up @@ -64,7 +64,7 @@ For more details, see [Build](https://github.com/OmniSharp/omnisharp-roslyn/blob

### VS Code

Add the following setting to your [User Settings or Workspace Settings](https://code.visualstudio.com/Docs/customization/userandworkspace).
Add the following setting to your [User Settings](https://code.visualstudio.com/Docs/customization/userandworkspace).

```JSON
{
Expand All @@ -77,7 +77,7 @@ The above option can also be set to:
- "latest" - To consume the latest build from the master branch
- A specific version number like `1.29.2-beta.60`

In order to be able to attach a debugger, add the following setting:
In order to be able to attach a debugger, add the following setting to your [User or Workspace settings](https://code.visualstudio.com/Docs/customization/userandworkspace):

```JSON
{
Expand Down
5 changes: 4 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ Task("CreateMSBuildFolder")
source: CombinePaths(msbuildSdkResolverSourceFolder, "Microsoft.DotNet.MSBuildSdkResolver.dll"),
destination: CombinePaths(msbuildSdkResolverTargetFolder, "Microsoft.DotNet.MSBuildSdkResolver.dll"));
FileHelper.Copy(
source: CombinePaths(msbuildSdkResolverSourceFolder, "Microsoft.DotNet.SdkResolver.dll"),
destination: CombinePaths(msbuildSdkResolverTargetFolder, "Microsoft.DotNet.SdkResolver.dll"));
if (Platform.Current.IsWindows)
{
CopyDotNetHostResolver(env, "win", "x86", "hostfxr.dll", msbuildSdkResolverTargetFolder, copyToArchSpecificFolder: true);
Expand Down Expand Up @@ -906,7 +910,6 @@ Task("Publish")
/// Execute the run script.
/// </summary>
Task("ExecuteRunScript")
.WithCriteria(() => !(Platform.Current.IsMacOS && TravisCI.IsRunningOnTravisCI))
.Does(() =>
{
// TODO: Pass configuration into run script to ensure that MSBuild output paths are handled correctly.
Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass .\build.ps1 "%*"
powershell.exe -NoProfile -ExecutionPolicy Bypass %~dp0build.ps1 "%*"
2 changes: 1 addition & 1 deletion build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"DotNetChannel": "Preview",
"DotNetVersions": [
"3.1.401",
"5.0.100-preview.8.20417.9"
"5.0.100-rc.1.20452.10"
],
"RequiredMonoVersion": "6.6.0",
"DownloadURL": "https://roslynomnisharp.blob.core.windows.net/ext",
Expand Down
6 changes: 1 addition & 5 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ http://cakebuild.net
Param(
[parameter(position=0)]
[string]$Target = "Default",
[string]$Script = "build.cake",
[string]$Script = "$PSScriptRoot/build.cake",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Debug",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
Expand Down Expand Up @@ -85,10 +85,6 @@ function MD5HashFile([string] $filePath)

Write-Host "Preparing to run build script..."

if(!$PSScriptRoot){
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}

$TOOLS_DIR = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "tools"))
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
Expand Down
6 changes: 3 additions & 3 deletions build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<PropertyGroup>
<MSBuildPackageVersion>16.6.0</MSBuildPackageVersion>
<NuGetPackageVersion>5.2.0</NuGetPackageVersion>
<RoslynPackageVersion>3.8.0-1.20363.1</RoslynPackageVersion>
<XunitPackageVersion>2.4.0</XunitPackageVersion>
<RoslynPackageVersion>3.8.0-3.20451.2</RoslynPackageVersion>
<XunitPackageVersion>2.4.1</XunitPackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -78,7 +78,7 @@

<PackageReference Update="System.Reflection.DispatchProxy" Version="4.5.1" />

<PackageReference Update="xunit.runner.visualstudio" Version="$(XunitPackageVersion)" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Update="xunit" Version="$(XunitPackageVersion)" />
</ItemGroup>
<ItemGroup>
Expand Down
65 changes: 49 additions & 16 deletions src/OmniSharp.Cake/Extensions/ResponseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OmniSharp.Models.Navigate;
using OmniSharp.Models.MembersTree;
using OmniSharp.Models.Rename;
using OmniSharp.Models.v1.Completion;
using OmniSharp.Models.V2;
using OmniSharp.Models.V2.CodeActions;
using OmniSharp.Models.V2.CodeStructure;
Expand All @@ -27,22 +28,6 @@ public static QuickFixResponse OnlyThisFile(this QuickFixResponse response, stri
var quickFixes = response.QuickFixes.Where(x => PathsAreEqual(x.FileName, fileName));
response.QuickFixes = quickFixes;
return response;

bool PathsAreEqual(string x, string y)
{
if (x == null && y == null)
{
return true;
}
if (x == null || y == null)
{
return false;
}

var comparer = PlatformHelper.IsWindows ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;

return Path.GetFullPath(x).Equals(Path.GetFullPath(y), comparer);
}
}

public static Task<QuickFixResponse> TranslateAsync(this QuickFixResponse response, OmniSharpWorkspace workspace)
Expand Down Expand Up @@ -211,6 +196,38 @@ public static async Task<BlockStructureResponse> TranslateAsync(this BlockStruct
return response;
}

public static async Task<CompletionResponse> TranslateAsync(this CompletionResponse response, OmniSharpWorkspace workspace, CompletionRequest request)
{
foreach (var item in response.Items)
{
if (item.AdditionalTextEdits is null)
{
continue;
}

List<LinePositionSpanTextChange> additionalTextEdits = null;

foreach (var additionalTextEdit in item.AdditionalTextEdits)
{
var (_, change) = await additionalTextEdit.TranslateAsync(workspace, request.FileName);

// Due to the fact that AdditionalTextEdits return the complete buffer, we can't currently use that in Cake.
// Revisit when we have a solution. At this point it's probably just best to remove AdditionalTextEdits.
if (change.StartLine < 0)
{
continue;
}

additionalTextEdits ??= new List<LinePositionSpanTextChange>();
additionalTextEdits.Add(change);
}

item.AdditionalTextEdits = additionalTextEdits;
}

return response;
}

private static async Task<CodeElement> TranslateAsync(this CodeElement element, OmniSharpWorkspace workspace, SimpleFileRequest request)
{
var builder = new CodeElement.Builder
Expand Down Expand Up @@ -345,5 +362,21 @@ private static async Task PopulateModificationsAsync(

return (newFileName, change);
}

private static bool PathsAreEqual(string x, string y)
{
if (x == null && y == null)
{
return true;
}
if (x == null || y == null)
{
return false;
}

var comparer = PlatformHelper.IsWindows ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;

return Path.GetFullPath(x).Equals(Path.GetFullPath(y), comparer);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Composition;
using System.Linq;
using System.Threading.Tasks;
using OmniSharp.Cake.Extensions;
using OmniSharp.Mef;
using OmniSharp.Models.v1.Completion;

namespace OmniSharp.Cake.Services.RequestHandlers.Completion
{
[Shared]
[OmniSharpHandler(OmniSharpEndpoints.Completion, Constants.LanguageNames.Cake)]
public class CompletionHandler : CakeRequestHandler<CompletionRequest, CompletionResponse>
{
[ImportingConstructor]
public CompletionHandler(OmniSharpWorkspace workspace) : base(workspace)
{
}

protected override Task<CompletionResponse> TranslateResponse(CompletionResponse response, CompletionRequest request)
{
return response.TranslateAsync(Workspace, request);
}
}

[Shared]
[OmniSharpHandler(OmniSharpEndpoints.CompletionResolve, Constants.LanguageNames.Cake)]
public class CompletionResolveHandler : CakeRequestHandler<CompletionResolveRequest, CompletionResolveResponse>
{
[ImportingConstructor]
public CompletionResolveHandler(OmniSharpWorkspace workspace) : base(workspace)
{
}

protected override Task<CompletionResolveResponse> TranslateResponse(CompletionResolveResponse response, CompletionResolveRequest request)
{
// Due to the fact that AdditionalTextEdits return the complete buffer, we can't currently use that in Cake.
// Revisit when we have a solution. At this point it's probably just best to remove AdditionalTextEdits.
if (response.Item is object)
{
response.Item.AdditionalTextEdits = null;
}

return Task.FromResult(response);
}
}
}
16 changes: 16 additions & 0 deletions src/OmniSharp.Cake/Services/RequestHandlers/QuickInfoHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Composition;
using OmniSharp.Mef;
using OmniSharp.Models;

namespace OmniSharp.Cake.Services.RequestHandlers
{
[Shared]
[OmniSharpHandler(OmniSharpEndpoints.QuickInfo, Constants.LanguageNames.Cake)]
public class QuickInfoHandler : CakeRequestHandler<QuickInfoRequest, QuickInfoResponse>
{
[ImportingConstructor]
public QuickInfoHandler(OmniSharpWorkspace workspace) : base(workspace)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ public static IEnumerable<IJsonRpcHandler> Enumerate(RequestHandlers handlers)
private static readonly IDictionary<string, CompletionItemKind> _kind = new Dictionary<string, CompletionItemKind>{
// types
{ "Class", CompletionItemKind.Class },
{ "Delegate", CompletionItemKind.Class }, // need a better option for this.
{ "Delegate", CompletionItemKind.Function },
{ "Enum", CompletionItemKind.Enum },
{ "Interface", CompletionItemKind.Interface },
{ "Struct", CompletionItemKind.Class }, // TODO: Is struct missing from enum?
{ "Struct", CompletionItemKind.Struct },

// variables
{ "Local", CompletionItemKind.Variable },
{ "Parameter", CompletionItemKind.Variable },
{ "RangeVariable", CompletionItemKind.Variable },

// members
{ "Const", CompletionItemKind.Value }, // TODO: Is const missing from enum?
{ "Const", CompletionItemKind.Constant },
{ "EnumMember", CompletionItemKind.Enum },
{ "Event", CompletionItemKind.Function }, // TODO: Is event missing from enum?
{ "Event", CompletionItemKind.Event },
{ "Field", CompletionItemKind.Field },
{ "Method", CompletionItemKind.Method },
{ "Property", CompletionItemKind.Property },

// other stuff
{ "Label", CompletionItemKind.Unit }, // need a better option for this.
{ "Label", CompletionItemKind.Text },
{ "Keyword", CompletionItemKind.Keyword },
{ "Namespace", CompletionItemKind.Module }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class CompletionService :
{ WellKnownTags.Keyword, CompletionItemKind.Keyword },
{ WellKnownTags.Label, CompletionItemKind.Text },
{ WellKnownTags.Local, CompletionItemKind.Variable },
{ WellKnownTags.Namespace, CompletionItemKind.Text },
{ WellKnownTags.Namespace, CompletionItemKind.Module },
{ WellKnownTags.Method, CompletionItemKind.Method },
{ WellKnownTags.Module, CompletionItemKind.Module },
{ WellKnownTags.Operator, CompletionItemKind.Operator },
Expand Down Expand Up @@ -174,6 +174,16 @@ public async Task<CompletionResponse> Handle(CompletionRequest request)
string providerName = completion.GetProviderName();
switch (providerName)
{
case CompletionItemExtensions.EmeddedLanguageCompletionProvider:
// The Regex completion provider can change escapes based on whether
// we're in a verbatim string or not
{
CompletionChange change = await completionService.GetChangeAsync(document, completion);
Debug.Assert(typedSpan == change.TextChange.Span);
insertText = change.TextChange.NewText!;
}
break;

case CompletionItemExtensions.InternalsVisibleToCompletionProvider:
// The IVT completer doesn't add extra things before the completion
// span, only assembly keys at the end if they exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal static class CompletionItemExtensions
internal const string XmlDocCommentCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.XmlDocCommentCompletionProvider";
internal const string TypeImportCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.TypeImportCompletionProvider";
internal const string ExtensionMethodImportCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.ExtensionMethodImportCompletionProvider";
internal const string EmeddedLanguageCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.EmbeddedLanguageCompletionProvider";
private const string ProviderName = nameof(ProviderName);
private const string SymbolCompletionItem = "Microsoft.CodeAnalysis.Completion.Providers.SymbolCompletionItem";
private const string SymbolKind = nameof(SymbolKind);
Expand Down Expand Up @@ -69,8 +70,9 @@ internal static Task<CompletionChange> GetChangeAsync(
CompletionItem item,
TextSpan completionListSpan,
char? commitCharacter = null,
bool disallowAddingImports = false,
CancellationToken cancellationToken = default)
=> (Task<CompletionChange>)_getChangeAsync.Invoke(completionService, new object[] { document, item, completionListSpan, commitCharacter, cancellationToken });
=> (Task<CompletionChange>)_getChangeAsync.Invoke(completionService, new object[] { document, item, completionListSpan, commitCharacter, disallowAddingImports, cancellationToken });

public static async Task<IEnumerable<ISymbol>> GetCompletionSymbolsAsync(this CompletionItem completionItem, IEnumerable<ISymbol> recommendedSymbols, Document document)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace OmniSharp.Roslyn.CSharp.Services.Intellisense
{
[Obsolete("Please use CompletionService.")]
[OmniSharpHandler(OmniSharpEndpoints.AutoComplete, LanguageNames.CSharp)]
public class IntellisenseService : IRequestHandler<AutoCompleteRequest, IEnumerable<AutoCompleteResponse>>
{
Expand Down
Loading

0 comments on commit 594e7d6

Please sign in to comment.