From a765c71c085d3594140d8b42dee04a1765da212c Mon Sep 17 00:00:00 2001 From: Todd Grunke Date: Tue, 8 Jun 2021 13:39:45 -0700 Subject: [PATCH 1/5] Prepare for content type renames for aspx/cshtml/html files. These content type names are not yet submitted. Once they have been submitted, there will be a subsequent commit to only remove the old content type names. --- .../Core/Def/Implementation/Venus/ContainedDocument.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs index 94b825545d357..868cbef0d747f 100644 --- a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs +++ b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs @@ -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 = '@'; @@ -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) || + if (projectionBuffer.SourceBuffers.Any(b => b.ContentType.IsOfType(HTML) || + b.ContentType.IsOfType(WebForms) || b.ContentType.IsOfType(HTMLX))) { return HostType.HTML; From 8b85de95e88baf1e7d10d33f11bd64f693a3ccbc Mon Sep 17 00:00:00 2001 From: Todd Grunke Date: Tue, 8 Jun 2021 15:10:57 -0700 Subject: [PATCH 2/5] Cleanup whitespace --- .../Core/Def/Implementation/Venus/ContainedDocument.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs index 868cbef0d747f..aa46fe4f09f16 100644 --- a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs +++ b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs @@ -150,7 +150,7 @@ 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; @@ -158,7 +158,7 @@ private HostType GetHostType() // For TypeScript hosted in HTML the source buffers will have type names // HTMLX and TypeScript. - if (projectionBuffer.SourceBuffers.Any(b => b.ContentType.IsOfType(HTML) || + if (projectionBuffer.SourceBuffers.Any(b => b.ContentType.IsOfType(HTML) || b.ContentType.IsOfType(WebForms) || b.ContentType.IsOfType(HTMLX))) { From 7a180baf99af96c871c449371741aa321baf82bc Mon Sep 17 00:00:00 2001 From: Gen Lu Date: Wed, 9 Jun 2021 14:24:43 -0700 Subject: [PATCH 3/5] updatePublishData --- eng/config/PublishData.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/config/PublishData.json b/eng/config/PublishData.json index fc75d14e9f6d1..3e752dd255d60 100644 --- a/eng/config/PublishData.json +++ b/eng/config/PublishData.json @@ -194,7 +194,7 @@ "version": "4.0.*", "packageFeeds": "default", "channels": [], - "vsBranch": "main", + "vsBranch": "rel/d17.0", "vsMajorVersion": 17 }, "main-vs-deps": { @@ -205,7 +205,7 @@ "version": "4.0.*", "packageFeeds": "default", "channels": [], - "vsBranch": "feature/d17initial", + "vsBranch": "main", "vsMajorVersion": 17 }, "main": { @@ -216,7 +216,7 @@ "version": "4.0.*", "packageFeeds": "arcade", "channels": [], - "vsBranch": "feature/d17initial", + "vsBranch": "main", "vsMajorVersion": 17 }, "features/NullableReferenceTypes": { From 0e940070b483a1631cb2dd8f86716a8de573c454 Mon Sep 17 00:00:00 2001 From: Allison Chou Date: Wed, 9 Jun 2021 15:51:38 -0700 Subject: [PATCH 4/5] [LSP] Add Razor options provider to Roslyn (#53879) --- .../Portable/Completion/CompletionProvider.cs | 7 +- .../Shared/Extensions/DocumentExtensions.cs | 1 - .../Completion/CompletionResolveHandler.cs | 1 - .../AbstractPullDiagnosticHandler.cs | 1 - src/Tools/ExternalAccess/Razor/Extensions.cs | 24 ++++++ .../Razor/IRazorDocumentOptions.cs | 13 ++++ .../Razor/IRazorDocumentOptionsService.cs | 15 ++++ .../RazorDocumentOptionsProviderFactory.cs | 75 +++++++++++++++++++ .../RazorDocumentServiceProviderWrapper.cs | 7 +- .../Razor/RazorSpanMappingServiceWrapper.cs | 2 - 10 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 src/Tools/ExternalAccess/Razor/Extensions.cs create mode 100644 src/Tools/ExternalAccess/Razor/IRazorDocumentOptions.cs create mode 100644 src/Tools/ExternalAccess/Razor/IRazorDocumentOptionsService.cs create mode 100644 src/Tools/ExternalAccess/Razor/RazorDocumentOptionsProviderFactory.cs diff --git a/src/Features/Core/Portable/Completion/CompletionProvider.cs b/src/Features/Core/Portable/Completion/CompletionProvider.cs index b01c8e502f1dc..013a77072b639 100644 --- a/src/Features/Core/Portable/Completion/CompletionProvider.cs +++ b/src/Features/Core/Portable/Completion/CompletionProvider.cs @@ -69,11 +69,8 @@ public virtual Task GetDescriptionAsync(Document document /// The item to be committed. /// The optional key character that caused the commit. /// - public virtual Task GetChangeAsync( - Document document, CompletionItem item, char? commitKey, CancellationToken cancellationToken) - { - return Task.FromResult(CompletionChange.Create(new TextChange(item.Span, item.DisplayText))); - } + public virtual Task GetChangeAsync(Document document, CompletionItem item, char? commitKey, CancellationToken cancellationToken) + => Task.FromResult(CompletionChange.Create(new TextChange(item.Span, item.DisplayText))); /// /// True if the provider produces snippet items. diff --git a/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs b/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs index 15193cbbfcfd6..776307b6cdf2f 100644 --- a/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs +++ b/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs @@ -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; diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs index 001f20c589150..736eb330686c0 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs @@ -4,7 +4,6 @@ using System; using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Completion; diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs index 00472af69e679..c2d7c278a07c1 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs @@ -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; diff --git a/src/Tools/ExternalAccess/Razor/Extensions.cs b/src/Tools/ExternalAccess/Razor/Extensions.cs new file mode 100644 index 0000000000000..bb0a4c895776f --- /dev/null +++ b/src/Tools/ExternalAccess/Razor/Extensions.cs @@ -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(); + if (documentPropertiesService != null && documentPropertiesService.DiagnosticsLspClientName == RazorCSharp) + { + return true; + } + + return false; + } + } +} diff --git a/src/Tools/ExternalAccess/Razor/IRazorDocumentOptions.cs b/src/Tools/ExternalAccess/Razor/IRazorDocumentOptions.cs new file mode 100644 index 0000000000000..f3948be3e0560 --- /dev/null +++ b/src/Tools/ExternalAccess/Razor/IRazorDocumentOptions.cs @@ -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); + } +} diff --git a/src/Tools/ExternalAccess/Razor/IRazorDocumentOptionsService.cs b/src/Tools/ExternalAccess/Razor/IRazorDocumentOptionsService.cs new file mode 100644 index 0000000000000..93cd5ff498f15 --- /dev/null +++ b/src/Tools/ExternalAccess/Razor/IRazorDocumentOptionsService.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.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Host; + +namespace Microsoft.CodeAnalysis.ExternalAccess.Razor +{ + internal interface IRazorDocumentOptionsService : IDocumentService + { + Task GetOptionsForDocumentAsync(Document document, CancellationToken cancellationToken); + } +} diff --git a/src/Tools/ExternalAccess/Razor/RazorDocumentOptionsProviderFactory.cs b/src/Tools/ExternalAccess/Razor/RazorDocumentOptionsProviderFactory.cs new file mode 100644 index 0000000000000..b8d9394e72616 --- /dev/null +++ b/src/Tools/ExternalAccess/Razor/RazorDocumentOptionsProviderFactory.cs @@ -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 _innerRazorDocumentOptionsService; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public RazorDocumentOptionsProviderFactory( + Lazy 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 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); + } + } +} diff --git a/src/Tools/ExternalAccess/Razor/RazorDocumentServiceProviderWrapper.cs b/src/Tools/ExternalAccess/Razor/RazorDocumentServiceProviderWrapper.cs index 825896e64b191..63fc07b6e2c3e 100644 --- a/src/Tools/ExternalAccess/Razor/RazorDocumentServiceProviderWrapper.cs +++ b/src/Tools/ExternalAccess/Razor/RazorDocumentServiceProviderWrapper.cs @@ -30,7 +30,8 @@ public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDo public TService? GetService() where TService : class, IDocumentService { - if (typeof(TService) == typeof(ISpanMappingService)) + var serviceType = typeof(TService); + if (serviceType == typeof(ISpanMappingService)) { if (_spanMappingService == null) { @@ -54,7 +55,7 @@ public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDo return (TService)(object)_spanMappingService; } - if (typeof(TService) == typeof(IDocumentExcerptService)) + if (serviceType == typeof(IDocumentExcerptService)) { if (_excerptService == null) { @@ -78,7 +79,7 @@ public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDo return (TService)(object)_excerptService; } - if (typeof(TService) == typeof(DocumentPropertiesService)) + if (serviceType == typeof(DocumentPropertiesService)) { if (_documentPropertiesService == null) { diff --git a/src/Tools/ExternalAccess/Razor/RazorSpanMappingServiceWrapper.cs b/src/Tools/ExternalAccess/Razor/RazorSpanMappingServiceWrapper.cs index ddd37a1577a3d..e3bbd1be26c77 100644 --- a/src/Tools/ExternalAccess/Razor/RazorSpanMappingServiceWrapper.cs +++ b/src/Tools/ExternalAccess/Razor/RazorSpanMappingServiceWrapper.cs @@ -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 { From 8b12a25af17e86df309be5c464e7bf6c60d34849 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Wed, 9 Jun 2021 16:59:39 -0700 Subject: [PATCH 5/5] Record "extended property patterns" feature as done (#53953) * Record "extended property patterns" feature as done * Add "async method builder override" feature --- docs/Language Feature Status.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/Language Feature Status.md b/docs/Language Feature Status.md index 1e1fcaa5df24f..6f8cd5a4052a3 100644 --- a/docs/Language Feature Status.md +++ b/docs/Language Feature Status.md @@ -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