Skip to content

Commit

Permalink
Merge pull request #2329 from JoeRobich/update-build-tools5
Browse files Browse the repository at this point in the history
Updates included build tool to match the current 6.0.200 sdk
  • Loading branch information
filipw authored Jan 25, 2022
2 parents d10ba5b + 9c2ad9f commit 39d0f4a
Show file tree
Hide file tree
Showing 23 changed files with 296 additions and 131 deletions.
4 changes: 4 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ Task("CreateMSBuildFolder")
source: CombinePaths(env.Folders.Tools, "SQLitePCLRaw.bundle_green", "lib", "netstandard2.0", "SQLitePCLRaw.batteries_v2.dll"),
destination: CombinePaths(msbuildCurrentBinTargetFolder, "SQLitePCLRaw.batteries_v2.dll"),
overwrite: true);
FileHelper.Copy(
source: CombinePaths(env.Folders.Tools, "Microsoft.IO.Redist", "lib", "net472", "Microsoft.IO.Redist.dll"),
destination: CombinePaths(msbuildCurrentBinTargetFolder, "Microsoft.IO.Redist.dll"));
});

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<MicrosoftTestPackageVersion>17.0.0</MicrosoftTestPackageVersion>
<MSBuildPackageVersion>17.0.0</MSBuildPackageVersion>
<NuGetPackageVersion>6.0.0</NuGetPackageVersion>
<RoslynPackageVersion>4.0.1-1.22053.6</RoslynPackageVersion>
<RoslynPackageVersion>4.1.0-3.22069.8</RoslynPackageVersion>
<XunitPackageVersion>2.4.1</XunitPackageVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/OmniSharp.Abstractions/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal static class Configuration
{
public static bool ZeroBasedIndices = false;

public const string RoslynVersion = "4.0.0.0";
public const string RoslynVersion = "4.1.0.0";
public const string RoslynPublicKeyToken = "31bf3856ad364e35";

public readonly static string RoslynFeatures = GetRoslynAssemblyFullName("Microsoft.CodeAnalysis.Features");
Expand Down
11 changes: 11 additions & 0 deletions src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ public void RegisterInstance(MSBuildInstance instance)

RegisteredInstance = instance ?? throw new ArgumentNullException(nameof(instance));

if (instance.DiscoveryType == DiscoveryType.StandAlone)
{
// MSBuild began relying on the Microsoft.IO.Redist library which does not work
// on MacOS or Linux platforms. Disabling the 17.0 feature wave opts us in to the
// earlier behavior of using System.IO.

// This issue only affects the MSBuild tools shipped with O# as Mono does not ship
// with a version of MSBuild that includes this change.
Environment.SetEnvironmentVariable("MSBUILDDISABLEFEATURESFROMVERSION", "17.0");
}

if (instance.SetMSBuildExePathVariable)
{
var msbuildExePath = Path.Combine(instance.MSBuildPath, "MSBuild.exe");
Expand Down
10 changes: 5 additions & 5 deletions src/OmniSharp.Http.Driver/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.Workspaces" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.Features" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp.Features" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Dataflow" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,17 @@ private static void VerifyEnumsInSync(Type enum1, Type enum2)
Debug.Assert(lspValues.Length == modelValues.Length);
for (int i = 0; i < lspValues.Length; i++)
{
Debug.Assert((int?)lspValues.GetValue(i) == (int?)modelValues.GetValue(i));
var lspValue = lspValues.GetValue(i);
var modelValue = modelValues.GetValue(i);

if (lspValue is null || modelValue is null)
{
Debug.Assert(lspValue is null && modelValue is null);
}
else
{
Debug.Assert((int)lspValue == (int)modelValue);
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/OmniSharp.LanguageServerProtocol/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.Workspaces" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.Features" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp.Features" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Dataflow" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal static partial class CompletionListBuilder
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";
internal const string AggregateEmeddedLanguageCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.AggregateEmbeddedLanguageCompletionProvider";

internal static async Task<(IReadOnlyList<CompletionItem>, bool)> BuildCompletionItems(
Document document,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
using CompletionItem = OmniSharp.Models.v1.Completion.CompletionItem;
using CompletionTriggerKind = OmniSharp.Models.v1.Completion.CompletionTriggerKind;
using CSharpCompletionService = Microsoft.CodeAnalysis.Completion.CompletionService;
using System.Threading;
using Roslyn.Utilities;

namespace OmniSharp.Roslyn.CSharp.Services.Completion
{
Expand Down Expand Up @@ -65,22 +67,25 @@ public async Task<CompletionResponse> Handle(CompletionRequest request)
var position = sourceText.GetTextPosition(request);

var completionService = CSharpCompletionService.GetService(document);
Debug.Assert(request.TriggerCharacter != null || request.CompletionTrigger != CompletionTriggerKind.TriggerCharacter);
RoslynDebug.Assert(completionService != null);
RoslynDebug.Assert(request.TriggerCharacter != null || request.CompletionTrigger != CompletionTriggerKind.TriggerCharacter);

CompletionTrigger trigger = request.CompletionTrigger switch
{
CompletionTriggerKind.TriggerCharacter when request.TriggerCharacter is char c => CompletionTrigger.CreateInsertionTrigger(c),
_ => CompletionTrigger.Invoke,
};

var options = new OmniSharpCompletionOptions(ShowItemsFromUnimportedNamespaces: _omniSharpOptions.RoslynExtensionsOptions.EnableImportCompletion);

if (request.CompletionTrigger == CompletionTriggerKind.TriggerCharacter &&
!completionService.ShouldTriggerCompletion(sourceText, position, trigger))
!await OmniSharpCompletionService.ShouldTriggerCompletionAsync(completionService, document, position, trigger, roles: null, options, CancellationToken.None))
{
_logger.LogTrace("Should not insert completions here.");
return new CompletionResponse { Items = ImmutableArray<CompletionItem>.Empty };
}

var (completions, expandedItemsAvailable) = await OmniSharpCompletionService.GetCompletionsAsync(completionService, document, position, trigger);
var (completions, expandedItemsAvailable) = await OmniSharpCompletionService.GetCompletionsAsync(completionService, document, position, trigger, roles: null, options, CancellationToken.None);
_logger.LogTrace("Found {0} completions for {1}:{2},{3}",
completions?.Items.IsDefaultOrEmpty != false ? 0 : completions.Items.Length,
request.FileName,
Expand Down Expand Up @@ -114,7 +119,7 @@ CompletionListBuilder.PartialMethodCompletionProvider or
// that completion provider is still creating the cache. We'll mark this completion list as not completed, and the
// editor will ask again when the user types more. By then, hopefully the cache will have populated and we can mark
// the completion as done.
bool expectingImportedItems = expandedItemsAvailable && _workspace.Options.GetOption(OmniSharpCompletionService.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp) == true;
bool expectingImportedItems = expandedItemsAvailable && _omniSharpOptions.RoslynExtensionsOptions.EnableImportCompletion;
var syntax = await document.GetSyntaxTreeAsync();

var replacingSpanStartPosition = sourceText.Lines.GetLinePosition(typedSpan.Start);
Expand Down Expand Up @@ -150,7 +155,7 @@ public async Task<CompletionResolveResponse> Handle(CompletionResolveRequest req
return new CompletionResolveResponse { Item = request.Item };
}

var (_, document, position, completions) = cachedList;
var (_, document, _, completions) = cachedList;
var index = request.Item.Data.Index;

if (request.Item is null
Expand All @@ -169,14 +174,17 @@ public async Task<CompletionResolveResponse> Handle(CompletionResolveRequest req
}

var completionService = CSharpCompletionService.GetService(document);
RoslynDebug.Assert(completionService != null);

var description = await completionService.GetDescriptionAsync(document, lastCompletionItem);
RoslynDebug.Assert(description != null);

var textBuilder = new StringBuilder();
MarkdownHelpers.TaggedTextToMarkdown(description.TaggedParts, textBuilder, _formattingOptions, MarkdownFormat.FirstLineAsCSharp, out _);

request.Item.Documentation = textBuilder.ToString();

string providerName = lastCompletionItem.GetProviderName();
var providerName = lastCompletionItem.GetProviderName();
switch (providerName)
{
case CompletionListBuilder.ExtensionMethodImportCompletionProvider:
Expand Down Expand Up @@ -243,6 +251,7 @@ public async Task<CompletionAfterInsertResponse> Handle(CompletionAfterInsertReq
}

var completionService = CSharpCompletionService.GetService(document);
RoslynDebug.Assert(completionService != null);

// Get a document with change from the completion inserted, so that we can resolve the completion and get the
// final full change.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static AutoCompleteResponse ToAutoCompleteResponse(this CompletionItem it

// if provider name is "Microsoft.CodeAnalysis.CSharp.Completion.Providers.EmbeddedLanguageCompletionProvider"
// we have access to more elaborate description
if (item.GetProviderName() == CompletionListBuilder.EmeddedLanguageCompletionProvider)
if (item.GetProviderName() == CompletionListBuilder.AggregateEmeddedLanguageCompletionProvider)
{
response.DisplayText = item.InlineDescription;
if (item.Properties.TryGetValue("DescriptionKey", out var description))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using OmniSharp.Roslyn.CSharp.Services.Documentation;
using OmniSharp.Roslyn.CSharp.Services.Completion;
using CompletionService = Microsoft.CodeAnalysis.Completion.CompletionService;
using System.Threading;

namespace OmniSharp.Roslyn.CSharp.Services.Intellisense
{
Expand All @@ -23,13 +24,17 @@ namespace OmniSharp.Roslyn.CSharp.Services.Intellisense
public class IntellisenseService : IRequestHandler<AutoCompleteRequest, IEnumerable<AutoCompleteResponse>>
{
private readonly OmniSharpWorkspace _workspace;

private readonly FormattingOptions _formattingOptions;

private readonly OmniSharpOptions _omniSharpOptions;

[ImportingConstructor]
public IntellisenseService(OmniSharpWorkspace workspace, FormattingOptions formattingOptions)
public IntellisenseService(OmniSharpWorkspace workspace, FormattingOptions formattingOptions, OmniSharpOptions omniSharpOptions)
{
_workspace = workspace;
_formattingOptions = formattingOptions;
_omniSharpOptions = omniSharpOptions;
}

public async Task<IEnumerable<AutoCompleteResponse>> Handle(AutoCompleteRequest request)
Expand All @@ -43,7 +48,8 @@ public async Task<IEnumerable<AutoCompleteResponse>> Handle(AutoCompleteRequest
var sourceText = await document.GetTextAsync();
var position = sourceText.GetTextPosition(request);
var service = CompletionService.GetService(document);
var completionList = await service.GetCompletionsAsync(document, position);
var options = new OmniSharpCompletionOptions(ShowItemsFromUnimportedNamespaces: _omniSharpOptions.RoslynExtensionsOptions.EnableImportCompletion);
var (completionList, expandedItemsAvailable) = await OmniSharpCompletionService.GetCompletionsAsync(service, document, position, trigger: default, roles: null, options, CancellationToken.None);

if (completionList != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public async Task<BlockStructureResponse> Handle(BlockStructureRequest request)

var text = await document.GetTextAsync();

var structure = await OmniSharpBlockStructureService.GetBlockStructureAsync(document, CancellationToken.None);
var options = new OmniSharpBlockStructureOptions(
ShowBlockStructureGuidesForCommentsAndPreprocessorRegions: true,
ShowOutliningForCommentsAndPreprocessorRegions: true);

var structure = await OmniSharpBlockStructureService.GetBlockStructureAsync(document, options, CancellationToken.None);

var outliningSpans = new List<CodeFoldingBlock>();
foreach (var span in structure.Spans)
Expand Down
28 changes: 28 additions & 0 deletions src/OmniSharp.Roslyn/Utilities/Debug.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace Roslyn.Utilities
{
internal static class RoslynDebug
{
/// <inheritdoc cref="Debug.Assert(bool)"/>
[Conditional("DEBUG")]
public static void Assert([DoesNotReturnIf(false)] bool b) => Debug.Assert(b);

/// <inheritdoc cref="Debug.Assert(bool, string)"/>
[Conditional("DEBUG")]
public static void Assert([DoesNotReturnIf(false)] bool b, string message)
=> Debug.Assert(b, message);

[Conditional("DEBUG")]
public static void AssertNotNull<T>([NotNull] T value)
{
Assert(value is object, "Unexpected null reference");
}
}
}
Loading

0 comments on commit 39d0f4a

Please sign in to comment.