From cb0ae1321eccd2fa29227199362f679dd0c043db Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 2 Sep 2024 15:01:37 +1000 Subject: [PATCH 01/19] Move trigger characters and logic to the formatting service So it can be shared --- .../DocumentOnTypeFormattingEndpoint.cs | 48 ++----------------- .../Formatting/IRazorFormattingService.cs | 8 ++++ .../Formatting/RazorFormattingService.cs | 37 ++++++++++++++ .../DocumentOnTypeFormattingEndpointTest.cs | 37 +------------- .../FormattingLanguageServerTestBase.cs | 9 +++- .../RazorFormattingServiceTest.cs | 27 +++++++++++ 6 files changed, 87 insertions(+), 79 deletions(-) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs index e72d79f83c..6568e9deb3 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Hosting; using Microsoft.CodeAnalysis.Razor.DocumentMapping; using Microsoft.CodeAnalysis.Razor.Formatting; using Microsoft.CodeAnalysis.Razor.Logging; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; @@ -36,20 +37,14 @@ internal class DocumentOnTypeFormattingEndpoint( private readonly IHtmlFormatter _htmlFormatter = htmlFormatter; private readonly ILogger _logger = loggerFactory.GetOrCreateLogger(); - private static readonly ImmutableArray s_allTriggerCharacters = ["}", ";", "\n", "{"]; - - private static readonly FrozenSet s_csharpTriggerCharacterSet = FrozenSet.ToFrozenSet(["}", ";"], StringComparer.Ordinal); - private static readonly FrozenSet s_htmlTriggerCharacterSet = FrozenSet.ToFrozenSet(["\n", "{", "}", ";"], StringComparer.Ordinal); - private static readonly FrozenSet s_allTriggerCharacterSet = s_allTriggerCharacters.ToFrozenSet(StringComparer.Ordinal); - public bool MutatesSolutionState => false; public void ApplyCapabilities(VSInternalServerCapabilities serverCapabilities, VSInternalClientCapabilities clientCapabilities) { serverCapabilities.DocumentOnTypeFormattingProvider = new DocumentOnTypeFormattingOptions { - FirstTriggerCharacter = s_allTriggerCharacters[0], - MoreTriggerCharacter = s_allTriggerCharacters.AsSpan()[1..].ToArray(), + FirstTriggerCharacter = RazorFormattingService.AllTriggerCharacters[0], + MoreTriggerCharacter = RazorFormattingService.AllTriggerCharacters.AsSpan()[1..].ToArray(), }; } @@ -74,7 +69,7 @@ internal class DocumentOnTypeFormattingEndpoint( return null; } - if (!s_allTriggerCharacterSet.Contains(request.Character)) + if (!RazorFormattingService.AllTriggerCharacterSet.Contains(request.Character)) { _logger.LogWarning($"Unexpected trigger character '{request.Character}'."); return null; @@ -102,24 +97,13 @@ internal class DocumentOnTypeFormattingEndpoint( return null; } - var triggerCharacterKind = _documentMappingService.GetLanguageKind(codeDocument, hostDocumentIndex, rightAssociative: false); - if (triggerCharacterKind is not (RazorLanguageKind.CSharp or RazorLanguageKind.Html)) + if (_razorFormattingService.TryGetOnTypeFormattingTriggerKind(codeDocument, hostDocumentIndex, request.Character, out var triggerCharacterKind)) { - _logger.LogInformation($"Unsupported trigger character language {triggerCharacterKind:G}."); - return null; - } - - if (!IsApplicableTriggerCharacter(request.Character, triggerCharacterKind)) - { - // We were triggered but the trigger character doesn't make sense for the current cursor position. Bail. - _logger.LogInformation($"Unsupported trigger character location."); return null; } cancellationToken.ThrowIfCancellationRequested(); - Debug.Assert(request.Character.Length > 0); - var options = RazorFormattingOptions.From(request.Options, _optionsMonitor.CurrentValue.CodeBlockBraceOnNextLine); TextEdit[] formattedEdits; @@ -147,26 +131,4 @@ internal class DocumentOnTypeFormattingEndpoint( _logger.LogInformation($"Returning {formattedEdits.Length} final formatted results."); return formattedEdits; } - - private static bool IsApplicableTriggerCharacter(string triggerCharacter, RazorLanguageKind languageKind) - { - if (languageKind == RazorLanguageKind.CSharp) - { - return s_csharpTriggerCharacterSet.Contains(triggerCharacter); - } - else if (languageKind == RazorLanguageKind.Html) - { - return s_htmlTriggerCharacterSet.Contains(triggerCharacter); - } - - // Unknown trigger character. - return false; - } - - internal static class TestAccessor - { - public static ImmutableArray GetAllTriggerCharacters() => s_allTriggerCharacters; - public static FrozenSet GetCSharpTriggerCharacterSet() => s_csharpTriggerCharacterSet; - public static FrozenSet GetHtmlTriggerCharacterSet() => s_htmlTriggerCharacterSet; - } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/IRazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/IRazorFormattingService.cs index 1ad189e90f..5974e7f18a 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/IRazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/IRazorFormattingService.cs @@ -3,7 +3,9 @@ using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.Razor.Formatting; @@ -49,4 +51,10 @@ internal interface IRazorFormattingService TextEdit[] csharpEdits, RazorFormattingOptions options, CancellationToken cancellationToken); + + bool TryGetOnTypeFormattingTriggerKind( + RazorCodeDocument codeDocument, + int hostDocumentIndex, + string triggerCharacter, + out RazorLanguageKind triggerCharacterKind); } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs index d9f012ff88..ea201061f0 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT license. See License.txt in the project root for license information. +using System; +using System.Collections.Frozen; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -11,6 +13,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor.DocumentMapping; using Microsoft.CodeAnalysis.Razor.Logging; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; @@ -20,7 +23,14 @@ namespace Microsoft.CodeAnalysis.Razor.Formatting; internal class RazorFormattingService : IRazorFormattingService { + public static readonly ImmutableArray AllTriggerCharacters = ["}", ";", "\n", "{"]; + public static readonly FrozenSet AllTriggerCharacterSet = AllTriggerCharacters.ToFrozenSet(StringComparer.Ordinal); + + private static readonly FrozenSet s_csharpTriggerCharacterSet = FrozenSet.ToFrozenSet(["}", ";"], StringComparer.Ordinal); + private static readonly FrozenSet s_htmlTriggerCharacterSet = FrozenSet.ToFrozenSet(["\n", "{", "}", ";"], StringComparer.Ordinal); + private readonly IFormattingCodeDocumentProvider _codeDocumentProvider; + private readonly IDocumentMappingService _documentMappingService; private readonly IAdhocWorkspaceFactory _workspaceFactory; private readonly ImmutableArray _documentFormattingPasses; @@ -35,6 +45,7 @@ internal class RazorFormattingService : IRazorFormattingService ILoggerFactory loggerFactory) { _codeDocumentProvider = codeDocumentProvider; + _documentMappingService = documentMappingService; _workspaceFactory = workspaceFactory; _htmlOnTypeFormattingPass = new HtmlOnTypeFormattingPass(loggerFactory); @@ -185,6 +196,26 @@ internal class RazorFormattingService : IRazorFormattingService return razorEdits.SingleOrDefault(); } + public bool TryGetOnTypeFormattingTriggerKind(RazorCodeDocument codeDocument, int hostDocumentIndex, string triggerCharacter, out RazorLanguageKind triggerCharacterKind) + { + triggerCharacterKind = _documentMappingService.GetLanguageKind(codeDocument, hostDocumentIndex, rightAssociative: false); + if (triggerCharacterKind is not (RazorLanguageKind.CSharp or RazorLanguageKind.Html)) + { + return false; + } + + if (triggerCharacterKind == RazorLanguageKind.CSharp) + { + return s_csharpTriggerCharacterSet.Contains(triggerCharacter); + } + else if (triggerCharacterKind == RazorLanguageKind.Html) + { + return s_htmlTriggerCharacterSet.Contains(triggerCharacter); + } + + return true; + } + private async Task ApplyFormattedEditsAsync( DocumentContext documentContext, TextEdit[] generatedDocumentEdits, @@ -279,4 +310,10 @@ internal class RazorFormattingService : IRazorFormattingService edit.NewText = edit.NewText.Replace("/*$0*/", "$0"); } } + + internal static class TestAccessor + { + public static FrozenSet GetCSharpTriggerCharacterSet() => s_csharpTriggerCharacterSet; + public static FrozenSet GetHtmlTriggerCharacterSet() => s_htmlTriggerCharacterSet; + } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentOnTypeFormattingEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentOnTypeFormattingEndpointTest.cs index 776cb9a295..5448d383ab 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentOnTypeFormattingEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentOnTypeFormattingEndpointTest.cs @@ -2,8 +2,6 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; @@ -19,37 +17,6 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting; public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) : FormattingLanguageServerTestBase(testOutput) { - [Fact] - public void AllTriggerCharacters_IncludesCSharpTriggerCharacters() - { - var allChars = DocumentOnTypeFormattingEndpoint.TestAccessor.GetAllTriggerCharacters(); - - foreach (var character in DocumentOnTypeFormattingEndpoint.TestAccessor.GetCSharpTriggerCharacterSet()) - { - Assert.Contains(character, allChars); - } - } - - [Fact] - public void AllTriggerCharacters_IncludesHtmlTriggerCharacters() - { - var allChars = DocumentOnTypeFormattingEndpoint.TestAccessor.GetAllTriggerCharacters(); - - foreach (var character in DocumentOnTypeFormattingEndpoint.TestAccessor.GetHtmlTriggerCharacterSet()) - { - Assert.Contains(character, allChars); - } - } - - [Fact] - public void AllTriggerCharacters_ContainsUniqueCharacters() - { - var allChars = DocumentOnTypeFormattingEndpoint.TestAccessor.GetAllTriggerCharacters(); - var distinctChars = allChars.Distinct().ToArray(); - - Assert.Equal(distinctChars, allChars); - } - [Fact] public async Task Handle_OnTypeFormatting_FormattingDisabled_ReturnsNull() { @@ -154,7 +121,7 @@ public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) var uri = new Uri("file://path/test.razor"); var documentContext = CreateDocumentContext(uri, codeDocument); - var formattingService = new DummyRazorFormattingService(); + var formattingService = new DummyRazorFormattingService(RazorLanguageKind.Html); var documentMappingService = new Mock(MockBehavior.Strict); documentMappingService.Setup(s => s.GetLanguageKind(codeDocument, 17, false)).Returns(RazorLanguageKind.Html); @@ -190,7 +157,7 @@ public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) var uri = new Uri("file://path/test.razor"); var documentContext = CreateDocumentContext(uri, codeDocument); - var formattingService = new DummyRazorFormattingService(); + var formattingService = new DummyRazorFormattingService(RazorLanguageKind.Razor); var documentMappingService = new Mock(MockBehavior.Strict); documentMappingService.Setup(s => s.GetLanguageKind(codeDocument, 17, false)).Returns(RazorLanguageKind.Razor); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerTestBase.cs index bf6ce5a569..d14e475aa5 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerTestBase.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; using Microsoft.AspNetCore.Razor.Threading; using Microsoft.CodeAnalysis.Razor.Formatting; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit.Abstractions; using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range; @@ -31,7 +32,7 @@ public abstract class FormattingLanguageServerTestBase(ITestOutputHelper testOut return codeDocument; } - internal class DummyRazorFormattingService : IRazorFormattingService + internal class DummyRazorFormattingService(RazorLanguageKind? languageKind = null) : IRazorFormattingService { public bool Called { get; private set; } @@ -65,5 +66,11 @@ public abstract class FormattingLanguageServerTestBase(ITestOutputHelper testOut { throw new NotImplementedException(); } + + public bool TryGetOnTypeFormattingTriggerKind(RazorCodeDocument codeDocument, int hostDocumentIndex, string triggerCharacter, out RazorLanguageKind triggerCharacterKind) + { + triggerCharacterKind = languageKind ?? RazorLanguageKind.CSharp; + return languageKind is not null; + } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingServiceTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingServiceTest.cs index 67a2f3e182..b3d38ddd5b 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingServiceTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingServiceTest.cs @@ -40,4 +40,31 @@ public class Foo{} Assert.Equal(multiEditChange.ToString(), singleEditChange.ToString()); } + + [Fact] + public void AllTriggerCharacters_IncludesCSharpTriggerCharacters() + { + foreach (var character in RazorFormattingService.TestAccessor.GetCSharpTriggerCharacterSet()) + { + Assert.Contains(character, RazorFormattingService.AllTriggerCharacters); + } + } + + [Fact] + public void AllTriggerCharacters_IncludesHtmlTriggerCharacters() + { + foreach (var character in RazorFormattingService.TestAccessor.GetHtmlTriggerCharacterSet()) + { + Assert.Contains(character, RazorFormattingService.AllTriggerCharacters); + } + } + + [Fact] + public void AllTriggerCharacters_ContainsUniqueCharacters() + { + var allChars = RazorFormattingService.AllTriggerCharacters; + var distinctChars = allChars.Distinct().ToArray(); + + Assert.Equal(distinctChars, allChars); + } } From 3da875b6fe51c63c4a3754f9a0352670f9aad35c Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 2 Sep 2024 15:02:42 +1000 Subject: [PATCH 02/19] Create remote formatting service that delegates to the Razor formatting service --- eng/targets/Services.props | 1 + .../Formatting/RazorFormattingOptions.cs | 5 + .../Remote/IRemoteFormattingService.cs | 26 +++ .../Remote/RazorServices.cs | 1 + .../Formatting/RemoteFormattingService.cs | 175 ++++++++++++++++++ 5 files changed, 208 insertions(+) create mode 100644 src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFormattingService.cs create mode 100644 src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingService.cs diff --git a/eng/targets/Services.props b/eng/targets/Services.props index b2476eab94..03343f4a39 100644 --- a/eng/targets/Services.props +++ b/eng/targets/Services.props @@ -29,5 +29,6 @@ + diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs index a0397ec80f..a1ab2f6a3e 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs @@ -1,17 +1,22 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT license. See License.txt in the project root for license information. +using System.Runtime.Serialization; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.Razor.Formatting; +[DataContract] internal readonly record struct RazorFormattingOptions { public static readonly RazorFormattingOptions Default = new(); + [DataMember(Order = 0)] public bool InsertSpaces { get; init; } = true; + [DataMember(Order = 1)] public int TabSize { get; init; } = 4; + [DataMember(Order = 2)] public bool CodeBlockBraceOnNextLine { get; init; } = false; public RazorFormattingOptions() diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFormattingService.cs new file mode 100644 index 0000000000..8a1b7aa379 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFormattingService.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Microsoft.CodeAnalysis.Razor.Formatting; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor.Remote; + +internal interface IRemoteFormattingService +{ + ValueTask> GetDocumentFormattingEditsAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId documentId, ImmutableArray htmlChanges, RazorFormattingOptions options, CancellationToken cancellationToken); + ValueTask> GetRangeFormattingEditsAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId documentId, ImmutableArray htmlChanges, LinePositionSpan linePositionSpan, RazorFormattingOptions options, CancellationToken cancellationToken); + ValueTask> GetOnTypeFormattingEditsAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId documentId, ImmutableArray htmlChanges, LinePosition linePosition, string triggerCharacter, RazorFormattingOptions options, CancellationToken cancellationToken); + ValueTask GetOnTypeFormattingTriggerKindAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId documentId, LinePosition linePosition, string triggerCharacter, CancellationToken cancellationToken); + + internal enum TriggerKind + { + Invalid, + ValidHtml, + ValidCSharp, + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs index 558b737d4c..1974d72c49 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs @@ -22,6 +22,7 @@ internal static class RazorServices (typeof(IRemoteFoldingRangeService), null), (typeof(IRemoteDocumentHighlightService), null), (typeof(IRemoteAutoInsertService), null), + (typeof(IRemoteFormattingService), null), ]; // Internal for testing diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingService.cs new file mode 100644 index 0000000000..e0dc5d35ac --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingService.cs @@ -0,0 +1,175 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor; +using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Microsoft.CodeAnalysis.Razor.Formatting; +using Microsoft.CodeAnalysis.Razor.Protocol; +using Microsoft.CodeAnalysis.Razor.Remote; +using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Response = Microsoft.CodeAnalysis.Razor.Remote.IRemoteFormattingService.TriggerKind; + +namespace Microsoft.CodeAnalysis.Remote.Razor; + +internal sealed class RemoteFormattingService(in ServiceArgs args) : RazorDocumentServiceBase(in args), IRemoteFormattingService +{ + internal sealed class Factory : FactoryBase + { + protected override IRemoteFormattingService CreateService(in ServiceArgs args) + => new RemoteFormattingService(in args); + } + + private readonly IRazorFormattingService _formattingService = args.ExportProvider.GetExportedValue(); + + public ValueTask> GetDocumentFormattingEditsAsync( + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + ImmutableArray htmlChanges, + RazorFormattingOptions options, + CancellationToken cancellationToken) + => RunServiceAsync( + solutionInfo, + documentId, + context => GetDocumentFormattingEditsAsync(context, htmlChanges, options, cancellationToken), + cancellationToken); + + private async ValueTask> GetDocumentFormattingEditsAsync( + RemoteDocumentContext context, + ImmutableArray htmlChanges, + RazorFormattingOptions options, + CancellationToken cancellationToken) + { + var sourceText = await context.GetSourceTextAsync(cancellationToken).ConfigureAwait(false); + var htmlEdits = htmlChanges.Select(sourceText.GetTextEdit).ToArray(); + + var edits = await _formattingService.GetDocumentFormattingEditsAsync(context, htmlEdits, range: null, options, cancellationToken).ConfigureAwait(false); + + if (edits is null) + { + return ImmutableArray.Empty; + } + + return edits.SelectAsArray(sourceText.GetTextChange); + } + + public ValueTask> GetRangeFormattingEditsAsync( + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + ImmutableArray htmlChanges, + LinePositionSpan linePositionSpan, + RazorFormattingOptions options, + CancellationToken cancellationToken) + => RunServiceAsync( + solutionInfo, + documentId, + context => GetRangeFormattingEditsAsync(context, htmlChanges, linePositionSpan, options, cancellationToken), + cancellationToken); + + private async ValueTask> GetRangeFormattingEditsAsync( + RemoteDocumentContext context, + ImmutableArray htmlChanges, + LinePositionSpan linePositionSpan, + RazorFormattingOptions options, + CancellationToken cancellationToken) + { + var sourceText = await context.GetSourceTextAsync(cancellationToken).ConfigureAwait(false); + var htmlEdits = htmlChanges.Select(sourceText.GetTextEdit).ToArray(); + + var edits = await _formattingService.GetDocumentFormattingEditsAsync(context, htmlEdits, range: linePositionSpan.ToRange(), options, cancellationToken).ConfigureAwait(false); + + if (edits is null) + { + return ImmutableArray.Empty; + } + + return edits.SelectAsArray(sourceText.GetTextChange); + } + + public ValueTask> GetOnTypeFormattingEditsAsync( + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + ImmutableArray htmlChanges, + LinePosition linePosition, + string character, + RazorFormattingOptions options, + CancellationToken cancellationToken) + => RunServiceAsync( + solutionInfo, + documentId, + context => GetOnTypeFormattingEditsAsync(context, htmlChanges, linePosition, character, options, cancellationToken), + cancellationToken); + + private async ValueTask> GetOnTypeFormattingEditsAsync(RemoteDocumentContext context, ImmutableArray htmlChanges, LinePosition linePosition, string triggerCharacter, RazorFormattingOptions options, CancellationToken cancellationToken) + { + var codeDocument = await context.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false); + var sourceText = await context.GetSourceTextAsync(cancellationToken).ConfigureAwait(false); + if (!sourceText.TryGetAbsoluteIndex(linePosition, out var hostDocumentIndex)) + { + return []; + } + + if (!_formattingService.TryGetOnTypeFormattingTriggerKind(codeDocument, hostDocumentIndex, triggerCharacter, out var triggerCharacterKind)) + { + return []; + } + + TextEdit[] result; + if (triggerCharacterKind is RazorLanguageKind.Html) + { + var htmlEdits = htmlChanges.Select(sourceText.GetTextEdit).ToArray(); + result = await _formattingService.GetHtmlOnTypeFormattingEditsAsync(context, htmlEdits, options, hostDocumentIndex, triggerCharacter[0], cancellationToken).ConfigureAwait(false); + } + else if (triggerCharacterKind is RazorLanguageKind.CSharp) + { + result = await _formattingService.GetCSharpOnTypeFormattingEditsAsync(context, options, hostDocumentIndex, triggerCharacter[0], cancellationToken).ConfigureAwait(false); + } + else + { + Assumed.Unreachable(); + return []; + } + + return result.SelectAsArray(sourceText.GetTextChange); + } + + public ValueTask GetOnTypeFormattingTriggerKindAsync( + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + LinePosition linePosition, + string triggerCharacter, + CancellationToken cancellationToken) + => RunServiceAsync( + solutionInfo, + documentId, + context => IsValidOnTypeFormattingTriggerAsync(context, linePosition, triggerCharacter, cancellationToken), + cancellationToken); + + private async ValueTask IsValidOnTypeFormattingTriggerAsync(RemoteDocumentContext context, LinePosition linePosition, string triggerCharacter, CancellationToken cancellationToken) + { + var codeDocument = await context.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false); + var sourceText = await context.GetSourceTextAsync(cancellationToken).ConfigureAwait(false); + if (!sourceText.TryGetAbsoluteIndex(linePosition, out var hostDocumentIndex)) + { + return Response.Invalid; + } + + if (!_formattingService.TryGetOnTypeFormattingTriggerKind(codeDocument, hostDocumentIndex, triggerCharacter, out var triggerCharacterKind)) + { + return Response.Invalid; + } + + if (triggerCharacterKind is RazorLanguageKind.Html) + { + return Response.ValidHtml; + } + + return Response.ValidCSharp; + } +} From 2a266248b3638a991f2009a857797142d1db810d Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 2 Sep 2024 15:03:10 +1000 Subject: [PATCH 03/19] Fix a bug from a previous PR --- .../Formatting/LspFormattingCodeDocumentProvider.cs | 4 ++-- .../Formatting/RazorFormattingService.cs | 2 +- .../Formatting/RemoteFormattingCodeDocumentProvider.cs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/LspFormattingCodeDocumentProvider.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/LspFormattingCodeDocumentProvider.cs index eaf9bfa091..e47da7f437 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/LspFormattingCodeDocumentProvider.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/LspFormattingCodeDocumentProvider.cs @@ -12,7 +12,7 @@ internal sealed class LspFormattingCodeDocumentProvider : IFormattingCodeDocumen { public Task GetCodeDocumentAsync(IDocumentSnapshot snapshot) { - var useDesignTimeGeneratedOutput = snapshot.Project.Configuration.LanguageServerFlags?.ForceRuntimeCodeGeneration ?? false; - return snapshot.GetGeneratedOutputAsync(useDesignTimeGeneratedOutput); + // Formatting always uses design time + return snapshot.GetGeneratedOutputAsync(forceDesignTimeGeneratedOutput: true); } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs index ea201061f0..99d63fe9d3 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs @@ -233,7 +233,7 @@ internal class RazorFormattingService : IRazorFormattingService var documentSnapshot = documentContext.Snapshot; var uri = documentContext.Uri; - var codeDocument = await documentSnapshot.GetGeneratedOutputAsync().ConfigureAwait(false); + var codeDocument = await _codeDocumentProvider.GetCodeDocumentAsync(documentSnapshot).ConfigureAwait(false); using var context = FormattingContext.CreateForOnTypeFormatting( uri, documentSnapshot, diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingCodeDocumentProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingCodeDocumentProvider.cs index 92a0ccd1ae..64c90c21cb 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingCodeDocumentProvider.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingCodeDocumentProvider.cs @@ -14,6 +14,7 @@ internal sealed class RemoteFormattingCodeDocumentProvider : IFormattingCodeDocu { public Task GetCodeDocumentAsync(IDocumentSnapshot snapshot) { - return snapshot.GetGeneratedOutputAsync(); + // Formatting always uses design time + return snapshot.GetGeneratedOutputAsync(forceDesignTimeGeneratedOutput: true); } } From 90c7b476a58f755ccd886f53b3b59e5d5f2c2587 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 2 Sep 2024 15:04:49 +1000 Subject: [PATCH 04/19] Move WebTools calling code to a shared layer --- .../FormattingLanguageServerClient.cs | 103 ++-------------- ...spNetCore.Razor.LanguageServer.Test.csproj | 13 -- .../Formatting_NetFx/HtmlFormatting.cs | 111 ++++++++++++++++++ .../Formatting_NetFx/WebTools.cs | 3 +- ...spNetCore.Razor.Test.Common.Tooling.csproj | 13 ++ 5 files changed, 139 insertions(+), 104 deletions(-) create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormatting.cs rename src/Razor/test/{Microsoft.AspNetCore.Razor.LanguageServer.Test => Microsoft.AspNetCore.Razor.Test.Common.Tooling}/Formatting_NetFx/WebTools.cs (99%) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerClient.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerClient.cs index 66dc964784..f647e7d31d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerClient.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerClient.cs @@ -3,25 +3,17 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.LanguageServer.Hosting; -using Microsoft.AspNetCore.Razor.PooledObjects; -using Microsoft.AspNetCore.Razor.Test.Common.Mef; using Microsoft.AspNetCore.Razor.Utilities; -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; +using Microsoft.CodeAnalysis.Razor.Formatting; using Microsoft.CodeAnalysis.Razor.Logging; using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Razor.Protocol.Formatting; -using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.Text; -using Microsoft.VisualStudio.Utilities; -using Microsoft.WebTools.Languages.Shared.ContentTypes; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting; @@ -40,52 +32,28 @@ internal class FormattingLanguageServerClient(ILoggerFactory loggerFactory) : IC _documents.Add("/" + path, codeDocument); } - private Task FormatAsync(DocumentOnTypeFormattingParams @params) + private async Task FormatAsync(DocumentOnTypeFormattingParams @params) { var generatedHtml = GetGeneratedHtml(@params.TextDocument.Uri); - var generatedHtmlSource = SourceText.From(generatedHtml, Encoding.UTF8); - var absoluteIndex = generatedHtmlSource.GetRequiredAbsoluteIndex(@params.Position); - var request = $$""" - { - "Options": - { - "UseSpaces": {{(@params.Options.InsertSpaces ? "true" : "false")}}, - "TabSize": {{@params.Options.TabSize}}, - "IndentSize": {{@params.Options.TabSize}} - }, - "Uri": "{{@params.TextDocument.Uri}}", - "GeneratedChanges": [], - "OperationType": "FormatOnType", - "SpanToFormat": - { - "Start": {{absoluteIndex}}, - "End": {{absoluteIndex}} - } - } - """; + var edits = await HtmlFormatting.GetOnTypeFormattingEditsAsync(_loggerFactory, @params.TextDocument.Uri, generatedHtml, @params.Position, @params.Options.InsertSpaces, @params.Options.TabSize); - return CallWebToolsApplyFormattedEditsHandlerAsync(request, @params.TextDocument.Uri, generatedHtml); + return new() + { + Edits = edits + }; } - private Task FormatAsync(DocumentFormattingParams @params) + private async Task FormatAsync(DocumentFormattingParams @params) { var generatedHtml = GetGeneratedHtml(@params.TextDocument.Uri); - var request = $$""" - { - "Options": - { - "UseSpaces": {{(@params.Options.InsertSpaces ? "true" : "false")}}, - "TabSize": {{@params.Options.TabSize}}, - "IndentSize": {{@params.Options.TabSize}} - }, - "Uri": "{{@params.TextDocument.Uri}}", - "GeneratedChanges": [], - } - """; + var edits = await HtmlFormatting.GetDocumentFormattingEditsAsync(_loggerFactory, @params.TextDocument.Uri, generatedHtml, @params.Options.InsertSpaces, @params.Options.TabSize); - return CallWebToolsApplyFormattedEditsHandlerAsync(request, @params.TextDocument.Uri, generatedHtml); + return new() + { + Edits = edits + }; } private string GetGeneratedHtml(Uri uri) @@ -95,51 +63,6 @@ internal class FormattingLanguageServerClient(ILoggerFactory loggerFactory) : IC return generatedHtml.Replace("\r", "").Replace("\n", "\r\n"); } - private async Task CallWebToolsApplyFormattedEditsHandlerAsync(string serializedValue, Uri documentUri, string generatedHtml) - { - var exportProvider = TestComposition.Editor.ExportProviderFactory.CreateExportProvider(); - var contentTypeService = exportProvider.GetExportedValue(); - - if (!contentTypeService.ContentTypes.Any(t => t.TypeName == HtmlContentTypeDefinition.HtmlContentType)) - { - contentTypeService.AddContentType(HtmlContentTypeDefinition.HtmlContentType, [StandardContentTypeNames.Text]); - } - - var textBufferFactoryService = (ITextBufferFactoryService3)exportProvider.GetExportedValue(); - var bufferManager = WebTools.BufferManager.New(contentTypeService, textBufferFactoryService, []); - var logger = _loggerFactory.GetOrCreateLogger("ApplyFormattedEditsHandler"); - var applyFormatEditsHandler = WebTools.ApplyFormatEditsHandler.New(textBufferFactoryService, bufferManager, logger); - - // Make sure the buffer manager knows about the source document - var textSnapshot = bufferManager.CreateBuffer( - documentUri: documentUri, - contentTypeName: HtmlContentTypeDefinition.HtmlContentType, - initialContent: generatedHtml, - snapshotVersionFromLSP: 0); - - var requestContext = WebTools.RequestContext.New(textSnapshot); - - var request = WebTools.ApplyFormatEditsParam.DeserializeFrom(serializedValue); - var response = await applyFormatEditsHandler.HandleRequestAsync(request, requestContext, CancellationToken.None); - - var sourceText = SourceText.From(generatedHtml); - - using var edits = new PooledArrayBuilder(); - - foreach (var textChange in response.TextChanges) - { - var span = new TextSpan(textChange.Position, textChange.Length); - var edit = VsLspFactory.CreateTextEdit(sourceText.GetRange(span), textChange.NewText); - - edits.Add(edit); - } - - return new() - { - Edits = edits.ToArray() - }; - } - public async Task SendRequestAsync(string method, TParams @params, CancellationToken cancellationToken) { if (@params is DocumentFormattingParams formattingParams && diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Microsoft.AspNetCore.Razor.LanguageServer.Test.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Microsoft.AspNetCore.Razor.LanguageServer.Test.csproj index b50276628e..685173189f 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Microsoft.AspNetCore.Razor.LanguageServer.Test.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Microsoft.AspNetCore.Razor.LanguageServer.Test.csproj @@ -13,19 +13,6 @@ - - - - - - - - - - - - - diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormatting.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormatting.cs new file mode 100644 index 0000000000..1879dfadf1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormatting.cs @@ -0,0 +1,111 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.PooledObjects; +using Microsoft.AspNetCore.Razor.Test.Common.Mef; +using Microsoft.CodeAnalysis.Razor.Logging; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Utilities; +using Microsoft.WebTools.Languages.Shared.ContentTypes; + +namespace Microsoft.CodeAnalysis.Razor.Formatting; + +internal static class HtmlFormatting +{ + public static Task GetDocumentFormattingEditsAsync(ILoggerFactory loggerFactory, Uri uri, string generatedHtml, bool insertSpaces, int tabSize) + { + var request = $$""" + { + "Options": + { + "UseSpaces": {{(insertSpaces ? "true" : "false")}}, + "TabSize": {{tabSize}}, + "IndentSize": {{tabSize}} + }, + "Uri": "{{uri}}", + "GeneratedChanges": [], + } + """; + + return CallWebToolsApplyFormattedEditsHandlerAsync(loggerFactory, request, uri, generatedHtml); + } + + public static Task GetOnTypeFormattingEditsAsync(ILoggerFactory loggerFactory, Uri uri, string generatedHtml, Position position, bool insertSpaces, int tabSize) + { + var generatedHtmlSource = SourceText.From(generatedHtml, Encoding.UTF8); + var absoluteIndex = generatedHtmlSource.GetRequiredAbsoluteIndex(position); + + var request = $$""" + { + "Options": + { + "UseSpaces": {{(insertSpaces ? "true" : "false")}}, + "TabSize": {{tabSize}}, + "IndentSize": {{tabSize}} + }, + "Uri": "{{uri}}", + "GeneratedChanges": [], + "OperationType": "FormatOnType", + "SpanToFormat": + { + "Start": {{absoluteIndex}}, + "End": {{absoluteIndex}} + } + } + """; + + return CallWebToolsApplyFormattedEditsHandlerAsync(loggerFactory, request, uri, generatedHtml); + } + + private static async Task CallWebToolsApplyFormattedEditsHandlerAsync(ILoggerFactory loggerFactory, string serializedValue, Uri documentUri, string generatedHtml) + { + var exportProvider = TestComposition.Editor.ExportProviderFactory.CreateExportProvider(); + var contentTypeService = exportProvider.GetExportedValue(); + + lock (contentTypeService) + { + if (!contentTypeService.ContentTypes.Any(t => t.TypeName == HtmlContentTypeDefinition.HtmlContentType)) + { + contentTypeService.AddContentType(HtmlContentTypeDefinition.HtmlContentType, [StandardContentTypeNames.Text]); + } + } + + var textBufferFactoryService = (ITextBufferFactoryService3)exportProvider.GetExportedValue(); + var bufferManager = WebTools.BufferManager.New(contentTypeService, textBufferFactoryService, []); + var logger = loggerFactory.GetOrCreateLogger("ApplyFormattedEditsHandler"); + var applyFormatEditsHandler = WebTools.ApplyFormatEditsHandler.New(textBufferFactoryService, bufferManager, logger); + + // Make sure the buffer manager knows about the source document + var textSnapshot = bufferManager.CreateBuffer( + documentUri: documentUri, + contentTypeName: HtmlContentTypeDefinition.HtmlContentType, + initialContent: generatedHtml, + snapshotVersionFromLSP: 0); + + var requestContext = WebTools.RequestContext.New(textSnapshot); + + var request = WebTools.ApplyFormatEditsParam.DeserializeFrom(serializedValue); + var response = await applyFormatEditsHandler.HandleRequestAsync(request, requestContext, CancellationToken.None); + + var sourceText = SourceText.From(generatedHtml); + + using var edits = new PooledArrayBuilder(); + + foreach (var textChange in response.TextChanges) + { + var span = new TextSpan(textChange.Position, textChange.Length); + var edit = VsLspFactory.CreateTextEdit(sourceText.GetRange(span), textChange.NewText); + + edits.Add(edit); + } + + return edits.ToArray(); + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/WebTools.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/WebTools.cs similarity index 99% rename from src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/WebTools.cs rename to src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/WebTools.cs index ec0430afe1..1077a3b09e 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/WebTools.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/WebTools.cs @@ -7,6 +7,7 @@ using System.Collections.Immutable; using System.Reflection; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.PooledObjects; using Microsoft.CodeAnalysis.Razor.Logging; using Microsoft.VisualStudio.Settings.Internal; @@ -16,7 +17,7 @@ using Microsoft.WebTools.Languages.Shared.Editor.Composition; using Microsoft.WebTools.Languages.Shared.Editor.Text; using Newtonsoft.Json; -namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting; +namespace Microsoft.CodeAnalysis.Razor.Formatting; /// /// Provides reflection-based access to the Web Tools LSP infrastructure needed for tests. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj index 6caeb6b298..89019499fa 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj @@ -35,6 +35,19 @@ + + + + + + + + + + + + + From 2cbbdf56908fe13105a023ac97604084e1bf1128 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 2 Sep 2024 15:05:10 +1000 Subject: [PATCH 05/19] Create cohosting endpoints --- .../CohostDocumentFormattingEndpoint.cs | 140 ++++++++++++++ .../Cohost/CohostOnTypeFormattingEndpoint.cs | 176 ++++++++++++++++++ .../Cohost/CohostRangeFormattingEndpoint.cs | 147 +++++++++++++++ 3 files changed, 463 insertions(+) create mode 100644 src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentFormattingEndpoint.cs create mode 100644 src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs create mode 100644 src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentFormattingEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentFormattingEndpoint.cs new file mode 100644 index 0000000000..8589644a08 --- /dev/null +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentFormattingEndpoint.cs @@ -0,0 +1,140 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Composition; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; +using Microsoft.CodeAnalysis.Razor.Formatting; +using Microsoft.CodeAnalysis.Razor.Logging; +using Microsoft.CodeAnalysis.Razor.Remote; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.VisualStudio.Razor.Settings; + +namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; + +#pragma warning disable RS0030 // Do not use banned APIs +[Shared] +[CohostEndpoint(Methods.TextDocumentFormattingName)] +[Export(typeof(IDynamicRegistrationProvider))] +[ExportCohostStatelessLspService(typeof(CohostDocumentFormattingEndpoint))] +[method: ImportingConstructor] +#pragma warning restore RS0030 // Do not use banned APIs +internal class CohostDocumentFormattingEndpoint( + IRemoteServiceInvoker remoteServiceInvoker, + IHtmlDocumentSynchronizer htmlDocumentSynchronizer, + LSPRequestInvoker requestInvoker, + IClientSettingsManager clientSettingsManager, + ILoggerFactory loggerFactory) + : AbstractRazorCohostDocumentRequestHandler, IDynamicRegistrationProvider +{ + private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker; + private readonly IHtmlDocumentSynchronizer _htmlDocumentSynchronizer = htmlDocumentSynchronizer; + private readonly LSPRequestInvoker _requestInvoker = requestInvoker; + private readonly IClientSettingsManager _clientSettingsManager = clientSettingsManager; + private readonly ILogger _logger = loggerFactory.GetOrCreateLogger(); + + protected override bool MutatesSolutionState => false; + + protected override bool RequiresLSPSolution => true; + + public Registration? GetRegistration(VSInternalClientCapabilities clientCapabilities, DocumentFilter[] filter, RazorCohostRequestContext requestContext) + { + if (clientCapabilities.TextDocument?.Formatting?.DynamicRegistration is true) + { + return new Registration() + { + Method = Methods.TextDocumentFormattingName, + RegisterOptions = new DocumentFormattingRegistrationOptions() + { + DocumentSelector = filter + } + }; + } + + return null; + } + + protected override RazorTextDocumentIdentifier? GetRazorTextDocumentIdentifier(DocumentFormattingParams request) + => request.TextDocument.ToRazorTextDocumentIdentifier(); + + protected override Task HandleRequestAsync(DocumentFormattingParams request, RazorCohostRequestContext context, CancellationToken cancellationToken) + => HandleRequestAsync(request, context.TextDocument.AssumeNotNull(), cancellationToken); + + private async Task HandleRequestAsync(DocumentFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + { + _logger.LogDebug($"Getting Html formatting changes for {razorDocument.FilePath}"); + var htmlResult = await GetHtmlFormattingEditsAsync(request, razorDocument, cancellationToken).ConfigureAwait(false); + + if (htmlResult is not { } htmlEdits) + { + // We prefer to return null, so the client will try again + _logger.LogDebug($"Didn't get any edits back from Html"); + return null; + } + + var sourceText = await razorDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); + var htmlChanges = htmlEdits.SelectAsArray(sourceText.GetTextChange); + + var options = RazorFormattingOptions.From(request.Options, _clientSettingsManager.GetClientSettings().AdvancedSettings.CodeBlockBraceOnNextLine); + + _logger.LogDebug($"Calling OOP with the {htmlChanges.Length} html edits, so it can fill in the rest"); + var remoteResult = await _remoteServiceInvoker.TryInvokeAsync>( + razorDocument.Project.Solution, + (service, solutionInfo, cancellationToken) => service.GetDocumentFormattingEditsAsync(solutionInfo, razorDocument.Id, htmlChanges, options, cancellationToken), + cancellationToken).ConfigureAwait(false); + + if (remoteResult is [_, ..] allChanges) + { + _logger.LogDebug($"Got a total of {allChanges.Length} ranges back from OOP"); + + return allChanges.Select(sourceText.GetTextEdit).ToArray(); + } + + return null; + } + + private async Task GetHtmlFormattingEditsAsync(DocumentFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + { + var htmlDocument = await _htmlDocumentSynchronizer.TryGetSynchronizedHtmlDocumentAsync(razorDocument, cancellationToken).ConfigureAwait(false); + if (htmlDocument is null) + { + return null; + } + + request.TextDocument = request.TextDocument.WithUri(htmlDocument.Uri); + + _logger.LogDebug($"Requesting document formatting edits for {htmlDocument.Uri}"); + + var result = await _requestInvoker.ReinvokeRequestOnServerAsync( + htmlDocument.Buffer, + Methods.TextDocumentFormattingName, + RazorLSPConstants.HtmlLanguageServerName, + request, + cancellationToken).ConfigureAwait(false); + + if (result?.Response is null) + { + _logger.LogDebug($"Didn't get any ranges back from Html. Returning null so we can abandon the whole thing"); + return null; + } + + return result.Response; + } + + internal TestAccessor GetTestAccessor() => new(this); + + internal readonly struct TestAccessor(CohostDocumentFormattingEndpoint instance) + { + public Task HandleRequestAsync(DocumentFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + => instance.HandleRequestAsync(request, razorDocument, cancellationToken); + } +} + diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs new file mode 100644 index 0000000000..e5cd437628 --- /dev/null +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs @@ -0,0 +1,176 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Composition; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; +using Microsoft.CodeAnalysis.Razor.Formatting; +using Microsoft.CodeAnalysis.Razor.Logging; +using Microsoft.CodeAnalysis.Razor.Remote; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.VisualStudio.Razor.Settings; + +namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; + +#pragma warning disable RS0030 // Do not use banned APIs +[Shared] +[CohostEndpoint(Methods.TextDocumentOnTypeFormattingName)] +[Export(typeof(IDynamicRegistrationProvider))] +[ExportCohostStatelessLspService(typeof(CohostOnTypeFormattingEndpoint))] +[method: ImportingConstructor] +#pragma warning restore RS0030 // Do not use banned APIs +internal class CohostOnTypeFormattingEndpoint( + IRemoteServiceInvoker remoteServiceInvoker, + IHtmlDocumentSynchronizer htmlDocumentSynchronizer, + LSPRequestInvoker requestInvoker, + IClientSettingsManager clientSettingsManager, + ILoggerFactory loggerFactory) + : AbstractRazorCohostDocumentRequestHandler, IDynamicRegistrationProvider +{ + private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker; + private readonly IHtmlDocumentSynchronizer _htmlDocumentSynchronizer = htmlDocumentSynchronizer; + private readonly LSPRequestInvoker _requestInvoker = requestInvoker; + private readonly IClientSettingsManager _clientSettingsManager = clientSettingsManager; + private readonly ILogger _logger = loggerFactory.GetOrCreateLogger(); + + protected override bool MutatesSolutionState => false; + + protected override bool RequiresLSPSolution => true; + + public Registration? GetRegistration(VSInternalClientCapabilities clientCapabilities, DocumentFilter[] filter, RazorCohostRequestContext requestContext) + { + if (clientCapabilities.TextDocument?.Formatting?.DynamicRegistration is true) + { + return new Registration() + { + Method = Methods.TextDocumentOnTypeFormattingName, + RegisterOptions = new DocumentOnTypeFormattingRegistrationOptions() + { + DocumentSelector = filter, + FirstTriggerCharacter = RazorFormattingService.AllTriggerCharacters[0], + MoreTriggerCharacter = RazorFormattingService.AllTriggerCharacters.AsSpan()[1..].ToArray(), + } + }; + } + + return null; + } + + protected override RazorTextDocumentIdentifier? GetRazorTextDocumentIdentifier(DocumentOnTypeFormattingParams request) + => request.TextDocument.ToRazorTextDocumentIdentifier(); + + protected override Task HandleRequestAsync(DocumentOnTypeFormattingParams request, RazorCohostRequestContext context, CancellationToken cancellationToken) + => HandleRequestAsync(request, context.TextDocument.AssumeNotNull(), cancellationToken); + + private async Task HandleRequestAsync(DocumentOnTypeFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + { + var clientSettings = _clientSettingsManager.GetClientSettings(); + if (!clientSettings.AdvancedSettings.FormatOnType) + { + _logger.LogInformation($"Formatting on type disabled."); + return null; + } + + if (!RazorFormattingService.AllTriggerCharacterSet.Contains(request.Character)) + { + _logger.LogWarning($"Unexpected trigger character '{request.Character}'."); + return null; + } + + // We have to go to OOP to find out if we want Html formatting for this request. This is a little unfortunate + // but just asking Html for formatting, just in case, would be bad for a couple of reasons. Firstly, the Html + // trigger characters are a superset of the C# triggers, so we can't use that as a sign. Secondly, whilst we + // might be making one Html request, it could be then calling CSS or TypeScript servers, so our single request + // to OOP could potentially save a few requests downstream. Lastly, our request to OOP is MessagePack which is + // generally faster than Json anyway. + var triggerKind = await _remoteServiceInvoker.TryInvokeAsync( + razorDocument.Project.Solution, + (service, solutionInfo, cancellationToken) => service.GetOnTypeFormattingTriggerKindAsync(solutionInfo, razorDocument.Id, request.Position.ToLinePosition(), request.Character, cancellationToken), + cancellationToken).ConfigureAwait(false); + + if (triggerKind == IRemoteFormattingService.TriggerKind.Invalid) + { + return null; + } + + var sourceText = await razorDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); + + ImmutableArray htmlChanges = []; + if (triggerKind == IRemoteFormattingService.TriggerKind.ValidHtml) + { + _logger.LogDebug($"Getting Html formatting changes for {razorDocument.FilePath}"); + var htmlResult = await GetHtmlFormattingEditsAsync(request, razorDocument, cancellationToken).ConfigureAwait(false); + + if (htmlResult is not { } htmlEdits) + { + // We prefer to return null, so the client will try again + _logger.LogDebug($"Didn't get any edits back from Html"); + return null; + } + + htmlChanges = htmlEdits.SelectAsArray(sourceText.GetTextChange); + } + + var options = RazorFormattingOptions.From(request.Options, clientSettings.AdvancedSettings.CodeBlockBraceOnNextLine); + + _logger.LogDebug($"Calling OOP with the {htmlChanges.Length} html edits, so it can fill in the rest"); + var remoteResult = await _remoteServiceInvoker.TryInvokeAsync>( + razorDocument.Project.Solution, + (service, solutionInfo, cancellationToken) => service.GetOnTypeFormattingEditsAsync(solutionInfo, razorDocument.Id, htmlChanges, request.Position.ToLinePosition(), request.Character, options, cancellationToken), + cancellationToken).ConfigureAwait(false); + + if (remoteResult is [_, ..] allChanges) + { + _logger.LogDebug($"Got a total of {allChanges.Length} ranges back from OOP"); + + return allChanges.Select(sourceText.GetTextEdit).ToArray(); + } + + return null; + } + + private async Task GetHtmlFormattingEditsAsync(DocumentOnTypeFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + { + var htmlDocument = await _htmlDocumentSynchronizer.TryGetSynchronizedHtmlDocumentAsync(razorDocument, cancellationToken).ConfigureAwait(false); + if (htmlDocument is null) + { + return null; + } + + request.TextDocument = request.TextDocument.WithUri(htmlDocument.Uri); + + _logger.LogDebug($"Requesting document formatting edits for {htmlDocument.Uri}"); + + var result = await _requestInvoker.ReinvokeRequestOnServerAsync( + htmlDocument.Buffer, + Methods.TextDocumentOnTypeFormattingName, + RazorLSPConstants.HtmlLanguageServerName, + request, + cancellationToken).ConfigureAwait(false); + + if (result?.Response is null) + { + _logger.LogDebug($"Didn't get any ranges back from Html. Returning null so we can abandon the whole thing"); + return null; + } + + return result.Response; + } + + internal TestAccessor GetTestAccessor() => new(this); + + internal readonly struct TestAccessor(CohostOnTypeFormattingEndpoint instance) + { + public Task HandleRequestAsync(DocumentOnTypeFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + => instance.HandleRequestAsync(request, razorDocument, cancellationToken); + } +} + diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs new file mode 100644 index 0000000000..9be30b7eab --- /dev/null +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs @@ -0,0 +1,147 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Composition; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; +using Microsoft.CodeAnalysis.Razor.Formatting; +using Microsoft.CodeAnalysis.Razor.Logging; +using Microsoft.CodeAnalysis.Razor.Remote; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.VisualStudio.Razor.Settings; + +namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; + +#pragma warning disable RS0030 // Do not use banned APIs +[Shared] +[CohostEndpoint(Methods.TextDocumentRangeFormattingName)] +[Export(typeof(IDynamicRegistrationProvider))] +[ExportCohostStatelessLspService(typeof(CohostRangeFormattingEndpoint))] +[method: ImportingConstructor] +#pragma warning restore RS0030 // Do not use banned APIs +internal class CohostRangeFormattingEndpoint( + IRemoteServiceInvoker remoteServiceInvoker, + IHtmlDocumentSynchronizer htmlDocumentSynchronizer, + LSPRequestInvoker requestInvoker, + IClientSettingsManager clientSettingsManager, + ILoggerFactory loggerFactory) + : AbstractRazorCohostDocumentRequestHandler, IDynamicRegistrationProvider +{ + private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker; + private readonly IHtmlDocumentSynchronizer _htmlDocumentSynchronizer = htmlDocumentSynchronizer; + private readonly LSPRequestInvoker _requestInvoker = requestInvoker; + private readonly IClientSettingsManager _clientSettingsManager = clientSettingsManager; + private readonly ILogger _logger = loggerFactory.GetOrCreateLogger(); + + protected override bool MutatesSolutionState => false; + + protected override bool RequiresLSPSolution => true; + + public Registration? GetRegistration(VSInternalClientCapabilities clientCapabilities, DocumentFilter[] filter, RazorCohostRequestContext requestContext) + { + if (clientCapabilities.TextDocument?.Formatting?.DynamicRegistration is true) + { + return new Registration() + { + Method = Methods.TextDocumentRangeFormattingName, + RegisterOptions = new DocumentRangeFormattingRegistrationOptions() + { + DocumentSelector = filter + } + }; + } + + return null; + } + + protected override RazorTextDocumentIdentifier? GetRazorTextDocumentIdentifier(DocumentRangeFormattingParams request) + => request.TextDocument.ToRazorTextDocumentIdentifier(); + + protected override Task HandleRequestAsync(DocumentRangeFormattingParams request, RazorCohostRequestContext context, CancellationToken cancellationToken) + => HandleRequestAsync(request, context.TextDocument.AssumeNotNull(), cancellationToken); + + private async Task HandleRequestAsync(DocumentRangeFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + { + _logger.LogDebug($"Getting Html formatting changes for {razorDocument.FilePath}"); + var htmlResult = await GetHtmlFormattingEditsAsync(request, razorDocument, cancellationToken).ConfigureAwait(false); + + if (htmlResult is not { } htmlEdits) + { + // We prefer to return null, so the client will try again + _logger.LogDebug($"Didn't get any edits back from Html"); + return null; + } + + var sourceText = await razorDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); + var htmlChanges = htmlEdits.SelectAsArray(sourceText.GetTextChange); + + var options = RazorFormattingOptions.From(request.Options, _clientSettingsManager.GetClientSettings().AdvancedSettings.CodeBlockBraceOnNextLine); + + _logger.LogDebug($"Calling OOP with the {htmlChanges.Length} html edits, so it can fill in the rest"); + var remoteResult = await _remoteServiceInvoker.TryInvokeAsync>( + razorDocument.Project.Solution, + (service, solutionInfo, cancellationToken) => service.GetRangeFormattingEditsAsync(solutionInfo, razorDocument.Id, htmlChanges, request.Range.ToLinePositionSpan(), options, cancellationToken), + cancellationToken).ConfigureAwait(false); + + if (remoteResult is [_, ..] allChanges) + { + _logger.LogDebug($"Got a total of {allChanges.Length} ranges back from OOP"); + + return allChanges.Select(sourceText.GetTextEdit).ToArray(); + } + + return null; + } + + private async Task GetHtmlFormattingEditsAsync(DocumentRangeFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + { + var htmlDocument = await _htmlDocumentSynchronizer.TryGetSynchronizedHtmlDocumentAsync(razorDocument, cancellationToken).ConfigureAwait(false); + if (htmlDocument is null) + { + return null; + } + + // We don't actually request range formatting results from Html, because our formatting engine can't deal with + // relative formatting results. Instead we request full document formatting, and filter the edits inside the + // formatting service to only the ones we care about. + var formattingRequest = new DocumentFormattingParams + { + TextDocument = request.TextDocument.WithUri(htmlDocument.Uri), + Options = request.Options + }; + + _logger.LogDebug($"Requesting document formatting edits for {htmlDocument.Uri}"); + + var result = await _requestInvoker.ReinvokeRequestOnServerAsync( + htmlDocument.Buffer, + Methods.TextDocumentFormattingName, + RazorLSPConstants.HtmlLanguageServerName, + formattingRequest, + cancellationToken).ConfigureAwait(false); + + if (result?.Response is null) + { + _logger.LogDebug($"Didn't get any ranges back from Html. Returning null so we can abandon the whole thing"); + return null; + } + + return result.Response; + } + + internal TestAccessor GetTestAccessor() => new(this); + + internal readonly struct TestAccessor(CohostRangeFormattingEndpoint instance) + { + public Task HandleRequestAsync(DocumentRangeFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + => instance.HandleRequestAsync(request, razorDocument, cancellationToken); + } +} + From 6c3b12be1e103dc4388605558dd3b6ea56b94677 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 2 Sep 2024 15:05:36 +1000 Subject: [PATCH 06/19] Turn off the old endpoints --- .../Extensions/IServiceCollectionExtensions.cs | 14 +++++++++----- .../RazorLanguageServer.cs | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Extensions/IServiceCollectionExtensions.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Extensions/IServiceCollectionExtensions.cs index 5b5a191120..b717027d9e 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Extensions/IServiceCollectionExtensions.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Extensions/IServiceCollectionExtensions.cs @@ -56,15 +56,19 @@ internal static class IServiceCollectionExtensions services.AddSingleton(clientConnection); } - public static void AddFormattingServices(this IServiceCollection services) + public static void AddFormattingServices(this IServiceCollection services, LanguageServerFeatureOptions featureOptions) { // Formatting - services.AddSingleton(); services.AddSingleton(); - services.AddHandlerWithCapabilities(); - services.AddHandlerWithCapabilities(); - services.AddHandlerWithCapabilities(); + if (!featureOptions.UseRazorCohostServer) + { + services.AddSingleton(); + + services.AddHandlerWithCapabilities(); + services.AddHandlerWithCapabilities(); + services.AddHandlerWithCapabilities(); + } } public static void AddCompletionServices(this IServiceCollection services) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs index d3162a0e5b..763edb83c3 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs @@ -135,7 +135,7 @@ internal partial class RazorLanguageServer : SystemTextJsonLanguageServer Date: Mon, 2 Sep 2024 15:06:09 +1000 Subject: [PATCH 07/19] Create basic tests These don't test the full capabilities of the formatting engine, just that it runs in cohosting --- .../CohostDocumentFormattingEndpointTest.cs | 144 ++++++++++++++++ .../CohostOnTypeFormattingEndpointTest.cs | 158 ++++++++++++++++++ .../CohostRangeFormattingEndpointTest.cs | 139 +++++++++++++++ 3 files changed, 441 insertions(+) create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentFormattingEndpointTest.cs create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRangeFormattingEndpointTest.cs diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentFormattingEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentFormattingEndpointTest.cs new file mode 100644 index 0000000000..3c8f9b268b --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentFormattingEndpointTest.cs @@ -0,0 +1,144 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Test.Common; +using Microsoft.AspNetCore.Razor.Test.Common.Mef; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Microsoft.CodeAnalysis.Razor.Formatting; +using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.VisualStudio.Razor.Settings; +using Microsoft.VisualStudio.Threading; +using Roslyn.Test.Utilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; + +[UseExportProvider] +public class CohostDocumentFormattingEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) +{ + // All of the formatting tests in the language server exercise the formatting engine and cover various edge cases + // and provide regression prevention. The tests here are not exhaustive, but they validate the the cohost endpoints + // call into the formatting engine at least, and handles C#, Html and Razor formatting changes correctly. + + [Fact] + public Task Formatting() + => VerifyDocumentFormattingAsync( + input: """ + @preservewhitespace true + +
+ + @{ +

+ @{ + var t = 1; + if (true) + { + + } + } +

+
+ @{ +
+
+ This is heavily nested +
+
+ } +
+ } + + @code { + private void M(string thisIsMyString) + { + var x = 5; + + var y = "Hello"; + + M("Hello"); + } + } + + """, + expected: """ + @preservewhitespace true + +
+ + @{ +

+ @{ + var t = 1; + if (true) + { + + } + } +

+
+ @{ +
+
+ This is heavily nested +
+
+ } +
+ } + + @code { + private void M(string thisIsMyString) + { + var x = 5; + + var y = "Hello"; + + M("Hello"); + } + } + + """); + + private async Task VerifyDocumentFormattingAsync(string input, string expected) + { + var document = CreateProjectAndRazorDocument(input); + var inputText = await document.GetTextAsync(DisposalToken); + + var htmlDocumentPublisher = new HtmlDocumentPublisher(RemoteServiceInvoker, StrictMock.Of(), StrictMock.Of(), LoggerFactory); + var generatedHtml = await htmlDocumentPublisher.GetHtmlSourceFromOOPAsync(document, DisposalToken); + Assert.NotNull(generatedHtml); + + var uri = new Uri(document.CreateUri(), $"{document.FilePath}{FeatureOptions.HtmlVirtualDocumentSuffix}"); + var htmlEdits = await HtmlFormatting.GetDocumentFormattingEditsAsync(LoggerFactory, uri, generatedHtml, insertSpaces: true, tabSize: 4); + + var requestInvoker = new TestLSPRequestInvoker([(Methods.TextDocumentFormattingName, htmlEdits)]); + + var clientSettingsManager = new ClientSettingsManager(changeTriggers: []); + + var endpoint = new CohostDocumentFormattingEndpoint(RemoteServiceInvoker, TestHtmlDocumentSynchronizer.Instance, requestInvoker, clientSettingsManager, LoggerFactory); + + var request = new DocumentFormattingParams() + { + TextDocument = new TextDocumentIdentifier() { Uri = document.CreateUri() }, + Options = new FormattingOptions() + { + TabSize = 4, + InsertSpaces = true + } + }; + + var edits = await endpoint.GetTestAccessor().HandleRequestAsync(request, document, DisposalToken); + + var changes = edits.Select(inputText.GetTextChange); + var finalText = inputText.WithChanges(changes); + + AssertEx.EqualOrDiff(expected, finalText.ToString()); + } +} diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs new file mode 100644 index 0000000000..b39ca778ab --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs @@ -0,0 +1,158 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Test.Common; +using Microsoft.AspNetCore.Razor.Test.Common.Mef; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Microsoft.CodeAnalysis.Razor.Formatting; +using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.VisualStudio.Razor.Settings; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.Threading; +using Roslyn.Test.Utilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; + +[UseExportProvider] +public class CohostOnTypeFormattingEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) +{ + [Fact] + public async Task InvalidTrigger() + { + await VerifyOnTypeFormattingAsync( + input: """ + @{ + if(true){}$$ + } + """, + expected: """ + @{ + if(true){} + } + """, + triggerCharacter: 'h'); + } + + [Fact] + public async Task CSharp_InvalidTrigger() + { + await VerifyOnTypeFormattingAsync( + input: """ + @{ + if(true){}$$ + } + """, + expected: """ + @{ + if(true){} + } + """, + triggerCharacter: '\n'); + } + + [Fact] + public async Task CSharp() + { + await VerifyOnTypeFormattingAsync( + input: """ + @{ + if(true){}$$ + } + """, + expected: """ + @{ + if (true) { } + } + """, + triggerCharacter: '}'); + } + + [Fact] + public async Task FormatsSimpleHtmlTag_OnType() + { + await VerifyOnTypeFormattingAsync( + input: """ + + + Hello + + + + """, + expected: """ + + + Hello + + + + """, + triggerCharacter: ';', + html: true); + } + + private async Task VerifyOnTypeFormattingAsync(TestCode input, string expected, char triggerCharacter, bool html = false) + { + var document = CreateProjectAndRazorDocument(input.Text); + var inputText = await document.GetTextAsync(DisposalToken); + var position = inputText.GetPosition(input.Position); + + LSPRequestInvoker requestInvoker; + if (html) + { + var htmlDocumentPublisher = new HtmlDocumentPublisher(RemoteServiceInvoker, StrictMock.Of(), StrictMock.Of(), LoggerFactory); + var generatedHtml = await htmlDocumentPublisher.GetHtmlSourceFromOOPAsync(document, DisposalToken); + Assert.NotNull(generatedHtml); + + var uri = new Uri(document.CreateUri(), $"{document.FilePath}{FeatureOptions.HtmlVirtualDocumentSuffix}"); + var htmlEdits = await HtmlFormatting.GetOnTypeFormattingEditsAsync(LoggerFactory, uri, generatedHtml, position, insertSpaces: true, tabSize: 4); + + requestInvoker = new TestLSPRequestInvoker([(Methods.TextDocumentOnTypeFormattingName, htmlEdits)]); + } + else + { + // We use a mock here so that it will throw if called + requestInvoker = StrictMock.Of(); + } + + var clientSettingsManager = new ClientSettingsManager(changeTriggers: []); + + var endpoint = new CohostOnTypeFormattingEndpoint(RemoteServiceInvoker, TestHtmlDocumentSynchronizer.Instance, requestInvoker, clientSettingsManager, LoggerFactory); + + var request = new DocumentOnTypeFormattingParams() + { + TextDocument = new TextDocumentIdentifier() { Uri = document.CreateUri() }, + Options = new FormattingOptions() + { + TabSize = 4, + InsertSpaces = true + }, + Character = triggerCharacter.ToString(), + Position = position + }; + + var edits = await endpoint.GetTestAccessor().HandleRequestAsync(request, document, DisposalToken); + + if (edits is null) + { + Assert.Equal(expected, input.Text); + return; + } + + var changes = edits.Select(inputText.GetTextChange); + var finalText = inputText.WithChanges(changes); + + AssertEx.EqualOrDiff(expected, finalText.ToString()); + } +} diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRangeFormattingEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRangeFormattingEndpointTest.cs new file mode 100644 index 0000000000..32d03e2800 --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRangeFormattingEndpointTest.cs @@ -0,0 +1,139 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Test.Common; +using Microsoft.AspNetCore.Razor.Test.Common.Mef; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Microsoft.CodeAnalysis.Razor.Formatting; +using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.VisualStudio.Razor.Settings; +using Microsoft.VisualStudio.Threading; +using Roslyn.Test.Utilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; + +[UseExportProvider] +public class CohostRangeFormattingEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) +{ + [Fact] + public Task RangeFormatting() + => VerifyRangeFormattingAsync( + input: """ + @preservewhitespace true + +
+ + @{ +

+ @{ + var t = 1; + if (true) + { + + } + } +

+ [|
+ @{ +
+
+ This is heavily nested +
+
+ } +
|] + } + + @code { + private void M(string thisIsMyString) + { + var x = 5; + + var y = "Hello"; + + M("Hello"); + } + } + """, + expected: """ + @preservewhitespace true + +
+ + @{ +

+ @{ + var t = 1; + if (true) + { + + } + } +

+
+ @{ +
+
+ This is heavily nested +
+
+ } +
+ } + + @code { + private void M(string thisIsMyString) + { + var x = 5; + + var y = "Hello"; + + M("Hello"); + } + } + """); + + private async Task VerifyRangeFormattingAsync(TestCode input, string expected) + { + var document = CreateProjectAndRazorDocument(input.Text); + var inputText = await document.GetTextAsync(DisposalToken); + + var htmlDocumentPublisher = new HtmlDocumentPublisher(RemoteServiceInvoker, StrictMock.Of(), StrictMock.Of(), LoggerFactory); + var generatedHtml = await htmlDocumentPublisher.GetHtmlSourceFromOOPAsync(document, DisposalToken); + Assert.NotNull(generatedHtml); + + var uri = new Uri(document.CreateUri(), $"{document.FilePath}{FeatureOptions.HtmlVirtualDocumentSuffix}"); + var htmlEdits = await HtmlFormatting.GetDocumentFormattingEditsAsync(LoggerFactory, uri, generatedHtml, insertSpaces: true, tabSize: 4); + + var requestInvoker = new TestLSPRequestInvoker([(Methods.TextDocumentFormattingName, htmlEdits)]); + + var clientSettingsManager = new ClientSettingsManager(changeTriggers: []); + + var endpoint = new CohostRangeFormattingEndpoint(RemoteServiceInvoker, TestHtmlDocumentSynchronizer.Instance, requestInvoker, clientSettingsManager, LoggerFactory); + + var request = new DocumentRangeFormattingParams() + { + TextDocument = new TextDocumentIdentifier() { Uri = document.CreateUri() }, + Options = new FormattingOptions() + { + TabSize = 4, + InsertSpaces = true + }, + Range = inputText.GetRange(input.Span) + }; + + var edits = await endpoint.GetTestAccessor().HandleRequestAsync(request, document, DisposalToken); + + var changes = edits.Select(inputText.GetTextChange); + var finalText = inputText.WithChanges(changes); + + AssertEx.EqualOrDiff(expected, finalText.ToString()); + } +} From 55c51a3a9d0218c9983d01a68ad9a20fdaf5075f Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 2 Sep 2024 15:34:32 +1000 Subject: [PATCH 08/19] Apply suggestions from code review --- .../Formatting/RazorFormattingService.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs index 99d63fe9d3..c5f28c682c 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs @@ -199,21 +199,16 @@ internal class RazorFormattingService : IRazorFormattingService public bool TryGetOnTypeFormattingTriggerKind(RazorCodeDocument codeDocument, int hostDocumentIndex, string triggerCharacter, out RazorLanguageKind triggerCharacterKind) { triggerCharacterKind = _documentMappingService.GetLanguageKind(codeDocument, hostDocumentIndex, rightAssociative: false); - if (triggerCharacterKind is not (RazorLanguageKind.CSharp or RazorLanguageKind.Html)) - { - return false; - } - - if (triggerCharacterKind == RazorLanguageKind.CSharp) + if (triggerCharacterKind is RazorLanguageKind.CSharp) { return s_csharpTriggerCharacterSet.Contains(triggerCharacter); } - else if (triggerCharacterKind == RazorLanguageKind.Html) + else if (triggerCharacterKind is RazorLanguageKind.Html) { return s_htmlTriggerCharacterSet.Contains(triggerCharacter); } - return true; + return false; } private async Task ApplyFormattedEditsAsync( From a7cd940cd7800ce5e791ac9033d9a495f9944cf3 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Tue, 3 Sep 2024 16:21:10 +1000 Subject: [PATCH 09/19] Cohost go to implementation --- eng/targets/Services.props | 1 + .../RazorLanguageServer.cs | 4 +- .../IRemoteGoToImplementationService.cs | 19 ++ .../Remote/RazorServices.cs | 1 + .../RemoteGoToDefinitionService.cs | 15 +- .../RemoteGoToImplementationService.cs | 111 ++++++++++++ .../RazorDocumentServiceBase.cs | 33 +++- .../CohostGoToImplementationEndpoint.cs | 153 ++++++++++++++++ .../CohostGoToImplementationEndpointTest.cs | 166 ++++++++++++++++++ 9 files changed, 484 insertions(+), 19 deletions(-) create mode 100644 src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToImplementationService.cs create mode 100644 src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GoToImplementation/RemoteGoToImplementationService.cs create mode 100644 src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostGoToImplementationEndpoint.cs create mode 100644 src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs diff --git a/eng/targets/Services.props b/eng/targets/Services.props index b2476eab94..07c6ab4456 100644 --- a/eng/targets/Services.props +++ b/eng/targets/Services.props @@ -29,5 +29,6 @@ +
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs index d3162a0e5b..f103464671 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs @@ -184,10 +184,10 @@ internal partial class RazorLanguageServer : SystemTextJsonLanguageServer(sp => sp.GetRequiredService()); - services.AddHandlerWithCapabilities(); - if (!featureOptions.UseRazorCohostServer) { + services.AddHandlerWithCapabilities(); + services.AddSingleton(); services.AddHandlerWithCapabilities(); diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToImplementationService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToImplementationService.cs new file mode 100644 index 0000000000..4131140457 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToImplementationService.cs @@ -0,0 +1,19 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using RoslynLocation = Roslyn.LanguageServer.Protocol.Location; +using RoslynPosition = Roslyn.LanguageServer.Protocol.Position; + +namespace Microsoft.CodeAnalysis.Razor.Remote; + +internal interface IRemoteGoToImplementationService : IRemoteJsonService +{ + ValueTask> GetImplementationAsync( + JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, + JsonSerializableDocumentId razorDocumentId, + RoslynPosition position, + CancellationToken cancellationToken); +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs index 558b737d4c..1a86184e8a 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs @@ -32,6 +32,7 @@ internal static class RazorServices (typeof(IRemoteInlayHintService), null), (typeof(IRemoteDocumentSymbolService), null), (typeof(IRemoteRenameService), null), + (typeof(IRemoteGoToImplementationService), null), ]; private const string ComponentName = "Razor"; diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GoToDefinition/RemoteGoToDefinitionService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GoToDefinition/RemoteGoToDefinitionService.cs index 58d6abd3e0..6169c99434 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GoToDefinition/RemoteGoToDefinitionService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GoToDefinition/RemoteGoToDefinitionService.cs @@ -58,20 +58,7 @@ internal sealed class RemoteGoToDefinitionService(in ServiceArgs args) : RazorDo return NoFurtherHandling; } - var positionInfo = GetPositionInfo(codeDocument, hostDocumentIndex); - - if (positionInfo.LanguageKind == RazorLanguageKind.Html) - { - // Sometimes Html can actually be mapped to C#, like for example component attributes, which map to - // C# properties, even though they appear entirely in a Html context. Since remapping is pretty cheap - // it's easier to just try mapping, and see what happens, rather than checking for specific syntax nodes. - if (DocumentMappingService.TryMapToGeneratedDocumentPosition(codeDocument.GetCSharpDocument(), positionInfo.HostDocumentIndex, out VsPosition? csharpPosition, out _)) - { - // We're just gonna pretend this mapped perfectly normally onto C#. Moving this logic to the actual position info - // calculating code is possible, but could have untold effects, so opt-in is better (for now?) - positionInfo = positionInfo with { LanguageKind = RazorLanguageKind.CSharp, Position = csharpPosition }; - } - } + var positionInfo = GetPositionInfo(codeDocument, hostDocumentIndex, preferCSharpOverHtml: true); if (positionInfo.LanguageKind is RazorLanguageKind.Html or RazorLanguageKind.Razor) { diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GoToImplementation/RemoteGoToImplementationService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GoToImplementation/RemoteGoToImplementationService.cs new file mode 100644 index 0000000000..7121cd6dbf --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GoToImplementation/RemoteGoToImplementationService.cs @@ -0,0 +1,111 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.PooledObjects; +using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Microsoft.CodeAnalysis.Razor.DocumentMapping; +using Microsoft.CodeAnalysis.Razor.Protocol; +using Microsoft.CodeAnalysis.Razor.Remote; +using Microsoft.CodeAnalysis.Remote.Razor.DocumentMapping; +using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; +using static Microsoft.CodeAnalysis.Razor.Remote.RemoteResponse; +using ExternalHandlers = Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers; +using RoslynLocation = Roslyn.LanguageServer.Protocol.Location; +using RoslynPosition = Roslyn.LanguageServer.Protocol.Position; +using VsPosition = Microsoft.VisualStudio.LanguageServer.Protocol.Position; + +namespace Microsoft.CodeAnalysis.Remote.Razor; + +internal sealed class RemoteGoToImplementationService(in ServiceArgs args) : RazorDocumentServiceBase(in args), IRemoteGoToImplementationService +{ + internal sealed class Factory : FactoryBase + { + protected override IRemoteGoToImplementationService CreateService(in ServiceArgs args) + => new RemoteGoToImplementationService(in args); + } + + protected override IDocumentPositionInfoStrategy DocumentPositionInfoStrategy => PreferAttributeNameDocumentPositionInfoStrategy.Instance; + + public ValueTask> GetImplementationAsync( + JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, + JsonSerializableDocumentId documentId, + RoslynPosition position, + CancellationToken cancellationToken) + => RunServiceAsync( + solutionInfo, + documentId, + context => GetImplementationAsync(context, position, cancellationToken), + cancellationToken); + + private async ValueTask> GetImplementationAsync( + RemoteDocumentContext context, + RoslynPosition position, + CancellationToken cancellationToken) + { + var codeDocument = await context.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false); + + if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var hostDocumentIndex)) + { + return NoFurtherHandling; + } + + var positionInfo = GetPositionInfo(codeDocument, hostDocumentIndex, preferCSharpOverHtml: true); + + if (positionInfo.LanguageKind is RazorLanguageKind.Razor) + { + return NoFurtherHandling; + } + + if (positionInfo.LanguageKind is RazorLanguageKind.Html) + { + return CallHtml; + } + + if (!DocumentMappingService.TryMapToGeneratedDocumentPosition(codeDocument.GetCSharpDocument(), positionInfo.HostDocumentIndex, out var mappedPosition, out _)) + { + // If we can't map to the generated C# file, we're done. + return NoFurtherHandling; + } + + // Finally, call into C#. + var generatedDocument = await context.Snapshot.GetGeneratedDocumentAsync().ConfigureAwait(false); + + var locations = await ExternalHandlers.GoToImplementation + .FindImplementationsAsync( + generatedDocument, + mappedPosition, + supportsVisualStudioExtensions: true, + cancellationToken) + .ConfigureAwait(false); + + if (locations is null and not []) + { + // C# didn't return anything, so we're done. + return NoFurtherHandling; + } + + // Map the C# locations back to the Razor file. + using var mappedLocations = new PooledArrayBuilder(locations.Length); + + foreach (var location in locations) + { + var (uri, range) = location; + + var (mappedDocumentUri, mappedRange) = await DocumentMappingService + .MapToHostDocumentUriAndRangeAsync(context.Snapshot, uri, range.ToLinePositionSpan(), cancellationToken) + .ConfigureAwait(false); + + var mappedLocation = RoslynLspFactory.CreateLocation(mappedDocumentUri, mappedRange); + + mappedLocations.Add(mappedLocation); + } + + return Results(mappedLocations.ToArray()); + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorDocumentServiceBase.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorDocumentServiceBase.cs index 9327d9931e..557fc66d27 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorDocumentServiceBase.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorDocumentServiceBase.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Razor.DocumentMapping; +using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; @@ -24,11 +25,34 @@ internal abstract class RazorDocumentServiceBase(in ServiceArgs args) : RazorBro protected virtual IDocumentPositionInfoStrategy DocumentPositionInfoStrategy { get; } = DefaultDocumentPositionInfoStrategy.Instance; protected DocumentPositionInfo GetPositionInfo(RazorCodeDocument codeDocument, int hostDocumentIndex) + => GetPositionInfo(codeDocument, hostDocumentIndex, preferCSharpOverHtml: false); + + protected DocumentPositionInfo GetPositionInfo(RazorCodeDocument codeDocument, int hostDocumentIndex, bool preferCSharpOverHtml) { - return DocumentPositionInfoStrategy.GetPositionInfo(DocumentMappingService, codeDocument, hostDocumentIndex); + var positionInfo = DocumentPositionInfoStrategy.GetPositionInfo(DocumentMappingService, codeDocument, hostDocumentIndex); + + if (preferCSharpOverHtml && positionInfo.LanguageKind == RazorLanguageKind.Html) + { + // Sometimes Html can actually be mapped to C#, like for example component attributes, which map to + // C# properties, even though they appear entirely in a Html context. Since remapping is pretty cheap + // it's easier to just try mapping, and see what happens, rather than checking for specific syntax nodes. + if (DocumentMappingService.TryMapToGeneratedDocumentPosition(codeDocument.GetCSharpDocument(), positionInfo.HostDocumentIndex, out VsPosition? csharpPosition, out _)) + { + // We're just gonna pretend this mapped perfectly normally onto C#. Moving this logic to the actual position info + // calculating code is possible, but could have untold effects, so opt-in is better (for now?) + + // TODO: Not using a with operator here because it doesn't work in OOP for some reason. + positionInfo = new DocumentPositionInfo(RazorLanguageKind.CSharp, csharpPosition, positionInfo.HostDocumentIndex); + } + } + + return positionInfo; } protected bool TryGetDocumentPositionInfo(RazorCodeDocument codeDocument, RoslynPosition position, out DocumentPositionInfo positionInfo) + => TryGetDocumentPositionInfo(codeDocument, position, preferCSharpOverHtml: false, out positionInfo); + + protected bool TryGetDocumentPositionInfo(RazorCodeDocument codeDocument, RoslynPosition position, bool preferCSharpOverHtml, out DocumentPositionInfo positionInfo) { if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var hostDocumentIndex)) { @@ -36,11 +60,14 @@ internal abstract class RazorDocumentServiceBase(in ServiceArgs args) : RazorBro return false; } - positionInfo = GetPositionInfo(codeDocument, hostDocumentIndex); + positionInfo = GetPositionInfo(codeDocument, hostDocumentIndex, preferCSharpOverHtml); return true; } protected bool TryGetDocumentPositionInfo(RazorCodeDocument codeDocument, VsPosition position, out DocumentPositionInfo positionInfo) + => TryGetDocumentPositionInfo(codeDocument, position, preferCSharpOverHtml: false, out positionInfo); + + protected bool TryGetDocumentPositionInfo(RazorCodeDocument codeDocument, VsPosition position, bool preferCSharpOverHtml, out DocumentPositionInfo positionInfo) { if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var hostDocumentIndex)) { @@ -48,7 +75,7 @@ internal abstract class RazorDocumentServiceBase(in ServiceArgs args) : RazorBro return false; } - positionInfo = GetPositionInfo(codeDocument, hostDocumentIndex); + positionInfo = GetPositionInfo(codeDocument, hostDocumentIndex, preferCSharpOverHtml); return true; } diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostGoToImplementationEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostGoToImplementationEndpoint.cs new file mode 100644 index 0000000000..be8e197bbb --- /dev/null +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostGoToImplementationEndpoint.cs @@ -0,0 +1,153 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Composition; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; +using Microsoft.CodeAnalysis.Razor.Remote; +using Microsoft.CodeAnalysis.Razor.Workspaces; +using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using RoslynLspFactory = Roslyn.LanguageServer.Protocol.RoslynLspFactory; +using RoslynLspLocation = Roslyn.LanguageServer.Protocol.Location; +using VsLspLocation = Microsoft.VisualStudio.LanguageServer.Protocol.Location; + +namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; + +#pragma warning disable RS0030 // Do not use banned APIs +[Shared] +[CohostEndpoint(Methods.TextDocumentImplementationName)] +[Export(typeof(IDynamicRegistrationProvider))] +[ExportCohostStatelessLspService(typeof(CohostGoToImplementationEndpoint))] +[method: ImportingConstructor] +#pragma warning restore RS0030 // Do not use banned APIs +internal sealed class CohostGoToImplementationEndpoint( + IRemoteServiceInvoker remoteServiceInvoker, + IHtmlDocumentSynchronizer htmlDocumentSynchronizer, + LSPRequestInvoker requestInvoker, + IFilePathService filePathService) + : AbstractRazorCohostDocumentRequestHandler?>, IDynamicRegistrationProvider +{ + private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker; + private readonly IHtmlDocumentSynchronizer _htmlDocumentSynchronizer = htmlDocumentSynchronizer; + private readonly LSPRequestInvoker _requestInvoker = requestInvoker; + private readonly IFilePathService _filePathService = filePathService; + + protected override bool MutatesSolutionState => false; + + protected override bool RequiresLSPSolution => true; + + public Registration? GetRegistration(VSInternalClientCapabilities clientCapabilities, DocumentFilter[] filter, RazorCohostRequestContext requestContext) + { + if (clientCapabilities.TextDocument?.Implementation?.DynamicRegistration == true) + { + return new Registration + { + Method = Methods.TextDocumentImplementationName, + RegisterOptions = new ImplementationOptions() + }; + } + + return null; + } + + protected override RazorTextDocumentIdentifier? GetRazorTextDocumentIdentifier(TextDocumentPositionParams request) + => request.TextDocument.ToRazorTextDocumentIdentifier(); + + protected override Task?> HandleRequestAsync(TextDocumentPositionParams request, RazorCohostRequestContext context, CancellationToken cancellationToken) + => HandleRequestAsync( + request, + context.TextDocument.AssumeNotNull(), + cancellationToken); + + private async Task?> HandleRequestAsync(TextDocumentPositionParams request, TextDocument razorDocument, CancellationToken cancellationToken) + { + var position = RoslynLspFactory.CreatePosition(request.Position.ToLinePosition()); + + var response = await _remoteServiceInvoker + .TryInvokeAsync>( + razorDocument.Project.Solution, + (service, solutionInfo, cancellationToken) => + service.GetImplementationAsync(solutionInfo, razorDocument.Id, position, cancellationToken), + cancellationToken) + .ConfigureAwait(false); + + if (response.Result is RoslynLspLocation[] locations) + { + return locations; + } + + if (response.StopHandling) + { + return null; + } + + return await GetHtmlImplementationsAsync(request, razorDocument, cancellationToken).ConfigureAwait(false); + } + + private async Task?> GetHtmlImplementationsAsync(TextDocumentPositionParams request, TextDocument razorDocument, CancellationToken cancellationToken) + { + var htmlDocument = await _htmlDocumentSynchronizer.TryGetSynchronizedHtmlDocumentAsync(razorDocument, cancellationToken).ConfigureAwait(false); + if (htmlDocument is null) + { + return null; + } + + request.TextDocument = request.TextDocument.WithUri(htmlDocument.Uri); + + var result = await _requestInvoker + .ReinvokeRequestOnServerAsync?>( + htmlDocument.Buffer, + Methods.TextDocumentImplementationName, + RazorLSPConstants.HtmlLanguageServerName, + request, + cancellationToken) + .ConfigureAwait(false); + + if (result is not { Response: { } response }) + { + return null; + } + + if (response.TryGetFirst(out var locations)) + { + foreach (var location in locations) + { + RemapVirtualHtmlUri(location); + } + + return locations; + } + else if (response.TryGetSecond(out var referenceItems)) + { + foreach (var referenceItem in referenceItems) + { + RemapVirtualHtmlUri(referenceItem.Location); + } + + return referenceItems; + } + + return null; + } + + private void RemapVirtualHtmlUri(VsLspLocation location) + { + if (_filePathService.IsVirtualHtmlFile(location.Uri)) + { + location.Uri = _filePathService.GetRazorDocumentUri(location.Uri); + } + } + + internal TestAccessor GetTestAccessor() => new(this); + + internal readonly struct TestAccessor(CohostGoToImplementationEndpoint instance) + { + public Task?> HandleRequestAsync( + TextDocumentPositionParams request, TextDocument razorDocument, CancellationToken cancellationToken) + => instance.HandleRequestAsync(request, razorDocument, cancellationToken); + } +} diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs new file mode 100644 index 0000000000..170ca71d6a --- /dev/null +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs @@ -0,0 +1,166 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Test.Common; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Microsoft.CodeAnalysis.Remote.Razor; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.LanguageServer.Protocol; +using Xunit; +using Xunit.Abstractions; +using LspLocation = Microsoft.VisualStudio.LanguageServer.Protocol.Location; +using RoslynLspExtensions = Roslyn.LanguageServer.Protocol.RoslynLspExtensions; + +namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; + +public class CohostGoToImplementationEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) +{ + [Fact] + public async Task CSharp_Method() + { + var input = """ +
+ + @{ + var x = Ge$$tX(); + } + + @code + { + void [|GetX|]() + { + } + } + """; + + await VerifyCSharpGoToImplementationAsync(input); + } + + [Fact] + public async Task CSharp_Field() + { + var input = """ +
+ + @{ + var x = GetX(); + } + + @code + { + private string [|_name|]; + + string GetX() + { + return _na$$me; + } + } + """; + + await VerifyCSharpGoToImplementationAsync(input); + } + + [Fact] + public async Task CSharp_Multiple() + { + var input = """ +
+ + @code + { + class [|Base|] { } + class [|Derived1|] : Base { } + class [|Derived2|] : Base { } + + void M(Ba$$se b) + { + } + } + """; + + await VerifyCSharpGoToImplementationAsync(input); + } + + [Fact] + public async Task Html() + { + // This really just validates Uri remapping, the actual response is largely arbitrary + + TestCode input = """ +
+ + + """; + + var document = CreateProjectAndRazorDocument(input.Text); + var inputText = await document.GetTextAsync(DisposalToken); + + var htmlResponse = new SumType?(new LspLocation[] + { + new LspLocation + { + Uri = new Uri(document.CreateUri(), document.Name + FeatureOptions.HtmlVirtualDocumentSuffix), + Range = inputText.GetRange(input.Span), + }, + }); + + var requestInvoker = new TestLSPRequestInvoker([(Methods.TextDocumentImplementationName, htmlResponse)]); + + await VerifyGoToImplementationResultAsync(input, document, requestInvoker); + } + + private async Task VerifyCSharpGoToImplementationAsync(TestCode input) + { + var document = CreateProjectAndRazorDocument(input.Text); + + var requestInvoker = new TestLSPRequestInvoker(); + + await VerifyGoToImplementationResultAsync(input, document, requestInvoker); + } + + private async Task VerifyGoToImplementationResultAsync(TestCode input, TextDocument document, TestLSPRequestInvoker requestInvoker) + { + var inputText = await document.GetTextAsync(DisposalToken); + + var filePathService = new RemoteFilePathService(FeatureOptions); + var endpoint = new CohostGoToImplementationEndpoint(RemoteServiceInvoker, TestHtmlDocumentSynchronizer.Instance, requestInvoker, filePathService); + + var position = inputText.GetPosition(input.Position); + var textDocumentPositionParams = new TextDocumentPositionParams + { + Position = position, + TextDocument = new TextDocumentIdentifier { Uri = document.CreateUri() }, + }; + + var result = await endpoint.GetTestAccessor().HandleRequestAsync(textDocumentPositionParams, document, DisposalToken); + + if (result.Value.TryGetFirst(out var roslynLocations)) + { + var expected = input.Spans.Select(s => inputText.GetRange(s).ToLinePositionSpan()).OrderBy(r => r.Start.Line).ToArray(); + var actual = roslynLocations.Select(l => RoslynLspExtensions.ToLinePositionSpan(l.Range)).OrderBy(r => r.Start.Line).ToArray(); + Assert.Equal(expected, actual); + + Assert.All(roslynLocations, l => l.Uri.Equals(document.CreateUri())); + } + else if (result.Value.TryGetSecond(out var vsLocations)) + { + var expected = input.Spans.Select(s => inputText.GetRange(s).ToLinePositionSpan()).OrderBy(r => r.Start.Line).ToArray(); + var actual = vsLocations.Select(l => l.Range.ToLinePositionSpan()).OrderBy(r => r.Start.Line).ToArray(); + Assert.Equal(expected, actual); + + Assert.All(vsLocations, l => l.Uri.Equals(document.CreateUri())); + } + else + { + Assert.Fail($"Unsupported result type: {result.Value.GetType()}"); + } + } +} From 84c2983392827a137e6b55be48f03a7a0dceb6b8 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 4 Sep 2024 11:21:13 +1000 Subject: [PATCH 10/19] Whitespace --- .../CohostGoToImplementationEndpointTest.cs | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs index 170ca71d6a..4ee5dab2c8 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs @@ -23,19 +23,19 @@ public class CohostGoToImplementationEndpointTest(ITestOutputHelper testOutputHe public async Task CSharp_Method() { var input = """ -
+
- @{ - var x = Ge$$tX(); - } + @{ + var x = Ge$$tX(); + } - @code + @code + { + void [|GetX|]() { - void [|GetX|]() - { - } } - """; + } + """; await VerifyCSharpGoToImplementationAsync(input); } @@ -44,22 +44,22 @@ public class CohostGoToImplementationEndpointTest(ITestOutputHelper testOutputHe public async Task CSharp_Field() { var input = """ -
+
- @{ - var x = GetX(); - } + @{ + var x = GetX(); + } - @code + @code + { + private string [|_name|]; + + string GetX() { - private string [|_name|]; - - string GetX() - { - return _na$$me; - } + return _na$$me; } - """; + } + """; await VerifyCSharpGoToImplementationAsync(input); } @@ -68,19 +68,19 @@ public class CohostGoToImplementationEndpointTest(ITestOutputHelper testOutputHe public async Task CSharp_Multiple() { var input = """ -
+
- @code + @code + { + class [|Base|] { } + class [|Derived1|] : Base { } + class [|Derived2|] : Base { } + + void M(Ba$$se b) { - class [|Base|] { } - class [|Derived1|] : Base { } - class [|Derived2|] : Base { } - - void M(Ba$$se b) - { - } } - """; + } + """; await VerifyCSharpGoToImplementationAsync(input); } @@ -91,14 +91,14 @@ public class CohostGoToImplementationEndpointTest(ITestOutputHelper testOutputHe // This really just validates Uri remapping, the actual response is largely arbitrary TestCode input = """ -
+
- - """; + + """; var document = CreateProjectAndRazorDocument(input.Text); var inputText = await document.GetTextAsync(DisposalToken); From 41acbdeb665c11bf26fea16b017ebf54e6a74e22 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 23:00:56 -0700 Subject: [PATCH 11/19] Update dependencies from https://github.com/dotnet/arcade build 20240826.2 (#10808) Microsoft.SourceBuild.Intermediate.arcade , Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24421.4 -> To Version 8.0.0-beta.24426.2 Co-authored-by: dotnet-maestro[bot] --- eng/Version.Details.xml | 8 ++++---- eng/Versions.props | 2 +- global.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index a674ac1037..100731f89a 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -96,14 +96,14 @@ https://dev.azure.com/dnceng/internal/_git/dotnet-runtime 3a25a7f1cc446b60678ed25c9d829420d6321eba - + https://github.com/dotnet/arcade - 4460b755f3c7c89e9660d9580ff79afc4218dd85 + 80264e60280e2815e7d65871081ccac04a32445c - + https://github.com/dotnet/arcade - 4460b755f3c7c89e9660d9580ff79afc4218dd85 + 80264e60280e2815e7d65871081ccac04a32445c diff --git a/eng/Versions.props b/eng/Versions.props index 76c5f9ea27..9296f59137 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -50,7 +50,7 @@ 6.0.2-servicing.22064.6 6.0.1 9.0.0-alpha.1.24304.1 - 8.0.0-beta.24421.4 + 8.0.0-beta.24426.2 1.0.0-beta.23475.1 1.0.0-beta.23475.1 4.11.0-3.24303.3 diff --git a/global.json b/global.json index bbd507f30d..0b7a32c006 100644 --- a/global.json +++ b/global.json @@ -21,7 +21,7 @@ "rollForward": "latestPatch" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24421.4", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24426.2", "Microsoft.Build.NoTargets": "3.7.0" } } From 7d8be8e16767e182beb31388d70c73eab1006abf Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 5 Sep 2024 12:12:55 +1000 Subject: [PATCH 12/19] Most PR feedback --- .../RazorCSharpFormattingBenchmark.cs | 2 +- .../CSharp/DefaultCSharpCodeActionResolver.cs | 2 +- .../Formatting/RazorFormattingOptions.cs | 2 -- .../Formatting/RazorFormattingService.cs | 15 ++++---- .../Remote/IRemoteFormattingService.cs | 34 +++++++++++++++--- .../Formatting/RemoteFormattingService.cs | 35 ++++++++++--------- .../RemoteRazorFormattingService.cs | 2 +- .../CohostDocumentFormattingEndpoint.cs | 12 +++---- .../Cohost/CohostOnTypeFormattingEndpoint.cs | 8 ++--- .../Cohost/CohostRangeFormattingEndpoint.cs | 8 ++--- .../FormattingLanguageServerTestBase.cs | 2 +- 11 files changed, 73 insertions(+), 49 deletions(-) diff --git a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer/RazorCSharpFormattingBenchmark.cs b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer/RazorCSharpFormattingBenchmark.cs index 12056563e0..88d6e3b633 100644 --- a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer/RazorCSharpFormattingBenchmark.cs +++ b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer/RazorCSharpFormattingBenchmark.cs @@ -112,7 +112,7 @@ public class RazorCSharpFormattingBenchmark : RazorLanguageServerBenchmarkBase { var documentContext = new DocumentContext(DocumentUri, DocumentSnapshot, projectContext: null); - var edits = await RazorFormattingService.GetDocumentFormattingEditsAsync(documentContext, htmlEdits: [], range: null, RazorFormattingOptions.Default, CancellationToken.None); + var edits = await RazorFormattingService.GetDocumentFormattingEditsAsync(documentContext, htmlEdits: [], range: null, new RazorFormattingOptions(), CancellationToken.None); #if DEBUG // For debugging purposes only. diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CSharp/DefaultCSharpCodeActionResolver.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CSharp/DefaultCSharpCodeActionResolver.cs index 5e0636c681..7457c02597 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CSharp/DefaultCSharpCodeActionResolver.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CSharp/DefaultCSharpCodeActionResolver.cs @@ -68,7 +68,7 @@ internal sealed class DefaultCSharpCodeActionResolver( var formattedEdit = await _razorFormattingService.GetCSharpCodeActionEditAsync( documentContext, csharpTextEdits, - RazorFormattingOptions.Default, + new RazorFormattingOptions(), cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs index a1ab2f6a3e..fdacc443ec 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs @@ -10,8 +10,6 @@ namespace Microsoft.CodeAnalysis.Razor.Formatting; [DataContract] internal readonly record struct RazorFormattingOptions { - public static readonly RazorFormattingOptions Default = new(); - [DataMember(Order = 0)] public bool InsertSpaces { get; init; } = true; [DataMember(Order = 1)] diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs index c5f28c682c..87bf5d68bf 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs @@ -199,16 +199,13 @@ internal class RazorFormattingService : IRazorFormattingService public bool TryGetOnTypeFormattingTriggerKind(RazorCodeDocument codeDocument, int hostDocumentIndex, string triggerCharacter, out RazorLanguageKind triggerCharacterKind) { triggerCharacterKind = _documentMappingService.GetLanguageKind(codeDocument, hostDocumentIndex, rightAssociative: false); - if (triggerCharacterKind is RazorLanguageKind.CSharp) - { - return s_csharpTriggerCharacterSet.Contains(triggerCharacter); - } - else if (triggerCharacterKind is RazorLanguageKind.Html) - { - return s_htmlTriggerCharacterSet.Contains(triggerCharacter); - } - return false; + return triggerCharacterKind switch + { + RazorLanguageKind.CSharp => s_csharpTriggerCharacterSet.Contains(triggerCharacter), + RazorLanguageKind.Html => s_htmlTriggerCharacterSet.Contains(triggerCharacter), + _ => false, + }; } private async Task ApplyFormattedEditsAsync( diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFormattingService.cs index 8a1b7aa379..3ec3ae4cb9 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFormattingService.cs @@ -12,10 +12,36 @@ namespace Microsoft.CodeAnalysis.Razor.Remote; internal interface IRemoteFormattingService { - ValueTask> GetDocumentFormattingEditsAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId documentId, ImmutableArray htmlChanges, RazorFormattingOptions options, CancellationToken cancellationToken); - ValueTask> GetRangeFormattingEditsAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId documentId, ImmutableArray htmlChanges, LinePositionSpan linePositionSpan, RazorFormattingOptions options, CancellationToken cancellationToken); - ValueTask> GetOnTypeFormattingEditsAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId documentId, ImmutableArray htmlChanges, LinePosition linePosition, string triggerCharacter, RazorFormattingOptions options, CancellationToken cancellationToken); - ValueTask GetOnTypeFormattingTriggerKindAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId documentId, LinePosition linePosition, string triggerCharacter, CancellationToken cancellationToken); + ValueTask> GetDocumentFormattingEditsAsync( + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + ImmutableArray htmlChanges, + RazorFormattingOptions options, + CancellationToken cancellationToken); + + ValueTask> GetRangeFormattingEditsAsync( + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + ImmutableArray htmlChanges, + LinePositionSpan linePositionSpan, + RazorFormattingOptions options, + CancellationToken cancellationToken); + + ValueTask> GetOnTypeFormattingEditsAsync( + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + ImmutableArray htmlChanges, + LinePosition linePosition, + string triggerCharacter, + RazorFormattingOptions options, + CancellationToken cancellationToken); + + ValueTask GetOnTypeFormattingTriggerKindAsync( + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + LinePosition linePosition, + string triggerCharacter, + CancellationToken cancellationToken); internal enum TriggerKind { diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingService.cs index e0dc5d35ac..e3e334604c 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteFormattingService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Immutable; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -53,24 +54,24 @@ internal sealed class RemoteFormattingService(in ServiceArgs args) : RazorDocume if (edits is null) { - return ImmutableArray.Empty; + return []; } return edits.SelectAsArray(sourceText.GetTextChange); } public ValueTask> GetRangeFormattingEditsAsync( - RazorPinnedSolutionInfoWrapper solutionInfo, - DocumentId documentId, - ImmutableArray htmlChanges, - LinePositionSpan linePositionSpan, - RazorFormattingOptions options, - CancellationToken cancellationToken) - => RunServiceAsync( - solutionInfo, - documentId, - context => GetRangeFormattingEditsAsync(context, htmlChanges, linePositionSpan, options, cancellationToken), - cancellationToken); + RazorPinnedSolutionInfoWrapper solutionInfo, + DocumentId documentId, + ImmutableArray htmlChanges, + LinePositionSpan linePositionSpan, + RazorFormattingOptions options, + CancellationToken cancellationToken) + => RunServiceAsync( + solutionInfo, + documentId, + context => GetRangeFormattingEditsAsync(context, htmlChanges, linePositionSpan, options, cancellationToken), + cancellationToken); private async ValueTask> GetRangeFormattingEditsAsync( RemoteDocumentContext context, @@ -86,7 +87,7 @@ internal sealed class RemoteFormattingService(in ServiceArgs args) : RazorDocume if (edits is null) { - return ImmutableArray.Empty; + return []; } return edits.SelectAsArray(sourceText.GetTextChange); @@ -132,8 +133,7 @@ internal sealed class RemoteFormattingService(in ServiceArgs args) : RazorDocume } else { - Assumed.Unreachable(); - return []; + return Assumed.Unreachable>(); } return result.SelectAsArray(sourceText.GetTextChange); @@ -154,7 +154,7 @@ internal sealed class RemoteFormattingService(in ServiceArgs args) : RazorDocume private async ValueTask IsValidOnTypeFormattingTriggerAsync(RemoteDocumentContext context, LinePosition linePosition, string triggerCharacter, CancellationToken cancellationToken) { var codeDocument = await context.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false); - var sourceText = await context.GetSourceTextAsync(cancellationToken).ConfigureAwait(false); + var sourceText = codeDocument.Source.Text; if (!sourceText.TryGetAbsoluteIndex(linePosition, out var hostDocumentIndex)) { return Response.Invalid; @@ -170,6 +170,9 @@ internal sealed class RemoteFormattingService(in ServiceArgs args) : RazorDocume return Response.ValidHtml; } + // TryGetOnTypeFormattingTriggerKind only returns true for C# or Html + Debug.Assert(triggerCharacterKind is RazorLanguageKind.CSharp); + return Response.ValidCSharp; } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteRazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteRazorFormattingService.cs index 7d9344fe3d..6974dabd01 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteRazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Formatting/RemoteRazorFormattingService.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor.Formatting; [Export(typeof(IRazorFormattingService)), Shared] [method: ImportingConstructor] -internal class RemoteRazorFormattingService(IFormattingCodeDocumentProvider codeDocumentProvider, IDocumentMappingService documentMappingService, IAdhocWorkspaceFactory adhocWorkspaceFactory, ILoggerFactory loggerFactory) +internal sealed class RemoteRazorFormattingService(IFormattingCodeDocumentProvider codeDocumentProvider, IDocumentMappingService documentMappingService, IAdhocWorkspaceFactory adhocWorkspaceFactory, ILoggerFactory loggerFactory) : RazorFormattingService(codeDocumentProvider, documentMappingService, adhocWorkspaceFactory, loggerFactory) { } diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentFormattingEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentFormattingEndpoint.cs index 8589644a08..9fa42babe9 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentFormattingEndpoint.cs @@ -27,7 +27,7 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; [ExportCohostStatelessLspService(typeof(CohostDocumentFormattingEndpoint))] [method: ImportingConstructor] #pragma warning restore RS0030 // Do not use banned APIs -internal class CohostDocumentFormattingEndpoint( +internal sealed class CohostDocumentFormattingEndpoint( IRemoteServiceInvoker remoteServiceInvoker, IHtmlDocumentSynchronizer htmlDocumentSynchronizer, LSPRequestInvoker requestInvoker, @@ -71,7 +71,7 @@ internal class CohostDocumentFormattingEndpoint( private async Task HandleRequestAsync(DocumentFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) { _logger.LogDebug($"Getting Html formatting changes for {razorDocument.FilePath}"); - var htmlResult = await GetHtmlFormattingEditsAsync(request, razorDocument, cancellationToken).ConfigureAwait(false); + var htmlResult = await TryGetHtmlFormattingEditsAsync(request, razorDocument, cancellationToken).ConfigureAwait(false); if (htmlResult is not { } htmlEdits) { @@ -91,17 +91,17 @@ internal class CohostDocumentFormattingEndpoint( (service, solutionInfo, cancellationToken) => service.GetDocumentFormattingEditsAsync(solutionInfo, razorDocument.Id, htmlChanges, options, cancellationToken), cancellationToken).ConfigureAwait(false); - if (remoteResult is [_, ..] allChanges) + if (remoteResult.Length > 0) { - _logger.LogDebug($"Got a total of {allChanges.Length} ranges back from OOP"); + _logger.LogDebug($"Got a total of {remoteResult.Length} ranges back from OOP"); - return allChanges.Select(sourceText.GetTextEdit).ToArray(); + return remoteResult.Select(sourceText.GetTextEdit).ToArray(); } return null; } - private async Task GetHtmlFormattingEditsAsync(DocumentFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) + private async Task TryGetHtmlFormattingEditsAsync(DocumentFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) { var htmlDocument = await _htmlDocumentSynchronizer.TryGetSynchronizedHtmlDocumentAsync(razorDocument, cancellationToken).ConfigureAwait(false); if (htmlDocument is null) diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs index e5cd437628..11a2a6f207 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs @@ -27,7 +27,7 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; [ExportCohostStatelessLspService(typeof(CohostOnTypeFormattingEndpoint))] [method: ImportingConstructor] #pragma warning restore RS0030 // Do not use banned APIs -internal class CohostOnTypeFormattingEndpoint( +internal sealed class CohostOnTypeFormattingEndpoint( IRemoteServiceInvoker remoteServiceInvoker, IHtmlDocumentSynchronizer htmlDocumentSynchronizer, LSPRequestInvoker requestInvoker, @@ -127,11 +127,11 @@ internal class CohostOnTypeFormattingEndpoint( (service, solutionInfo, cancellationToken) => service.GetOnTypeFormattingEditsAsync(solutionInfo, razorDocument.Id, htmlChanges, request.Position.ToLinePosition(), request.Character, options, cancellationToken), cancellationToken).ConfigureAwait(false); - if (remoteResult is [_, ..] allChanges) + if (remoteResult.Length > 0) { - _logger.LogDebug($"Got a total of {allChanges.Length} ranges back from OOP"); + _logger.LogDebug($"Got a total of {remoteResult.Length} ranges back from OOP"); - return allChanges.Select(sourceText.GetTextEdit).ToArray(); + return remoteResult.Select(sourceText.GetTextEdit).ToArray(); } return null; diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs index 9be30b7eab..cc27035b56 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs @@ -27,7 +27,7 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; [ExportCohostStatelessLspService(typeof(CohostRangeFormattingEndpoint))] [method: ImportingConstructor] #pragma warning restore RS0030 // Do not use banned APIs -internal class CohostRangeFormattingEndpoint( +internal sealed class CohostRangeFormattingEndpoint( IRemoteServiceInvoker remoteServiceInvoker, IHtmlDocumentSynchronizer htmlDocumentSynchronizer, LSPRequestInvoker requestInvoker, @@ -91,11 +91,11 @@ internal class CohostRangeFormattingEndpoint( (service, solutionInfo, cancellationToken) => service.GetRangeFormattingEditsAsync(solutionInfo, razorDocument.Id, htmlChanges, request.Range.ToLinePositionSpan(), options, cancellationToken), cancellationToken).ConfigureAwait(false); - if (remoteResult is [_, ..] allChanges) + if (remoteResult.Length > 0) { - _logger.LogDebug($"Got a total of {allChanges.Length} ranges back from OOP"); + _logger.LogDebug($"Got a total of {remoteResult.Length} ranges back from OOP"); - return allChanges.Select(sourceText.GetTextEdit).ToArray(); + return remoteResult.Select(sourceText.GetTextEdit).ToArray(); } return null; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerTestBase.cs index d14e475aa5..85dfee530a 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingLanguageServerTestBase.cs @@ -69,7 +69,7 @@ public abstract class FormattingLanguageServerTestBase(ITestOutputHelper testOut public bool TryGetOnTypeFormattingTriggerKind(RazorCodeDocument codeDocument, int hostDocumentIndex, string triggerCharacter, out RazorLanguageKind triggerCharacterKind) { - triggerCharacterKind = languageKind ?? RazorLanguageKind.CSharp; + triggerCharacterKind = languageKind.GetValueOrDefault(); return languageKind is not null; } } From d87ad016dd11c313341b504f50144cb7261c4b8d Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 5 Sep 2024 13:09:33 +1000 Subject: [PATCH 13/19] Move initialization logic --- .../Formatting/DocumentOnTypeFormattingEndpoint.cs | 6 +----- .../Hosting/LspInitializationHelpers.cs | 9 +++++++++ .../Formatting/RazorFormattingService.cs | 5 +++-- .../Cohost/CohostOnTypeFormattingEndpoint.cs | 5 ++--- .../Formatting_NetFx/RazorFormattingServiceTest.cs | 13 ++----------- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs index 6568e9deb3..af7b91a5c2 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs @@ -41,11 +41,7 @@ internal class DocumentOnTypeFormattingEndpoint( public void ApplyCapabilities(VSInternalServerCapabilities serverCapabilities, VSInternalClientCapabilities clientCapabilities) { - serverCapabilities.DocumentOnTypeFormattingProvider = new DocumentOnTypeFormattingOptions - { - FirstTriggerCharacter = RazorFormattingService.AllTriggerCharacters[0], - MoreTriggerCharacter = RazorFormattingService.AllTriggerCharacters.AsSpan()[1..].ToArray(), - }; + serverCapabilities.DocumentOnTypeFormattingProvider = new DocumentOnTypeFormattingOptions().EnableOnTypeFormattingTriggerCharacters(); } public TextDocumentIdentifier GetTextDocumentIdentifier(DocumentOnTypeFormattingParams request) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/LspInitializationHelpers.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/LspInitializationHelpers.cs index ac141c8168..f6016f918c 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/LspInitializationHelpers.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/LspInitializationHelpers.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; +using Microsoft.CodeAnalysis.Razor.Formatting; using Microsoft.CodeAnalysis.Razor.SemanticTokens; using Microsoft.VisualStudio.LanguageServer.Protocol; @@ -84,4 +85,12 @@ internal static class LspInitializationHelpers return options; } + + public static DocumentOnTypeFormattingOptions EnableOnTypeFormattingTriggerCharacters(this DocumentOnTypeFormattingOptions options) + { + options.FirstTriggerCharacter = RazorFormattingService.FirstTriggerCharacter; + options.MoreTriggerCharacter = RazorFormattingService.MoreTriggerCharacters.ToArray(); + + return options; + } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs index 6186505c51..b4c593f67d 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs @@ -23,8 +23,9 @@ namespace Microsoft.CodeAnalysis.Razor.Formatting; internal class RazorFormattingService : IRazorFormattingService { - public static readonly ImmutableArray AllTriggerCharacters = ["}", ";", "\n", "{"]; - public static readonly FrozenSet AllTriggerCharacterSet = AllTriggerCharacters.ToFrozenSet(StringComparer.Ordinal); + public static readonly string FirstTriggerCharacter = "}"; + public static readonly ImmutableArray MoreTriggerCharacters = [";", "\n", "{"]; + public static readonly FrozenSet AllTriggerCharacterSet = FrozenSet.ToFrozenSet([FirstTriggerCharacter, .. MoreTriggerCharacters], StringComparer.Ordinal); private static readonly FrozenSet s_csharpTriggerCharacterSet = FrozenSet.ToFrozenSet(["}", ";"], StringComparer.Ordinal); private static readonly FrozenSet s_htmlTriggerCharacterSet = FrozenSet.ToFrozenSet(["\n", "{", "}", ";"], StringComparer.Ordinal); diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs index 11a2a6f207..a08a12a2a6 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnTypeFormattingEndpoint.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor; +using Microsoft.AspNetCore.Razor.LanguageServer.Hosting; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; using Microsoft.CodeAnalysis.Razor.Formatting; @@ -55,9 +56,7 @@ internal sealed class CohostOnTypeFormattingEndpoint( RegisterOptions = new DocumentOnTypeFormattingRegistrationOptions() { DocumentSelector = filter, - FirstTriggerCharacter = RazorFormattingService.AllTriggerCharacters[0], - MoreTriggerCharacter = RazorFormattingService.AllTriggerCharacters.AsSpan()[1..].ToArray(), - } + }.EnableOnTypeFormattingTriggerCharacters() }; } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingServiceTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingServiceTest.cs index b3d38ddd5b..6c56614d77 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingServiceTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingServiceTest.cs @@ -46,7 +46,7 @@ public class Foo{} { foreach (var character in RazorFormattingService.TestAccessor.GetCSharpTriggerCharacterSet()) { - Assert.Contains(character, RazorFormattingService.AllTriggerCharacters); + Assert.Contains(character, RazorFormattingService.AllTriggerCharacterSet); } } @@ -55,16 +55,7 @@ public class Foo{} { foreach (var character in RazorFormattingService.TestAccessor.GetHtmlTriggerCharacterSet()) { - Assert.Contains(character, RazorFormattingService.AllTriggerCharacters); + Assert.Contains(character, RazorFormattingService.AllTriggerCharacterSet); } } - - [Fact] - public void AllTriggerCharacters_ContainsUniqueCharacters() - { - var allChars = RazorFormattingService.AllTriggerCharacters; - var distinctChars = allChars.Distinct().ToArray(); - - Assert.Equal(distinctChars, allChars); - } } From b7cd05e45378f91951ef430b6d4660bd368f847b Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 5 Sep 2024 13:15:10 +1000 Subject: [PATCH 14/19] Remove unused parameter --- .../DocumentOnTypeFormattingEndpoint.cs | 2 -- .../Formatting/RazorFormattingService.cs | 2 +- .../DocumentOnTypeFormattingEndpointTest.cs | 23 +++++-------------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs index af7b91a5c2..2c2a853b61 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs @@ -26,13 +26,11 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting; internal class DocumentOnTypeFormattingEndpoint( IRazorFormattingService razorFormattingService, IHtmlFormatter htmlFormatter, - IDocumentMappingService documentMappingService, RazorLSPOptionsMonitor optionsMonitor, ILoggerFactory loggerFactory) : IRazorRequestHandler, ICapabilitiesProvider { private readonly IRazorFormattingService _razorFormattingService = razorFormattingService; - private readonly IDocumentMappingService _documentMappingService = documentMappingService; private readonly RazorLSPOptionsMonitor _optionsMonitor = optionsMonitor; private readonly IHtmlFormatter _htmlFormatter = htmlFormatter; private readonly ILogger _logger = loggerFactory.GetOrCreateLogger(); diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs index b4c593f67d..396f6cf7ee 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs @@ -310,7 +310,7 @@ internal class RazorFormattingService : IRazorFormattingService /// If LF line endings are more prevalent, it removes any CR characters from the text edits /// to ensure consistency with the LF style. ///
- private TextEdit[] NormalizeLineEndings(SourceText originalText, TextEdit[] edits) + private static TextEdit[] NormalizeLineEndings(SourceText originalText, TextEdit[] edits) { if (originalText.HasLFLineEndings()) { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentOnTypeFormattingEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentOnTypeFormattingEndpointTest.cs index 5448d383ab..7d313bfffa 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentOnTypeFormattingEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentOnTypeFormattingEndpointTest.cs @@ -4,12 +4,9 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; -using Microsoft.CodeAnalysis.Razor.DocumentMapping; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.VisualStudio.LanguageServer.Protocol; -using Moq; using Xunit; using Xunit.Abstractions; @@ -23,12 +20,11 @@ public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) // Arrange var uri = new Uri("file://path/test.razor"); var formattingService = new DummyRazorFormattingService(); - var documentMappingService = new LspDocumentMappingService(FilePathService, new TestDocumentContextFactory(), LoggerFactory); var optionsMonitor = GetOptionsMonitor(enableFormatting: false); var htmlFormatter = new TestHtmlFormatter(); var endpoint = new DocumentOnTypeFormattingEndpoint( - formattingService, htmlFormatter, documentMappingService, optionsMonitor, LoggerFactory); + formattingService, htmlFormatter, optionsMonitor, LoggerFactory); var @params = new DocumentOnTypeFormattingParams { TextDocument = new TextDocumentIdentifier { Uri = uri, } }; var requestContext = CreateRazorRequestContext(documentContext: null); @@ -52,12 +48,11 @@ public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) var documentContext = CreateDocumentContext(new Uri("file://path/testDifferentFile.razor"), codeDocument); var formattingService = new DummyRazorFormattingService(); - var documentMappingService = new LspDocumentMappingService(FilePathService, new TestDocumentContextFactory(), LoggerFactory); var optionsMonitor = GetOptionsMonitor(enableFormatting: true); var htmlFormatter = new TestHtmlFormatter(); var endpoint = new DocumentOnTypeFormattingEndpoint( - formattingService, htmlFormatter, documentMappingService, optionsMonitor, LoggerFactory); + formattingService, htmlFormatter, optionsMonitor, LoggerFactory); var @params = new DocumentOnTypeFormattingParams() { TextDocument = new TextDocumentIdentifier { Uri = uri, }, @@ -87,12 +82,11 @@ public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) var documentContext = CreateDocumentContext(uri, codeDocument); var formattingService = new DummyRazorFormattingService(); - var documentMappingService = new LspDocumentMappingService(FilePathService, new TestDocumentContextFactory(), LoggerFactory); var optionsMonitor = GetOptionsMonitor(enableFormatting: true); var htmlFormatter = new TestHtmlFormatter(); var endpoint = new DocumentOnTypeFormattingEndpoint( - formattingService, htmlFormatter, documentMappingService, optionsMonitor, LoggerFactory); + formattingService, htmlFormatter, optionsMonitor, LoggerFactory); var @params = new DocumentOnTypeFormattingParams() { TextDocument = new TextDocumentIdentifier { Uri = uri, }, @@ -123,12 +117,10 @@ public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) var documentContext = CreateDocumentContext(uri, codeDocument); var formattingService = new DummyRazorFormattingService(RazorLanguageKind.Html); - var documentMappingService = new Mock(MockBehavior.Strict); - documentMappingService.Setup(s => s.GetLanguageKind(codeDocument, 17, false)).Returns(RazorLanguageKind.Html); var optionsMonitor = GetOptionsMonitor(enableFormatting: true); var htmlFormatter = new TestHtmlFormatter(); var endpoint = new DocumentOnTypeFormattingEndpoint( - formattingService, htmlFormatter, documentMappingService.Object, optionsMonitor, LoggerFactory); + formattingService, htmlFormatter, optionsMonitor, LoggerFactory); var @params = new DocumentOnTypeFormattingParams() { TextDocument = new TextDocumentIdentifier { Uri = uri, }, @@ -159,12 +151,10 @@ public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) var documentContext = CreateDocumentContext(uri, codeDocument); var formattingService = new DummyRazorFormattingService(RazorLanguageKind.Razor); - var documentMappingService = new Mock(MockBehavior.Strict); - documentMappingService.Setup(s => s.GetLanguageKind(codeDocument, 17, false)).Returns(RazorLanguageKind.Razor); var optionsMonitor = GetOptionsMonitor(enableFormatting: true); var htmlFormatter = new TestHtmlFormatter(); var endpoint = new DocumentOnTypeFormattingEndpoint( - formattingService, htmlFormatter, documentMappingService.Object, optionsMonitor, LoggerFactory); + formattingService, htmlFormatter, optionsMonitor, LoggerFactory); var @params = new DocumentOnTypeFormattingParams() { TextDocument = new TextDocumentIdentifier { Uri = uri, }, @@ -194,12 +184,11 @@ public class DocumentOnTypeFormattingEndpointTest(ITestOutputHelper testOutput) var documentContextFactory = CreateDocumentContextFactory(uri, codeDocument); var formattingService = new DummyRazorFormattingService(); - var documentMappingService = new LspDocumentMappingService(FilePathService, documentContextFactory, LoggerFactory); var optionsMonitor = GetOptionsMonitor(enableFormatting: true); var htmlFormatter = new TestHtmlFormatter(); var endpoint = new DocumentOnTypeFormattingEndpoint( - formattingService, htmlFormatter, documentMappingService, optionsMonitor, LoggerFactory); + formattingService, htmlFormatter, optionsMonitor, LoggerFactory); var @params = new DocumentOnTypeFormattingParams() { TextDocument = new TextDocumentIdentifier { Uri = uri, }, From dde7fe8c2f3c2be154c631d281256cd153a0089e Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Thu, 5 Sep 2024 09:28:48 +0200 Subject: [PATCH 15/19] Ensure type arguments are `global::` qualified (#10834) * Add a test * Use fully globally qualified type name * Update baselines * Fix delegates and child content * Update baselines * Fix other child content scenarios * Update baselines * Encapsulate shared code --- .../ComponentCodeGenerationTestBase.cs | 55 +++++++++---- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 6 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 6 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 6 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 6 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 6 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 6 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.mappings.txt | 10 +-- .../GenericTypeCheck/TestComponent.codegen.cs | 77 +++++++++++++++++++ .../GenericTypeCheck/TestComponent.ir.txt | 23 ++++++ .../TestComponent.mappings.txt | 35 +++++++++ .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.mappings.txt | 8 +- .../GenericTypeCheck/TestComponent.codegen.cs | 60 +++++++++++++++ .../GenericTypeCheck/TestComponent.ir.txt | 14 ++++ .../TestComponent.mappings.txt | 35 +++++++++ .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../ComponentDesignTimeNodeWriter.cs | 14 +--- .../Components/ComponentNodeWriter.cs | 30 ++++++++ .../Components/ComponentRuntimeNodeWriter.cs | 14 +--- 150 files changed, 546 insertions(+), 263 deletions(-) create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.mappings.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.mappings.txt diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 57040aebba..02461edf28 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2336,9 +2336,9 @@ namespace Test : [// x:\dir\subdir\Test\TestComponent.cshtml(1,27): error CS1503: Argument 1: cannot convert from 'string' to 'int' // ParentValue Diagnostic(ErrorCode.ERR_BadArgType, "ParentValue").WithArguments("1", "string", "int").WithLocation(1, 27), - // (38,158): error CS0029: Cannot implicitly convert type 'int' to 'string' - // __builder.AddComponentParameter(2, "ValueChanged", (global::System.Action)(__value => ParentValue = __value)); - Diagnostic(ErrorCode.ERR_NoImplicitConv, "__value").WithArguments("int", "string").WithLocation(38, 158)]); + // (38,166): error CS0029: Cannot implicitly convert type 'int' to 'string' + // __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); + Diagnostic(ErrorCode.ERR_NoImplicitConv, "__value").WithArguments("int", "string").WithLocation(38, 166)]); } [IntegrationTestFact] @@ -2616,18 +2616,18 @@ namespace Test CompileToAssembly(generated, DesignTime - ? [// (31,179): error CS0029: Cannot implicitly convert type 'int' to 'string' - // __builder.AddComponentParameter(3, "ValueExpression", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); - Diagnostic(ErrorCode.ERR_NoImplicitConv, "ParentValue").WithArguments("int", "string").WithLocation(38, 179), - // (31,179): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type - // __builder.AddComponentParameter(3, "ValueExpression", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); - Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "ParentValue").WithArguments("lambda expression").WithLocation(38, 179)] - : [// (39,258): error CS0029: Cannot implicitly convert type 'int' to 'string' - // __builder.AddComponentParameter(3, "ValueExpression", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); - Diagnostic(ErrorCode.ERR_NoImplicitConv, "ParentValue").WithArguments("int", "string").WithLocation(39, 258), - // (39,258): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type - // __builder.AddComponentParameter(3, "ValueExpression", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); - Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "ParentValue").WithArguments("lambda expression").WithLocation(39, 258) + ? [// (38,195): error CS0029: Cannot implicitly convert type 'int' to 'string' + // __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue); + Diagnostic(ErrorCode.ERR_NoImplicitConv, "ParentValue").WithArguments("int", "string").WithLocation(38, 195), + // (38,195): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type + // __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue); + Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "ParentValue").WithArguments("lambda expression").WithLocation(38, 195)] + : [// (39,274): error CS0029: Cannot implicitly convert type 'int' to 'string' + // __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.ValueExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); + Diagnostic(ErrorCode.ERR_NoImplicitConv, "ParentValue").WithArguments("int", "string").WithLocation(39, 274), + // (39,274): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type + // __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.ValueExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); + Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "ParentValue").WithArguments("lambda expression").WithLocation(39, 274) ]); } @@ -8743,6 +8743,31 @@ namespace Test CompileToAssembly(generated); } + [IntegrationTestFact, WorkItem("https://github.com/dotnet/razor/issues/10827")] + public void GenericTypeCheck() + { + var generated = CompileToCSharp(""" + + + @code { + private class System + { + private class String + { + } + } + + [Parameter] + public List Data { get; set; } + } + """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion #region Key diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.codegen.cs index 754429913a..053890cdcb 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.codegen.cs @@ -35,7 +35,7 @@ namespace Test ); __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue))); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.mappings.txt index a19135f325..cffece03fb 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1135:29,26 [11] ) Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2197:45,19 [5] ) +Generated Location: (2213:45,19 [5] ) |Value| Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2610:63,7 [50] ) +Generated Location: (2626:63,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs index 934efc188b..b2cdc3c52e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => ParentValue = __value); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt index ca1dfc22c6..8764466578 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt @@ -5,19 +5,19 @@ Generated Location: (1135:29,26 [11] ) Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1668:44,19 [5] ) +Generated Location: (1676:44,19 [5] ) |Value| Source Location: (45:0,45 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1915:53,45 [5] ) +Generated Location: (1923:53,45 [5] ) |Value| Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2328:71,7 [50] ) +Generated Location: (2336:71,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.codegen.cs index a41ddb4b1f..9f671206f3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.codegen.cs @@ -33,9 +33,9 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => ParentValue = __value); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.mappings.txt index 4ebc3834dd..e53ee23626 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1135:29,26 [11] ) Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1860:45,19 [5] ) +Generated Location: (1884:45,19 [5] ) |Value| Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2273:63,7 [50] ) +Generated Location: (2297:63,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs index 973606f9d7..cd9931c87d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => ParentValue = __value); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt index cb7d4a2522..54450e18f9 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1135:29,26 [11] ) Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1668:44,19 [5] ) +Generated Location: (1676:44,19 [5] ) |Value| Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2081:62,7 [50] ) +Generated Location: (2089:62,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.codegen.cs index da7e74a784..f69fcc14f5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => ParentValue = __value); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.mappings.txt index bebd4144eb..d05b1672b9 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1131:29,22 [11] ) Source Location: (15:0,15 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1656:44,15 [5] ) +Generated Location: (1664:44,15 [5] ) |Value| Source Location: (46:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2065:62,7 [50] ) +Generated Location: (2073:62,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.codegen.cs index 02317b1f28..be16367fc2 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => ParentValue = __value); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.mappings.txt index c0b3b29ac6..ce4b96c423 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1127:29,18 [11] ) Source Location: (11:0,11 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1645:44,11 [5] ) +Generated Location: (1653:44,11 [5] ) |Value| Source Location: (42:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2051:62,7 [50] ) +Generated Location: (2059:62,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.codegen.cs index e57b3f7c0f..d91f706f6c 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => ParentValue = __value); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.mappings.txt index d69e5ca573..6bf8284da1 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1135:29,26 [11] ) Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1663:44,19 [5] ) +Generated Location: (1671:44,19 [5] ) |Value| Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2071:62,7 [50] ) +Generated Location: (2079:62,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.codegen.cs index 2d38b17095..a9c7f9e1c0 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => ParentValue = __value); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.mappings.txt index 39e1027589..0682636b19 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.mappings.txt @@ -5,7 +5,7 @@ Generated Location: (1135:29,26 [11] ) Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1668:44,19 [5] ) +Generated Location: (1676:44,19 [5] ) |Value| Source Location: (50:1,7 [105] x:\dir\subdir\Test\TestComponent.cshtml) @@ -14,7 +14,7 @@ Source Location: (50:1,7 [105] x:\dir\subdir\Test\TestComponent.cshtml) public string nameof(string s) => string.Empty; | -Generated Location: (2081:62,7 [105] ) +Generated Location: (2089:62,7 [105] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs index a108553352..703599cdda 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => ParentValue = __value); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt index a5d7ebef12..4116275996 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1135:29,26 [11] ) Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1668:44,19 [5] ) +Generated Location: (1676:44,19 [5] ) |Value| Source Location: (50:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) | public string ParentValue { get; set; } = "42"; | -Generated Location: (2081:62,7 [55] ) +Generated Location: (2089:62,7 [55] ) | public string ParentValue { get; set; } = "42"; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs index 325781c213..9aa28166c3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt index e1437b4eef..8b70c24ba0 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt @@ -5,17 +5,17 @@ Generated Location: (1139:29,30 [11] ) Source Location: (62:0,62 [6] x:\dir\subdir\Test\TestComponent.cshtml) |Update| -Generated Location: (1559:39,62 [6] ) +Generated Location: (1567:39,62 [6] ) |Update| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1983:52,19 [5] ) +Generated Location: (1991:52,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2234:61,49 [5] ) +Generated Location: (2242:61,49 [5] ) |Value| Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) @@ -24,7 +24,7 @@ Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) public void Update() { } | -Generated Location: (2647:79,7 [82] ) +Generated Location: (2655:79,7 [82] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs index 23292cba39..e4c3b60d71 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt index 000cad67f5..117445020a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt @@ -5,24 +5,24 @@ Generated Location: (1139:29,30 [11] ) Source Location: (62:0,62 [9] x:\dir\subdir\Test\TestComponent.cshtml) |() => { }| -Generated Location: (1559:39,62 [9] ) +Generated Location: (1567:39,62 [9] ) |() => { }| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1986:52,19 [5] ) +Generated Location: (1994:52,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2237:61,49 [5] ) +Generated Location: (2245:61,49 [5] ) |Value| Source Location: (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2650:79,7 [50] ) +Generated Location: (2658:79,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs index 2ce18051e0..f3ebee2d52 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" (value => { ParentValue = value; return Task.CompletedTask; }) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt index 93db8db95c..7f370b6408 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt @@ -5,24 +5,24 @@ Generated Location: (1139:29,30 [11] ) Source Location: (60:0,60 [62] x:\dir\subdir\Test\TestComponent.cshtml) |(value => { ParentValue = value; return Task.CompletedTask; })| -Generated Location: (1408:38,60 [62] ) +Generated Location: (1416:38,60 [62] ) |(value => { ParentValue = value; return Task.CompletedTask; })| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1884:51,19 [5] ) +Generated Location: (1892:51,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2135:60,49 [5] ) +Generated Location: (2143:60,49 [5] ) |Value| Source Location: (135:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2548:78,7 [50] ) +Generated Location: (2556:78,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs index 745ce872aa..8c3c5acf9d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Func( + __o = new global::System.Func( async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt index 73ef41823c..70e32af6fe 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt @@ -5,17 +5,17 @@ Generated Location: (1139:29,30 [11] ) Source Location: (62:0,62 [6] x:\dir\subdir\Test\TestComponent.cshtml) |Update| -Generated Location: (1599:39,62 [6] ) +Generated Location: (1615:39,62 [6] ) |Update| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2023:52,19 [5] ) +Generated Location: (2039:52,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2274:61,49 [5] ) +Generated Location: (2290:61,49 [5] ) |Value| Source Location: (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) @@ -24,7 +24,7 @@ Source Location: (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) public Task Update() => Task.CompletedTask; | -Generated Location: (2687:79,7 [101] ) +Generated Location: (2703:79,7 [101] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs index eec3fa0033..8215523848 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Func( + __o = new global::System.Func( async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt index 269fe92e48..e841920c43 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt @@ -5,24 +5,24 @@ Generated Location: (1139:29,30 [11] ) Source Location: (62:0,62 [36] x:\dir\subdir\Test\TestComponent.cshtml) |() => { return Task.CompletedTask; }| -Generated Location: (1599:39,62 [36] ) +Generated Location: (1615:39,62 [36] ) |() => { return Task.CompletedTask; }| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2053:52,19 [5] ) +Generated Location: (2069:52,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2304:61,49 [5] ) +Generated Location: (2320:61,49 [5] ) |Value| Source Location: (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2717:79,7 [50] ) +Generated Location: (2733:79,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs index 41fdf22050..5e2ebb8011 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" UpdateValue diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt index 1aeef332ea..66925885b3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt @@ -5,17 +5,17 @@ Generated Location: (1139:29,30 [11] ) Source Location: (60:0,60 [11] x:\dir\subdir\Test\TestComponent.cshtml) |UpdateValue| -Generated Location: (1408:38,60 [11] ) +Generated Location: (1416:38,60 [11] ) |UpdateValue| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1833:51,19 [5] ) +Generated Location: (1841:51,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2084:60,49 [5] ) +Generated Location: (2092:60,49 [5] ) |Value| Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) @@ -24,7 +24,7 @@ Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) public void UpdateValue(int value) => ParentValue = value; | -Generated Location: (2497:78,7 [116] ) +Generated Location: (2505:78,7 [116] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs index a8402349c9..074a23d6e7 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" value => ParentValue = value diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt index cc2db5348e..d6ab56b5e6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt @@ -5,24 +5,24 @@ Generated Location: (1139:29,30 [11] ) Source Location: (60:0,60 [28] x:\dir\subdir\Test\TestComponent.cshtml) |value => ParentValue = value| -Generated Location: (1408:38,60 [28] ) +Generated Location: (1416:38,60 [28] ) |value => ParentValue = value| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1850:51,19 [5] ) +Generated Location: (1858:51,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2101:60,49 [5] ) +Generated Location: (2109:60,49 [5] ) |Value| Source Location: (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2514:78,7 [50] ) +Generated Location: (2522:78,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs index 41fdf22050..5e2ebb8011 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" UpdateValue diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt index 1aeef332ea..66925885b3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt @@ -5,17 +5,17 @@ Generated Location: (1139:29,30 [11] ) Source Location: (60:0,60 [11] x:\dir\subdir\Test\TestComponent.cshtml) |UpdateValue| -Generated Location: (1408:38,60 [11] ) +Generated Location: (1416:38,60 [11] ) |UpdateValue| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1833:51,19 [5] ) +Generated Location: (1841:51,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2084:60,49 [5] ) +Generated Location: (2092:60,49 [5] ) |Value| Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) @@ -24,7 +24,7 @@ Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) public void UpdateValue(int value) => ParentValue = value; | -Generated Location: (2497:78,7 [116] ) +Generated Location: (2505:78,7 [116] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs index cfca370366..aba901656d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Func( + __o = new global::System.Func( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" UpdateValue diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt index b9472a3c42..df63516ed0 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt @@ -5,17 +5,17 @@ Generated Location: (1139:29,30 [11] ) Source Location: (60:0,60 [11] x:\dir\subdir\Test\TestComponent.cshtml) |UpdateValue| -Generated Location: (1435:38,60 [11] ) +Generated Location: (1451:38,60 [11] ) |UpdateValue| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1860:51,19 [5] ) +Generated Location: (1876:51,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2111:60,49 [5] ) +Generated Location: (2127:60,49 [5] ) |Value| Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) @@ -24,7 +24,7 @@ Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } | -Generated Location: (2524:78,7 [144] ) +Generated Location: (2540:78,7 [144] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs index 14e1416d3e..332b6c0f6b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Func( + __o = new global::System.Func( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" value => { ParentValue = value; return Task.CompletedTask; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt index f0d13ffcf5..5d61abde4f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt @@ -5,24 +5,24 @@ Generated Location: (1139:29,30 [11] ) Source Location: (60:0,60 [60] x:\dir\subdir\Test\TestComponent.cshtml) |value => { ParentValue = value; return Task.CompletedTask; }| -Generated Location: (1435:38,60 [60] ) +Generated Location: (1451:38,60 [60] ) |value => { ParentValue = value; return Task.CompletedTask; }| Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1909:51,19 [5] ) +Generated Location: (1925:51,19 [5] ) |Value| Source Location: (49:0,49 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (2160:60,49 [5] ) +Generated Location: (2176:60,49 [5] ) |Value| Source Location: (133:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2573:78,7 [50] ) +Generated Location: (2589:78,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.codegen.cs index 61804569c7..18c64f5282 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.codegen.cs @@ -33,7 +33,7 @@ namespace Test #line hidden #nullable disable ); - __o = new global::System.Action( + __o = new global::System.Action( __value => person.Name = __value); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.mappings.txt index 429713ee70..0701c79b99 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1134:29,24 [11] ) Source Location: (17:0,17 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1664:44,17 [5] ) +Generated Location: (1672:44,17 [5] ) |Value| Source Location: (56:3,1 [37] x:\dir\subdir\Test\TestComponent.cshtml) | Person person = new Person(); | -Generated Location: (2069:62,1 [37] ) +Generated Location: (2077:62,1 [37] ) | Person person = new Person(); | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs index 6ca7cc208e..c75812baa9 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs @@ -47,7 +47,7 @@ namespace Test #line default #line hidden #nullable disable - __o = new global::Microsoft.AspNetCore.Components.RenderFragment( + __o = new global::Microsoft.AspNetCore.Components.RenderFragment( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" header diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt index 35479cd883..9d8376bf37 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt @@ -15,11 +15,11 @@ Generated Location: (1492:44,87 [2] ) Source Location: (113:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) |header| -Generated Location: (1731:52,21 [6] ) +Generated Location: (1739:52,21 [6] ) |header| Source Location: (105:1,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) |Header| -Generated Location: (2145:65,13 [6] ) +Generated Location: (2153:65,13 [6] ) |Header| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs index 2c2ba993c4..32ddc0cb54 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs @@ -47,7 +47,7 @@ namespace Test #line default #line hidden #nullable disable - __o = new global::Microsoft.AspNetCore.Components.RenderFragment( + __o = new global::Microsoft.AspNetCore.Components.RenderFragment( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" header diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt index 4aefa9dfb1..9b29d3d5c7 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt @@ -15,11 +15,11 @@ Generated Location: (1492:44,87 [2] ) Source Location: (113:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) |header| -Generated Location: (1731:52,21 [6] ) +Generated Location: (1739:52,21 [6] ) |header| Source Location: (105:1,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) |Header| -Generated Location: (2302:68,13 [6] ) +Generated Location: (2310:68,13 [6] ) |Header| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs index 0306bc68f6..e070a3569c 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs @@ -24,7 +24,7 @@ namespace Test #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = new global::System.Action( + __o = new global::System.Action( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" Increment diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt index 55d40b8adf..f37d269859 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt @@ -1,11 +1,11 @@ Source Location: (23:0,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) |Increment| -Generated Location: (1072:29,23 [9] ) +Generated Location: (1080:29,23 [9] ) |Increment| Source Location: (13:0,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) |OnClick| -Generated Location: (1489:42,13 [7] ) +Generated Location: (1497:42,13 [7] ) |OnClick| Source Location: (46:2,7 [98] x:\dir\subdir\Test\TestComponent.cshtml) @@ -15,7 +15,7 @@ Source Location: (46:2,7 [98] x:\dir\subdir\Test\TestComponent.cshtml) counter++; } | -Generated Location: (1904:60,7 [98] ) +Generated Location: (1912:60,7 [98] ) | private int counter; private void Increment(EventArgs e) { diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs index 4d2d180e5d..84c02a181f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs @@ -24,7 +24,7 @@ namespace Test #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" __o = context; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt index 20d19f9d44..c8b71a120d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt @@ -1,5 +1,5 @@ Source Location: (28:0,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) |context| -Generated Location: (1172:29,28 [7] ) +Generated Location: (1180:29,28 [7] ) |context| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs index 862bf02ba3..078564652c 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs @@ -25,7 +25,7 @@ namespace Test protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __o = ""; - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" __o = context.ToLowerInvariant(); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt index 80c0b6cf09..a20c4a1227 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt @@ -1,10 +1,10 @@ Source Location: (54:0,54 [26] x:\dir\subdir\Test\TestComponent.cshtml) |context.ToLowerInvariant()| -Generated Location: (1221:30,54 [26] ) +Generated Location: (1229:30,54 [26] ) |context.ToLowerInvariant()| Source Location: (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) |MyAttr| -Generated Location: (1509:41,13 [6] ) +Generated Location: (1517:41,13 [6] ) |MyAttr| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs index dba90ed504..4a9f66ac45 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs @@ -25,7 +25,7 @@ namespace Test protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __o = ""; - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((item) => (__builder2) => { + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((item) => (__builder2) => { #nullable restore #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" __o = item.ToLowerInvariant(); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt index 23b94d39bd..507f9be45a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt @@ -1,10 +1,10 @@ Source Location: (93:2,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) |item.ToLowerInvariant()| -Generated Location: (1196:30,32 [23] ) +Generated Location: (1204:30,32 [23] ) |item.ToLowerInvariant()| Source Location: (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) |MyAttr| -Generated Location: (1481:41,13 [6] ) +Generated Location: (1489:41,13 [6] ) |MyAttr| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs index dba90ed504..4a9f66ac45 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs @@ -25,7 +25,7 @@ namespace Test protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __o = ""; - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((item) => (__builder2) => { + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((item) => (__builder2) => { #nullable restore #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" __o = item.ToLowerInvariant(); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt index 23b94d39bd..507f9be45a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt @@ -1,10 +1,10 @@ Source Location: (93:2,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) |item.ToLowerInvariant()| -Generated Location: (1196:30,32 [23] ) +Generated Location: (1204:30,32 [23] ) |item.ToLowerInvariant()| Source Location: (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) |MyAttr| -Generated Location: (1481:41,13 [6] ) +Generated Location: (1489:41,13 [6] ) |MyAttr| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs index 77d4de4e32..1aecfc18a6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs @@ -24,7 +24,7 @@ namespace Test #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = new global::System.Action( + __o = new global::System.Action( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" e => { Increment(); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt index 69d76657c4..5897aed0e5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt @@ -1,11 +1,11 @@ Source Location: (24:0,24 [21] x:\dir\subdir\Test\TestComponent.cshtml) |e => { Increment(); }| -Generated Location: (1073:29,24 [21] ) +Generated Location: (1081:29,24 [21] ) |e => { Increment(); }| Source Location: (13:0,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) |OnClick| -Generated Location: (1502:42,13 [7] ) +Generated Location: (1510:42,13 [7] ) |OnClick| Source Location: (60:2,7 [87] x:\dir\subdir\Test\TestComponent.cshtml) @@ -15,7 +15,7 @@ Source Location: (60:2,7 [87] x:\dir\subdir\Test\TestComponent.cshtml) counter++; } | -Generated Location: (1917:60,7 [87] ) +Generated Location: (1925:60,7 [87] ) | private int counter; private void Increment() { diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.codegen.cs index f4de066d32..c00a412ae3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.codegen.cs @@ -39,7 +39,7 @@ __o = typeof(global::Test.HeaderComponent); #line default #line hidden #nullable disable - __builder.AddAttribute(-1, "Footer", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { + __builder.AddAttribute(-1, "Footer", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { #nullable restore #line 7 "x:\dir\subdir\Test\TestComponent.cshtml" __o = context; @@ -66,7 +66,7 @@ __o = typeof(global::Test.HeaderComponent); #line default #line hidden #nullable disable - __builder.AddAttribute(-1, "Footer", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { + __builder.AddAttribute(-1, "Footer", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { #nullable restore #line 13 "x:\dir\subdir\Test\TestComponent.cshtml" __o = context; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.mappings.txt index 5f67098fac..1e8ef43ff5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.mappings.txt @@ -5,11 +5,11 @@ Generated Location: (361:12,0 [17] ) Source Location: (119:6,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) |context| -Generated Location: (1578:44,13 [7] ) +Generated Location: (1586:44,13 [7] ) |context| Source Location: (276:12,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) |context| -Generated Location: (2403:71,13 [7] ) +Generated Location: (2419:71,13 [7] ) |context| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.codegen.cs index 7b01bafbaa..a81862f7e6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.codegen.cs @@ -24,7 +24,7 @@ namespace Test #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<(System.Int32 Horizontal, System.Int32 Vertical)>( + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<(global::System.Int32 Horizontal, global::System.Int32 Vertical)>( #nullable restore #line 5 "x:\dir\subdir\Test\TestComponent.cshtml" (32, 16) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.mappings.txt index 21f5c103e9..ee7c896015 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.mappings.txt @@ -1,18 +1,18 @@ Source Location: (113:4,23 [8] x:\dir\subdir\Test\TestComponent.cshtml) |(32, 16)| -Generated Location: (1160:29,23 [8] ) +Generated Location: (1176:29,23 [8] ) |(32, 16)| Source Location: (105:4,15 [6] x:\dir\subdir\Test\TestComponent.cshtml) |Gutter| -Generated Location: (1580:42,15 [6] ) +Generated Location: (1596:42,15 [6] ) |Gutter| Source Location: (7:0,7 [78] x:\dir\subdir\Test\TestComponent.cshtml) | [Parameter] public (int Horizontal, int Vertical) Gutter { get; set; } | -Generated Location: (1996:60,7 [78] ) +Generated Location: (2012:60,7 [78] ) | [Parameter] public (int Horizontal, int Vertical) Gutter { get; set; } | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs index fde39def4b..dfa9acb1c2 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs @@ -44,7 +44,7 @@ namespace Test ); __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message))); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt index d91e91607f..043705cd50 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt @@ -10,19 +10,19 @@ Generated Location: (1451:38,48 [7] ) Source Location: (13:0,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) |Message| -Generated Location: (2496:54,13 [7] ) +Generated Location: (2512:54,13 [7] ) |Message| Source Location: (38:0,38 [7] x:\dir\subdir\Test\TestComponent.cshtml) |Message| -Generated Location: (2738:63,38 [7] ) +Generated Location: (2754:63,38 [7] ) |Message| Source Location: (73:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) | string message = "hi"; | -Generated Location: (3158:81,12 [30] ) +Generated Location: (3174:81,12 [30] ) | string message = "hi"; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs index b5e8ba75d7..83ce025ea6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs @@ -44,7 +44,7 @@ namespace Test ); __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message))); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt index 50654ea80a..3d02765188 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt @@ -10,19 +10,19 @@ Generated Location: (1626:38,59 [7] ) Source Location: (13:0,13 [14] x:\dir\subdir\Test\TestComponent.cshtml) |MessageChanged| -Generated Location: (2671:54,13 [14] ) +Generated Location: (2687:54,13 [14] ) |MessageChanged| Source Location: (49:0,49 [7] x:\dir\subdir\Test\TestComponent.cshtml) |Message| -Generated Location: (2931:63,49 [7] ) +Generated Location: (2947:63,49 [7] ) |Message| Source Location: (84:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) | string message = "hi"; | -Generated Location: (3351:81,12 [30] ) +Generated Location: (3367:81,12 [30] ) | string message = "hi"; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs index 31b29f813e..0970d172be 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs @@ -24,7 +24,7 @@ namespace Test #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>( + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>( #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" (s) => {} @@ -44,7 +44,7 @@ namespace Test ); __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message))); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt index ebf495502c..14dc7e7f95 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt @@ -1,28 +1,28 @@ Source Location: (59:0,59 [9] x:\dir\subdir\Test\TestComponent.cshtml) |(s) => {}| -Generated Location: (1220:29,59 [9] ) +Generated Location: (1236:29,59 [9] ) |(s) => {}| Source Location: (29:0,29 [7] x:\dir\subdir\Test\TestComponent.cshtml) |message| -Generated Location: (1521:38,29 [7] ) +Generated Location: (1537:38,29 [7] ) |message| Source Location: (38:0,38 [17] x:\dir\subdir\Test\TestComponent.cshtml) |MessageExpression| -Generated Location: (2591:54,38 [17] ) +Generated Location: (2623:54,38 [17] ) |MessageExpression| Source Location: (19:0,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) |Message| -Generated Location: (2824:63,19 [7] ) +Generated Location: (2856:63,19 [7] ) |Message| Source Location: (87:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) | string message = "hi"; | -Generated Location: (3244:81,12 [30] ) +Generated Location: (3276:81,12 [30] ) | string message = "hi"; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.codegen.cs new file mode 100644 index 0000000000..87cac7cbb5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.codegen.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + null + +#line default +#line hidden +#nullable disable + ); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); + #pragma warning disable BL0005 + ((global::Test.TestComponent)default). +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + Data + +#line default +#line hidden +#nullable disable + = default; + #pragma warning restore BL0005 +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.TestComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private class System + { + private class String + { + } + } + + [Parameter] + public List Data { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.ir.txt new file mode 100644 index 0000000000..a2e3283c0d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.ir.txt @@ -0,0 +1,23 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - TestComponent + ComponentAttribute - (21:0,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Data - Data - AttributeStructure.DoubleQuotes + LazyIntermediateToken - (21:0,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - null + HtmlContent - (29:0,29 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (29:0,29 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (40:2,7 [172] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (40:2,7 [172] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private class System\n {\n private class String\n {\n }\n }\n\n [Parameter]\n public List Data { get; set; }\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.mappings.txt new file mode 100644 index 0000000000..43f60bdfe9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericTypeCheck/TestComponent.mappings.txt @@ -0,0 +1,35 @@ +Source Location: (21:0,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|null| +Generated Location: (1172:29,21 [4] ) +|null| + +Source Location: (15:0,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|Data| +Generated Location: (1588:42,15 [4] ) +|Data| + +Source Location: (40:2,7 [172] x:\dir\subdir\Test\TestComponent.cshtml) +| + private class System + { + private class String + { + } + } + + [Parameter] + public List Data { get; set; } +| +Generated Location: (2002:60,7 [172] ) +| + private class System + { + private class String + { + } + } + + [Parameter] + public List Data { get; set; } +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs index 204c0b85da..ff5688f424 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs @@ -54,7 +54,7 @@ namespace Test #line default #line hidden #nullable disable - __o = new global::Microsoft.AspNetCore.Components.RenderFragment( + __o = new global::Microsoft.AspNetCore.Components.RenderFragment( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" template diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt index 7fc1225c64..394dea96db 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt @@ -20,11 +20,11 @@ Generated Location: (1740:51,107 [2] ) Source Location: (136:1,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) |template| -Generated Location: (1981:59,24 [8] ) +Generated Location: (1989:59,24 [8] ) |template| Source Location: (125:1,13 [8] x:\dir\subdir\Test\TestComponent.cshtml) |Template| -Generated Location: (2397:72,13 [8] ) +Generated Location: (2405:72,13 [8] ) |Template| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs index 3cc96f544b..c1b4786f9b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs @@ -47,7 +47,7 @@ namespace Test #line default #line hidden #nullable disable - __o = new global::Microsoft.AspNetCore.Components.RenderFragment( + __o = new global::Microsoft.AspNetCore.Components.RenderFragment( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" template diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt index 8b670765ac..ddf3533e92 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt @@ -15,11 +15,11 @@ Generated Location: (1465:44,73 [2] ) Source Location: (108:1,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) |template| -Generated Location: (1711:52,30 [8] ) +Generated Location: (1719:52,30 [8] ) |template| Source Location: (91:1,13 [14] x:\dir\subdir\Test\TestComponent.cshtml) |PersonTemplate| -Generated Location: (2127:65,13 [14] ) +Generated Location: (2135:65,13 [14] ) |PersonTemplate| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.codegen.cs index abd3ceb063..b46ee79b0f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.codegen.cs @@ -36,7 +36,7 @@ ParentValue #nullable disable )); __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue)))); - __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.ValueExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); + __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.ValueExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.mappings.txt index 6a68a34f37..f02bfe1b54 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (2174:44,0 [50] ) +Generated Location: (2190:44,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs index 6c85c6edbb..d901af0959 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.OnChanged), (global::System.Action)(__value => ParentValue = __value)); + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.OnChanged), (global::System.Action)(__value => ParentValue = __value)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt index 7f3dc1ced2..43bc075186 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1560:43,0 [50] ) +Generated Location: (1568:43,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.codegen.cs index 3167bd4ea2..2e70a69ed5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.codegen.cs @@ -35,8 +35,8 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); - __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.ValueExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); + __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.ValueExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.mappings.txt index 01f8dac402..e8d4440ec8 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndExpression/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1835:44,0 [50] ) +Generated Location: (1859:44,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs index e36578b746..3f10ecd4ea 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt index d192ffede1..3a94fce999 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1563:43,0 [50] ) +Generated Location: (1571:43,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.codegen.cs index df3153b6ea..bdf2d36514 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.dynamic.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); + __builder.AddComponentParameter(2, nameof(global::Test.dynamic.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.mappings.txt index dbef272501..0d5fcc2cce 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_DynamicComponentName/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (46:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1551:43,0 [50] ) +Generated Location: (1559:43,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.codegen.cs index 983865f9dd..94bebec1e5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.@int.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); + __builder.AddComponentParameter(2, nameof(global::Test.@int.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.mappings.txt index 776acdd1ae..ff86df204f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_EscapedComponentName/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (42:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1542:43,0 [50] ) +Generated Location: (1550:43,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.codegen.cs index d8baebfd6d..aa9e240946 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); + __builder.AddComponentParameter(2, nameof(global::MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.mappings.txt index 1e7397b4f7..b2dabfd1ac 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_GlobalNamespaceComponent/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1548:43,0 [50] ) +Generated Location: (1556:43,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.codegen.cs index 2748c8c3cf..de4d84d649 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.mappings.txt index 022089c502..7daa1a95a5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties_WithNameof/TestComponent.mappings.txt @@ -14,7 +14,7 @@ Source Location: (50:1,7 [105] x:\dir\subdir\Test\TestComponent.cshtml) public string nameof(string s) => string.Empty; | -Generated Location: (1563:43,0 [105] ) +Generated Location: (1571:43,0 [105] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs index cade82dcb2..ceb8519409 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)(__value => ParentValue = __value)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt index 01a2b30dde..6391db2862 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (50:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) | public string ParentValue { get; set; } = "42"; | -Generated Location: (1563:43,0 [55] ) +Generated Location: (1571:43,0 [55] ) | public string ParentValue { get; set; } = "42"; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs index e7f7c74e2f..1f8135dd3d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate( #nullable restore #line (1,63)-(1,69) "x:\dir\subdir\Test\TestComponent.cshtml" Update diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt index 52094507c1..810b5101f3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt @@ -10,7 +10,7 @@ Generated Location: (1144:31,0 [11] ) Source Location: (62:0,62 [6] x:\dir\subdir\Test\TestComponent.cshtml) |Update| -Generated Location: (1575:40,0 [6] ) +Generated Location: (1583:40,0 [6] ) |Update| Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) @@ -19,7 +19,7 @@ Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) public void Update() { } | -Generated Location: (1824:51,0 [82] ) +Generated Location: (1832:51,0 [82] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs index 5f96b9aa07..f386b9d274 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate( #nullable restore #line (1,63)-(1,72) "x:\dir\subdir\Test\TestComponent.cshtml" () => { } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt index 7f2679c616..8240e57028 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt @@ -10,14 +10,14 @@ Generated Location: (1144:31,0 [11] ) Source Location: (62:0,62 [9] x:\dir\subdir\Test\TestComponent.cshtml) |() => { }| -Generated Location: (1575:40,0 [9] ) +Generated Location: (1583:40,0 [9] ) |() => { }| Source Location: (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1827:51,0 [50] ) +Generated Location: (1835:51,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs index a673f7ff34..1bf6800bda 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( #nullable restore #line (1,61)-(1,123) "x:\dir\subdir\Test\TestComponent.cshtml" (value => { ParentValue = value; return Task.CompletedTask; }) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt index f8a444575c..586a029c53 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt @@ -10,14 +10,14 @@ Generated Location: (1144:31,0 [11] ) Source Location: (60:0,60 [62] x:\dir\subdir\Test\TestComponent.cshtml) |(value => { ParentValue = value; return Task.CompletedTask; })| -Generated Location: (1441:40,0 [62] ) +Generated Location: (1449:40,0 [62] ) |(value => { ParentValue = value; return Task.CompletedTask; })| Source Location: (135:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1742:51,0 [50] ) +Generated Location: (1750:51,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs index f3e042efa3..bb422b7686 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate( #nullable restore #line (1,63)-(1,69) "x:\dir\subdir\Test\TestComponent.cshtml" Update diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt index 196efd4fa8..4b6ab91b9d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt @@ -10,7 +10,7 @@ Generated Location: (1144:31,0 [11] ) Source Location: (62:0,62 [6] x:\dir\subdir\Test\TestComponent.cshtml) |Update| -Generated Location: (1615:40,0 [6] ) +Generated Location: (1631:40,0 [6] ) |Update| Source Location: (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) @@ -19,7 +19,7 @@ Source Location: (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) public Task Update() => Task.CompletedTask; | -Generated Location: (1864:51,0 [101] ) +Generated Location: (1880:51,0 [101] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs index 49e65646f4..c925f792b5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate( #nullable restore #line (1,63)-(1,99) "x:\dir\subdir\Test\TestComponent.cshtml" () => { return Task.CompletedTask; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt index 7a0348f8e2..24f207033e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt @@ -10,14 +10,14 @@ Generated Location: (1144:31,0 [11] ) Source Location: (62:0,62 [36] x:\dir\subdir\Test\TestComponent.cshtml) |() => { return Task.CompletedTask; }| -Generated Location: (1615:40,0 [36] ) +Generated Location: (1631:40,0 [36] ) |() => { return Task.CompletedTask; }| Source Location: (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1894:51,0 [50] ) +Generated Location: (1910:51,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs index bfb36b475d..6e26b464c7 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( #nullable restore #line (1,61)-(1,72) "x:\dir\subdir\Test\TestComponent.cshtml" UpdateValue diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt index 94d87a1d84..a04298cae6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt @@ -10,7 +10,7 @@ Generated Location: (1144:31,0 [11] ) Source Location: (60:0,60 [11] x:\dir\subdir\Test\TestComponent.cshtml) |UpdateValue| -Generated Location: (1440:40,0 [11] ) +Generated Location: (1448:40,0 [11] ) |UpdateValue| Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) @@ -19,7 +19,7 @@ Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) public void UpdateValue(int value) => ParentValue = value; | -Generated Location: (1690:51,0 [116] ) +Generated Location: (1698:51,0 [116] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs index 21f622ba37..96ff2c3df0 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Action)( #nullable restore #line (1,61)-(1,89) "x:\dir\subdir\Test\TestComponent.cshtml" value => ParentValue = value diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt index dfbb63429b..4240393425 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt @@ -10,14 +10,14 @@ Generated Location: (1144:31,0 [11] ) Source Location: (60:0,60 [28] x:\dir\subdir\Test\TestComponent.cshtml) |value => ParentValue = value| -Generated Location: (1440:40,0 [28] ) +Generated Location: (1448:40,0 [28] ) |value => ParentValue = value| Source Location: (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1707:51,0 [50] ) +Generated Location: (1715:51,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs index 361d55a95a..0edba25ee8 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable ))); - __builder.AddAttribute(2, nameof(global::Test.MyComponent.ValueChanged), (object)((global::System.Action)( + __builder.AddAttribute(2, nameof(global::Test.MyComponent.ValueChanged), (object)((global::System.Action)( #nullable restore #line (1,61)-(1,72) "x:\dir\subdir\Test\TestComponent.cshtml" UpdateValue diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt index 0e4155e028..cf93f16845 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt @@ -10,7 +10,7 @@ Generated Location: (1144:31,0 [11] ) Source Location: (60:0,60 [11] x:\dir\subdir\Test\TestComponent.cshtml) |UpdateValue| -Generated Location: (1441:40,0 [11] ) +Generated Location: (1449:40,0 [11] ) |UpdateValue| Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) @@ -19,7 +19,7 @@ Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) public void UpdateValue(int value) => ParentValue = value; | -Generated Location: (1692:51,0 [116] ) +Generated Location: (1700:51,0 [116] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs index a43e5220dc..3d8becd851 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Func)( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Func)( #nullable restore #line (1,61)-(1,72) "x:\dir\subdir\Test\TestComponent.cshtml" UpdateValue diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt index e2045b99fd..1d2d804a1b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt @@ -10,7 +10,7 @@ Generated Location: (1144:31,0 [11] ) Source Location: (60:0,60 [11] x:\dir\subdir\Test\TestComponent.cshtml) |UpdateValue| -Generated Location: (1467:40,0 [11] ) +Generated Location: (1483:40,0 [11] ) |UpdateValue| Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) @@ -19,7 +19,7 @@ Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } | -Generated Location: (1717:51,0 [144] ) +Generated Location: (1733:51,0 [144] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs index 358e53a3b9..47034cd437 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs @@ -35,7 +35,7 @@ ParentValue #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Func)( + __builder.AddComponentParameter(2, nameof(global::Test.MyComponent.ValueChanged), (global::System.Func)( #nullable restore #line (1,61)-(1,121) "x:\dir\subdir\Test\TestComponent.cshtml" value => { ParentValue = value; return Task.CompletedTask; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt index 70a99a8556..15ba3e4b8a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt @@ -10,14 +10,14 @@ Generated Location: (1144:31,0 [11] ) Source Location: (60:0,60 [60] x:\dir\subdir\Test\TestComponent.cshtml) |value => { ParentValue = value; return Task.CompletedTask; }| -Generated Location: (1468:40,0 [60] ) +Generated Location: (1484:40,0 [60] ) |value => { ParentValue = value; return Task.CompletedTask; }| Source Location: (133:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1767:51,0 [50] ) +Generated Location: (1783:51,0 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.codegen.cs index c72983ec8e..9d8396d523 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.codegen.cs @@ -35,7 +35,7 @@ person.Name #line hidden #nullable disable )); - __builder.AddComponentParameter(2, nameof(global::Test.InputText.ValueChanged), (global::System.Action)(__value => person.Name = __value)); + __builder.AddComponentParameter(2, nameof(global::Test.InputText.ValueChanged), (global::System.Action)(__value => person.Name = __value)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.mappings.txt index 3db547b9f8..2481581777 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithStringAttribute_DoesNotUseStringSyntax/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (56:3,1 [37] x:\dir\subdir\Test\TestComponent.cshtml) | Person person = new Person(); | -Generated Location: (1559:43,0 [37] ) +Generated Location: (1567:43,0 [37] ) | Person person = new Person(); | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs index d79cfac041..41c7649750 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs @@ -55,7 +55,7 @@ Header #line default #line hidden #nullable disable - ), (global::Microsoft.AspNetCore.Components.RenderFragment)( + ), (global::Microsoft.AspNetCore.Components.RenderFragment)( #nullable restore #line (2,22)-(2,28) "x:\dir\subdir\Test\TestComponent.cshtml" header diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt index 21b82df25e..6f6fcfe1b8 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt @@ -20,6 +20,6 @@ Generated Location: (1567:52,0 [6] ) Source Location: (113:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) |header| -Generated Location: (1796:60,0 [6] ) +Generated Location: (1804:60,0 [6] ) |header| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs index 2a4aab4d08..ccb3b82a12 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs @@ -55,7 +55,7 @@ Header #line default #line hidden #nullable disable - ), (global::Microsoft.AspNetCore.Components.RenderFragment)( + ), (global::Microsoft.AspNetCore.Components.RenderFragment)( #nullable restore #line (2,22)-(2,28) "x:\dir\subdir\Test\TestComponent.cshtml" header diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt index 21b82df25e..6f6fcfe1b8 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt @@ -20,6 +20,6 @@ Generated Location: (1567:52,0 [6] ) Source Location: (113:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) |header| -Generated Location: (1796:60,0 [6] ) +Generated Location: (1804:60,0 [6] ) |header| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs index 7d5ef13cd7..dde5917e7e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs @@ -26,7 +26,7 @@ OnClick #line default #line hidden #nullable disable - ), (global::System.Action)( + ), (global::System.Action)( #nullable restore #line (1,24)-(1,33) "x:\dir\subdir\Test\TestComponent.cshtml" Increment diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt index 0cf47482c5..94c96b14b1 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt @@ -5,7 +5,7 @@ Generated Location: (884:23,0 [7] ) Source Location: (23:0,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) |Increment| -Generated Location: (1084:31,0 [9] ) +Generated Location: (1092:31,0 [9] ) |Increment| Source Location: (46:2,7 [98] x:\dir\subdir\Test\TestComponent.cshtml) @@ -15,7 +15,7 @@ Source Location: (46:2,7 [98] x:\dir\subdir\Test\TestComponent.cshtml) counter++; } | -Generated Location: (1332:42,0 [98] ) +Generated Location: (1340:42,0 [98] ) | private int counter; private void Increment(EventArgs e) { diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs index b36feb64fc..eb8ecdc2c3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs @@ -18,7 +18,7 @@ namespace Test protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenComponent(0); - __builder.AddAttribute(1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { + __builder.AddAttribute(1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { __builder2.AddContent(2, #nullable restore #line (1,29)-(1,36) "x:\dir\subdir\Test\TestComponent.cshtml" diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt index ef18bd9518..4324daa4ef 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt @@ -1,5 +1,5 @@ Source Location: (28:0,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) |context| -Generated Location: (1004:24,0 [7] ) +Generated Location: (1012:24,0 [7] ) |context| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs index e5f348b840..9d7566ec43 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs @@ -27,7 +27,7 @@ MyAttr #line hidden #nullable disable ), "abc"); - __builder.AddAttribute(2, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { + __builder.AddAttribute(2, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { __builder2.AddContent(3, "Some text"); __builder2.OpenElement(4, "some-child"); __builder2.AddAttribute(5, "a", "1"); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt index 50912aabae..37d668a476 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt @@ -5,6 +5,6 @@ Generated Location: (884:23,0 [6] ) Source Location: (54:0,54 [26] x:\dir\subdir\Test\TestComponent.cshtml) |context.ToLowerInvariant()| -Generated Location: (1418:36,0 [26] ) +Generated Location: (1426:36,0 [26] ) |context.ToLowerInvariant()| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs index 44ea67ef97..32b57b0257 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs @@ -27,7 +27,7 @@ MyAttr #line hidden #nullable disable ), "abc"); - __builder.AddAttribute(2, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((item) => (__builder2) => { + __builder.AddAttribute(2, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((item) => (__builder2) => { __builder2.AddMarkupContent(3, "\r\n Some text"); __builder2.OpenElement(4, "some-child"); __builder2.AddAttribute(5, "a", "1"); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt index 776d0225c1..7a4d7657a6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt @@ -5,6 +5,6 @@ Generated Location: (884:23,0 [6] ) Source Location: (93:2,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) |item.ToLowerInvariant()| -Generated Location: (1429:36,0 [23] ) +Generated Location: (1437:36,0 [23] ) |item.ToLowerInvariant()| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs index 44ea67ef97..32b57b0257 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs @@ -27,7 +27,7 @@ MyAttr #line hidden #nullable disable ), "abc"); - __builder.AddAttribute(2, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((item) => (__builder2) => { + __builder.AddAttribute(2, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((item) => (__builder2) => { __builder2.AddMarkupContent(3, "\r\n Some text"); __builder2.OpenElement(4, "some-child"); __builder2.AddAttribute(5, "a", "1"); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt index 776d0225c1..7a4d7657a6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt @@ -5,6 +5,6 @@ Generated Location: (884:23,0 [6] ) Source Location: (93:2,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) |item.ToLowerInvariant()| -Generated Location: (1429:36,0 [23] ) +Generated Location: (1437:36,0 [23] ) |item.ToLowerInvariant()| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs index 4877f647dd..9d3de93549 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs @@ -26,7 +26,7 @@ OnClick #line default #line hidden #nullable disable - ), (global::System.Action)( + ), (global::System.Action)( #nullable restore #line (1,25)-(1,46) "x:\dir\subdir\Test\TestComponent.cshtml" e => { Increment(); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt index e26ef4a863..9e81c5f14d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt @@ -5,7 +5,7 @@ Generated Location: (884:23,0 [7] ) Source Location: (24:0,24 [21] x:\dir\subdir\Test\TestComponent.cshtml) |e => { Increment(); }| -Generated Location: (1084:31,0 [21] ) +Generated Location: (1092:31,0 [21] ) |e => { Increment(); }| Source Location: (60:2,7 [87] x:\dir\subdir\Test\TestComponent.cshtml) @@ -15,7 +15,7 @@ Source Location: (60:2,7 [87] x:\dir\subdir\Test\TestComponent.cshtml) counter++; } | -Generated Location: (1344:42,0 [87] ) +Generated Location: (1352:42,0 [87] ) | private int counter; private void Increment() { diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.codegen.cs index f38948c997..0fa8152e78 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.codegen.cs @@ -31,7 +31,7 @@ using AnotherTest __builder.CloseComponent(); __builder.AddMarkupContent(3, "\r\n"); __builder.OpenComponent(4); - __builder.AddAttribute(5, "Footer", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { + __builder.AddAttribute(5, "Footer", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { __builder2.AddContent(6, #nullable restore #line (7,14)-(7,21) "x:\dir\subdir\Test\TestComponent.cshtml" @@ -53,7 +53,7 @@ context __builder.CloseComponent(); __builder.AddMarkupContent(11, "\r\n"); __builder.OpenComponent(12); - __builder.AddAttribute(13, "Footer", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { + __builder.AddAttribute(13, "Footer", (global::Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { __builder2.AddContent(14, #nullable restore #line (13,14)-(13,21) "x:\dir\subdir\Test\TestComponent.cshtml" diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.mappings.txt index 731c331464..9ce8d189e2 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildContent_FromAnotherNamespace/TestComponent.mappings.txt @@ -7,11 +7,11 @@ Generated Location: (371:12,0 [19] ) Source Location: (119:6,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) |context| -Generated Location: (1500:37,0 [7] ) +Generated Location: (1508:37,0 [7] ) |context| Source Location: (276:12,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) |context| -Generated Location: (2438:59,0 [7] ) +Generated Location: (2454:59,0 [7] ) |context| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.codegen.cs index 49c1f8db49..6eaef762d1 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.codegen.cs @@ -26,7 +26,7 @@ Gutter #line default #line hidden #nullable disable - ), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<(System.Int32 Horizontal, System.Int32 Vertical)>( + ), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<(global::System.Int32 Horizontal, global::System.Int32 Vertical)>( #nullable restore #line (5,24)-(5,32) "x:\dir\subdir\Test\TestComponent.cshtml" (32, 16) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.mappings.txt index b75023acb7..e1507a1b33 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTupleParameter/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (888:23,0 [6] ) Source Location: (113:4,23 [8] x:\dir\subdir\Test\TestComponent.cshtml) |(32, 16)| -Generated Location: (1177:31,0 [8] ) +Generated Location: (1193:31,0 [8] ) |(32, 16)| Source Location: (7:0,7 [78] x:\dir\subdir\Test\TestComponent.cshtml) | [Parameter] public (int Horizontal, int Vertical) Gutter { get; set; } | -Generated Location: (1424:42,0 [78] ) +Generated Location: (1440:42,0 [78] ) | [Parameter] public (int Horizontal, int Vertical) Gutter { get; set; } | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs index 912e12b452..d92a7cd12b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs @@ -53,7 +53,7 @@ message #nullable disable )); __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.MessageChanged), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message)))); - __builder.AddComponentParameter(4, nameof(global::Test.MyComponent.MessageExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message)); + __builder.AddComponentParameter(4, nameof(global::Test.MyComponent.MessageExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt index 0b6febc8b8..d1ca801dd4 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt @@ -22,7 +22,7 @@ Source Location: (73:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) | string message = "hi"; | -Generated Location: (2673:61,0 [30] ) +Generated Location: (2689:61,0 [30] ) | string message = "hi"; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs index 66d476bcf1..2b1d46948b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs @@ -53,7 +53,7 @@ message #nullable disable )); __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.MessageChanged), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message)))); - __builder.AddComponentParameter(4, nameof(global::Test.MyComponent.MessageExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message)); + __builder.AddComponentParameter(4, nameof(global::Test.MyComponent.MessageExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt index 924aed3be4..3fb5998d48 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt @@ -22,7 +22,7 @@ Source Location: (84:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) | string message = "hi"; | -Generated Location: (2836:61,0 [30] ) +Generated Location: (2852:61,0 [30] ) | string message = "hi"; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs index 2e4a9d5031..de3f01d6ce 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs @@ -26,7 +26,7 @@ MessageExpression #line default #line hidden #nullable disable - ), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>( + ), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>( #nullable restore #line (1,60)-(1,69) "x:\dir\subdir\Test\TestComponent.cshtml" (s) => {} @@ -53,7 +53,7 @@ message #nullable disable )); __builder.AddComponentParameter(3, nameof(global::Test.MyComponent.MessageChanged), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message)))); - __builder.AddComponentParameter(4, nameof(global::Test.MyComponent.MessageExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message)); + __builder.AddComponentParameter(4, nameof(global::Test.MyComponent.MessageExpression), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => message)); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt index 16fac7b9e8..5587b5952a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt @@ -5,24 +5,24 @@ Generated Location: (884:23,0 [17] ) Source Location: (59:0,59 [9] x:\dir\subdir\Test\TestComponent.cshtml) |(s) => {}| -Generated Location: (1208:31,0 [9] ) +Generated Location: (1224:31,0 [9] ) |(s) => {}| Source Location: (19:0,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) |Message| -Generated Location: (1449:40,0 [7] ) +Generated Location: (1465:40,0 [7] ) |Message| Source Location: (29:0,29 [7] x:\dir\subdir\Test\TestComponent.cshtml) |message| -Generated Location: (1712:48,0 [7] ) +Generated Location: (1728:48,0 [7] ) |message| Source Location: (87:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) | string message = "hi"; | -Generated Location: (2736:61,0 [30] ) +Generated Location: (2768:61,0 [30] ) | string message = "hi"; | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.codegen.cs new file mode 100644 index 0000000000..bb2b60e992 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.codegen.cs @@ -0,0 +1,60 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddComponentParameter(1, nameof(global::Test.TestComponent. +#nullable restore +#line (1,16)-(1,20) "x:\dir\subdir\Test\TestComponent.cshtml" +Data + +#line default +#line hidden +#nullable disable + ), global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>( +#nullable restore +#line (1,22)-(1,26) "x:\dir\subdir\Test\TestComponent.cshtml" +null + +#line default +#line hidden +#nullable disable + )); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line (3,8)-(13,1) "x:\dir\subdir\Test\TestComponent.cshtml" + + private class System + { + private class String + { + } + } + + [Parameter] + public List Data { get; set; } + +#line default +#line hidden +#nullable disable + + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.ir.txt new file mode 100644 index 0000000000..e3d0d35fdb --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.ir.txt @@ -0,0 +1,14 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [22] ) - global::System + UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [27] ) - global::System.Linq + UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - TestComponent + ComponentAttribute - (21:0,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Data - Data - AttributeStructure.DoubleQuotes + LazyIntermediateToken - (21:0,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - null + CSharpCode - (40:2,7 [172] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (40:2,7 [172] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private class System\n {\n private class String\n {\n }\n }\n\n [Parameter]\n public List Data { get; set; }\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.mappings.txt new file mode 100644 index 0000000000..419d824f7e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericTypeCheck/TestComponent.mappings.txt @@ -0,0 +1,35 @@ +Source Location: (15:0,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|Data| +Generated Location: (888:23,0 [4] ) +|Data| + +Source Location: (21:0,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|null| +Generated Location: (1189:31,0 [4] ) +|null| + +Source Location: (40:2,7 [172] x:\dir\subdir\Test\TestComponent.cshtml) +| + private class System + { + private class String + { + } + } + + [Parameter] + public List Data { get; set; } +| +Generated Location: (1433:42,0 [172] ) +| + private class System + { + private class String + { + } + } + + [Parameter] + public List Data { get; set; } +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs index 379a952c6b..3cb6fe273d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs @@ -66,7 +66,7 @@ Template #line default #line hidden #nullable disable - ), (global::Microsoft.AspNetCore.Components.RenderFragment)( + ), (global::Microsoft.AspNetCore.Components.RenderFragment)( #nullable restore #line (2,25)-(2,33) "x:\dir\subdir\Test\TestComponent.cshtml" template diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt index 90e2fb3112..fd9f1d737d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt @@ -25,6 +25,6 @@ Generated Location: (1881:63,0 [8] ) Source Location: (136:1,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) |template| -Generated Location: (2111:71,0 [8] ) +Generated Location: (2119:71,0 [8] ) |template| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs index 22754f7622..83487236b4 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs @@ -55,7 +55,7 @@ PersonTemplate #line default #line hidden #nullable disable - ), (global::Microsoft.AspNetCore.Components.RenderFragment)( + ), (global::Microsoft.AspNetCore.Components.RenderFragment)( #nullable restore #line (2,31)-(2,39) "x:\dir\subdir\Test\TestComponent.cshtml" template diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt index 6c66253d0b..91318bfbc4 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt @@ -20,6 +20,6 @@ Generated Location: (1553:52,0 [14] ) Source Location: (108:1,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) |template| -Generated Location: (1788:60,0 [8] ) +Generated Location: (1796:60,0 [8] ) |template| diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentDesignTimeNodeWriter.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentDesignTimeNodeWriter.cs index 8702653d9a..e5a7c050f4 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentDesignTimeNodeWriter.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentDesignTimeNodeWriter.cs @@ -801,7 +801,7 @@ internal class ComponentDesignTimeNodeWriter : ComponentNodeWriter if (canTypeCheck) { context.CodeWriter.Write("new "); - TypeNameHelper.WriteGloballyQualifiedName(context.CodeWriter, node.TypeName); + WriteGloballyQualifiedTypeName(context, node); context.CodeWriter.Write("("); } context.CodeWriter.WriteLine(); @@ -883,15 +883,7 @@ internal class ComponentDesignTimeNodeWriter : ComponentNodeWriter { context.CodeWriter.Write(ComponentsApi.RuntimeHelpers.TypeCheck); context.CodeWriter.Write("<"); - var explicitType = (bool?)node.Annotations[ComponentMetadata.Component.ExplicitTypeNameKey]; - if (explicitType == true) - { - context.CodeWriter.Write(node.TypeName); - } - else - { - TypeNameHelper.WriteGloballyQualifiedName(context.CodeWriter, node.TypeName); - } + WriteGloballyQualifiedTypeName(context, node); context.CodeWriter.Write(">"); context.CodeWriter.Write("("); } @@ -964,7 +956,7 @@ internal class ComponentDesignTimeNodeWriter : ComponentNodeWriter BeginWriteAttribute(context, node.AttributeName); context.CodeWriter.WriteParameterSeparator(); context.CodeWriter.Write("("); - TypeNameHelper.WriteGloballyQualifiedName(context.CodeWriter, node.TypeName); + WriteGloballyQualifiedTypeName(context, node); context.CodeWriter.Write(")("); WriteComponentChildContentInnards(context, node); diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentNodeWriter.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentNodeWriter.cs index 9e924a6b38..79b270262f 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentNodeWriter.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentNodeWriter.cs @@ -483,6 +483,36 @@ internal abstract class ComponentNodeWriter : IntermediateNodeWriter, ITemplateT context.CodeWriter.WriteLine(); } + protected static void WriteGloballyQualifiedTypeName(CodeRenderingContext context, ComponentAttributeIntermediateNode node) + { + var explicitType = (bool?)node.Annotations[ComponentMetadata.Component.ExplicitTypeNameKey]; + if (explicitType == true) + { + context.CodeWriter.Write(node.TypeName); + } + else if (node.BoundAttribute?.GetGloballyQualifiedTypeName() is string typeName) + { + context.CodeWriter.Write(typeName); + } + else + { + TypeNameHelper.WriteGloballyQualifiedName(context.CodeWriter, node.TypeName); + } + } + + protected static void WriteGloballyQualifiedTypeName(CodeRenderingContext context, ComponentChildContentIntermediateNode node) + { + if (node.BoundAttribute?.GetGloballyQualifiedTypeName() is string typeName && + !node.BoundAttribute.IsGenericTypedProperty()) + { + context.CodeWriter.Write(typeName); + } + else + { + TypeNameHelper.WriteGloballyQualifiedName(context.CodeWriter, node.TypeName); + } + } + protected class TypeInferenceMethodParameter { public string SeqName { get; private set; } diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRuntimeNodeWriter.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRuntimeNodeWriter.cs index bd0b77cab0..8cb57354a5 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRuntimeNodeWriter.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentRuntimeNodeWriter.cs @@ -654,7 +654,7 @@ internal class ComponentRuntimeNodeWriter : ComponentNodeWriter if (canTypeCheck) { context.CodeWriter.Write("("); - TypeNameHelper.WriteGloballyQualifiedName(context.CodeWriter, node.TypeName); + WriteGloballyQualifiedTypeName(context, node); context.CodeWriter.Write(")"); context.CodeWriter.Write("("); } @@ -726,15 +726,7 @@ internal class ComponentRuntimeNodeWriter : ComponentNodeWriter { context.CodeWriter.Write(ComponentsApi.RuntimeHelpers.TypeCheck); context.CodeWriter.Write("<"); - var explicitType = (bool?)node.Annotations[ComponentMetadata.Component.ExplicitTypeNameKey]; - if (explicitType == true) - { - context.CodeWriter.Write(node.TypeName); - } - else - { - TypeNameHelper.WriteGloballyQualifiedName(context.CodeWriter, node.TypeName); - } + WriteGloballyQualifiedTypeName(context, node); context.CodeWriter.Write(">"); context.CodeWriter.Write("("); } @@ -813,7 +805,7 @@ internal class ComponentRuntimeNodeWriter : ComponentNodeWriter BeginWriteAttribute(context, node.AttributeName); context.CodeWriter.WriteParameterSeparator(); context.CodeWriter.Write("("); - TypeNameHelper.WriteGloballyQualifiedName(context.CodeWriter, node.TypeName); + WriteGloballyQualifiedTypeName(context, node); context.CodeWriter.Write(")("); WriteComponentChildContentInnards(context, node); From fdda4bbae9261f96d1eb15cca92566c7bf5792c4 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Thu, 5 Sep 2024 15:42:30 -0700 Subject: [PATCH 16/19] CodeQL suppressions (#10845) --- .../src/Language/CodeGeneration/DefaultDocumentWriter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/DefaultDocumentWriter.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/DefaultDocumentWriter.cs index 550e32ca7e..afc161e7cc 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/DefaultDocumentWriter.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration/DefaultDocumentWriter.cs @@ -71,6 +71,7 @@ internal class DefaultDocumentWriter(CodeTarget codeTarget, RazorCodeGenerationO } else { + // CodeQL [SM02196] This is supported by the underlying Roslyn APIs and as consumers we must also support it. string?[] supportedAlgorithms = [HashAlgorithmName.SHA1.Name, HashAlgorithmName.SHA256.Name]; var message = Resources.FormatUnsupportedChecksumAlgorithm( From 6e121618bb0645e2f0598278bd35c1b3e30434b9 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 6 Sep 2024 11:51:26 +1000 Subject: [PATCH 17/19] Bump to real Roslyn version --- eng/Version.Details.xml | 76 ++++++++++++++++++++--------------------- eng/Versions.props | 38 ++++++++++----------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 613a373266..3c4f6ac850 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -11,82 +11,82 @@ 9ae78a4e6412926d19ba97cfed159bf9de70b538 - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb - + https://github.com/dotnet/roslyn - 0ec44d9775c80a6861b811d8af637ee36e3315e1 + 9f86520c46f67d2a8a59af189f8fd87e35c574bb diff --git a/eng/Versions.props b/eng/Versions.props index c468083330..c5cbdff6fd 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -53,25 +53,25 @@ 9.0.0-beta.24426.3 1.0.0-beta.23475.1 1.0.0-beta.23475.1 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 - 4.12.0-2.24419.3 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5 + 4.12.0-3.24454.5