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

Merge main to main-vs-deps #53983

Merged
7 commits merged into from
Jun 10, 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
3 changes: 2 additions & 1 deletion docs/Language Feature Status.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ efforts behind them.
| [Constant Interpolated Strings](https://github.com/dotnet/csharplang/issues/2951) | main | [Merged into 16.9p3](https://github.com/dotnet/roslyn/pull/49676) | [kevinsun-dev](https://github.com/kevinsun-dev) | [333fred](https://github.com/333fred) | [jaredar](https://github.com/jaredpar), [agocke](https://github.com/agocke) |
| [Mix declarations and variables in deconstruction](https://github.com/dotnet/csharplang/issues/125) | main | [Merged into 16.10](https://github.com/dotnet/roslyn/issues/47746) | [YairHalberstadt ](https://github.com/YairHalberstadt) | [jcouv](https://github.com/jcouv) | [MadsTorgersen](https://github.com/MadsTorgersen) |
| [List patterns](https://github.com/dotnet/csharplang/issues/3435) | [list-patterns](https://github.com/dotnet/roslyn/tree/features/list-patterns) | [In Progress](https://github.com/dotnet/roslyn/issues/51289) | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv), [333fred](https://github.com/333fred) | [333fred](https://github.com/333fred) |
| [Extended property patterns](https://github.com/dotnet/csharplang/issues/4394) | [extended-property-patterns](https://github.com/dotnet/roslyn/tree/features/extended-property-patterns) | [In Progress](https://github.com/dotnet/roslyn/issues/52468) | [alrz](https://github.com/alrz) | [333fred](https://github.com/333fred) (Tentative), [jcouv](https://github.com/jcouv) | [333fred](https://github.com/333fred) |
| [Extended property patterns](https://github.com/dotnet/csharplang/issues/4394) | [extended-property-patterns](https://github.com/dotnet/roslyn/tree/features/extended-property-patterns) | [Merged into 17.0](https://github.com/dotnet/roslyn/issues/52468) | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv), [333fred](https://github.com/333fred) | [333fred](https://github.com/333fred) |
| [Sealed record ToString](https://github.com/dotnet/csharplang/issues/4174) | main | [Merged](https://github.com/dotnet/roslyn/issues/52031) | [thomaslevesque](https://github.com/thomaslevesque/) | [jcouv](https://github.com/jcouv) | [333fred](https://github.com/333fred) |
| [Source Generator V2 APIs](https://github.com/dotnet/roslyn/issues/51257) | [features/source-generators](https://github.com/dotnet/roslyn/tree/features/source-generators) | [In Progress](https://github.com/dotnet/roslyn/issues/51257) | [chsienki](https://github.com/chsienki/) | [rikkigibson](https://github.com/rikkigibson), [jaredpar](https://github.com/jaredpar), [cston](https://github.com/cston) | N/A |
| [Async method builder override](https://github.com/dotnet/csharplang/issues/1407) | main | [In Progress](https://github.com/dotnet/roslyn/issues/51999) | [jcouv](https://github.com/jcouv) | TBD | [stephentoub](https://github.com/stephentoub) |

# VB 16.9

Expand Down
6 changes: 3 additions & 3 deletions eng/config/PublishData.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"version": "4.0.*",
"packageFeeds": "default",
"channels": [],
"vsBranch": "main",
"vsBranch": "rel/d17.0",
"vsMajorVersion": 17
},
"main-vs-deps": {
Expand All @@ -205,7 +205,7 @@
"version": "4.0.*",
"packageFeeds": "default",
"channels": [],
"vsBranch": "feature/d17initial",
"vsBranch": "main",
"vsMajorVersion": 17
},
"main": {
Expand All @@ -216,7 +216,7 @@
"version": "4.0.*",
"packageFeeds": "arcade",
"channels": [],
"vsBranch": "feature/d17initial",
"vsBranch": "main",
"vsMajorVersion": 17
},
"features/NullableReferenceTypes": {
Expand Down
7 changes: 2 additions & 5 deletions src/Features/Core/Portable/Completion/CompletionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ public virtual Task<CompletionDescription> GetDescriptionAsync(Document document
/// <param name="item">The item to be committed.</param>
/// <param name="commitKey">The optional key character that caused the commit.</param>
/// <param name="cancellationToken"></param>
public virtual Task<CompletionChange> GetChangeAsync(
Document document, CompletionItem item, char? commitKey, CancellationToken cancellationToken)
{
return Task.FromResult(CompletionChange.Create(new TextChange(item.Span, item.DisplayText)));
}
public virtual Task<CompletionChange> GetChangeAsync(Document document, CompletionItem item, char? commitKey, CancellationToken cancellationToken)
=> Task.FromResult(CompletionChange.Create(new TextChange(item.Span, item.DisplayText)));

/// <summary>
/// True if the provider produces snippet items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Naming;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Completion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Text;
Expand Down
24 changes: 24 additions & 0 deletions src/Tools/ExternalAccess/Razor/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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.Host;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor
{
internal static class Extensions
{
private const string RazorCSharp = "RazorCSharp";

public static bool IsRazorDocument(this Document document)
{
var documentPropertiesService = document.Services.GetService<DocumentPropertiesService>();
if (documentPropertiesService != null && documentPropertiesService.DiagnosticsLspClientName == RazorCSharp)
{
return true;
}

return false;
}
}
}
13 changes: 13 additions & 0 deletions src/Tools/ExternalAccess/Razor/IRazorDocumentOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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.Options;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor
{
internal interface IRazorDocumentOptions
{
bool TryGetDocumentOption(OptionKey option, out object? value);
}
}
15 changes: 15 additions & 0 deletions src/Tools/ExternalAccess/Razor/IRazorDocumentOptionsService.cs
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.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor
{
internal interface IRazorDocumentOptionsService : IDocumentService
{
Task<IRazorDocumentOptions> GetOptionsForDocumentAsync(Document document, CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor
{
[Shared]
[Export(typeof(IDocumentOptionsProviderFactory))]
internal sealed class RazorDocumentOptionsProviderFactory : IDocumentOptionsProviderFactory
{
private readonly Lazy<IRazorDocumentOptionsService> _innerRazorDocumentOptionsService;

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public RazorDocumentOptionsProviderFactory(
Lazy<IRazorDocumentOptionsService> innerRazorDocumentOptionsService)
{
if (innerRazorDocumentOptionsService is null)
{
throw new ArgumentNullException(nameof(innerRazorDocumentOptionsService));
}

_innerRazorDocumentOptionsService = innerRazorDocumentOptionsService;
}

public IDocumentOptionsProvider? TryCreate(Workspace workspace)
{
var optionsService = _innerRazorDocumentOptionsService.Value;
return new RazorDocumentOptionsProvider(optionsService);
}

private sealed class RazorDocumentOptionsProvider : IDocumentOptionsProvider
{
public readonly IRazorDocumentOptionsService RazorDocumentOptionsService;

public RazorDocumentOptionsProvider(IRazorDocumentOptionsService razorDocumentOptionsService)
{
RazorDocumentOptionsService = razorDocumentOptionsService;
}

public async Task<IDocumentOptions?> GetOptionsForDocumentAsync(Document document, CancellationToken cancellationToken)
{
if (!document.IsRazorDocument())
{
return null;
}

var options = await RazorDocumentOptionsService.GetOptionsForDocumentAsync(document, cancellationToken).ConfigureAwait(false);
return new RazorDocumentOptions(options);
}
}

// Used to convert IRazorDocumentOptions -> IDocumentOptions
private sealed class RazorDocumentOptions : IDocumentOptions
{
private readonly IRazorDocumentOptions _razorOptions;

public RazorDocumentOptions(IRazorDocumentOptions razorOptions)
{
_razorOptions = razorOptions;
}

public bool TryGetDocumentOption(OptionKey option, out object? value)
=> _razorOptions.TryGetDocumentOption(option, out value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDo

public TService? GetService<TService>() where TService : class, IDocumentService
{
if (typeof(TService) == typeof(ISpanMappingService))
var serviceType = typeof(TService);
if (serviceType == typeof(ISpanMappingService))
{
if (_spanMappingService == null)
{
Expand All @@ -54,7 +55,7 @@ public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDo
return (TService)(object)_spanMappingService;
}

if (typeof(TService) == typeof(IDocumentExcerptService))
if (serviceType == typeof(IDocumentExcerptService))
{
if (_excerptService == null)
{
Expand All @@ -78,7 +79,7 @@ public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDo
return (TService)(object)_excerptService;
}

if (typeof(TService) == typeof(DocumentPropertiesService))
if (serviceType == typeof(DocumentPropertiesService))
{
if (_documentPropertiesService == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ internal sealed partial class ContainedDocument : ForegroundThreadAffinitizedObj

private const string HTML = nameof(HTML);
private const string HTMLX = nameof(HTMLX);
private const string LegacyRazor = nameof(LegacyRazor);
private const string Razor = nameof(Razor);
private const string XOML = nameof(XOML);
private const string WebForms = nameof(WebForms);

private const char RazorExplicit = '@';

Expand Down Expand Up @@ -148,14 +150,16 @@ private HostType GetHostType()
{
// RazorCSharp has an HTMLX base type but should not be associated with
// the HTML host type, so we check for it first.
if (projectionBuffer.SourceBuffers.Any(b => b.ContentType.IsOfType(Razor)))
if (projectionBuffer.SourceBuffers.Any(b => b.ContentType.IsOfType(Razor) ||
b.ContentType.IsOfType(LegacyRazor)))
{
return HostType.Razor;
}

// For TypeScript hosted in HTML the source buffers will have type names
// HTMLX and TypeScript.
if (projectionBuffer.SourceBuffers.Any(b => b.ContentType.IsOfType(HTML) ||
b.ContentType.IsOfType(WebForms) ||
b.ContentType.IsOfType(HTMLX)))
{
return HostType.HTML;
Expand Down