diff --git a/src/Razor/Directory.Build.props b/src/Razor/Directory.Build.props index 8260b6f326..220748df5f 100644 --- a/src/Razor/Directory.Build.props +++ b/src/Razor/Directory.Build.props @@ -14,9 +14,8 @@ $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true - true true - Microsoft + 7.3 diff --git a/src/Razor/Directory.Build.targets b/src/Razor/Directory.Build.targets index 53b3f6e1da..78626b773e 100644 --- a/src/Razor/Directory.Build.targets +++ b/src/Razor/Directory.Build.targets @@ -1,7 +1,10 @@ - + $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(MicrosoftNETCoreApp22PackageVersion) $(NETStandardLibrary20PackageVersion) + + 99.9 diff --git a/src/Razor/NuGetPackageVerifier.json b/src/Razor/NuGetPackageVerifier.json index aeabac8d86..b62352e8b9 100644 --- a/src/Razor/NuGetPackageVerifier.json +++ b/src/Razor/NuGetPackageVerifier.json @@ -6,6 +6,7 @@ "packages": { "Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources": {}, "RazorPageGenerator": {}, + "Microsoft.CodeAnalysis.Razor.Workspaces": {}, "Microsoft.CodeAnalysis.Remote.Razor": {}, "Microsoft.VisualStudio.Editor.Razor": {}, "Microsoft.VisualStudio.LanguageServices.Razor": {}, diff --git a/src/Razor/Razor.sln b/src/Razor/Razor.sln index 6ec8cff6c0..5bb3137be2 100644 --- a/src/Razor/Razor.sln +++ b/src/Razor/Razor.sln @@ -81,8 +81,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Design.Test", "test\Microsoft.AspNetCore.Razor.Design.Test\Microsoft.AspNetCore.Razor.Design.Test.csproj", "{1D90F276-E1CA-4FDF-A173-EB889E7D3150}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Tasks", "src\Microsoft.AspNetCore.Razor.Tasks\Microsoft.AspNetCore.Razor.Tasks.csproj", "{043B9497-C0BA-4770-9210-4456D2F81CE0}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test", "test\Microsoft.AspNetCore.Razor.Test\Microsoft.AspNetCore.Razor.Test.csproj", "{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "benchmarks\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{6205467F-E381-4C42-AEEC-763BD62B3D5E}" @@ -345,14 +343,6 @@ Global {1D90F276-E1CA-4FDF-A173-EB889E7D3150}.Release|Any CPU.Build.0 = Release|Any CPU {1D90F276-E1CA-4FDF-A173-EB889E7D3150}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU {1D90F276-E1CA-4FDF-A173-EB889E7D3150}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {043B9497-C0BA-4770-9210-4456D2F81CE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {043B9497-C0BA-4770-9210-4456D2F81CE0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {043B9497-C0BA-4770-9210-4456D2F81CE0}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {043B9497-C0BA-4770-9210-4456D2F81CE0}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {043B9497-C0BA-4770-9210-4456D2F81CE0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {043B9497-C0BA-4770-9210-4456D2F81CE0}.Release|Any CPU.Build.0 = Release|Any CPU - {043B9497-C0BA-4770-9210-4456D2F81CE0}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {043B9497-C0BA-4770-9210-4456D2F81CE0}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU {323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU @@ -391,8 +381,8 @@ Global {7D9ECCEE-71D1-4A42-ABEE-876AFA1B4FC9}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU {7D9ECCEE-71D1-4A42-ABEE-876AFA1B4FC9}.Release|Any CPU.ActiveCfg = Release|Any CPU {7D9ECCEE-71D1-4A42-ABEE-876AFA1B4FC9}.Release|Any CPU.Build.0 = Release|Any CPU - {7D9ECCEE-71D1-4A42-ABEE-876AFA1B4FC9}.ReleaseNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {7D9ECCEE-71D1-4A42-ABEE-876AFA1B4FC9}.ReleaseNoVSIX|Any CPU.Build.0 = Debug|Any CPU + {7D9ECCEE-71D1-4A42-ABEE-876AFA1B4FC9}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU + {7D9ECCEE-71D1-4A42-ABEE-876AFA1B4FC9}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU {6EA56B2B-89EC-4C38-A384-97D203375B06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EA56B2B-89EC-4C38-A384-97D203375B06}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EA56B2B-89EC-4C38-A384-97D203375B06}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU @@ -444,7 +434,6 @@ Global {B8A3E4CA-D54A-441F-A3BF-E00F060CA042} = {92463391-81BE-462B-AC3C-78C6C760741F} {5257B25D-330A-4DCF-ACED-B4709CFBF916} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {1D90F276-E1CA-4FDF-A173-EB889E7D3150} = {92463391-81BE-462B-AC3C-78C6C760741F} - {043B9497-C0BA-4770-9210-4456D2F81CE0} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {323553F0-14AB-4FBD-9CF0-1CC0BE8056F8} = {92463391-81BE-462B-AC3C-78C6C760741F} {6205467F-E381-4C42-AEEC-763BD62B3D5E} = {C2C98051-0F39-47F2-80B6-E72B29159F2C} {933101DA-C4CC-401A-AA01-2784E1025B7F} = {92463391-81BE-462B-AC3C-78C6C760741F} diff --git a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj index 60fc7c6b47..ab0ec8c6fc 100644 --- a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj +++ b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj @@ -17,6 +17,18 @@ Serialization\%(FileName)%(Extension) + + TestServices\%(FileName)%(Extension) + + + TestServices\%(FileName)%(Extension) + + + TestServices\%(FileName)%(Extension) + + + TestServices\%(FileName)%(Extension) + diff --git a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/BackgroundCodeGenerationBenchmark.cs b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/BackgroundCodeGenerationBenchmark.cs new file mode 100644 index 0000000000..40b903844b --- /dev/null +++ b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/BackgroundCodeGenerationBenchmark.cs @@ -0,0 +1,53 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; + +namespace Microsoft.AspNetCore.Razor.Performance +{ + public class BackgroundCodeGenerationBenchmark : ProjectSnapshotManagerBenchmarkBase + { + [IterationSetup] + public void Setup() + { + SnapshotManager = CreateProjectSnapshotManager(); + SnapshotManager.HostProjectAdded(HostProject); + SnapshotManager.Changed += SnapshotManager_Changed; + } + + [IterationCleanup] + public void Cleanup() + { + SnapshotManager.Changed -= SnapshotManager_Changed; + + Tasks.Clear(); + } + + private List Tasks { get; } = new List(); + + private DefaultProjectSnapshotManager SnapshotManager { get; set; } + + [Benchmark(Description = "Generates the code for 100 files", OperationsPerInvoke = 100)] + public async Task BackgroundCodeGeneration_Generate100Files() + { + for (var i = 0; i < Documents.Length; i++) + { + SnapshotManager.DocumentAdded(HostProject, Documents[i], TextLoaders[i % 4]); + } + + await Task.WhenAll(Tasks); + } + + private void SnapshotManager_Changed(object sender, ProjectChangeEventArgs e) + { + // The real work happens here. + var project = SnapshotManager.GetLoadedProject(e.ProjectFilePath); + var document = project.GetDocument(e.DocumentFilePath); + + Tasks.Add(document.GetGeneratedOutputAsync()); + } + } +} diff --git a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/ProjectLoadBenchmark.cs b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/ProjectLoadBenchmark.cs new file mode 100644 index 0000000000..58baba8faf --- /dev/null +++ b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/ProjectLoadBenchmark.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using BenchmarkDotNet.Attributes; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; + +namespace Microsoft.AspNetCore.Razor.Performance +{ + public class ProjectLoadBenchmark : ProjectSnapshotManagerBenchmarkBase + { + [IterationSetup] + public void Setup() + { + SnapshotManager = CreateProjectSnapshotManager(); + } + + private DefaultProjectSnapshotManager SnapshotManager { get; set; } + + [Benchmark(Description = "Initializes a project and 100 files", OperationsPerInvoke = 100)] + public void ProjectLoad_AddProjectAnd100Files() + { + SnapshotManager.HostProjectAdded(HostProject); + + for (var i= 0; i < Documents.Length; i++) + { + SnapshotManager.DocumentAdded(HostProject, Documents[i], TextLoaders[i % 4]); + } + } + } +} diff --git a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/ProjectSnapshotManagerBenchmarkBase.cs b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/ProjectSnapshotManagerBenchmarkBase.cs new file mode 100644 index 0000000000..70590a6a35 --- /dev/null +++ b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/ProjectSystem/ProjectSnapshotManagerBenchmarkBase.cs @@ -0,0 +1,154 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Razor.Extensions; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.LanguageServices.Razor.Serialization; +using Newtonsoft.Json; + +namespace Microsoft.AspNetCore.Razor.Performance +{ + public class ProjectSnapshotManagerBenchmarkBase + { + public ProjectSnapshotManagerBenchmarkBase() + { + var current = new DirectoryInfo(AppContext.BaseDirectory); + while (current != null && !File.Exists(Path.Combine(current.FullName, "Razor.sln"))) + { + current = current.Parent; + } + + var root = current; + var projectRoot = Path.Combine(root.FullName, "test", "testapps", "LargeProject"); + + HostProject = new HostProject(Path.Combine(projectRoot, "LargeProject.csproj"), FallbackRazorConfiguration.MVC_2_1); + + TextLoaders = new TextLoader[4]; + for (var i = 0; i < 4; i++) + { + var filePath = Path.Combine(projectRoot, "Views", "Home", $"View00{i % 4}.cshtml"); + var text = SourceText.From(filePath, encoding: null); + TextLoaders[i] = TextLoader.From(TextAndVersion.Create(text, VersionStamp.Create())); + } + + Documents = new HostDocument[100]; + for (var i = 0; i < Documents.Length; i++) + { + var filePath = Path.Combine(projectRoot, "Views", "Home", $"View00{i % 4}.cshtml"); + Documents[i] = new HostDocument(filePath, $"/Views/Home/View00{i}.cshtml"); + } + + var tagHelpers = Path.Combine(root.FullName, "benchmarks", "Microsoft.AspNetCore.Razor.Performance", "taghelpers.json"); + TagHelperResolver = new StaticTagHelperResolver(ReadTagHelpers(tagHelpers)); + } + + internal HostProject HostProject { get; } + + internal HostDocument[] Documents { get; } + + internal TextLoader[] TextLoaders { get; } + + internal TagHelperResolver TagHelperResolver { get; } + + internal DefaultProjectSnapshotManager CreateProjectSnapshotManager() + { + var services = TestServices.Create( + new IWorkspaceService[] + { + new StaticProjectSnapshotProjectEngineFactory(), + }, + new ILanguageService[] + { + TagHelperResolver, + }); + + return new DefaultProjectSnapshotManager( + new TestForegroundDispatcher(), + new TestErrorReporter(), + Array.Empty(), + new AdhocWorkspace(services)); + } + + private static IReadOnlyList ReadTagHelpers(string filePath) + { + var serializer = new JsonSerializer(); + serializer.Converters.Add(new RazorDiagnosticJsonConverter()); + serializer.Converters.Add(new TagHelperDescriptorJsonConverter()); + + using (var reader = new JsonTextReader(File.OpenText(filePath))) + { + return serializer.Deserialize>(reader); + } + } + + private class TestForegroundDispatcher : ForegroundDispatcher + { + public override bool IsForegroundThread => true; + + public override TaskScheduler ForegroundScheduler => TaskScheduler.Default; + + public override TaskScheduler BackgroundScheduler => TaskScheduler.Default; + } + + private class TestErrorReporter : ErrorReporter + { + public override void ReportError(Exception exception) + { + } + + public override void ReportError(Exception exception, ProjectSnapshot project) + { + } + + public override void ReportError(Exception exception, Project workspaceProject) + { + } + } + + private class StaticTagHelperResolver : TagHelperResolver + { + private readonly IReadOnlyList _tagHelpers; + + public StaticTagHelperResolver(IReadOnlyList tagHelpers) + { + this._tagHelpers = tagHelpers; + } + + public override Task GetTagHelpersAsync(ProjectSnapshot project, CancellationToken cancellationToken = default) + { + return Task.FromResult(new TagHelperResolutionResult(_tagHelpers, Array.Empty())); + } + } + + private class StaticProjectSnapshotProjectEngineFactory : ProjectSnapshotProjectEngineFactory + { + public override RazorProjectEngine Create(ProjectSnapshot project, RazorProjectFileSystem fileSystem, Action configure) + { + return RazorProjectEngine.Create(project.Configuration, fileSystem, b => + { + RazorExtensions.Register(b); + }); + } + + public override IProjectEngineFactory FindFactory(ProjectSnapshot project) + { + throw new NotImplementedException(); + } + + public override IProjectEngineFactory FindSerializableFactory(ProjectSnapshot project) + { + throw new NotImplementedException(); + } + } + } +} diff --git a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/SyntaxTreeGenerationBenckmark.cs b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/SyntaxTreeGenerationBenckmark.cs new file mode 100644 index 0000000000..d1ec9a0a55 --- /dev/null +++ b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Performance/SyntaxTreeGenerationBenckmark.cs @@ -0,0 +1,77 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Linq; +using BenchmarkDotNet.Attributes; +using Microsoft.AspNetCore.Mvc.Razor.Extensions; +using Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.AspNetCore.Razor.Performance +{ + public class SyntaxTreeGenerationBenchmark + { + public SyntaxTreeGenerationBenchmark() + { + var current = new DirectoryInfo(AppContext.BaseDirectory); + while (current != null && !File.Exists(Path.Combine(current.FullName, "MSN.cshtml"))) + { + current = current.Parent; + } + + var root = current; + var fileSystem = RazorProjectFileSystem.Create(root.FullName); + + ProjectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => RazorExtensions.Register(b)); ; + + var projectItem = fileSystem.GetItem(Path.Combine(root.FullName, "MSN.cshtml")); + MSN = RazorSourceDocument.ReadFrom(projectItem); + + var directiveFeature = ProjectEngine.EngineFeatures.OfType().FirstOrDefault(); + Directives = directiveFeature?.Directives.ToArray() ?? Array.Empty(); + } + + public RazorProjectEngine ProjectEngine { get; } + + public RazorSourceDocument MSN { get; } + + public DirectiveDescriptor[] Directives { get; } + + [Benchmark(Description = "Razor Design Time Syntax Tree Generation of MSN.com")] + public void SyntaxTreeGeneration_DesignTime_LargeStaticFile() + { + var options = RazorParserOptions.CreateDesignTime(o => + { + foreach (var directive in Directives) + { + o.Directives.Add(directive); + } + }); + var syntaxTree = RazorSyntaxTree.Parse(MSN, options); + + if (syntaxTree.Diagnostics.Count != 0) + { + throw new Exception("Error!" + Environment.NewLine + string.Join(Environment.NewLine, syntaxTree.Diagnostics)); + } + } + + [Benchmark(Description = "Razor Runtime Syntax Tree Generation of MSN.com")] + public void SyntaxTreeGeneration_Runtime_LargeStaticFile() + { + var options = RazorParserOptions.Create(o => + { + foreach (var directive in Directives) + { + o.Directives.Add(directive); + } + }); + var syntaxTree = RazorSyntaxTree.Parse(MSN, options); + + if (syntaxTree.Diagnostics.Count != 0) + { + throw new Exception("Error!" + Environment.NewLine + string.Join(Environment.NewLine, syntaxTree.Diagnostics)); + } + } + } +} diff --git a/src/Razor/build/MPack.targets b/src/Razor/build/MPack.targets index 54ace6edf4..ce81b91622 100644 --- a/src/Razor/build/MPack.targets +++ b/src/Razor/build/MPack.targets @@ -30,7 +30,9 @@ $(MPackArtifactCategory) - + + + diff --git a/src/Razor/build/VSIX.targets b/src/Razor/build/VSIX.targets index febfc39d48..eda19a3bef 100644 --- a/src/Razor/build/VSIX.targets +++ b/src/Razor/build/VSIX.targets @@ -42,7 +42,8 @@ $(VSIXName) - + + @@ -63,7 +64,6 @@ @@ -96,7 +96,6 @@ diff --git a/src/Razor/build/dependencies.props b/src/Razor/build/dependencies.props index e128924edb..b76ea87d30 100644 --- a/src/Razor/build/dependencies.props +++ b/src/Razor/build/dependencies.props @@ -2,19 +2,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - - + 0.10.13 - 2.1.3-rtm-15802 + 2.2.0-preview2-20181108.4 + 2.2.0-rtm-181106-13 + 2.2.0-rtm-35661 + 2.2.0-rtm-181106-13 15.6.82 15.6.82 15.6.82 2.8.0 2.8.0 + 2.2.0-rtm-181106-13 + 2.2.0-rtm-181106-13 2.1.0 - 2.0.0 - 2.1.2 + 2.2.0-rtm-181106-13 + 2.2.0-rtm-181106-13 + 2.2.0-rtm-35661 + 2.0.9 + 2.1.3 + 2.2.0-rtm-27105-02 15.6.1 15.0.26606 15.6.161-preview @@ -33,7 +40,7 @@ 15.6.161-preview 1.3.8 1.0.1 - 4.7.49 + 4.10.0 2.0.3 11.0.2 1.1.92 @@ -41,32 +48,21 @@ 4.3.0 4.5.0 9.0.1 - 2.8.0 - 2.8.0 - 2.8.0 - 2.8.0 - 2.8.0 - 2.8.0-beta2-62721-09 - 2.8.0 - 2.8.0 - 2.8.0 - 2.8.0-beta2-62721-09 - 0.8.0 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 2.9.0-beta4-62911-02 + 0.10.0 2.3.1 - 2.4.0-beta.1.build3945 + 2.4.0 + - - - - - 2.1.1 - 2.1.1 - 2.1.0 - 2.1.1 - 2.1.1 - 2.1.1 - 2.1.1 - - \ No newline at end of file + diff --git a/src/Razor/build/repo.props b/src/Razor/build/repo.props index ec177662e4..def34f0b6f 100644 --- a/src/Razor/build/repo.props +++ b/src/Razor/build/repo.props @@ -21,12 +21,13 @@ Internal.AspNetCore.Universe.Lineup - 2.1.0-rc1-* + 2.2.0-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + diff --git a/src/Razor/build/repo.targets b/src/Razor/build/repo.targets index 2e234b2b72..550069ec47 100644 --- a/src/Razor/build/repo.targets +++ b/src/Razor/build/repo.targets @@ -1,6 +1,7 @@  + @@ -21,7 +22,11 @@ Outputs="$(MSBuildLocationFileOutput)"> - MSBuildLocation=$(VisualStudioMSBuildx86Path) + + MSBuildLocation=$(VisualStudioMSBuildx86Path); + MicrosoftNETCoreAppPackageVersion=$(MicrosoftNETCoreApp22PackageVersion); + NETStandardLibraryPackageVersion=$(NETStandardLibrary20PackageVersion) + (); - var visitor = ViewComponentTypeVisitor.Create(compilation, types); + var visitor = new ViewComponentTypeVisitor(vcAttribute, nonVCAttribute, types); // We always visit the global namespace. visitor.Visit(compilation.Assembly.GlobalNamespace); diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ViewComponentTagHelperIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ViewComponentTagHelperIntermediateNode.cs index bfe937aaa8..b1399ffbea 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ViewComponentTagHelperIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ViewComponentTagHelperIntermediateNode.cs @@ -47,5 +47,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X extension.WriteViewComponentTagHelper(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(ClassName); + + formatter.WriteProperty(nameof(ClassName), ClassName); + formatter.WriteProperty(nameof(TagHelper), TagHelper?.DisplayName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ViewComponentTypeVisitor.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ViewComponentTypeVisitor.cs index be987cbdd5..db0912087a 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ViewComponentTypeVisitor.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ViewComponentTypeVisitor.cs @@ -16,13 +16,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X private readonly INamedTypeSymbol _nonViewComponentAttribute; private readonly List _results; - public static ViewComponentTypeVisitor Create(Compilation compilation, List results) - { - var vcAttribute = compilation.GetTypeByMetadataName(ViewComponentTypes.ViewComponentAttribute); - var nonVCAttribute = compilation.GetTypeByMetadataName(ViewComponentTypes.NonViewComponentAttribute); - return new ViewComponentTypeVisitor(vcAttribute, nonVCAttribute, results); - } - public ViewComponentTypeVisitor( INamedTypeSymbol viewComponentAttribute, INamedTypeSymbol nonViewComponentAttribute, @@ -31,12 +24,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X _viewComponentAttribute = viewComponentAttribute; _nonViewComponentAttribute = nonViewComponentAttribute; _results = results; - - Enabled = _viewComponentAttribute != null; } - public bool Enabled { get; set; } - public override void VisitNamedType(INamedTypeSymbol symbol) { if (IsViewComponent(symbol)) @@ -65,11 +54,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X internal bool IsViewComponent(INamedTypeSymbol symbol) { - if (!Enabled) - { - return false; - } - if (symbol.DeclaredAccessibility != Accessibility.Public || symbol.IsAbstract || symbol.IsGenericType || diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectIntermediateNode.cs index e1dfe9cf15..572d8bb1dc 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectIntermediateNode.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -47,5 +46,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions extension.WriteInjectProperty(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(MemberName); + + formatter.WriteProperty(nameof(MemberName), MemberName); + formatter.WriteProperty(nameof(TypeName), TypeName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs index 1ae0a72210..d80c2b9b68 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs @@ -33,8 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions private static void AddInstrumentation(InstrumentationItem item) { - var beginContextMethodName = "BeginContext"; /* ORIGINAL: BeginContextMethodName */ - var endContextMethodName = "EndContext"; /* ORIGINAL: EndContextMethodName */ + var beginContextMethodName = "BeginContext"; // ORIGINAL: BeginContextMethodName + var endContextMethodName = "EndContext"; // ORIGINAL: EndContextMethodName var beginNode = new CSharpCodeIntermediateNode(); beginNode.Children.Add(new IntermediateToken() diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs index 2378f23591..57e9ad23a2 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using System.Text; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -25,7 +27,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @namespace.Content = "AspNetCore"; var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; - @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); + if (string.IsNullOrEmpty(filePath)) + { + // It's possible for a Razor document to not have a file path. + // Eg. When we try to generate code for an in memory document like default imports. + var checksum = BytesToString(codeDocument.Source.GetChecksum()); + @class.ClassName = $"AspNetCore_{checksum}"; + } + else + { + @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); + } + @class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage"; @class.Modifiers.Clear(); @class.Modifiers.Add("public"); @@ -37,5 +50,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions method.Modifiers.Add("override"); method.ReturnType = $"global::{typeof(System.Threading.Tasks.Task).FullName}"; } + + private static string BytesToString(byte[] bytes) + { + if (bytes == null) + { + throw new ArgumentNullException(nameof(bytes)); + } + + var result = new StringBuilder(bytes.Length); + for (var i = 0; i < bytes.Length; i++) + { + // The x2 format means lowercase hex, where each byte is a 2-character string. + result.Append(bytes[i].ToString("x2")); + } + + return result.ToString(); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs index daf8e0e606..9af7873874 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs @@ -1,7 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Diagnostics; +using System.Text; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Extensions; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -52,7 +54,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page"; var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; - @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); + if (string.IsNullOrEmpty(filePath)) + { + // It's possible for a Razor document to not have a file path. + // Eg. When we try to generate code for an in memory document like default imports. + var checksum = BytesToString(codeDocument.Source.GetChecksum()); + @class.ClassName = $"AspNetCore_{checksum}"; + } + else + { + @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); + } @class.Modifiers.Clear(); @class.Modifiers.Add("public"); @@ -131,5 +143,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions options.ParseLeadingDirectives = true; } } + + private static string BytesToString(byte[] bytes) + { + if (bytes == null) + { + throw new ArgumentNullException(nameof(bytes)); + } + + var result = new StringBuilder(bytes.Length); + for (var i = 0; i < bytes.Length; i++) + { + // The x2 format means lowercase hex, where each byte is a 2-character string. + result.Append(bytes[i].ToString("x2")); + } + + return result.ToString(); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperDescriptorFactory.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperDescriptorFactory.cs index cb64a4611a..a5181fd789 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperDescriptorFactory.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperDescriptorFactory.cs @@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var descriptorBuilder = TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, typeName, assemblyName); descriptorBuilder.SetTypeName(typeName); descriptorBuilder.DisplayName = displayName; - + if (TryFindInvokeMethod(type, out var method, out var diagnostic)) { var methodParameters = method.Parameters; @@ -84,21 +84,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions private bool TryFindInvokeMethod(INamedTypeSymbol type, out IMethodSymbol method, out RazorDiagnostic diagnostic) { - var methods = type.GetMembers() - .OfType() - .Where(m => - m.DeclaredAccessibility == Accessibility.Public && - (string.Equals(m.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal) || - string.Equals(m.Name, ViewComponentTypes.SyncMethodName, StringComparison.Ordinal))) - .ToArray(); + var methods = GetInvokeMethods(type); - if (methods.Length == 0) + if (methods.Count == 0) { - diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_CannotFindMethod(type.ToDisplayString(FullNameTypeDisplayFormat)); + diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_CannotFindMethod(type.ToDisplayString(FullNameTypeDisplayFormat)); method = null; return false; } - else if (methods.Length > 1) + else if (methods.Count > 1) { diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_AmbiguousMethods(type.ToDisplayString(FullNameTypeDisplayFormat)); method = null; @@ -153,6 +147,27 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return true; } + private static IReadOnlyList GetInvokeMethods(INamedTypeSymbol type) + { + var methods = new List(); + while (type != null) + { + var currentTypeMethods = type.GetMembers() + .OfType() + .Where(m => + m.DeclaredAccessibility == Accessibility.Public && + !m.IsStatic && + (string.Equals(m.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal) || + string.Equals(m.Name, ViewComponentTypes.SyncMethodName, StringComparison.Ordinal))); + + methods.AddRange(currentTypeMethods); + + type = type.BaseType; + } + + return methods; + } + private void AddRequiredAttributes(ImmutableArray methodParameters, TagMatchingRuleDescriptorBuilder builder) { foreach (var parameter in methodParameters) @@ -164,7 +179,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Attribute(attributeBuilder => { var lowerKebabName = HtmlConventions.ToHtmlCase(parameter.Name); - attributeBuilder.Name =lowerKebabName; + attributeBuilder.Name = lowerKebabName; }); } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperDescriptorProvider.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperDescriptorProvider.cs index a5c05dc585..d0d9805f6b 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperDescriptorProvider.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperDescriptorProvider.cs @@ -27,8 +27,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return; } + var vcAttribute = compilation.GetTypeByMetadataName(ViewComponentTypes.ViewComponentAttribute); + var nonVCAttribute = compilation.GetTypeByMetadataName(ViewComponentTypes.NonViewComponentAttribute); + if (vcAttribute == null || vcAttribute.TypeKind == TypeKind.Error) + { + // Could not find attributes we care about in the compilation. Nothing to do. + return; + } + var types = new List(); - var visitor = ViewComponentTypeVisitor.Create(compilation, types); + var visitor = new ViewComponentTypeVisitor(vcAttribute, nonVCAttribute, types); // We always visit the global namespace. visitor.Visit(compilation.Assembly.GlobalNamespace); diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperIntermediateNode.cs index 09b124970e..9283b2c092 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTagHelperIntermediateNode.cs @@ -47,5 +47,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions extension.WriteViewComponentTagHelper(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(ClassName); + + formatter.WriteProperty(nameof(ClassName), ClassName); + formatter.WriteProperty(nameof(TagHelper), TagHelper?.DisplayName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTypeVisitor.cs b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTypeVisitor.cs index 2fd215d99d..9e1f936060 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTypeVisitor.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ViewComponentTypeVisitor.cs @@ -13,13 +13,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions private readonly INamedTypeSymbol _nonViewComponentAttribute; private readonly List _results; - public static ViewComponentTypeVisitor Create(Compilation compilation, List results) - { - var vcAttribute = compilation.GetTypeByMetadataName(ViewComponentTypes.ViewComponentAttribute); - var nonVCAttribute = compilation.GetTypeByMetadataName(ViewComponentTypes.NonViewComponentAttribute); - return new ViewComponentTypeVisitor(vcAttribute, nonVCAttribute, results); - } - public ViewComponentTypeVisitor( INamedTypeSymbol viewComponentAttribute, INamedTypeSymbol nonViewComponentAttribute, diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.csproj b/src/Razor/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.csproj index 13ab584df8..083a24e847 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.csproj +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.csproj @@ -1,103 +1,56 @@ - - - - - + Razor is a markup syntax for adding server-side logic to web pages. This package contains MSBuild support for Razor. - netstandard2.0 + netcoreapp2.0 false + false + false $(MSBuildProjectName).nuspec - - - - - - - - - - - - - - _BuildDependencyProjects;$(GenerateNuspecDependsOn) - _BuildDependencyProjects;$(BuildDependsOn) + ..\Microsoft.AspNetCore.Razor.Tools\Microsoft.AspNetCore.Razor.Tools.csproj - - + - First, build the project, then copy it to the ouput directory, then add it as packable content. - --> - + + - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_RazorTool Include="$(OutputPath)tools\**\*" /> - - - - - - + true + + unknown + id=$(PackageId); version=$(PackageVersion); @@ -111,15 +64,21 @@ repositoryCommit=$(RepositoryCommit); copyright=$(Copyright); - - TaskAssemblyNet46=@(TaskAssemblyNet46); - TaskSymbolNet46=@(TaskSymbolNet46); - TaskAssemblyNetStandard=@(TaskAssemblyNetStandard); - TaskSymbolNetStandard=@(TaskSymbolNetStandard); - - ToolAssembly=$(OutputPath)tools\**\*; + ToolFiles=$(OutputPath)tools\**\*; + + + + + + + <_RazorTool Include="$(OutputPath)tools\**\*" /> + + + + + diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.nuspec b/src/Razor/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.nuspec index 687b5cf1d8..47d16cd554 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.nuspec +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.nuspec @@ -26,6 +26,6 @@ - + - \ No newline at end of file + diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets b/src/Razor/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets index c390749c45..c81d741e1f 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets @@ -4,6 +4,16 @@ This target is explicitly imported by Razor SDK. --> + + + + <_RazorMSBuildRoot Condition="'$(_RazorMSBuildRoot)'==''">$(MSBuildThisFileDirectory)..\..\ - <_RazorTaskFolder Condition=" '$(MSBuildRuntimeType)' == 'Core' ">netstandard2.0 - <_RazorTaskFolder Condition=" '$(MSBuildRuntimeType)' != 'Core' ">net46 - - <_RazorTaskAssembly Condition="'$(_RazorTaskAssembly)'==''">$(_RazorMSBuildRoot)\tasks\$(_RazorTaskFolder)\Microsoft.AspNetCore.Razor.Tasks.dll - <_RazorToolAssembly Condition="'$(_RazorToolAssembly)'==''">$(_RazorMSBuildRoot)tools\rzc.dll @@ -47,6 +42,4 @@ - - diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptorComparer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptorComparer.cs index d73e3ec71e..37f0a55417 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptorComparer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptorComparer.cs @@ -54,20 +54,18 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - return descriptorX != null && + return string.Equals(descriptorX.Name, descriptorY.Name, _stringComparison) && - string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal) && - Enumerable.SequenceEqual(descriptorX.Diagnostics, descriptorY.Diagnostics); + string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal); } /// public virtual int GetHashCode(AllowedChildTagDescriptor descriptor) { - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(descriptor.Name, _stringComparer); - hashCodeCombiner.Add(descriptor.DisplayName, StringComparer.Ordinal); + var hash = HashCodeCombiner.Start(); + hash.Add(descriptor.Name, _stringComparer); - return hashCodeCombiner.CombinedHash; + return hash.CombinedHash; } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptorComparer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptorComparer.cs index 21b610e45b..fbf68929eb 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptorComparer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptorComparer.cs @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - return descriptorX != null && + return string.Equals(descriptorX.Kind, descriptorY.Kind, StringComparison.Ordinal) && descriptorX.IsIndexerStringProperty == descriptorY.IsIndexerStringProperty && descriptorX.IsEnum == descriptorY.IsEnum && @@ -61,7 +61,6 @@ namespace Microsoft.AspNetCore.Razor.Language string.Equals(descriptorX.IndexerTypeName, descriptorY.IndexerTypeName, StringComparison.Ordinal) && string.Equals(descriptorX.Documentation, descriptorY.Documentation, StringComparison.Ordinal) && string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal) && - Enumerable.SequenceEqual(descriptorX.Diagnostics, descriptorY.Diagnostics) && Enumerable.SequenceEqual( descriptorX.Metadata.OrderBy(propertyX => propertyX.Key, StringComparer.Ordinal), descriptorY.Metadata.OrderBy(propertyY => propertyY.Key, StringComparer.Ordinal)); @@ -74,19 +73,11 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(descriptor)); } - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(descriptor.Kind); - hashCodeCombiner.Add(descriptor.IsIndexerStringProperty); - hashCodeCombiner.Add(descriptor.IsEnum); - hashCodeCombiner.Add(descriptor.HasIndexer); - hashCodeCombiner.Add(descriptor.Name, _stringComparer); - hashCodeCombiner.Add(descriptor.IndexerNamePrefix, _stringComparer); - hashCodeCombiner.Add(descriptor.TypeName, StringComparer.Ordinal); - hashCodeCombiner.Add(descriptor.IndexerTypeName, StringComparer.Ordinal); - hashCodeCombiner.Add(descriptor.Documentation, StringComparer.Ordinal); - hashCodeCombiner.Add(descriptor.DisplayName, StringComparer.Ordinal); + var hash = HashCodeCombiner.Start(); + hash.Add(descriptor.Kind); + hash.Add(descriptor.Name, _stringComparer); - return hashCodeCombiner.CombinedHash; + return hash.CombinedHash; } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeNodeWriter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeNodeWriter.cs index 46837d0e23..d937c6f626 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeNodeWriter.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeNodeWriter.cs @@ -88,32 +88,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public override void WriteCSharpCode(CodeRenderingContext context, CSharpCodeIntermediateNode node) { - var isWhitespaceStatement = true; - for (var i = 0; i < node.Children.Count; i++) - { - var token = node.Children[i] as IntermediateToken; - if (token == null || !string.IsNullOrWhiteSpace(token.Content)) - { - isWhitespaceStatement = false; - break; - } - } - IDisposable linePragmaScope = null; if (node.Source != null) { - if (!isWhitespaceStatement) - { - linePragmaScope = context.CodeWriter.BuildLinePragma(node.Source.Value); - } + linePragmaScope = context.CodeWriter.BuildLinePragma(node.Source.Value); context.CodeWriter.WritePadding(0, node.Source.Value, context); } - else if (isWhitespaceStatement) - { - // Don't write whitespace if there is no line mapping for it. - return; - } for (var i = 0; i < node.Children.Count; i++) { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeNodeWriter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeNodeWriter.cs index 9f08216548..f913a53fc4 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeNodeWriter.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeNodeWriter.cs @@ -325,28 +325,56 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration var content = builder.ToString(); - var charactersConsumed = 0; + WriteHtmlLiteral(context, MaxStringLiteralLength, content); + } - // Render the string in pieces to avoid Roslyn OOM exceptions at compile time: https://github.com/aspnet/External/issues/54 - while (charactersConsumed < content.Length) + // Internal for testing + internal void WriteHtmlLiteral(CodeRenderingContext context, int maxStringLiteralLength, string literal) + { + if (literal.Length <= maxStringLiteralLength) { - string textToRender; - if (content.Length <= MaxStringLiteralLength) + WriteLiteral(literal); + return; + } + + // String is too large, render the string in pieces to avoid Roslyn OOM exceptions at compile time: https://github.com/aspnet/External/issues/54 + var charactersConsumed = 0; + do + { + var charactersRemaining = literal.Length - charactersConsumed; + var charactersToSubstring = Math.Min(maxStringLiteralLength, charactersRemaining); + var lastCharBeforeSplitIndex = charactersConsumed + charactersToSubstring - 1; + var lastCharBeforeSplit = literal[lastCharBeforeSplitIndex]; + + if (char.IsHighSurrogate(lastCharBeforeSplit)) { - textToRender = content; - } - else - { - var charactersToSubstring = Math.Min(MaxStringLiteralLength, content.Length - charactersConsumed); - textToRender = content.Substring(charactersConsumed, charactersToSubstring); + if (charactersRemaining > 1) + { + // Take one less character this iteration. We're attempting to split inbetween a surrogate pair. + // This can happen when something like an emoji sits on the barrier between splits; if we were to + // split the emoji we'd end up with invalid bytes in our output. + charactersToSubstring--; + } + else + { + // The user has an invalid file with a partial surrogate a the splitting point. + // We'll let the invalid character flow but we'll explode later on. + } } - context.CodeWriter - .WriteStartMethodInvocation(WriteHtmlContentMethod) - .WriteStringLiteral(textToRender) - .WriteEndMethodInvocation(); + var textToRender = literal.Substring(charactersConsumed, charactersToSubstring); + + WriteLiteral(textToRender); charactersConsumed += textToRender.Length; + } while (charactersConsumed < literal.Length); + + void WriteLiteral(string content) + { + context.CodeWriter + .WriteStartMethodInvocation(WriteHtmlContentMethod) + .WriteStringLiteral(content) + .WriteEndMethodInvocation(); } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs index 5e3ae8a258..a711567547 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs @@ -34,13 +34,13 @@ namespace Microsoft.AspNetCore.Razor.Language document.Options = codeDocument.GetCodeGenerationOptions() ?? _optionsFeature.GetOptions(); - var namespaces = new Dictionary(StringComparer.Ordinal); + IReadOnlyList importedUsings = Array.Empty(); // The import documents should be inserted logically before the main document. var imports = codeDocument.GetImportSyntaxTrees(); if (imports != null) { - var importsVisitor = new ImportsVisitor(document, builder, namespaces, syntaxTree.Options.FeatureFlags); + var importsVisitor = new ImportsVisitor(document, builder, syntaxTree.Options.FeatureFlags); for (var j = 0; j < imports.Count; j++) { @@ -49,26 +49,40 @@ namespace Microsoft.AspNetCore.Razor.Language importsVisitor.FilePath = import.Source.FilePath; importsVisitor.VisitBlock(import.Root); } + + importedUsings = importsVisitor.Usings; } var tagHelperPrefix = tagHelperContext?.Prefix; - var visitor = new MainSourceVisitor(document, builder, namespaces, tagHelperPrefix, syntaxTree.Options.FeatureFlags) + var visitor = new MainSourceVisitor(document, builder, tagHelperPrefix, syntaxTree.Options.FeatureFlags) { FilePath = syntaxTree.Source.FilePath, }; visitor.VisitBlock(syntaxTree.Root); + // 1. Prioritize non-imported usings over imported ones. + // 2. Don't import usings that already exist in primary document. + // 3. Allow duplicate usings in primary document (C# warning). + var usingReferences = new List(visitor.Usings); + for (var j = importedUsings.Count - 1; j >= 0; j--) + { + if (!usingReferences.Contains(importedUsings[j])) + { + usingReferences.Insert(0, importedUsings[j]); + } + } + // In each lowering piece above, namespaces were tracked. We render them here to ensure every // lowering action has a chance to add a source location to a namespace. Ultimately, closest wins. var i = 0; - foreach (var @namespace in namespaces) + foreach (var reference in usingReferences) { var @using = new UsingDirectiveIntermediateNode() { - Content = @namespace.Key, - Source = @namespace.Value, + Content = reference.Namespace, + Source = reference.Source, }; builder.Insert(i++, @using); @@ -147,21 +161,51 @@ namespace Microsoft.AspNetCore.Razor.Language } } + private struct UsingReference : IEquatable + { + public UsingReference(string @namespace, SourceSpan? source) + { + Namespace = @namespace; + Source = source; + } + public string Namespace { get; } + + public SourceSpan? Source { get; } + + public override bool Equals(object other) + { + if (other is UsingReference reference) + { + return Equals(reference); + } + + return false; + } + public bool Equals(UsingReference other) + { + return string.Equals(Namespace, other.Namespace, StringComparison.Ordinal); + } + + public override int GetHashCode() => Namespace.GetHashCode(); + } + private class LoweringVisitor : ParserVisitor { protected readonly IntermediateNodeBuilder _builder; protected readonly DocumentIntermediateNode _document; - protected readonly Dictionary _namespaces; + protected readonly List _usings; protected readonly RazorParserFeatureFlags _featureFlags; - public LoweringVisitor(DocumentIntermediateNode document, IntermediateNodeBuilder builder, Dictionary namespaces, RazorParserFeatureFlags featureFlags) + public LoweringVisitor(DocumentIntermediateNode document, IntermediateNodeBuilder builder, RazorParserFeatureFlags featureFlags) { _document = document; _builder = builder; - _namespaces = namespaces; + _usings = new List(); _featureFlags = featureFlags; } + public IReadOnlyList Usings => _usings; + public string FilePath { get; set; } public override void VisitDirectiveToken(DirectiveTokenChunkGenerator chunkGenerator, Span span) @@ -212,7 +256,7 @@ namespace Microsoft.AspNetCore.Razor.Language { var namespaceImport = chunkGenerator.Namespace.Trim(); var namespaceSpan = BuildSourceSpanFromNode(span); - _namespaces[namespaceImport] = namespaceSpan; + _usings.Add(new UsingReference(namespaceImport, namespaceSpan)); } public override void VisitAddTagHelperSpan(AddTagHelperChunkGenerator chunkGenerator, Span span) @@ -353,8 +397,8 @@ namespace Microsoft.AspNetCore.Razor.Language { private readonly string _tagHelperPrefix; - public MainSourceVisitor(DocumentIntermediateNode document, IntermediateNodeBuilder builder, Dictionary namespaces, string tagHelperPrefix, RazorParserFeatureFlags featureFlags) - : base(document, builder, namespaces, featureFlags) + public MainSourceVisitor(DocumentIntermediateNode document, IntermediateNodeBuilder builder, string tagHelperPrefix, RazorParserFeatureFlags featureFlags) + : base(document, builder, featureFlags) { _tagHelperPrefix = tagHelperPrefix; } @@ -549,14 +593,14 @@ namespace Microsoft.AspNetCore.Razor.Language public override void VisitMarkupSpan(MarkupChunkGenerator chunkGenerator, Span span) { - if (span.Symbols.Count == 1) + if (span.Tokens.Count == 1) { - var symbol = span.Symbols[0] as HtmlSymbol; - if (symbol != null && - symbol.Type == HtmlSymbolType.Unknown && - symbol.Content.Length == 0) + var token = span.Tokens[0] as HtmlToken; + if (token != null && + token.Type == HtmlTokenType.Unknown && + token.Content.Length == 0) { - // We don't want to create IR nodes for marker symbols. + // We don't want to create IR nodes for marker tokens. return; } } @@ -731,8 +775,8 @@ namespace Microsoft.AspNetCore.Razor.Language private class ImportsVisitor : LoweringVisitor { - public ImportsVisitor(DocumentIntermediateNode document, IntermediateNodeBuilder builder, Dictionary namespaces, RazorParserFeatureFlags featureFlags) - : base(document, new ImportBuilder(builder), namespaces, featureFlags) + public ImportsVisitor(DocumentIntermediateNode document, IntermediateNodeBuilder builder, RazorParserFeatureFlags featureFlags) + : base(document, new ImportBuilder(builder), featureFlags) { } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs index e5993ce1a3..a560a0030a 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs @@ -68,10 +68,23 @@ namespace Microsoft.AspNetCore.Razor.Language var importItems = importFeature.GetImports(projectItem); var importSourceDocuments = GetImportSourceDocuments(importItems); + return CreateCodeDocumentCore(sourceDocument, importSourceDocuments, tagHelpers: null); + } + + internal override RazorCodeDocument CreateCodeDocumentCore(RazorSourceDocument sourceDocument, IReadOnlyList importSourceDocuments, IReadOnlyList tagHelpers) + { + if (sourceDocument == null) + { + throw new ArgumentNullException(nameof(sourceDocument)); + } + var parserOptions = GetRequiredFeature().Create(ConfigureParserOptions); var codeGenerationOptions = GetRequiredFeature().Create(ConfigureCodeGenerationOptions); - return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); + var codeDocument = RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); + codeDocument.SetTagHelpers(tagHelpers); + + return codeDocument; } protected override RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem) @@ -87,10 +100,23 @@ namespace Microsoft.AspNetCore.Razor.Language var importItems = importFeature.GetImports(projectItem); var importSourceDocuments = GetImportSourceDocuments(importItems, suppressExceptions: true); + return CreateCodeDocumentDesignTimeCore(sourceDocument, importSourceDocuments, tagHelpers: null); + } + + internal override RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorSourceDocument sourceDocument, IReadOnlyList importSourceDocuments, IReadOnlyList tagHelpers) + { + if (sourceDocument == null) + { + throw new ArgumentNullException(nameof(sourceDocument)); + } + var parserOptions = GetRequiredFeature().Create(ConfigureDesignTimeParserOptions); var codeGenerationOptions = GetRequiredFeature().Create(ConfigureDesignTimeCodeGenerationOptions); - return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); + var codeDocument = RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); + codeDocument.SetTagHelpers(tagHelpers); + + return codeDocument; } protected override void ProcessCore(RazorCodeDocument codeDocument) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs index 7d9dfb7c6e..aa0668a539 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs @@ -15,18 +15,23 @@ namespace Microsoft.AspNetCore.Razor.Language var syntaxTree = codeDocument.GetSyntaxTree(); ThrowForMissingDocumentDependency(syntaxTree); - var feature = Engine.Features.OfType().FirstOrDefault(); - if (feature == null) + var descriptors = codeDocument.GetTagHelpers(); + if (descriptors == null) { - // No feature, nothing to do. - return; + var feature = Engine.Features.OfType().FirstOrDefault(); + if (feature == null) + { + // No feature, nothing to do. + return; + } + + descriptors = feature.GetDescriptors(); } // We need to find directives in all of the *imports* as well as in the main razor file // // The imports come logically before the main razor file and are in the order they // should be processed. - var descriptors = feature.GetDescriptors(); var visitor = new DirectiveVisitor(descriptors); var imports = codeDocument.GetImportSyntaxTrees(); if (imports != null) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DirectiveTokenEditHandler.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DirectiveTokenEditHandler.cs index 6abaa03f5c..308c274518 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DirectiveTokenEditHandler.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/DirectiveTokenEditHandler.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DirectiveTokenEditHandler : SpanEditHandler { - public DirectiveTokenEditHandler(Func> tokenizer) : base(tokenizer) + public DirectiveTokenEditHandler(Func> tokenizer) : base(tokenizer) { } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperCreateIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperCreateIntermediateNode.cs index 92aa2e3038..0ef75f1b7a 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperCreateIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperCreateIntermediateNode.cs @@ -48,5 +48,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteTagHelperCreate(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(TypeName); + + formatter.WriteProperty(nameof(FieldName), FieldName); + formatter.WriteProperty(nameof(TagHelper), TagHelper?.DisplayName); + formatter.WriteProperty(nameof(TypeName), TypeName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperHtmlAttributeIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperHtmlAttributeIntermediateNode.cs index 4122f66ef2..0290be8323 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperHtmlAttributeIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperHtmlAttributeIntermediateNode.cs @@ -72,5 +72,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteTagHelperHtmlAttribute(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(AttributeName); + + formatter.WriteProperty(nameof(AttributeName), AttributeName); + formatter.WriteProperty(nameof(AttributeStructure), AttributeStructure.ToString()); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperPropertyIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperPropertyIntermediateNode.cs index 083d84f32e..c0362f0d60 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperPropertyIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperPropertyIntermediateNode.cs @@ -85,5 +85,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteTagHelperProperty(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(AttributeName); + + formatter.WriteProperty(nameof(AttributeName), AttributeName); + formatter.WriteProperty(nameof(AttributeStructure), AttributeStructure.ToString()); + formatter.WriteProperty(nameof(BoundAttribute), BoundAttribute?.DisplayName); + formatter.WriteProperty(nameof(FieldName), FieldName); + formatter.WriteProperty(nameof(IsIndexerNameMatch), IsIndexerNameMatch.ToString()); + formatter.WriteProperty(nameof(PropertyName), PropertyName); + formatter.WriteProperty(nameof(TagHelper), TagHelper?.DisplayName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs index ad85ebf807..884ef07df5 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs @@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions var uniqueId = (string)context.Items[CodeRenderingContext.SuppressUniqueIds]; if (uniqueId == null) { - uniqueId = Guid.NewGuid().ToString("N"); + uniqueId = GetDeterministicId(context); } context.CodeWriter.WriteStringLiteral(node.TagName) @@ -637,6 +637,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions return builder.ToString(); } + // Internal for testing + internal static string GetDeterministicId(CodeRenderingContext context) + { + // Use the file checksum along with the absolute position in the generated code to create a unique id for each tag helper call site. + var checksum = Checksum.BytesToString(context.SourceDocument.GetChecksum()); + var uniqueId = checksum + context.CodeWriter.Location.AbsoluteIndex; + + return uniqueId; + } + private static string GetPropertyAccessor(DefaultTagHelperPropertyIntermediateNode node) { var propertyAccessor = $"{node.FieldName}.{node.PropertyName}"; diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveIntermediateNode.cs index ef1e971584..957e73a17d 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveIntermediateNode.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Text; using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Intermediate; diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveTargetExtension.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveTargetExtension.cs index bc73343044..316c255bfe 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveTargetExtension.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectiveTargetExtension.cs @@ -59,8 +59,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions if (string.IsNullOrEmpty(node.Content)) { - // This is most likely a marker symbol. - WriteMarkerSymbol(context, node); + // This is most likely a marker token. + WriteMarkerToken(context, node); break; } @@ -80,8 +80,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions if (string.IsNullOrEmpty(node.Content)) { - // This is most likely a marker symbol. - WriteMarkerSymbol(context, node); + // This is most likely a marker token. + WriteMarkerToken(context, node); break; } @@ -102,8 +102,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions if (string.IsNullOrEmpty(node.Content)) { - // This is most likely a marker symbol. - WriteMarkerSymbol(context, node); + // This is most likely a marker token. + WriteMarkerToken(context, node); break; } @@ -155,9 +155,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions context.CodeWriter.WriteLine("))();"); } - private void WriteMarkerSymbol(CodeRenderingContext context, DirectiveTokenIntermediateNode node) + private void WriteMarkerToken(CodeRenderingContext context, DirectiveTokenIntermediateNode node) { - // We want to map marker symbols to a location in the generated document + // We want to map marker tokens to a location in the generated document // that will provide CSharp intellisense. context.AddSourceMappingFor(node); context.CodeWriter.Write(" "); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeIntermediateNode.cs index 11501c1a26..70a9c61fa6 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeIntermediateNode.cs @@ -44,5 +44,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteTagHelperHtmlAttribute(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(VariableName); + + formatter.WriteProperty(nameof(VariableName), VariableName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeValueIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeValueIntermediateNode.cs index 03bb175094..5faed5344b 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeValueIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeValueIntermediateNode.cs @@ -74,5 +74,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteTagHelperHtmlAttributeValue(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(AttributeName); + + formatter.WriteProperty(nameof(AttributeName), AttributeName); + formatter.WriteProperty(nameof(AttributeStructure), AttributeStructure.ToString()); + formatter.WriteProperty(nameof(Value), Value); + formatter.WriteProperty(nameof(VariableName), VariableName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyIntermediateNode.cs index d062328cb3..7db273a1d6 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyIntermediateNode.cs @@ -79,5 +79,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteTagHelperProperty(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(AttributeName); + + formatter.WriteProperty(nameof(AttributeName), AttributeName); + formatter.WriteProperty(nameof(AttributeStructure), AttributeStructure.ToString()); + formatter.WriteProperty(nameof(BoundAttribute), BoundAttribute?.DisplayName); + formatter.WriteProperty(nameof(FieldName), FieldName); + formatter.WriteProperty(nameof(IsIndexerNameMatch), IsIndexerNameMatch.ToString()); + formatter.WriteProperty(nameof(PropertyName), PropertyName); + formatter.WriteProperty(nameof(TagHelper), TagHelper?.DisplayName); + formatter.WriteProperty(nameof(VariableName), VariableName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyValueIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyValueIntermediateNode.cs index d769905ff4..6516a22133 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyValueIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyValueIntermediateNode.cs @@ -50,5 +50,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteTagHelperPropertyValue(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(AttributeName); + + formatter.WriteProperty(nameof(AttributeName), AttributeName); + formatter.WriteProperty(nameof(AttributeStructure), AttributeStructure.ToString()); + formatter.WriteProperty(nameof(Value), Value); + formatter.WriteProperty(nameof(VariableName), VariableName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs index 792fb4ecc1..ee82fca81a 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs @@ -48,5 +48,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteRazorCompiledItemAttribute(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteProperty(nameof(Identifier), Identifier); + formatter.WriteProperty(nameof(Kind), Kind); + formatter.WriteProperty(nameof(TypeName), TypeName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemMetadataAttributeIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemMetadataAttributeIntermediateNode.cs index 0c05523028..52f7b92012 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemMetadataAttributeIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemMetadataAttributeIntermediateNode.cs @@ -55,5 +55,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteRazorCompiledItemMetadataAttribute(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteProperty(nameof(Key), Key); + formatter.WriteProperty(nameof(Value), Value); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionIntermediateNode.cs index 7076e3df06..d3d4c10557 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionIntermediateNode.cs @@ -44,5 +44,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions extension.WriteSection(context, this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(SectionName); + + formatter.WriteProperty(nameof(SectionName), SectionName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeAttributeValueIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeAttributeValueIntermediateNode.cs index 23eff1efda..4a9ce5d1a9 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeAttributeValueIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeAttributeValueIntermediateNode.cs @@ -20,5 +20,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitCSharpCodeAttributeValue(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteChildren(Children); + + formatter.WriteProperty(nameof(Prefix), Prefix); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeIntermediateNode.cs index f15ce8b067..f888a561f8 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeIntermediateNode.cs @@ -18,5 +18,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitCSharpCode(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteChildren(Children); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionAttributeValueIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionAttributeValueIntermediateNode.cs index 6cc7a837e4..c058b67acc 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionAttributeValueIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionAttributeValueIntermediateNode.cs @@ -20,5 +20,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitCSharpExpressionAttributeValue(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteChildren(Children); + + formatter.WriteProperty(nameof(Prefix), Prefix); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionIntermediateNode.cs index 42b25a8df3..c4c9e02962 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionIntermediateNode.cs @@ -18,5 +18,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitCSharpExpression(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteChildren(Children); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ClassDeclarationIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ClassDeclarationIntermediateNode.cs index cf923eb429..ea178228c3 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ClassDeclarationIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ClassDeclarationIntermediateNode.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Microsoft.AspNetCore.Razor.Language.Intermediate { @@ -29,5 +30,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitClassDeclaration(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(ClassName); + + formatter.WriteProperty(nameof(BaseType), BaseType); + formatter.WriteProperty(nameof(ClassName), ClassName); + formatter.WriteProperty(nameof(Interfaces), string.Join(", ", Interfaces)); + formatter.WriteProperty(nameof(Modifiers), string.Join(", ", Modifiers)); + formatter.WriteProperty(nameof(TypeParameters), string.Join(", ", TypeParameters.Select(t => t.ParameterName))); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DebuggerDisplayFormatter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DebuggerDisplayFormatter.cs new file mode 100644 index 0000000000..705148b8ab --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DebuggerDisplayFormatter.cs @@ -0,0 +1,21 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + internal class DebuggerDisplayFormatter : IntermediateNodeFormatterBase + { + public DebuggerDisplayFormatter() + { + Writer = new StringWriter(); + ContentMode = FormatterContentMode.PreferContent; + } + + public override string ToString() + { + return Writer.ToString(); + } + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveIntermediateNode.cs index abb3a933de..6f954a89f8 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveIntermediateNode.cs @@ -20,5 +20,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { visitor.VisitDirective(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(DirectiveName); + + formatter.WriteProperty(nameof(Directive), Directive?.DisplayName); + formatter.WriteProperty(nameof(DirectiveName), DirectiveName); + } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIntermediateNode.cs index 7db3769a08..a01ed25b80 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIntermediateNode.cs @@ -1,6 +1,8 @@ // Copyright(c) .NET Foundation.All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Text; + namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class DirectiveTokenIntermediateNode : IntermediateNode @@ -15,5 +17,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { visitor.VisitDirectiveToken(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(Content); + + formatter.WriteProperty(nameof(Content), Content); + } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DocumentIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DocumentIntermediateNode.cs index af071a7488..9570092e46 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DocumentIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DocumentIntermediateNode.cs @@ -25,5 +25,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitDocument(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(DocumentKind); + + formatter.WriteProperty(nameof(DocumentKind), DocumentKind); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/FieldDeclarationIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/FieldDeclarationIntermediateNode.cs index 6719f0768e..0d6b731390 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/FieldDeclarationIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/FieldDeclarationIntermediateNode.cs @@ -25,5 +25,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitFieldDeclaration(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(FieldName); + + formatter.WriteProperty(nameof(FieldName), FieldName); + formatter.WriteProperty(nameof(FieldType), FieldType); + formatter.WriteProperty(nameof(Modifiers), string.Join(" ", Modifiers)); + } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeIntermediateNode.cs index 46f772fce9..861b14b227 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeIntermediateNode.cs @@ -24,5 +24,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitHtmlAttribute(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(AttributeName); + + formatter.WriteProperty(nameof(AttributeName), AttributeName); + formatter.WriteProperty(nameof(Prefix), Prefix); + formatter.WriteProperty(nameof(Suffix), Suffix); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeValueIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeValueIntermediateNode.cs index d22eaa78aa..6fdc5247a3 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeValueIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeValueIntermediateNode.cs @@ -20,5 +20,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitHtmlAttributeValue(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteChildren(Children); + + formatter.WriteProperty(nameof(Prefix), Prefix); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlContentIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlContentIntermediateNode.cs index d41b8a6a47..3a213fe460 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlContentIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlContentIntermediateNode.cs @@ -18,5 +18,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitHtml(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteChildren(Children); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNode.cs index f8970d23f6..02c2976c55 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNode.cs @@ -1,8 +1,11 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Diagnostics; + namespace Microsoft.AspNetCore.Razor.Language.Intermediate { + [DebuggerDisplay("{DebuggerToString(),nq}")] public abstract class IntermediateNode { private ItemCollection _annotations; @@ -39,7 +42,30 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; public SourceSpan? Source { get; set; } - + public abstract void Accept(IntermediateNodeVisitor visitor); + + [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)] + private string Tree + { + get + { + var formatter = new DebuggerDisplayFormatter(); + formatter.FormatTree(this); + return formatter.ToString(); + } + } + + private string DebuggerToString() + { + var formatter = new DebuggerDisplayFormatter(); + formatter.FormatNode(this); + return formatter.ToString(); + } + + + public virtual void FormatNode(IntermediateNodeFormatter formatter) + { + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNodeFormatter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNodeFormatter.cs new file mode 100644 index 0000000000..c453dbe6e9 --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNodeFormatter.cs @@ -0,0 +1,16 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + public abstract class IntermediateNodeFormatter + { + public abstract void WriteChildren(IntermediateNodeCollection children); + + public abstract void WriteContent(string content); + + public abstract void WriteProperty(string key, string value); + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNodeFormatterBase.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNodeFormatterBase.cs new file mode 100644 index 0000000000..54846acaaf --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNodeFormatterBase.cs @@ -0,0 +1,180 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + internal class IntermediateNodeFormatterBase : IntermediateNodeFormatter + { + private string _content; + private Dictionary _properties = new Dictionary(StringComparer.Ordinal); + + protected FormatterContentMode ContentMode { get; set; } + + protected bool IncludeSource { get; set; } + + protected TextWriter Writer { get; set; } + + public override void WriteChildren(IntermediateNodeCollection children) + { + if (children == null) + { + throw new ArgumentNullException(nameof(children)); + } + + Writer.Write(" "); + Writer.Write("\""); + for (var i = 0; i < children.Count; i++) + { + var child = children[i] as IntermediateToken; + if (child != null) + { + Writer.Write(EscapeNewlines(child.Content)); + } + } + Writer.Write("\""); + } + + public override void WriteContent(string content) + { + if (content == null) + { + return; + } + + _content = EscapeNewlines(content); + } + + public override void WriteProperty(string key, string value) + { + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + if (value == null) + { + return; + } + + _properties.Add(key, EscapeNewlines(value)); + } + + public void FormatNode(IntermediateNode node) + { + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + BeginNode(node); + node.FormatNode(this); + EndNode(node); + } + + public void FormatTree(IntermediateNode node) + { + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + var visitor = new FormatterVisitor(this); + visitor.Visit(node); + } + + private void BeginNode(IntermediateNode node) + { + Writer.Write(GetShortName(node)); + + if (IncludeSource) + { + Writer.Write(" "); + Writer.Write(node.Source?.ToString() ?? "(n/a)"); + } + } + + private void EndNode(IntermediateNode node) + { + if (_content != null && (_properties.Count == 0 || ContentMode == FormatterContentMode.PreferContent)) + { + Writer.Write(" "); + Writer.Write("\""); + Writer.Write(EscapeNewlines(_content)); + Writer.Write("\""); + } + + if (_properties.Count > 0 && (_content == null || ContentMode == FormatterContentMode.PreferProperties)) + { + Writer.Write(" "); + Writer.Write("{ "); + Writer.Write(string.Join(", ", _properties.Select(kvp => $"{kvp.Key}: \"{kvp.Value}\""))); + Writer.Write(" }"); + } + + _content = null; + _properties.Clear(); + } + + private string GetShortName(IntermediateNode node) + { + var typeName = node.GetType().Name; + return + typeName.EndsWith(nameof(IntermediateNode), StringComparison.Ordinal) ? + typeName.Substring(0, typeName.Length - nameof(IntermediateNode).Length) : + typeName; + } + + private string EscapeNewlines(string content) + { + return content.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t"); + } + + // Depending on the usage of the formatter we might prefer thoroughness (properties) + // or brevity (content). Generally if a node has a single string that provides value + // it has content. + // + // Some nodes have neither: TagHelperBody + // Some nodes have content: HtmlContent + // Some nodes have properties: Document + // Some nodes have both: TagHelperProperty + protected enum FormatterContentMode + { + PreferContent, + PreferProperties, + } + + protected class FormatterVisitor : IntermediateNodeWalker + { + private const int IndentSize = 2; + + private readonly IntermediateNodeFormatterBase _formatter; + private int _indent = 0; + + public FormatterVisitor(IntermediateNodeFormatterBase formatter) + { + _formatter = formatter; + } + + public override void VisitDefault(IntermediateNode node) + { + // Indent + for (var i = 0; i < _indent; i++) + { + _formatter.Writer.Write(' '); + } + _formatter.FormatNode(node); + _formatter.Writer.WriteLine(); + + // Process children + _indent += IndentSize; + base.VisitDefault(node); + _indent -= IndentSize; + } + } + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateToken.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateToken.cs index d2da5fae18..d60643d24a 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateToken.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateToken.cs @@ -26,7 +26,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitToken(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(Content); + + formatter.WriteProperty(nameof(Content), Content); + } } -} - - +} \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MalformedDirectiveIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MalformedDirectiveIntermediateNode.cs index 22d23927ca..d37a2316a5 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MalformedDirectiveIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MalformedDirectiveIntermediateNode.cs @@ -20,5 +20,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { visitor.VisitMalformedDirective(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(DirectiveName); + + formatter.WriteProperty(nameof(Directive), Directive?.DisplayName); + formatter.WriteProperty(nameof(DirectiveName), DirectiveName); + } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MethodDeclarationIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MethodDeclarationIntermediateNode.cs index e1a039c5e0..ad15636824 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MethodDeclarationIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MethodDeclarationIntermediateNode.cs @@ -3,6 +3,8 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Text; namespace Microsoft.AspNetCore.Razor.Language.Intermediate { @@ -28,5 +30,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitMethodDeclaration(this); } + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(MethodName); + + formatter.WriteProperty(nameof(MethodName), MethodName); + formatter.WriteProperty(nameof(Modifiers), string.Join(", ", Modifiers)); + formatter.WriteProperty(nameof(Parameters), string.Join(", ", Parameters.Select(FormatMethodParameter))); + formatter.WriteProperty(nameof(ReturnType), ReturnType); + } + + private static string FormatMethodParameter(MethodParameter parameter) + { + var builder = new StringBuilder(); + for (var i = 0; i t.DisplayName))); + formatter.WriteProperty(nameof(TagMode), TagMode.ToString()); + formatter.WriteProperty(nameof(TagName), TagName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperPropertyIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperPropertyIntermediateNode.cs index 073571b185..1a755fe6f9 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperPropertyIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperPropertyIntermediateNode.cs @@ -28,5 +28,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitTagHelperProperty(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(AttributeName); + + formatter.WriteProperty(nameof(AttributeName), AttributeName); + formatter.WriteProperty(nameof(AttributeStructure), AttributeStructure.ToString()); + formatter.WriteProperty(nameof(BoundAttribute), BoundAttribute?.DisplayName); + formatter.WriteProperty(nameof(IsIndexerNameMatch), IsIndexerNameMatch.ToString()); + formatter.WriteProperty(nameof(TagHelper), TagHelper?.DisplayName); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/UsingDirectiveIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/UsingDirectiveIntermediateNode.cs index 4199c95e97..67c64f79e7 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/UsingDirectiveIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/UsingDirectiveIntermediateNode.cs @@ -20,5 +20,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate visitor.VisitUsingDirective(this); } + + public override void FormatNode(IntermediateNodeFormatter formatter) + { + formatter.WriteContent(Content); + + formatter.WriteProperty(nameof(Content), Content); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/AddTagHelperChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/AddTagHelperChunkGenerator.cs index 8c9d98633b..f446be12c0 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/AddTagHelperChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/AddTagHelperChunkGenerator.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language.Legacy @@ -63,5 +64,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return combiner.CombinedHash; } + + public override string ToString() + { + var builder = new StringBuilder("AddTagHelper:{"); + builder.Append(LookupText); + builder.Append(";"); + builder.Append(DirectiveText); + builder.Append(";"); + builder.Append(TypePattern); + builder.Append(";"); + builder.Append(AssemblyName); + builder.Append("}"); + + if (Diagnostics.Count > 0) + { + builder.Append(" ["); + var ids = string.Join(", ", Diagnostics.Select(diagnostic => $"{diagnostic.Id}{diagnostic.Span}")); + builder.Append(ids); + builder.Append("]"); + } + + return builder.ToString(); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/AutoCompleteEditHandler.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/AutoCompleteEditHandler.cs index bd73bbc1b2..3aecb29a52 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/AutoCompleteEditHandler.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/AutoCompleteEditHandler.cs @@ -11,18 +11,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { private static readonly int TypeHashCode = typeof(AutoCompleteEditHandler).GetHashCode(); - public AutoCompleteEditHandler(Func> tokenizer) + public AutoCompleteEditHandler(Func> tokenizer) : base(tokenizer) { } - public AutoCompleteEditHandler(Func> tokenizer, bool autoCompleteAtEndOfSpan) + public AutoCompleteEditHandler(Func> tokenizer, bool autoCompleteAtEndOfSpan) : this(tokenizer) { AutoCompleteAtEndOfSpan = autoCompleteAtEndOfSpan; } - public AutoCompleteEditHandler(Func> tokenizer, AcceptedCharactersInternal accepted) + public AutoCompleteEditHandler(Func> tokenizer, AcceptedCharactersInternal accepted) : base(tokenizer, accepted) { } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs index 13d8352ba6..a75c983fec 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs @@ -8,14 +8,14 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal class CSharpCodeParser : TokenizerBackedParser + internal class CSharpCodeParser : TokenizerBackedParser { private static HashSet InvalidNonWhitespaceNameCharacters = new HashSet(new[] { '@', '!', '<', '/', '?', '[', '>', ']', '=', '"', '\'', '*' }); - private static readonly Func IsValidStatementSpacingSymbol = + private static readonly Func IsValidStatementSpacingToken = IsSpacingToken(includeNewLines: true, includeComments: true); internal static readonly DirectiveDescriptor AddTagHelperDirectiveDescriptor = DirectiveDescriptor.CreateDirective( @@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public bool IsNested { get; set; } - protected override bool SymbolTypeEquals(CSharpSymbolType x, CSharpSymbolType y) => x == y; + protected override bool TokenTypeEquals(CSharpTokenType x, CSharpTokenType y) => x == y; protected void MapDirectives(Action handler, params string[] directives) { @@ -161,16 +161,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Conditional("DEBUG")] internal void Assert(CSharpKeyword expectedKeyword) { - Debug.Assert(CurrentSymbol.Type == CSharpSymbolType.Keyword && - CurrentSymbol.Keyword.HasValue && - CurrentSymbol.Keyword.Value == expectedKeyword); + Debug.Assert(CurrentToken.Type == CSharpTokenType.Keyword && + CurrentToken.Keyword.HasValue && + CurrentToken.Keyword.Value == expectedKeyword); } protected internal bool At(CSharpKeyword keyword) { - return At(CSharpSymbolType.Keyword) && - CurrentSymbol.Keyword.HasValue && - CurrentSymbol.Keyword.Value == keyword; + return At(CSharpTokenType.Keyword) && + CurrentToken.Keyword.HasValue && + CurrentToken.Keyword.Value == keyword; } protected internal bool AcceptIf(CSharpKeyword keyword) @@ -183,11 +183,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return false; } - protected static Func IsSpacingToken(bool includeNewLines, bool includeComments) + protected static Func IsSpacingToken(bool includeNewLines, bool includeComments) { - return sym => sym.Type == CSharpSymbolType.WhiteSpace || - (includeNewLines && sym.Type == CSharpSymbolType.NewLine) || - (includeComments && sym.Type == CSharpSymbolType.Comment); + return token => token.Type == CSharpTokenType.WhiteSpace || + (includeNewLines && token.Type == CSharpTokenType.NewLine) || + (includeComments && token.Type == CSharpTokenType.Comment); } public override void ParseBlock() @@ -208,27 +208,27 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AcceptWhile(IsSpacingToken(includeNewLines: true, includeComments: true)); - var current = CurrentSymbol; - if (At(CSharpSymbolType.StringLiteral) && - CurrentSymbol.Content.Length > 0 && - CurrentSymbol.Content[0] == SyntaxConstants.TransitionCharacter) + var current = CurrentToken; + if (At(CSharpTokenType.StringLiteral) && + CurrentToken.Content.Length > 0 && + CurrentToken.Content[0] == SyntaxConstants.TransitionCharacter) { - var split = Language.SplitSymbol(CurrentSymbol, 1, CSharpSymbolType.Transition); + var split = Language.SplitToken(CurrentToken, 1, CSharpTokenType.Transition); current = split.Item1; // Back up to the end of the transition Context.Source.Position -= split.Item2.Content.Length; NextToken(); } - else if (At(CSharpSymbolType.Transition)) + else if (At(CSharpTokenType.Transition)) { NextToken(); } // Accept "@" if we see it, but if we don't, that's OK. We assume we were started for a good reason - if (current.Type == CSharpSymbolType.Transition) + if (current.Type == CSharpTokenType.Transition) { - if (Span.Symbols.Count > 0) + if (Span.Tokens.Count > 0) { Output(SpanKindInternal.Code); } @@ -251,9 +251,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy span.ChunkGenerator = new StatementChunkGenerator(); } - private void AtTransition(CSharpSymbol current) + private void AtTransition(CSharpToken current) { - Debug.Assert(current.Type == CSharpSymbolType.Transition); + Debug.Assert(current.Type == CSharpTokenType.Transition); Accept(current); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -273,16 +273,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // What type of block is this? if (!EndOfFile) { - if (CurrentSymbol.Type == CSharpSymbolType.LeftParenthesis) + if (CurrentToken.Type == CSharpTokenType.LeftParenthesis) { Context.Builder.CurrentBlock.Type = BlockKindInternal.Expression; Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator(); ExplicitExpression(); return; } - else if (CurrentSymbol.Type == CSharpSymbolType.Identifier) + else if (CurrentToken.Type == CSharpTokenType.Identifier) { - if (TryGetDirectiveHandler(CurrentSymbol.Content, out var handler)) + if (TryGetDirectiveHandler(CurrentToken.Content, out var handler)) { Span.ChunkGenerator = SpanChunkGenerator.Null; handler(); @@ -291,13 +291,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { if (string.Equals( - CurrentSymbol.Content, + CurrentToken.Content, SyntaxConstants.CSharp.HelperKeyword, StringComparison.Ordinal)) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); + new SourceSpan(CurrentStart, CurrentToken.Content.Length))); } Context.Builder.CurrentBlock.Type = BlockKindInternal.Expression; @@ -306,9 +306,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return; } } - else if (CurrentSymbol.Type == CSharpSymbolType.Keyword) + else if (CurrentToken.Type == CSharpTokenType.Keyword) { - if (TryGetDirectiveHandler(CurrentSymbol.Content, out var handler)) + if (TryGetDirectiveHandler(CurrentToken.Content, out var handler)) { Span.ChunkGenerator = SpanChunkGenerator.Null; handler(); @@ -320,7 +320,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return; } } - else if (CurrentSymbol.Type == CSharpSymbolType.LeftBrace) + else if (CurrentToken.Type == CSharpTokenType.LeftBrace) { VerbatimBlock(); return; @@ -330,7 +330,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Invalid character Context.Builder.CurrentBlock.Type = BlockKindInternal.Expression; Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator(); - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); Span.ChunkGenerator = new ExpressionChunkGenerator(); Span.EditHandler = new ImplicitExpressionEditHandler( Language.TokenizeString, @@ -339,11 +339,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { AcceptedCharacters = AcceptedCharactersInternal.NonWhiteSpace }; - if (At(CSharpSymbolType.WhiteSpace) || At(CSharpSymbolType.NewLine)) + if (At(CSharpTokenType.WhiteSpace) || At(CSharpTokenType.NewLine)) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); + new SourceSpan(CurrentStart, CurrentToken.Content.Length))); } else if (EndOfFile) { @@ -355,8 +355,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), - CurrentSymbol.Content)); + new SourceSpan(CurrentStart, CurrentToken.Content.Length), + CurrentToken.Content)); } } finally @@ -369,7 +369,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void VerbatimBlock() { - Assert(CSharpSymbolType.LeftBrace); + Assert(CSharpTokenType.LeftBrace); var block = new Block(Resources.BlockName_Code, CurrentStart); AcceptAndMoveNext(); @@ -384,14 +384,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy CodeBlock(false, block); Span.ChunkGenerator = new StatementChunkGenerator(); - AddMarkerSymbolIfNecessary(); - if (!At(CSharpSymbolType.RightBrace)) + AddMarkerTokenIfNecessary(); + if (!At(CSharpTokenType.RightBrace)) { editHandler.AutoCompleteString = "}"; } Output(SpanKindInternal.Code); - if (Optional(CSharpSymbolType.RightBrace)) + if (Optional(CSharpTokenType.RightBrace)) { // Set up the "}" span Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; @@ -401,8 +401,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!IsNested) { EnsureCurrent(); - if (At(CSharpSymbolType.NewLine) || - (At(CSharpSymbolType.WhiteSpace) && NextIs(CSharpSymbolType.NewLine))) + if (At(CSharpTokenType.NewLine) || + (At(CSharpTokenType.WhiteSpace) && NextIs(CSharpTokenType.NewLine))) { Context.NullGenerateWhitespaceAndNewLine = true; } @@ -456,13 +456,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (!EndOfFile) { - if (CurrentSymbol.Type == CSharpSymbolType.LeftParenthesis || - CurrentSymbol.Type == CSharpSymbolType.LeftBracket) + if (CurrentToken.Type == CSharpTokenType.LeftParenthesis || + CurrentToken.Type == CSharpTokenType.LeftBracket) { // If we end within "(", whitespace is fine Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Any; - CSharpSymbolType right; + CSharpTokenType right; bool success; using (PushSpanConfig((span, prev) => @@ -471,13 +471,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Any; })) { - right = Language.FlipBracket(CurrentSymbol.Type); + right = Language.FlipBracket(CurrentToken.Type); success = Balance(BalancingModes.BacktrackOnFailure | BalancingModes.AllowCommentsAndTemplates); } if (!success) { - AcceptUntil(CSharpSymbolType.LessThan); + AcceptUntil(CSharpTokenType.LessThan); } if (At(right)) { @@ -488,22 +488,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } return MethodCallOrArrayIndex(acceptedCharacters); } - if (At(CSharpSymbolType.QuestionMark)) + if (At(CSharpTokenType.QuestionMark)) { var next = Lookahead(count: 1); if (next != null) { - if (next.Type == CSharpSymbolType.Dot) + if (next.Type == CSharpTokenType.Dot) { // Accept null conditional dot operator (?.). AcceptAndMoveNext(); AcceptAndMoveNext(); // If the next piece after the ?. is a keyword or identifier then we want to continue. - return At(CSharpSymbolType.Identifier) || At(CSharpSymbolType.Keyword); + return At(CSharpTokenType.Identifier) || At(CSharpTokenType.Keyword); } - else if (next.Type == CSharpSymbolType.LeftBracket) + else if (next.Type == CSharpTokenType.LeftBracket) { // We're at the ? for a null conditional bracket operator (?[). AcceptAndMoveNext(); @@ -513,12 +513,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } } - else if (At(CSharpSymbolType.Dot)) + else if (At(CSharpTokenType.Dot)) { - var dot = CurrentSymbol; + var dot = CurrentToken; if (NextToken()) { - if (At(CSharpSymbolType.Identifier) || At(CSharpSymbolType.Keyword)) + if (At(CSharpTokenType.Identifier) || At(CSharpTokenType.Keyword)) { // Accept the dot and return to the start Accept(dot); @@ -526,7 +526,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } else { - // Put the symbol back + // Put the token back PutCurrentBack(); } } @@ -540,7 +540,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Accept(dot); } } - else if (!At(CSharpSymbolType.WhiteSpace) && !At(CSharpSymbolType.NewLine)) + else if (!At(CSharpTokenType.WhiteSpace) && !At(CSharpTokenType.NewLine)) { PutCurrentBack(); } @@ -564,7 +564,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (insertMarkerIfNecessary && Context.Builder.LastAcceptedCharacters != AcceptedCharactersInternal.Any) { - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); } EnsureCurrent(); @@ -587,8 +587,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void CaptureWhitespaceAtEndOfCodeOnlyLine() { - var whitespace = ReadWhile(sym => sym.Type == CSharpSymbolType.WhiteSpace); - if (At(CSharpSymbolType.NewLine)) + var whitespace = ReadWhile(token => token.Type == CSharpTokenType.WhiteSpace); + if (At(CSharpTokenType.NewLine)) { Accept(whitespace); AcceptAndMoveNext(); @@ -610,7 +610,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void ExplicitExpression() { var block = new Block(Resources.BlockName_ExplicitExpression, CurrentStart); - Assert(CSharpSymbolType.LeftParenthesis); + Assert(CSharpTokenType.LeftParenthesis); AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -621,28 +621,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BalancingModes.BacktrackOnFailure | BalancingModes.NoErrorOnFailure | BalancingModes.AllowCommentsAndTemplates, - CSharpSymbolType.LeftParenthesis, - CSharpSymbolType.RightParenthesis, + CSharpTokenType.LeftParenthesis, + CSharpTokenType.RightParenthesis, block.Start); if (!success) { - AcceptUntil(CSharpSymbolType.LessThan); + AcceptUntil(CSharpTokenType.LessThan); Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( new SourceSpan(block.Start, contentLength: 1 /* ( */), block.Name, ")", "(")); } - // If necessary, put an empty-content marker symbol here - if (Span.Symbols.Count == 0) + // If necessary, put an empty-content marker token here + if (Span.Tokens.Count == 0) { - Accept(new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown)); + Accept(new CSharpToken(string.Empty, CSharpTokenType.Unknown)); } // Output the content span and then capture the ")" Output(SpanKindInternal.Code); } - Optional(CSharpSymbolType.RightParenthesis); + Optional(CSharpTokenType.RightParenthesis); if (!EndOfFile) { PutCurrentBack(); @@ -701,19 +701,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // No embedded transitions in C#, so ignore that param return allowTemplatesAndComments - && ((Language.IsTransition(CurrentSymbol) - && NextIs(CSharpSymbolType.LessThan, CSharpSymbolType.Colon, CSharpSymbolType.DoubleColon)) - || Language.IsCommentStart(CurrentSymbol)); + && ((Language.IsTransition(CurrentToken) + && NextIs(CSharpTokenType.LessThan, CSharpTokenType.Colon, CSharpTokenType.DoubleColon)) + || Language.IsCommentStart(CurrentToken)); } protected override void HandleEmbeddedTransition() { - if (Language.IsTransition(CurrentSymbol)) + if (Language.IsTransition(CurrentToken)) { PutCurrentBack(); Template(); } - else if (Language.IsCommentStart(CurrentSymbol)) + else if (Language.IsCommentStart(CurrentToken)) { RazorComment(); } @@ -761,7 +761,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_ReservedWord( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), CurrentSymbol.Content)); + new SourceSpan(CurrentStart, CurrentToken.Content.Length), CurrentToken.Content)); AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; @@ -783,12 +783,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void CaseStatement(bool topLevel) { - Assert(CSharpSymbolType.Keyword); - Debug.Assert(CurrentSymbol.Keyword != null && - (CurrentSymbol.Keyword.Value == CSharpKeyword.Case || - CurrentSymbol.Keyword.Value == CSharpKeyword.Default)); - AcceptUntil(CSharpSymbolType.Colon); - Optional(CSharpSymbolType.Colon); + Assert(CSharpTokenType.Keyword); + Debug.Assert(CurrentToken.Keyword != null && + (CurrentToken.Keyword.Value == CSharpKeyword.Case || + CurrentToken.Keyword.Value == CSharpKeyword.Default)); + AcceptUntil(CSharpTokenType.Colon); + Optional(CSharpTokenType.Colon); } private void DoStatement(bool topLevel) @@ -813,7 +813,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Assert(CSharpKeyword.While); AcceptAndMoveNext(); AcceptWhile(IsSpacingToken(includeNewLines: true, includeComments: true)); - if (AcceptCondition() && Optional(CSharpSymbolType.Semicolon)) + if (AcceptCondition() && Optional(CSharpTokenType.Semicolon)) { Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; } @@ -828,16 +828,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void UsingKeyword(bool topLevel) { Assert(CSharpKeyword.Using); - var block = new Block(CurrentSymbol, CurrentStart); + var block = new Block(CurrentToken, CurrentStart); AcceptAndMoveNext(); AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true)); - if (At(CSharpSymbolType.LeftParenthesis)) + if (At(CSharpTokenType.LeftParenthesis)) { // using ( ==> Using Statement UsingStatement(block); } - else if (At(CSharpSymbolType.Identifier) || At(CSharpKeyword.Static)) + else if (At(CSharpTokenType.Identifier) || At(CSharpKeyword.Static)) { // using Identifier ==> Using Declaration if (!topLevel) @@ -865,16 +865,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Context.Builder.CurrentBlock.Type = BlockKindInternal.Directive; var start = CurrentStart; - if (At(CSharpSymbolType.Identifier)) + if (At(CSharpTokenType.Identifier)) { // non-static using NamespaceOrTypeName(); var whitespace = ReadWhile(IsSpacingToken(includeNewLines: true, includeComments: true)); - if (At(CSharpSymbolType.Assign)) + if (At(CSharpTokenType.Assign)) { // Alias Accept(whitespace); - Assert(CSharpSymbolType.Assign); + Assert(CSharpTokenType.Assign); AcceptAndMoveNext(); AcceptWhile(IsSpacingToken(includeNewLines: true, includeComments: true)); @@ -898,13 +898,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.AnyExceptNewline; Span.ChunkGenerator = new AddImportChunkGenerator(new LocationTagged( - string.Concat(Span.Symbols.Skip(1).Select(s => s.Content)), + string.Concat(Span.Tokens.Skip(1).Select(s => s.Content)), start)); // Optional ";" if (EnsureCurrent()) { - Optional(CSharpSymbolType.Semicolon); + Optional(CSharpTokenType.Semicolon); } } @@ -920,15 +920,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var tokens = ReadWhile(token => { var type = token.Type; - if ((expectingDot && type == CSharpSymbolType.Dot) || - (!expectingDot && type == CSharpSymbolType.Identifier)) + if ((expectingDot && type == CSharpTokenType.Dot) || + (!expectingDot && type == CSharpTokenType.Identifier)) { expectingDot = !expectingDot; return true; } - if (type != CSharpSymbolType.WhiteSpace && - type != CSharpSymbolType.NewLine) + if (type != CSharpTokenType.WhiteSpace && + type != CSharpTokenType.NewLine) { expectingDot = false; currentIdentifierLength += token.Content.Length; @@ -966,69 +966,69 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected bool NamespaceOrTypeName() { - if (Optional(CSharpSymbolType.LeftParenthesis)) + if (Optional(CSharpTokenType.LeftParenthesis)) { - while (!Optional(CSharpSymbolType.RightParenthesis) && !EndOfFile) + while (!Optional(CSharpTokenType.RightParenthesis) && !EndOfFile) { - Optional(CSharpSymbolType.WhiteSpace); + Optional(CSharpTokenType.WhiteSpace); if (!NamespaceOrTypeName()) { return false; } - Optional(CSharpSymbolType.WhiteSpace); - Optional(CSharpSymbolType.Identifier); - Optional(CSharpSymbolType.WhiteSpace); - Optional(CSharpSymbolType.Comma); + Optional(CSharpTokenType.WhiteSpace); + Optional(CSharpTokenType.Identifier); + Optional(CSharpTokenType.WhiteSpace); + Optional(CSharpTokenType.Comma); } - if (At(CSharpSymbolType.WhiteSpace) && NextIs(CSharpSymbolType.QuestionMark)) + if (At(CSharpTokenType.WhiteSpace) && NextIs(CSharpTokenType.QuestionMark)) { // Only accept the whitespace if we are going to consume the next token. AcceptAndMoveNext(); } - Optional(CSharpSymbolType.QuestionMark); // Nullable + Optional(CSharpTokenType.QuestionMark); // Nullable return true; } - else if (Optional(CSharpSymbolType.Identifier) || Optional(CSharpSymbolType.Keyword)) + else if (Optional(CSharpTokenType.Identifier) || Optional(CSharpTokenType.Keyword)) { - if (Optional(CSharpSymbolType.DoubleColon)) + if (Optional(CSharpTokenType.DoubleColon)) { - if (!Optional(CSharpSymbolType.Identifier)) + if (!Optional(CSharpTokenType.Identifier)) { - Optional(CSharpSymbolType.Keyword); + Optional(CSharpTokenType.Keyword); } } - if (At(CSharpSymbolType.LessThan)) + if (At(CSharpTokenType.LessThan)) { TypeArgumentList(); } - if (Optional(CSharpSymbolType.Dot)) + if (Optional(CSharpTokenType.Dot)) { NamespaceOrTypeName(); } - if (At(CSharpSymbolType.WhiteSpace) && NextIs(CSharpSymbolType.QuestionMark)) + if (At(CSharpTokenType.WhiteSpace) && NextIs(CSharpTokenType.QuestionMark)) { // Only accept the whitespace if we are going to consume the next token. AcceptAndMoveNext(); } - Optional(CSharpSymbolType.QuestionMark); // Nullable + Optional(CSharpTokenType.QuestionMark); // Nullable - if (At(CSharpSymbolType.WhiteSpace) && NextIs(CSharpSymbolType.LeftBracket)) + if (At(CSharpTokenType.WhiteSpace) && NextIs(CSharpTokenType.LeftBracket)) { // Only accept the whitespace if we are going to consume the next token. AcceptAndMoveNext(); } - while (At(CSharpSymbolType.LeftBracket)) + while (At(CSharpTokenType.LeftBracket)) { Balance(BalancingModes.None); - Optional(CSharpSymbolType.RightBracket); + Optional(CSharpTokenType.RightBracket); } return true; } @@ -1040,14 +1040,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void TypeArgumentList() { - Assert(CSharpSymbolType.LessThan); + Assert(CSharpTokenType.LessThan); Balance(BalancingModes.None); - Optional(CSharpSymbolType.GreaterThan); + Optional(CSharpTokenType.GreaterThan); } private void UsingStatement(Block block) { - Assert(CSharpSymbolType.LeftParenthesis); + Assert(CSharpTokenType.LeftParenthesis); // Parse condition if (AcceptCondition()) @@ -1136,7 +1136,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return; } - var block = new Block(CurrentSymbol, CurrentStart); + var block = new Block(CurrentToken, CurrentStart); AcceptAndMoveNext(); AcceptWhile(IsSpacingToken(includeNewLines: true, includeComments: true)); @@ -1159,13 +1159,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!EndOfFile) { // Check for "{" to make sure we're at a block - if (!At(CSharpSymbolType.LeftBrace)) + if (!At(CSharpTokenType.LeftBrace)) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), - Language.GetSample(CSharpSymbolType.LeftBrace), - CurrentSymbol.Content)); + new SourceSpan(CurrentStart, CurrentToken.Content.Length), + Language.GetSample(CSharpTokenType.LeftBrace), + CurrentToken.Content)); } // Parse the statement and then we're done @@ -1175,8 +1175,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void UnconditionalBlock() { - Assert(CSharpSymbolType.Keyword); - var block = new Block(CurrentSymbol, CurrentStart); + Assert(CSharpTokenType.Keyword); + var block = new Block(CurrentToken, CurrentStart); AcceptAndMoveNext(); AcceptWhile(IsSpacingToken(includeNewLines: true, includeComments: true)); ExpectCodeBlock(block); @@ -1186,22 +1186,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Assert(CSharpKeyword.Catch); - var block = new Block(CurrentSymbol, CurrentStart); + var block = new Block(CurrentToken, CurrentStart); // Accept "catch" AcceptAndMoveNext(); - AcceptWhile(IsValidStatementSpacingSymbol); + AcceptWhile(IsValidStatementSpacingToken); // Parse the catch condition if present. If not present, let the C# compiler complain. if (AcceptCondition()) { - AcceptWhile(IsValidStatementSpacingSymbol); + AcceptWhile(IsValidStatementSpacingToken); if (At(CSharpKeyword.When)) { // Accept "when". AcceptAndMoveNext(); - AcceptWhile(IsValidStatementSpacingSymbol); + AcceptWhile(IsValidStatementSpacingToken); // Parse the filter condition if present. If not present, let the C# compiler complain. if (!AcceptCondition()) @@ -1210,7 +1210,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return; } - AcceptWhile(IsValidStatementSpacingSymbol); + AcceptWhile(IsValidStatementSpacingToken); } ExpectCodeBlock(block); @@ -1219,8 +1219,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void ConditionalBlock(bool topLevel) { - Assert(CSharpSymbolType.Keyword); - var block = new Block(CurrentSymbol, CurrentStart); + Assert(CSharpTokenType.Keyword); + var block = new Block(CurrentToken, CurrentStart); ConditionalBlock(block); if (topLevel) { @@ -1243,16 +1243,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private bool AcceptCondition() { - if (At(CSharpSymbolType.LeftParenthesis)) + if (At(CSharpTokenType.LeftParenthesis)) { var complete = Balance(BalancingModes.BacktrackOnFailure | BalancingModes.AllowCommentsAndTemplates); if (!complete) { - AcceptUntil(CSharpSymbolType.NewLine); + AcceptUntil(CSharpTokenType.NewLine); } else { - Optional(CSharpSymbolType.RightParenthesis); + Optional(CSharpTokenType.RightParenthesis); } return complete; } @@ -1280,16 +1280,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return; } - var type = CurrentSymbol.Type; + var type = CurrentToken.Type; var loc = CurrentStart; // Both cases @: and @:: are triggered as markup, second colon in second case will be triggered as a plain text - var isSingleLineMarkup = type == CSharpSymbolType.Transition && - (NextIs(CSharpSymbolType.Colon, CSharpSymbolType.DoubleColon)); + var isSingleLineMarkup = type == CSharpTokenType.Transition && + (NextIs(CSharpTokenType.Colon, CSharpTokenType.DoubleColon)); var isMarkup = isSingleLineMarkup || - type == CSharpSymbolType.LessThan || - (type == CSharpSymbolType.Transition && NextIs(CSharpSymbolType.LessThan)); + type == CSharpTokenType.LessThan || + (type == CSharpTokenType.Transition && NextIs(CSharpTokenType.LessThan)); if (Context.DesignTimeMode || !isMarkup) { @@ -1301,14 +1301,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } else { - var nextSymbol = Lookahead(1); + var nextToken = Lookahead(1); // MARKUP owns whitespace EXCEPT in DesignTimeMode. PutCurrentBack(); // Put back the whitespace unless it precedes a '' tag. - if (nextSymbol != null && - !string.Equals(nextSymbol.Content, SyntaxConstants.TextTagName, StringComparison.Ordinal)) + if (nextToken != null && + !string.Equals(nextToken.Content, SyntaxConstants.TextTagName, StringComparison.Ordinal)) { PutBack(lastWhitespace); } @@ -1321,7 +1321,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (isMarkup) { - if (type == CSharpSymbolType.Transition && !isSingleLineMarkup) + if (type == CSharpTokenType.Transition && !isSingleLineMarkup) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( @@ -1330,8 +1330,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Markup block Output(SpanKindInternal.Code); - if (Context.DesignTimeMode && CurrentSymbol != null && - (CurrentSymbol.Type == CSharpSymbolType.LessThan || CurrentSymbol.Type == CSharpSymbolType.Transition)) + if (Context.DesignTimeMode && CurrentToken != null && + (CurrentToken.Type == CSharpTokenType.LessThan || CurrentToken.Type == CSharpTokenType.Transition)) { PutCurrentBack(); } @@ -1344,33 +1344,33 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - private void HandleStatement(Block block, CSharpSymbolType type) + private void HandleStatement(Block block, CSharpTokenType type) { switch (type) { - case CSharpSymbolType.RazorCommentTransition: + case CSharpTokenType.RazorCommentTransition: Output(SpanKindInternal.Code); RazorComment(); Statement(block); break; - case CSharpSymbolType.LeftBrace: + case CSharpTokenType.LeftBrace: // Verbatim Block block = block ?? new Block(Resources.BlockName_Code, CurrentStart); AcceptAndMoveNext(); CodeBlock(block); break; - case CSharpSymbolType.Keyword: + case CSharpTokenType.Keyword: // Keyword block HandleKeyword(false, StandardStatement); break; - case CSharpSymbolType.Transition: + case CSharpTokenType.Transition: // Embedded Expression block EmbeddedExpression(); break; - case CSharpSymbolType.RightBrace: + case CSharpTokenType.RightBrace: // Possible end of Code Block, just run the continuation break; - case CSharpSymbolType.Comment: + case CSharpTokenType.Comment: AcceptAndMoveNext(); break; default: @@ -1383,11 +1383,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void EmbeddedExpression() { // First, verify the type of the block - Assert(CSharpSymbolType.Transition); - var transition = CurrentSymbol; + Assert(CSharpTokenType.Transition); + var transition = CurrentToken; NextToken(); - if (At(CSharpSymbolType.Transition)) + if (At(CSharpTokenType.Transition)) { // Escaped "@" Output(SpanKindInternal.Code); @@ -1397,14 +1397,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Span.ChunkGenerator = SpanChunkGenerator.Null; Output(SpanKindInternal.Code); - Assert(CSharpSymbolType.Transition); + Assert(CSharpTokenType.Transition); AcceptAndMoveNext(); StandardStatement(); } else { // Throw errors as necessary, but continue parsing - if (At(CSharpSymbolType.LeftBrace)) + if (At(CSharpTokenType.LeftBrace)) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_UnexpectedNestedCodeBlock( @@ -1416,7 +1416,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy PutBack(transition); // Before exiting, add a marker span if necessary - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); NestedBlock(); } @@ -1427,49 +1427,49 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy while (!EndOfFile) { var bookmark = CurrentStart.AbsoluteIndex; - var read = ReadWhile(sym => - sym.Type != CSharpSymbolType.Semicolon && - sym.Type != CSharpSymbolType.RazorCommentTransition && - sym.Type != CSharpSymbolType.Transition && - sym.Type != CSharpSymbolType.LeftBrace && - sym.Type != CSharpSymbolType.LeftParenthesis && - sym.Type != CSharpSymbolType.LeftBracket && - sym.Type != CSharpSymbolType.RightBrace); + var read = ReadWhile(token => + token.Type != CSharpTokenType.Semicolon && + token.Type != CSharpTokenType.RazorCommentTransition && + token.Type != CSharpTokenType.Transition && + token.Type != CSharpTokenType.LeftBrace && + token.Type != CSharpTokenType.LeftParenthesis && + token.Type != CSharpTokenType.LeftBracket && + token.Type != CSharpTokenType.RightBrace); - if (At(CSharpSymbolType.LeftBrace) || - At(CSharpSymbolType.LeftParenthesis) || - At(CSharpSymbolType.LeftBracket)) + if (At(CSharpTokenType.LeftBrace) || + At(CSharpTokenType.LeftParenthesis) || + At(CSharpTokenType.LeftBracket)) { Accept(read); if (Balance(BalancingModes.AllowCommentsAndTemplates | BalancingModes.BacktrackOnFailure)) { - Optional(CSharpSymbolType.RightBrace); + Optional(CSharpTokenType.RightBrace); } else { // Recovery - AcceptUntil(CSharpSymbolType.LessThan, CSharpSymbolType.RightBrace); + AcceptUntil(CSharpTokenType.LessThan, CSharpTokenType.RightBrace); return; } } - else if (At(CSharpSymbolType.Transition) && (NextIs(CSharpSymbolType.LessThan, CSharpSymbolType.Colon))) + else if (At(CSharpTokenType.Transition) && (NextIs(CSharpTokenType.LessThan, CSharpTokenType.Colon))) { Accept(read); Output(SpanKindInternal.Code); Template(); } - else if (At(CSharpSymbolType.RazorCommentTransition)) + else if (At(CSharpTokenType.RazorCommentTransition)) { Accept(read); RazorComment(); } - else if (At(CSharpSymbolType.Semicolon)) + else if (At(CSharpTokenType.Semicolon)) { Accept(read); AcceptAndMoveNext(); return; } - else if (At(CSharpSymbolType.RightBrace)) + else if (At(CSharpTokenType.RightBrace)) { Accept(read); return; @@ -1478,7 +1478,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Context.Source.Position = bookmark; NextToken(); - AcceptUntil(CSharpSymbolType.LessThan, CSharpSymbolType.LeftBrace, CSharpSymbolType.RightBrace); + AcceptUntil(CSharpTokenType.LessThan, CSharpTokenType.LeftBrace, CSharpTokenType.RightBrace); return; } } @@ -1492,7 +1492,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void CodeBlock(bool acceptTerminatingBrace, Block block) { EnsureCurrent(); - while (!EndOfFile && !At(CSharpSymbolType.RightBrace)) + while (!EndOfFile && !At(CSharpTokenType.RightBrace)) { // Parse a statement, then return here Statement(); @@ -1507,7 +1507,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } else if (acceptTerminatingBrace) { - Assert(CSharpSymbolType.RightBrace); + Assert(CSharpTokenType.RightBrace); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; AcceptAndMoveNext(); } @@ -1515,8 +1515,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void HandleKeyword(bool topLevel, Action fallback) { - Debug.Assert(CurrentSymbol.Type == CSharpSymbolType.Keyword && CurrentSymbol.Keyword != null); - if (_keywordParsers.TryGetValue(CurrentSymbol.Keyword.Value, out var handler)) + Debug.Assert(CurrentToken.Type == CSharpTokenType.Keyword && CurrentToken.Keyword != null); + if (_keywordParsers.TryGetValue(CurrentToken.Keyword.Value, out var handler)) { handler(topLevel); } @@ -1526,12 +1526,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - private IEnumerable SkipToNextImportantToken() + private IEnumerable SkipToNextImportantToken() { while (!EndOfFile) { var whitespace = ReadWhile(IsSpacingToken(includeNewLines: true, includeComments: true)); - if (At(CSharpSymbolType.RazorCommentTransition)) + if (At(CSharpTokenType.RazorCommentTransition)) { Accept(whitespace); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Any; @@ -1542,13 +1542,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return whitespace; } } - return Enumerable.Empty(); + return Enumerable.Empty(); } // Common code for Parsers, but FxCop REALLY doesn't like it in the base class.. moving it here for now. protected override void OutputSpanBeforeRazorComment() { - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); Output(SpanKindInternal.Code); } @@ -1610,7 +1610,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!char.IsWhiteSpace(@char)) { - var currentDirective = CurrentSymbol.Content; + var currentDirective = CurrentToken.Content; Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( new SourceSpan(CurrentStart, currentDirective.Length), currentDirective)); @@ -1644,13 +1644,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy for (var i = 0; i < descriptor.Tokens.Count; i++) { - if (!At(CSharpSymbolType.WhiteSpace) && - !At(CSharpSymbolType.NewLine) && + if (!At(CSharpTokenType.WhiteSpace) && + !At(CSharpTokenType.NewLine) && !EndOfFile) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); + new SourceSpan(CurrentStart, CurrentToken.Content.Length), descriptor.Directive)); return; } @@ -1664,10 +1664,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Span.ChunkGenerator = SpanChunkGenerator.Null; Output(SpanKindInternal.Code, AcceptedCharactersInternal.WhiteSpace); - if (EndOfFile || At(CSharpSymbolType.NewLine)) + if (EndOfFile || At(CSharpTokenType.NewLine)) { - // Add a marker symbol to provide CSharp intellisense when we start typing the directive token. - AddMarkerSymbolIfNecessary(); + // Add a marker token to provide CSharp intellisense when we start typing the directive token. + AddMarkerTokenIfNecessary(); Span.ChunkGenerator = new DirectiveTokenChunkGenerator(tokenDescriptor); Span.EditHandler = new DirectiveTokenEditHandler(Language.TokenizeString); Output(SpanKindInternal.Code, AcceptedCharactersInternal.NonWhiteSpace); @@ -1679,7 +1679,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Output(SpanKindInternal.Markup, AcceptedCharactersInternal.WhiteSpace); } - if (tokenDescriptor.Optional && (EndOfFile || At(CSharpSymbolType.NewLine))) + if (tokenDescriptor.Optional && (EndOfFile || At(CSharpTokenType.NewLine))) { break; } @@ -1700,7 +1700,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_DirectiveExpectsTypeName( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); + new SourceSpan(CurrentStart, CurrentToken.Content.Length), descriptor.Directive)); return; } @@ -1718,7 +1718,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy break; case DirectiveTokenKind.Member: - if (At(CSharpSymbolType.Identifier)) + if (At(CSharpTokenType.Identifier)) { AcceptAndMoveNext(); } @@ -1726,13 +1726,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); + new SourceSpan(CurrentStart, CurrentToken.Content.Length), descriptor.Directive)); return; } break; case DirectiveTokenKind.String: - if (At(CSharpSymbolType.StringLiteral) && CurrentSymbol.Errors.Count == 0) + if (At(CSharpTokenType.StringLiteral) && CurrentToken.Errors.Count == 0) { AcceptAndMoveNext(); } @@ -1740,7 +1740,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); + new SourceSpan(CurrentStart, CurrentToken.Content.Length), descriptor.Directive)); return; } break; @@ -1759,13 +1759,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy case DirectiveKind.SingleLine: Output(SpanKindInternal.None, AcceptedCharactersInternal.WhiteSpace); - Optional(CSharpSymbolType.Semicolon); + Optional(CSharpTokenType.Semicolon); Span.ChunkGenerator = SpanChunkGenerator.Null; Output(SpanKindInternal.MetaCode, AcceptedCharactersInternal.WhiteSpace); AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true)); - if (At(CSharpSymbolType.NewLine)) + if (At(CSharpTokenType.NewLine)) { AcceptAndMoveNext(); } @@ -1773,7 +1773,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), + new SourceSpan(CurrentStart, CurrentToken.Content.Length), descriptor.Directive, Resources.ErrorComponent_Newline)); } @@ -1816,9 +1816,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDirectiveBlock(descriptor, parseChildren: (startingBraceLocation) => { NextToken(); - Balance(BalancingModes.NoErrorOnFailure, CSharpSymbolType.LeftBrace, CSharpSymbolType.RightBrace, startingBraceLocation); + Balance(BalancingModes.NoErrorOnFailure, CSharpTokenType.LeftBrace, CSharpTokenType.RightBrace, startingBraceLocation); Span.ChunkGenerator = new StatementChunkGenerator(); + var existingEditHandler = Span.EditHandler; + Span.EditHandler = new CodeBlockEditHandler(Language.TokenizeString); + + AddMarkerTokenIfNecessary(); + Output(SpanKindInternal.Code); + + Span.EditHandler = existingEditHandler; }); break; } @@ -1861,25 +1868,25 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( new SourceSpan(CurrentStart, contentLength: 1 /* { */), descriptor.Directive, "{")); } - else if (!At(CSharpSymbolType.LeftBrace)) + else if (!At(CSharpTokenType.LeftBrace)) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive, "{")); + new SourceSpan(CurrentStart, CurrentToken.Content.Length), descriptor.Directive, "{")); } else { var editHandler = new AutoCompleteEditHandler(Language.TokenizeString, autoCompleteAtEndOfSpan: true); Span.EditHandler = editHandler; var startingBraceLocation = CurrentStart; - Accept(CurrentSymbol); + Accept(CurrentToken); Span.ChunkGenerator = SpanChunkGenerator.Null; Output(SpanKindInternal.MetaCode, AcceptedCharactersInternal.None); parseChildren(startingBraceLocation); Span.ChunkGenerator = SpanChunkGenerator.Null; - if (!Optional(CSharpSymbolType.RightBrace)) + if (!Optional(CSharpTokenType.RightBrace)) { editHandler.AutoCompleteString = "}"; Context.ErrorSink.OnError( @@ -1975,9 +1982,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Ex: @addTagHelper "*, Microsoft.AspNetCore.CoolLibrary" // ^ ^ // Start End - if (Span.Symbols.Count == 1 && (Span.Symbols[0] as CSharpSymbol)?.Type == CSharpSymbolType.StringLiteral) + if (Span.Tokens.Count == 1 && (Span.Tokens[0] as CSharpToken)?.Type == CSharpTokenType.StringLiteral) { - offset += Span.Symbols[0].Content.IndexOf(directiveText, StringComparison.Ordinal); + offset += Span.Tokens[0].Content.IndexOf(directiveText, StringComparison.Ordinal); // This is safe because inside one of these directives all of the text needs to be on the // same line. @@ -2074,8 +2081,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Conditional("DEBUG")] protected void AssertDirective(string directive) { - Debug.Assert(CurrentSymbol.Type == CSharpSymbolType.Identifier || CurrentSymbol.Type == CSharpSymbolType.Keyword); - Debug.Assert(string.Equals(CurrentSymbol.Content, directive, StringComparison.Ordinal)); + Debug.Assert(CurrentToken.Type == CSharpTokenType.Identifier || CurrentToken.Type == CSharpTokenType.Keyword); + Debug.Assert(string.Equals(CurrentToken.Content, directive, StringComparison.Ordinal)); } private void TagHelperDirective(string keyword, Func, ISpanChunkGenerator> chunkGeneratorFactory) @@ -2101,18 +2108,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var keywordLength = Span.End.AbsoluteIndex - Span.Start.AbsoluteIndex; - var foundWhitespace = At(CSharpSymbolType.WhiteSpace); + var foundWhitespace = At(CSharpTokenType.WhiteSpace); // If we found whitespace then any content placed within the whitespace MAY cause a destructive change // to the document. We can't accept it. var acceptedCharacters = foundWhitespace ? AcceptedCharactersInternal.None : AcceptedCharactersInternal.AnyExceptNewline; Output(SpanKindInternal.MetaCode, acceptedCharacters); - AcceptWhile(CSharpSymbolType.WhiteSpace); + AcceptWhile(CSharpTokenType.WhiteSpace); Span.ChunkGenerator = SpanChunkGenerator.Null; Output(SpanKindInternal.Markup, acceptedCharacters); - if (EndOfFile || At(CSharpSymbolType.NewLine)) + if (EndOfFile || At(CSharpTokenType.NewLine)) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( @@ -2127,10 +2134,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Parse to the end of the line. Essentially accepts anything until end of line, comments, invalid code // etc. - AcceptUntil(CSharpSymbolType.NewLine); + AcceptUntil(CSharpTokenType.NewLine); // Pull out the value and remove whitespaces and optional quotes - var rawValue = string.Concat(Span.Symbols.Select(s => s.Content)).Trim(); + var rawValue = string.Concat(Span.Tokens.Select(s => s.Content)).Trim(); var startsWithQuote = rawValue.StartsWith("\"", StringComparison.Ordinal); var endsWithQuote = rawValue.EndsWith("\"", StringComparison.Ordinal); @@ -2163,21 +2170,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Start = start; } - public Block(CSharpSymbol symbol, SourceLocation start) - : this(GetName(symbol), start) + public Block(CSharpToken token, SourceLocation start) + : this(GetName(token), start) { } public string Name { get; set; } public SourceLocation Start { get; set; } - private static string GetName(CSharpSymbol sym) + private static string GetName(CSharpToken token) { - if (sym.Type == CSharpSymbolType.Keyword) + if (token.Type == CSharpTokenType.Keyword) { - return CSharpLanguageCharacteristics.GetKeyword(sym.Keyword.Value); + return CSharpLanguageCharacteristics.GetKeyword(token.Keyword.Value); } - return sym.Content; + return token.Content; } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs index 44ce3a89ce..70d4bfeda1 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs @@ -6,61 +6,61 @@ using System.Diagnostics; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal class CSharpLanguageCharacteristics : LanguageCharacteristics + internal class CSharpLanguageCharacteristics : LanguageCharacteristics { private static readonly CSharpLanguageCharacteristics _instance = new CSharpLanguageCharacteristics(); - private static Dictionary _symbolSamples = new Dictionary() + private static Dictionary _tokenSamples = new Dictionary() { - { CSharpSymbolType.Arrow, "->" }, - { CSharpSymbolType.Minus, "-" }, - { CSharpSymbolType.Decrement, "--" }, - { CSharpSymbolType.MinusAssign, "-=" }, - { CSharpSymbolType.NotEqual, "!=" }, - { CSharpSymbolType.Not, "!" }, - { CSharpSymbolType.Modulo, "%" }, - { CSharpSymbolType.ModuloAssign, "%=" }, - { CSharpSymbolType.AndAssign, "&=" }, - { CSharpSymbolType.And, "&" }, - { CSharpSymbolType.DoubleAnd, "&&" }, - { CSharpSymbolType.LeftParenthesis, "(" }, - { CSharpSymbolType.RightParenthesis, ")" }, - { CSharpSymbolType.Star, "*" }, - { CSharpSymbolType.MultiplyAssign, "*=" }, - { CSharpSymbolType.Comma, "," }, - { CSharpSymbolType.Dot, "." }, - { CSharpSymbolType.Slash, "/" }, - { CSharpSymbolType.DivideAssign, "/=" }, - { CSharpSymbolType.DoubleColon, "::" }, - { CSharpSymbolType.Colon, ":" }, - { CSharpSymbolType.Semicolon, ";" }, - { CSharpSymbolType.QuestionMark, "?" }, - { CSharpSymbolType.NullCoalesce, "??" }, - { CSharpSymbolType.RightBracket, "]" }, - { CSharpSymbolType.LeftBracket, "[" }, - { CSharpSymbolType.XorAssign, "^=" }, - { CSharpSymbolType.Xor, "^" }, - { CSharpSymbolType.LeftBrace, "{" }, - { CSharpSymbolType.OrAssign, "|=" }, - { CSharpSymbolType.DoubleOr, "||" }, - { CSharpSymbolType.Or, "|" }, - { CSharpSymbolType.RightBrace, "}" }, - { CSharpSymbolType.Tilde, "~" }, - { CSharpSymbolType.Plus, "+" }, - { CSharpSymbolType.PlusAssign, "+=" }, - { CSharpSymbolType.Increment, "++" }, - { CSharpSymbolType.LessThan, "<" }, - { CSharpSymbolType.LessThanEqual, "<=" }, - { CSharpSymbolType.LeftShift, "<<" }, - { CSharpSymbolType.LeftShiftAssign, "<<=" }, - { CSharpSymbolType.Assign, "=" }, - { CSharpSymbolType.Equals, "==" }, - { CSharpSymbolType.GreaterThan, ">" }, - { CSharpSymbolType.GreaterThanEqual, ">=" }, - { CSharpSymbolType.RightShift, ">>" }, - { CSharpSymbolType.RightShiftAssign, ">>=" }, - { CSharpSymbolType.Hash, "#" }, - { CSharpSymbolType.Transition, "@" }, + { CSharpTokenType.Arrow, "->" }, + { CSharpTokenType.Minus, "-" }, + { CSharpTokenType.Decrement, "--" }, + { CSharpTokenType.MinusAssign, "-=" }, + { CSharpTokenType.NotEqual, "!=" }, + { CSharpTokenType.Not, "!" }, + { CSharpTokenType.Modulo, "%" }, + { CSharpTokenType.ModuloAssign, "%=" }, + { CSharpTokenType.AndAssign, "&=" }, + { CSharpTokenType.And, "&" }, + { CSharpTokenType.DoubleAnd, "&&" }, + { CSharpTokenType.LeftParenthesis, "(" }, + { CSharpTokenType.RightParenthesis, ")" }, + { CSharpTokenType.Star, "*" }, + { CSharpTokenType.MultiplyAssign, "*=" }, + { CSharpTokenType.Comma, "," }, + { CSharpTokenType.Dot, "." }, + { CSharpTokenType.Slash, "/" }, + { CSharpTokenType.DivideAssign, "/=" }, + { CSharpTokenType.DoubleColon, "::" }, + { CSharpTokenType.Colon, ":" }, + { CSharpTokenType.Semicolon, ";" }, + { CSharpTokenType.QuestionMark, "?" }, + { CSharpTokenType.NullCoalesce, "??" }, + { CSharpTokenType.RightBracket, "]" }, + { CSharpTokenType.LeftBracket, "[" }, + { CSharpTokenType.XorAssign, "^=" }, + { CSharpTokenType.Xor, "^" }, + { CSharpTokenType.LeftBrace, "{" }, + { CSharpTokenType.OrAssign, "|=" }, + { CSharpTokenType.DoubleOr, "||" }, + { CSharpTokenType.Or, "|" }, + { CSharpTokenType.RightBrace, "}" }, + { CSharpTokenType.Tilde, "~" }, + { CSharpTokenType.Plus, "+" }, + { CSharpTokenType.PlusAssign, "+=" }, + { CSharpTokenType.Increment, "++" }, + { CSharpTokenType.LessThan, "<" }, + { CSharpTokenType.LessThanEqual, "<=" }, + { CSharpTokenType.LeftShift, "<<" }, + { CSharpTokenType.LeftShiftAssign, "<<=" }, + { CSharpTokenType.Assign, "=" }, + { CSharpTokenType.Equals, "==" }, + { CSharpTokenType.GreaterThan, ">" }, + { CSharpTokenType.GreaterThanEqual, ">=" }, + { CSharpTokenType.RightShift, ">>" }, + { CSharpTokenType.RightShiftAssign, ">>=" }, + { CSharpTokenType.Hash, "#" }, + { CSharpTokenType.Transition, "@" }, }; protected CSharpLanguageCharacteristics() @@ -74,96 +74,96 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return new CSharpTokenizer(source); } - protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) + protected override CSharpToken CreateToken(string content, CSharpTokenType type, IReadOnlyList errors) { - return new CSharpSymbol(content, type, errors); + return new CSharpToken(content, type, errors); } - public override string GetSample(CSharpSymbolType type) + public override string GetSample(CSharpTokenType type) { string sample; - if (!_symbolSamples.TryGetValue(type, out sample)) + if (!_tokenSamples.TryGetValue(type, out sample)) { switch (type) { - case CSharpSymbolType.Identifier: - return Resources.CSharpSymbol_Identifier; - case CSharpSymbolType.Keyword: - return Resources.CSharpSymbol_Keyword; - case CSharpSymbolType.IntegerLiteral: - return Resources.CSharpSymbol_IntegerLiteral; - case CSharpSymbolType.NewLine: - return Resources.CSharpSymbol_Newline; - case CSharpSymbolType.WhiteSpace: - return Resources.CSharpSymbol_Whitespace; - case CSharpSymbolType.Comment: - return Resources.CSharpSymbol_Comment; - case CSharpSymbolType.RealLiteral: - return Resources.CSharpSymbol_RealLiteral; - case CSharpSymbolType.CharacterLiteral: - return Resources.CSharpSymbol_CharacterLiteral; - case CSharpSymbolType.StringLiteral: - return Resources.CSharpSymbol_StringLiteral; + case CSharpTokenType.Identifier: + return Resources.CSharpToken_Identifier; + case CSharpTokenType.Keyword: + return Resources.CSharpToken_Keyword; + case CSharpTokenType.IntegerLiteral: + return Resources.CSharpToken_IntegerLiteral; + case CSharpTokenType.NewLine: + return Resources.CSharpToken_Newline; + case CSharpTokenType.WhiteSpace: + return Resources.CSharpToken_Whitespace; + case CSharpTokenType.Comment: + return Resources.CSharpToken_Comment; + case CSharpTokenType.RealLiteral: + return Resources.CSharpToken_RealLiteral; + case CSharpTokenType.CharacterLiteral: + return Resources.CSharpToken_CharacterLiteral; + case CSharpTokenType.StringLiteral: + return Resources.CSharpToken_StringLiteral; default: - return Resources.Symbol_Unknown; + return Resources.Token_Unknown; } } return sample; } - public override CSharpSymbol CreateMarkerSymbol() + public override CSharpToken CreateMarkerToken() { - return new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown); + return new CSharpToken(string.Empty, CSharpTokenType.Unknown); } - public override CSharpSymbolType GetKnownSymbolType(KnownSymbolType type) + public override CSharpTokenType GetKnownTokenType(KnownTokenType type) { switch (type) { - case KnownSymbolType.Identifier: - return CSharpSymbolType.Identifier; - case KnownSymbolType.Keyword: - return CSharpSymbolType.Keyword; - case KnownSymbolType.NewLine: - return CSharpSymbolType.NewLine; - case KnownSymbolType.WhiteSpace: - return CSharpSymbolType.WhiteSpace; - case KnownSymbolType.Transition: - return CSharpSymbolType.Transition; - case KnownSymbolType.CommentStart: - return CSharpSymbolType.RazorCommentTransition; - case KnownSymbolType.CommentStar: - return CSharpSymbolType.RazorCommentStar; - case KnownSymbolType.CommentBody: - return CSharpSymbolType.RazorComment; + case KnownTokenType.Identifier: + return CSharpTokenType.Identifier; + case KnownTokenType.Keyword: + return CSharpTokenType.Keyword; + case KnownTokenType.NewLine: + return CSharpTokenType.NewLine; + case KnownTokenType.WhiteSpace: + return CSharpTokenType.WhiteSpace; + case KnownTokenType.Transition: + return CSharpTokenType.Transition; + case KnownTokenType.CommentStart: + return CSharpTokenType.RazorCommentTransition; + case KnownTokenType.CommentStar: + return CSharpTokenType.RazorCommentStar; + case KnownTokenType.CommentBody: + return CSharpTokenType.RazorComment; default: - return CSharpSymbolType.Unknown; + return CSharpTokenType.Unknown; } } - public override CSharpSymbolType FlipBracket(CSharpSymbolType bracket) + public override CSharpTokenType FlipBracket(CSharpTokenType bracket) { switch (bracket) { - case CSharpSymbolType.LeftBrace: - return CSharpSymbolType.RightBrace; - case CSharpSymbolType.LeftBracket: - return CSharpSymbolType.RightBracket; - case CSharpSymbolType.LeftParenthesis: - return CSharpSymbolType.RightParenthesis; - case CSharpSymbolType.LessThan: - return CSharpSymbolType.GreaterThan; - case CSharpSymbolType.RightBrace: - return CSharpSymbolType.LeftBrace; - case CSharpSymbolType.RightBracket: - return CSharpSymbolType.LeftBracket; - case CSharpSymbolType.RightParenthesis: - return CSharpSymbolType.LeftParenthesis; - case CSharpSymbolType.GreaterThan: - return CSharpSymbolType.LessThan; + case CSharpTokenType.LeftBrace: + return CSharpTokenType.RightBrace; + case CSharpTokenType.LeftBracket: + return CSharpTokenType.RightBracket; + case CSharpTokenType.LeftParenthesis: + return CSharpTokenType.RightParenthesis; + case CSharpTokenType.LessThan: + return CSharpTokenType.GreaterThan; + case CSharpTokenType.RightBrace: + return CSharpTokenType.LeftBrace; + case CSharpTokenType.RightBracket: + return CSharpTokenType.LeftBracket; + case CSharpTokenType.RightParenthesis: + return CSharpTokenType.LeftParenthesis; + case CSharpTokenType.GreaterThan: + return CSharpTokenType.LessThan; default: Debug.Fail("FlipBracket must be called with a bracket character"); - return CSharpSymbolType.Unknown; + return CSharpTokenType.Unknown; } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpToken.cs similarity index 83% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs rename to src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpToken.cs index 21cd94915d..c928f0880e 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpToken.cs @@ -6,11 +6,11 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal class CSharpSymbol : SymbolBase + internal class CSharpToken : TokenBase { - public CSharpSymbol( + public CSharpToken( string content, - CSharpSymbolType type) + CSharpTokenType type) : base(content, type, RazorDiagnostic.EmptyArray) { if (content == null) @@ -19,9 +19,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - public CSharpSymbol( + public CSharpToken( string content, - CSharpSymbolType type, + CSharpTokenType type, IReadOnlyList errors) : base(content, type, errors) { @@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public override bool Equals(object obj) { - var other = obj as CSharpSymbol; + var other = obj as CSharpToken; return base.Equals(other) && other.Keyword == Keyword; } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbolType.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenType.cs similarity index 97% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbolType.cs rename to src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenType.cs index 059d7c48a6..10f3478d6d 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbolType.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenType.cs @@ -3,7 +3,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal enum CSharpSymbolType + internal enum CSharpTokenType { Unknown, Identifier, diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs index a1943070f3..f819e98a3a 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs @@ -8,9 +8,9 @@ using System.Globalization; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal class CSharpTokenizer : Tokenizer + internal class CSharpTokenizer : Tokenizer { - private Dictionary> _operatorHandlers; + private Dictionary> _operatorHandlers; private static readonly Dictionary _keywords = new Dictionary(StringComparer.Ordinal) { @@ -100,31 +100,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { base.CurrentState = StartState; - _operatorHandlers = new Dictionary>() + _operatorHandlers = new Dictionary>() { { '-', MinusOperator }, { '<', LessThanOperator }, { '>', GreaterThanOperator }, - { '&', CreateTwoCharOperatorHandler(CSharpSymbolType.And, '=', CSharpSymbolType.AndAssign, '&', CSharpSymbolType.DoubleAnd) }, - { '|', CreateTwoCharOperatorHandler(CSharpSymbolType.Or, '=', CSharpSymbolType.OrAssign, '|', CSharpSymbolType.DoubleOr) }, - { '+', CreateTwoCharOperatorHandler(CSharpSymbolType.Plus, '=', CSharpSymbolType.PlusAssign, '+', CSharpSymbolType.Increment) }, - { '=', CreateTwoCharOperatorHandler(CSharpSymbolType.Assign, '=', CSharpSymbolType.Equals, '>', CSharpSymbolType.GreaterThanEqual) }, - { '!', CreateTwoCharOperatorHandler(CSharpSymbolType.Not, '=', CSharpSymbolType.NotEqual) }, - { '%', CreateTwoCharOperatorHandler(CSharpSymbolType.Modulo, '=', CSharpSymbolType.ModuloAssign) }, - { '*', CreateTwoCharOperatorHandler(CSharpSymbolType.Star, '=', CSharpSymbolType.MultiplyAssign) }, - { ':', CreateTwoCharOperatorHandler(CSharpSymbolType.Colon, ':', CSharpSymbolType.DoubleColon) }, - { '?', CreateTwoCharOperatorHandler(CSharpSymbolType.QuestionMark, '?', CSharpSymbolType.NullCoalesce) }, - { '^', CreateTwoCharOperatorHandler(CSharpSymbolType.Xor, '=', CSharpSymbolType.XorAssign) }, - { '(', () => CSharpSymbolType.LeftParenthesis }, - { ')', () => CSharpSymbolType.RightParenthesis }, - { '{', () => CSharpSymbolType.LeftBrace }, - { '}', () => CSharpSymbolType.RightBrace }, - { '[', () => CSharpSymbolType.LeftBracket }, - { ']', () => CSharpSymbolType.RightBracket }, - { ',', () => CSharpSymbolType.Comma }, - { ';', () => CSharpSymbolType.Semicolon }, - { '~', () => CSharpSymbolType.Tilde }, - { '#', () => CSharpSymbolType.Hash } + { '&', CreateTwoCharOperatorHandler(CSharpTokenType.And, '=', CSharpTokenType.AndAssign, '&', CSharpTokenType.DoubleAnd) }, + { '|', CreateTwoCharOperatorHandler(CSharpTokenType.Or, '=', CSharpTokenType.OrAssign, '|', CSharpTokenType.DoubleOr) }, + { '+', CreateTwoCharOperatorHandler(CSharpTokenType.Plus, '=', CSharpTokenType.PlusAssign, '+', CSharpTokenType.Increment) }, + { '=', CreateTwoCharOperatorHandler(CSharpTokenType.Assign, '=', CSharpTokenType.Equals, '>', CSharpTokenType.GreaterThanEqual) }, + { '!', CreateTwoCharOperatorHandler(CSharpTokenType.Not, '=', CSharpTokenType.NotEqual) }, + { '%', CreateTwoCharOperatorHandler(CSharpTokenType.Modulo, '=', CSharpTokenType.ModuloAssign) }, + { '*', CreateTwoCharOperatorHandler(CSharpTokenType.Star, '=', CSharpTokenType.MultiplyAssign) }, + { ':', CreateTwoCharOperatorHandler(CSharpTokenType.Colon, ':', CSharpTokenType.DoubleColon) }, + { '?', CreateTwoCharOperatorHandler(CSharpTokenType.QuestionMark, '?', CSharpTokenType.NullCoalesce) }, + { '^', CreateTwoCharOperatorHandler(CSharpTokenType.Xor, '=', CSharpTokenType.XorAssign) }, + { '(', () => CSharpTokenType.LeftParenthesis }, + { ')', () => CSharpTokenType.RightParenthesis }, + { '{', () => CSharpTokenType.LeftBrace }, + { '}', () => CSharpTokenType.RightBrace }, + { '[', () => CSharpTokenType.LeftBracket }, + { ']', () => CSharpTokenType.RightBracket }, + { ',', () => CSharpTokenType.Comma }, + { ';', () => CSharpTokenType.Semicolon }, + { '~', () => CSharpTokenType.Tilde }, + { '#', () => CSharpTokenType.Hash } }; } @@ -132,11 +132,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private new CSharpTokenizerState? CurrentState => (CSharpTokenizerState?)base.CurrentState; - public override CSharpSymbolType RazorCommentType => CSharpSymbolType.RazorComment; + public override CSharpTokenType RazorCommentType => CSharpTokenType.RazorComment; - public override CSharpSymbolType RazorCommentTransitionType => CSharpSymbolType.RazorCommentTransition; + public override CSharpTokenType RazorCommentTransitionType => CSharpTokenType.RazorCommentTransition; - public override CSharpSymbolType RazorCommentStarType => CSharpSymbolType.RazorCommentStar; + public override CSharpTokenType RazorCommentStarType => CSharpTokenType.RazorCommentStar; protected override StateResult Dispatch() { @@ -160,8 +160,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return RazorCommentBody(); case CSharpTokenizerState.StarAfterRazorCommentBody: return StarAfterRazorCommentBody(); - case CSharpTokenizerState.AtSymbolAfterRazorCommentBody: - return AtSymbolAfterRazorCommentBody(); + case CSharpTokenizerState.AtTokenAfterRazorCommentBody: + return AtTokenAfterRazorCommentBody(); default: Debug.Fail("Invalid TokenizerState"); return default(StateResult); @@ -169,15 +169,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } // Optimize memory allocation by returning constants for the most frequent cases - protected override string GetSymbolContent(CSharpSymbolType type) + protected override string GetTokenContent(CSharpTokenType type) { - var symbolLength = Buffer.Length; + var tokenLength = Buffer.Length; - if (symbolLength == 1) + if (tokenLength == 1) { switch (type) { - case CSharpSymbolType.IntegerLiteral: + case CSharpTokenType.IntegerLiteral: switch (Buffer[0]) { case '0': @@ -202,13 +202,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return "9"; } break; - case CSharpSymbolType.NewLine: + case CSharpTokenType.NewLine: if (Buffer[0] == '\n') { return "\n"; } break; - case CSharpSymbolType.WhiteSpace: + case CSharpTokenType.WhiteSpace: if (Buffer[0] == ' ') { return " "; @@ -218,134 +218,134 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return "\t"; } break; - case CSharpSymbolType.Minus: + case CSharpTokenType.Minus: return "-"; - case CSharpSymbolType.Not: + case CSharpTokenType.Not: return "!"; - case CSharpSymbolType.Modulo: + case CSharpTokenType.Modulo: return "%"; - case CSharpSymbolType.And: + case CSharpTokenType.And: return "&"; - case CSharpSymbolType.LeftParenthesis: + case CSharpTokenType.LeftParenthesis: return "("; - case CSharpSymbolType.RightParenthesis: + case CSharpTokenType.RightParenthesis: return ")"; - case CSharpSymbolType.Star: + case CSharpTokenType.Star: return "*"; - case CSharpSymbolType.Comma: + case CSharpTokenType.Comma: return ","; - case CSharpSymbolType.Dot: + case CSharpTokenType.Dot: return "."; - case CSharpSymbolType.Slash: + case CSharpTokenType.Slash: return "/"; - case CSharpSymbolType.Colon: + case CSharpTokenType.Colon: return ":"; - case CSharpSymbolType.Semicolon: + case CSharpTokenType.Semicolon: return ";"; - case CSharpSymbolType.QuestionMark: + case CSharpTokenType.QuestionMark: return "?"; - case CSharpSymbolType.RightBracket: + case CSharpTokenType.RightBracket: return "]"; - case CSharpSymbolType.LeftBracket: + case CSharpTokenType.LeftBracket: return "["; - case CSharpSymbolType.Xor: + case CSharpTokenType.Xor: return "^"; - case CSharpSymbolType.LeftBrace: + case CSharpTokenType.LeftBrace: return "{"; - case CSharpSymbolType.Or: + case CSharpTokenType.Or: return "|"; - case CSharpSymbolType.RightBrace: + case CSharpTokenType.RightBrace: return "}"; - case CSharpSymbolType.Tilde: + case CSharpTokenType.Tilde: return "~"; - case CSharpSymbolType.Plus: + case CSharpTokenType.Plus: return "+"; - case CSharpSymbolType.LessThan: + case CSharpTokenType.LessThan: return "<"; - case CSharpSymbolType.Assign: + case CSharpTokenType.Assign: return "="; - case CSharpSymbolType.GreaterThan: + case CSharpTokenType.GreaterThan: return ">"; - case CSharpSymbolType.Hash: + case CSharpTokenType.Hash: return "#"; - case CSharpSymbolType.Transition: + case CSharpTokenType.Transition: return "@"; } } - else if (symbolLength == 2) + else if (tokenLength == 2) { switch (type) { - case CSharpSymbolType.NewLine: + case CSharpTokenType.NewLine: return "\r\n"; - case CSharpSymbolType.Arrow: + case CSharpTokenType.Arrow: return "->"; - case CSharpSymbolType.Decrement: + case CSharpTokenType.Decrement: return "--"; - case CSharpSymbolType.MinusAssign: + case CSharpTokenType.MinusAssign: return "-="; - case CSharpSymbolType.NotEqual: + case CSharpTokenType.NotEqual: return "!="; - case CSharpSymbolType.ModuloAssign: + case CSharpTokenType.ModuloAssign: return "%="; - case CSharpSymbolType.AndAssign: + case CSharpTokenType.AndAssign: return "&="; - case CSharpSymbolType.DoubleAnd: + case CSharpTokenType.DoubleAnd: return "&&"; - case CSharpSymbolType.MultiplyAssign: + case CSharpTokenType.MultiplyAssign: return "*="; - case CSharpSymbolType.DivideAssign: + case CSharpTokenType.DivideAssign: return "/="; - case CSharpSymbolType.DoubleColon: + case CSharpTokenType.DoubleColon: return "::"; - case CSharpSymbolType.NullCoalesce: + case CSharpTokenType.NullCoalesce: return "??"; - case CSharpSymbolType.XorAssign: + case CSharpTokenType.XorAssign: return "^="; - case CSharpSymbolType.OrAssign: + case CSharpTokenType.OrAssign: return "|="; - case CSharpSymbolType.DoubleOr: + case CSharpTokenType.DoubleOr: return "||"; - case CSharpSymbolType.PlusAssign: + case CSharpTokenType.PlusAssign: return "+="; - case CSharpSymbolType.Increment: + case CSharpTokenType.Increment: return "++"; - case CSharpSymbolType.LessThanEqual: + case CSharpTokenType.LessThanEqual: return "<="; - case CSharpSymbolType.LeftShift: + case CSharpTokenType.LeftShift: return "<<"; - case CSharpSymbolType.Equals: + case CSharpTokenType.Equals: return "=="; - case CSharpSymbolType.GreaterThanEqual: + case CSharpTokenType.GreaterThanEqual: if (Buffer[0] == '=') { return "=>"; } return ">="; - case CSharpSymbolType.RightShift: + case CSharpTokenType.RightShift: return ">>"; } } - else if (symbolLength == 3) + else if (tokenLength == 3) { switch (type) { - case CSharpSymbolType.LeftShiftAssign: + case CSharpTokenType.LeftShiftAssign: return "<<="; - case CSharpSymbolType.RightShiftAssign: + case CSharpTokenType.RightShiftAssign: return ">>="; } } - return base.GetSymbolContent(type); + return base.GetTokenContent(type); } - protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) + protected override CSharpToken CreateToken(string content, CSharpTokenType type, IReadOnlyList errors) { - return new CSharpSymbol(content, type, errors); + return new CSharpToken(content, type, errors); } private StateResult Data() @@ -359,13 +359,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TakeCurrent(); } - return Stay(EndSymbol(CSharpSymbolType.NewLine)); + return Stay(EndToken(CSharpTokenType.NewLine)); } else if (ParserHelpers.IsWhitespace(CurrentCharacter)) { // CSharp Spec §2.3.3 TakeUntil(c => !ParserHelpers.IsWhitespace(c)); - return Stay(EndSymbol(CSharpSymbolType.WhiteSpace)); + return Stay(EndToken(CSharpTokenType.WhiteSpace)); } else if (IsIdentifierStart(CurrentCharacter)) { @@ -378,7 +378,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy switch (CurrentCharacter) { case '@': - return AtSymbol(); + return AtToken(); case '\'': TakeCurrent(); return Transition(CSharpTokenizerState.QuotedCharacterLiteral); @@ -390,7 +390,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return RealLiteral(); } - return Stay(Single(CSharpSymbolType.Dot)); + return Stay(Single(CSharpTokenType.Dot)); case '/': TakeCurrent(); if (CurrentCharacter == '/') @@ -406,18 +406,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (CurrentCharacter == '=') { TakeCurrent(); - return Stay(EndSymbol(CSharpSymbolType.DivideAssign)); + return Stay(EndToken(CSharpTokenType.DivideAssign)); } else { - return Stay(EndSymbol(CSharpSymbolType.Slash)); + return Stay(EndToken(CSharpTokenType.Slash)); } default: - return Stay(EndSymbol(Operator())); + return Stay(EndToken(Operator())); } } - private StateResult AtSymbol() + private StateResult AtToken() { TakeCurrent(); if (CurrentCharacter == '"') @@ -429,78 +429,78 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return Transition( CSharpTokenizerState.AfterRazorCommentTransition, - EndSymbol(CSharpSymbolType.RazorCommentTransition)); + EndToken(CSharpTokenType.RazorCommentTransition)); } else if (CurrentCharacter == '@') { // Could be escaped comment transition return Transition( CSharpTokenizerState.EscapedRazorCommentTransition, - EndSymbol(CSharpSymbolType.Transition)); + EndToken(CSharpTokenType.Transition)); } - return Stay(EndSymbol(CSharpSymbolType.Transition)); + return Stay(EndToken(CSharpTokenType.Transition)); } private StateResult EscapedRazorCommentTransition() { TakeCurrent(); - return Transition(CSharpTokenizerState.Data, EndSymbol(CSharpSymbolType.Transition)); + return Transition(CSharpTokenizerState.Data, EndToken(CSharpTokenType.Transition)); } - private CSharpSymbolType Operator() + private CSharpTokenType Operator() { var first = CurrentCharacter; TakeCurrent(); - Func handler; + Func handler; if (_operatorHandlers.TryGetValue(first, out handler)) { return handler(); } - return CSharpSymbolType.Unknown; + return CSharpTokenType.Unknown; } - private CSharpSymbolType LessThanOperator() + private CSharpTokenType LessThanOperator() { if (CurrentCharacter == '=') { TakeCurrent(); - return CSharpSymbolType.LessThanEqual; + return CSharpTokenType.LessThanEqual; } - return CSharpSymbolType.LessThan; + return CSharpTokenType.LessThan; } - private CSharpSymbolType GreaterThanOperator() + private CSharpTokenType GreaterThanOperator() { if (CurrentCharacter == '=') { TakeCurrent(); - return CSharpSymbolType.GreaterThanEqual; + return CSharpTokenType.GreaterThanEqual; } - return CSharpSymbolType.GreaterThan; + return CSharpTokenType.GreaterThan; } - private CSharpSymbolType MinusOperator() + private CSharpTokenType MinusOperator() { if (CurrentCharacter == '>') { TakeCurrent(); - return CSharpSymbolType.Arrow; + return CSharpTokenType.Arrow; } else if (CurrentCharacter == '-') { TakeCurrent(); - return CSharpSymbolType.Decrement; + return CSharpTokenType.Decrement; } else if (CurrentCharacter == '=') { TakeCurrent(); - return CSharpSymbolType.MinusAssign; + return CSharpTokenType.MinusAssign; } - return CSharpSymbolType.Minus; + return CSharpTokenType.Minus; } - private Func CreateTwoCharOperatorHandler(CSharpSymbolType typeIfOnlyFirst, char second, CSharpSymbolType typeIfBoth) + private Func CreateTwoCharOperatorHandler(CSharpTokenType typeIfOnlyFirst, char second, CSharpTokenType typeIfBoth) { return () => { @@ -513,7 +513,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; } - private Func CreateTwoCharOperatorHandler(CSharpSymbolType typeIfOnlyFirst, char option1, CSharpSymbolType typeIfOption1, char option2, CSharpSymbolType typeIfOption2) + private Func CreateTwoCharOperatorHandler(CSharpTokenType typeIfOnlyFirst, char option1, CSharpTokenType typeIfOption1, char option2, CSharpTokenType typeIfOption2) { return () => { @@ -550,14 +550,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } - return Transition(CSharpTokenizerState.Data, EndSymbol(CSharpSymbolType.StringLiteral)); + return Transition(CSharpTokenizerState.Data, EndToken(CSharpTokenType.StringLiteral)); } - private StateResult QuotedCharacterLiteral() => QuotedLiteral('\'', CSharpSymbolType.CharacterLiteral); + private StateResult QuotedCharacterLiteral() => QuotedLiteral('\'', CSharpTokenType.CharacterLiteral); - private StateResult QuotedStringLiteral() => QuotedLiteral('\"', CSharpSymbolType.StringLiteral); + private StateResult QuotedStringLiteral() => QuotedLiteral('\"', CSharpTokenType.StringLiteral); - private StateResult QuotedLiteral(char quote, CSharpSymbolType literalType) + private StateResult QuotedLiteral(char quote, CSharpTokenType literalType) { TakeUntil(c => c == '\\' || c == quote || ParserHelpers.IsNewLine(c)); if (CurrentCharacter == '\\') @@ -581,7 +581,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TakeCurrent(); // No-op if at EOF } - return Transition(CSharpTokenizerState.Data, EndSymbol(literalType)); + return Transition(CSharpTokenizerState.Data, EndToken(literalType)); } // CSharp Spec §2.3.2 @@ -594,7 +594,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy RazorDiagnosticFactory.CreateParsing_BlockCommentNotTerminated( new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); - return Transition(CSharpTokenizerState.Data, EndSymbol(CSharpSymbolType.Comment)); + return Transition(CSharpTokenizerState.Data, EndToken(CSharpTokenType.Comment)); } if (CurrentCharacter == '*') { @@ -602,7 +602,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (CurrentCharacter == '/') { TakeCurrent(); - return Transition(CSharpTokenizerState.Data, EndSymbol(CSharpSymbolType.Comment)); + return Transition(CSharpTokenizerState.Data, EndToken(CSharpTokenType.Comment)); } } return Stay(); @@ -612,7 +612,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private StateResult SingleLineComment() { TakeUntil(c => ParserHelpers.IsNewLine(c)); - return Stay(EndSymbol(CSharpSymbolType.Comment)); + return Stay(EndToken(CSharpTokenType.Comment)); } // CSharp Spec §2.4.4 @@ -632,7 +632,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TakeUntil(c => !IsHexDigit(c)); TakeIntegerSuffix(); - return Stay(EndSymbol(CSharpSymbolType.IntegerLiteral)); + return Stay(EndToken(CSharpTokenType.IntegerLiteral)); } private StateResult DecimalLiteral() @@ -650,7 +650,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { TakeIntegerSuffix(); - return Stay(EndSymbol(CSharpSymbolType.IntegerLiteral)); + return Stay(EndToken(CSharpTokenType.IntegerLiteral)); } } @@ -669,7 +669,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TakeCurrent(); } - return Stay(EndSymbol(CSharpSymbolType.RealLiteral)); + return Stay(EndToken(CSharpTokenType.RealLiteral)); } // CSharp Spec §2.4.4.3 @@ -708,27 +708,27 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Debug.Assert(IsIdentifierStart(CurrentCharacter)); TakeCurrent(); TakeUntil(c => !IsIdentifierPart(c)); - CSharpSymbol symbol = null; + CSharpToken token = null; if (HaveContent) { CSharpKeyword keyword; - var type = CSharpSymbolType.Identifier; - var symbolContent = Buffer.ToString(); - if (_keywords.TryGetValue(symbolContent, out keyword)) + var type = CSharpTokenType.Identifier; + var tokenContent = Buffer.ToString(); + if (_keywords.TryGetValue(tokenContent, out keyword)) { - type = CSharpSymbolType.Keyword; + type = CSharpTokenType.Keyword; } - symbol = new CSharpSymbol(symbolContent, type) + token = new CSharpToken(tokenContent, type) { - Keyword = type == CSharpSymbolType.Keyword ? (CSharpKeyword?)keyword : null, + Keyword = type == CSharpTokenType.Keyword ? (CSharpKeyword?)keyword : null, }; Buffer.Clear(); CurrentErrors.Clear(); } - return Stay(symbol); + return Stay(token); } private StateResult Transition(CSharpTokenizerState state) @@ -736,7 +736,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return Transition((int)state, result: null); } - private StateResult Transition(CSharpTokenizerState state, CSharpSymbol result) + private StateResult Transition(CSharpTokenizerState state, CSharpToken result) { return Transition((int)state, result); } @@ -793,7 +793,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy EscapedRazorCommentTransition = RazorCommentTokenizerState.EscapedRazorCommentTransition, RazorCommentBody = RazorCommentTokenizerState.RazorCommentBody, StarAfterRazorCommentBody = RazorCommentTokenizerState.StarAfterRazorCommentBody, - AtSymbolAfterRazorCommentBody = RazorCommentTokenizerState.AtSymbolAfterRazorCommentBody, + AtTokenAfterRazorCommentBody = RazorCommentTokenizerState.AtTokenAfterRazorCommentBody, } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ClassifiedSpanInternal.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ClassifiedSpanInternal.cs new file mode 100644 index 0000000000..93c4331923 --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ClassifiedSpanInternal.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + internal struct ClassifiedSpanInternal + { + public ClassifiedSpanInternal(SourceSpan span, SourceSpan blockSpan, SpanKindInternal spanKind, BlockKindInternal blockKind, AcceptedCharactersInternal acceptedCharacters) + { + Span = span; + BlockSpan = blockSpan; + SpanKind = spanKind; + BlockKind = blockKind; + AcceptedCharacters = acceptedCharacters; + } + + public AcceptedCharactersInternal AcceptedCharacters { get; } + + public BlockKindInternal BlockKind { get; } + + public SourceSpan BlockSpan { get; } + + public SourceSpan Span { get; } + + public SpanKindInternal SpanKind { get; } + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CodeBlockEditHandler.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CodeBlockEditHandler.cs new file mode 100644 index 0000000000..d5ce71c43e --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/CodeBlockEditHandler.cs @@ -0,0 +1,126 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Globalization; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + internal class CodeBlockEditHandler : SpanEditHandler + { + public CodeBlockEditHandler(Func> tokenizer) : base(tokenizer) + { + } + + protected override PartialParseResultInternal CanAcceptChange(Span target, SourceChange change) + { + if (IsAcceptableDeletion(target, change)) + { + return PartialParseResultInternal.Accepted; + } + + if (IsAcceptableReplacement(target, change)) + { + return PartialParseResultInternal.Accepted; + } + + if (IsAcceptableInsertion(change)) + { + return PartialParseResultInternal.Accepted; + } + + return PartialParseResultInternal.Rejected; + } + + // Internal for testing + internal static bool IsAcceptableReplacement(Span target, SourceChange change) + { + if (!change.IsReplace) + { + return false; + } + + if (ContainsInvalidContent(change)) + { + return false; + } + + if (ModifiesInvalidContent(target, change)) + { + return false; + } + + return true; + } + + // Internal for testing + internal static bool IsAcceptableDeletion(Span target, SourceChange change) + { + if (!change.IsDelete) + { + return false; + } + + if (ModifiesInvalidContent(target, change)) + { + return false; + } + + return true; + } + + // Internal for testing + internal static bool ModifiesInvalidContent(Span target, SourceChange change) + { + var relativePosition = change.Span.AbsoluteIndex - target.Start.AbsoluteIndex; + + if (target.Content.IndexOfAny(new[] { '{', '}' }, relativePosition, change.Span.Length) >= 0) + { + return true; + } + + return false; + } + + // Internal for testing + internal static bool IsAcceptableInsertion(SourceChange change) + { + if (!change.IsInsert) + { + return false; + } + + if (ContainsInvalidContent(change)) + { + return false; + } + + return true; + } + + // Internal for testing + internal static bool ContainsInvalidContent(SourceChange change) + { + if (change.NewText.IndexOfAny(new[] { '{', '}' }) >= 0) + { + return true; + } + + return false; + } + + public override string ToString() + { + return string.Format(CultureInfo.InvariantCulture, "{0};CodeBlock", base.ToString()); + } + + public override bool Equals(object obj) + { + return obj is CodeBlockEditHandler other && + base.Equals(other); + } + + public override int GetHashCode() => base.GetHashCode(); + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveCSharpTokenizer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveCSharpTokenizer.cs index d9507e8522..a9befaa302 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveCSharpTokenizer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveCSharpTokenizer.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { _visitedFirstTokenStart = true; } - else if (result.Result != null && _visitedFirstTokenStart && result.Result.Type == CSharpSymbolType.NewLine) + else if (result.Result != null && _visitedFirstTokenStart && result.Result.Type == CSharpTokenType.NewLine) { _visitedFirstTokenLineEnd = true; } @@ -29,34 +29,34 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return result; } - public override CSharpSymbol NextSymbol() + public override CSharpToken NextToken() { // Post-Condition: Buffer should be empty at the start of Next() Debug.Assert(Buffer.Length == 0); - StartSymbol(); + StartToken(); if (EndOfFile || (_visitedFirstTokenStart && _visitedFirstTokenLineEnd)) { return null; } - var symbol = Turn(); + var token = Turn(); // Post-Condition: Buffer should be empty at the end of Next() Debug.Assert(Buffer.Length == 0); - return symbol; + return token; } - private bool IsValidTokenType(CSharpSymbolType type) + private bool IsValidTokenType(CSharpTokenType type) { - return type != CSharpSymbolType.WhiteSpace && - type != CSharpSymbolType.NewLine && - type != CSharpSymbolType.Comment && - type != CSharpSymbolType.RazorComment && - type != CSharpSymbolType.RazorCommentStar && - type != CSharpSymbolType.RazorCommentTransition && - type != CSharpSymbolType.Transition; + return type != CSharpTokenType.WhiteSpace && + type != CSharpTokenType.NewLine && + type != CSharpTokenType.Comment && + type != CSharpTokenType.RazorComment && + type != CSharpTokenType.RazorCommentStar && + type != CSharpTokenType.RazorCommentTransition && + type != CSharpTokenType.Transition; } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveChunkGenerator.cs index c584de9cc8..19a6bad463 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveChunkGenerator.cs @@ -60,14 +60,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // This is used primarily at test time to show an identifiable representation of the chunk generator. - var builder = new StringBuilder("Directive {"); + var builder = new StringBuilder("Directive:{"); builder.Append(Descriptor.Directive); + builder.Append(";"); + builder.Append(Descriptor.Kind); + builder.Append(";"); + builder.Append(Descriptor.Usage); builder.Append("}"); if (Diagnostics.Count > 0) { builder.Append(" ["); - var ids = string.Join(", ", Diagnostics.Select(diagnostic => diagnostic.Id)); + var ids = string.Join(", ", Diagnostics.Select(diagnostic => $"{diagnostic.Id}{diagnostic.Span}")); builder.Append(ids); builder.Append("]"); } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveHtmlTokenizer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveHtmlTokenizer.cs index 5e52dd6ade..034977c758 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveHtmlTokenizer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveHtmlTokenizer.cs @@ -24,33 +24,33 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return result; } - public override HtmlSymbol NextSymbol() + public override HtmlToken NextToken() { // Post-Condition: Buffer should be empty at the start of Next() Debug.Assert(Buffer.Length == 0); - StartSymbol(); + StartToken(); if (EndOfFile || _visitedFirstTokenStart) { return null; } - var symbol = Turn(); + var token = Turn(); // Post-Condition: Buffer should be empty at the end of Next() Debug.Assert(Buffer.Length == 0); - return symbol; + return token; } - private bool IsValidTokenType(HtmlSymbolType type) + private bool IsValidTokenType(HtmlTokenType type) { - return type != HtmlSymbolType.WhiteSpace && - type != HtmlSymbolType.NewLine && - type != HtmlSymbolType.RazorComment && - type != HtmlSymbolType.RazorCommentStar && - type != HtmlSymbolType.RazorCommentTransition && - type != HtmlSymbolType.Transition; + return type != HtmlTokenType.WhiteSpace && + type != HtmlTokenType.NewLine && + type != HtmlTokenType.RazorComment && + type != HtmlTokenType.RazorCommentStar && + type != HtmlTokenType.RazorCommentTransition && + type != HtmlTokenType.Transition; } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveTokenChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveTokenChunkGenerator.cs index b7b2c9fe84..69327ba6e2 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveTokenChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/DirectiveTokenChunkGenerator.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Text; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language.Legacy @@ -15,7 +16,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Descriptor = tokenDescriptor; } - public DirectiveTokenDescriptor Descriptor { get; set; } + public DirectiveTokenDescriptor Descriptor { get; } public override void Accept(ParserVisitor visitor, Span span) { @@ -37,5 +38,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return combiner.CombinedHash; } + + public override string ToString() + { + var builder = new StringBuilder("DirectiveToken {"); + builder.Append(Descriptor.Name); + builder.Append(";"); + builder.Append(Descriptor.Kind); + builder.Append(";Opt:"); + builder.Append(Descriptor.Optional); + builder.Append("}"); + + return builder.ToString(); + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs index cc44a34368..096ae84dc0 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs @@ -6,7 +6,7 @@ using System.Diagnostics; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal class HtmlLanguageCharacteristics : LanguageCharacteristics + internal class HtmlLanguageCharacteristics : LanguageCharacteristics { private static readonly HtmlLanguageCharacteristics _instance = new HtmlLanguageCharacteristics(); @@ -19,50 +19,50 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { return _instance; } } - public override string GetSample(HtmlSymbolType type) + public override string GetSample(HtmlTokenType type) { switch (type) { - case HtmlSymbolType.Text: - return Resources.HtmlSymbol_Text; - case HtmlSymbolType.WhiteSpace: - return Resources.HtmlSymbol_WhiteSpace; - case HtmlSymbolType.NewLine: - return Resources.HtmlSymbol_NewLine; - case HtmlSymbolType.OpenAngle: + case HtmlTokenType.Text: + return Resources.HtmlToken_Text; + case HtmlTokenType.WhiteSpace: + return Resources.HtmlToken_WhiteSpace; + case HtmlTokenType.NewLine: + return Resources.HtmlToken_NewLine; + case HtmlTokenType.OpenAngle: return "<"; - case HtmlSymbolType.Bang: + case HtmlTokenType.Bang: return "!"; - case HtmlSymbolType.ForwardSlash: + case HtmlTokenType.ForwardSlash: return "/"; - case HtmlSymbolType.QuestionMark: + case HtmlTokenType.QuestionMark: return "?"; - case HtmlSymbolType.DoubleHyphen: + case HtmlTokenType.DoubleHyphen: return "--"; - case HtmlSymbolType.LeftBracket: + case HtmlTokenType.LeftBracket: return "["; - case HtmlSymbolType.CloseAngle: + case HtmlTokenType.CloseAngle: return ">"; - case HtmlSymbolType.RightBracket: + case HtmlTokenType.RightBracket: return "]"; - case HtmlSymbolType.Equals: + case HtmlTokenType.Equals: return "="; - case HtmlSymbolType.DoubleQuote: + case HtmlTokenType.DoubleQuote: return "\""; - case HtmlSymbolType.SingleQuote: + case HtmlTokenType.SingleQuote: return "'"; - case HtmlSymbolType.Transition: + case HtmlTokenType.Transition: return "@"; - case HtmlSymbolType.Colon: + case HtmlTokenType.Colon: return ":"; - case HtmlSymbolType.RazorComment: - return Resources.HtmlSymbol_RazorComment; - case HtmlSymbolType.RazorCommentStar: + case HtmlTokenType.RazorComment: + return Resources.HtmlToken_RazorComment; + case HtmlTokenType.RazorCommentStar: return "*"; - case HtmlSymbolType.RazorCommentTransition: + case HtmlTokenType.RazorCommentTransition: return "@"; default: - return Resources.Symbol_Unknown; + return Resources.Token_Unknown; } } @@ -71,57 +71,57 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return new HtmlTokenizer(source); } - public override HtmlSymbolType FlipBracket(HtmlSymbolType bracket) + public override HtmlTokenType FlipBracket(HtmlTokenType bracket) { switch (bracket) { - case HtmlSymbolType.LeftBracket: - return HtmlSymbolType.RightBracket; - case HtmlSymbolType.OpenAngle: - return HtmlSymbolType.CloseAngle; - case HtmlSymbolType.RightBracket: - return HtmlSymbolType.LeftBracket; - case HtmlSymbolType.CloseAngle: - return HtmlSymbolType.OpenAngle; + case HtmlTokenType.LeftBracket: + return HtmlTokenType.RightBracket; + case HtmlTokenType.OpenAngle: + return HtmlTokenType.CloseAngle; + case HtmlTokenType.RightBracket: + return HtmlTokenType.LeftBracket; + case HtmlTokenType.CloseAngle: + return HtmlTokenType.OpenAngle; default: Debug.Fail("FlipBracket must be called with a bracket character"); - return HtmlSymbolType.Unknown; + return HtmlTokenType.Unknown; } } - public override HtmlSymbol CreateMarkerSymbol() + public override HtmlToken CreateMarkerToken() { - return new HtmlSymbol(string.Empty, HtmlSymbolType.Unknown); + return new HtmlToken(string.Empty, HtmlTokenType.Unknown); } - public override HtmlSymbolType GetKnownSymbolType(KnownSymbolType type) + public override HtmlTokenType GetKnownTokenType(KnownTokenType type) { switch (type) { - case KnownSymbolType.CommentStart: - return HtmlSymbolType.RazorCommentTransition; - case KnownSymbolType.CommentStar: - return HtmlSymbolType.RazorCommentStar; - case KnownSymbolType.CommentBody: - return HtmlSymbolType.RazorComment; - case KnownSymbolType.Identifier: - return HtmlSymbolType.Text; - case KnownSymbolType.Keyword: - return HtmlSymbolType.Text; - case KnownSymbolType.NewLine: - return HtmlSymbolType.NewLine; - case KnownSymbolType.Transition: - return HtmlSymbolType.Transition; - case KnownSymbolType.WhiteSpace: - return HtmlSymbolType.WhiteSpace; + case KnownTokenType.CommentStart: + return HtmlTokenType.RazorCommentTransition; + case KnownTokenType.CommentStar: + return HtmlTokenType.RazorCommentStar; + case KnownTokenType.CommentBody: + return HtmlTokenType.RazorComment; + case KnownTokenType.Identifier: + return HtmlTokenType.Text; + case KnownTokenType.Keyword: + return HtmlTokenType.Text; + case KnownTokenType.NewLine: + return HtmlTokenType.NewLine; + case KnownTokenType.Transition: + return HtmlTokenType.Transition; + case KnownTokenType.WhiteSpace: + return HtmlTokenType.WhiteSpace; default: - return HtmlSymbolType.Unknown; + return HtmlTokenType.Unknown; } } - protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) + protected override HtmlToken CreateToken(string content, HtmlTokenType type, IReadOnlyList errors) { - return new HtmlSymbol(content, type, errors); + return new HtmlToken(content, type, errors); } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs index d038f58cc5..2408c552dd 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs @@ -8,16 +8,16 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal class HtmlMarkupParser : TokenizerBackedParser + internal class HtmlMarkupParser : TokenizerBackedParser { private const string ScriptTagName = "script"; - private static readonly HtmlSymbol[] nonAllowedHtmlCommentEnding = new[] { HtmlSymbol.Hyphen, new HtmlSymbol("!", HtmlSymbolType.Bang), new HtmlSymbol("<", HtmlSymbolType.OpenAngle) }; - private static readonly HtmlSymbol[] singleHyphenArray = new[] { HtmlSymbol.Hyphen }; + private static readonly HtmlToken[] nonAllowedHtmlCommentEnding = new[] { HtmlToken.Hyphen, new HtmlToken("!", HtmlTokenType.Bang), new HtmlToken("<", HtmlTokenType.OpenAngle) }; + private static readonly HtmlToken[] singleHyphenArray = new[] { HtmlToken.Hyphen }; private static readonly char[] ValidAfterTypeAttributeNameCharacters = { ' ', '\t', '\r', '\n', '\f', '=' }; private SourceLocation _lastTagStart = SourceLocation.Zero; - private HtmlSymbol _bufferedOpenAngle; + private HtmlToken _bufferedOpenAngle; //From http://dev.w3.org/html5/spec/Overview.html#elements-0 private ISet _voidElements = new HashSet(StringComparer.OrdinalIgnoreCase) @@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { return CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; } } - protected override bool SymbolTypeEquals(HtmlSymbolType x, HtmlSymbolType y) => x == y; + protected override bool TokenTypeEquals(HtmlTokenType x, HtmlTokenType y) => x == y; public override void BuildSpan(SpanBuilder span, SourceLocation start, string content) { @@ -73,30 +73,30 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Output(SpanKindInternal.Markup); } - protected void SkipToAndParseCode(HtmlSymbolType type) + protected void SkipToAndParseCode(HtmlTokenType type) { - SkipToAndParseCode(sym => sym.Type == type); + SkipToAndParseCode(token => token.Type == type); } - protected void SkipToAndParseCode(Func condition) + protected void SkipToAndParseCode(Func condition) { - HtmlSymbol last = null; + HtmlToken last = null; var startOfLine = false; - while (!EndOfFile && !condition(CurrentSymbol)) + while (!EndOfFile && !condition(CurrentToken)) { if (Context.NullGenerateWhitespaceAndNewLine) { Context.NullGenerateWhitespaceAndNewLine = false; Span.ChunkGenerator = SpanChunkGenerator.Null; - AcceptWhile(symbol => symbol.Type == HtmlSymbolType.WhiteSpace); - if (At(HtmlSymbolType.NewLine)) + AcceptWhile(token => token.Type == HtmlTokenType.WhiteSpace); + if (At(HtmlTokenType.NewLine)) { AcceptAndMoveNext(); } Output(SpanKindInternal.Markup); } - else if (At(HtmlSymbolType.NewLine)) + else if (At(HtmlTokenType.NewLine)) { if (last != null) { @@ -108,11 +108,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy last = null; AcceptAndMoveNext(); } - else if (At(HtmlSymbolType.Transition)) + else if (At(HtmlTokenType.Transition)) { - var transition = CurrentSymbol; + var transition = CurrentToken; NextToken(); - if (At(HtmlSymbolType.Transition)) + if (At(HtmlTokenType.Transition)) { if (last != null) { @@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Handle whitespace rewriting if (last != null) { - if (!Context.DesignTimeMode && last.Type == HtmlSymbolType.WhiteSpace && startOfLine) + if (!Context.DesignTimeMode && last.Type == HtmlTokenType.WhiteSpace && startOfLine) { // Put the whitespace back too startOfLine = false; @@ -155,15 +155,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy OtherParserBlock(); } - else if (At(HtmlSymbolType.RazorCommentTransition)) + else if (At(HtmlTokenType.RazorCommentTransition)) { if (last != null) { // Don't render the whitespace between the start of the line and the razor comment. - if (startOfLine && last.Type == HtmlSymbolType.WhiteSpace) + if (startOfLine && last.Type == HtmlTokenType.WhiteSpace) { - AddMarkerSymbolIfNecessary(); - // Output the symbols that may have been accepted prior to the whitespace. + AddMarkerTokenIfNecessary(); + // Output the tokens that may have been accepted prior to the whitespace. Output(SpanKindInternal.Markup); Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -173,15 +173,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy last = null; } - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); Output(SpanKindInternal.Markup); RazorComment(); // Handle the whitespace and newline at the end of a razor comment. if (startOfLine && - (At(HtmlSymbolType.NewLine) || - (At(HtmlSymbolType.WhiteSpace) && NextIs(HtmlSymbolType.NewLine)))) + (At(HtmlTokenType.NewLine) || + (At(HtmlTokenType.WhiteSpace) && NextIs(HtmlTokenType.NewLine)))) { AcceptWhile(IsSpacingToken(includeNewLines: false)); AcceptAndMoveNext(); @@ -192,7 +192,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { // As long as we see whitespace, we're still at the "start" of the line - startOfLine &= At(HtmlSymbolType.WhiteSpace); + startOfLine &= At(HtmlTokenType.WhiteSpace); // If there's a last token, accept it if (last != null) @@ -202,7 +202,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } // Advance - last = CurrentSymbol; + last = CurrentToken; NextToken(); } } @@ -213,14 +213,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - protected static Func IsSpacingToken(bool includeNewLines) + protected static Func IsSpacingToken(bool includeNewLines) { - return sym => sym.Type == HtmlSymbolType.WhiteSpace || (includeNewLines && sym.Type == HtmlSymbolType.NewLine); + return token => token.Type == HtmlTokenType.WhiteSpace || (includeNewLines && token.Type == HtmlTokenType.NewLine); } private void OtherParserBlock() { - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); Output(SpanKindInternal.Markup); using (PushSpanConfig()) @@ -238,12 +238,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var potentialBang = Lookahead(lookahead); if (potentialBang != null && - potentialBang.Type == HtmlSymbolType.Bang) + potentialBang.Type == HtmlTokenType.Bang) { var afterBang = Lookahead(lookahead + 1); return afterBang != null && - afterBang.Type == HtmlSymbolType.Text && + afterBang.Type == HtmlTokenType.Text && !string.Equals(afterBang.Content, "DOCTYPE", StringComparison.OrdinalIgnoreCase); } @@ -257,7 +257,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Output(SpanKindInternal.Markup); // Accept the parser escape character '!'. - Assert(HtmlSymbolType.Bang); + Assert(HtmlTokenType.Bang); AcceptAndMoveNext(); // Setup the metacode span that we will be outputing. @@ -286,23 +286,23 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AcceptWhile(IsSpacingToken(includeNewLines: true)); - if (CurrentSymbol.Type == HtmlSymbolType.OpenAngle) + if (CurrentToken.Type == HtmlTokenType.OpenAngle) { // "<" => Implicit Tag Block - TagBlock(new Stack>()); + TagBlock(new Stack>()); } - else if (CurrentSymbol.Type == HtmlSymbolType.Transition) + else if (CurrentToken.Type == HtmlTokenType.Transition) { // "@" => Explicit Tag/Single Line Block OR Template Output(SpanKindInternal.Markup); // Definitely have a transition span - Assert(HtmlSymbolType.Transition); + Assert(HtmlTokenType.Transition); AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; Span.ChunkGenerator = SpanChunkGenerator.Null; Output(SpanKindInternal.Transition); - if (At(HtmlSymbolType.Transition)) + if (At(HtmlTokenType.Transition)) { Span.ChunkGenerator = SpanChunkGenerator.Null; AcceptAndMoveNext(); @@ -314,7 +314,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_MarkupBlockMustStartWithTag( - new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); + new SourceSpan(CurrentStart, CurrentToken.Content.Length))); } Output(SpanKindInternal.Markup); } @@ -330,10 +330,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void AfterTransition() { // "@:" => Explicit Single Line Block - if (CurrentSymbol.Type == HtmlSymbolType.Text && CurrentSymbol.Content.Length > 0 && CurrentSymbol.Content[0] == ':') + if (CurrentToken.Type == HtmlTokenType.Text && CurrentToken.Content.Length > 0 && CurrentToken.Content[0] == ':') { // Split the token - Tuple split = Language.SplitSymbol(CurrentSymbol, 1, HtmlSymbolType.Colon); + Tuple split = Language.SplitToken(CurrentToken, 1, HtmlTokenType.Colon); // The first part (left) is added to this span and we return a MetaCode span Accept(split.Item1); @@ -346,9 +346,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy NextToken(); SingleLineMarkup(); } - else if (CurrentSymbol.Type == HtmlSymbolType.OpenAngle) + else if (CurrentToken.Type == HtmlTokenType.OpenAngle) { - TagBlock(new Stack>()); + TagBlock(new Stack>()); } } @@ -359,8 +359,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var old = Context.WhiteSpaceIsSignificantToAncestorBlock; Context.WhiteSpaceIsSignificantToAncestorBlock = true; Span.EditHandler = new SpanEditHandler(Language.TokenizeString); - SkipToAndParseCode(HtmlSymbolType.NewLine); - if (!EndOfFile && CurrentSymbol.Type == HtmlSymbolType.NewLine) + SkipToAndParseCode(HtmlTokenType.NewLine); + if (!EndOfFile && CurrentToken.Type == HtmlTokenType.NewLine) { AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; @@ -370,13 +370,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Output(SpanKindInternal.Markup); } - private void TagBlock(Stack> tags) + private void TagBlock(Stack> tags) { // Skip Whitespace and Text var complete = false; do { - SkipToAndParseCode(HtmlSymbolType.OpenAngle); + SkipToAndParseCode(HtmlTokenType.OpenAngle); // Output everything prior to the OpenAngle into a markup span Output(SpanKindInternal.Markup); @@ -401,8 +401,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { _bufferedOpenAngle = null; _lastTagStart = CurrentStart; - Assert(HtmlSymbolType.OpenAngle); - _bufferedOpenAngle = CurrentSymbol; + Assert(HtmlTokenType.OpenAngle); + _bufferedOpenAngle = CurrentToken; var tagStart = CurrentStart; if (!NextToken()) { @@ -440,18 +440,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } private bool AfterTagStart(SourceLocation tagStart, - Stack> tags, + Stack> tags, bool atSpecialTag, IDisposable tagBlockWrapper) { if (!EndOfFile) { - switch (CurrentSymbol.Type) + switch (CurrentToken.Type) { - case HtmlSymbolType.ForwardSlash: + case HtmlTokenType.ForwardSlash: // End Tag return EndTag(tagStart, tags, tagBlockWrapper); - case HtmlSymbolType.Bang: + case HtmlTokenType.Bang: // Comment, CDATA, DOCTYPE, or a parser-escaped HTML tag. if (atSpecialTag) { @@ -462,7 +462,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { goto default; } - case HtmlSymbolType.QuestionMark: + case HtmlTokenType.QuestionMark: // XML PI Accept(_bufferedOpenAngle); return XmlPI(); @@ -483,15 +483,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private bool XmlPI() { // Accept "?" - Assert(HtmlSymbolType.QuestionMark); + Assert(HtmlTokenType.QuestionMark); AcceptAndMoveNext(); - return AcceptUntilAll(HtmlSymbolType.QuestionMark, HtmlSymbolType.CloseAngle); + return AcceptUntilAll(HtmlTokenType.QuestionMark, HtmlTokenType.CloseAngle); } private bool BangTag() { // Accept "!" - Assert(HtmlSymbolType.Bang); + Assert(HtmlTokenType.Bang); if (AcceptAndMoveNext()) { @@ -499,17 +499,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { using (Context.Builder.StartBlock(BlockKindInternal.HtmlComment)) { - // Accept the double-hyphen symbol at the beginning of the comment block. + // Accept the double-hyphen token at the beginning of the comment block. AcceptAndMoveNext(); Output(SpanKindInternal.Markup, AcceptedCharactersInternal.None); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.WhiteSpace; while (!EndOfFile) { - SkipToAndParseCode(HtmlSymbolType.DoubleHyphen); + SkipToAndParseCode(HtmlTokenType.DoubleHyphen); var lastDoubleHyphen = AcceptAllButLastDoubleHyphens(); - if (At(HtmlSymbolType.CloseAngle)) + if (At(HtmlTokenType.CloseAngle)) { // Output the content in the comment block as a separate markup Output(SpanKindInternal.Markup, AcceptedCharactersInternal.WhiteSpace); @@ -527,7 +527,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } } - else if (CurrentSymbol.Type == HtmlSymbolType.LeftBracket) + else if (CurrentToken.Type == HtmlTokenType.LeftBracket) { if (AcceptAndMoveNext()) { @@ -537,19 +537,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { AcceptAndMoveNext(); - return AcceptUntilAll(HtmlSymbolType.CloseAngle); + return AcceptUntilAll(HtmlTokenType.CloseAngle); } } return false; } - protected HtmlSymbol AcceptAllButLastDoubleHyphens() + protected HtmlToken AcceptAllButLastDoubleHyphens() { - var lastDoubleHyphen = CurrentSymbol; + var lastDoubleHyphen = CurrentToken; AcceptWhile(s => { - if (NextIs(HtmlSymbolType.DoubleHyphen)) + if (NextIs(HtmlTokenType.DoubleHyphen)) { lastDoubleHyphen = s; return true; @@ -560,10 +560,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy NextToken(); - if (At(HtmlSymbolType.Text) && IsHyphen(CurrentSymbol)) + if (At(HtmlTokenType.Text) && IsHyphen(CurrentToken)) { - // Doing this here to maintain the order of symbols - if (!NextIs(HtmlSymbolType.CloseAngle)) + // Doing this here to maintain the order of tokens + if (!NextIs(HtmlTokenType.CloseAngle)) { Accept(lastDoubleHyphen); lastDoubleHyphen = null; @@ -575,53 +575,50 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return lastDoubleHyphen; } - internal static bool IsHyphen(HtmlSymbol symbol) + internal static bool IsHyphen(HtmlToken token) { - return symbol.Equals(HtmlSymbol.Hyphen); + return token.Equals(HtmlToken.Hyphen); } protected bool IsHtmlCommentAhead() { - /* - * From HTML5 Specification, available at http://www.w3.org/TR/html52/syntax.html#comments - * - * Comments must have the following format: - * 1. The string "" // As we will be treating this as a comment ending, there is no need to handle this case at all. - * 2.2.3 "--!>" - * 2.3 nor end with the string "" - * - * */ + // From HTML5 Specification, available at http://www.w3.org/TR/html52/syntax.html#comments + + // Comments must have the following format: + // 1. The string "" As we will be treating this as a comment ending, there is no need to handle this case at all. + // 2.2.3 "--!>" + // 2.3 nor end with the string "" - if (CurrentSymbol.Type != HtmlSymbolType.DoubleHyphen) + if (CurrentToken.Type != HtmlTokenType.DoubleHyphen) { return false; } // Check condition 2.1 - if (NextIs(HtmlSymbolType.CloseAngle) || NextIs(next => IsHyphen(next) && NextIs(HtmlSymbolType.CloseAngle))) + if (NextIs(HtmlTokenType.CloseAngle) || NextIs(next => IsHyphen(next) && NextIs(HtmlTokenType.CloseAngle))) { return false; } // Check condition 2.2 var isValidComment = false; - LookaheadUntil((symbol, prevSymbols) => + LookaheadUntil((token, prevTokens) => { - if (symbol.Type == HtmlSymbolType.DoubleHyphen) + if (token.Type == HtmlTokenType.DoubleHyphen) { - if (NextIs(HtmlSymbolType.CloseAngle)) + if (NextIs(HtmlTokenType.CloseAngle)) { // Check condition 2.3: We're at the end of a comment. Check to make sure the text ending is allowed. - isValidComment = !IsCommentContentEndingInvalid(prevSymbols); + isValidComment = !IsCommentContentEndingInvalid(prevTokens); return true; } - else if (NextIs(ns => IsHyphen(ns) && NextIs(HtmlSymbolType.CloseAngle))) + else if (NextIs(ns => IsHyphen(ns) && NextIs(HtmlTokenType.CloseAngle))) { // Check condition 2.3: we're at the end of a comment, which has an extra dash. // Need to treat the dash as part of the content and check the ending. @@ -630,17 +627,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy isValidComment = true; return true; } - else if (NextIs(ns => ns.Type == HtmlSymbolType.Bang && NextIs(HtmlSymbolType.CloseAngle))) + else if (NextIs(ns => ns.Type == HtmlTokenType.Bang && NextIs(HtmlTokenType.CloseAngle))) { // This is condition 2.2.3 isValidComment = false; return true; } } - else if (symbol.Type == HtmlSymbolType.OpenAngle) + else if (token.Type == HtmlTokenType.OpenAngle) { // Checking condition 2.2.1 - if (NextIs(ns => ns.Type == HtmlSymbolType.Bang && NextIs(HtmlSymbolType.DoubleHyphen))) + if (NextIs(ns => ns.Type == HtmlTokenType.Bang && NextIs(HtmlTokenType.DoubleHyphen))) { isValidComment = false; return true; @@ -654,9 +651,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } /// - /// Verifies, that the sequence doesn't end with the "<!-" HtmlSymbols. Note, the first symbol is an opening bracket symbol + /// Verifies, that the sequence doesn't end with the "<!-" HtmlTokens. Note, the first token is an opening bracket token /// - internal static bool IsCommentContentEndingInvalid(IEnumerable sequence) + internal static bool IsCommentContentEndingInvalid(IEnumerable sequence) { var reversedSequence = sequence.Reverse(); var index = 0; @@ -678,13 +675,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private bool CData() { - if (CurrentSymbol.Type == HtmlSymbolType.Text && string.Equals(CurrentSymbol.Content, "cdata", StringComparison.OrdinalIgnoreCase)) + if (CurrentToken.Type == HtmlTokenType.Text && string.Equals(CurrentToken.Content, "cdata", StringComparison.OrdinalIgnoreCase)) { if (AcceptAndMoveNext()) { - if (CurrentSymbol.Type == HtmlSymbolType.LeftBracket) + if (CurrentToken.Type == HtmlTokenType.LeftBracket) { - return AcceptUntilAll(HtmlSymbolType.RightBracket, HtmlSymbolType.RightBracket, HtmlSymbolType.CloseAngle); + return AcceptUntilAll(HtmlTokenType.RightBracket, HtmlTokenType.RightBracket, HtmlTokenType.CloseAngle); } } } @@ -693,12 +690,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } private bool EndTag(SourceLocation tagStart, - Stack> tags, + Stack> tags, IDisposable tagBlockWrapper) { // Accept "/" and move next - Assert(HtmlSymbolType.ForwardSlash); - var forwardSlash = CurrentSymbol; + Assert(HtmlTokenType.ForwardSlash); + var forwardSlash = CurrentToken; if (!NextToken()) { Accept(_bufferedOpenAngle); @@ -708,22 +705,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { var tagName = string.Empty; - HtmlSymbol bangSymbol = null; + HtmlToken bangToken = null; - if (At(HtmlSymbolType.Bang)) + if (At(HtmlTokenType.Bang)) { - bangSymbol = CurrentSymbol; + bangToken = CurrentToken; - var nextSymbol = Lookahead(count: 1); + var nextToken = Lookahead(count: 1); - if (nextSymbol != null && nextSymbol.Type == HtmlSymbolType.Text) + if (nextToken != null && nextToken.Type == HtmlTokenType.Text) { - tagName = "!" + nextSymbol.Content; + tagName = "!" + nextToken.Content; } } - else if (At(HtmlSymbolType.Text)) + else if (At(HtmlTokenType.Text)) { - tagName = CurrentSymbol.Content; + tagName = CurrentToken.Content; } var matched = RemoveTag(tags, tagName, tagStart); @@ -741,32 +738,32 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy OptionalBangEscape(); - AcceptUntil(HtmlSymbolType.CloseAngle); + AcceptUntil(HtmlTokenType.CloseAngle); // Accept the ">" - return Optional(HtmlSymbolType.CloseAngle); + return Optional(HtmlTokenType.CloseAngle); } } private void RecoverTextTag() { // We don't want to skip-to and parse because there shouldn't be anything in the body of text tags. - AcceptUntil(HtmlSymbolType.CloseAngle, HtmlSymbolType.NewLine); + AcceptUntil(HtmlTokenType.CloseAngle, HtmlTokenType.NewLine); // Include the close angle in the text tag block if it's there, otherwise just move on - Optional(HtmlSymbolType.CloseAngle); + Optional(HtmlTokenType.CloseAngle); } - private bool EndTextTag(HtmlSymbol solidus, IDisposable tagBlockWrapper) + private bool EndTextTag(HtmlToken solidus, IDisposable tagBlockWrapper) { Accept(_bufferedOpenAngle); Accept(solidus); var textLocation = CurrentStart; - Assert(HtmlSymbolType.Text); + Assert(HtmlTokenType.Text); AcceptAndMoveNext(); - var seenCloseAngle = Optional(HtmlSymbolType.CloseAngle); + var seenCloseAngle = Optional(HtmlTokenType.CloseAngle); if (!seenCloseAngle) { @@ -794,32 +791,32 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { get { - if (At(HtmlSymbolType.OpenAngle)) + if (At(HtmlTokenType.OpenAngle)) { - if (NextIs(HtmlSymbolType.Bang)) + if (NextIs(HtmlTokenType.Bang)) { return !IsBangEscape(lookahead: 1); } - return NextIs(HtmlSymbolType.QuestionMark); + return NextIs(HtmlTokenType.QuestionMark); } return false; } } - private bool IsTagRecoveryStopPoint(HtmlSymbol sym) + private bool IsTagRecoveryStopPoint(HtmlToken token) { - return sym.Type == HtmlSymbolType.CloseAngle || - sym.Type == HtmlSymbolType.ForwardSlash || - sym.Type == HtmlSymbolType.OpenAngle || - sym.Type == HtmlSymbolType.SingleQuote || - sym.Type == HtmlSymbolType.DoubleQuote; + return token.Type == HtmlTokenType.CloseAngle || + token.Type == HtmlTokenType.ForwardSlash || + token.Type == HtmlTokenType.OpenAngle || + token.Type == HtmlTokenType.SingleQuote || + token.Type == HtmlTokenType.DoubleQuote; } private void TagContent() { - if (!At(HtmlSymbolType.WhiteSpace) && !At(HtmlSymbolType.NewLine)) + if (!At(HtmlTokenType.WhiteSpace) && !At(HtmlTokenType.NewLine)) { // We should be right after the tag name, so if there's no whitespace or new line, something is wrong RecoverToEndOfTag(); @@ -836,9 +833,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private bool IsEndOfTag() { - if (At(HtmlSymbolType.ForwardSlash)) + if (At(HtmlTokenType.ForwardSlash)) { - if (NextIs(HtmlSymbolType.CloseAngle)) + if (NextIs(HtmlTokenType.CloseAngle)) { return true; } @@ -847,16 +844,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AcceptAndMoveNext(); } } - return At(HtmlSymbolType.CloseAngle) || At(HtmlSymbolType.OpenAngle); + return At(HtmlTokenType.CloseAngle) || At(HtmlTokenType.OpenAngle); } private void BeforeAttribute() { // http://dev.w3.org/html5/spec/tokenization.html#before-attribute-name-state // Capture whitespace - var whitespace = ReadWhile(sym => sym.Type == HtmlSymbolType.WhiteSpace || sym.Type == HtmlSymbolType.NewLine); + var whitespace = ReadWhile(token => token.Type == HtmlTokenType.WhiteSpace || token.Type == HtmlTokenType.NewLine); - if (At(HtmlSymbolType.Transition)) + if (At(HtmlTokenType.Transition)) { // Transition outside of attribute value => Switch to recovery mode Accept(whitespace); @@ -866,21 +863,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // http://dev.w3.org/html5/spec/tokenization.html#attribute-name-state // Read the 'name' (i.e. read until the '=' or whitespace/newline) - var name = Enumerable.Empty(); - var whitespaceAfterAttributeName = Enumerable.Empty(); - if (IsValidAttributeNameSymbol(CurrentSymbol)) + var name = Enumerable.Empty(); + var whitespaceAfterAttributeName = Enumerable.Empty(); + if (IsValidAttributeNameToken(CurrentToken)) { - name = ReadWhile(sym => - sym.Type != HtmlSymbolType.WhiteSpace && - sym.Type != HtmlSymbolType.NewLine && - sym.Type != HtmlSymbolType.Equals && - sym.Type != HtmlSymbolType.CloseAngle && - sym.Type != HtmlSymbolType.OpenAngle && - (sym.Type != HtmlSymbolType.ForwardSlash || !NextIs(HtmlSymbolType.CloseAngle))); + name = ReadWhile(token => + token.Type != HtmlTokenType.WhiteSpace && + token.Type != HtmlTokenType.NewLine && + token.Type != HtmlTokenType.Equals && + token.Type != HtmlTokenType.CloseAngle && + token.Type != HtmlTokenType.OpenAngle && + (token.Type != HtmlTokenType.ForwardSlash || !NextIs(HtmlTokenType.CloseAngle))); // capture whitespace after attribute name (if any) whitespaceAfterAttributeName = ReadWhile( - sym => sym.Type == HtmlSymbolType.WhiteSpace || sym.Type == HtmlSymbolType.NewLine); + token => token.Type == HtmlTokenType.WhiteSpace || token.Type == HtmlTokenType.NewLine); } else { @@ -890,7 +887,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return; } - if (!At(HtmlSymbolType.Equals)) + if (!At(HtmlTokenType.Equals)) { // Minimized attribute @@ -925,32 +922,32 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } private void AttributePrefix( - IEnumerable whitespace, - IEnumerable nameSymbols, - IEnumerable whitespaceAfterAttributeName) + IEnumerable whitespace, + IEnumerable nameTokens, + IEnumerable whitespaceAfterAttributeName) { // First, determine if this is a 'data-' attribute (since those can't use conditional attributes) - var name = string.Concat(nameSymbols.Select(s => s.Content)); + var name = string.Concat(nameTokens.Select(s => s.Content)); var attributeCanBeConditional = Context.FeatureFlags.EXPERIMENTAL_AllowConditionalDataDashAttributes || !name.StartsWith("data-", StringComparison.OrdinalIgnoreCase); // Accept the whitespace and name Accept(whitespace); - Accept(nameSymbols); + Accept(nameTokens); // Since this is not a minimized attribute, the whitespace after attribute name belongs to this attribute. Accept(whitespaceAfterAttributeName); - Assert(HtmlSymbolType.Equals); // We should be at "=" + Assert(HtmlTokenType.Equals); // We should be at "=" AcceptAndMoveNext(); - var whitespaceAfterEquals = ReadWhile(sym => sym.Type == HtmlSymbolType.WhiteSpace || sym.Type == HtmlSymbolType.NewLine); - var quote = HtmlSymbolType.Unknown; - if (At(HtmlSymbolType.SingleQuote) || At(HtmlSymbolType.DoubleQuote)) + var whitespaceAfterEquals = ReadWhile(token => token.Type == HtmlTokenType.WhiteSpace || token.Type == HtmlTokenType.NewLine); + var quote = HtmlTokenType.Unknown; + if (At(HtmlTokenType.SingleQuote) || At(HtmlTokenType.DoubleQuote)) { // Found a quote, the whitespace belongs to this attribute. Accept(whitespaceAfterEquals); - quote = CurrentSymbol.Type; + quote = CurrentToken.Type; AcceptAndMoveNext(); } else if (whitespaceAfterEquals.Any()) @@ -961,7 +958,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } // We now have the prefix: (i.e. ' foo="') - var prefix = new LocationTagged(string.Concat(Span.Symbols.Select(s => s.Content)), Span.Start); + var prefix = new LocationTagged(string.Concat(Span.Tokens.Select(s => s.Content)), Span.Start); if (attributeCanBeConditional) { @@ -970,10 +967,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Read the attribute value only if the value is quoted // or if there is no whitespace between '=' and the unquoted value. - if (quote != HtmlSymbolType.Unknown || !whitespaceAfterEquals.Any()) + if (quote != HtmlTokenType.Unknown || !whitespaceAfterEquals.Any()) { // Read the attribute value. - while (!EndOfFile && !IsEndOfAttributeValue(quote, CurrentSymbol)) + while (!EndOfFile && !IsEndOfAttributeValue(quote, CurrentToken)) { AttributeValue(quote); } @@ -981,13 +978,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Capture the suffix var suffix = new LocationTagged(string.Empty, CurrentStart); - if (quote != HtmlSymbolType.Unknown && At(quote)) + if (quote != HtmlTokenType.Unknown && At(quote)) { - suffix = new LocationTagged(CurrentSymbol.Content, CurrentStart); + suffix = new LocationTagged(CurrentToken.Content, CurrentStart); AcceptAndMoveNext(); } - if (Span.Symbols.Count > 0) + if (Span.Tokens.Count > 0) { // Again, block chunk generator will render the suffix Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -1003,18 +1000,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Output the attribute name, the equals and optional quote. Ex: foo=" Output(SpanKindInternal.Markup); - if (quote == HtmlSymbolType.Unknown && whitespaceAfterEquals.Any()) + if (quote == HtmlTokenType.Unknown && whitespaceAfterEquals.Any()) { return; } // Not a "conditional" attribute, so just read the value - SkipToAndParseCode(sym => IsEndOfAttributeValue(quote, sym)); + SkipToAndParseCode(token => IsEndOfAttributeValue(quote, token)); // Output the attribute value (will include everything in-between the attribute's quotes). Output(SpanKindInternal.Markup); - if (quote != HtmlSymbolType.Unknown) + if (quote != HtmlTokenType.Unknown) { Optional(quote); } @@ -1022,14 +1019,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - private void AttributeValue(HtmlSymbolType quote) + private void AttributeValue(HtmlTokenType quote) { var prefixStart = CurrentStart; - var prefix = ReadWhile(sym => sym.Type == HtmlSymbolType.WhiteSpace || sym.Type == HtmlSymbolType.NewLine); + var prefix = ReadWhile(token => token.Type == HtmlTokenType.WhiteSpace || token.Type == HtmlTokenType.NewLine); - if (At(HtmlSymbolType.Transition)) + if (At(HtmlTokenType.Transition)) { - if (NextIs(HtmlSymbolType.Transition)) + if (NextIs(HtmlTokenType.Transition)) { // Wrapping this in a block so that the ConditionalAttributeCollapser doesn't rewrite it. using (Context.Builder.StartBlock(BlockKindInternal.Markup)) @@ -1039,7 +1036,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Render a single "@" in place of "@@". Span.ChunkGenerator = new LiteralAttributeChunkGenerator( new LocationTagged(string.Concat(prefix.Select(s => s.Content)), prefixStart), - new LocationTagged(CurrentSymbol.Content, CurrentStart)); + new LocationTagged(CurrentToken.Content, CurrentStart)); AcceptAndMoveNext(); Output(SpanKindInternal.Markup, AcceptedCharactersInternal.None); @@ -1074,17 +1071,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Accept(prefix); // Literal value - // 'quote' should be "Unknown" if not quoted and symbols coming from the tokenizer should never have + // 'quote' should be "Unknown" if not quoted and tokens coming from the tokenizer should never have // "Unknown" type. var valueStart = CurrentStart; - var value = ReadWhile(sym => + var value = ReadWhile(token => // These three conditions find separators which break the attribute value into portions - sym.Type != HtmlSymbolType.WhiteSpace && - sym.Type != HtmlSymbolType.NewLine && - sym.Type != HtmlSymbolType.Transition && + token.Type != HtmlTokenType.WhiteSpace && + token.Type != HtmlTokenType.NewLine && + token.Type != HtmlTokenType.Transition && // This condition checks for the end of the attribute value (it repeats some of the checks above // but for now that's ok) - !IsEndOfAttributeValue(quote, sym)); + !IsEndOfAttributeValue(quote, token)); Accept(value); Span.ChunkGenerator = new LiteralAttributeChunkGenerator( new LocationTagged(string.Concat(prefix.Select(s => s.Content)), prefixStart), @@ -1093,27 +1090,27 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Output(SpanKindInternal.Markup); } - private bool IsEndOfAttributeValue(HtmlSymbolType quote, HtmlSymbol sym) + private bool IsEndOfAttributeValue(HtmlTokenType quote, HtmlToken token) { - return EndOfFile || sym == null || - (quote != HtmlSymbolType.Unknown - ? sym.Type == quote // If quoted, just wait for the quote - : IsUnquotedEndOfAttributeValue(sym)); + return EndOfFile || token == null || + (quote != HtmlTokenType.Unknown + ? token.Type == quote // If quoted, just wait for the quote + : IsUnquotedEndOfAttributeValue(token)); } - private bool IsUnquotedEndOfAttributeValue(HtmlSymbol sym) + private bool IsUnquotedEndOfAttributeValue(HtmlToken token) { // If unquoted, we have a larger set of terminating characters: // http://dev.w3.org/html5/spec/tokenization.html#attribute-value-unquoted-state // Also we need to detect "/" and ">" - return sym.Type == HtmlSymbolType.DoubleQuote || - sym.Type == HtmlSymbolType.SingleQuote || - sym.Type == HtmlSymbolType.OpenAngle || - sym.Type == HtmlSymbolType.Equals || - (sym.Type == HtmlSymbolType.ForwardSlash && NextIs(HtmlSymbolType.CloseAngle)) || - sym.Type == HtmlSymbolType.CloseAngle || - sym.Type == HtmlSymbolType.WhiteSpace || - sym.Type == HtmlSymbolType.NewLine; + return token.Type == HtmlTokenType.DoubleQuote || + token.Type == HtmlTokenType.SingleQuote || + token.Type == HtmlTokenType.OpenAngle || + token.Type == HtmlTokenType.Equals || + (token.Type == HtmlTokenType.ForwardSlash && NextIs(HtmlTokenType.CloseAngle)) || + token.Type == HtmlTokenType.CloseAngle || + token.Type == HtmlTokenType.WhiteSpace || + token.Type == HtmlTokenType.NewLine; } private void RecoverToEndOfTag() @@ -1125,17 +1122,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!EndOfFile) { EnsureCurrent(); - switch (CurrentSymbol.Type) + switch (CurrentToken.Type) { - case HtmlSymbolType.SingleQuote: - case HtmlSymbolType.DoubleQuote: + case HtmlTokenType.SingleQuote: + case HtmlTokenType.DoubleQuote: ParseQuoted(); break; - case HtmlSymbolType.OpenAngle: + case HtmlTokenType.OpenAngle: // Another "<" means this tag is invalid. - case HtmlSymbolType.ForwardSlash: + case HtmlTokenType.ForwardSlash: // Empty tag - case HtmlSymbolType.CloseAngle: + case HtmlTokenType.CloseAngle: // End of tag return; default: @@ -1148,12 +1145,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void ParseQuoted() { - var type = CurrentSymbol.Type; + var type = CurrentToken.Type; AcceptAndMoveNext(); ParseQuoted(type); } - private void ParseQuoted(HtmlSymbolType type) + private void ParseQuoted(HtmlTokenType type) { SkipToAndParseCode(type); if (!EndOfFile) @@ -1163,38 +1160,38 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - private bool StartTag(Stack> tags, IDisposable tagBlockWrapper) + private bool StartTag(Stack> tags, IDisposable tagBlockWrapper) { - HtmlSymbol bangSymbol = null; - HtmlSymbol potentialTagNameSymbol; + HtmlToken bangToken = null; + HtmlToken potentialTagNameToken; - if (At(HtmlSymbolType.Bang)) + if (At(HtmlTokenType.Bang)) { - bangSymbol = CurrentSymbol; + bangToken = CurrentToken; - potentialTagNameSymbol = Lookahead(count: 1); + potentialTagNameToken = Lookahead(count: 1); } else { - potentialTagNameSymbol = CurrentSymbol; + potentialTagNameToken = CurrentToken; } - HtmlSymbol tagName; + HtmlToken tagName; - if (potentialTagNameSymbol == null || potentialTagNameSymbol.Type != HtmlSymbolType.Text) + if (potentialTagNameToken == null || potentialTagNameToken.Type != HtmlTokenType.Text) { - tagName = new HtmlSymbol(string.Empty, HtmlSymbolType.Unknown); + tagName = new HtmlToken(string.Empty, HtmlTokenType.Unknown); } - else if (bangSymbol != null) + else if (bangToken != null) { - tagName = new HtmlSymbol("!" + potentialTagNameSymbol.Content, HtmlSymbolType.Text); + tagName = new HtmlToken("!" + potentialTagNameToken.Content, HtmlTokenType.Text); } else { - tagName = potentialTagNameSymbol; + tagName = potentialTagNameToken; } - Tuple tag = Tuple.Create(tagName, _lastTagStart); + Tuple tag = Tuple.Create(tagName, _lastTagStart); if (tags.Count == 0 && // Note tagName may contain a '!' escape character. This ensures doesn't match here. @@ -1206,23 +1203,23 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Accept(_bufferedOpenAngle); var textLocation = CurrentStart; - Assert(HtmlSymbolType.Text); + Assert(HtmlTokenType.Text); AcceptAndMoveNext(); var bookmark = CurrentStart.AbsoluteIndex; - IEnumerable tokens = ReadWhile(IsSpacingToken(includeNewLines: true)); - var empty = At(HtmlSymbolType.ForwardSlash); + IEnumerable tokens = ReadWhile(IsSpacingToken(includeNewLines: true)); + var empty = At(HtmlTokenType.ForwardSlash); if (empty) { Accept(tokens); - Assert(HtmlSymbolType.ForwardSlash); + Assert(HtmlTokenType.ForwardSlash); AcceptAndMoveNext(); bookmark = CurrentStart.AbsoluteIndex; tokens = ReadWhile(IsSpacingToken(includeNewLines: true)); } - if (!Optional(HtmlSymbolType.CloseAngle)) + if (!Optional(HtmlTokenType.CloseAngle)) { Context.Source.Position = bookmark; NextToken(); @@ -1250,24 +1247,24 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Accept(_bufferedOpenAngle); OptionalBangEscape(); - Optional(HtmlSymbolType.Text); + Optional(HtmlTokenType.Text); return RestOfTag(tag, tags, tagBlockWrapper); } - private bool RestOfTag(Tuple tag, - Stack> tags, + private bool RestOfTag(Tuple tag, + Stack> tags, IDisposable tagBlockWrapper) { TagContent(); // We are now at a possible end of the tag // Found '<', so we just abort this tag. - if (At(HtmlSymbolType.OpenAngle)) + if (At(HtmlTokenType.OpenAngle)) { return false; } - var isEmpty = At(HtmlSymbolType.ForwardSlash); + var isEmpty = At(HtmlTokenType.ForwardSlash); // Found a solidus, so don't accept it but DON'T push the tag to the stack if (isEmpty) { @@ -1275,7 +1272,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } // Check for the '>' to determine if the tag is finished - var seenClose = Optional(HtmlSymbolType.CloseAngle); + var seenClose = Optional(HtmlTokenType.CloseAngle); if (!seenClose) { Context.ErrorSink.OnError( @@ -1301,17 +1298,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var bookmark = CurrentStart.AbsoluteIndex; // Skip whitespace - IEnumerable whiteSpace = ReadWhile(IsSpacingToken(includeNewLines: true)); + IEnumerable whiteSpace = ReadWhile(IsSpacingToken(includeNewLines: true)); // Open Angle - if (At(HtmlSymbolType.OpenAngle) && NextIs(HtmlSymbolType.ForwardSlash)) + if (At(HtmlTokenType.OpenAngle) && NextIs(HtmlTokenType.ForwardSlash)) { - var openAngle = CurrentSymbol; + var openAngle = CurrentToken; NextToken(); - Assert(HtmlSymbolType.ForwardSlash); - var solidus = CurrentSymbol; + Assert(HtmlTokenType.ForwardSlash); + var solidus = CurrentToken; NextToken(); - if (At(HtmlSymbolType.Text) && string.Equals(CurrentSymbol.Content, tagName, StringComparison.OrdinalIgnoreCase)) + if (At(HtmlTokenType.Text) && string.Equals(CurrentToken.Content, tagName, StringComparison.OrdinalIgnoreCase)) { // Accept up to here Accept(whiteSpace); @@ -1324,9 +1321,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AcceptAndMoveNext(); // Accept to '>', '<' or EOF - AcceptUntil(HtmlSymbolType.CloseAngle, HtmlSymbolType.OpenAngle); + AcceptUntil(HtmlTokenType.CloseAngle, HtmlTokenType.OpenAngle); // Accept the '>' if we saw it. And if we do see it, we're complete - var complete = Optional(HtmlSymbolType.CloseAngle); + var complete = Optional(HtmlTokenType.CloseAngle); if (complete) { @@ -1376,18 +1373,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy while (!seenEndScript && !EndOfFile) { - SkipToAndParseCode(HtmlSymbolType.OpenAngle); + SkipToAndParseCode(HtmlTokenType.OpenAngle); var tagStart = CurrentStart; - if (NextIs(HtmlSymbolType.ForwardSlash)) + if (NextIs(HtmlTokenType.ForwardSlash)) { - var openAngle = CurrentSymbol; + var openAngle = CurrentToken; NextToken(); // Skip over '<', current is '/' - var solidus = CurrentSymbol; + var solidus = CurrentToken; NextToken(); // Skip over '/', current should be text - if (At(HtmlSymbolType.Text) && - string.Equals(CurrentSymbol.Content, ScriptTagName, StringComparison.OrdinalIgnoreCase)) + if (At(HtmlTokenType.Text) && + string.Equals(CurrentToken.Content, ScriptTagName, StringComparison.OrdinalIgnoreCase)) { seenEndScript = true; } @@ -1398,7 +1395,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy PutBack(solidus); // Put back '/' PutBack(openAngle); // Put back '<' - // We just looked ahead, this NextToken will set CurrentSymbol to an open angle bracket. + // We just looked ahead, this NextToken will set CurrentToken to an open angle bracket. NextToken(); } @@ -1412,8 +1409,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AcceptAndMoveNext(); // '<' AcceptAndMoveNext(); // '/' - SkipToAndParseCode(HtmlSymbolType.CloseAngle); - if (!Optional(HtmlSymbolType.CloseAngle)) + SkipToAndParseCode(HtmlTokenType.CloseAngle); + if (!Optional(HtmlTokenType.CloseAngle)) { Context.ErrorSink.OnError( RazorDiagnosticFactory.CreateParsing_UnfinishedTag( @@ -1444,7 +1441,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy tagBlockWrapper.Dispose(); } - private bool AcceptUntilAll(params HtmlSymbolType[] endSequence) + private bool AcceptUntilAll(params HtmlTokenType[] endSequence) { while (!EndOfFile) { @@ -1459,9 +1456,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return false; } - private bool RemoveTag(Stack> tags, string tagName, SourceLocation tagStart) + private bool RemoveTag(Stack> tags, string tagName, SourceLocation tagStart) { - Tuple currentTag = null; + Tuple currentTag = null; while (tags.Count > 0) { currentTag = tags.Pop(); @@ -1489,7 +1486,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return false; } - private void EndTagBlock(Stack> tags, bool complete) + private void EndTagBlock(Stack> tags, bool complete) { if (tags.Count > 0) { @@ -1517,46 +1514,46 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (Context.Builder.LastSpan.Kind == SpanKindInternal.Transition) { - var symbols = ReadWhile( - f => (f.Type == HtmlSymbolType.WhiteSpace) || (f.Type == HtmlSymbolType.NewLine)); + var tokens = ReadWhile( + f => (f.Type == HtmlTokenType.WhiteSpace) || (f.Type == HtmlTokenType.NewLine)); - // Make sure the current symbol is not markup, which can be html start tag or @: - if (!(At(HtmlSymbolType.OpenAngle) || - (At(HtmlSymbolType.Transition) && Lookahead(count: 1).Content.StartsWith(":")))) + // Make sure the current token is not markup, which can be html start tag or @: + if (!(At(HtmlTokenType.OpenAngle) || + (At(HtmlTokenType.Transition) && Lookahead(count: 1).Content.StartsWith(":")))) { // Don't accept whitespace as markup if the end text tag is followed by csharp. shouldAcceptWhitespaceAndNewLine = false; } PutCurrentBack(); - PutBack(symbols); + PutBack(tokens); EnsureCurrent(); } if (shouldAcceptWhitespaceAndNewLine) { // Accept whitespace and a single newline if present - AcceptWhile(HtmlSymbolType.WhiteSpace); - Optional(HtmlSymbolType.NewLine); + AcceptWhile(HtmlTokenType.WhiteSpace); + Optional(HtmlTokenType.NewLine); } } else if (Span.EditHandler.AcceptedCharacters == AcceptedCharactersInternal.Any) { - AcceptWhile(HtmlSymbolType.WhiteSpace); - Optional(HtmlSymbolType.NewLine); + AcceptWhile(HtmlTokenType.WhiteSpace); + Optional(HtmlTokenType.NewLine); } PutCurrentBack(); if (!complete) { - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); } Output(SpanKindInternal.Markup); } - internal static bool IsValidAttributeNameSymbol(HtmlSymbol symbol) + internal static bool IsValidAttributeNameToken(HtmlToken token) { - if (symbol == null) + if (token == null) { return false; } @@ -1565,16 +1562,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // However, it's not all of it. For instance we don't special case control characters or allow OpenAngle. // It also doesn't try to exclude Razor specific features such as the @ transition. This is based on the // expectation that the parser handles such scenarios prior to falling through to name resolution. - var symbolType = symbol.Type; - return symbolType != HtmlSymbolType.WhiteSpace && - symbolType != HtmlSymbolType.NewLine && - symbolType != HtmlSymbolType.CloseAngle && - symbolType != HtmlSymbolType.OpenAngle && - symbolType != HtmlSymbolType.ForwardSlash && - symbolType != HtmlSymbolType.DoubleQuote && - symbolType != HtmlSymbolType.SingleQuote && - symbolType != HtmlSymbolType.Equals && - symbolType != HtmlSymbolType.Unknown; + var tokenType = token.Type; + return tokenType != HtmlTokenType.WhiteSpace && + tokenType != HtmlTokenType.NewLine && + tokenType != HtmlTokenType.CloseAngle && + tokenType != HtmlTokenType.OpenAngle && + tokenType != HtmlTokenType.ForwardSlash && + tokenType != HtmlTokenType.DoubleQuote && + tokenType != HtmlTokenType.SingleQuote && + tokenType != HtmlTokenType.Equals && + tokenType != HtmlTokenType.Unknown; } public void ParseDocument() @@ -1593,10 +1590,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy NextToken(); while (!EndOfFile) { - SkipToAndParseCode(HtmlSymbolType.OpenAngle); + SkipToAndParseCode(HtmlTokenType.OpenAngle); ScanTagInDocumentContext(); } - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); Output(SpanKindInternal.Markup); } } @@ -1608,14 +1605,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy /// private void ScanTagInDocumentContext() { - if (At(HtmlSymbolType.OpenAngle)) + if (At(HtmlTokenType.OpenAngle)) { - if (NextIs(HtmlSymbolType.Bang)) + if (NextIs(HtmlTokenType.Bang)) { // Checking to see if we meet the conditions of a special '!' tag: ';" as an HTML tag. @@ -1670,13 +1667,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Parsing an end tag // This section can accept things like: '

' or '

' etc. - Optional(HtmlSymbolType.ForwardSlash); + Optional(HtmlTokenType.ForwardSlash); // Whitespace here is invalid (according to the spec) OptionalBangEscape(); - Optional(HtmlSymbolType.Text); - Optional(HtmlSymbolType.WhiteSpace); - Optional(HtmlSymbolType.CloseAngle); + Optional(HtmlTokenType.Text); + Optional(HtmlTokenType.WhiteSpace); + Optional(HtmlTokenType.CloseAngle); } Output(SpanKindInternal.Markup); @@ -1758,7 +1755,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { NestingSection(nestingSequences); } - AddMarkerSymbolIfNecessary(); + AddMarkerTokenIfNecessary(); Output(SpanKindInternal.Markup); } } @@ -1768,7 +1765,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { do { - SkipToAndParseCode(sym => sym.Type == HtmlSymbolType.OpenAngle || AtEnd(nestingSequenceComponents)); + SkipToAndParseCode(token => token.Type == HtmlTokenType.OpenAngle || AtEnd(nestingSequenceComponents)); ScanTagInDocumentContext(); if (!EndOfFile && AtEnd(nestingSequenceComponents)) { @@ -1785,13 +1782,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var nesting = 1; while (nesting > 0 && !EndOfFile) { - SkipToAndParseCode(sym => - sym.Type == HtmlSymbolType.Text || - sym.Type == HtmlSymbolType.OpenAngle); - if (At(HtmlSymbolType.Text)) + SkipToAndParseCode(token => + token.Type == HtmlTokenType.Text || + token.Type == HtmlTokenType.OpenAngle); + if (At(HtmlTokenType.Text)) { nesting += ProcessTextToken(nestingSequences, nesting); - if (CurrentSymbol != null) + if (CurrentToken != null) { AcceptAndMoveNext(); } @@ -1810,19 +1807,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private bool AtEnd(string[] nestingSequenceComponents) { EnsureCurrent(); - if (string.Equals(CurrentSymbol.Content, nestingSequenceComponents[0], Comparison)) + if (string.Equals(CurrentToken.Content, nestingSequenceComponents[0], Comparison)) { - var bookmark = Context.Source.Position - CurrentSymbol.Content.Length; + var bookmark = Context.Source.Position - CurrentToken.Content.Length; try { foreach (string component in nestingSequenceComponents) { - if (!EndOfFile && !string.Equals(CurrentSymbol.Content, component, Comparison)) + if (!EndOfFile && !string.Equals(CurrentToken.Content, component, Comparison)) { return false; } NextToken(); - while (!EndOfFile && IsSpacingToken(includeNewLines: true)(CurrentSymbol)) + while (!EndOfFile && IsSpacingToken(includeNewLines: true)(CurrentToken)) { NextToken(); } @@ -1840,7 +1837,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private int ProcessTextToken(Tuple nestingSequences, int currentNesting) { - for (int i = 0; i < CurrentSymbol.Content.Length; i++) + for (int i = 0; i < CurrentToken.Content.Length; i++) { var nestingDelta = HandleNestingSequence(nestingSequences.Item1, i, currentNesting, 1); if (nestingDelta == 0) @@ -1859,22 +1856,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private int HandleNestingSequence(string sequence, int position, int currentNesting, int retIfMatched) { if (sequence != null && - CurrentSymbol.Content[position] == sequence[0] && - position + sequence.Length <= CurrentSymbol.Content.Length) + CurrentToken.Content[position] == sequence[0] && + position + sequence.Length <= CurrentToken.Content.Length) { - var possibleStart = CurrentSymbol.Content.Substring(position, sequence.Length); + var possibleStart = CurrentToken.Content.Substring(position, sequence.Length); if (string.Equals(possibleStart, sequence, Comparison)) { - // Capture the current symbol and "put it back" (really we just want to clear CurrentSymbol) + // Capture the current token and "put it back" (really we just want to clear CurrentToken) var bookmark = CurrentStart; - var sym = CurrentSymbol; + var token = CurrentToken; PutCurrentBack(); - // Carve up the symbol - Tuple pair = Language.SplitSymbol(sym, position, HtmlSymbolType.Text); + // Carve up the token + Tuple pair = Language.SplitToken(token, position, HtmlTokenType.Text); var preSequence = pair.Item1; Debug.Assert(pair.Item2 != null); - pair = Language.SplitSymbol(pair.Item2, sequence.Length, HtmlSymbolType.Text); + pair = Language.SplitToken(pair.Item2, sequence.Length, HtmlTokenType.Text); var sequenceToken = pair.Item1; var postSequence = pair.Item2; var postSequenceBookmark = bookmark.AbsoluteIndex + preSequence.Content.Length + pair.Item1.Content.Length; @@ -1897,7 +1894,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // This isn't the end of the last nesting sequence, accept the token and keep going Accept(sequenceToken); - // Position at the start of the postSequence symbol, which might be null. + // Position at the start of the postSequence token, which might be null. Context.Source.Position = postSequenceBookmark; } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlSymbol.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlToken.cs similarity index 73% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlSymbol.cs rename to src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlToken.cs index 217e293704..2d52ed14e2 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlSymbol.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlToken.cs @@ -6,11 +6,11 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal class HtmlSymbol : SymbolBase + internal class HtmlToken : TokenBase { - internal static readonly HtmlSymbol Hyphen = new HtmlSymbol("-", HtmlSymbolType.Text); + internal static readonly HtmlToken Hyphen = new HtmlToken("-", HtmlTokenType.Text); - public HtmlSymbol(string content, HtmlSymbolType type) + public HtmlToken(string content, HtmlTokenType type) : base(content, type, RazorDiagnostic.EmptyArray) { if (content == null) @@ -19,9 +19,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - public HtmlSymbol( + public HtmlToken( string content, - HtmlSymbolType type, + HtmlTokenType type, IReadOnlyList errors) : base(content, type, errors) { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlSymbolType.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenType.cs similarity index 96% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlSymbolType.cs rename to src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenType.cs index bc90b98022..82d96d7ebc 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlSymbolType.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenType.cs @@ -6,7 +6,7 @@ using System; namespace Microsoft.AspNetCore.Razor.Language.Legacy { [Flags] - internal enum HtmlSymbolType + internal enum HtmlTokenType { Unknown, Text, // Text which isn't one of the below diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs index df9671d1b7..99a7152447 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs @@ -7,7 +7,7 @@ using System.Diagnostics; namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Tokenizer _loosely_ based on http://dev.w3.org/html5/spec/Overview.html#tokenization - internal class HtmlTokenizer : Tokenizer + internal class HtmlTokenizer : Tokenizer { private const char TransitionChar = '@'; @@ -21,24 +21,24 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private new HtmlTokenizerState? CurrentState => (HtmlTokenizerState?)base.CurrentState; - public override HtmlSymbolType RazorCommentType + public override HtmlTokenType RazorCommentType { - get { return HtmlSymbolType.RazorComment; } + get { return HtmlTokenType.RazorComment; } } - public override HtmlSymbolType RazorCommentTransitionType + public override HtmlTokenType RazorCommentTransitionType { - get { return HtmlSymbolType.RazorCommentTransition; } + get { return HtmlTokenType.RazorCommentTransition; } } - public override HtmlSymbolType RazorCommentStarType + public override HtmlTokenType RazorCommentStarType { - get { return HtmlSymbolType.RazorCommentStar; } + get { return HtmlTokenType.RazorCommentStar; } } - protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) + protected override HtmlToken CreateToken(string content, HtmlTokenType type, IReadOnlyList errors) { - return new HtmlSymbol(content, type, errors); + return new HtmlToken(content, type, errors); } protected override StateResult Dispatch() @@ -57,8 +57,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return RazorCommentBody(); case HtmlTokenizerState.StarAfterRazorCommentBody: return StarAfterRazorCommentBody(); - case HtmlTokenizerState.AtSymbolAfterRazorCommentBody: - return AtSymbolAfterRazorCommentBody(); + case HtmlTokenizerState.AtTokenAfterRazorCommentBody: + return AtTokenAfterRazorCommentBody(); default: Debug.Fail("Invalid TokenizerState"); return default(StateResult); @@ -66,35 +66,35 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } // Optimize memory allocation by returning constants for the most frequent cases - protected override string GetSymbolContent(HtmlSymbolType type) + protected override string GetTokenContent(HtmlTokenType type) { - var symbolLength = Buffer.Length; + var tokenLength = Buffer.Length; - if (symbolLength == 1) + if (tokenLength == 1) { switch (type) { - case HtmlSymbolType.OpenAngle: + case HtmlTokenType.OpenAngle: return "<"; - case HtmlSymbolType.Bang: + case HtmlTokenType.Bang: return "!"; - case HtmlSymbolType.ForwardSlash: + case HtmlTokenType.ForwardSlash: return "/"; - case HtmlSymbolType.QuestionMark: + case HtmlTokenType.QuestionMark: return "?"; - case HtmlSymbolType.LeftBracket: + case HtmlTokenType.LeftBracket: return "["; - case HtmlSymbolType.CloseAngle: + case HtmlTokenType.CloseAngle: return ">"; - case HtmlSymbolType.RightBracket: + case HtmlTokenType.RightBracket: return "]"; - case HtmlSymbolType.Equals: + case HtmlTokenType.Equals: return "="; - case HtmlSymbolType.DoubleQuote: + case HtmlTokenType.DoubleQuote: return "\""; - case HtmlSymbolType.SingleQuote: + case HtmlTokenType.SingleQuote: return "'"; - case HtmlSymbolType.WhiteSpace: + case HtmlTokenType.WhiteSpace: if (Buffer[0] == ' ') { return " "; @@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return "\t"; } break; - case HtmlSymbolType.NewLine: + case HtmlTokenType.NewLine: if (Buffer[0] == '\n') { return "\n"; @@ -113,12 +113,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - if (symbolLength == 2 && type == HtmlSymbolType.NewLine) + if (tokenLength == 2 && type == HtmlTokenType.NewLine) { return "\r\n"; } - return base.GetSymbolContent(type); + return base.GetTokenContent(type); } // http://dev.w3.org/html5/spec/Overview.html#data-state @@ -139,21 +139,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return Transition( HtmlTokenizerState.AfterRazorCommentTransition, - EndSymbol(HtmlSymbolType.RazorCommentTransition)); + EndToken(HtmlTokenType.RazorCommentTransition)); } else if (CurrentCharacter == '@') { // Could be escaped comment transition return Transition( HtmlTokenizerState.EscapedRazorCommentTransition, - EndSymbol(HtmlSymbolType.Transition)); + EndToken(HtmlTokenType.Transition)); } - return Stay(EndSymbol(HtmlSymbolType.Transition)); + return Stay(EndToken(HtmlTokenType.Transition)); } - else if (AtSymbol()) + else if (AtToken()) { - return Stay(Symbol()); + return Stay(Token()); } else { @@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private StateResult EscapedRazorCommentTransition() { TakeCurrent(); - return Transition(HtmlTokenizerState.Data, EndSymbol(HtmlSymbolType.Transition)); + return Transition(HtmlTokenizerState.Data, EndToken(HtmlTokenType.Transition)); } private StateResult Text() @@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var prev = '\0'; while (!EndOfFile && !(ParserHelpers.IsWhitespace(CurrentCharacter) || ParserHelpers.IsNewLine(CurrentCharacter)) && - !AtSymbol()) + !AtToken()) { prev = CurrentCharacter; TakeCurrent(); @@ -190,56 +190,56 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } // Output the Text token and return to the Data state to tokenize the next character (if there is one) - return Transition(HtmlTokenizerState.Data, EndSymbol(HtmlSymbolType.Text)); + return Transition(HtmlTokenizerState.Data, EndToken(HtmlTokenType.Text)); } - private HtmlSymbol Symbol() + private HtmlToken Token() { - Debug.Assert(AtSymbol()); + Debug.Assert(AtToken()); var sym = CurrentCharacter; TakeCurrent(); switch (sym) { case '<': - return EndSymbol(HtmlSymbolType.OpenAngle); + return EndToken(HtmlTokenType.OpenAngle); case '!': - return EndSymbol(HtmlSymbolType.Bang); + return EndToken(HtmlTokenType.Bang); case '/': - return EndSymbol(HtmlSymbolType.ForwardSlash); + return EndToken(HtmlTokenType.ForwardSlash); case '?': - return EndSymbol(HtmlSymbolType.QuestionMark); + return EndToken(HtmlTokenType.QuestionMark); case '[': - return EndSymbol(HtmlSymbolType.LeftBracket); + return EndToken(HtmlTokenType.LeftBracket); case '>': - return EndSymbol(HtmlSymbolType.CloseAngle); + return EndToken(HtmlTokenType.CloseAngle); case ']': - return EndSymbol(HtmlSymbolType.RightBracket); + return EndToken(HtmlTokenType.RightBracket); case '=': - return EndSymbol(HtmlSymbolType.Equals); + return EndToken(HtmlTokenType.Equals); case '"': - return EndSymbol(HtmlSymbolType.DoubleQuote); + return EndToken(HtmlTokenType.DoubleQuote); case '\'': - return EndSymbol(HtmlSymbolType.SingleQuote); + return EndToken(HtmlTokenType.SingleQuote); case '-': Debug.Assert(CurrentCharacter == '-'); TakeCurrent(); - return EndSymbol(HtmlSymbolType.DoubleHyphen); + return EndToken(HtmlTokenType.DoubleHyphen); default: - Debug.Fail("Unexpected symbol!"); - return EndSymbol(HtmlSymbolType.Unknown); + Debug.Fail("Unexpected token!"); + return EndToken(HtmlTokenType.Unknown); } } - private HtmlSymbol Whitespace() + private HtmlToken Whitespace() { while (ParserHelpers.IsWhitespace(CurrentCharacter)) { TakeCurrent(); } - return EndSymbol(HtmlSymbolType.WhiteSpace); + return EndToken(HtmlTokenType.WhiteSpace); } - private HtmlSymbol Newline() + private HtmlToken Newline() { Debug.Assert(ParserHelpers.IsNewLine(CurrentCharacter)); // CSharp Spec §2.3.1 @@ -249,10 +249,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TakeCurrent(); } - return EndSymbol(HtmlSymbolType.NewLine); + return EndToken(HtmlTokenType.NewLine); } - private bool AtSymbol() + private bool AtToken() { return CurrentCharacter == '<' || CurrentCharacter == '<' || @@ -274,7 +274,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return Transition((int)state, result: null); } - private StateResult Transition(HtmlTokenizerState state, HtmlSymbol result) + private StateResult Transition(HtmlTokenizerState state, HtmlToken result) { return Transition((int)state, result); } @@ -289,7 +289,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy EscapedRazorCommentTransition = RazorCommentTokenizerState.EscapedRazorCommentTransition, RazorCommentBody = RazorCommentTokenizerState.RazorCommentBody, StarAfterRazorCommentBody = RazorCommentTokenizerState.StarAfterRazorCommentBody, - AtSymbolAfterRazorCommentBody = RazorCommentTokenizerState.AtSymbolAfterRazorCommentBody, + AtTokenAfterRazorCommentBody = RazorCommentTokenizerState.AtTokenAfterRazorCommentBody, } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ISymbol.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/IToken.cs similarity index 91% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ISymbol.cs rename to src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/IToken.cs index 346a390375..2f8eb1214d 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ISymbol.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/IToken.cs @@ -3,7 +3,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal interface ISymbol + internal interface IToken { Span Parent { get; set; } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ITokenizer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ITokenizer.cs index 30e5186afb..530df75dbc 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ITokenizer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ITokenizer.cs @@ -5,6 +5,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { internal interface ITokenizer { - ISymbol NextSymbol(); + IToken NextToken(); } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ImplicitExpressionEditHandler.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ImplicitExpressionEditHandler.cs index ababd6c7f7..b3869f00d0 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ImplicitExpressionEditHandler.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ImplicitExpressionEditHandler.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private readonly ISet _keywords; private readonly IReadOnlyCollection _readOnlyKeywords; - public ImplicitExpressionEditHandler(Func> tokenizer, ISet keywords, bool acceptTrailingDot) + public ImplicitExpressionEditHandler(Func> tokenizer, ISet keywords, bool acceptTrailingDot) : base(tokenizer) { _keywords = keywords ?? new HashSet(); @@ -109,11 +109,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return HandleInsertion(target, lastChar.Value, change); } + if (IsAcceptableInsertionInBalancedParenthesis(target, change)) + { + return PartialParseResultInternal.Accepted; + } + if (IsAcceptableDeletion(target, change)) { return HandleDeletion(target, lastChar.Value, change); } + if (IsAcceptableDeletionInBalancedParenthesis(target, change)) + { + return PartialParseResultInternal.Accepted; + } + return PartialParseResultInternal.Rejected; } @@ -160,44 +170,44 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return false; } - for (var i = 0; i < target.Symbols.Count; i++) + for (var i = 0; i < target.Tokens.Count; i++) { - var symbol = target.Symbols[i] as CSharpSymbol; + var token = target.Tokens[i] as CSharpToken; - if (symbol == null) + if (token == null) { break; } - var symbolStartIndex = symbol.Start.AbsoluteIndex; - var symbolEndIndex = symbolStartIndex + symbol.Content.Length; + var tokenStartIndex = token.Start.AbsoluteIndex; + var tokenEndIndex = tokenStartIndex + token.Content.Length; - // We're looking for the first symbol that contains the SourceChange. - if (symbolEndIndex > change.Span.AbsoluteIndex) + // We're looking for the first token that contains the SourceChange. + if (tokenEndIndex > change.Span.AbsoluteIndex) { - if (symbolEndIndex >= change.Span.AbsoluteIndex + change.Span.Length && symbol.Type == CSharpSymbolType.Identifier) + if (tokenEndIndex >= change.Span.AbsoluteIndex + change.Span.Length && token.Type == CSharpTokenType.Identifier) { - // The symbol we're changing happens to be an identifier. Need to check if its transformed state is also one. + // The token we're changing happens to be an identifier. Need to check if its transformed state is also one. // We do this transformation logic to capture the case that the new text change happens to not be an identifier; // i.e. "5". Alone, it's numeric, within an identifier it's classified as identifier. - var transformedContent = change.GetEditedContent(symbol.Content, change.Span.AbsoluteIndex - symbolStartIndex); - var newSymbols = Tokenizer(transformedContent); + var transformedContent = change.GetEditedContent(token.Content, change.Span.AbsoluteIndex - tokenStartIndex); + var newTokens = Tokenizer(transformedContent); - if (newSymbols.Count() != 1) + if (newTokens.Count() != 1) { - // The transformed content resulted in more than one symbol; we can only replace a single identifier with + // The transformed content resulted in more than one token; we can only replace a single identifier with // another single identifier. break; } - var newSymbol = (CSharpSymbol)newSymbols.First(); - if (newSymbol.Type == CSharpSymbolType.Identifier) + var newToken = (CSharpToken)newTokens.First(); + if (newToken.Type == CSharpTokenType.Identifier) { return true; } } - // Change is touching a non-identifier symbol or spans multiple symbols. + // Change is touching a non-identifier token or spans multiple tokens. break; } @@ -216,8 +226,196 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private static bool IsAcceptableInsertion(Span target, SourceChange change) { return change.IsInsert && - (IsAcceptableEndInsertion(target, change) || - IsAcceptableInnerInsertion(target, change)); + (IsAcceptableEndInsertion(target, change) || + IsAcceptableInnerInsertion(target, change)); + } + + // Internal for testing + internal static bool IsAcceptableDeletionInBalancedParenthesis(Span target, SourceChange change) + { + if (!change.IsDelete) + { + return false; + } + + var changeStart = change.Span.AbsoluteIndex; + var changeLength = change.Span.Length; + var changeEnd = changeStart + changeLength; + var tokens = target.Tokens.Cast().ToArray(); + if (!IsInsideParenthesis(changeStart, tokens) || !IsInsideParenthesis(changeEnd, tokens)) + { + // Either the start or end of the delete does not fall inside of parenthesis, unacceptable inner deletion. + return false; + } + + var relativePosition = changeStart - target.Start.AbsoluteIndex; + var deletionContent = target.Content.Substring(relativePosition, changeLength); + + if (deletionContent.IndexOfAny(new[] { '(', ')' }) >= 0) + { + // Change deleted some parenthesis + return false; + } + + return true; + } + + // Internal for testing + internal static bool IsAcceptableInsertionInBalancedParenthesis(Span target, SourceChange change) + { + if (!change.IsInsert) + { + return false; + } + + if (change.NewText.IndexOfAny(new[] { '(', ')' }) >= 0) + { + // Insertions of parenthesis aren't handled by us. If someone else wants to accept it, they can. + return false; + } + + var tokens = target.Tokens.Cast().ToArray(); + if (IsInsideParenthesis(change.Span.AbsoluteIndex, tokens)) + { + return true; + } + + return false; + } + + // Internal for testing + internal static bool IsInsideParenthesis(int position, IReadOnlyList tokens) + { + var balanceCount = 0; + var foundInsertionPoint = false; + for (var i = 0; i < tokens.Count; i++) + { + var currentToken = tokens[i]; + if (ContainsPosition(position, currentToken)) + { + if (balanceCount == 0) + { + // Insertion point is outside of parenthesis, i.e. inserting at the pipe: @Foo|Baz() + return false; + } + + foundInsertionPoint = true; + } + + if (!TryUpdateBalanceCount(currentToken, ref balanceCount)) + { + // Couldn't update the count. This usually occurrs when we run into a ')' outside of any parenthesis. + return false; + } + + if (foundInsertionPoint && balanceCount == 0) + { + // Once parenthesis become balanced after the insertion point we return true, no need to go further. + // If they get unbalanced down the line the expression was already unbalanced to begin with and this + // change happens prior to any ambiguity. + return true; + } + } + + // Unbalanced parenthesis + return false; + } + + // Internal for testing + internal static bool ContainsPosition(int position, CSharpToken currentToken) + { + var tokenStart = currentToken.Start.AbsoluteIndex; + if (tokenStart == position) + { + // Token is exactly at the insertion point. + return true; + } + + var tokenEnd = tokenStart + currentToken.Content.Length; + if (tokenStart < position && tokenEnd > position) + { + // Insertion point falls in the middle of the current token. + return true; + } + + return false; + } + + // Internal for testing + internal static bool TryUpdateBalanceCount(CSharpToken token, ref int count) + { + var updatedCount = count; + if (token.Type == CSharpTokenType.LeftParenthesis) + { + updatedCount++; + } + else if (token.Type == CSharpTokenType.RightParenthesis) + { + if (updatedCount == 0) + { + return false; + } + + updatedCount--; + } + else if (token.Type == CSharpTokenType.StringLiteral) + { + var content = token.Content; + if (content.Length > 0 && content[content.Length - 1] != '"') + { + // Incomplete string literal may have consumed some of our parenthesis and usually occurr during auto-completion of '"' => '""'. + if (!TryUpdateCountFromContent(content, ref updatedCount)) + { + return false; + } + } + } + else if (token.Type == CSharpTokenType.CharacterLiteral) + { + var content = token.Content; + if (content.Length > 0 && content[content.Length - 1] != '\'') + { + // Incomplete character literal may have consumed some of our parenthesis and usually occurr during auto-completion of "'" => "''". + if (!TryUpdateCountFromContent(content, ref updatedCount)) + { + return false; + } + } + } + + if (updatedCount < 0) + { + return false; + } + + count = updatedCount; + return true; + } + + // Internal for testing + internal static bool TryUpdateCountFromContent(string content, ref int count) + { + var updatedCount = count; + for (var i = 0; i < content.Length; i++) + { + if (content[i] == '(') + { + updatedCount++; + } + else if (content[i] == ')') + { + if (updatedCount == 0) + { + // Unbalanced parenthesis, i.e. @Foo) + return false; + } + + updatedCount--; + } + } + + count = updatedCount; + return true; } // Accepts character insertions at the end of spans. AKA: '@foo' -> '@fooo' or '@foo' -> '@foo ' etc. @@ -291,10 +489,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return TryAcceptChange(target, change); } - else + else if (previousChar == '(') { - return PartialParseResultInternal.Rejected; + var changeRelativePosition = change.Span.AbsoluteIndex - target.Start.AbsoluteIndex; + if (target.Content[changeRelativePosition] == ')') + { + return PartialParseResultInternal.Accepted | PartialParseResultInternal.Provisional; + } } + + return PartialParseResultInternal.Rejected; } private PartialParseResultInternal HandleInsertion(Span target, char previousChar, SourceChange change) @@ -308,6 +512,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return HandleInsertionAfterIdPart(target, change); } + else if (previousChar == '(') + { + return HandleInsertionAfterOpenParenthesis(target, change); + } else { return PartialParseResultInternal.Rejected; @@ -321,6 +529,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return TryAcceptChange(target, change); } + else if (IsDoubleParenthesisInsertion(change) || IsOpenParenthesisInsertion(change)) + { + // Allow inserting parens after an identifier - this is needed to support signature + // help intellisense in VS. + return TryAcceptChange(target, change); + } else if (EndsWithDot(change.NewText)) { // Accept it, possibly provisionally @@ -337,6 +551,40 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } + private PartialParseResultInternal HandleInsertionAfterOpenParenthesis(Span target, SourceChange change) + { + if (IsCloseParenthesisInsertion(change)) + { + return TryAcceptChange(target, change); + } + + return PartialParseResultInternal.Rejected; + } + + private static bool IsDoubleParenthesisInsertion(SourceChange change) + { + return + change.IsInsert && + change.NewText.Length == 2 && + change.NewText == "()"; + } + + private static bool IsOpenParenthesisInsertion(SourceChange change) + { + return + change.IsInsert && + change.NewText.Length == 1 && + change.NewText == "("; + } + + private static bool IsCloseParenthesisInsertion(SourceChange change) + { + return + change.IsInsert && + change.NewText.Length == 1 && + change.NewText == ")"; + } + private static bool EndsWithDot(string content) { return (content.Length == 1 && content[0] == '.') || diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/KnownSymbolType.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/KnownTokenType.cs similarity index 92% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/KnownSymbolType.cs rename to src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/KnownTokenType.cs index a1ed444ac9..ca5fad7254 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/KnownSymbolType.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/KnownTokenType.cs @@ -3,7 +3,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal enum KnownSymbolType + internal enum KnownTokenType { WhiteSpace, NewLine, diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs index 23d5f037d0..b12bf612b9 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs @@ -6,104 +6,104 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal abstract class LanguageCharacteristics - where TSymbolType : struct - where TTokenizer : Tokenizer - where TSymbol : SymbolBase + internal abstract class LanguageCharacteristics + where TTokenType : struct + where TTokenizer : Tokenizer + where TToken : TokenBase { - public abstract string GetSample(TSymbolType type); + public abstract string GetSample(TTokenType type); public abstract TTokenizer CreateTokenizer(ITextDocument source); - public abstract TSymbolType FlipBracket(TSymbolType bracket); - public abstract TSymbol CreateMarkerSymbol(); + public abstract TTokenType FlipBracket(TTokenType bracket); + public abstract TToken CreateMarkerToken(); - public virtual IEnumerable TokenizeString(string content) + public virtual IEnumerable TokenizeString(string content) { return TokenizeString(SourceLocation.Zero, content); } - public virtual IEnumerable TokenizeString(SourceLocation start, string input) + public virtual IEnumerable TokenizeString(SourceLocation start, string input) { using (var reader = new SeekableTextReader(input, start.FilePath)) { var tok = CreateTokenizer(reader); - TSymbol sym; - while ((sym = tok.NextSymbol()) != null) + TToken token; + while ((token = tok.NextToken()) != null) { - yield return sym; + yield return token; } } } - public virtual bool IsWhiteSpace(TSymbol symbol) + public virtual bool IsWhiteSpace(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.WhiteSpace); + return IsKnownTokenType(token, KnownTokenType.WhiteSpace); } - public virtual bool IsNewLine(TSymbol symbol) + public virtual bool IsNewLine(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.NewLine); + return IsKnownTokenType(token, KnownTokenType.NewLine); } - public virtual bool IsIdentifier(TSymbol symbol) + public virtual bool IsIdentifier(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.Identifier); + return IsKnownTokenType(token, KnownTokenType.Identifier); } - public virtual bool IsKeyword(TSymbol symbol) + public virtual bool IsKeyword(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.Keyword); + return IsKnownTokenType(token, KnownTokenType.Keyword); } - public virtual bool IsTransition(TSymbol symbol) + public virtual bool IsTransition(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.Transition); + return IsKnownTokenType(token, KnownTokenType.Transition); } - public virtual bool IsCommentStart(TSymbol symbol) + public virtual bool IsCommentStart(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.CommentStart); + return IsKnownTokenType(token, KnownTokenType.CommentStart); } - public virtual bool IsCommentStar(TSymbol symbol) + public virtual bool IsCommentStar(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.CommentStar); + return IsKnownTokenType(token, KnownTokenType.CommentStar); } - public virtual bool IsCommentBody(TSymbol symbol) + public virtual bool IsCommentBody(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.CommentBody); + return IsKnownTokenType(token, KnownTokenType.CommentBody); } - public virtual bool IsUnknown(TSymbol symbol) + public virtual bool IsUnknown(TToken token) { - return IsKnownSymbolType(symbol, KnownSymbolType.Unknown); + return IsKnownTokenType(token, KnownTokenType.Unknown); } - public virtual bool IsKnownSymbolType(TSymbol symbol, KnownSymbolType type) + public virtual bool IsKnownTokenType(TToken token, KnownTokenType type) { - return symbol != null && Equals(symbol.Type, GetKnownSymbolType(type)); + return token != null && Equals(token.Type, GetKnownTokenType(type)); } - public virtual Tuple SplitSymbol(TSymbol symbol, int splitAt, TSymbolType leftType) + public virtual Tuple SplitToken(TToken token, int splitAt, TTokenType leftType) { - var left = CreateSymbol(symbol.Content.Substring(0, splitAt), leftType, RazorDiagnostic.EmptyArray); + var left = CreateToken(token.Content.Substring(0, splitAt), leftType, RazorDiagnostic.EmptyArray); - TSymbol right = null; - if (splitAt < symbol.Content.Length) + TToken right = null; + if (splitAt < token.Content.Length) { - right = CreateSymbol(symbol.Content.Substring(splitAt), symbol.Type, symbol.Errors); + right = CreateToken(token.Content.Substring(splitAt), token.Type, token.Errors); } return Tuple.Create(left, right); } - public abstract TSymbolType GetKnownSymbolType(KnownSymbolType type); + public abstract TTokenType GetKnownTokenType(KnownTokenType type); - public virtual bool KnowsSymbolType(KnownSymbolType type) + public virtual bool KnowsTokenType(KnownTokenType type) { - return type == KnownSymbolType.Unknown || !Equals(GetKnownSymbolType(type), GetKnownSymbolType(KnownSymbolType.Unknown)); + return type == KnownTokenType.Unknown || !Equals(GetKnownTokenType(type), GetKnownTokenType(KnownTokenType.Unknown)); } - protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); + protected abstract TToken CreateToken(string content, TTokenType type, IReadOnlyList errors); } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/MarkupRewriter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/MarkupRewriter.cs index 6ce51f273f..42074050ff 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/MarkupRewriter.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/MarkupRewriter.cs @@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy builder.Kind = SpanKindInternal.Markup; builder.ChunkGenerator = new MarkupChunkGenerator(); - foreach (ISymbol sym in HtmlLanguageCharacteristics.Instance.TokenizeString(start, content)) + foreach (IToken sym in HtmlLanguageCharacteristics.Instance.TokenizeString(start, content)) { builder.Accept(sym); } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParentChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParentChunkGenerator.cs index 0d57311757..09a8c94f28 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParentChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParentChunkGenerator.cs @@ -47,10 +47,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public void Accept(ParserVisitor visitor, Block block) { - for (var i = 0; i < block.Children.Count; i++) - { - block.Children[i].Accept(visitor); - } + visitor.VisitDefault(block); } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserHelpers.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserHelpers.cs index 71835178b2..fc5b31a1e3 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserHelpers.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserHelpers.cs @@ -19,15 +19,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy '\u2029' // Paragraph separator }; - public static bool IsNewLine(char value) - { - return NewLineCharacters.Contains(value); - } + public static bool IsNewLine(char value) => Array.IndexOf(NewLineCharacters, value) != -1; public static bool IsNewLine(string value) { + // We want to handle both LF and CRLF regardless of the platform. + // We explicitly check for CRLF and IsNewLine() should return true for LF. return (value.Length == 1 && (IsNewLine(value[0]))) || - (string.Equals(value, Environment.NewLine, StringComparison.Ordinal)); + (string.Equals(value, "\r\n", StringComparison.Ordinal)); } public static bool IsIdentifier(string value) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserVisitor.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserVisitor.cs index 108fcf5d21..fe6031046e 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserVisitor.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserVisitor.cs @@ -5,7 +5,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { internal abstract class ParserVisitor { - protected virtual void VisitDefault(Block block) + public virtual void Visit(SyntaxTreeNode node) + { + node.Accept(this); + } + + public virtual void VisitDefault(Block block) { for (var i = 0; i < block.Children.Count; i++) { @@ -13,6 +18,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } + public virtual void VisitDefault(Span span) + { + } + public virtual void VisitBlock(Block block) { if (block.ChunkGenerator != null) @@ -44,35 +53,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy VisitDefault(block); } - public virtual void VisitExpressionSpan(ExpressionChunkGenerator chunkGenerator, Span span) - { - } - - public virtual void VisitMarkupSpan(MarkupChunkGenerator chunkGenerator, Span span) - { - } - - public virtual void VisitImportSpan(AddImportChunkGenerator chunkGenerator, Span span) - { - } - - public virtual void VisitStatementSpan(StatementChunkGenerator chunkGenerator, Span span) - { - } - - public virtual void VisitLiteralAttributeSpan(LiteralAttributeChunkGenerator chunkGenerator, Span span) - { - } - - public virtual void VisitDirectiveToken(DirectiveTokenChunkGenerator chunkGenerator, Span block) - { - } - - public virtual void VisitDirectiveBlock(DirectiveChunkGenerator chunkGenerator, Block block) - { - VisitDefault(block); - } - public virtual void VisitTemplateBlock(TemplateBlockChunkGenerator chunkGenerator, Block block) { VisitDefault(block); @@ -88,16 +68,54 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy VisitDefault(block); } + public virtual void VisitDirectiveBlock(DirectiveChunkGenerator chunkGenerator, Block block) + { + VisitDefault(block); + } + + public virtual void VisitExpressionSpan(ExpressionChunkGenerator chunkGenerator, Span span) + { + VisitDefault(span); + } + + public virtual void VisitMarkupSpan(MarkupChunkGenerator chunkGenerator, Span span) + { + VisitDefault(span); + } + + public virtual void VisitImportSpan(AddImportChunkGenerator chunkGenerator, Span span) + { + VisitDefault(span); + } + + public virtual void VisitStatementSpan(StatementChunkGenerator chunkGenerator, Span span) + { + VisitDefault(span); + } + + public virtual void VisitLiteralAttributeSpan(LiteralAttributeChunkGenerator chunkGenerator, Span span) + { + VisitDefault(span); + } + + public virtual void VisitDirectiveToken(DirectiveTokenChunkGenerator chunkGenerator, Span span) + { + VisitDefault(span); + } + public virtual void VisitAddTagHelperSpan(AddTagHelperChunkGenerator chunkGenerator, Span span) { + VisitDefault(span); } public virtual void VisitRemoveTagHelperSpan(RemoveTagHelperChunkGenerator chunkGenerator, Span span) { + VisitDefault(span); } public virtual void VisitTagHelperPrefixDirectiveSpan(TagHelperPrefixDirectiveChunkGenerator chunkGenerator, Span span) { + VisitDefault(span); } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorCommentChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorCommentChunkGenerator.cs index fdf6a6f1e4..4d3d13f0b0 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorCommentChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorCommentChunkGenerator.cs @@ -9,5 +9,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { visitor.VisitCommentBlock(this, block); } + + public override string ToString() + { + return "RazorComment"; + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorSyntaxTreeExtensions.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorSyntaxTreeExtensions.cs new file mode 100644 index 0000000000..a07082152c --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorSyntaxTreeExtensions.cs @@ -0,0 +1,130 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + internal static class RazorSyntaxTreeExtensions + { + public static IReadOnlyList GetClassifiedSpans(this RazorSyntaxTree syntaxTree) + { + if (syntaxTree == null) + { + throw new ArgumentNullException(nameof(syntaxTree)); + } + + var spans = Flatten(syntaxTree); + + var result = new ClassifiedSpanInternal[spans.Count]; + for (var i = 0; i < spans.Count; i++) + { + var span = spans[i]; + result[i] = new ClassifiedSpanInternal( + new SourceSpan( + span.Start.FilePath ?? syntaxTree.Source.FilePath, + span.Start.AbsoluteIndex, + span.Start.LineIndex, + span.Start.CharacterIndex, + span.Length), + new SourceSpan( + span.Parent.Start.FilePath ?? syntaxTree.Source.FilePath, + span.Parent.Start.AbsoluteIndex, + span.Parent.Start.LineIndex, + span.Parent.Start.CharacterIndex, + span.Parent.Length), + span.Kind, + span.Parent.Type, + span.EditHandler.AcceptedCharacters); + } + + return result; + } + + public static IReadOnlyList GetTagHelperSpans(this RazorSyntaxTree syntaxTree) + { + if (syntaxTree == null) + { + throw new ArgumentNullException(nameof(syntaxTree)); + } + + var results = new List(); + + var toProcess = new List(); + var blockChildren = new List(); + toProcess.Add(syntaxTree.Root); + + for (var i = 0; i < toProcess.Count; i++) + { + var blockNode = toProcess[i]; + if (blockNode is TagHelperBlock tagHelperNode) + { + results.Add(new TagHelperSpanInternal( + new SourceSpan( + tagHelperNode.Start.FilePath ?? syntaxTree.Source.FilePath, + tagHelperNode.Start.AbsoluteIndex, + tagHelperNode.Start.LineIndex, + tagHelperNode.Start.CharacterIndex, + tagHelperNode.Length), + tagHelperNode.Binding)); + } + + // collect all child blocks and inject into toProcess as a single InsertRange + foreach (var child in blockNode.Children) + { + if (child is Block block) + { + blockChildren.Add(block); + } + } + + if (blockChildren.Count > 0) + { + toProcess.InsertRange(i + 1, blockChildren); + blockChildren.Clear(); + } + } + + return results; + } + + private static List Flatten(RazorSyntaxTree syntaxTree) + { + var result = new List(); + AppendFlattenedSpans(syntaxTree.Root, result); + return result; + + void AppendFlattenedSpans(SyntaxTreeNode node, List foundSpans) + { + if (node is Span spanNode) + { + foundSpans.Add(spanNode); + } + else + { + if (node is TagHelperBlock tagHelperNode) + { + // These aren't in document order, sort them first and then dig in + var attributeNodes = tagHelperNode.Attributes.Select(kvp => kvp.Value).Where(att => att != null).ToList(); + attributeNodes.Sort((x, y) => x.Start.AbsoluteIndex.CompareTo(y.Start.AbsoluteIndex)); + + foreach (var attributeNode in attributeNodes) + { + AppendFlattenedSpans(attributeNode, foundSpans); + } + } + + if (node is Block block) + { + foreach (var child in block.Children) + { + AppendFlattenedSpans(child, foundSpans); + } + } + } + } + } + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RemoveTagHelperChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RemoveTagHelperChunkGenerator.cs index 09328bb69c..58b170d33e 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RemoveTagHelperChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/RemoveTagHelperChunkGenerator.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language.Legacy @@ -63,5 +64,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return combiner.CombinedHash; } + + public override string ToString() + { + var builder = new StringBuilder("RemoveTagHelper:{"); + builder.Append(LookupText); + builder.Append(";"); + builder.Append(DirectiveText); + builder.Append(";"); + builder.Append(TypePattern); + builder.Append(";"); + builder.Append(AssemblyName); + builder.Append("}"); + + if (Diagnostics.Count > 0) + { + builder.Append(" ["); + var ids = string.Join(", ", Diagnostics.Select(diagnostic => $"{diagnostic.Id}{diagnostic.Span}")); + builder.Append(ids); + builder.Append("]"); + } + + return builder.ToString(); + } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SeekableTextReader.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SeekableTextReader.cs index b95b649a67..85057cf9fb 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SeekableTextReader.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SeekableTextReader.cs @@ -10,8 +10,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { private readonly LineTrackingStringBuffer _buffer; private int _position = 0; + private int _current; private SourceLocation _location; - private char? _current; public SeekableTextReader(string source, string filePath) : this(source.ToCharArray(), filePath) { } @@ -24,8 +24,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy _buffer = new LineTrackingStringBuffer(source, filePath); UpdateState(); - - _location = new SourceLocation(filePath, 0, 0, 0); } public SourceLocation Location => _location; @@ -47,24 +45,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public override int Read() { - if (_current == null) - { - return -1; - } - var chr = _current.Value; + var c = _current; _position++; UpdateState(); - return chr; + return c; } - public override int Peek() - { - if (_current == null) - { - return -1; - } - return _current.Value; - } + public override int Peek() => _current; private void UpdateState() { @@ -76,12 +63,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } else if (_buffer.Length == 0) { - _current = null; + _current = -1; _location = SourceLocation.Zero; } else { - _current = null; + _current = -1; _location = _buffer.EndLocation; } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs index 9b7366fc5e..fbf9f9f2c2 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public ISpanChunkGenerator ChunkGenerator { get; private set; } public SpanKindInternal Kind { get; private set; } - public IReadOnlyList Symbols { get; private set; } + public IReadOnlyList Tokens { get; private set; } // Allow test code to re-link spans public Span Previous { get; internal set; } @@ -42,9 +42,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var length = 0; if (_content == null) { - for (var i = 0; i < Symbols.Count; i++) + for (var i = 0; i < Tokens.Count; i++) { - length += Symbols[i].Content.Length; + length += Tokens[i].Content.Length; } } else @@ -67,19 +67,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (_content == null) { - var symbolCount = Symbols.Count; - if (symbolCount == 1) + var tokenCount = Tokens.Count; + if (tokenCount == 1) { // Perf: no StringBuilder allocation if not necessary - _content = Symbols[0].Content; + _content = Tokens[0].Content; } else { var builder = new StringBuilder(); - for (var i = 0; i < symbolCount; i++) + for (var i = 0; i < tokenCount; i++) { - var symbol = Symbols[i]; - builder.Append(symbol.Content); + var token = Tokens[i]; + builder.Append(token.Content); } _content = builder.ToString(); @@ -93,11 +93,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public void ReplaceWith(SpanBuilder builder) { Kind = builder.Kind; - Symbols = builder.Symbols; + Tokens = builder.Tokens; - for (var i = 0; i Gen: <"); builder.Append(ChunkGenerator.ToString()); builder.Append("> {"); - builder.Append(string.Join(";", Symbols.GroupBy(sym => sym.GetType()).Select(grp => string.Concat(grp.Key.Name, ":", grp.Count())))); + builder.Append(string.Join(";", Tokens.GroupBy(sym => sym.GetType()).Select(grp => string.Concat(grp.Key.Name, ":", grp.Count())))); builder.Append("}"); return builder.ToString(); } @@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Kind.Equals(other.Kind) && EditHandler.Equals(other.EditHandler) && ChunkGenerator.Equals(other.ChunkGenerator) && - Symbols.SequenceEqual(other.Symbols); + Tokens.SequenceEqual(other.Tokens); } public override int GetHashCode() diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanBuilder.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanBuilder.cs index b9b9e2df54..6d2e647b91 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanBuilder.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanBuilder.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy internal class SpanBuilder { private SourceLocation _start; - private List _symbols; + private List _tokens; private SourceLocationTracker _tracker; public SpanBuilder(Span original) @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy _start = original.Start; ChunkGenerator = original.ChunkGenerator; - _symbols = new List(original.Symbols); + _tokens = new List(original.Tokens); _tracker = new SourceLocationTracker(original.Start); } @@ -49,16 +49,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public SpanKindInternal Kind { get; set; } - public IReadOnlyList Symbols + public IReadOnlyList Tokens { get { - if (_symbols == null) + if (_tokens == null) { - _symbols = new List(); + _tokens = new List(); } - return _symbols; + return _tokens; } } @@ -68,10 +68,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Need to potentially allocate a new list because Span.ReplaceWith takes ownership // of the original list. - _symbols = null; - _symbols = new List(); + _tokens = null; + _tokens = new List(); - EditHandler = SpanEditHandler.CreateDefault((content) => Enumerable.Empty()); + EditHandler = SpanEditHandler.CreateDefault((content) => Enumerable.Empty()); ChunkGenerator = SpanChunkGenerator.Null; Start = SourceLocation.Undefined; } @@ -80,23 +80,23 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var span = new Span(this); - for (var i = 0; i < span.Symbols.Count; i++) + for (var i = 0; i < span.Tokens.Count; i++) { - var symbol = span.Symbols[i]; - symbol.Parent = span; + var token = span.Tokens[i]; + token.Parent = span; } return span; } - public void ClearSymbols() + public void ClearTokens() { - _symbols?.Clear(); + _tokens?.Clear(); } - public void Accept(ISymbol symbol) + public void Accept(IToken token) { - if (symbol == null) + if (token == null) { return; } @@ -106,8 +106,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy throw new InvalidOperationException("SpanBuilder must have a valid location"); } - _symbols.Add(symbol); - _tracker.UpdateLocation(symbol.Content); + _tokens.Add(token); + _tracker.UpdateLocation(token.Content); } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanChunkGenerator.cs index 75defef805..4e15538609 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanChunkGenerator.cs @@ -32,6 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public void Accept(ParserVisitor visitor, Span span) { + visitor.VisitDefault(span); } public void GenerateChunk(Span target, ChunkGeneratorContext context) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanEditHandler.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanEditHandler.cs index dd9511ce70..d5407f34dd 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanEditHandler.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanEditHandler.cs @@ -11,12 +11,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { private static readonly int TypeHashCode = typeof(SpanEditHandler).GetHashCode(); - public SpanEditHandler(Func> tokenizer) + public SpanEditHandler(Func> tokenizer) : this(tokenizer, AcceptedCharactersInternal.Any) { } - public SpanEditHandler(Func> tokenizer, AcceptedCharactersInternal accepted) + public SpanEditHandler(Func> tokenizer, AcceptedCharactersInternal accepted) { AcceptedCharacters = accepted; Tokenizer = tokenizer; @@ -24,9 +24,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public AcceptedCharactersInternal AcceptedCharacters { get; set; } - public Func> Tokenizer { get; set; } + public Func> Tokenizer { get; set; } - public static SpanEditHandler CreateDefault(Func> tokenizer) + public static SpanEditHandler CreateDefault(Func> tokenizer) { return new SpanEditHandler(tokenizer); } @@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var newContent = change.GetEditedContent(target); var newSpan = new SpanBuilder(target); - newSpan.ClearSymbols(); + newSpan.ClearTokens(); foreach (var token in Tokenizer(newContent)) { newSpan.Accept(token); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs index a20c7c318b..1b7b192db9 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy /// The node to compare this node with /// /// true if the provided node has all the same content and metadata, though the specific quantity and type of - /// symbols may be different. + /// tokens may be different. /// public abstract bool EquivalentTo(SyntaxTreeNode node); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs index bfb31bce05..f08d0579e5 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs @@ -42,8 +42,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // We skip the first child "" or "/>". // The -2 accounts for both the start and end tags. If the tag does not have a valid structure then there's // no end tag to ignore. - var symbolOffset = validStructure ? 2 : 1; - var attributeChildren = tagBlock.Children.Skip(1).Take(tagBlock.Children.Count() - symbolOffset); + var tokenOffset = validStructure ? 2 : 1; + var attributeChildren = tagBlock.Children.Skip(1).Take(tagBlock.Children.Count() - tokenOffset); var processedBoundAttributeNames = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (var child in attributeChildren) @@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } else { - // Error occured while parsing the attribute. Don't try parsing the rest to avoid misleading errors. + // Error occurred while parsing the attribute. Don't try parsing the rest to avoid misleading errors. break; } } @@ -149,8 +149,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Kind = span.Kind }; - // Will contain symbols that represent a single attribute value: - var htmlSymbols = span.Symbols.OfType().ToArray(); + // Will contain tokens that represent a single attribute value: + var htmlTokens = span.Tokens.OfType().ToArray(); var capturedAttributeValueStart = false; var attributeValueStartLocation = span.Start; @@ -158,53 +158,53 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // TryParseBlock() variation of attribute parsing. var attributeValueStyle = AttributeStructure.DoubleQuotes; - // The symbolOffset is initialized to 0 to expect worst case: "class=". If a quote is found later on for - // the attribute value the symbolOffset is adjusted accordingly. - var symbolOffset = 0; + // The tokenOffset is initialized to 0 to expect worst case: "class=". If a quote is found later on for + // the attribute value the tokenOffset is adjusted accordingly. + var tokenOffset = 0; string name = null; - // Iterate down through the symbols to find the name and the start of the value. - // We subtract the symbolOffset so we don't accept an ending quote of a span. - for (var i = 0; i < htmlSymbols.Length - symbolOffset; i++) + // Iterate down through the tokens to find the name and the start of the value. + // We subtract the tokenOffset so we don't accept an ending quote of a span. + for (var i = 0; i < htmlTokens.Length - tokenOffset; i++) { - var symbol = htmlSymbols[i]; + var token = htmlTokens[i]; if (afterEquals) { // We've captured all leading whitespace, the attribute name, and an equals with an optional // quote/double quote. We're now at: " asp-for='|...'" or " asp-for=|..." - // The goal here is to capture all symbols until the end of the attribute. Note this will not - // consume an ending quote due to the symbolOffset. + // The goal here is to capture all tokens until the end of the attribute. Note this will not + // consume an ending quote due to the tokenOffset. - // When symbols are accepted into SpanBuilders, their locations get altered to be offset by the - // parent which is why we need to mark our start location prior to adding the symbol. + // When tokens are accepted into SpanBuilders, their locations get altered to be offset by the + // parent which is why we need to mark our start location prior to adding the token. // This is needed to know the location of the attribute value start within the document. if (!capturedAttributeValueStart) { capturedAttributeValueStart = true; - attributeValueStartLocation = symbol.Start; + attributeValueStartLocation = token.Start; } - builder.Accept(symbol); + builder.Accept(token); } - else if (name == null && HtmlMarkupParser.IsValidAttributeNameSymbol(symbol)) + else if (name == null && HtmlMarkupParser.IsValidAttributeNameToken(token)) { // We've captured all leading whitespace prior to the attribute name. // We're now at: " |asp-for='...'" or " |asp-for=..." // The goal here is to capture the attribute name. var nameBuilder = new StringBuilder(); - // Move the indexer past the attribute name symbols. - for (var j = i; j < htmlSymbols.Length; j++) + // Move the indexer past the attribute name tokens. + for (var j = i; j < htmlTokens.Length; j++) { - var nameSymbol = htmlSymbols[j]; - if (!HtmlMarkupParser.IsValidAttributeNameSymbol(nameSymbol)) + var nameToken = htmlTokens[j]; + if (!HtmlMarkupParser.IsValidAttributeNameToken(nameToken)) { break; } - nameBuilder.Append(nameSymbol.Content); + nameBuilder.Append(nameToken.Content); i++; } @@ -213,67 +213,67 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy name = nameBuilder.ToString(); attributeValueStartLocation = SourceLocationTracker.Advance(attributeValueStartLocation, name); } - else if (symbol.Type == HtmlSymbolType.Equals) + else if (token.Type == HtmlTokenType.Equals) { // We've captured all leading whitespace and the attribute name. // We're now at: " asp-for|='...'" or " asp-for|=..." // The goal here is to consume the equal sign and the optional single/double-quote. - // The coming symbols will either be a quote or value (in the case that the value is unquoted). + // The coming tokens will either be a quote or value (in the case that the value is unquoted). - SourceLocation symbolStartLocation; + SourceLocation tokenStartLocation; // Skip the whitespace preceding the start of the attribute value. do { - i++; // Start from the symbol after '='. - } while (i < htmlSymbols.Length && - (htmlSymbols[i].Type == HtmlSymbolType.WhiteSpace || - htmlSymbols[i].Type == HtmlSymbolType.NewLine)); + i++; // Start from the token after '='. + } while (i < htmlTokens.Length && + (htmlTokens[i].Type == HtmlTokenType.WhiteSpace || + htmlTokens[i].Type == HtmlTokenType.NewLine)); // Check for attribute start values, aka single or double quote - if (i < htmlSymbols.Length && IsQuote(htmlSymbols[i])) + if (i < htmlTokens.Length && IsQuote(htmlTokens[i])) { - if (htmlSymbols[i].Type == HtmlSymbolType.SingleQuote) + if (htmlTokens[i].Type == HtmlTokenType.SingleQuote) { attributeValueStyle = AttributeStructure.SingleQuotes; } - symbolStartLocation = htmlSymbols[i].Start; + tokenStartLocation = htmlTokens[i].Start; // If there's a start quote then there must be an end quote to be valid, skip it. - symbolOffset = 1; + tokenOffset = 1; } else { - // We are at the symbol after equals. Go back to equals to ensure we don't skip past that symbol. + // We are at the token after equals. Go back to equals to ensure we don't skip past that token. i--; - symbolStartLocation = symbol.Start; + tokenStartLocation = token.Start; } attributeValueStartLocation = new SourceLocation( - symbolStartLocation.FilePath, - symbolStartLocation.AbsoluteIndex + 1, - symbolStartLocation.LineIndex, - symbolStartLocation.CharacterIndex + 1); + tokenStartLocation.FilePath, + tokenStartLocation.AbsoluteIndex + 1, + tokenStartLocation.LineIndex, + tokenStartLocation.CharacterIndex + 1); afterEquals = true; } - else if (symbol.Type == HtmlSymbolType.WhiteSpace) + else if (token.Type == HtmlTokenType.WhiteSpace) { // We're at the start of the attribute, this branch may be hit on the first iterations of - // the loop since the parser separates attributes with their spaces included as symbols. + // the loop since the parser separates attributes with their spaces included as tokens. // We're at: "| asp-for='...'" or "| asp-for=..." // Note: This will not be hit even for situations like asp-for ="..." because the core Razor // parser currently does not know how to handle attributes in that format. This will be addressed // by https://github.com/aspnet/Razor/issues/123. - attributeValueStartLocation = SourceLocationTracker.Advance(attributeValueStartLocation, symbol.Content); + attributeValueStartLocation = SourceLocationTracker.Advance(attributeValueStartLocation, token.Content); } } - // After all symbols have been added we need to set the builders start position so we do not indirectly + // After all tokens have been added we need to set the builders start position so we do not indirectly // modify the span's start location. builder.Start = attributeValueStartLocation; @@ -341,14 +341,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return TryParseSpan(childSpan, descriptors, errorSink, processedBoundAttributeNames); } - var nameSymbols = childSpan - .Symbols - .OfType() - .SkipWhile(symbol => !HtmlMarkupParser.IsValidAttributeNameSymbol(symbol)) // Skip prefix - .TakeWhile(nameSymbol => HtmlMarkupParser.IsValidAttributeNameSymbol(nameSymbol)) - .Select(nameSymbol => nameSymbol.Content); + var nameTokens = childSpan + .Tokens + .OfType() + .SkipWhile(token => !HtmlMarkupParser.IsValidAttributeNameToken(token)) // Skip prefix + .TakeWhile(nameToken => HtmlMarkupParser.IsValidAttributeNameToken(nameToken)) + .Select(nameToken => nameToken.Content); - var name = string.Concat(nameSymbols); + var name = string.Concat(nameTokens); if (string.IsNullOrEmpty(name)) { var location = new SourceSpan(childSpan.Start, childSpan.Length); @@ -362,12 +362,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var result = CreateTryParseResult(name, descriptors, processedBoundAttributeNames); var firstChild = builder.Children[0] as Span; - if (firstChild != null && firstChild.Symbols[0] is HtmlSymbol) + if (firstChild != null && firstChild.Tokens[0] is HtmlToken) { - var htmlSymbol = firstChild.Symbols[firstChild.Symbols.Count - 1] as HtmlSymbol; - switch (htmlSymbol.Type) + var htmlToken = firstChild.Tokens[firstChild.Tokens.Count - 1] as HtmlToken; + switch (htmlToken.Type) { - case HtmlSymbolType.Equals: + case HtmlTokenType.Equals: if (builder.Children.Count == 2 && builder.Children[1] is Span value && value.Kind == SpanKindInternal.Markup) @@ -385,10 +385,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy result.AttributeStructure = AttributeStructure.DoubleQuotes; } break; - case HtmlSymbolType.DoubleQuote: + case HtmlTokenType.DoubleQuote: result.AttributeStructure = AttributeStructure.DoubleQuotes; break; - case HtmlSymbolType.SingleQuote: + case HtmlTokenType.SingleQuote: result.AttributeStructure = AttributeStructure.SingleQuotes; break; default: @@ -407,12 +407,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var endSpan = (Span)endNode; // In some malformed cases e.g.

would cause an error because there's no // matching end

tag in the template block scope and therefore doesn't make sense as a tag helper. BuildMalformedTagHelpers(_trackerStack.Count - activeTrackers, errorSink); - - Debug.Assert(activeTrackers == _trackerStack.Count); } BuildCurrentlyTrackedBlock(); @@ -370,12 +368,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // We can assume the first span will always contain attributename=" and the last span will always // contain the final quote. Therefore, if the values not quoted there's no ending quote to skip. var childOffset = 0; - if (childSpan.Symbols.Count > 0) + if (childSpan.Tokens.Count > 0) { - var potentialQuote = childSpan.Symbols[childSpan.Symbols.Count - 1] as HtmlSymbol; + var potentialQuote = childSpan.Tokens[childSpan.Tokens.Count - 1] as HtmlToken; if (potentialQuote != null && - (potentialQuote.Type == HtmlSymbolType.DoubleQuote || - potentialQuote.Type == HtmlSymbolType.SingleQuote)) + (potentialQuote.Type == HtmlTokenType.DoubleQuote || + potentialQuote.Type == HtmlTokenType.SingleQuote)) { childOffset = 1; } @@ -391,9 +389,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { var valueChildSpan = (Span)valueChild; - for (var k = 0; k < valueChildSpan.Symbols.Count; k++) + for (var k = 0; k < valueChildSpan.Tokens.Count; k++) { - _attributeValueBuilder.Append(valueChildSpan.Symbols[k].Content); + _attributeValueBuilder.Append(valueChildSpan.Tokens[k].Content); } } } @@ -404,43 +402,43 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var afterEquals = false; var atValue = false; - var endValueMarker = childSpan.Symbols.Count; + var endValueMarker = childSpan.Tokens.Count; // Entire attribute is a string for (var j = 0; j < endValueMarker; j++) { - var htmlSymbol = (HtmlSymbol)childSpan.Symbols[j]; + var htmlToken = (HtmlToken)childSpan.Tokens[j]; if (!afterEquals) { - afterEquals = htmlSymbol.Type == HtmlSymbolType.Equals; + afterEquals = htmlToken.Type == HtmlTokenType.Equals; continue; } if (!atValue) { - atValue = htmlSymbol.Type != HtmlSymbolType.WhiteSpace && - htmlSymbol.Type != HtmlSymbolType.NewLine; + atValue = htmlToken.Type != HtmlTokenType.WhiteSpace && + htmlToken.Type != HtmlTokenType.NewLine; if (atValue) { - if (htmlSymbol.Type == HtmlSymbolType.DoubleQuote || - htmlSymbol.Type == HtmlSymbolType.SingleQuote) + if (htmlToken.Type == HtmlTokenType.DoubleQuote || + htmlToken.Type == HtmlTokenType.SingleQuote) { endValueMarker--; } else { - // Current symbol is considered the value (unquoted). Add its content to the + // Current token is considered the value (unquoted). Add its content to the // attribute value builder before we move past it. - _attributeValueBuilder.Append(htmlSymbol.Content); + _attributeValueBuilder.Append(htmlToken.Content); } } continue; } - _attributeValueBuilder.Append(htmlSymbol.Content); + _attributeValueBuilder.Append(htmlToken.Content); } } @@ -642,11 +640,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // If our tag end is not a markup span it means it's some sort of code SyntaxTreeNode (not a valid format) if (tagEnd != null && tagEnd.Kind == SpanKindInternal.Markup) { - var endSymbol = tagEnd.Symbols.Count > 0 ? - tagEnd.Symbols[tagEnd.Symbols.Count - 1] as HtmlSymbol : + var endToken = tagEnd.Tokens.Count > 0 ? + tagEnd.Tokens[tagEnd.Tokens.Count - 1] as HtmlToken : null; - if (endSymbol != null && endSymbol.Type == HtmlSymbolType.CloseAngle) + if (endToken != null && endToken.Type == HtmlTokenType.CloseAngle) { return false; } @@ -793,25 +791,25 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } var childSpan = (Span)child; - HtmlSymbol textSymbol = null; - for (var i = 0; i < childSpan.Symbols.Count; i++) + HtmlToken textToken = null; + for (var i = 0; i < childSpan.Tokens.Count; i++) { - var symbol = childSpan.Symbols[i] as HtmlSymbol; + var token = childSpan.Tokens[i] as HtmlToken; - if (symbol != null && - (symbol.Type & (HtmlSymbolType.WhiteSpace | HtmlSymbolType.Text)) == symbol.Type) + if (token != null && + (token.Type & (HtmlTokenType.WhiteSpace | HtmlTokenType.Text)) == token.Type) { - textSymbol = symbol; + textToken = token; break; } } - if (textSymbol == null) + if (textToken == null) { return null; } - return textSymbol.Type == HtmlSymbolType.WhiteSpace ? null : textSymbol.Content; + return textToken.Type == HtmlTokenType.WhiteSpace ? null : textToken.Content; } private static bool IsEndTag(Block tagBlock) @@ -820,10 +818,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var childSpan = (Span)tagBlock.Children.First(); - // We grab the symbol that could be forward slash - var relevantSymbol = (HtmlSymbol)childSpan.Symbols[childSpan.Symbols.Count == 1 ? 0 : 1]; + // We grab the token that could be forward slash + var relevantToken = (HtmlToken)childSpan.Tokens[childSpan.Tokens.Count == 1 ? 0 : 1]; - return relevantSymbol.Type == HtmlSymbolType.ForwardSlash; + return relevantToken.Type == HtmlTokenType.ForwardSlash; } internal static bool IsComment(Span span) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperPrefixDirectiveChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperPrefixDirectiveChunkGenerator.cs index bed1cadcc7..f559ed585c 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperPrefixDirectiveChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperPrefixDirectiveChunkGenerator.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language.Legacy @@ -48,5 +49,24 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return combiner.CombinedHash; } + + public override string ToString() + { + var builder = new StringBuilder("TagHelperPrefix:{"); + builder.Append(Prefix); + builder.Append(";"); + builder.Append(DirectiveText); + builder.Append("}"); + + if (Diagnostics.Count > 0) + { + builder.Append(" ["); + var ids = string.Join(", ", Diagnostics.Select(diagnostic => $"{diagnostic.Id}{diagnostic.Span}")); + builder.Append(ids); + builder.Append("]"); + } + + return builder.ToString(); + } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperSpanInternal.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperSpanInternal.cs new file mode 100644 index 0000000000..8d5ff92f9d --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperSpanInternal.cs @@ -0,0 +1,28 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + internal struct TagHelperSpanInternal + { + public TagHelperSpanInternal(SourceSpan span, TagHelperBinding binding) + { + if (binding == null) + { + throw new ArgumentNullException(nameof(binding)); + } + + Span = span; + Binding = binding; + } + + public TagHelperBinding Binding { get; } + + public IEnumerable TagHelpers => Binding.Descriptors; + + public SourceSpan Span { get; } + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TemplateBlockChunkGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TemplateBlockChunkGenerator.cs index 68212bf1b2..02940c1c31 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TemplateBlockChunkGenerator.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TemplateBlockChunkGenerator.cs @@ -19,5 +19,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { //context.ChunkTreeBuilder.EndParentChunk(); } + + public override string ToString() + { + return "Template"; + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenBase.cs similarity index 83% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs rename to src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenBase.cs index c1caebb988..562a41f5bc 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenBase.cs @@ -8,9 +8,9 @@ using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal abstract class SymbolBase : ISymbol where TType : struct + internal abstract class TokenBase : IToken where TType : struct { - protected SymbolBase( + protected TokenBase( string content, TType type, IReadOnlyList errors) @@ -43,15 +43,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } var tracker = new SourceLocationTracker(Parent.Start); - for (var i = 0; i < Parent.Symbols.Count; i++) + for (var i = 0; i < Parent.Tokens.Count; i++) { - var symbol = Parent.Symbols[i]; - if (object.ReferenceEquals(this, symbol)) + var token = Parent.Tokens[i]; + if (object.ReferenceEquals(this, token)) { break; } - tracker.UpdateLocation(symbol.Content); + tracker.UpdateLocation(token.Content); } return tracker.CurrentLocation; @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public override bool Equals(object obj) { - var other = obj as SymbolBase; + var other = obj as TokenBase; return other != null && string.Equals(Content, other.Content, StringComparison.Ordinal) && Type.Equals(other.Type); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/Tokenizer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/Tokenizer.cs index 465754f6d5..af77d2ddc6 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/Tokenizer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/Tokenizer.cs @@ -8,9 +8,9 @@ using System.Text; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal abstract partial class Tokenizer : ITokenizer - where TSymbolType : struct - where TSymbol : SymbolBase + internal abstract partial class Tokenizer : ITokenizer + where TTokenType : struct + where TToken : TokenBase { protected Tokenizer(ITextDocument source) { @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Source = source; Buffer = new StringBuilder(); CurrentErrors = new List(); - StartSymbol(); + StartToken(); } protected List CurrentErrors { get; } @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected int? CurrentState { get; set; } - protected TSymbol CurrentSymbol { get; private set; } + protected TToken CurrentToken { get; private set; } public ITextDocument Source { get; private set; } @@ -42,9 +42,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { return Source.Peek() == -1; } } - public abstract TSymbolType RazorCommentStarType { get; } - public abstract TSymbolType RazorCommentType { get; } - public abstract TSymbolType RazorCommentTransitionType { get; } + public abstract TTokenType RazorCommentStarType { get; } + public abstract TTokenType RazorCommentType { get; } + public abstract TTokenType RazorCommentTransitionType { get; } protected bool HaveContent { @@ -64,27 +64,27 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public SourceLocation CurrentStart { get; private set; } - protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); + protected abstract TToken CreateToken(string content, TTokenType type, IReadOnlyList errors); protected abstract StateResult Dispatch(); - ISymbol ITokenizer.NextSymbol() + IToken ITokenizer.NextToken() { - return NextSymbol(); + return NextToken(); } - public virtual TSymbol NextSymbol() + public virtual TToken NextToken() { // Post-Condition: Buffer should be empty at the start of Next() Debug.Assert(Buffer.Length == 0); - StartSymbol(); + StartToken(); if (EndOfFile) { return null; } - var symbol = Turn(); + var token = Turn(); // Post-Condition: Buffer should be empty at the end of Next() Debug.Assert(Buffer.Length == 0); @@ -92,10 +92,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Post-Condition: Token should be non-zero length unless we're at EOF. Debug.Assert(EndOfFile || !CurrentStart.Equals(CurrentLocation)); - return symbol; + return token; } - protected virtual TSymbol Turn() + protected virtual TToken Turn() { if (CurrentState != null) { @@ -105,19 +105,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var next = Dispatch(); CurrentState = next.State; - CurrentSymbol = next.Result; + CurrentToken = next.Result; } - while (CurrentState != null && CurrentSymbol == null); + while (CurrentState != null && CurrentToken == null); if (CurrentState == null) { - return default(TSymbol); // Terminated + return default(TToken); // Terminated } - return CurrentSymbol; + return CurrentToken; } - return default(TSymbol); + return default(TToken); } public void Reset() @@ -149,7 +149,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy /// Returns a result containing the specified output and indicating that the next call to /// should invoke the provided state. /// - protected StateResult Transition(int state, TSymbol result) + protected StateResult Transition(int state, TToken result) { return new StateResult(state, result); } @@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return new StateResult((int)state, result: null); } - protected StateResult Transition(RazorCommentTokenizerState state, TSymbol result) + protected StateResult Transition(RazorCommentTokenizerState state, TToken result) { return new StateResult((int)state, result); } @@ -180,18 +180,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy /// Returns a result containing the specified output and indicating that the next call to /// should re-invoke the current state. /// - protected StateResult Stay(TSymbol result) + protected StateResult Stay(TToken result) { return new StateResult(CurrentState, result); } - protected TSymbol Single(TSymbolType type) + protected TToken Single(TTokenType type) { TakeCurrent(); - return EndSymbol(type); + return EndToken(type); } - protected void StartSymbol() + protected void StartToken() { Debug.Assert(Buffer.Length == 0); Debug.Assert(CurrentErrors.Count == 0); @@ -199,9 +199,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy CurrentStart = CurrentLocation; } - protected TSymbol EndSymbol(TSymbolType type) + protected TToken EndToken(TTokenType type) { - TSymbol symbol = null; + TToken token = null; if (HaveContent) { // Perf: Don't allocate a new errors array unless necessary. @@ -211,18 +211,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy errors[i] = CurrentErrors[i]; } - var symbolContent = GetSymbolContent(type); - Debug.Assert(string.Equals(symbolContent, Buffer.ToString(), StringComparison.Ordinal)); - symbol = CreateSymbol(symbolContent, type, errors); + var tokenContent = GetTokenContent(type); + Debug.Assert(string.Equals(tokenContent, Buffer.ToString(), StringComparison.Ordinal)); + token = CreateToken(tokenContent, type, errors); Buffer.Clear(); CurrentErrors.Clear(); } - return symbol; + return token; } - protected virtual string GetSymbolContent(TSymbolType type) + protected virtual string GetTokenContent(TTokenType type) { return Buffer.ToString(); } @@ -272,13 +272,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (CurrentCharacter != '*') { - // We've been moved since last time we were asked for a symbol... reset the state + // We've been moved since last time we were asked for a token... reset the state return Transition(StartState); } AssertCurrent('*'); TakeCurrent(); - return Transition(1002, EndSymbol(RazorCommentStarType)); + return Transition(1002, EndToken(RazorCommentStarType)); } protected StateResult RazorCommentBody() @@ -292,7 +292,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return Transition( RazorCommentTokenizerState.StarAfterRazorCommentBody, - EndSymbol(RazorCommentType)); + EndToken(RazorCommentType)); } else { @@ -306,7 +306,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - return Transition(StartState, EndSymbol(RazorCommentType)); + return Transition(StartState, EndToken(RazorCommentType)); } protected StateResult StarAfterRazorCommentBody() @@ -314,15 +314,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AssertCurrent('*'); TakeCurrent(); return Transition( - RazorCommentTokenizerState.AtSymbolAfterRazorCommentBody, - EndSymbol(RazorCommentStarType)); + RazorCommentTokenizerState.AtTokenAfterRazorCommentBody, + EndToken(RazorCommentStarType)); } - protected StateResult AtSymbolAfterRazorCommentBody() + protected StateResult AtTokenAfterRazorCommentBody() { AssertCurrent('@'); TakeCurrent(); - return Transition(StartState, EndSymbol(RazorCommentTransitionType)); + return Transition(StartState, EndToken(RazorCommentTransitionType)); } /// @@ -392,12 +392,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy EscapedRazorCommentTransition, RazorCommentBody, StarAfterRazorCommentBody, - AtSymbolAfterRazorCommentBody, + AtTokenAfterRazorCommentBody, } protected struct StateResult { - public StateResult(int? state, TSymbol result) + public StateResult(int? state, TToken result) { State = state; Result = result; @@ -405,7 +405,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public int? State { get; } - public TSymbol Result { get; } + public TToken Result { get; } } private static LookaheadToken BeginLookahead(ITextBuffer buffer) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs index 01fa0b11e1..af5a08831f 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs @@ -8,20 +8,20 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal abstract partial class TokenizerBackedParser : ParserBase - where TSymbolType : struct - where TTokenizer : Tokenizer - where TSymbol : SymbolBase + internal abstract partial class TokenizerBackedParser : ParserBase + where TTokenType : struct + where TTokenizer : Tokenizer + where TToken : TokenBase { - private readonly TokenizerView _tokenizer; + private readonly TokenizerView _tokenizer; - protected TokenizerBackedParser(LanguageCharacteristics language, ParserContext context) + protected TokenizerBackedParser(LanguageCharacteristics language, ParserContext context) : base(context) { Language = language; var languageTokenizer = Language.CreateTokenizer(Context.Source); - _tokenizer = new TokenizerView(languageTokenizer); + _tokenizer = new TokenizerView(languageTokenizer); Span = new SpanBuilder(CurrentLocation); } @@ -29,12 +29,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected Action SpanConfig { get; set; } - protected TSymbol CurrentSymbol + protected TToken CurrentToken { get { return _tokenizer.Current; } } - protected TSymbol PreviousSymbol { get; private set; } + protected TToken PreviousToken { get; private set; } protected SourceLocation CurrentLocation => _tokenizer.Tokenizer.CurrentLocation; @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { return _tokenizer.EndOfFile; } } - protected LanguageCharacteristics Language { get; } + protected LanguageCharacteristics Language { get; } protected virtual void HandleEmbeddedTransition() { @@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public override void BuildSpan(SpanBuilder span, SourceLocation start, string content) { - foreach (ISymbol sym in Language.TokenizeString(start, content)) + foreach (IToken sym in Language.TokenizeString(start, content)) { span.Accept(sym); } @@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - protected TSymbol Lookahead(int count) + protected TToken Lookahead(int count) { if (count < 0) { @@ -80,42 +80,42 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } else if (count == 0) { - return CurrentSymbol; + return CurrentToken; } - // We add 1 in order to store the current symbol. - var symbols = new TSymbol[count + 1]; - var currentSymbol = CurrentSymbol; + // We add 1 in order to store the current token. + var tokens = new TToken[count + 1]; + var currentToken = CurrentToken; - symbols[0] = currentSymbol; + tokens[0] = currentToken; // We need to look forward "count" many times. for (var i = 1; i <= count; i++) { NextToken(); - symbols[i] = CurrentSymbol; + tokens[i] = CurrentToken; } // Restore Tokenizer's location to where it was pointing before the look-ahead. for (var i = count; i >= 0; i--) { - PutBack(symbols[i]); + PutBack(tokens[i]); } - // The PutBacks above will set CurrentSymbol to null. EnsureCurrent will set our CurrentSymbol to the - // next symbol. + // The PutBacks above will set CurrentToken to null. EnsureCurrent will set our CurrentToken to the + // next token. EnsureCurrent(); - return symbols[count]; + return tokens[count]; } /// /// Looks forward until the specified condition is met. /// - /// A predicate accepting the symbol being evaluated and the list of symbols which have been looped through. - /// true, if the condition was met. false - if the condition wasn't met and the last symbol has already been processed. - /// The list of previous symbols is passed in the reverse order. So the last processed element will be the first one in the list. - protected bool LookaheadUntil(Func, bool> condition) + /// A predicate accepting the token being evaluated and the list of tokens which have been looped through. + /// true, if the condition was met. false - if the condition wasn't met and the last token has already been processed. + /// The list of previous tokens is passed in the reverse order. So the last processed element will be the first one in the list. + protected bool LookaheadUntil(Func, bool> condition) { if (condition == null) { @@ -124,8 +124,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var matchFound = false; - var symbols = new List(); - symbols.Add(CurrentSymbol); + var tokens = new List(); + tokens.Add(CurrentToken); while (true) { @@ -134,8 +134,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy break; } - symbols.Add(CurrentSymbol); - if (condition(CurrentSymbol, symbols)) + tokens.Add(CurrentToken); + if (condition(CurrentToken, tokens)) { matchFound = true; break; @@ -143,13 +143,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } // Restore Tokenizer's location to where it was pointing before the look-ahead. - for (var i = symbols.Count - 1; i >= 0; i--) + for (var i = tokens.Count - 1; i >= 0; i--) { - PutBack(symbols[i]); + PutBack(tokens[i]); } - // The PutBacks above will set CurrentSymbol to null. EnsureCurrent will set our CurrentSymbol to the - // next symbol. + // The PutBacks above will set CurrentToken to null. EnsureCurrent will set our CurrentToken to the + // next token. EnsureCurrent(); return matchFound; @@ -157,57 +157,57 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected internal bool NextToken() { - PreviousSymbol = CurrentSymbol; + PreviousToken = CurrentToken; return _tokenizer.Next(); } // Helpers [Conditional("DEBUG")] - internal void Assert(TSymbolType expectedType) + internal void Assert(TTokenType expectedType) { - Debug.Assert(!EndOfFile && SymbolTypeEquals(CurrentSymbol.Type, expectedType)); + Debug.Assert(!EndOfFile && TokenTypeEquals(CurrentToken.Type, expectedType)); } - abstract protected bool SymbolTypeEquals(TSymbolType x, TSymbolType y); + abstract protected bool TokenTypeEquals(TTokenType x, TTokenType y); - protected internal void PutBack(TSymbol symbol) + protected internal void PutBack(TToken token) { - if (symbol != null) + if (token != null) { - _tokenizer.PutBack(symbol); + _tokenizer.PutBack(token); } } /// - /// Put the specified symbols back in the input stream. The provided list MUST be in the ORDER THE SYMBOLS WERE READ. The - /// list WILL be reversed and the Putback(TSymbol) will be called on each item. + /// Put the specified tokens back in the input stream. The provided list MUST be in the ORDER THE TOKENS WERE READ. The + /// list WILL be reversed and the Putback(TToken) will be called on each item. /// /// - /// If a document contains symbols: a, b, c, d, e, f + /// If a document contains tokens: a, b, c, d, e, f /// and AcceptWhile or AcceptUntil is used to collect until d /// the list returned by AcceptWhile/Until will contain: a, b, c IN THAT ORDER /// that is the correct format for providing to this method. The caller of this method would, /// in that case, want to put c, b and a back into the stream, so "a, b, c" is the CORRECT order /// - protected internal void PutBack(IEnumerable symbols) + protected internal void PutBack(IEnumerable tokens) { - foreach (TSymbol symbol in symbols.Reverse()) + foreach (TToken token in tokens.Reverse()) { - PutBack(symbol); + PutBack(token); } } protected internal void PutCurrentBack() { - if (!EndOfFile && CurrentSymbol != null) + if (!EndOfFile && CurrentToken != null) { - PutBack(CurrentSymbol); + PutBack(CurrentToken); } } protected internal bool Balance(BalancingModes mode) { - var left = CurrentSymbol.Type; + var left = CurrentToken.Type; var right = Language.FlipBracket(left); var start = CurrentStart; AcceptAndMoveNext(); @@ -223,13 +223,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return Balance(mode, left, right, start); } - protected internal bool Balance(BalancingModes mode, TSymbolType left, TSymbolType right, SourceLocation start) + protected internal bool Balance(BalancingModes mode, TTokenType left, TTokenType right, SourceLocation start) { var startPosition = CurrentStart.AbsoluteIndex; var nesting = 1; if (!EndOfFile) { - var syms = new List(); + var syms = new List(); do { if (IsAtEmbeddedTransition( @@ -253,7 +253,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } if (nesting > 0) { - syms.Add(CurrentSymbol); + syms.Add(CurrentToken); } } while (nesting > 0 && NextToken()); @@ -280,29 +280,29 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } else { - // Accept all the symbols we saw + // Accept all the tokens we saw Accept(syms); } } return nesting == 0; } - protected internal bool NextIs(TSymbolType type) + protected internal bool NextIs(TTokenType type) { - return NextIs(sym => sym != null && SymbolTypeEquals(type, sym.Type)); + return NextIs(sym => sym != null && TokenTypeEquals(type, sym.Type)); } - protected internal bool NextIs(params TSymbolType[] types) + protected internal bool NextIs(params TTokenType[] types) { - return NextIs(sym => sym != null && types.Any(t => SymbolTypeEquals(t, sym.Type))); + return NextIs(sym => sym != null && types.Any(t => TokenTypeEquals(t, sym.Type))); } - protected internal bool NextIs(Func condition) + protected internal bool NextIs(Func condition) { - var cur = CurrentSymbol; + var cur = CurrentToken; if (NextToken()) { - var result = condition(CurrentSymbol); + var result = condition(CurrentToken); PutCurrentBack(); PutBack(cur); EnsureCurrent(); @@ -317,27 +317,27 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return false; } - protected internal bool Was(TSymbolType type) + protected internal bool Was(TTokenType type) { - return PreviousSymbol != null && SymbolTypeEquals(PreviousSymbol.Type, type); + return PreviousToken != null && TokenTypeEquals(PreviousToken.Type, type); } - protected internal bool At(TSymbolType type) + protected internal bool At(TTokenType type) { - return !EndOfFile && CurrentSymbol != null && SymbolTypeEquals(CurrentSymbol.Type, type); + return !EndOfFile && CurrentToken != null && TokenTypeEquals(CurrentToken.Type, type); } protected internal bool AcceptAndMoveNext() { - Accept(CurrentSymbol); + Accept(CurrentToken); return NextToken(); } - protected TSymbol AcceptSingleWhiteSpaceCharacter() + protected TToken AcceptSingleWhiteSpaceCharacter() { - if (Language.IsWhiteSpace(CurrentSymbol)) + if (Language.IsWhiteSpace(CurrentToken)) { - Tuple pair = Language.SplitSymbol(CurrentSymbol, 1, Language.GetKnownSymbolType(KnownSymbolType.WhiteSpace)); + Tuple pair = Language.SplitToken(CurrentToken, 1, Language.GetKnownTokenType(KnownTokenType.WhiteSpace)); Accept(pair.Item1); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; NextToken(); @@ -346,32 +346,32 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return null; } - protected internal void Accept(IEnumerable symbols) + protected internal void Accept(IEnumerable tokens) { - foreach (TSymbol symbol in symbols) + foreach (TToken token in tokens) { - Accept(symbol); + Accept(token); } } - protected internal void Accept(TSymbol symbol) + protected internal void Accept(TToken token) { - if (symbol != null) + if (token != null) { - foreach (var error in symbol.Errors) + foreach (var error in token.Errors) { Context.ErrorSink.OnError(error); } - Span.Accept(symbol); + Span.Accept(token); } } - protected internal bool AcceptAll(params TSymbolType[] types) + protected internal bool AcceptAll(params TTokenType[] types) { - foreach (TSymbolType type in types) + foreach (TTokenType type in types) { - if (CurrentSymbol == null || !SymbolTypeEquals(CurrentSymbol.Type, type)) + if (CurrentToken == null || !TokenTypeEquals(CurrentToken.Type, type)) { return false; } @@ -380,11 +380,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return true; } - protected internal void AddMarkerSymbolIfNecessary() + protected internal void AddMarkerTokenIfNecessary() { - if (Span.Symbols.Count == 0 && Context.Builder.LastAcceptedCharacters != AcceptedCharactersInternal.Any) + if (Span.Tokens.Count == 0 && Context.Builder.LastAcceptedCharacters != AcceptedCharactersInternal.Any) { - Accept(Language.CreateMarkerSymbol()); + Accept(Language.CreateMarkerToken()); } } @@ -408,7 +408,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void Output() { - if (Span.Symbols.Count > 0) + if (Span.Tokens.Count > 0) { var nextStart = Span.End; @@ -462,23 +462,23 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Initialize(Span); } - protected internal void Expected(KnownSymbolType type) + protected internal void Expected(KnownTokenType type) { - Expected(Language.GetKnownSymbolType(type)); + Expected(Language.GetKnownTokenType(type)); } - protected internal void Expected(params TSymbolType[] types) + protected internal void Expected(params TTokenType[] types) { - Debug.Assert(!EndOfFile && CurrentSymbol != null && types.Contains(CurrentSymbol.Type)); + Debug.Assert(!EndOfFile && CurrentToken != null && types.Contains(CurrentToken.Type)); AcceptAndMoveNext(); } - protected internal bool Optional(KnownSymbolType type) + protected internal bool Optional(KnownTokenType type) { - return Optional(Language.GetKnownSymbolType(type)); + return Optional(Language.GetKnownTokenType(type)); } - protected internal bool Optional(TSymbolType type) + protected internal bool Optional(TTokenType type) { if (At(type)) { @@ -490,7 +490,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected bool EnsureCurrent() { - if (CurrentSymbol == null) + if (CurrentToken == null) { return NextToken(); } @@ -498,62 +498,62 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return true; } - protected internal void AcceptWhile(TSymbolType type) + protected internal void AcceptWhile(TTokenType type) { - AcceptWhile(sym => SymbolTypeEquals(type, sym.Type)); + AcceptWhile(sym => TokenTypeEquals(type, sym.Type)); } // We want to avoid array allocations and enumeration where possible, so we use the same technique as string.Format - protected internal void AcceptWhile(TSymbolType type1, TSymbolType type2) + protected internal void AcceptWhile(TTokenType type1, TTokenType type2) { - AcceptWhile(sym => SymbolTypeEquals(type1, sym.Type) || SymbolTypeEquals(type2, sym.Type)); + AcceptWhile(sym => TokenTypeEquals(type1, sym.Type) || TokenTypeEquals(type2, sym.Type)); } - protected internal void AcceptWhile(TSymbolType type1, TSymbolType type2, TSymbolType type3) + protected internal void AcceptWhile(TTokenType type1, TTokenType type2, TTokenType type3) { - AcceptWhile(sym => SymbolTypeEquals(type1, sym.Type) || SymbolTypeEquals(type2, sym.Type) || SymbolTypeEquals(type3, sym.Type)); + AcceptWhile(sym => TokenTypeEquals(type1, sym.Type) || TokenTypeEquals(type2, sym.Type) || TokenTypeEquals(type3, sym.Type)); } - protected internal void AcceptWhile(params TSymbolType[] types) + protected internal void AcceptWhile(params TTokenType[] types) { - AcceptWhile(sym => types.Any(expected => SymbolTypeEquals(expected, sym.Type))); + AcceptWhile(sym => types.Any(expected => TokenTypeEquals(expected, sym.Type))); } - protected internal void AcceptUntil(TSymbolType type) + protected internal void AcceptUntil(TTokenType type) { - AcceptWhile(sym => !SymbolTypeEquals(type, sym.Type)); + AcceptWhile(sym => !TokenTypeEquals(type, sym.Type)); } // We want to avoid array allocations and enumeration where possible, so we use the same technique as string.Format - protected internal void AcceptUntil(TSymbolType type1, TSymbolType type2) + protected internal void AcceptUntil(TTokenType type1, TTokenType type2) { - AcceptWhile(sym => !SymbolTypeEquals(type1, sym.Type) && !SymbolTypeEquals(type2, sym.Type)); + AcceptWhile(sym => !TokenTypeEquals(type1, sym.Type) && !TokenTypeEquals(type2, sym.Type)); } - protected internal void AcceptUntil(TSymbolType type1, TSymbolType type2, TSymbolType type3) + protected internal void AcceptUntil(TTokenType type1, TTokenType type2, TTokenType type3) { - AcceptWhile(sym => !SymbolTypeEquals(type1, sym.Type) && !SymbolTypeEquals(type2, sym.Type) && !SymbolTypeEquals(type3, sym.Type)); + AcceptWhile(sym => !TokenTypeEquals(type1, sym.Type) && !TokenTypeEquals(type2, sym.Type) && !TokenTypeEquals(type3, sym.Type)); } - protected internal void AcceptUntil(params TSymbolType[] types) + protected internal void AcceptUntil(params TTokenType[] types) { - AcceptWhile(sym => types.All(expected => !SymbolTypeEquals(expected, sym.Type))); + AcceptWhile(sym => types.All(expected => !TokenTypeEquals(expected, sym.Type))); } - protected internal void AcceptWhile(Func condition) + protected internal void AcceptWhile(Func condition) { Accept(ReadWhileLazy(condition)); } - protected internal IEnumerable ReadWhile(Func condition) + protected internal IEnumerable ReadWhile(Func condition) { return ReadWhileLazy(condition).ToList(); } - protected TSymbol AcceptWhiteSpaceInLines() + protected TToken AcceptWhiteSpaceInLines() { - TSymbol lastWs = null; - while (Language.IsWhiteSpace(CurrentSymbol) || Language.IsNewLine(CurrentSymbol)) + TToken lastWs = null; + while (Language.IsWhiteSpace(CurrentToken) || Language.IsNewLine(CurrentToken)) { // Capture the previous whitespace node if (lastWs != null) @@ -561,14 +561,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Accept(lastWs); } - if (Language.IsWhiteSpace(CurrentSymbol)) + if (Language.IsWhiteSpace(CurrentToken)) { - lastWs = CurrentSymbol; + lastWs = CurrentToken; } - else if (Language.IsNewLine(CurrentSymbol)) + else if (Language.IsNewLine(CurrentToken)) { // Accept newline and reset last whitespace tracker - Accept(CurrentSymbol); + Accept(CurrentToken); lastWs = null; } @@ -579,18 +579,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected bool AtIdentifier(bool allowKeywords) { - return CurrentSymbol != null && - (Language.IsIdentifier(CurrentSymbol) || - (allowKeywords && Language.IsKeyword(CurrentSymbol))); + return CurrentToken != null && + (Language.IsIdentifier(CurrentToken) || + (allowKeywords && Language.IsKeyword(CurrentToken))); } // Don't open this to sub classes because it's lazy but it looks eager. // You have to advance the Enumerable to read the next characters. - internal IEnumerable ReadWhileLazy(Func condition) + internal IEnumerable ReadWhileLazy(Func condition) { - while (EnsureCurrent() && condition(CurrentSymbol)) + while (EnsureCurrent() && condition(CurrentToken)) { - yield return CurrentSymbol; + yield return CurrentToken; NextToken(); } } @@ -620,9 +620,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected void RazorComment() { - if (!Language.KnowsSymbolType(KnownSymbolType.CommentStart) || - !Language.KnowsSymbolType(KnownSymbolType.CommentStar) || - !Language.KnowsSymbolType(KnownSymbolType.CommentBody)) + if (!Language.KnowsTokenType(KnownTokenType.CommentStart) || + !Language.KnowsTokenType(KnownTokenType.CommentStar) || + !Language.KnowsTokenType(KnownTokenType.CommentBody)) { throw new InvalidOperationException(Resources.Language_Does_Not_Support_RazorComment); } @@ -634,18 +634,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Context.Builder.CurrentBlock.ChunkGenerator = new RazorCommentChunkGenerator(); var start = CurrentStart; - Expected(KnownSymbolType.CommentStart); + Expected(KnownTokenType.CommentStart); Output(SpanKindInternal.Transition, AcceptedCharactersInternal.None); - Expected(KnownSymbolType.CommentStar); + Expected(KnownTokenType.CommentStar); Output(SpanKindInternal.MetaCode, AcceptedCharactersInternal.None); - Optional(KnownSymbolType.CommentBody); - AddMarkerSymbolIfNecessary(); + Optional(KnownTokenType.CommentBody); + AddMarkerTokenIfNecessary(); Output(SpanKindInternal.Comment); var errorReported = false; - if (!Optional(KnownSymbolType.CommentStar)) + if (!Optional(KnownTokenType.CommentStar)) { errorReported = true; Context.ErrorSink.OnError( @@ -657,7 +657,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Output(SpanKindInternal.MetaCode, AcceptedCharactersInternal.None); } - if (!Optional(KnownSymbolType.CommentStart)) + if (!Optional(KnownTokenType.CommentStart)) { if (!errorReported) { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerView.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerView.cs index b85f0cd10b..2b290bda5c 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerView.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerView.cs @@ -3,10 +3,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { - internal class TokenizerView - where TSymbolType : struct - where TTokenizer : Tokenizer - where TSymbol : SymbolBase + internal class TokenizerView + where TTokenType : struct + where TTokenizer : Tokenizer + where TToken : TokenBase { public TokenizerView(TTokenizer tokenizer) { @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public TTokenizer Tokenizer { get; private set; } public bool EndOfFile { get; private set; } - public TSymbol Current { get; private set; } + public TToken Current { get; private set; } public ITextDocument Source { @@ -24,14 +24,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public bool Next() { - Current = Tokenizer.NextSymbol(); + Current = Tokenizer.NextToken(); EndOfFile = (Current == null); return !EndOfFile; } - public void PutBack(TSymbol symbol) + public void PutBack(TToken token) { - Source.Position -= symbol.Content.Length; + Source.Position -= token.Content.Length; Current = null; EndOfFile = Source.Position >= Source.Length; Tokenizer.Reset(); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/WhiteSpaceRewriter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/WhiteSpaceRewriter.cs index 766f57d4bf..cf71b0a024 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/WhiteSpaceRewriter.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Legacy/WhiteSpaceRewriter.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Add this node to the parent var builder = new SpanBuilder(ws); - builder.ClearSymbols(); + builder.ClearTokens(); FillSpan(builder, ws.Start, ws.Content); parent.Children.Add(builder.Build()); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs index a785a39bca..773fb6de9c 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs @@ -139,128 +139,128 @@ namespace Microsoft.AspNetCore.Razor.Language /// /// <<character literal>> /// - internal static string CSharpSymbol_CharacterLiteral + internal static string CSharpToken_CharacterLiteral { - get => GetString("CSharpSymbol_CharacterLiteral"); + get => GetString("CSharpToken_CharacterLiteral"); } /// /// <<character literal>> /// - internal static string FormatCSharpSymbol_CharacterLiteral() - => GetString("CSharpSymbol_CharacterLiteral"); + internal static string FormatCSharpToken_CharacterLiteral() + => GetString("CSharpToken_CharacterLiteral"); /// /// <<comment>> /// - internal static string CSharpSymbol_Comment + internal static string CSharpToken_Comment { - get => GetString("CSharpSymbol_Comment"); + get => GetString("CSharpToken_Comment"); } /// /// <<comment>> /// - internal static string FormatCSharpSymbol_Comment() - => GetString("CSharpSymbol_Comment"); + internal static string FormatCSharpToken_Comment() + => GetString("CSharpToken_Comment"); /// /// <<identifier>> /// - internal static string CSharpSymbol_Identifier + internal static string CSharpToken_Identifier { - get => GetString("CSharpSymbol_Identifier"); + get => GetString("CSharpToken_Identifier"); } /// /// <<identifier>> /// - internal static string FormatCSharpSymbol_Identifier() - => GetString("CSharpSymbol_Identifier"); + internal static string FormatCSharpToken_Identifier() + => GetString("CSharpToken_Identifier"); /// /// <<integer literal>> /// - internal static string CSharpSymbol_IntegerLiteral + internal static string CSharpToken_IntegerLiteral { - get => GetString("CSharpSymbol_IntegerLiteral"); + get => GetString("CSharpToken_IntegerLiteral"); } /// /// <<integer literal>> /// - internal static string FormatCSharpSymbol_IntegerLiteral() - => GetString("CSharpSymbol_IntegerLiteral"); + internal static string FormatCSharpToken_IntegerLiteral() + => GetString("CSharpToken_IntegerLiteral"); /// /// <<keyword>> /// - internal static string CSharpSymbol_Keyword + internal static string CSharpToken_Keyword { - get => GetString("CSharpSymbol_Keyword"); + get => GetString("CSharpToken_Keyword"); } /// /// <<keyword>> /// - internal static string FormatCSharpSymbol_Keyword() - => GetString("CSharpSymbol_Keyword"); + internal static string FormatCSharpToken_Keyword() + => GetString("CSharpToken_Keyword"); /// /// <<newline sequence>> /// - internal static string CSharpSymbol_Newline + internal static string CSharpToken_Newline { - get => GetString("CSharpSymbol_Newline"); + get => GetString("CSharpToken_Newline"); } /// /// <<newline sequence>> /// - internal static string FormatCSharpSymbol_Newline() - => GetString("CSharpSymbol_Newline"); + internal static string FormatCSharpToken_Newline() + => GetString("CSharpToken_Newline"); /// /// <<real literal>> /// - internal static string CSharpSymbol_RealLiteral + internal static string CSharpToken_RealLiteral { - get => GetString("CSharpSymbol_RealLiteral"); + get => GetString("CSharpToken_RealLiteral"); } /// /// <<real literal>> /// - internal static string FormatCSharpSymbol_RealLiteral() - => GetString("CSharpSymbol_RealLiteral"); + internal static string FormatCSharpToken_RealLiteral() + => GetString("CSharpToken_RealLiteral"); /// /// <<string literal>> /// - internal static string CSharpSymbol_StringLiteral + internal static string CSharpToken_StringLiteral { - get => GetString("CSharpSymbol_StringLiteral"); + get => GetString("CSharpToken_StringLiteral"); } /// /// <<string literal>> /// - internal static string FormatCSharpSymbol_StringLiteral() - => GetString("CSharpSymbol_StringLiteral"); + internal static string FormatCSharpToken_StringLiteral() + => GetString("CSharpToken_StringLiteral"); /// /// <<white space>> /// - internal static string CSharpSymbol_Whitespace + internal static string CSharpToken_Whitespace { - get => GetString("CSharpSymbol_Whitespace"); + get => GetString("CSharpToken_Whitespace"); } /// /// <<white space>> /// - internal static string FormatCSharpSymbol_Whitespace() - => GetString("CSharpSymbol_Whitespace"); + internal static string FormatCSharpToken_Whitespace() + => GetString("CSharpToken_Whitespace"); /// /// The document type '{0}' does not support the extension '{1}'. @@ -489,58 +489,58 @@ namespace Microsoft.AspNetCore.Razor.Language /// /// <<newline sequence>> /// - internal static string HtmlSymbol_NewLine + internal static string HtmlToken_NewLine { - get => GetString("HtmlSymbol_NewLine"); + get => GetString("HtmlToken_NewLine"); } /// /// <<newline sequence>> /// - internal static string FormatHtmlSymbol_NewLine() - => GetString("HtmlSymbol_NewLine"); + internal static string FormatHtmlToken_NewLine() + => GetString("HtmlToken_NewLine"); /// /// <<razor comment>> /// - internal static string HtmlSymbol_RazorComment + internal static string HtmlToken_RazorComment { - get => GetString("HtmlSymbol_RazorComment"); + get => GetString("HtmlToken_RazorComment"); } /// /// <<razor comment>> /// - internal static string FormatHtmlSymbol_RazorComment() - => GetString("HtmlSymbol_RazorComment"); + internal static string FormatHtmlToken_RazorComment() + => GetString("HtmlToken_RazorComment"); /// /// <<text>> /// - internal static string HtmlSymbol_Text + internal static string HtmlToken_Text { - get => GetString("HtmlSymbol_Text"); + get => GetString("HtmlToken_Text"); } /// /// <<text>> /// - internal static string FormatHtmlSymbol_Text() - => GetString("HtmlSymbol_Text"); + internal static string FormatHtmlToken_Text() + => GetString("HtmlToken_Text"); /// /// <<white space>> /// - internal static string HtmlSymbol_WhiteSpace + internal static string HtmlToken_WhiteSpace { - get => GetString("HtmlSymbol_WhiteSpace"); + get => GetString("HtmlToken_WhiteSpace"); } /// /// <<white space>> /// - internal static string FormatHtmlSymbol_WhiteSpace() - => GetString("HtmlSymbol_WhiteSpace"); + internal static string FormatHtmlToken_WhiteSpace() + => GetString("HtmlToken_WhiteSpace"); /// /// Specify the base class for the current document. @@ -711,7 +711,7 @@ namespace Microsoft.AspNetCore.Razor.Language => GetString("KeyMustNotBeNull"); /// - /// Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment + /// Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known token types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment /// internal static string Language_Does_Not_Support_RazorComment { @@ -719,7 +719,7 @@ namespace Microsoft.AspNetCore.Razor.Language } /// - /// Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment + /// Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known token types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment /// internal static string FormatLanguage_Does_Not_Support_RazorComment() => GetString("Language_Does_Not_Support_RazorComment"); @@ -1351,16 +1351,16 @@ namespace Microsoft.AspNetCore.Razor.Language /// /// <<unknown>> /// - internal static string Symbol_Unknown + internal static string Token_Unknown { - get => GetString("Symbol_Unknown"); + get => GetString("Token_Unknown"); } /// /// <<unknown>> /// - internal static string FormatSymbol_Unknown() - => GetString("Symbol_Unknown"); + internal static string FormatToken_Unknown() + => GetString("Token_Unknown"); /// /// Invalid tag helper bound property '{1}' on tag helper '{0}'. Tag helpers cannot bind to HTML attributes with name '{2}' because the name contains a '{3}' character. diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs index 85df33837a..dafc33983f 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs @@ -29,6 +29,26 @@ namespace Microsoft.AspNetCore.Razor.Language document.Items[typeof(TagHelperDocumentContext)] = context; } + internal static IReadOnlyList GetTagHelpers(this RazorCodeDocument document) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + return (document.Items[typeof(TagHelpersHolder)] as TagHelpersHolder)?.TagHelpers; + } + + internal static void SetTagHelpers(this RazorCodeDocument document, IReadOnlyList tagHelpers) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + document.Items[typeof(TagHelpersHolder)] = new TagHelpersHolder(tagHelpers); + } + public static RazorSyntaxTree GetSyntaxTree(this RazorCodeDocument document) { if (document == null) @@ -168,5 +188,15 @@ namespace Microsoft.AspNetCore.Razor.Language public IReadOnlyList SyntaxTrees { get; } } + + private class TagHelpersHolder + { + public TagHelpersHolder(IReadOnlyList tagHelpers) + { + TagHelpers = tagHelpers; + } + + public IReadOnlyList TagHelpers { get; } + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs index e8ef287c0c..1094b0a432 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs @@ -4,10 +4,11 @@ using System; using System.Collections.Generic; using System.Linq; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language { - public abstract class RazorConfiguration + public abstract class RazorConfiguration : IEquatable { public static readonly RazorConfiguration Default = new DefaultRazorConfiguration( RazorLanguageVersion.Latest, @@ -43,6 +44,58 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract RazorLanguageVersion LanguageVersion { get; } + public override bool Equals(object obj) + { + return base.Equals(obj as RazorConfiguration); + } + + public virtual bool Equals(RazorConfiguration other) + { + if (object.ReferenceEquals(other, null)) + { + return false; + } + + if (LanguageVersion != other.LanguageVersion) + { + return false; + } + + if (ConfigurationName != other.ConfigurationName) + { + return false; + } + + if (Extensions.Count != other.Extensions.Count) + { + return false; + } + + for (var i = 0; i < Extensions.Count; i++) + { + if (Extensions[i].ExtensionName != other.Extensions[i].ExtensionName) + { + return false; + } + } + + return true; + } + + public override int GetHashCode() + { + var hash = new HashCodeCombiner(); + hash.Add(LanguageVersion); + hash.Add(ConfigurationName); + + for (var i = 0; i < Extensions.Count; i++) + { + hash.Add(Extensions[i].ExtensionName); + } + + return hash; + } + private class DefaultRazorConfiguration : RazorConfiguration { public DefaultRazorConfiguration( diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs index cf1ad34dd6..ef111ac0ae 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs @@ -240,16 +240,6 @@ namespace Microsoft.AspNetCore.Razor.Language return RazorDiagnostic.Create(Parsing_InvalidTagHelperPrefixValue, location, directiveName, character, prefix); } - internal static readonly RazorDiagnosticDescriptor Parsing_InvalidTagHelperLookupText = - new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}1020", - () => Resources.InvalidTagHelperLookupText, - RazorDiagnosticSeverity.Error); - public static RazorDiagnostic CreateParsing_InvalidTagHelperLookupText(SourceSpan location, string lookupText) - { - return RazorDiagnostic.Create(Parsing_InvalidTagHelperLookupText, location, lookupText); - } - internal static readonly RazorDiagnosticDescriptor Parsing_MarkupBlockMustStartWithTag = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}1021", @@ -417,6 +407,16 @@ namespace Microsoft.AspNetCore.Razor.Language return diagnostic; } + internal static readonly RazorDiagnosticDescriptor Parsing_InvalidTagHelperLookupText = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1036", + () => Resources.InvalidTagHelperLookupText, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InvalidTagHelperLookupText(SourceSpan location, string lookupText) + { + return RazorDiagnostic.Create(Parsing_InvalidTagHelperLookupText, location, lookupText); + } + #endregion #region Semantic Errors diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs index 07ee624370..a36b80d4b0 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs @@ -35,6 +35,18 @@ namespace Microsoft.AspNetCore.Razor.Language return codeDocument; } + internal virtual RazorCodeDocument Process(RazorSourceDocument source, IReadOnlyList importSources, IReadOnlyList tagHelpers) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + + var codeDocument = CreateCodeDocumentCore(source, importSources, tagHelpers); + ProcessCore(codeDocument); + return codeDocument; + } + public virtual RazorCodeDocument ProcessDesignTime(RazorProjectItem projectItem) { if (projectItem == null) @@ -47,10 +59,32 @@ namespace Microsoft.AspNetCore.Razor.Language return codeDocument; } + internal virtual RazorCodeDocument ProcessDesignTime(RazorSourceDocument source, IReadOnlyList importSources, IReadOnlyList tagHelpers) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + + var codeDocument = CreateCodeDocumentDesignTimeCore(source, importSources, tagHelpers); + ProcessCore(codeDocument); + return codeDocument; + } + protected abstract RazorCodeDocument CreateCodeDocumentCore(RazorProjectItem projectItem); + internal virtual RazorCodeDocument CreateCodeDocumentCore(RazorSourceDocument source, IReadOnlyList importSources, IReadOnlyList tagHelpers) + { + return RazorCodeDocument.Create(source, importSources); + } + protected abstract RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem); + internal virtual RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorSourceDocument source, IReadOnlyList importSources, IReadOnlyList tagHelpers) + { + return RazorCodeDocument.Create(source, importSources); + } + protected abstract void ProcessCore(RazorCodeDocument codeDocument); internal static RazorProjectEngine CreateEmpty(Action configure = null) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RequiredAttributeDescriptorComparer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RequiredAttributeDescriptorComparer.cs index 78186cfb49..149f6a0c3d 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RequiredAttributeDescriptorComparer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/RequiredAttributeDescriptorComparer.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language @@ -58,26 +57,21 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - return descriptorX != null && + return descriptorX.NameComparison == descriptorY.NameComparison && descriptorX.ValueComparison == descriptorY.ValueComparison && string.Equals(descriptorX.Name, descriptorY.Name, _stringComparison) && string.Equals(descriptorX.Value, descriptorY.Value, StringComparison.Ordinal) && - string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal) && - Enumerable.SequenceEqual(descriptorX.Diagnostics, descriptorY.Diagnostics); + string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal); } /// public virtual int GetHashCode(RequiredAttributeDescriptor descriptor) { - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(descriptor.NameComparison); - hashCodeCombiner.Add(descriptor.ValueComparison); - hashCodeCombiner.Add(descriptor.Name, _stringComparer); - hashCodeCombiner.Add(descriptor.Value, StringComparer.Ordinal); - hashCodeCombiner.Add(descriptor.DisplayName, StringComparer.Ordinal); + var hash = HashCodeCombiner.Start(); + hash.Add(descriptor.Name, _stringComparer); - return hashCodeCombiner.CombinedHash; + return hash.CombinedHash; } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Resources.resx b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Resources.resx index 195a9d791b..e23e66c297 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Resources.resx +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Resources.resx @@ -146,31 +146,31 @@ Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. - + <<character literal>> - + <<comment>> - + <<identifier>> - + <<integer literal>> - + <<keyword>> - + <<newline sequence>> - + <<real literal>> - + <<string literal>> - + <<white space>> @@ -221,16 +221,16 @@ Specify a C# code block. - + <<newline sequence>> - + <<razor comment>> - + <<text>> - + <<white space>> @@ -270,7 +270,7 @@ The key must not be null. - Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known symbol types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment + Cannot use built-in RazorComment handler, language characteristics does not define the CommentStart, CommentStar and CommentBody known token types or parser does not override TokenizerBackedParser.OutputSpanBeforeRazorComment The specified encoding '{0}' does not match the content's encoding '{1}'. @@ -423,7 +423,7 @@ Instead, wrap the contents of the block in "{{}}": @section Header { ... } In CSHTML, the @section keyword is case-sensitive and lowercase (as with all C# keywords) - + <<unknown>> diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagHelperDescriptorComparer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagHelperDescriptorComparer.cs index 90cead0e50..5ca9c0fe91 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagHelperDescriptorComparer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagHelperDescriptorComparer.cs @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Language public virtual bool Equals(TagHelperDescriptor descriptorX, TagHelperDescriptor descriptorY) { - if (descriptorX == descriptorY) + if (object.ReferenceEquals(descriptorX, descriptorY)) { return true; } @@ -59,31 +59,81 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - return descriptorX != null && - string.Equals(descriptorX.Kind, descriptorY.Kind, StringComparison.Ordinal) && - string.Equals(descriptorX.AssemblyName, descriptorY.AssemblyName, StringComparison.Ordinal) && - Enumerable.SequenceEqual( - descriptorX.BoundAttributes.OrderBy(attribute => attribute.Name, _stringComparer), - descriptorY.BoundAttributes.OrderBy(attribute => attribute.Name, _stringComparer), - _boundAttributeComparer) && - Enumerable.SequenceEqual( - descriptorX.TagMatchingRules.OrderBy(rule => rule.TagName, _stringComparer), - descriptorY.TagMatchingRules.OrderBy(rule => rule.TagName, _stringComparer), - _tagMatchingRuleComparer) && - (descriptorX.AllowedChildTags == descriptorY.AllowedChildTags || + if (descriptorX == null) + { + return false; + } + + if (!string.Equals(descriptorX.Kind, descriptorY.Kind, StringComparison.Ordinal)) + { + return false; + } + + if (!string.Equals(descriptorX.AssemblyName, descriptorY.AssemblyName, StringComparison.Ordinal)) + { + return false; + } + + if (!string.Equals(descriptorX.Name, descriptorY.Name, StringComparison.Ordinal)) + { + return false; + } + + if (!Enumerable.SequenceEqual( + descriptorX.BoundAttributes.OrderBy(attribute => attribute.Name, _stringComparer), + descriptorY.BoundAttributes.OrderBy(attribute => attribute.Name, _stringComparer), + _boundAttributeComparer)) + { + return false; + } + + if (!Enumerable.SequenceEqual( + descriptorX.TagMatchingRules.OrderBy(rule => rule.TagName, _stringComparer), + descriptorY.TagMatchingRules.OrderBy(rule => rule.TagName, _stringComparer), + _tagMatchingRuleComparer)) + { + return false; + } + + if (!(descriptorX.AllowedChildTags == descriptorY.AllowedChildTags || (descriptorX.AllowedChildTags != null && descriptorY.AllowedChildTags != null && Enumerable.SequenceEqual( descriptorX.AllowedChildTags.OrderBy(childTag => childTag.Name, _stringComparer), descriptorY.AllowedChildTags.OrderBy(childTag => childTag.Name, _stringComparer), - _AllowedChildTagDescriptorComparer))) && - string.Equals(descriptorX.Documentation, descriptorY.Documentation, StringComparison.Ordinal) && - string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal) && - string.Equals(descriptorX.TagOutputHint, descriptorY.TagOutputHint, _stringComparison) && - Enumerable.SequenceEqual(descriptorX.Diagnostics, descriptorY.Diagnostics) && - Enumerable.SequenceEqual( - descriptorX.Metadata.OrderBy(metadataX => metadataX.Key, StringComparer.Ordinal), - descriptorY.Metadata.OrderBy(metadataY => metadataY.Key, StringComparer.Ordinal)); + _AllowedChildTagDescriptorComparer)))) + { + return false; + } + + if (!string.Equals(descriptorX.Documentation, descriptorY.Documentation, StringComparison.Ordinal)) + { + return false; + } + + if (!string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal)) + { + return false; + } + + if (!string.Equals(descriptorX.TagOutputHint, descriptorY.TagOutputHint, _stringComparison)) + { + return false; + } + + if (!Enumerable.SequenceEqual(descriptorX.Diagnostics, descriptorY.Diagnostics)) + { + return false; + } + + if (!Enumerable.SequenceEqual( + descriptorX.Metadata.OrderBy(metadataX => metadataX.Key, StringComparer.Ordinal), + descriptorY.Metadata.OrderBy(metadataY => metadataY.Key, StringComparer.Ordinal))) + { + return false; + } + + return true; } /// @@ -94,33 +144,12 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(descriptor)); } - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(descriptor.Kind); - hashCodeCombiner.Add(descriptor.AssemblyName, StringComparer.Ordinal); + var hash = HashCodeCombiner.Start(); + hash.Add(descriptor.Kind, StringComparer.Ordinal); + hash.Add(descriptor.AssemblyName, StringComparer.Ordinal); + hash.Add(descriptor.Name, StringComparer.Ordinal); - var childTags = descriptor.AllowedChildTags.OrderBy(childTag => childTag.Name, _stringComparer); - foreach (var childTag in childTags) - { - hashCodeCombiner.Add(_AllowedChildTagDescriptorComparer.GetHashCode(childTag)); - } - - var boundAttributes = descriptor.BoundAttributes.OrderBy(attribute => attribute.Name, _stringComparer); - foreach (var attribute in boundAttributes) - { - hashCodeCombiner.Add(_boundAttributeComparer.GetHashCode(attribute)); - } - - var rules = descriptor.TagMatchingRules.OrderBy(rule => rule.TagName, _stringComparer); - foreach (var rule in rules) - { - hashCodeCombiner.Add(_tagMatchingRuleComparer.GetHashCode(rule)); - } - - hashCodeCombiner.Add(descriptor.Documentation, StringComparer.Ordinal); - hashCodeCombiner.Add(descriptor.DisplayName, StringComparer.Ordinal); - hashCodeCombiner.Add(descriptor.TagOutputHint, _stringComparer); - - return hashCodeCombiner.CombinedHash; + return hash.CombinedHash; } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagMatchingRuleDescriptorComparer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagMatchingRuleDescriptorComparer.cs index c77bdfbddb..734485b3c3 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagMatchingRuleDescriptorComparer.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagMatchingRuleDescriptorComparer.cs @@ -54,12 +54,11 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - return ruleX != null && + return string.Equals(ruleX.TagName, ruleY.TagName, _stringComparison) && string.Equals(ruleX.ParentTag, ruleY.ParentTag, _stringComparison) && ruleX.TagStructure == ruleY.TagStructure && - Enumerable.SequenceEqual(ruleX.Attributes, ruleY.Attributes, _requiredAttributeComparer) && - Enumerable.SequenceEqual(ruleX.Diagnostics, ruleY.Diagnostics); + Enumerable.SequenceEqual(ruleX.Attributes, ruleY.Attributes, _requiredAttributeComparer); } public virtual int GetHashCode(TagMatchingRuleDescriptor rule) @@ -69,18 +68,10 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(rule)); } - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(rule.TagName, _stringComparer); - hashCodeCombiner.Add(rule.ParentTag, _stringComparer); - hashCodeCombiner.Add(rule.TagStructure); + var hash = HashCodeCombiner.Start(); + hash.Add(rule.TagName, _stringComparer); - var attributes = rule.Attributes.OrderBy(attribute => attribute.Name, _stringComparer); - foreach (var attribute in attributes) - { - hashCodeCombiner.Add(_requiredAttributeComparer.GetHashCode(attribute)); - } - - return hashCodeCombiner.CombinedHash; + return hash.CombinedHash; } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/breakingchanges.netcore.json b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/breakingchanges.netcore.json new file mode 100644 index 0000000000..a753f1bfc8 --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/breakingchanges.netcore.json @@ -0,0 +1,15 @@ +[ + { + "TypeId": "protected enum Microsoft.AspNetCore.Razor.Language.Legacy.Tokenizer+RazorCommentTokenizerState where T0 : Microsoft.AspNetCore.Razor.Language.Legacy.SymbolBase where T1 : struct", + "Kind": "Removal" + }, + { + "TypeId": "protected struct Microsoft.AspNetCore.Razor.Language.Legacy.Tokenizer+StateResult where T0 : Microsoft.AspNetCore.Razor.Language.Legacy.SymbolBase where T1 : struct", + "Kind": "Removal" + }, + { + "TypeId": "protected class Microsoft.AspNetCore.Razor.Language.Legacy.CSharpCodeParser+Block", + "MemberId": "public .ctor(Microsoft.AspNetCore.Razor.Language.Legacy.CSharpSymbol symbol, Microsoft.AspNetCore.Razor.Language.SourceLocation start)", + "Kind": "Removal" + } +] \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/breakingchanges.netframework.json b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/breakingchanges.netframework.json new file mode 100644 index 0000000000..a753f1bfc8 --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/breakingchanges.netframework.json @@ -0,0 +1,15 @@ +[ + { + "TypeId": "protected enum Microsoft.AspNetCore.Razor.Language.Legacy.Tokenizer+RazorCommentTokenizerState where T0 : Microsoft.AspNetCore.Razor.Language.Legacy.SymbolBase where T1 : struct", + "Kind": "Removal" + }, + { + "TypeId": "protected struct Microsoft.AspNetCore.Razor.Language.Legacy.Tokenizer+StateResult where T0 : Microsoft.AspNetCore.Razor.Language.Legacy.SymbolBase where T1 : struct", + "Kind": "Removal" + }, + { + "TypeId": "protected class Microsoft.AspNetCore.Razor.Language.Legacy.CSharpCodeParser+Block", + "MemberId": "public .ctor(Microsoft.AspNetCore.Razor.Language.Legacy.CSharpSymbol symbol, Microsoft.AspNetCore.Razor.Language.SourceLocation start)", + "Kind": "Removal" + } +] \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Runtime/Runtime/TagHelpers/TagHelperExecutionContext.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Runtime/Runtime/TagHelpers/TagHelperExecutionContext.cs index 030e898b44..140c90597e 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Runtime/Runtime/TagHelpers/TagHelperExecutionContext.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Runtime/Runtime/TagHelpers/TagHelperExecutionContext.cs @@ -258,8 +258,14 @@ namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers if (childContent == null) { _startTagHelperWritingScope(null); - await _executeChildContentAsync(); - childContent = _endTagHelperWritingScope(); + try + { + await _executeChildContentAsync(); + } + finally + { + childContent = _endTagHelperWritingScope(); + } } Debug.Assert(!Output.IsContentModified); @@ -292,8 +298,14 @@ namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers if (!useCachedResult || childContent == null) { _startTagHelperWritingScope(encoder); - await _executeChildContentAsync(); - childContent = _endTagHelperWritingScope(); + try + { + await _executeChildContentAsync(); + } + finally + { + childContent = _endTagHelperWritingScope(); + } if (encoder == null) { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/Microsoft.AspNetCore.Razor.Tasks.csproj b/src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/Microsoft.AspNetCore.Razor.Tasks.csproj deleted file mode 100644 index 79eefc909b..0000000000 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/Microsoft.AspNetCore.Razor.Tasks.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - Razor is a markup syntax for adding server-side logic to web pages. This assembly contains infrastructure supporting Razor MSBuild integration. - - - net46;netstandard2.0 - - - false - false - - - - - - - - - Shared\ServerProtocol\%(FileName) - - - Shared\PipeName.cs - - - Shared\MutexName.cs - - - Shared\Client.cs - - - diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/Application.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/Application.cs index ba043a2b40..9c63203f66 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/Application.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/Application.cs @@ -57,8 +57,11 @@ namespace Microsoft.AspNetCore.Razor.Tools } catch (AggregateException ex) when (ex.InnerException != null) { - Error.WriteLine(ex.InnerException.Message); - Error.WriteLine(ex.InnerException.StackTrace); + foreach (var innerException in ex.Flatten().InnerExceptions) + { + Error.WriteLine(innerException.Message); + Error.WriteLine(innerException.StackTrace); + } return 1; } catch (CommandParsingException ex) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/ServerCommand.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/ServerCommand.cs index 44bb594b1c..a4aee01b3d 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/ServerCommand.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/ServerCommand.cs @@ -25,7 +25,10 @@ namespace Microsoft.AspNetCore.Razor.Tools internal ServerCommand(Application parent, string pipeName, int? keepAlive = null) : this(parent) { - Pipe.Values.Add(pipeName); + if (!string.IsNullOrEmpty(pipeName)) + { + Pipe.Values.Add(pipeName); + } if (keepAlive.HasValue) { @@ -119,8 +122,21 @@ namespace Microsoft.AspNetCore.Razor.Tools dispatcher.Run(); } - internal FileStream WritePidFile() + protected virtual FileStream WritePidFile() { + var path = GetPidFilePath(env => Environment.GetEnvironmentVariable(env)); + return WritePidFile(path); + } + + // Internal for testing. + internal virtual FileStream WritePidFile(string directoryPath) + { + if (string.IsNullOrEmpty(directoryPath)) + { + // Invalid path. Bail. + return null; + } + // To make all the running rzc servers more discoverable, We want to write the process Id and pipe name to a file. // The file contents will be in the following format, // @@ -133,24 +149,10 @@ namespace Microsoft.AspNetCore.Razor.Tools var processId = Process.GetCurrentProcess().Id; var fileName = $"rzc-{processId}"; - var path = Environment.GetEnvironmentVariable("DOTNET_BUILD_PIDFILE_DIRECTORY"); - if (string.IsNullOrEmpty(path)) - { - var homeEnvVariable = PlatformInformation.IsWindows ? "USERPROFILE" : "HOME"; - var homePath = Environment.GetEnvironmentVariable(homeEnvVariable); - if (string.IsNullOrEmpty(homePath)) - { - // Couldn't locate the user profile directory. Bail. - return null; - } - - path = Path.Combine(homePath, ".dotnet", "pids", "build"); - } - // Make sure the directory exists. - Directory.CreateDirectory(path); + Directory.CreateDirectory(directoryPath); - path = Path.Combine(path, fileName); + var path = Path.Combine(directoryPath, fileName); var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, DefaultBufferSize, FileOptions.DeleteOnClose); using (var writer = new StreamWriter(fileStream, Encoding.UTF8, DefaultBufferSize, leaveOpen: true)) @@ -162,5 +164,25 @@ namespace Microsoft.AspNetCore.Razor.Tools return fileStream; } + + // Internal for testing. + internal virtual string GetPidFilePath(Func getEnvironmentVariable) + { + var path = getEnvironmentVariable("DOTNET_BUILD_PIDFILE_DIRECTORY"); + if (string.IsNullOrEmpty(path)) + { + var homeEnvVariable = PlatformInformation.IsWindows ? "USERPROFILE" : "HOME"; + var homePath = getEnvironmentVariable(homeEnvVariable); + if (string.IsNullOrEmpty(homePath)) + { + // Couldn't locate the user profile directory. Bail. + return null; + } + + path = Path.Combine(homePath, ".dotnet", "pids", "build"); + } + + return path; + } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs index d9fb8d4b11..d254be4e60 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } catch { - // In the case an exception occured trying to open the Mutex then + // In the case an exception occurred trying to open the Mutex then // the assumption is that it's not open. } @@ -387,4 +387,4 @@ namespace Microsoft.AspNetCore.Razor.Tools public static bool IsWindows => Path.DirectorySeparatorChar == '\\'; public static bool IsUnix => Path.DirectorySeparatorChar == '/'; } -} \ No newline at end of file +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor/TagHelpers/DefaultTagHelperContent.cs b/src/Razor/src/Microsoft.AspNetCore.Razor/TagHelpers/DefaultTagHelperContent.cs index c4cdc3750f..f7185ba8a6 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor/TagHelpers/DefaultTagHelperContent.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor/TagHelpers/DefaultTagHelperContent.cs @@ -221,8 +221,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers return; } - var stringValue = entry as string; - if (stringValue != null) + if (entry is string stringValue) { encoder.Encode(writer, stringValue); } @@ -239,13 +238,11 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers return; } - string entryAsString; - IHtmlContentContainer entryAsContainer; - if ((entryAsString = entry as string) != null) + if (entry is string entryAsString) { destination.Append(entryAsString); } - else if ((entryAsContainer = entry as IHtmlContentContainer) != null) + else if (entry is IHtmlContentContainer entryAsContainer) { entryAsContainer.CopyTo(destination); } @@ -262,13 +259,11 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers return; } - string entryAsString; - IHtmlContentContainer entryAsContainer; - if ((entryAsString = entry as string) != null) + if (entry is string entryAsString) { destination.Append(entryAsString); } - else if ((entryAsContainer = entry as IHtmlContentContainer) != null) + else if (entry is IHtmlContentContainer entryAsContainer) { entryAsContainer.MoveTo(destination); } @@ -282,29 +277,19 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers { if (entry == null) { - return false; + return true; } - var stringValue = entry as string; - if (stringValue != null) + if (entry is string stringValue) { // Do not encode the string because encoded value remains whitespace from user's POV. - if (!string.IsNullOrWhiteSpace(stringValue)) - { - return false; - } - } - else - { - // Use NullHtmlEncoder to avoid treating encoded whitespace as non-whitespace e.g. "\t" as " ". - ((IHtmlContent)entry).WriteTo(writer, NullHtmlEncoder.Default); - if (!writer.IsEmptyOrWhiteSpace) - { - return false; - } + return string.IsNullOrWhiteSpace(stringValue); } - return true; + // Use NullHtmlEncoder to avoid treating encoded whitespace as non-whitespace e.g. "\t" as " ". + ((IHtmlContent)entry).WriteTo(writer, NullHtmlEncoder.Default); + + return writer.IsEmptyOrWhiteSpace; } private TagHelperContent AppendCore(object entry) @@ -329,7 +314,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers { return GetContent(); } - + // Overrides Write(string) to find if the content written is empty/whitespace. private class EmptyOrWhiteSpaceWriter : TextWriter { @@ -360,4 +345,4 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers } } } -} \ No newline at end of file +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultProjectSnapshotProjectEngineFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultProjectSnapshotProjectEngineFactory.cs new file mode 100644 index 0000000000..cd9ac1ee51 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultProjectSnapshotProjectEngineFactory.cs @@ -0,0 +1,102 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class DefaultProjectSnapshotProjectEngineFactory : ProjectSnapshotProjectEngineFactory + { + private readonly static RazorConfiguration DefaultConfiguration = FallbackRazorConfiguration.MVC_2_1; + + private readonly IFallbackProjectEngineFactory _fallback; + private readonly Lazy[] _factories; + + public DefaultProjectSnapshotProjectEngineFactory( + IFallbackProjectEngineFactory fallback, + Lazy[] factories) + { + if (fallback == null) + { + throw new ArgumentNullException(nameof(fallback)); + } + + if (factories == null) + { + throw new ArgumentNullException(nameof(factories)); + } + + _fallback = fallback; + _factories = factories; + } + + public override RazorProjectEngine Create(ProjectSnapshot project, RazorProjectFileSystem fileSystem, Action configure) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } + + // When we're running in the editor, the editor provides a configure delegate that will include + // the editor settings and tag helpers. + // + // This service is only used in process in Visual Studio, and any other callers should provide these + // things also. + configure = configure ?? ((b) => { }); + + // The default configuration currently matches the newest MVC configuration. + // + // We typically want this because the language adds features over time - we don't want to a bunch of errors + // to show up when a document is first opened, and then go away when the configuration loads, we'd prefer the opposite. + var configuration = project.Configuration ?? DefaultConfiguration; + + // If there's no factory to handle the configuration then fall back to a very basic configuration. + // + // This will stop a crash from happening in this case (misconfigured project), but will still make + // it obvious to the user that something is wrong. + var factory = SelectFactory(configuration) ?? _fallback; + return factory.Create(configuration, fileSystem, configure); + } + + public override IProjectEngineFactory FindFactory(ProjectSnapshot project) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + return SelectFactory(project.Configuration ?? DefaultConfiguration, requireSerializable: false); + } + + public override IProjectEngineFactory FindSerializableFactory(ProjectSnapshot project) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + return SelectFactory(project.Configuration ?? DefaultConfiguration, requireSerializable: true); + } + + private IProjectEngineFactory SelectFactory(RazorConfiguration configuration, bool requireSerializable = false) + { + for (var i = 0; i < _factories.Length; i++) + { + var factory = _factories[i]; + if (string.Equals(configuration.ConfigurationName, factory.Metadata.ConfigurationName)) + { + return requireSerializable && !factory.Metadata.SupportsSerialization ? null : factory.Value; + } + } + + return null; + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultProjectSnapshotProjectEngineFactoryFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultProjectSnapshotProjectEngineFactoryFactory.cs new file mode 100644 index 0000000000..663bd8f2bc --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultProjectSnapshotProjectEngineFactoryFactory.cs @@ -0,0 +1,46 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.CodeAnalysis.Razor.Workspaces +{ + [ExportWorkspaceServiceFactory(typeof(ProjectSnapshotProjectEngineFactory))] + internal class DefaultProjectSnapshotProjectEngineFactoryFactory : IWorkspaceServiceFactory + { + private readonly IFallbackProjectEngineFactory _fallback; + private readonly Lazy[] _factories; + + [ImportingConstructor] + public DefaultProjectSnapshotProjectEngineFactoryFactory( + IFallbackProjectEngineFactory fallback, + [ImportMany] Lazy[] factories) + { + if (fallback == null) + { + throw new ArgumentNullException(nameof(fallback)); + } + + if (factories == null) + { + throw new ArgumentNullException(nameof(factories)); + } + + _fallback = fallback; + _factories = factories; + } + + public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) + { + if (workspaceServices == null) + { + throw new ArgumentNullException(nameof(workspaceServices)); + } + + return new DefaultProjectSnapshotProjectEngineFactory(_fallback, _factories); + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentGenerator/BackgroundDocumentGenerator.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentGenerator/BackgroundDocumentGenerator.cs new file mode 100644 index 0000000000..eba3c12e25 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentGenerator/BackgroundDocumentGenerator.cs @@ -0,0 +1,275 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Composition; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.Extensions.Internal; + +namespace Microsoft.CodeAnalysis.Razor +{ + // Deliberately not exported for now, until this feature is working end to end. + // [Export(typeof(ProjectSnapshotChangeTrigger))] + internal class BackgroundDocumentGenerator : ProjectSnapshotChangeTrigger + { + private ForegroundDispatcher _foregroundDispatcher; + private ProjectSnapshotManagerBase _projectManager; + + private readonly Dictionary _files; + private Timer _timer; + + [ImportingConstructor] + public BackgroundDocumentGenerator(ForegroundDispatcher foregroundDispatcher) + { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + _foregroundDispatcher = foregroundDispatcher; + + _files = new Dictionary(); + } + + public bool HasPendingNotifications + { + get + { + lock (_files) + { + return _files.Count > 0; + } + } + } + + // Used in unit tests to control the timer delay. + public TimeSpan Delay { get; set; } = TimeSpan.FromSeconds(2); + + public bool IsScheduledOrRunning => _timer != null; + + // Used in unit tests to ensure we can control when background work starts. + public ManualResetEventSlim BlockBackgroundWorkStart { get; set; } + + // Used in unit tests to ensure we can know when background work finishes. + public ManualResetEventSlim NotifyBackgroundWorkStarting { get; set; } + + // Used in unit tests to ensure we can know when background has captured its current workload. + public ManualResetEventSlim NotifyBackgroundCapturedWorkload { get; set; } + + // Used in unit tests to ensure we can control when background work completes. + public ManualResetEventSlim BlockBackgroundWorkCompleting { get; set; } + + // Used in unit tests to ensure we can know when background work finishes. + public ManualResetEventSlim NotifyBackgroundWorkCompleted { get; set; } + + private void OnStartingBackgroundWork() + { + if (BlockBackgroundWorkStart != null) + { + BlockBackgroundWorkStart.Wait(); + BlockBackgroundWorkStart.Reset(); + } + + if (NotifyBackgroundWorkStarting != null) + { + NotifyBackgroundWorkStarting.Set(); + } + } + + private void OnCompletingBackgroundWork() + { + if (BlockBackgroundWorkCompleting != null) + { + BlockBackgroundWorkCompleting.Wait(); + BlockBackgroundWorkCompleting.Reset(); + } + } + + private void OnCompletedBackgroundWork() + { + if (NotifyBackgroundWorkCompleted != null) + { + NotifyBackgroundWorkCompleted.Set(); + } + } + + private void OnBackgroundCapturedWorkload() + { + if (NotifyBackgroundCapturedWorkload != null) + { + NotifyBackgroundCapturedWorkload.Set(); + } + } + + public override void Initialize(ProjectSnapshotManagerBase projectManager) + { + if (projectManager == null) + { + throw new ArgumentNullException(nameof(projectManager)); + } + + _projectManager = projectManager; + _projectManager.Changed += ProjectManager_Changed; + } + + protected virtual Task ProcessDocument(DocumentSnapshot document) + { + return document.GetGeneratedOutputAsync(); + } + + public void Enqueue(ProjectSnapshot project, DocumentSnapshot document) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + _foregroundDispatcher.AssertForegroundThread(); + + lock (_files) + { + // We only want to store the last 'seen' version of any given document. That way when we pick one to process + // it's always the best version to use. + _files[new DocumentKey(project.FilePath, document.FilePath)] = document; + + StartWorker(); + } + } + + protected virtual void StartWorker() + { + // Access to the timer is protected by the lock in Enqueue and in Timer_Tick + if (_timer == null) + { + + // Timer will fire after a fixed delay, but only once. + _timer = NonCapturingTimer.Create(state => ((BackgroundDocumentGenerator)state).Timer_Tick(), this, Delay, Timeout.InfiniteTimeSpan); + } + } + + private void Timer_Tick() + { + _ = TimerTick(); + } + + private async Task TimerTick() + { + try + { + _foregroundDispatcher.AssertBackgroundThread(); + + // Timer is stopped. + _timer.Change(Timeout.Infinite, Timeout.Infinite); + + OnStartingBackgroundWork(); + + DocumentSnapshot[] work; + lock (_files) + { + work = _files.Values.ToArray(); + _files.Clear(); + } + + OnBackgroundCapturedWorkload(); + + for (var i = 0; i < work.Length; i++) + { + var document = work[i]; + try + { + await ProcessDocument(document); + } + catch (Exception ex) + { + ReportError(document, ex); + } + } + + OnCompletingBackgroundWork(); + + lock (_files) + { + // Resetting the timer allows another batch of work to start. + _timer.Dispose(); + _timer = null; + + // If more work came in while we were running start the worker again. + if (_files.Count > 0) + { + StartWorker(); + } + } + + OnCompletedBackgroundWork(); + } + catch (Exception ex) + { + // This is something totally unexpected, let's just send it over to the workspace. + await Task.Factory.StartNew( + (p) => ((ProjectSnapshotManagerBase)p).ReportError(ex), + _projectManager, + CancellationToken.None, + TaskCreationOptions.None, + _foregroundDispatcher.ForegroundScheduler); + } + } + + private void ReportError(DocumentSnapshot document, Exception ex) + { + GC.KeepAlive(Task.Factory.StartNew( + (p) => ((ProjectSnapshotManagerBase)p).ReportError(ex), + _projectManager, + CancellationToken.None, + TaskCreationOptions.None, + _foregroundDispatcher.ForegroundScheduler)); + } + + private void ProjectManager_Changed(object sender, ProjectChangeEventArgs e) + { + switch (e.Kind) + { + case ProjectChangeKind.ProjectAdded: + case ProjectChangeKind.ProjectChanged: + { + var project = _projectManager.GetLoadedProject(e.ProjectFilePath); + foreach (var documentFilePath in project.DocumentFilePaths) + { + Enqueue(project, project.GetDocument(documentFilePath)); + } + + break; + } + + case ProjectChangeKind.ProjectRemoved: + // ignore + break; + + case ProjectChangeKind.DocumentAdded: + case ProjectChangeKind.DocumentChanged: + { + var project = _projectManager.GetLoadedProject(e.ProjectFilePath); + Enqueue(project, project.GetDocument(e.DocumentFilePath)); + + break; + } + + + case ProjectChangeKind.DocumentRemoved: + // ignore + break; + + default: + throw new InvalidOperationException($"Unknown ProjectChangeKind {e.Kind}"); + } + } + } +} \ No newline at end of file diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentKey.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentKey.cs new file mode 100644 index 0000000000..2fe707a707 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentKey.cs @@ -0,0 +1,41 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.Extensions.Internal; + +namespace Microsoft.CodeAnalysis.Razor +{ + public struct DocumentKey : IEquatable + { + public DocumentKey(string projectFilePath, string documentFilePath) + { + ProjectFilePath = projectFilePath; + DocumentFilePath = documentFilePath; + } + + public string ProjectFilePath { get; } + + public string DocumentFilePath { get; } + + public bool Equals(DocumentKey other) + { + return + FilePathComparer.Instance.Equals(ProjectFilePath, other.ProjectFilePath) && + FilePathComparer.Instance.Equals(DocumentFilePath, other.DocumentFilePath); + } + + public override bool Equals(object obj) + { + return obj is DocumentKey key ? Equals(key) : false; + } + + public override int GetHashCode() + { + var hash = new HashCodeCombiner(); + hash.Add(ProjectFilePath, FilePathComparer.Instance); + hash.Add(DocumentFilePath, FilePathComparer.Instance); + return hash; + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj index e7f29a2fb0..ca09c13e78 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSnapshotProjectEngineFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSnapshotProjectEngineFactory.cs new file mode 100644 index 0000000000..cf2341878d --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSnapshotProjectEngineFactory.cs @@ -0,0 +1,51 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal abstract class ProjectSnapshotProjectEngineFactory : IWorkspaceService + { + public abstract IProjectEngineFactory FindFactory(ProjectSnapshot project); + + public abstract IProjectEngineFactory FindSerializableFactory(ProjectSnapshot project); + + public RazorProjectEngine Create(ProjectSnapshot project) + { + return Create(project, RazorProjectFileSystem.Create(Path.GetDirectoryName(project.FilePath)), null); + } + + public RazorProjectEngine Create(ProjectSnapshot project, RazorProjectFileSystem fileSystem) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } + + return Create(project, fileSystem, null); + } + + public RazorProjectEngine Create(ProjectSnapshot project, Action configure) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + return Create(project, RazorProjectFileSystem.Create(Path.GetDirectoryName(project.FilePath)), configure); + } + + public abstract RazorProjectEngine Create(ProjectSnapshot project, RazorProjectFileSystem fileSystem, Action configure); + + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultDocumentSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultDocumentSnapshot.cs new file mode 100644 index 0000000000..d25b38ddbe --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultDocumentSnapshot.cs @@ -0,0 +1,81 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal class DefaultDocumentSnapshot : DocumentSnapshot + { + public DefaultDocumentSnapshot(DefaultProjectSnapshot project, DocumentState state) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + if (state == null) + { + throw new ArgumentNullException(nameof(state)); + } + + Project = project; + State = state; + } + + public DefaultProjectSnapshot Project { get; } + + public DocumentState State { get; } + + public override string FilePath => State.HostDocument.FilePath; + + public override string TargetPath => State.HostDocument.TargetPath; + + public override IReadOnlyList GetImports() + { + return State.Imports.GetImports(Project, this); + } + + public override Task GetTextAsync() + { + return State.GetTextAsync(); + } + + public override Task GetTextVersionAsync() + { + return State.GetTextVersionAsync(); + } + + public override Task GetGeneratedOutputAsync() + { + // IMPORTANT: Don't put more code here. We want this to return a cached task. + return State.GeneratedOutput.GetGeneratedOutputInitializationTask(Project, this); + } + + public override bool TryGetText(out SourceText result) + { + return State.TryGetText(out result); + } + + public override bool TryGetTextVersion(out VersionStamp result) + { + return State.TryGetTextVersion(out result); + } + + public override bool TryGetGeneratedOutput(out RazorCodeDocument result) + { + if (State.GeneratedOutput.IsResultAvailable) + { + result = State.GeneratedOutput.GetGeneratedOutputInitializationTask(Project, this).Result; + return true; + } + + result = null; + return false; + } + } +} \ No newline at end of file diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs index b8646429c6..aba5e7a916 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs @@ -3,182 +3,82 @@ using System; using System.Collections.Generic; -using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { - // All of the public state of this is immutable - we create a new instance and notify subscribers - // when it changes. - // - // However we use the private state to track things like dirty/clean. - // - // See the private constructors... When we update the snapshot we either are processing a Workspace - // change (Project) or updating the computed state (ProjectSnapshotUpdateContext). We don't do both - // at once. internal class DefaultProjectSnapshot : ProjectSnapshot { - public DefaultProjectSnapshot(HostProject hostProject, Project workspaceProject, VersionStamp? version = null) + private readonly object _lock; + + private Dictionary _documents; + + public DefaultProjectSnapshot(ProjectState state) { - if (hostProject == null) + if (state == null) { - throw new ArgumentNullException(nameof(hostProject)); + throw new ArgumentNullException(nameof(state)); } - HostProject = hostProject; - WorkspaceProject = workspaceProject; // Might be null - - FilePath = hostProject.FilePath; - Version = version ?? VersionStamp.Default; + State = state; + + _lock = new object(); + _documents = new Dictionary(FilePathComparer.Instance); } - private DefaultProjectSnapshot(HostProject hostProject, DefaultProjectSnapshot other) - { - if (hostProject == null) - { - throw new ArgumentNullException(nameof(hostProject)); - } - - if (other == null) - { - throw new ArgumentNullException(nameof(other)); - } - - ComputedVersion = other.ComputedVersion; - - FilePath = other.FilePath; - TagHelpers = other.TagHelpers; - HostProject = hostProject; - WorkspaceProject = other.WorkspaceProject; - - Version = other.Version.GetNewerVersion(); - } - - private DefaultProjectSnapshot(Project workspaceProject, DefaultProjectSnapshot other) - { - if (workspaceProject == null) - { - throw new ArgumentNullException(nameof(workspaceProject)); - } - - if (other == null) - { - throw new ArgumentNullException(nameof(other)); - } - - ComputedVersion = other.ComputedVersion; - - FilePath = other.FilePath; - TagHelpers = other.TagHelpers; - HostProject = other.HostProject; - WorkspaceProject = workspaceProject; - - Version = other.Version.GetNewerVersion(); - } - - private DefaultProjectSnapshot(ProjectSnapshotUpdateContext update, DefaultProjectSnapshot other) - { - if (update == null) - { - throw new ArgumentNullException(nameof(update)); - } - - if (other == null) - { - throw new ArgumentNullException(nameof(other)); - } - - ComputedVersion = update.Version; - - FilePath = other.FilePath; - HostProject = other.HostProject; - TagHelpers = update.TagHelpers ?? Array.Empty(); - WorkspaceProject = other.WorkspaceProject; - - // This doesn't represent a new version of the underlying data. Keep the same version. - Version = other.Version; - } + public ProjectState State { get; } public override RazorConfiguration Configuration => HostProject.Configuration; - public override string FilePath { get; } + public override IEnumerable DocumentFilePaths => State.Documents.Keys; - public override HostProject HostProject { get; } + public override string FilePath => State.HostProject.FilePath; + + public HostProject HostProject => State.HostProject; public override bool IsInitialized => WorkspaceProject != null; - public override VersionStamp Version { get; } + public override VersionStamp Version => State.Version; - public override Project WorkspaceProject { get; } + public override Project WorkspaceProject => State.WorkspaceProject; - public override IReadOnlyList TagHelpers { get; } = Array.Empty(); - - // This is the version that the computed state is based on. - public VersionStamp? ComputedVersion { get; set; } - - // We know the project is dirty if we don't have a computed result, or it was computed for a different version. - // Since the PSM updates the snapshots synchronously, the snapshot can never be older than the computed state. - public bool IsDirty => ComputedVersion == null || ComputedVersion.Value != Version; - - public ProjectSnapshotUpdateContext CreateUpdateContext() + public override DocumentSnapshot GetDocument(string filePath) { - return new ProjectSnapshotUpdateContext(FilePath, HostProject, WorkspaceProject, Version); + lock (_lock) + { + if (!_documents.TryGetValue(filePath, out var result) && + State.Documents.TryGetValue(filePath, out var state)) + { + result = new DefaultDocumentSnapshot(this, state); + _documents.Add(filePath, result); + } + + return result; + } } - public DefaultProjectSnapshot WithHostProject(HostProject hostProject) + public override RazorProjectEngine GetProjectEngine() { - if (hostProject == null) + return State.ProjectEngine.GetProjectEngine(this); + } + + public override Task> GetTagHelpersAsync() + { + // IMPORTANT: Don't put more code here. We want this to return a cached task. + return State.TagHelpers.GetTagHelperInitializationTask(this); + } + + public override bool TryGetTagHelpers(out IReadOnlyList result) + { + if (State.TagHelpers.IsResultAvailable) { - throw new ArgumentNullException(nameof(hostProject)); + result = State.TagHelpers.GetTagHelperInitializationTask(this).Result; + return true; } - return new DefaultProjectSnapshot(hostProject, this); - } - - public DefaultProjectSnapshot RemoveWorkspaceProject() - { - // We want to get rid of all of the computed state since it's not really valid. - return new DefaultProjectSnapshot(HostProject, null, Version.GetNewerVersion()); - } - - public DefaultProjectSnapshot WithWorkspaceProject(Project workspaceProject) - { - if (workspaceProject == null) - { - throw new ArgumentNullException(nameof(workspaceProject)); - } - - return new DefaultProjectSnapshot(workspaceProject, this); - } - - public DefaultProjectSnapshot WithComputedUpdate(ProjectSnapshotUpdateContext update) - { - if (update == null) - { - throw new ArgumentNullException(nameof(update)); - } - - return new DefaultProjectSnapshot(update, this); - } - - public bool HasConfigurationChanged(DefaultProjectSnapshot original) - { - if (original == null) - { - throw new ArgumentNullException(nameof(original)); - } - - return !object.Equals(Configuration, original.Configuration); - } - - public bool HaveTagHelpersChanged(ProjectSnapshot original) - { - if (original == null) - { - throw new ArgumentNullException(nameof(original)); - } - - return !Enumerable.SequenceEqual(TagHelpers, original.TagHelpers); + result = null; + return false; } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs index c246fa14d7..5a810cc803 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs @@ -3,8 +3,10 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { @@ -31,15 +33,15 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem private readonly ErrorReporter _errorReporter; private readonly ForegroundDispatcher _foregroundDispatcher; private readonly ProjectSnapshotChangeTrigger[] _triggers; - private readonly ProjectSnapshotWorkerQueue _workerQueue; - private readonly ProjectSnapshotWorker _worker; - private readonly Dictionary _projects; + // Each entry holds a ProjectState and an optional ProjectSnapshot. ProjectSnapshots are + // created lazily. + private readonly Dictionary _projects; + private readonly HashSet _openDocuments; public DefaultProjectSnapshotManager( ForegroundDispatcher foregroundDispatcher, ErrorReporter errorReporter, - ProjectSnapshotWorker worker, IEnumerable triggers, Workspace workspace) { @@ -53,11 +55,6 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem throw new ArgumentNullException(nameof(errorReporter)); } - if (worker == null) - { - throw new ArgumentNullException(nameof(worker)); - } - if (triggers == null) { throw new ArgumentNullException(nameof(triggers)); @@ -70,13 +67,11 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem _foregroundDispatcher = foregroundDispatcher; _errorReporter = errorReporter; - _worker = worker; _triggers = triggers.ToArray(); Workspace = workspace; - _projects = new Dictionary(FilePathComparer.Instance); - - _workerQueue = new ProjectSnapshotWorkerQueue(_foregroundDispatcher, this, worker); + _projects = new Dictionary(FilePathComparer.Instance); + _openDocuments = new HashSet(FilePathComparer.Instance); for (var i = 0; i < _triggers.Length; i++) { @@ -89,43 +84,305 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem get { _foregroundDispatcher.AssertForegroundThread(); - return _projects.Values.ToArray(); + + + var i = 0; + var projects = new ProjectSnapshot[_projects.Count]; + foreach (var entry in _projects) + { + if (entry.Value.Snapshot == null) + { + entry.Value.Snapshot = new DefaultProjectSnapshot(entry.Value.State); + } + + projects[i++] = entry.Value.Snapshot; + } + + return projects; } } public override Workspace Workspace { get; } - public override void ProjectUpdated(ProjectSnapshotUpdateContext update) + public override ProjectSnapshot GetLoadedProject(string filePath) { - if (update == null) + if (filePath == null) { - throw new ArgumentNullException(nameof(update)); + throw new ArgumentNullException(nameof(filePath)); } _foregroundDispatcher.AssertForegroundThread(); - if (_projects.TryGetValue(update.WorkspaceProject.FilePath, out var original)) + if (_projects.TryGetValue(filePath, out var entry)) { - if (!original.IsInitialized) + if (entry.Snapshot == null) { - // If the project has been uninitialized, just ignore the update. - return; + entry.Snapshot = new DefaultProjectSnapshot(entry.State); } - // This is an update to the project's computed values, so everything should be overwritten - var snapshot = original.WithComputedUpdate(update); - _projects[update.WorkspaceProject.FilePath] = snapshot; + return entry.Snapshot; + } - if (snapshot.IsDirty) + return null; + } + + public override ProjectSnapshot GetOrCreateProject(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + _foregroundDispatcher.AssertForegroundThread(); + + return GetLoadedProject(filePath) ?? new EphemeralProjectSnapshot(Workspace.Services, filePath); + } + + public override bool IsDocumentOpen(string documentFilePath) + { + if (documentFilePath == null) + { + throw new ArgumentNullException(nameof(documentFilePath)); + } + + _foregroundDispatcher.AssertForegroundThread(); + + return _openDocuments.Contains(documentFilePath); + } + + public override void DocumentAdded(HostProject hostProject, HostDocument document, TextLoader textLoader) + { + if (hostProject == null) + { + throw new ArgumentNullException(nameof(hostProject)); + } + + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + _foregroundDispatcher.AssertForegroundThread(); + + if (_projects.TryGetValue(hostProject.FilePath, out var entry)) + { + var loader = textLoader == null ? DocumentState.EmptyLoader : (Func>)(() => { - // It's possible that the snapshot can still be dirty if we got a project update while computing state in - // the background. We need to trigger the background work to asynchronously compute the effect of the updates. - NotifyBackgroundWorker(snapshot.CreateUpdateContext()); + return textLoader.LoadTextAndVersionAsync(Workspace, null, CancellationToken.None); + }); + var state = entry.State.WithAddedHostDocument(document, loader); + + // Document updates can no-op. + if (!object.ReferenceEquals(state, entry.State)) + { + _projects[hostProject.FilePath] = new Entry(state); + NotifyListeners(new ProjectChangeEventArgs(hostProject.FilePath, document.FilePath, ProjectChangeKind.DocumentAdded)); } - - if (!object.Equals(snapshot.ComputedVersion, original.ComputedVersion)) + } + } + + public override void DocumentRemoved(HostProject hostProject, HostDocument document) + { + if (hostProject == null) + { + throw new ArgumentNullException(nameof(hostProject)); + } + + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + _foregroundDispatcher.AssertForegroundThread(); + if (_projects.TryGetValue(hostProject.FilePath, out var entry)) + { + var state = entry.State.WithRemovedHostDocument(document); + + // Document updates can no-op. + if (!object.ReferenceEquals(state, entry.State)) { - NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.TagHelpersChanged)); + _projects[hostProject.FilePath] = new Entry(state); + NotifyListeners(new ProjectChangeEventArgs(hostProject.FilePath, document.FilePath, ProjectChangeKind.DocumentRemoved)); + } + } + } + + public override void DocumentOpened(string projectFilePath, string documentFilePath, SourceText sourceText) + { + if (projectFilePath == null) + { + throw new ArgumentNullException(nameof(projectFilePath)); + } + + if (documentFilePath == null) + { + throw new ArgumentNullException(nameof(documentFilePath)); + } + + if (sourceText == null) + { + throw new ArgumentNullException(nameof(sourceText)); + } + + _foregroundDispatcher.AssertForegroundThread(); + if (_projects.TryGetValue(projectFilePath, out var entry) && + entry.State.Documents.TryGetValue(documentFilePath, out var older)) + { + ProjectState state; + SourceText olderText; + VersionStamp olderVersion; + + var currentText = sourceText; + if (older.TryGetText(out olderText) && + older.TryGetTextVersion(out olderVersion)) + { + var version = currentText.ContentEquals(olderText) ? olderVersion : olderVersion.GetNewerVersion(); + state = entry.State.WithChangedHostDocument(older.HostDocument, currentText, version); + } + else + { + state = entry.State.WithChangedHostDocument(older.HostDocument, async () => + { + olderText = await older.GetTextAsync().ConfigureAwait(false); + olderVersion = await older.GetTextVersionAsync().ConfigureAwait(false); + + var version = currentText.ContentEquals(olderText) ? olderVersion : olderVersion.GetNewerVersion(); + return TextAndVersion.Create(currentText, version, documentFilePath); + }); + } + + _openDocuments.Add(documentFilePath); + + // Document updates can no-op. + if (!object.ReferenceEquals(state, entry.State)) + { + _projects[projectFilePath] = new Entry(state); + NotifyListeners(new ProjectChangeEventArgs(projectFilePath, documentFilePath, ProjectChangeKind.DocumentChanged)); + } + } + } + + public override void DocumentClosed(string projectFilePath, string documentFilePath, TextLoader textLoader) + { + if (projectFilePath == null) + { + throw new ArgumentNullException(nameof(projectFilePath)); + } + + if (documentFilePath == null) + { + throw new ArgumentNullException(nameof(documentFilePath)); + } + + if (textLoader == null) + { + throw new ArgumentNullException(nameof(textLoader)); + } + + _foregroundDispatcher.AssertForegroundThread(); + if (_projects.TryGetValue(projectFilePath, out var entry) && + entry.State.Documents.TryGetValue(documentFilePath, out var older)) + { + var state = entry.State.WithChangedHostDocument(older.HostDocument, async () => + { + return await textLoader.LoadTextAndVersionAsync(Workspace, default, default); + }); + + _openDocuments.Remove(documentFilePath); + + // Document updates can no-op. + if (!object.ReferenceEquals(state, entry.State)) + { + _projects[projectFilePath] = new Entry(state); + NotifyListeners(new ProjectChangeEventArgs(projectFilePath, documentFilePath, ProjectChangeKind.DocumentChanged)); + } + } + } + + public override void DocumentChanged(string projectFilePath, string documentFilePath, SourceText sourceText) + { + if (projectFilePath == null) + { + throw new ArgumentNullException(nameof(projectFilePath)); + } + + if (documentFilePath == null) + { + throw new ArgumentNullException(nameof(documentFilePath)); + } + + if (sourceText == null) + { + throw new ArgumentNullException(nameof(sourceText)); + } + + _foregroundDispatcher.AssertForegroundThread(); + if (_projects.TryGetValue(projectFilePath, out var entry) && + entry.State.Documents.TryGetValue(documentFilePath, out var older)) + { + ProjectState state; + SourceText olderText; + VersionStamp olderVersion; + + var currentText = sourceText; + if (older.TryGetText(out olderText) && + older.TryGetTextVersion(out olderVersion)) + { + var version = currentText.ContentEquals(olderText) ? olderVersion : olderVersion.GetNewerVersion(); + state = entry.State.WithChangedHostDocument(older.HostDocument, currentText, version); + } + else + { + state = entry.State.WithChangedHostDocument(older.HostDocument, async () => + { + olderText = await older.GetTextAsync().ConfigureAwait(false); + olderVersion = await older.GetTextVersionAsync().ConfigureAwait(false); + + var version = currentText.ContentEquals(olderText) ? olderVersion : olderVersion.GetNewerVersion(); + return TextAndVersion.Create(currentText, version, documentFilePath); + }); + } + + // Document updates can no-op. + if (!object.ReferenceEquals(state, entry.State)) + { + _projects[projectFilePath] = new Entry(state); + NotifyListeners(new ProjectChangeEventArgs(projectFilePath, documentFilePath, ProjectChangeKind.DocumentChanged)); + } + } + } + + public override void DocumentChanged(string projectFilePath, string documentFilePath, TextLoader textLoader) + { + if (projectFilePath == null) + { + throw new ArgumentNullException(nameof(projectFilePath)); + } + + if (documentFilePath == null) + { + throw new ArgumentNullException(nameof(documentFilePath)); + } + + if (textLoader == null) + { + throw new ArgumentNullException(nameof(textLoader)); + } + + _foregroundDispatcher.AssertForegroundThread(); + if (_projects.TryGetValue(projectFilePath, out var entry) && + entry.State.Documents.TryGetValue(documentFilePath, out var older)) + { + var state = entry.State.WithChangedHostDocument(older.HostDocument, async () => + { + return await textLoader.LoadTextAndVersionAsync(Workspace, default, default); + }); + + // Document updates can no-op. + if (!object.ReferenceEquals(state, entry.State)) + { + _projects[projectFilePath] = new Entry(state); + NotifyListeners(new ProjectChangeEventArgs(projectFilePath, documentFilePath, ProjectChangeKind.DocumentChanged)); } } } @@ -149,17 +406,11 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // So if possible find a WorkspaceProject. var workspaceProject = GetWorkspaceProject(hostProject.FilePath); - var snapshot = new DefaultProjectSnapshot(hostProject, workspaceProject); - _projects[hostProject.FilePath] = snapshot; - - if (snapshot.IsInitialized && snapshot.IsDirty) - { - // Start computing background state if the project is fully initialized. - NotifyBackgroundWorker(snapshot.CreateUpdateContext()); - } + var state = ProjectState.Create(Workspace.Services, hostProject, workspaceProject); + _projects[hostProject.FilePath] = new Entry(state); // We need to notify listeners about every project add. - NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.Added)); + NotifyListeners(new ProjectChangeEventArgs(hostProject.FilePath, ProjectChangeKind.ProjectAdded)); } public override void HostProjectChanged(HostProject hostProject) @@ -171,22 +422,17 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem _foregroundDispatcher.AssertForegroundThread(); - if (_projects.TryGetValue(hostProject.FilePath, out var original)) + if (_projects.TryGetValue(hostProject.FilePath, out var entry)) { - // Doing an update to the project should keep computed values, but mark the project as dirty if the - // underlying project is newer. - var snapshot = original.WithHostProject(hostProject); - _projects[hostProject.FilePath] = snapshot; + var state = entry.State.WithHostProject(hostProject); - if (snapshot.IsInitialized && snapshot.IsDirty) + // HostProject updates can no-op. + if (!object.ReferenceEquals(state, entry.State)) { - // Start computing background state if the project is fully initialized. - NotifyBackgroundWorker(snapshot.CreateUpdateContext()); - } + _projects[hostProject.FilePath] = new Entry(state); - // Notify listeners right away because if the HostProject changes then it's likely that the Razor - // configuration changed. - NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.Changed)); + NotifyListeners(new ProjectChangeEventArgs(hostProject.FilePath, ProjectChangeKind.ProjectChanged)); + } } } @@ -204,37 +450,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem _projects.Remove(hostProject.FilePath); // We need to notify listeners about every project removal. - NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.Removed)); - } - } - - public override void HostProjectBuildComplete(HostProject hostProject) - { - if (hostProject == null) - { - throw new ArgumentNullException(nameof(hostProject)); - } - - _foregroundDispatcher.AssertForegroundThread(); - - if (_projects.TryGetValue(hostProject.FilePath, out var original)) - { - var workspaceProject = GetWorkspaceProject(hostProject.FilePath); - if (workspaceProject == null) - { - // Host project was built prior to a workspace project being associated. We have nothing to do without - // a workspace project so we short circuit. - return; - } - - // Doing an update to the project should keep computed values, but mark the project as dirty if the - // underlying project is newer. - var snapshot = original.WithWorkspaceProject(workspaceProject); - - _projects[hostProject.FilePath] = snapshot; - - // Notify the background worker so it can trigger tag helper discovery. - NotifyBackgroundWorker(snapshot.CreateUpdateContext()); + NotifyListeners(new ProjectChangeEventArgs(hostProject.FilePath, ProjectChangeKind.ProjectRemoved)); } } @@ -254,25 +470,16 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // The WorkspaceProject initialization never triggers a "Project Add" from out point of view, we // only care if the new WorkspaceProject matches an existing HostProject. - if (_projects.TryGetValue(workspaceProject.FilePath, out var original)) + if (_projects.TryGetValue(workspaceProject.FilePath, out var entry)) { // If this is a multi-targeting project then we are only interested in a single workspace project. If we already // found one in the past just ignore this one. - if (original.WorkspaceProject == null) + if (entry.State.WorkspaceProject == null) { - var snapshot = original.WithWorkspaceProject(workspaceProject); - _projects[workspaceProject.FilePath] = snapshot; + var state = entry.State.WithWorkspaceProject(workspaceProject); + _projects[workspaceProject.FilePath] = new Entry(state); - if (snapshot.IsInitialized && snapshot.IsDirty) - { - // We don't need to notify listeners yet because we don't have any **new** computed state. - // - // However we do need to trigger the background work to asynchronously compute the effect of the updates. - NotifyBackgroundWorker(snapshot.CreateUpdateContext()); - } - - // Notify listeners right away since WorkspaceProject was just added, the project is now initialized. - NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.Changed)); + NotifyListeners(new ProjectChangeEventArgs(workspaceProject.FilePath, ProjectChangeKind.ProjectChanged)); } } } @@ -293,25 +500,19 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // We also need to check the projectId here. If this is a multi-targeting project then we are only interested // in a single workspace project. Just use the one that showed up first. - if (_projects.TryGetValue(workspaceProject.FilePath, out var original) && - (original.WorkspaceProject == null || - original.WorkspaceProject.Id == workspaceProject.Id)) + if (_projects.TryGetValue(workspaceProject.FilePath, out var entry) && + (entry.State.WorkspaceProject == null || entry.State.WorkspaceProject.Id == workspaceProject.Id) && + (entry.State.WorkspaceProject == null || entry.State.WorkspaceProject.Version.GetNewerVersion(workspaceProject.Version) == workspaceProject.Version)) { - // Doing an update to the project should keep computed values, but mark the project as dirty if the - // underlying project is newer. - var snapshot = original.WithWorkspaceProject(workspaceProject); - _projects[workspaceProject.FilePath] = snapshot; - - if (snapshot.IsInitialized && snapshot.IsDirty) + var state = entry.State.WithWorkspaceProject(workspaceProject); + + // WorkspaceProject updates can no-op. This can be the case if a build is triggered, but we've + // already seen the update. + if (!object.ReferenceEquals(state, entry.State)) { - // We don't need to notify listeners yet because we don't have any **new** computed state. However we do - // need to trigger the background work to asynchronously compute the effect of the updates. - NotifyBackgroundWorker(snapshot.CreateUpdateContext()); - } + _projects[workspaceProject.FilePath] = new Entry(state); - if (snapshot.HaveTagHelpersChanged(original)) - { - NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.TagHelpersChanged)); + NotifyListeners(new ProjectChangeEventArgs(workspaceProject.FilePath, ProjectChangeKind.ProjectChanged)); } } } @@ -330,16 +531,16 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return; } - if (_projects.TryGetValue(workspaceProject.FilePath, out var original)) + if (_projects.TryGetValue(workspaceProject.FilePath, out var entry)) { // We also need to check the projectId here. If this is a multi-targeting project then we are only interested // in a single workspace project. Make sure the WorkspaceProject we're using is the one that's being removed. - if (original.WorkspaceProject?.Id != workspaceProject.Id) + if (entry.State.WorkspaceProject?.Id != workspaceProject.Id) { return; } - DefaultProjectSnapshot snapshot; + ProjectState state; // So if the WorkspaceProject got removed, we should double check to make sure that there aren't others // hanging around. This could happen if a project is multi-targeting and one of the TFMs is removed. @@ -347,30 +548,19 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem if (otherWorkspaceProject != null && otherWorkspaceProject.Id != workspaceProject.Id) { // OK there's another WorkspaceProject, use that. - // - // Doing an update to the project should keep computed values, but mark the project as dirty if the - // underlying project is newer. - snapshot = original.WithWorkspaceProject(otherWorkspaceProject); - _projects[workspaceProject.FilePath] = snapshot; + state = entry.State.WithWorkspaceProject(otherWorkspaceProject); + _projects[otherWorkspaceProject.FilePath] = new Entry(state); - if (snapshot.IsInitialized && snapshot.IsDirty) - { - // We don't need to notify listeners yet because we don't have any **new** computed state. However we do - // need to trigger the background work to asynchronously compute the effect of the updates. - NotifyBackgroundWorker(snapshot.CreateUpdateContext()); - } - - // Notify listeners of a change because it's a different WorkspaceProject. - NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.Changed)); - - return; + NotifyListeners(new ProjectChangeEventArgs(otherWorkspaceProject.FilePath, ProjectChangeKind.ProjectChanged)); } + else + { + state = entry.State.WithWorkspaceProject(null); + _projects[workspaceProject.FilePath] = new Entry(state); - snapshot = original.RemoveWorkspaceProject(); - _projects[workspaceProject.FilePath] = snapshot; - - // Notify listeners of a change because we've removed computed state. - NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.Changed)); + // Notify listeners of a change because we've removed computed state. + NotifyListeners(new ProjectChangeEventArgs(workspaceProject.FilePath, ProjectChangeKind.ProjectChanged)); + } } } @@ -401,8 +591,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem throw new ArgumentNullException(nameof(exception)); } - var project = hostProject?.FilePath == null ? null : this.GetProjectWithFilePath(hostProject.FilePath); - _errorReporter.ReportError(exception, project); + var snapshot = hostProject?.FilePath == null ? null : GetLoadedProject(hostProject.FilePath); + _errorReporter.ReportError(exception, snapshot); } public override void ReportError(Exception exception, Project workspaceProject) @@ -411,7 +601,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { throw new ArgumentNullException(nameof(exception)); } - + _errorReporter.ReportError(exception, workspaceProject); } @@ -440,14 +630,6 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return null; } - // virtual so it can be overridden in tests - protected virtual void NotifyBackgroundWorker(ProjectSnapshotUpdateContext context) - { - _foregroundDispatcher.AssertForegroundThread(); - - _workerQueue.Enqueue(context); - } - // virtual so it can be overridden in tests protected virtual void NotifyListeners(ProjectChangeEventArgs e) { @@ -459,5 +641,16 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem handler(this, e); } } + + private class Entry + { + public ProjectSnapshot Snapshot; + public readonly ProjectState State; + + public Entry(ProjectState state) + { + State = state; + } + } } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs index d82d82cd7c..b092174aa6 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs @@ -45,8 +45,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return new DefaultProjectSnapshotManager( _foregroundDispatcher, languageServices.WorkspaceServices.GetRequiredService(), - languageServices.GetRequiredService(), - _triggers, + _triggers, languageServices.WorkspaceServices.Workspace); } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs deleted file mode 100644 index 1b7480f940..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - internal class DefaultProjectSnapshotWorker : ProjectSnapshotWorker - { - private readonly ForegroundDispatcher _foregroundDispatcher; - private readonly TagHelperResolver _tagHelperResolver; - - public DefaultProjectSnapshotWorker(ForegroundDispatcher foregroundDispatcher, TagHelperResolver tagHelperResolver) - { - if (foregroundDispatcher == null) - { - throw new ArgumentNullException(nameof(foregroundDispatcher)); - } - - if (tagHelperResolver == null) - { - throw new ArgumentNullException(nameof(tagHelperResolver)); - } - - _foregroundDispatcher = foregroundDispatcher; - _tagHelperResolver = tagHelperResolver; - } - - public override Task ProcessUpdateAsync(ProjectSnapshotUpdateContext update, CancellationToken cancellationToken = default(CancellationToken)) - { - if (update == null) - { - throw new ArgumentNullException(nameof(update)); - } - - // Don't block the main thread - if (_foregroundDispatcher.IsForegroundThread) - { - return Task.Factory.StartNew(ProjectUpdatesCoreAsync, update, cancellationToken, TaskCreationOptions.None, _foregroundDispatcher.BackgroundScheduler); - } - - return ProjectUpdatesCoreAsync(update); - } - - protected virtual void OnProcessingUpdate() - { - } - - private async Task ProjectUpdatesCoreAsync(object state) - { - var update = (ProjectSnapshotUpdateContext)state; - - OnProcessingUpdate(); - - var snapshot = new DefaultProjectSnapshot(update.HostProject, update.WorkspaceProject, update.Version); - var result = await _tagHelperResolver.GetTagHelpersAsync(snapshot, CancellationToken.None); - update.TagHelpers = result.Descriptors; - } - } -} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs deleted file mode 100644 index bd36bf361d..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Composition; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Host.Mef; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - [Shared] - [ExportLanguageServiceFactory(typeof(ProjectSnapshotWorker), RazorLanguage.Name)] - internal class DefaultProjectSnapshotWorkerFactory : ILanguageServiceFactory - { - private readonly ForegroundDispatcher _foregroundDispatcher; - - [ImportingConstructor] - public DefaultProjectSnapshotWorkerFactory(ForegroundDispatcher foregroundDispatcher) - { - if (foregroundDispatcher == null) - { - throw new System.ArgumentNullException(nameof(foregroundDispatcher)); - } - - _foregroundDispatcher = foregroundDispatcher; - } - - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) - { - return new DefaultProjectSnapshotWorker(_foregroundDispatcher, languageServices.GetRequiredService()); - } - } -} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentGeneratedOutputTracker.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentGeneratedOutputTracker.cs new file mode 100644 index 0000000000..a3e11da04f --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentGeneratedOutputTracker.cs @@ -0,0 +1,172 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Text; +using Microsoft.Extensions.Internal; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal class DocumentGeneratedOutputTracker + { + private readonly object _lock; + + private DocumentGeneratedOutputTracker _older; + private Task _task; + + private IReadOnlyList _tagHelpers; + private IReadOnlyList _imports; + + public DocumentGeneratedOutputTracker(DocumentGeneratedOutputTracker older) + { + _older = older; + + _lock = new object(); + } + + public bool IsResultAvailable => _task?.IsCompleted == true; + + public DocumentGeneratedOutputTracker Older => _older; + + public Task GetGeneratedOutputInitializationTask(ProjectSnapshot project, DocumentSnapshot document) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + if (_task == null) + { + lock (_lock) + { + if (_task == null) + { + _task = GetGeneratedOutputInitializationTaskCore(project, document); + } + } + } + + return _task; + } + + public DocumentGeneratedOutputTracker Fork() + { + return new DocumentGeneratedOutputTracker(this); + } + + private async Task GetGeneratedOutputInitializationTaskCore(ProjectSnapshot project, DocumentSnapshot document) + { + var tagHelpers = await project.GetTagHelpersAsync().ConfigureAwait(false); + var imports = await GetImportsAsync(project, document); + + if (_older != null && _older.IsResultAvailable) + { + var tagHelperDifference = new HashSet(TagHelperDescriptorComparer.Default); + tagHelperDifference.UnionWith(_older._tagHelpers); + tagHelperDifference.SymmetricExceptWith(tagHelpers); + + var importDifference = new HashSet(); + importDifference.UnionWith(_older._imports); + importDifference.SymmetricExceptWith(imports); + + if (tagHelperDifference.Count == 0 && importDifference.Count == 0) + { + // We can use the cached result. + var result = _older._task.Result; + + // Drop reference so it can be GC'ed + _older = null; + + // Cache the tag helpers and imports so the next version can use them + _tagHelpers = tagHelpers; + _imports = imports; + + return result; + } + } + + // Drop reference so it can be GC'ed + _older = null; + + // Cache the tag helpers and imports so the next version can use them + _tagHelpers = tagHelpers; + _imports = imports; + + var importSources = new List(); + foreach (var item in imports) + { + var sourceDocument = await GetRazorSourceDocumentAsync(item.Import); + importSources.Add(sourceDocument); + } + + var documentSource = await GetRazorSourceDocumentAsync(document); + + var projectEngine = project.GetProjectEngine(); + + return projectEngine.ProcessDesignTime(documentSource, importSources, tagHelpers); + } + + private async Task GetRazorSourceDocumentAsync(DocumentSnapshot document) + { + var sourceText = await document.GetTextAsync(); + + return sourceText.GetRazorSourceDocument(document.FilePath); + } + + private async Task> GetImportsAsync(ProjectSnapshot project, DocumentSnapshot document) + { + var imports = new List(); + foreach (var snapshot in document.GetImports()) + { + var versionStamp = await snapshot.GetTextVersionAsync(); + imports.Add(new ImportItem(snapshot.FilePath, versionStamp, snapshot)); + } + + return imports; + } + + private struct ImportItem : IEquatable + { + public ImportItem(string filePath, VersionStamp versionStamp, DocumentSnapshot import) + { + FilePath = filePath; + VersionStamp = versionStamp; + Import = import; + } + + public string FilePath { get; } + + public VersionStamp VersionStamp { get; } + + public DocumentSnapshot Import { get; } + + public bool Equals(ImportItem other) + { + return + FilePathComparer.Instance.Equals(FilePath, other.FilePath) && + VersionStamp == other.VersionStamp; + } + + public override bool Equals(object obj) + { + return obj is ImportItem item ? Equals(item) : false; + } + + public override int GetHashCode() + { + var hash = new HashCodeCombiner(); + hash.Add(FilePath, FilePathComparer.Instance); + hash.Add(VersionStamp); + return hash; + } + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentImportsTracker.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentImportsTracker.cs new file mode 100644 index 0000000000..96b927e42f --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentImportsTracker.cs @@ -0,0 +1,165 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal class DocumentImportsTracker + { + private readonly object _lock; + + private IReadOnlyList _imports; + + public DocumentImportsTracker() + { + _lock = new object(); + } + + public IReadOnlyList GetImports(ProjectSnapshot project, DocumentSnapshot document) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + if (_imports == null) + { + lock (_lock) + { + if (_imports == null) + { + _imports = GetImportsCore(project, document); + } + } + } + + return _imports; + } + + private IReadOnlyList GetImportsCore(ProjectSnapshot project, DocumentSnapshot document) + { + var projectEngine = project.GetProjectEngine(); + var importFeature = projectEngine.ProjectFeatures.OfType().FirstOrDefault(); + var projectItem = projectEngine.FileSystem.GetItem(document.FilePath); + var importItems = importFeature?.GetImports(projectItem).Where(i => i.Exists); + if (importItems == null) + { + return Array.Empty(); + } + + var imports = new List(); + foreach (var item in importItems) + { + if (item.PhysicalPath == null) + { + // This is a default import. + var defaultImport = new DefaultImportDocumentSnapshot(project, item); + imports.Add(defaultImport); + } + else + { + var import = project.GetDocument(item.PhysicalPath); + if (import == null) + { + // We are not tracking this document in this project. So do nothing. + continue; + } + + imports.Add(import); + } + } + + return imports; + } + + private class DefaultImportDocumentSnapshot : DocumentSnapshot + { + private ProjectSnapshot _project; + private RazorProjectItem _importItem; + private SourceText _sourceText; + private VersionStamp _version; + private DocumentGeneratedOutputTracker _generatedOutput; + + public DefaultImportDocumentSnapshot(ProjectSnapshot project, RazorProjectItem item) + { + _project = project; + _importItem = item; + _version = VersionStamp.Default; + _generatedOutput = new DocumentGeneratedOutputTracker(null); + } + + public override string FilePath => null; + + public override string TargetPath => null; + + public override Task GetGeneratedOutputAsync() + { + return _generatedOutput.GetGeneratedOutputInitializationTask(_project, this); + } + + public override IReadOnlyList GetImports() + { + return Array.Empty(); + } + + public async override Task GetTextAsync() + { + using (var stream = _importItem.Read()) + using (var reader = new StreamReader(stream)) + { + var content = await reader.ReadToEndAsync(); + _sourceText = SourceText.From(content); + } + + return _sourceText; + } + + public override Task GetTextVersionAsync() + { + return Task.FromResult(_version); + } + + public override bool TryGetText(out SourceText result) + { + if (_sourceText != null) + { + result = _sourceText; + return true; + } + + result = null; + return false; + } + + public override bool TryGetTextVersion(out VersionStamp result) + { + result = _version; + return true; + } + + public override bool TryGetGeneratedOutput(out RazorCodeDocument result) + { + if (_generatedOutput.IsResultAvailable) + { + result = GetGeneratedOutputAsync().Result; + return true; + } + + result = null; + return false; + } + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs new file mode 100644 index 0000000000..0cc9da8f04 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal abstract class DocumentSnapshot + { + public abstract string FilePath { get; } + + public abstract string TargetPath { get; } + + public abstract IReadOnlyList GetImports(); + + public abstract Task GetTextAsync(); + + public abstract Task GetTextVersionAsync(); + + public abstract Task GetGeneratedOutputAsync(); + + public abstract bool TryGetText(out SourceText result); + + public abstract bool TryGetTextVersion(out VersionStamp result); + + public abstract bool TryGetGeneratedOutput(out RazorCodeDocument result); + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs new file mode 100644 index 0000000000..d1fb05b67a --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs @@ -0,0 +1,219 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal class DocumentState + { + private static readonly TextAndVersion EmptyText = TextAndVersion.Create( + SourceText.From(string.Empty), + VersionStamp.Default); + + public static readonly Func> EmptyLoader = () => Task.FromResult(EmptyText); + + private readonly object _lock; + + private Func> _loader; + private Task _loaderTask; + private SourceText _sourceText; + private VersionStamp? _version; + + private DocumentGeneratedOutputTracker _generatedOutput; + private DocumentImportsTracker _imports; + + public static DocumentState Create( + HostWorkspaceServices services, + HostDocument hostDocument, + Func> loader) + { + if (services == null) + { + throw new ArgumentNullException(nameof(services)); + } + + if (hostDocument == null) + { + throw new ArgumentNullException(nameof(hostDocument)); + } + + loader = loader ?? EmptyLoader; + return new DocumentState(services, hostDocument, null, null, loader); + } + + // Internal for testing + internal DocumentState( + HostWorkspaceServices services, + HostDocument hostDocument, + SourceText text, + VersionStamp? version, + Func> loader) + { + Services = services; + HostDocument = hostDocument; + _sourceText = text; + _version = version; + _loader = loader; + _lock = new object(); + } + + public HostDocument HostDocument { get; } + + public HostWorkspaceServices Services { get; } + + public DocumentGeneratedOutputTracker GeneratedOutput + { + get + { + if (_generatedOutput == null) + { + lock (_lock) + { + if (_generatedOutput == null) + { + _generatedOutput = new DocumentGeneratedOutputTracker(null); + } + } + } + + return _generatedOutput; + } + } + + public DocumentImportsTracker Imports + { + get + { + if (_imports == null) + { + lock (_lock) + { + if (_imports == null) + { + _imports = new DocumentImportsTracker(); + } + } + } + + return _imports; + } + } + + public async Task GetTextAsync() + { + if (TryGetText(out var text)) + { + return text; + } + + lock (_lock) + { + _loaderTask = _loader(); + } + + return (await _loaderTask.ConfigureAwait(false)).Text; + } + + public async Task GetTextVersionAsync() + { + if (TryGetTextVersion(out var version)) + { + return version; + } + + lock (_lock) + { + _loaderTask = _loader(); + } + + return (await _loaderTask.ConfigureAwait(false)).Version; + } + + public bool TryGetText(out SourceText result) + { + if (_sourceText != null) + { + result = _sourceText; + return true; + } + + if (_loaderTask != null && _loaderTask.IsCompleted) + { + result = _loaderTask.Result.Text; + return true; + } + + result = null; + return false; + } + + public bool TryGetTextVersion(out VersionStamp result) + { + if (_version != null) + { + result = _version.Value; + return true; + } + + if (_loaderTask != null && _loaderTask.IsCompleted) + { + result = _loaderTask.Result.Version; + return true; + } + + result = default; + return false; + } + + public virtual DocumentState WithConfigurationChange() + { + var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader); + + // The source could not have possibly changed. + state._sourceText = _sourceText; + state._version = _version; + state._loaderTask = _loaderTask; + + return state; + } + + public virtual DocumentState WithWorkspaceProjectChange() + { + var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader); + + // The source could not have possibly changed. + state._sourceText = _sourceText; + state._version = _version; + state._loaderTask = _loaderTask; + + // Opportunistically cache the generated code + state._generatedOutput = _generatedOutput?.Fork(); + + return state; + } + + public virtual DocumentState WithText(SourceText sourceText, VersionStamp version) + { + if (sourceText == null) + { + throw new ArgumentNullException(nameof(sourceText)); + } + + return new DocumentState(Services, HostDocument, sourceText, version, null); + } + + public virtual DocumentState WithTextLoader(Func> loader) + { + if (loader == null) + { + throw new ArgumentNullException(nameof(loader)); + } + + return new DocumentState(Services, HostDocument, null, null, loader); + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EphemeralProjectSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EphemeralProjectSnapshot.cs new file mode 100644 index 0000000000..cd87c074de --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EphemeralProjectSnapshot.cs @@ -0,0 +1,81 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Host; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal class EphemeralProjectSnapshot : ProjectSnapshot + { + private static readonly Task> EmptyTagHelpers = Task.FromResult>(Array.Empty()); + + private readonly HostWorkspaceServices _services; + private readonly Lazy _projectEngine; + + public EphemeralProjectSnapshot(HostWorkspaceServices services, string filePath) + { + if (services == null) + { + throw new ArgumentNullException(nameof(services)); + } + + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + _services = services; + FilePath = filePath; + + _projectEngine = new Lazy(CreateProjectEngine); + } + + public override RazorConfiguration Configuration => FallbackRazorConfiguration.MVC_2_1; + + public override IEnumerable DocumentFilePaths => Array.Empty(); + + public override string FilePath { get; } + + public override bool IsInitialized => false; + + public override VersionStamp Version { get; } = VersionStamp.Default; + + public override Project WorkspaceProject => null; + + public override DocumentSnapshot GetDocument(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + return null; + } + + public override RazorProjectEngine GetProjectEngine() + { + return _projectEngine.Value; + } + + public override Task> GetTagHelpersAsync() + { + return EmptyTagHelpers; + } + + public override bool TryGetTagHelpers(out IReadOnlyList result) + { + result = EmptyTagHelpers.Result; + return true; + } + + private RazorProjectEngine CreateProjectEngine() + { + var factory = _services.GetRequiredService(); + return factory.Create(this); + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostDocument.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostDocument.cs new file mode 100644 index 0000000000..859cc0df32 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostDocument.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal class HostDocument + { + public HostDocument(string filePath, string targetPath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + if (targetPath == null) + { + throw new ArgumentNullException(nameof(targetPath)); + } + + FilePath = filePath; + TargetPath = targetPath; + } + + public string FilePath { get; } + + public string TargetPath { get; } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/LiveShareProjectSnapshotBase.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/LiveShareProjectSnapshotBase.cs new file mode 100644 index 0000000000..f03a31b0ae --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/LiveShareProjectSnapshotBase.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; + +namespace Microsoft.CodeAnalysis.Razor.Workspaces.ProjectSystem +{ + // This is a marker class to allow us to know when potential breaking changes might impact live share. + // This is intentionally not abstract so any API changes that happen to ProjectSnapshot will break this. + internal class LiveShareProjectSnapshotBase : ProjectSnapshot + { + public override RazorConfiguration Configuration => throw new NotImplementedException(); + + public override IEnumerable DocumentFilePaths => throw new NotImplementedException(); + + public override string FilePath => throw new NotImplementedException(); + + public override bool IsInitialized => throw new NotImplementedException(); + + public override VersionStamp Version => throw new NotImplementedException(); + + public override Project WorkspaceProject => throw new NotImplementedException(); + + public override DocumentSnapshot GetDocument(string filePath) => throw new NotImplementedException(); + + public override RazorProjectEngine GetProjectEngine() => throw new NotImplementedException(); + + public override Task> GetTagHelpersAsync() => throw new NotImplementedException(); + + public override bool TryGetTagHelpers(out IReadOnlyList result) => throw new NotImplementedException(); + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeEventArgs.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeEventArgs.cs index eca6b56774..a163ba5f1b 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeEventArgs.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeEventArgs.cs @@ -7,13 +7,32 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { internal class ProjectChangeEventArgs : EventArgs { - public ProjectChangeEventArgs(ProjectSnapshot project, ProjectChangeKind kind) + public ProjectChangeEventArgs(string projectFilePath, ProjectChangeKind kind) { - Project = project; + if (projectFilePath == null) + { + throw new ArgumentNullException(nameof(projectFilePath)); + } + + ProjectFilePath = projectFilePath; Kind = kind; } - public ProjectSnapshot Project { get; } + public ProjectChangeEventArgs(string projectFilePath, string documentFilePath, ProjectChangeKind kind) + { + if (projectFilePath == null) + { + throw new ArgumentNullException(nameof(projectFilePath)); + } + + ProjectFilePath = projectFilePath; + DocumentFilePath = documentFilePath; + Kind = kind; + } + + public string ProjectFilePath { get; } + + public string DocumentFilePath { get; } public ProjectChangeKind Kind { get; } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeKind.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeKind.cs index c2ff3feacf..98bd0a4010 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeKind.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeKind.cs @@ -5,9 +5,13 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { internal enum ProjectChangeKind { - Added, - Removed, - Changed, - TagHelpersChanged, + ProjectAdded, + ProjectRemoved, + ProjectChanged, + DocumentAdded, + DocumentRemoved, + + // This could be a state change (opened/closed) or a content change. + DocumentChanged, } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectDifference.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectDifference.cs new file mode 100644 index 0000000000..138acdb312 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectDifference.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + [Flags] + internal enum ProjectDifference + { + None = 0, + ConfigurationChanged = 1, + WorkspaceProjectAdded = 2, + WorkspaceProjectRemoved = 4, + WorkspaceProjectChanged = 8, + DocumentAdded = 16, + DocumentRemoved = 32, + DocumentChanged = 64, + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectEngineTracker.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectEngineTracker.cs new file mode 100644 index 0000000000..6e54daed0b --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectEngineTracker.cs @@ -0,0 +1,66 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Host; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal class ProjectEngineTracker + { + private const ProjectDifference Mask = ProjectDifference.ConfigurationChanged; + + private readonly object _lock = new object(); + + private readonly HostWorkspaceServices _services; + private RazorProjectEngine _projectEngine; + + public ProjectEngineTracker(ProjectState state) + { + if (state == null) + { + throw new ArgumentNullException(nameof(state)); + } + + _services = state.Services; + } + + public ProjectEngineTracker ForkFor(ProjectState state, ProjectDifference difference) + { + if (state == null) + { + throw new ArgumentNullException(nameof(state)); + } + + if ((difference & Mask) != 0) + { + return null; + } + + return this; + } + + public RazorProjectEngine GetProjectEngine(ProjectSnapshot snapshot) + { + if (snapshot == null) + { + throw new ArgumentNullException(nameof(snapshot)); + } + + if (_projectEngine == null) + { + lock (_lock) + { + if (_projectEngine == null) + { + var factory = _services.GetRequiredService(); + _projectEngine = factory.Create(snapshot); + } + } + } + + return _projectEngine; + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectExtensibilityAssembly.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectExtensibilityAssembly.cs deleted file mode 100644 index 43839f3664..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectExtensibilityAssembly.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - internal sealed class ProjectExtensibilityAssembly : IEquatable - { - public ProjectExtensibilityAssembly(AssemblyIdentity identity) - { - if (identity == null) - { - throw new ArgumentNullException(nameof(identity)); - } - - Identity = identity; - } - - public AssemblyIdentity Identity { get; } - - public bool Equals(ProjectExtensibilityAssembly other) - { - if (other == null) - { - return false; - } - - return Identity.Equals(other.Identity); - } - - public override int GetHashCode() - { - return Identity.GetHashCode(); - } - - public override bool Equals(object obj) - { - return base.Equals(obj as ProjectExtensibilityAssembly); - } - } -} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs index 538b3cb9fa..418d117ff2 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs @@ -1,8 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem @@ -11,16 +11,22 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { public abstract RazorConfiguration Configuration { get; } + public abstract IEnumerable DocumentFilePaths { get; } + public abstract string FilePath { get; } public abstract bool IsInitialized { get; } - public abstract IReadOnlyList TagHelpers { get; } - public abstract VersionStamp Version { get; } public abstract Project WorkspaceProject { get; } - public abstract HostProject HostProject { get; } + public abstract RazorProjectEngine GetProjectEngine(); + + public abstract DocumentSnapshot GetDocument(string filePath); + + public abstract Task> GetTagHelpersAsync(); + + public abstract bool TryGetTagHelpers(out IReadOnlyList result); } } \ No newline at end of file diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs index b9e39e00b1..40dfec08a9 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs @@ -12,5 +12,11 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem public abstract event EventHandler Changed; public abstract IReadOnlyList Projects { get; } + + public abstract bool IsDocumentOpen(string documentFilePath); + + public abstract ProjectSnapshot GetLoadedProject(string filePath); + + public abstract ProjectSnapshot GetOrCreateProject(string filePath); } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs index 026b27956f..5545bbb3a8 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { @@ -9,7 +10,18 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { public abstract Workspace Workspace { get; } - public abstract void ProjectUpdated(ProjectSnapshotUpdateContext update); + public abstract void DocumentAdded(HostProject hostProject, HostDocument hostDocument, TextLoader textLoader); + + // Yeah this is kinda ugly. + public abstract void DocumentOpened(string projectFilePath, string documentFilePath, SourceText sourceText); + + public abstract void DocumentClosed(string projectFilePath, string documentFilePath, TextLoader textLoader); + + public abstract void DocumentChanged(string projectFilePath, string documentFilePath, TextLoader textLoader); + + public abstract void DocumentChanged(string projectFilePath, string documentFilePath, SourceText sourceText); + + public abstract void DocumentRemoved(HostProject hostProject, HostDocument hostDocument); public abstract void HostProjectAdded(HostProject hostProject); @@ -17,8 +29,6 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem public abstract void HostProjectRemoved(HostProject hostProject); - public abstract void HostProjectBuildComplete(HostProject hostProject); - public abstract void WorkspaceProjectAdded(Project workspaceProject); public abstract void WorkspaceProjectChanged(Project workspaceProject); diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerExtensions.cs deleted file mode 100644 index d6299717ca..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - internal static class ProjectSnapshotManagerExtensions - { - public static ProjectSnapshot GetProjectWithFilePath(this ProjectSnapshotManager snapshotManager, string filePath) - { - var projects = snapshotManager.Projects; - for (var i = 0; i< projects.Count; i++) - { - var project = projects[i]; - if (FilePathComparer.Instance.Equals(filePath, project.FilePath)) - { - return project; - } - } - - return null; - } - } -} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs deleted file mode 100644 index cddb3b08c1..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Razor.Language; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - internal class ProjectSnapshotUpdateContext - { - public ProjectSnapshotUpdateContext(string filePath, HostProject hostProject, Project workspaceProject, VersionStamp version) - { - if (filePath == null) - { - throw new ArgumentNullException(nameof(filePath)); - } - - if (hostProject == null) - { - throw new ArgumentNullException(nameof(hostProject)); - } - - if (workspaceProject == null) - { - throw new ArgumentNullException(nameof(workspaceProject)); - } - - FilePath = filePath; - HostProject = hostProject; - WorkspaceProject = workspaceProject; - Version = version; - } - - public string FilePath { get; } - - public HostProject HostProject { get; } - - public Project WorkspaceProject { get; } - - public IReadOnlyList TagHelpers { get; set; } - - public VersionStamp Version { get; } - } -} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotWorker.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotWorker.cs deleted file mode 100644 index 5c6288ee22..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotWorker.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Threading; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - internal abstract class ProjectSnapshotWorker : ILanguageService - { - public abstract Task ProcessUpdateAsync(ProjectSnapshotUpdateContext update, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotWorkerQueue.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotWorkerQueue.cs deleted file mode 100644 index 69c0062f05..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotWorkerQueue.cs +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - internal class ProjectSnapshotWorkerQueue - { - private readonly ForegroundDispatcher _foregroundDispatcher; - private readonly DefaultProjectSnapshotManager _projectManager; - private readonly ProjectSnapshotWorker _projectWorker; - - private readonly Dictionary _projects; - private Timer _timer; - - public ProjectSnapshotWorkerQueue(ForegroundDispatcher foregroundDispatcher, DefaultProjectSnapshotManager projectManager, ProjectSnapshotWorker projectWorker) - { - if (foregroundDispatcher == null) - { - throw new ArgumentNullException(nameof(foregroundDispatcher)); - } - - if (projectManager == null) - { - throw new ArgumentNullException(nameof(projectManager)); - } - - if (projectWorker == null) - { - throw new ArgumentNullException(nameof(projectWorker)); - } - - _foregroundDispatcher = foregroundDispatcher; - _projectManager = projectManager; - _projectWorker = projectWorker; - - _projects = new Dictionary(FilePathComparer.Instance); - } - - public bool HasPendingNotifications - { - get - { - lock (_projects) - { - return _projects.Count > 0; - } - } - } - - // Used in unit tests to control the timer delay. - public TimeSpan Delay { get; set; } = TimeSpan.FromSeconds(2); - - public bool IsScheduledOrRunning => _timer != null; - - // Used in unit tests to ensure we can control when background work starts. - public ManualResetEventSlim BlockBackgroundWorkStart { get; set; } - - // Used in unit tests to ensure we can know when background work finishes. - public ManualResetEventSlim NotifyBackgroundWorkFinish { get; set; } - - // Used in unit tests to ensure we can be notified when all completes. - public ManualResetEventSlim NotifyForegroundWorkFinish { get; set; } - - private void OnStartingBackgroundWork() - { - if (BlockBackgroundWorkStart != null) - { - BlockBackgroundWorkStart.Wait(); - BlockBackgroundWorkStart.Reset(); - } - } - - private void OnFinishingBackgroundWork() - { - if (NotifyBackgroundWorkFinish != null) - { - NotifyBackgroundWorkFinish.Set(); - } - } - - private void OnFinishingForegroundWork() - { - if (NotifyForegroundWorkFinish != null) - { - NotifyForegroundWorkFinish.Set(); - } - } - - public void Enqueue(ProjectSnapshotUpdateContext context) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - _foregroundDispatcher.AssertForegroundThread(); - - lock (_projects) - { - // We only want to store the last 'seen' version of any given project. That way when we pick one to process - // it's always the best version to use. - _projects[context.FilePath] = context; - - StartWorker(); - } - } - - protected virtual void StartWorker() - { - // Access to the timer is protected by the lock in Enqueue and in Timer_Tick - if (_timer == null) - { - // Timer will fire after a fixed delay, but only once. - _timer = new Timer(Timer_Tick, null, Delay, Timeout.InfiniteTimeSpan); - } - } - - private async void Timer_Tick(object state) // Yeah I know. - { - try - { - _foregroundDispatcher.AssertBackgroundThread(); - - // Timer is stopped. - _timer.Change(Timeout.Infinite, Timeout.Infinite); - - OnStartingBackgroundWork(); - - ProjectSnapshotUpdateContext[] work; - lock (_projects) - { - work = _projects.Values.ToArray(); - _projects.Clear(); - } - - var updates = new(ProjectSnapshotUpdateContext context, Exception exception)[work.Length]; - for (var i = 0; i < work.Length; i++) - { - try - { - updates[i] = (work[i], null); - await _projectWorker.ProcessUpdateAsync(updates[i].context); - } - catch (Exception projectException) - { - updates[i] = (updates[i].context, projectException); - } - } - - OnFinishingBackgroundWork(); - - // We need to get back to the UI thread to update the project system. - await Task.Factory.StartNew(PersistUpdates, updates, CancellationToken.None, TaskCreationOptions.None, _foregroundDispatcher.ForegroundScheduler); - - lock (_projects) - { - // Resetting the timer allows another batch of work to start. - _timer.Dispose(); - _timer = null; - - // If more work came in while we were running start the worker again. - if (_projects.Count > 0) - { - StartWorker(); - } - } - - OnFinishingForegroundWork(); - } - catch (Exception ex) - { - // This is something totally unexpected, let's just send it over to the workspace. - await Task.Factory.StartNew(() => _projectManager.ReportError(ex), CancellationToken.None, TaskCreationOptions.None, _foregroundDispatcher.ForegroundScheduler); - } - } - - private void PersistUpdates(object state) - { - _foregroundDispatcher.AssertForegroundThread(); - - var updates = ((ProjectSnapshotUpdateContext context, Exception exception)[])state; - - for (var i = 0; i < updates.Length; i++) - { - var update = updates[i]; - if (update.exception == null) - { - _projectManager.ProjectUpdated(update.context); - } - else - { - _projectManager.ReportError(update.exception, update.context?.WorkspaceProject); - } - } - } - } -} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs new file mode 100644 index 0000000000..6670ba55a2 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs @@ -0,0 +1,304 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + // Internal tracker for DefaultProjectSnapshot + internal class ProjectState + { + private static readonly IReadOnlyDictionary EmptyDocuments = new Dictionary(); + + private readonly object _lock; + + private ProjectEngineTracker _projectEngine; + private ProjectTagHelperTracker _tagHelpers; + + public static ProjectState Create(HostWorkspaceServices services, HostProject hostProject, Project workspaceProject = null) + { + if (services == null) + { + throw new ArgumentNullException(nameof(services)); + } + + if (hostProject == null) + { + throw new ArgumentNullException(nameof(hostProject)); + } + + return new ProjectState(services, hostProject, workspaceProject); + } + + private ProjectState( + HostWorkspaceServices services, + HostProject hostProject, + Project workspaceProject) + { + Services = services; + HostProject = hostProject; + WorkspaceProject = workspaceProject; + Documents = EmptyDocuments; + Version = VersionStamp.Create(); + + _lock = new object(); + } + + private ProjectState( + ProjectState older, + ProjectDifference difference, + HostProject hostProject, + Project workspaceProject, + IReadOnlyDictionary documents) + { + if (older == null) + { + throw new ArgumentNullException(nameof(older)); + } + + if (hostProject == null) + { + throw new ArgumentNullException(nameof(hostProject)); + } + + if (documents == null) + { + throw new ArgumentNullException(nameof(documents)); + } + + Services = older.Services; + Version = older.Version.GetNewerVersion(); + + HostProject = hostProject; + WorkspaceProject = workspaceProject; + Documents = documents; + + _lock = new object(); + + _projectEngine = older._projectEngine?.ForkFor(this, difference); + _tagHelpers = older._tagHelpers?.ForkFor(this, difference); + } + + // Internal set for testing. + public IReadOnlyDictionary Documents { get; internal set; } + + public HostProject HostProject { get; } + + public HostWorkspaceServices Services { get; } + + public Project WorkspaceProject { get; } + + public VersionStamp Version { get; } + + // Computed State + public ProjectEngineTracker ProjectEngine + { + get + { + if (_projectEngine == null) + { + lock (_lock) + { + if (_projectEngine == null) + { + _projectEngine = new ProjectEngineTracker(this); + } + } + } + + return _projectEngine; + } + } + + // Computed State + public ProjectTagHelperTracker TagHelpers + { + get + { + if (_tagHelpers == null) + { + lock (_lock) + { + if (_tagHelpers == null) + { + _tagHelpers = new ProjectTagHelperTracker(this); + } + } + } + + return _tagHelpers; + } + } + + public ProjectState WithAddedHostDocument(HostDocument hostDocument, Func> loader) + { + if (hostDocument == null) + { + throw new ArgumentNullException(nameof(hostDocument)); + } + + if (loader == null) + { + throw new ArgumentNullException(nameof(loader)); + } + + // Ignore attempts to 'add' a document with different data, we only + // care about one, so it might as well be the one we have. + if (Documents.ContainsKey(hostDocument.FilePath)) + { + return this; + } + + var documents = new Dictionary(FilePathComparer.Instance); + foreach (var kvp in Documents) + { + documents.Add(kvp.Key, kvp.Value); + } + + documents.Add(hostDocument.FilePath, DocumentState.Create(Services, hostDocument, loader)); + + var difference = ProjectDifference.DocumentAdded; + var state = new ProjectState(this, difference, HostProject, WorkspaceProject, documents); + return state; + } + + public ProjectState WithRemovedHostDocument(HostDocument hostDocument) + { + if (hostDocument == null) + { + throw new ArgumentNullException(nameof(hostDocument)); + } + + if (!Documents.ContainsKey(hostDocument.FilePath)) + { + return this; + } + + var documents = new Dictionary(FilePathComparer.Instance); + foreach (var kvp in Documents) + { + documents.Add(kvp.Key, kvp.Value); + } + + documents.Remove(hostDocument.FilePath); + + var difference = ProjectDifference.DocumentRemoved; + var state = new ProjectState(this, difference, HostProject, WorkspaceProject, documents); + return state; + } + + public ProjectState WithChangedHostDocument(HostDocument hostDocument, SourceText sourceText, VersionStamp version) + { + if (hostDocument == null) + { + throw new ArgumentNullException(nameof(hostDocument)); + } + + if (!Documents.ContainsKey(hostDocument.FilePath)) + { + return this; + } + + var documents = new Dictionary(FilePathComparer.Instance); + foreach (var kvp in Documents) + { + documents.Add(kvp.Key, kvp.Value); + } + + if (documents.TryGetValue(hostDocument.FilePath, out var document)) + { + documents[hostDocument.FilePath] = document.WithText(sourceText, version); + } + + var state = new ProjectState(this, ProjectDifference.DocumentChanged, HostProject, WorkspaceProject, documents); + return state; + } + + public ProjectState WithChangedHostDocument(HostDocument hostDocument, Func> loader) + { + if (hostDocument == null) + { + throw new ArgumentNullException(nameof(hostDocument)); + } + + if (!Documents.ContainsKey(hostDocument.FilePath)) + { + return this; + } + + var documents = new Dictionary(FilePathComparer.Instance); + foreach (var kvp in Documents) + { + documents.Add(kvp.Key, kvp.Value); + } + + if (documents.TryGetValue(hostDocument.FilePath, out var document)) + { + documents[hostDocument.FilePath] = document.WithTextLoader(loader); + } + + var state = new ProjectState(this, ProjectDifference.DocumentChanged, HostProject, WorkspaceProject, documents); + return state; + } + + public ProjectState WithHostProject(HostProject hostProject) + { + if (hostProject == null) + { + throw new ArgumentNullException(nameof(hostProject)); + } + + if (HostProject.Configuration.Equals(hostProject.Configuration)) + { + return this; + } + + var difference = ProjectDifference.ConfigurationChanged; + var documents = new Dictionary(FilePathComparer.Instance); + foreach (var kvp in Documents) + { + documents.Add(kvp.Key, kvp.Value.WithConfigurationChange()); + } + + var state = new ProjectState(this, difference, hostProject, WorkspaceProject, documents); + return state; + } + + public ProjectState WithWorkspaceProject(Project workspaceProject) + { + var difference = ProjectDifference.None; + if (WorkspaceProject == null && workspaceProject != null) + { + difference |= ProjectDifference.WorkspaceProjectAdded; + } + else if (WorkspaceProject != null && workspaceProject == null) + { + difference |= ProjectDifference.WorkspaceProjectRemoved; + } + else + { + // We always update the snapshot right now when the project changes. This is how + // we deal with changes to the content of C# sources. + difference |= ProjectDifference.WorkspaceProjectChanged; + } + + if (difference == ProjectDifference.None) + { + return this; + } + + var documents = new Dictionary(FilePathComparer.Instance); + foreach (var kvp in Documents) + { + documents.Add(kvp.Key, kvp.Value.WithWorkspaceProjectChange()); + } + + var state = new ProjectState(this, difference, HostProject, workspaceProject, documents); + return state; + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectTagHelperTracker.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectTagHelperTracker.cs new file mode 100644 index 0000000000..0c3be4ddec --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectTagHelperTracker.cs @@ -0,0 +1,79 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.Host; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + internal class ProjectTagHelperTracker + { + private const ProjectDifference Mask = + ProjectDifference.ConfigurationChanged | + ProjectDifference.WorkspaceProjectAdded | + ProjectDifference.WorkspaceProjectChanged | + ProjectDifference.WorkspaceProjectRemoved; + + private readonly object _lock = new object(); + private readonly HostWorkspaceServices _services; + + private Task> _task; + + public ProjectTagHelperTracker(ProjectState state) + { + if (state == null) + { + throw new ArgumentNullException(nameof(state)); + } + + _services = state.Services; + } + + public bool IsResultAvailable => _task?.IsCompleted == true; + + public ProjectTagHelperTracker ForkFor(ProjectState state, ProjectDifference difference) + { + if (state == null) + { + throw new ArgumentNullException(nameof(state)); + } + + if ((difference & Mask) != 0) + { + return null; + } + + return this; + } + + public Task> GetTagHelperInitializationTask(ProjectSnapshot snapshot) + { + if (snapshot == null) + { + throw new ArgumentNullException(nameof(snapshot)); + } + + if (_task == null) + { + lock (_lock) + { + if (_task == null) + { + _task = GetTagHelperInitializationTaskCore(snapshot); + } + } + } + + return _task; + } + + private async Task> GetTagHelperInitializationTaskCore(ProjectSnapshot snapshot) + { + var resolver = _services.GetLanguageServices(RazorLanguage.Name).GetRequiredService(); + return (await resolver.GetTagHelpersAsync(snapshot)).Descriptors; + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/WorkspaceProjectSnapshotChangeTrigger.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/WorkspaceProjectSnapshotChangeTrigger.cs index fb2deeec32..f5bbee95de 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/WorkspaceProjectSnapshotChangeTrigger.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/WorkspaceProjectSnapshotChangeTrigger.cs @@ -1,8 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.Composition; using System.Diagnostics; +using System.Threading.Tasks; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { @@ -11,11 +13,21 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { private ProjectSnapshotManagerBase _projectManager; + public int ProjectChangeDelay { get; set; } = 3 * 1000; + + // We throttle updates to projects to prevent doing too much work while the projects + // are being initialized. + // + // Internal for testing + internal Dictionary _deferredUpdates; + public override void Initialize(ProjectSnapshotManagerBase projectManager) { _projectManager = projectManager; _projectManager.Workspace.WorkspaceChanged += Workspace_WorkspaceChanged; + _deferredUpdates = new Dictionary(); + InitializeSolution(_projectManager.Workspace.CurrentSolution); } @@ -47,10 +59,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem case WorkspaceChangeKind.ProjectChanged: case WorkspaceChangeKind.ProjectReloaded: { - project = e.NewSolution.GetProject(e.ProjectId); - Debug.Assert(project != null); - - _projectManager.WorkspaceProjectChanged(project); + EnqueueUpdate(e.ProjectId); break; } @@ -81,5 +90,27 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem break; } } + + private void EnqueueUpdate(ProjectId projectId) + { + // A race is not possible here because we use the main thread to synchronize the updates + // by capturing the sync context. + if (!_deferredUpdates.TryGetValue(projectId, out var update) || update.IsCompleted) + { + _deferredUpdates[projectId] = UpdateAfterDelay(projectId); + } + } + + private async Task UpdateAfterDelay(ProjectId projectId) + { + await Task.Delay(ProjectChangeDelay); + + var solution = _projectManager.Workspace.CurrentSolution; + var workspaceProject = solution.GetProject(projectId); + if (workspaceProject != null) + { + _projectManager.WorkspaceProjectChanged(workspaceProject); + } + } } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs index e70ec9920f..fefb5cd1de 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Performance, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.RazorAddin, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs deleted file mode 100644 index 4defb21947..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Razor.ProjectSystem; - -namespace Microsoft.CodeAnalysis.Razor -{ - internal abstract class RazorProjectEngineFactoryService : ILanguageService - { - public abstract IProjectEngineFactory FindFactory(ProjectSnapshot project); - - public abstract IProjectEngineFactory FindSerializableFactory(ProjectSnapshot project); - - public abstract RazorProjectEngine Create(ProjectSnapshot project, Action configure); - - public abstract RazorProjectEngine Create(ProjectSnapshot project, RazorProjectFileSystem fileSystem, Action configure); - - public abstract RazorProjectEngine Create(string directoryPath, Action configure); - } -} \ No newline at end of file diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SourceTextExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SourceTextExtensions.cs new file mode 100644 index 0000000000..efc74344d5 --- /dev/null +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SourceTextExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.CodeAnalysis.Text +{ + internal static class SourceTextExtensions + { + public static RazorSourceDocument GetRazorSourceDocument(this SourceText sourceText, string fileName) + { + if (sourceText == null) + { + throw new ArgumentNullException(nameof(sourceText)); + } + + var content = sourceText.ToString(); + + return RazorSourceDocument.Create(content, fileName); + } + } +} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs index 847e22a674..4316f6ee3b 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs @@ -45,7 +45,10 @@ namespace Microsoft.CodeAnalysis.Razor context.IncludeDocumentation = true; var compilation = await project.WorkspaceProject.GetCompilationAsync().ConfigureAwait(false); - context.SetCompilation(compilation); + if (CompilationTagHelperFeature.IsValidCompilation(compilation)) + { + context.SetCompilation(compilation); + } for (var i = 0; i < providers.Length; i++) { diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor/CompilationTagHelperFeature.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor/CompilationTagHelperFeature.cs index 6aa81ff506..2041cd9eb5 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor/CompilationTagHelperFeature.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor/CompilationTagHelperFeature.cs @@ -19,7 +19,10 @@ namespace Microsoft.CodeAnalysis.Razor var context = TagHelperDescriptorProviderContext.Create(results); var compilation = CSharpCompilation.Create("__TagHelpers", references: _referenceFeature.References); - context.SetCompilation(compilation); + if (IsValidCompilation(compilation)) + { + context.SetCompilation(compilation); + } for (var i = 0; i < _providers.Length; i++) { @@ -34,5 +37,14 @@ namespace Microsoft.CodeAnalysis.Razor _referenceFeature = Engine.Features.OfType().FirstOrDefault(); _providers = Engine.Features.OfType().OrderBy(f => f.Order).ToArray(); } + + internal static bool IsValidCompilation(Compilation compilation) + { + var @string = compilation.GetSpecialType(SpecialType.System_String); + + // Do some minimal tests to verify the compilation is valid. If symbols for System.String + // is missing or errored, the compilation may be missing references. + return @string != null && @string.TypeKind != TypeKind.Error; + } } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor/DefaultTagHelperDescriptorProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor/DefaultTagHelperDescriptorProvider.cs index b0d07db459..ebb649da5b 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor/DefaultTagHelperDescriptorProvider.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor/DefaultTagHelperDescriptorProvider.cs @@ -31,8 +31,15 @@ namespace Microsoft.CodeAnalysis.Razor return; } + var iTagHelper = compilation.GetTypeByMetadataName(TagHelperTypes.ITagHelper); + if (iTagHelper == null || iTagHelper.TypeKind == TypeKind.Error) + { + // Could not find attributes we care about in the compilation. Nothing to do. + return; + } + var types = new List(); - var visitor = TagHelperTypeVisitor.Create(compilation, types); + var visitor = new TagHelperTypeVisitor(iTagHelper, types); // We always visit the global namespace. visitor.Visit(compilation.Assembly.GlobalNamespace); diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor/Properties/AssemblyInfo.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor/Properties/AssemblyInfo.cs index a43f1d9aa4..0de18b91dc 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor/Properties/AssemblyInfo.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor/Properties/AssemblyInfo.cs @@ -3,11 +3,14 @@ using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor/RazorDiagnosticFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor/RazorDiagnosticFactory.cs index 12fa708189..55705b5eac 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor/RazorDiagnosticFactory.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor/RazorDiagnosticFactory.cs @@ -9,40 +9,30 @@ namespace Microsoft.CodeAnalysis.Razor { private const string DiagnosticPrefix = "RZ"; - /* - * Razor.Language starts at 0, 1000, 2000, 3000. Therefore, we should offset by 500 to ensure we can easily - * maintain this list of diagnostic descriptors in conjunction with the one in Razor.Language. - */ - + // Razor.Language starts at 0, 1000, 2000, 3000. Therefore, we should offset by 500 to ensure we can easily + // maintain this list of diagnostic descriptors in conjunction with the one in Razor.Language. + #region General Errors - /* - * General Errors ID Offset = 500 - */ + // General Errors ID Offset = 500 #endregion #region Language Errors - /* - * Language Errors ID Offset = 1500 - */ + // Language Errors ID Offset = 1500 #endregion #region Semantic Errors - /* - * Semantic Errors ID Offset = 2500 - */ + // Semantic Errors ID Offset = 2500 #endregion #region TagHelper Errors - /* - * TagHelper Errors ID Offset = 3500 - */ + // TagHelper Errors ID Offset = 3500 internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidAttributeNameNullOrEmpty = new RazorDiagnosticDescriptor( diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor/TagHelperTypeVisitor.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor/TagHelperTypeVisitor.cs index 625e8284c1..3387cfd1e8 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor/TagHelperTypeVisitor.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor/TagHelperTypeVisitor.cs @@ -11,12 +11,6 @@ namespace Microsoft.CodeAnalysis.Razor private INamedTypeSymbol _interface; private List _results; - public static TagHelperTypeVisitor Create(Compilation compilation, List results) - { - var @interface = compilation.GetTypeByMetadataName(TagHelperTypes.ITagHelper); - return new TagHelperTypeVisitor(@interface, results); - } - public TagHelperTypeVisitor(INamedTypeSymbol @interface, List results) { _interface = @interface; @@ -47,6 +41,7 @@ namespace Microsoft.CodeAnalysis.Razor } return + symbol.TypeKind != TypeKind.Error && symbol.DeclaredAccessibility == Accessibility.Public && !symbol.IsAbstract && !symbol.IsGenericType && diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GeneratedDocument.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GeneratedDocument.cs deleted file mode 100644 index 8299fce595..0000000000 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/GeneratedDocument.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Microsoft.CodeAnalysis.Remote.Razor -{ - internal class GeneratedDocument - { - public string Text { get; set; } - } -} diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorLanguageService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorLanguageService.cs index ecde04c752..16ababe0db 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorLanguageService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorLanguageService.cs @@ -2,13 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; @@ -27,42 +23,5 @@ namespace Microsoft.CodeAnalysis.Remote.Razor return await RazorServices.TagHelperResolver.GetTagHelpersAsync(project, factoryTypeName, cancellationToken); } - - public Task> GetDirectivesAsync(Guid projectIdBytes, string projectDebugName, CancellationToken cancellationToken = default(CancellationToken)) - { - var projectId = ProjectId.CreateFromSerialized(projectIdBytes, projectDebugName); - - var projectEngine = RazorProjectEngine.Create(); - var directives = projectEngine.EngineFeatures.OfType().FirstOrDefault()?.Directives; - return Task.FromResult(directives ?? Enumerable.Empty()); - } - - public Task GenerateDocumentAsync(Guid projectIdBytes, string projectDebugName, string filePath, string text, CancellationToken cancellationToken = default(CancellationToken)) - { - var projectId = ProjectId.CreateFromSerialized(projectIdBytes, projectDebugName); - - var projectEngine = RazorProjectEngine.Create(); - - RazorSourceDocument source; - using (var stream = new MemoryStream()) - { - var bytes = Encoding.UTF8.GetBytes(text); - stream.Write(bytes, 0, bytes.Length); - - stream.Seek(0L, SeekOrigin.Begin); - source = RazorSourceDocument.ReadFrom(stream, filePath, Encoding.UTF8); - } - - var code = RazorCodeDocument.Create(source); - projectEngine.Engine.Process(code); - - var csharp = code.GetCSharpDocument(); - if (csharp == null) - { - throw new InvalidOperationException(); - } - - return Task.FromResult(new GeneratedDocument() { Text = csharp.GeneratedCode, }); - } } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs index 8fdbdd81da..289d75cc0f 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs @@ -48,9 +48,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor { FilePath = filePath; Configuration = configuration; - HostProject = new HostProject(filePath, configuration); WorkspaceProject = workspaceProject; - TagHelpers = Array.Empty(); IsInitialized = true; Version = VersionStamp.Default; @@ -58,6 +56,8 @@ namespace Microsoft.CodeAnalysis.Remote.Razor public override RazorConfiguration Configuration { get; } + public override IEnumerable DocumentFilePaths => Array.Empty(); + public override string FilePath { get; } public override bool IsInitialized { get; } @@ -66,9 +66,30 @@ namespace Microsoft.CodeAnalysis.Remote.Razor public override Project WorkspaceProject { get; } - public override HostProject HostProject { get; } + public override DocumentSnapshot GetDocument(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } - public override IReadOnlyList TagHelpers { get; } + return null; + } + + public override RazorProjectEngine GetProjectEngine() + { + throw new NotImplementedException(); + } + + public override Task> GetTagHelpersAsync() + { + throw new NotImplementedException(); + } + + public override bool TryGetTagHelpers(out IReadOnlyList result) + { + throw new NotImplementedException(); + } } } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/DotnetToolTask.cs b/src/Razor/src/Microsoft.NET.Sdk.Razor/DotnetToolTask.cs similarity index 100% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/DotnetToolTask.cs rename to src/Razor/src/Microsoft.NET.Sdk.Razor/DotnetToolTask.cs diff --git a/src/Razor/src/Microsoft.NET.Sdk.Razor/Microsoft.NET.Sdk.Razor.csproj b/src/Razor/src/Microsoft.NET.Sdk.Razor/Microsoft.NET.Sdk.Razor.csproj index 95bb7fec04..a835c5d06a 100644 --- a/src/Razor/src/Microsoft.NET.Sdk.Razor/Microsoft.NET.Sdk.Razor.csproj +++ b/src/Razor/src/Microsoft.NET.Sdk.Razor/Microsoft.NET.Sdk.Razor.csproj @@ -1,19 +1,44 @@ Razor is a markup syntax for adding server-side logic to web pages. This package contains MSBuild support for Razor. - netstandard2.0 + netstandard2.0;net46 - + Microsoft.NET.Sdk.Razor.Tasks false - false - false + - + + + + + + + + + + + + + + + + Shared\ServerProtocol\%(FileName) + + + Shared\PipeName.cs + + + Shared\MutexName.cs + + + Shared\Client.cs + + diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs b/src/Razor/src/Microsoft.NET.Sdk.Razor/RazorGenerate.cs similarity index 100% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs rename to src/Razor/src/Microsoft.NET.Sdk.Razor/RazorGenerate.cs diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/RazorTagHelper.cs b/src/Razor/src/Microsoft.NET.Sdk.Razor/RazorTagHelper.cs similarity index 100% rename from src/Razor/src/Microsoft.AspNetCore.Razor.Tasks/RazorTagHelper.cs rename to src/Razor/src/Microsoft.NET.Sdk.Razor/RazorTagHelper.cs diff --git a/src/Razor/src/Microsoft.NET.Sdk.Razor/baseline.netcore.json b/src/Razor/src/Microsoft.NET.Sdk.Razor/baseline.netcore.json new file mode 100644 index 0000000000..0443192d45 --- /dev/null +++ b/src/Razor/src/Microsoft.NET.Sdk.Razor/baseline.netcore.json @@ -0,0 +1,762 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Razor.Tasks, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.Build.Utilities.ToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.Build.Framework.ITask", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Cancel", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.Build.Framework.ICancelableTask", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Debug", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Debug", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DebugTool", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DebugTool", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ToolAssembly", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ToolAssembly", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UseServer", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UseServer", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForceServer", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForceServer", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SuppressCurrentUserOnlyPipeOptions", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SuppressCurrentUserOnlyPipeOptions", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PipeName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PipeName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ToolName", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StandardOutputLoggingImportance", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.MessageImportance", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StandardErrorLoggingImportance", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.MessageImportance", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateFullPathToTool", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateCommandLineCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetResponseFileSwitch", + "Parameters": [ + { + "Name": "responseFilePath", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteTool", + "Parameters": [ + { + "Name": "pathToTool", + "Type": "System.String" + }, + { + "Name": "responseFileCommands", + "Type": "System.String" + }, + { + "Name": "commandLineCommands", + "Type": "System.String" + } + ], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "LogToolCommand", + "Parameters": [ + { + "Name": "message", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TryExecuteOnServer", + "Parameters": [ + { + "Name": "pathToTool", + "Type": "System.String" + }, + { + "Name": "responseFileCommands", + "Type": "System.String" + }, + { + "Name": "commandLineCommands", + "Type": "System.String" + }, + { + "Name": "result", + "Type": "System.Int32", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleTaskExecutionErrors", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.RazorGenerate", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Version", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Version", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Extensions", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Extensions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Sources", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Sources", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProjectRoot", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProjectRoot", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelperManifest", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelperManifest", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateParameters", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.RazorTagHelper", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Version", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Version", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Extensions", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Extensions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Assemblies", + "Parameters": [], + "ReturnType": "System.String[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Assemblies", + "Parameters": [ + { + "Name": "value", + "Type": "System.String[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelperManifest", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelperManifest", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProjectRoot", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProjectRoot", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipTaskExecution", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateParameters", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tools.RequestArgument+ArgumentId", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "CurrentDirectory", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294433" + }, + { + "Kind": "Field", + "Name": "CommandLineArgument", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294434" + }, + { + "Kind": "Field", + "Name": "KeepAlive", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294435" + }, + { + "Kind": "Field", + "Name": "Shutdown", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294436" + }, + { + "Kind": "Field", + "Name": "TempDirectory", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294437" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tools.ServerResponse+ResponseType", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "MismatchedVersion", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "Completed", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + }, + { + "Kind": "Field", + "Name": "Shutdown", + "Parameters": [], + "GenericParameter": [], + "Literal": "2" + }, + { + "Kind": "Field", + "Name": "Rejected", + "Parameters": [], + "GenericParameter": [], + "Literal": "3" + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Razor/src/Microsoft.NET.Sdk.Razor/baseline.netframework.json b/src/Razor/src/Microsoft.NET.Sdk.Razor/baseline.netframework.json new file mode 100644 index 0000000000..4cec036ca8 --- /dev/null +++ b/src/Razor/src/Microsoft.NET.Sdk.Razor/baseline.netframework.json @@ -0,0 +1,762 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Razor.Tasks, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.Build.Utilities.ToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Debug", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Debug", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DebugTool", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DebugTool", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ToolAssembly", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ToolAssembly", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UseServer", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UseServer", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForceServer", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForceServer", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SuppressCurrentUserOnlyPipeOptions", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SuppressCurrentUserOnlyPipeOptions", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PipeName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PipeName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ToolName", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StandardOutputLoggingImportance", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.MessageImportance", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StandardErrorLoggingImportance", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.MessageImportance", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateFullPathToTool", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateCommandLineCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetResponseFileSwitch", + "Parameters": [ + { + "Name": "responseFilePath", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.Build.Framework.ITask", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteTool", + "Parameters": [ + { + "Name": "pathToTool", + "Type": "System.String" + }, + { + "Name": "responseFileCommands", + "Type": "System.String" + }, + { + "Name": "commandLineCommands", + "Type": "System.String" + } + ], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "LogToolCommand", + "Parameters": [ + { + "Name": "message", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Cancel", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.Build.Framework.ICancelableTask", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TryExecuteOnServer", + "Parameters": [ + { + "Name": "pathToTool", + "Type": "System.String" + }, + { + "Name": "responseFileCommands", + "Type": "System.String" + }, + { + "Name": "commandLineCommands", + "Type": "System.String" + }, + { + "Name": "result", + "Type": "System.Int32", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleTaskExecutionErrors", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.RazorGenerate", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Version", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Version", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Extensions", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Extensions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Sources", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Sources", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProjectRoot", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProjectRoot", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelperManifest", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelperManifest", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateParameters", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.RazorTagHelper", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Version", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Version", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Extensions", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Extensions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Assemblies", + "Parameters": [], + "ReturnType": "System.String[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Assemblies", + "Parameters": [ + { + "Name": "value", + "Type": "System.String[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelperManifest", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelperManifest", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProjectRoot", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProjectRoot", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipTaskExecution", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateParameters", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tools.RequestArgument+ArgumentId", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "CurrentDirectory", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294433" + }, + { + "Kind": "Field", + "Name": "CommandLineArgument", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294434" + }, + { + "Kind": "Field", + "Name": "KeepAlive", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294435" + }, + { + "Kind": "Field", + "Name": "Shutdown", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294436" + }, + { + "Kind": "Field", + "Name": "TempDirectory", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294437" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tools.ServerResponse+ResponseType", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "MismatchedVersion", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "Completed", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + }, + { + "Kind": "Field", + "Name": "Shutdown", + "Parameters": [], + "GenericParameter": [], + "Literal": "2" + }, + { + "Kind": "Field", + "Name": "Rejected", + "Parameters": [], + "GenericParameter": [], + "Literal": "3" + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets b/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets index 0b012be77c..64c5d8f61a 100644 --- a/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets +++ b/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets @@ -45,4 +45,7 @@ Copyright (c) .NET Foundation. All rights reserved. + + + diff --git a/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorGenerateWithTargetPath.xaml b/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorGenerateWithTargetPath.xaml new file mode 100644 index 0000000000..bab10bf249 --- /dev/null +++ b/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorGenerateWithTargetPath.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index d100b112cc..1790ba588d 100644 --- a/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -9,7 +9,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and Copyright (c) .NET Foundation. All rights reserved. *********************************************************************************************** --> - + + + $(MSBuildThisFileDirectory)..\..\tasks\ + <_RazorSdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">netstandard2.0 + <_RazorSdkTasksTFM Condition=" '$(_RazorSdkTasksTFM)' == ''">net46 + $(RazorSdkBuildTasksDirectoryRoot)$(_RazorSdkTasksTFM)\Microsoft.NET.Sdk.Razor.Tasks.dll + + + + + + false + + + - netcoreapp2.0 + netcoreapp2.2 true $(DefineConstants);PRESERVE_WORKING_DIRECTORY @@ -41,6 +41,12 @@ false + + false + + + false + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeNodeWriterTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeNodeWriterTest.cs index c602375095..79932bb30e 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeNodeWriterTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeNodeWriterTest.cs @@ -205,29 +205,6 @@ __o = i++; ignoreLineEndingDifferences: true); } - [Fact] - public void WriteCSharpCode_WhitespaceContent_DoesNothing() - { - // Arrange - var writer = new DesignTimeNodeWriter(); - var context = TestCodeRenderingContext.CreateDesignTime(); - - var node = new CSharpCodeIntermediateNode(); - IntermediateNodeBuilder.Create(node) - .Add(new IntermediateToken() - { - Kind = TokenKind.CSharp, - Content = " \t" - }); - - // Act - writer.WriteCSharpCode(context, node); - - // Assert - var csharp = context.CodeWriter.GenerateCode(); - Assert.Empty(csharp); - } - [Fact] public void WriteCSharpCode_WhitespaceContentWithSource_WritesContent() { @@ -252,7 +229,11 @@ __o = i++; // Assert var csharp = context.CodeWriter.GenerateCode(); Assert.Equal( -@" +@"#line 1 ""test.cshtml"" + + +#line default +#line hidden ", csharp, ignoreLineEndingDifferences: true); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeNodeWriterTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeNodeWriterTest.cs index 443acf376f..b2d99dbd4c 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeNodeWriterTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeNodeWriterTest.cs @@ -339,6 +339,91 @@ if (true) { } ignoreLineEndingDifferences: true); } + [Fact] + public void WriteHtmlLiteral_WithinMaxSize_WritesSingleLiteral() + { + // Arrange + var codeWriter = new CodeWriter(); + var writer = new RuntimeNodeWriter(); + var context = TestCodeRenderingContext.CreateRuntime(); + + // Act + writer.WriteHtmlLiteral(context, maxStringLiteralLength: 6, "Hello"); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"WriteLiteral(""Hello""); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteHtmlLiteral_GreaterThanMaxSize_WritesMultipleLiterals() + { + // Arrange + var codeWriter = new CodeWriter(); + var writer = new RuntimeNodeWriter(); + var context = TestCodeRenderingContext.CreateRuntime(); + + // Act + writer.WriteHtmlLiteral(context, maxStringLiteralLength: 6, "Hello World"); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"WriteLiteral(""Hello ""); +WriteLiteral(""World""); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteHtmlLiteral_GreaterThanMaxSize_SingleEmojisSplit() + { + // Arrange + var codeWriter = new CodeWriter(); + var writer = new RuntimeNodeWriter(); + var context = TestCodeRenderingContext.CreateRuntime(); + + // Act + writer.WriteHtmlLiteral(context, maxStringLiteralLength: 2, " 👦"); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"WriteLiteral("" ""); +WriteLiteral(""👦""); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteHtmlLiteral_GreaterThanMaxSize_SequencedZeroWithJoinedEmojisSplit() + { + // Arrange + var codeWriter = new CodeWriter(); + var writer = new RuntimeNodeWriter(); + var context = TestCodeRenderingContext.CreateRuntime(); + + // Act + writer.WriteHtmlLiteral(context, maxStringLiteralLength: 6, "👩‍👩‍👧‍👧👩‍👩‍👧‍👧"); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"WriteLiteral(""👩‍👩‍""); +WriteLiteral(""👧‍👧""); +WriteLiteral(""👩‍👩‍""); +WriteLiteral(""👧‍👧""); +", + csharp, + ignoreLineEndingDifferences: true); + } + [Fact] public void WriteHtmlContent_RendersContentCorrectly() { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs index c841c569a6..32eaa5f743 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs @@ -3,12 +3,12 @@ using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.AspNetCore.Razor.Language.Extensions; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Moq; using Xunit; using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; -using Moq; -using Microsoft.AspNetCore.Razor.Language.Extensions; namespace Microsoft.AspNetCore.Razor.Language { @@ -358,7 +358,7 @@ namespace Microsoft.AspNetCore.Razor.Language TestRazorSourceDocument.Create("@using System.Globalization"), TestRazorSourceDocument.Create("@using System.Text"), }; - + var codeDocument = TestRazorCodeDocument.Create(source, imports); // Act @@ -373,6 +373,29 @@ namespace Microsoft.AspNetCore.Razor.Language n => Html("

Hi!

", n)); } + [Fact] + public void Lower_WithImports_AllowsIdenticalNamespacesInPrimaryDocument() + { + // Arrange + var source = TestRazorSourceDocument.Create(@"@using System.Threading.Tasks +@using System.Threading.Tasks"); + var imports = new[] + { + TestRazorSourceDocument.Create("@using System.Threading.Tasks"), + }; + + var codeDocument = TestRazorCodeDocument.Create(source, imports); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Children( + documentNode, + n => Using("System.Threading.Tasks", n), + n => Using("System.Threading.Tasks", n)); + } + [Fact] public void Lower_WithMultipleImports_SingleLineFileScopedSinglyOccurring() { @@ -390,8 +413,8 @@ namespace Microsoft.AspNetCore.Razor.Language var documentNode = Lower(codeDocument, b => { b.AddDirective(DirectiveDescriptor.CreateDirective( - "test", - DirectiveKind.SingleLine, + "test", + DirectiveKind.SingleLine, builder => { builder.AddMemberToken(); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs index 38b5082b2e..d9c58137bb 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using System.Collections.Generic; using System.IO; using Moq; using Xunit; @@ -91,5 +93,147 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.NotNull(csharpDocument); Assert.Empty(csharpDocument.Diagnostics); } + + [Fact] + public void Process_WithImportsAndTagHelpers_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + var importItem = new TestRazorProjectItem("_import.cshtml"); + var expectedImports = new[] { RazorSourceDocument.ReadFrom(importItem) }; + var expectedTagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build(), + TagHelperDescriptorBuilder.Create("Test2TagHelper", "TestAssembly").Build(), + }; + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), expectedImports, expectedTagHelpers); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Same(expectedTagHelpers, tagHelpers); + Assert.Equal(expectedImports, codeDocument.Imports); + } + + [Fact] + public void Process_WithNullTagHelpers_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), Array.Empty(), tagHelpers: null); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Null(tagHelpers); + } + + [Fact] + public void Process_SetsNullTagHelpersOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Null(tagHelpers); + } + + [Fact] + public void Process_WithNullImports_SetsEmptyListOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), importSources: null, tagHelpers: null); + + // Assert + Assert.Empty(codeDocument.Imports); + } + + [Fact] + public void ProcessDesignTime_WithImportsAndTagHelpers_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + var importItem = new TestRazorProjectItem("_import.cshtml"); + var expectedImports = new[] { RazorSourceDocument.ReadFrom(importItem) }; + var expectedTagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build(), + TagHelperDescriptorBuilder.Create("Test2TagHelper", "TestAssembly").Build(), + }; + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(RazorSourceDocument.ReadFrom(projectItem), expectedImports, expectedTagHelpers); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Same(expectedTagHelpers, tagHelpers); + Assert.Equal(expectedImports, codeDocument.Imports); + } + + [Fact] + public void ProcessDesignTime_WithNullTagHelpers_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(RazorSourceDocument.ReadFrom(projectItem), Array.Empty(), tagHelpers: null); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Null(tagHelpers); + } + + [Fact] + public void ProcessDesignTime_SetsNullTagHelpersOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Null(tagHelpers); + } + + [Fact] + public void ProcessDesignTime_WithNullImports_SetsEmptyListOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(RazorSourceDocument.ReadFrom(projectItem), importSources: null, tagHelpers: null); + + // Assert + Assert.Empty(codeDocument.Imports); + } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs index 0585198d3e..65b5b49fe9 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs @@ -171,6 +171,129 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal("input", inputTagHelper.TagName); } + [Fact] + public void Execute_WithTagHelperDescriptorsFromCodeDocument_RewritesTagHelpers() + { + // Arrange + var projectEngine = RazorProjectEngine.Create(); + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }; + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + codeDocument.SetTagHelpers(tagHelpers); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + Assert.Empty(rewrittenTree.Diagnostics); + Assert.Equal(3, rewrittenTree.Root.Children.Count); + var formTagHelper = Assert.IsType(rewrittenTree.Root.Children[2]); + Assert.Equal("form", formTagHelper.TagName); + Assert.Equal(3, formTagHelper.Children.Count); + var inputTagHelper = Assert.IsType(formTagHelper.Children[1]); + Assert.Equal("input", inputTagHelper.TagName); + } + + [Fact] + public void Execute_NullTagHelperDescriptorsFromCodeDocument_FallsBackToTagHelperFeature() + { + // Arrange + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }; + var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + codeDocument.SetTagHelpers(tagHelpers: null); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + Assert.Empty(rewrittenTree.Diagnostics); + Assert.Equal(3, rewrittenTree.Root.Children.Count); + var formTagHelper = Assert.IsType(rewrittenTree.Root.Children[2]); + Assert.Equal("form", formTagHelper.TagName); + Assert.Equal(3, formTagHelper.Children.Count); + var inputTagHelper = Assert.IsType(formTagHelper.Children[1]); + Assert.Equal("input", inputTagHelper.TagName); + } + + [Fact] + public void Execute_EmptyTagHelperDescriptorsFromCodeDocument_DoesNotFallbackToTagHelperFeature() + { + // Arrange + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }; + var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + codeDocument.SetTagHelpers(tagHelpers: Array.Empty()); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + Assert.Empty(rewrittenTree.Diagnostics); + Assert.Equal(7, rewrittenTree.Root.Children.Count); + var rewrittenNodes = rewrittenTree.Root.Children.OfType(); + Assert.Empty(rewrittenNodes); + } + [Fact] public void Execute_DirectiveWithoutQuotes_RewritesTagHelpers_TagHelperMatchesElementTwice() { @@ -278,35 +401,58 @@ namespace Microsoft.AspNetCore.Razor.Language } [Fact] - public void Execute_NoopsWhenNoTagHelperFeature() + public void Execute_TagHelpersFromCodeDocumentAndFeature_PrefersCodeDocument() { // Arrange - var projectEngine = RazorProjectEngine.Create(); + var featureTagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }; + var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(featureTagHelpers)); + var phase = new DefaultRazorTagHelperBinderPhase() { Engine = projectEngine.Engine, }; + var sourceDocument = CreateTestSourceDocument(); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); codeDocument.SetSyntaxTree(originalTree); + var codeDocumentTagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + }; + codeDocument.SetTagHelpers(codeDocumentTagHelpers); + // Act phase.Execute(codeDocument); // Assert - var outputTree = codeDocument.GetSyntaxTree(); - Assert.Empty(outputTree.Diagnostics); - Assert.Same(originalTree, outputTree); + var rewrittenTree = codeDocument.GetSyntaxTree(); + Assert.Empty(rewrittenTree.Diagnostics); + Assert.Equal(3, rewrittenTree.Root.Children.Count); + var formTagHelper = Assert.IsType(rewrittenTree.Root.Children[2]); + Assert.Equal("form", formTagHelper.TagName); + Assert.Collection( + formTagHelper.Children, + node => Assert.IsNotType(node), + node => Assert.IsNotType(node), + node => Assert.IsNotType(node)); } [Fact] - public void Execute_NoopsWhenNoFeature() + public void Execute_NoopsWhenNoTagHelpersFromCodeDocumentOrFeature() { // Arrange - var projectEngine = RazorProjectEngine.Create(builder => - { - }); + var projectEngine = RazorProjectEngine.Create(); var phase = new DefaultRazorTagHelperBinderPhase() { Engine = projectEngine.Engine, diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs index 6372657d9c..ccf5e5ca7e 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs @@ -1118,6 +1118,20 @@ private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeMana ignoreLineEndingDifferences: true); } + [Fact] + public void GetDeterministicId_IsDeterministic() + { + // Arrange + var context = TestCodeRenderingContext.CreateRuntime(suppressUniqueIds: null); + + // Act + var firstId = DefaultTagHelperTargetExtension.GetDeterministicId(context); + var secondId = DefaultTagHelperTargetExtension.GetDeterministicId(context); + + // Assert + Assert.Equal(firstId, secondId); + } + private static void Push(CodeRenderingContext context, TagHelperIntermediateNode node) { ((DefaultCodeRenderingContext)context).AncestorsInternal.Push(node); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs index 4f9facbdfd..9ae793d5a1 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests { // Arrange var projectEngine = CreateProjectEngine(); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = projectEngine.Process(projectItem); @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests { // Arrange var projectEngine = CreateProjectEngine(); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = projectEngine.Process(projectItem); @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests b.AddDirective(DirectiveDescriptor.CreateDirective("test", DirectiveKind.SingleLine)); }); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = projectEngine.Process(projectItem); @@ -53,65 +53,5 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Assert AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); } - - [Fact] - public void BuildEngine_CallProcess() - { - // Arrange - var projectEngine = CreateProjectEngine(); - var projectItem = new TestRazorProjectItem("Index.cshtml"); - - // Act - var codeDocument = projectEngine.Process(projectItem); - - // Assert - Assert.NotNull(codeDocument.GetSyntaxTree()); - Assert.NotNull(codeDocument.GetDocumentIntermediateNode()); - } - - [Fact] - public void CSharpDocument_Runtime_PreservesParserErrors() - { - // Arrange - var projectEngine = CreateProjectEngine(); - var projectItem = new TestRazorProjectItem("test.cshtml") - { - Content = "@!!!" - }; - - var expected = RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation("test.cshtml", 1, 0, 1), contentLength: 1), - "!"); - - // Act - var codeDocument = projectEngine.Process(projectItem); - - // Assert - var csharpDocument = codeDocument.GetCSharpDocument(); - var error = Assert.Single(csharpDocument.Diagnostics); - Assert.Equal(expected, error); - } - - [Fact] - public void CSharpDocument_DesignTime_PreservesParserErrors() - { - // Arrange - var projectEngine = CreateProjectEngine(); - var projectItem = new TestRazorProjectItem("test.cshtml") - { - Content = "@{" - }; - - var expected = RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation("test.cshtml", 1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"); - - // Act - var codeDocument = projectEngine.ProcessDesignTime(projectItem); - - // Assert - var csharpDocument = codeDocument.GetCSharpDocument(); - var error = Assert.Single(csharpDocument.Diagnostics); - Assert.Equal(expected, error); - } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs index e40989bbb3..6ead22dfae 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using System.Linq; using Microsoft.AspNetCore.Razor.Language.Extensions; using Xunit; @@ -9,6 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests { public class CodeGenerationIntegrationTest : IntegrationTestBase { + #region Runtime [Fact] public void IncompleteDirectives_Runtime() @@ -22,12 +24,6 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests RunTimeTest(); } - [Fact] - public void BasicImports_Runtime() - { - RunTimeTest(); - } - [Fact] public void UnfinishedExpressionInCode_Runtime() { @@ -459,12 +455,6 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests DesignTimeTest(); } - [Fact] - public void BasicImports_DesignTime() - { - DesignTimeTest(); - } - [Fact] public void UnfinishedExpressionInCode_DesignTime() { @@ -895,7 +885,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests SectionDirective.Register(builder); }); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = projectEngine.ProcessDesignTime(projectItem); @@ -921,7 +911,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests SectionDirective.Register(builder); }); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = projectEngine.Process(projectItem); @@ -937,7 +927,6 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests var projectEngine = CreateProjectEngine(builder => { builder.ConfigureDocumentClassifier(); - builder.AddTagHelpers(descriptors); // Some of these tests use templates builder.AddTargetExtension(new TemplateTargetExtension()); @@ -947,10 +936,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests SectionDirective.Register(builder); }); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); + var imports = GetImports(projectEngine, projectItem); // Act - var codeDocument = projectEngine.Process(projectItem); + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), imports, descriptors.ToList()); // Assert AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); @@ -963,7 +953,6 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests var projectEngine = CreateProjectEngine(builder => { builder.ConfigureDocumentClassifier(); - builder.AddTagHelpers(descriptors); // Some of these tests use templates builder.AddTargetExtension(new TemplateTargetExtension()); @@ -973,15 +962,25 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests SectionDirective.Register(builder); }); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); + var imports = GetImports(projectEngine, projectItem); // Act - var codeDocument = projectEngine.ProcessDesignTime(projectItem); + var codeDocument = projectEngine.ProcessDesignTime(RazorSourceDocument.ReadFrom(projectItem), imports, descriptors.ToList()); // Assert AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); AssertCSharpDocumentMatchesBaseline(codeDocument.GetCSharpDocument()); AssertSourceMappingsMatchBaseline(codeDocument); } + + private static IReadOnlyList GetImports(RazorProjectEngine projectEngine, RazorProjectItem projectItem) + { + var importFeature = projectEngine.ProjectFeatures.OfType().FirstOrDefault(); + var importItems = importFeature.GetImports(projectItem); + var importSourceDocuments = importItems.Where(i => i.Exists).Select(i => RazorSourceDocument.ReadFrom(i)).ToList(); + + return importSourceDocuments; + } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs index 9e722b53b9..e26ce3b6fd 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests builder.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken())); }); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = engine.ProcessDesignTime(projectItem); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/HtmlAttributeIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/HtmlAttributeIntegrationTest.cs index 7683ca94ae..7fd26ffd80 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/HtmlAttributeIntegrationTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/HtmlAttributeIntegrationTest.cs @@ -11,28 +11,26 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void HtmlWithDataDashAttribute() { // Arrange - var projectEngine = CreateProjectEngine(); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act - var codeDocument = projectEngine.Process(projectItem); + var compiled = CompileToCSharp(projectItem); // Assert - AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); } [Fact] public void HtmlWithConditionalAttribute() { // Arrange - var projectEngine = CreateProjectEngine(); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act - var codeDocument = projectEngine.Process(projectItem); + var compiled = CompileToCSharp(projectItem); // Assert - AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/TagHelpersIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/TagHelpersIntegrationTest.cs index 7d7ce390ec..c8cd0e4146 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/TagHelpersIntegrationTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/TagHelpersIntegrationTest.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests }; var projectEngine = CreateProjectEngine(builder => builder.AddTagHelpers(descriptors)); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = projectEngine.Process(projectItem); @@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests }; var projectEngine = CreateProjectEngine(builder => builder.AddTagHelpers(descriptors)); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = projectEngine.Process(projectItem); @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests }; var projectEngine = CreateProjectEngine(builder => builder.AddTagHelpers(descriptors)); - var projectItem = CreateProjectItem(); + var projectItem = CreateProjectItemFromFile(); // Act var codeDocument = projectEngine.Process(projectItem); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs index 4b4f984ce6..d54ef401df 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Arrange var spanBuilder = new SpanBuilder(SourceLocation.Zero); - spanBuilder.Accept(new HtmlSymbol("hello", HtmlSymbolType.Text)); + spanBuilder.Accept(new HtmlToken("hello", HtmlTokenType.Text)); var span = spanBuilder.Build(); var blockBuilder = new BlockBuilder() { @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var parentBlock = blockBuilder.Build(); var originalBlockLength = parentBlock.Length; spanBuilder = new SpanBuilder(SourceLocation.Zero); - spanBuilder.Accept(new HtmlSymbol("hi", HtmlSymbolType.Text)); + spanBuilder.Accept(new HtmlToken("hi", HtmlTokenType.Text)); span.ReplaceWith(spanBuilder); // Wire up parents now so we can re-trigger ChildChanged to cause cache refresh. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs index 13633efdd1..5ef32b1e8a 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs @@ -13,132 +13,41 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void FunctionsDirectiveAutoCompleteAtEOF() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), FunctionsDirective.Directive.Directive, "}", "{")); - - // Act & Assert - ParseBlockTest( - "@functions{", - new[] { FunctionsDirective.Directive }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("functions").Accepts(AcceptedCharactersInternal.None), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None))); + // Arrange, Act & Assert + ParseBlockTest("@functions{", new[] { FunctionsDirective.Directive }); } [Fact] public void SectionDirectiveAutoCompleteAtEOF() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "section", "}", "{")); - - // Act & Assert - ParseBlockTest( - "@section Header {", - new[] { SectionDirective.Directive }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Header", CSharpSymbolType.Identifier) - .AsDirectiveToken(SectionDirective.Directive.Tokens.First()), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.EmptyHtml()))); + // Arrange, Act & Assert + ParseBlockTest("@section Header {", new[] { SectionDirective.Directive }); } [Fact] public void VerbatimBlockAutoCompleteAtEOF() { - ParseBlockTest("@{", - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); + ParseBlockTest("@{"); } [Fact] public void FunctionsDirectiveAutoCompleteAtStartOfFile() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); - - // Act & Assert - ParseBlockTest( - "@functions{" + Environment.NewLine + "foo", - new[] { FunctionsDirective.Directive }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("functions").Accepts(AcceptedCharactersInternal.None), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + "foo").AsStatement())); + // Arrange, Act & Assert + ParseBlockTest("@functions{" + Environment.NewLine + "foo", new[] { FunctionsDirective.Directive }); } [Fact] public void SectionDirectiveAutoCompleteAtStartOfFile() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "section", "}", "{")); - - // Act & Assert - ParseBlockTest( - "@section Header {" + Environment.NewLine + "

Foo

", - new[] { SectionDirective.Directive }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Header", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens.First()), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(Environment.NewLine), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

"))))); + // Arrange, Act & Assert + ParseBlockTest("@section Header {" + Environment.NewLine + "

Foo

", new[] { SectionDirective.Directive }); } [Fact] public void VerbatimBlockAutoCompleteAtStartOfFile() { - ParseBlockTest( - "@{" + Environment.NewLine + "

", - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine) - .AsStatement() - .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None))), - Factory.Span(SpanKindInternal.Code, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown)) - .With(new StatementChunkGenerator()) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); + ParseBlockTest("@{" + Environment.NewLine + "

"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs index fa22393a46..6e7f36da26 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs @@ -9,64 +9,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public class CSharpBlockTest : CsHtmlCodeParserTestBase { [Fact] - public void ParseBlock_NestedCodeBlockWithCSharpAt() + public void NestedCodeBlockWithCSharpAt() { - ParseBlockTest("{ if (true) { var val = @x; if (val != 3) { } } }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory - .Code(" if (true) { var val = @x; if (val != 3) { } } ") - .AsStatement() - .Accepts(AcceptedCharactersInternal.Any) - .AutoCompleteWith(autoCompleteString: null, atEndOfSpan: false), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("{ if (true) { var val = @x; if (val != 3) { } } }"); } [Fact] - public void ParseBlock_NestedCodeBlockWithMarkupSetsDotAsMarkup() + public void NestedCodeBlockWithMarkupSetsDotAsMarkup() { - ParseBlockTest("if (true) { @if(false) {
@something.
} }", - new StatementBlock( - Factory.Code("if (true) { ").AsStatement(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(false) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("
", AcceptedCharactersInternal.None), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("something") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: false) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Markup("."), - BlockFactory.MarkupTagBlock("
", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement()), - Factory.Code(" }").AsStatement())); + ParseBlockTest("if (true) { @if(false) {
@something.
} }"); } [Fact] - public void BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideSingleLineComments() + public void BalancingBracketsIgnoresStringLiteralCharactersAndBrackets() { + // BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideSingleLineComments SingleSpanBlockTest(@"if(foo) { // bar } "" baz ' zoop(); -}", BlockKindInternal.Statement, SpanKindInternal.Code); +}"); } [Fact] public void NestedCodeBlockWithAtDoesntCauseError() { - ParseBlockTest("if (true) { @if(false) { } }", - new StatementBlock( - Factory.Code("if (true) { ").AsStatement(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(false) { }").AsStatement() - ), - Factory.Code(" }").AsStatement())); + ParseBlockTest("if (true) { @if(false) { } }"); } [Fact] @@ -76,162 +43,138 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy @"if(foo) { /* bar } "" */ ' baz } ' zoop(); -}", BlockKindInternal.Statement, SpanKindInternal.Code); +}"); } [Fact] - public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForKeyword() + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForKeyword + SingleSpanBlockTest( + "for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForeachKeyword + SingleSpanBlockTest( + "foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsWhileKeyword + SingleSpanBlockTest( + "while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsUsingKeywordFollowedByParen + SingleSpanBlockTest( + "using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void SupportsUsingsNestedWithinOtherBlocks() { SingleSpanBlockTest( - "for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); + "if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }"); } [Fact] - public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForeachKeyword() + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches + SingleSpanBlockTest( + "if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void AllowsEmptyBlockStatement() + { + SingleSpanBlockTest("if(false) { }"); + } + + [Fact] + public void TerminatesParenBalancingAtEOF() + { + ImplicitExpressionTest("Html.En(code()"); + } + + [Fact] + public void SupportsBlockCommentBetweenIfAndElseClause() { SingleSpanBlockTest( - "foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); + "if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }"); } [Fact] - public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsWhileKeyword() - { - SingleSpanBlockTest( - "while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); - } - - [Fact] - public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsUsingKeywordFollowedByParen() - { - SingleSpanBlockTest( - "using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockKindInternal.Statement, - SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); - } - - [Fact] - public void ParseBlockSupportsUsingsNestedWithinOtherBlocks() - { - SingleSpanBlockTest( - "if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }", - BlockKindInternal.Statement, - SpanKindInternal.Code); - } - - [Fact] - public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches() - { - SingleSpanBlockTest( - "if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", - BlockKindInternal.Statement, - SpanKindInternal.Code); - } - - [Fact] - public void ParseBlockAllowsEmptyBlockStatement() - { - SingleSpanBlockTest("if(false) { }", BlockKindInternal.Statement, SpanKindInternal.Code); - } - - [Fact] - public void ParseBlockTerminatesParenBalancingAtEOF() - { - ImplicitExpressionTest( - "Html.En(code()", "Html.En(code()", - AcceptedCharactersInternal.Any, - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "(", ")")); - } - - [Fact] - public void ParseBlockSupportsBlockCommentBetweenIfAndElseClause() - { - SingleSpanBlockTest( - "if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); - } - - [Fact] - public void ParseBlockSupportsRazorCommentBetweenIfAndElseClause() + public void SupportsRazorCommentBetweenIfAndElseClause() { RunRazorCommentBetweenClausesTest( - "if(foo) { bar(); } ", " else { baz(); }", - acceptedCharacters: AcceptedCharactersInternal.None); + "if(foo) { bar(); } ", " else { baz(); }"); } [Fact] - public void ParseBlockSupportsBlockCommentBetweenElseIfAndElseClause() + public void SupportsBlockCommentBetweenElseIfAndElseClause() { SingleSpanBlockTest( - "if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); + "if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }"); } [Fact] - public void ParseBlockSupportsRazorCommentBetweenElseIfAndElseClause() + public void SupportsRazorCommentBetweenElseIfAndElseClause() { RunRazorCommentBetweenClausesTest( - "if(foo) { bar(); } else if(bar) { baz(); } ", " else { baz(); }", - acceptedCharacters: AcceptedCharactersInternal.None); + "if(foo) { bar(); } else if(bar) { baz(); } ", " else { baz(); }"); } [Fact] - public void ParseBlockSupportsBlockCommentBetweenIfAndElseIfClause() + public void SupportsBlockCommentBetweenIfAndElseIfClause() { SingleSpanBlockTest( - "if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }", - BlockKindInternal.Statement, - SpanKindInternal.Code); + "if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }"); } [Fact] - public void ParseBlockSupportsRazorCommentBetweenIfAndElseIfClause() + public void SupportsRazorCommentBetweenIfAndElseIfClause() { RunRazorCommentBetweenClausesTest("if(foo) { bar(); } ", " else if(bar) { baz(); }"); } [Fact] - public void ParseBlockSupportsLineCommentBetweenIfAndElseClause() + public void SupportsLineCommentBetweenIfAndElseClause() { SingleSpanBlockTest(@"if(foo) { bar(); } // Foo // Bar -else { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); +else { baz(); }"); } [Fact] - public void ParseBlockSupportsLineCommentBetweenElseIfAndElseClause() + public void SupportsLineCommentBetweenElseIfAndElseClause() { SingleSpanBlockTest(@"if(foo) { bar(); } else if(bar) { baz(); } // Foo // Bar -else { biz(); }", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); +else { biz(); }"); } [Fact] - public void ParseBlockSupportsLineCommentBetweenIfAndElseIfClause() + public void SupportsLineCommentBetweenIfAndElseIfClause() { SingleSpanBlockTest(@"if(foo) { bar(); } // Foo // Bar -else if(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); +else if(bar) { baz(); }"); } [Fact] - public void ParseBlockParsesElseIfBranchesOfIfStatement() + public void ParsesElseIfBranchesOfIfStatement() { const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { Debug.WriteLine(@""foo } bar""); @@ -241,11 +184,11 @@ else if(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); }"; const string document = ifStatement + elseIfBranch; - SingleSpanBlockTest(document, BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest(document); } [Fact] - public void ParseBlockParsesMultipleElseIfBranchesOfIfStatement() + public void ParsesMultipleElseIfBranchesOfIfStatement() { const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { Debug.WriteLine(@""foo } bar""); @@ -254,11 +197,11 @@ else if(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); Debug.WriteLine(@""bar } baz""); }"; const string document = ifStatement + elseIfBranch + elseIfBranch + elseIfBranch + elseIfBranch; - SingleSpanBlockTest(document, BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest(document); } [Fact] - public void ParseBlockParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch() + public void ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch() { const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { Debug.WriteLine(@""foo } bar""); @@ -269,11 +212,11 @@ else if(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); const string elseBranch = @" else { Debug.WriteLine(@""bar } baz""); }"; const string document = ifStatement + elseIfBranch + elseIfBranch + elseBranch; - SingleSpanBlockTest(document, BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); + SingleSpanBlockTest(document); } [Fact] - public void ParseBlockStopsParsingCodeAfterElseBranch() + public void StopsParsingCodeAfterElseBranch() { const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { Debug.WriteLine(@""foo } bar""); @@ -283,25 +226,22 @@ else if(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); }"; const string elseBranch = @" else { Debug.WriteLine(@""bar } baz""); }"; const string document = ifStatement + elseIfBranch + elseBranch + elseIfBranch; - const string expected = ifStatement + elseIfBranch + elseBranch; - ParseBlockTest( - document, - new StatementBlock(Factory.Code(expected).AsStatement().Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest(document); } [Fact] - public void ParseBlockStopsParsingIfIfStatementNotFollowedByElse() + public void StopsParsingIfIfStatementNotFollowedByElse() { const string document = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { Debug.WriteLine(@""foo } bar""); }"; - SingleSpanBlockTest(document, BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest(document); } [Fact] - public void ParseBlockAcceptsElseIfWithNoCondition() + public void AcceptsElseIfWithNoCondition() { // We don't want to be a full C# parser - If the else if is missing it's condition, the C# compiler // can handle that, we have all the info we need to keep parsing @@ -311,95 +251,74 @@ else if(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); const string elseIfBranch = @" else if { foo(); }"; const string document = ifBranch + elseIfBranch; - SingleSpanBlockTest(document, BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest(document); } [Fact] - public void ParseBlockCorrectlyParsesDoWhileBlock() + public void CorrectlyParsesDoWhileBlock() { SingleSpanBlockTest( - "do { var foo = bar; } while(foo != bar);", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); + "do { var foo = bar; } while(foo != bar);"); } [Fact] - public void ParseBlockCorrectlyParsesDoWhileBlockMissingSemicolon() + public void CorrectlyParsesDoWhileBlockMissingSemicolon() { - SingleSpanBlockTest("do { var foo = bar; } while(foo != bar)", BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest("do { var foo = bar; } while(foo != bar)"); } [Fact] - public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileCondition() + public void CorrectlyParsesDoWhileBlockMissingWhileCondition() { - SingleSpanBlockTest("do { var foo = bar; } while", BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest("do { var foo = bar; } while"); } [Fact] - public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon() + public void CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon() { SingleSpanBlockTest( - "do { var foo = bar; } while;", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); + "do { var foo = bar; } while;"); } [Fact] - public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileClauseEntirely() + public void CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely() { - SingleSpanBlockTest("do { var foo = bar; } narf;", "do { var foo = bar; }", BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest("do { var foo = bar; } narf;"); } [Fact] - public void ParseBlockSupportsBlockCommentBetweenDoAndWhileClause() + public void SupportsBlockCommentBetweenDoAndWhileClause() { SingleSpanBlockTest( - "do { var foo = bar; } /* Foo */ /* Bar */ while(true);", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); + "do { var foo = bar; } /* Foo */ /* Bar */ while(true);"); } [Fact] - public void ParseBlockSupportsLineCommentBetweenDoAndWhileClause() + public void SupportsLineCommentBetweenDoAndWhileClause() { SingleSpanBlockTest(@"do { var foo = bar; } // Foo // Bar -while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); +while(true);"); } [Fact] - public void ParseBlockSupportsRazorCommentBetweenDoAndWhileClause() + public void SupportsRazorCommentBetweenDoAndWhileClause() { RunRazorCommentBetweenClausesTest( - "do { var foo = bar; } ", " while(true);", - acceptedCharacters: AcceptedCharactersInternal.None); + "do { var foo = bar; } ", " while(true);"); } [Fact] - public void ParseBlockCorrectlyParsesMarkupInDoWhileBlock() + public void CorrectlyParsesMarkupInDoWhileBlock() { - ParseBlockTest("@do { var foo = bar;

Foo

foo++; } while (foo);", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("do { var foo = bar;").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("foo++; } while (foo);").AsStatement().Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@do { var foo = bar;

Foo

foo++; } while (foo);"); } [Fact] - public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsSwitchKeyword() + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword() { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsSwitchKeyword SingleSpanBlockTest(@"switch(foo) { case 0: break; @@ -411,389 +330,273 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara return; default: return; -}", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); +}"); } [Fact] - public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsLockKeyword() + public void ThenBalancesBracesIfFirstIdentifierIsLockKeyword() { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsLockKeyword SingleSpanBlockTest( - "lock(foo) { Debug.WriteLine(@\"foo } bar\"); }", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); + "lock(foo) { Debug.WriteLine(@\"foo } bar\"); }"); } [Fact] - public void ParseBlockHasErrorsIfNamespaceImportMissingSemicolon() + public void HasErrorsIfNamespaceImportMissingSemicolon() { - NamespaceImportTest( - "using Foo.Bar.Baz", - " Foo.Bar.Baz", - acceptedCharacters: AcceptedCharactersInternal.NonWhiteSpace | AcceptedCharactersInternal.WhiteSpace, - location: new SourceLocation(17, 0, 17)); + ParseBlockTest( + "using Foo.Bar.Baz"); } [Fact] - public void ParseBlockHasErrorsIfNamespaceAliasMissingSemicolon() + public void HasErrorsIfNamespaceAliasMissingSemicolon() { - NamespaceImportTest( - "using Foo.Bar.Baz = FooBarBaz", - " Foo.Bar.Baz = FooBarBaz", - acceptedCharacters: AcceptedCharactersInternal.NonWhiteSpace | AcceptedCharactersInternal.WhiteSpace, - location: new SourceLocation(29, 0, 29)); + ParseBlockTest( + "using Foo.Bar.Baz = FooBarBaz"); } [Fact] - public void ParseBlockParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat() + public void ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat() { - NamespaceImportTest( - "using Foo.Bar.Baz;", - " Foo.Bar.Baz", - AcceptedCharactersInternal.NonWhiteSpace | AcceptedCharactersInternal.WhiteSpace); + ParseBlockTest( + "using Foo.Bar.Baz;"); } [Fact] - public void ParseBlockDoesntCaptureWhitespaceAfterUsing() + public void DoesntCaptureWhitespaceAfterUsing() { - ParseBlockTest("using Foo ", - new DirectiveBlock( - Factory.Code("using Foo") - .AsNamespaceImport(" Foo") - .Accepts(AcceptedCharactersInternal.NonWhiteSpace | AcceptedCharactersInternal.WhiteSpace))); + ParseBlockTest("using Foo "); } [Fact] - public void ParseBlockCapturesNewlineAfterUsing() + public void CapturesNewlineAfterUsing() { - ParseBlockTest($"using Foo{Environment.NewLine}", - new DirectiveBlock( - Factory.Code($"using Foo{Environment.NewLine}") - .AsNamespaceImport(" Foo") - .Accepts(AcceptedCharactersInternal.NonWhiteSpace | AcceptedCharactersInternal.WhiteSpace))); + ParseBlockTest($"using Foo{Environment.NewLine}"); } [Fact] - public void ParseBlockParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat() + public void ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat() { - NamespaceImportTest( - "using FooBarBaz = FooBarBaz;", - " FooBarBaz = FooBarBaz", - AcceptedCharactersInternal.NonWhiteSpace | AcceptedCharactersInternal.WhiteSpace); + ParseBlockTest( + "using FooBarBaz = FooBarBaz;"); } [Fact] - public void ParseBlockTerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock() + public void TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock() { - SingleSpanBlockTest("using ", BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest("using "); } [Fact] - public void ParseBlockTerminatesSingleLineCommentAtEndOfFile() + public void TerminatesSingleLineCommentAtEndOfFile() { const string document = "foreach(var f in Foo) { // foo bar baz"; - SingleSpanBlockTest( - document, - document, - BlockKindInternal.Statement, - SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); + SingleSpanBlockTest(document); } [Fact] - public void ParseBlockTerminatesBlockCommentAtEndOfFile() + public void TerminatesBlockCommentAtEndOfFile() { const string document = "foreach(var f in Foo) { /* foo bar baz"; - SingleSpanBlockTest( - document, - document, - BlockKindInternal.Statement, - SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_BlockCommentNotTerminated( - new SourceSpan(new SourceLocation(24, 0, 24), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); + SingleSpanBlockTest(document); } [Fact] - public void ParseBlockTerminatesSingleSlashAtEndOfFile() + public void TerminatesSingleSlashAtEndOfFile() { const string document = "foreach(var f in Foo) { / foo bar baz"; - SingleSpanBlockTest( - document, - document, - BlockKindInternal.Statement, - SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); + SingleSpanBlockTest(document); } [Fact] - public void ParseBlockSupportsBlockCommentBetweenTryAndFinallyClause() + public void SupportsBlockCommentBetweenTryAndFinallyClause() { - SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ finally { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); + SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ finally { baz(); }"); } [Fact] - public void ParseBlockSupportsRazorCommentBetweenTryAndFinallyClause() + public void SupportsRazorCommentBetweenTryAndFinallyClause() { - RunRazorCommentBetweenClausesTest("try { bar(); } ", " finally { biz(); }", acceptedCharacters: AcceptedCharactersInternal.None); + RunRazorCommentBetweenClausesTest("try { bar(); } ", " finally { biz(); }"); } [Fact] - public void ParseBlockSupportsBlockCommentBetweenCatchAndFinallyClause() + public void SupportsBlockCommentBetweenCatchAndFinallyClause() { SingleSpanBlockTest( - "try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }", - BlockKindInternal.Statement, - SpanKindInternal.Code, - acceptedCharacters: AcceptedCharactersInternal.None); + "try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }"); } [Fact] - public void ParseBlockSupportsRazorCommentBetweenCatchAndFinallyClause() + public void SupportsRazorCommentBetweenCatchAndFinallyClause() { RunRazorCommentBetweenClausesTest( - "try { bar(); } catch(bar) { baz(); } ", " finally { biz(); }", - acceptedCharacters: AcceptedCharactersInternal.None); + "try { bar(); } catch(bar) { baz(); } ", " finally { biz(); }"); } [Fact] - public void ParseBlockSupportsBlockCommentBetweenTryAndCatchClause() + public void SupportsBlockCommentBetweenTryAndCatchClause() { - SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }"); } [Fact] - public void ParseBlockSupportsRazorCommentBetweenTryAndCatchClause() + public void SupportsRazorCommentBetweenTryAndCatchClause() { RunRazorCommentBetweenClausesTest("try { bar(); }", " catch(bar) { baz(); }"); } [Fact] - public void ParseBlockSupportsLineCommentBetweenTryAndFinallyClause() + public void SupportsLineCommentBetweenTryAndFinallyClause() { SingleSpanBlockTest(@"try { bar(); } // Foo // Bar -finally { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); +finally { baz(); }"); } [Fact] - public void ParseBlockSupportsLineCommentBetweenCatchAndFinallyClause() + public void SupportsLineCommentBetweenCatchAndFinallyClause() { SingleSpanBlockTest(@"try { bar(); } catch(bar) { baz(); } // Foo // Bar -finally { biz(); }", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); +finally { biz(); }"); } [Fact] - public void ParseBlockSupportsLineCommentBetweenTryAndCatchClause() + public void SupportsLineCommentBetweenTryAndCatchClause() { SingleSpanBlockTest(@"try { bar(); } // Foo // Bar -catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); +catch(bar) { baz(); }"); } [Fact] - public void ParseBlockSupportsTryStatementWithNoAdditionalClauses() + public void SupportsTryStatementWithNoAdditionalClauses() { - SingleSpanBlockTest("try { var foo = new { } }", BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest("try { var foo = new { } }"); } [Fact] - public void ParseBlockSupportsMarkupWithinTryClause() + public void SupportsMarkupWithinTryClause() { RunSimpleWrappedMarkupTest( prefix: "try {", markup: "

Foo

", - suffix: "}", - expectedStart: new SourceLocation(5, 0, 5), - expectedMarkup: new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + suffix: "}"); } [Fact] - public void ParseBlockSupportsTryStatementWithOneCatchClause() + public void SupportsTryStatementWithOneCatchClause() { - SingleSpanBlockTest("try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }", BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest("try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }"); } [Fact] - public void ParseBlockSupportsMarkupWithinCatchClause() + public void SupportsMarkupWithinCatchClause() { RunSimpleWrappedMarkupTest( prefix: "try { var foo = new { } } catch(Foo Bar Baz) {", markup: "

Foo

", - suffix: "}", - expectedStart: new SourceLocation(46, 0, 46), - expectedMarkup: new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + suffix: "}"); } [Fact] - public void ParseBlockSupportsTryStatementWithMultipleCatchClause() + public void SupportsTryStatementWithMultipleCatchClause() { SingleSpanBlockTest( "try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " + - "{ var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }", - BlockKindInternal.Statement, - SpanKindInternal.Code); + "{ var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }"); } [Fact] - public void ParseBlockSupportsExceptionLessCatchClauses() + public void SupportsExceptionLessCatchClauses() { - SingleSpanBlockTest("try { var foo = new { } } catch { var foo = new { } }", BlockKindInternal.Statement, SpanKindInternal.Code); + SingleSpanBlockTest("try { var foo = new { } } catch { var foo = new { } }"); } [Fact] - public void ParseBlockSupportsMarkupWithinAdditionalCatchClauses() + public void SupportsMarkupWithinAdditionalCatchClauses() { RunSimpleWrappedMarkupTest( prefix: "try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " + "{ var foo = new { } } catch(Foo Bar Baz) {", markup: "

Foo

", - suffix: "}", - expectedStart: new SourceLocation(128, 0, 128), - expectedMarkup: new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + suffix: "}"); } [Fact] - public void ParseBlockSupportsTryStatementWithFinallyClause() + public void SupportsTryStatementWithFinallyClause() { - SingleSpanBlockTest("try { var foo = new { } } finally { var foo = new { } }", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); + SingleSpanBlockTest("try { var foo = new { } } finally { var foo = new { } }"); } [Fact] - public void ParseBlockSupportsMarkupWithinFinallyClause() + public void SupportsMarkupWithinFinallyClause() { RunSimpleWrappedMarkupTest( prefix: "try { var foo = new { } } finally {", markup: "

Foo

", - suffix: "}", - expectedStart: new SourceLocation(35, 0, 35), - expectedMarkup: new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - acceptedCharacters: AcceptedCharactersInternal.None); + suffix: "}"); } [Fact] - public void ParseBlockStopsParsingCatchClausesAfterFinallyBlock() + public void StopsParsingCatchClausesAfterFinallyBlock() { - var expectedContent = "try { var foo = new { } } finally { var foo = new { } }"; - SingleSpanBlockTest(expectedContent + " catch(Foo Bar Baz) { }", expectedContent, BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); + var content = "try { var foo = new { } } finally { var foo = new { } }"; + SingleSpanBlockTest(content + " catch(Foo Bar Baz) { }"); } [Fact] - public void ParseBlockDoesNotAllowMultipleFinallyBlocks() + public void DoesNotAllowMultipleFinallyBlocks() { - var expectedContent = "try { var foo = new { } } finally { var foo = new { } }"; - SingleSpanBlockTest(expectedContent + " finally { }", expectedContent, BlockKindInternal.Statement, SpanKindInternal.Code, acceptedCharacters: AcceptedCharactersInternal.None); + var content = "try { var foo = new { } } finally { var foo = new { } }"; + SingleSpanBlockTest(content + " finally { }"); } [Fact] - public void ParseBlockAcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode() + public void AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode() { // Arrange - ParseBlockTest(@"if(foo) { @foo. }", - new StatementBlock( - Factory.Code("if(foo) { ").AsStatement(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo.") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - Factory.Code(" }").AsStatement() - )); + ParseBlockTest(@"if(foo) { @foo. }"); } [Fact] - public void ParseBlockParsesExpressionOnSwitchCharacterFollowedByOpenParen() + public void ParsesExpressionOnSwitchCharacterFollowedByOpenParen() { // Arrange - ParseBlockTest(@"if(foo) { @(foo + bar) }", - new StatementBlock( - Factory.Code("if(foo) { ").AsStatement(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("foo + bar").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code(" }").AsStatement() - )); + ParseBlockTest(@"if(foo) { @(foo + bar) }"); } [Fact] - public void ParseBlockParsesExpressionOnSwitchCharacterFollowedByIdentifierStart() + public void ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart() { // Arrange - ParseBlockTest(@"if(foo) { @foo[4].bar() }", - new StatementBlock( - Factory.Code("if(foo) { ").AsStatement(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo[4].bar()") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - Factory.Code(" }").AsStatement() - )); + ParseBlockTest(@"if(foo) { @foo[4].bar() }"); } [Fact] - public void ParseBlockTreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart() + public void TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart() { // Arrange - ParseBlockTest(@"if(foo) { @@class.Foo() }", - new StatementBlock( - Factory.Code("if(foo) { ").AsStatement(), - Factory.Code("@").Hidden(), - Factory.Code("@class.Foo() }").AsStatement() - )); + ParseBlockTest(@"if(foo) { @@class.Foo() }"); } [Fact] - public void ParseBlockTreatsAtSignsAfterFirstPairAsPartOfCSharpStatement() + public void TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement() { // Arrange - ParseBlockTest(@"if(foo) { @@@@class.Foo() }", - new StatementBlock( - Factory.Code("if(foo) { ").AsStatement(), - Factory.Code("@").Hidden(), - Factory.Code("@@@class.Foo() }").AsStatement() - )); + ParseBlockTest(@"if(foo) { @@@@class.Foo() }"); } [Fact] - public void ParseBlockDoesNotParseMarkupStatementOrExpressionOnSwitchCharacterNotFollowedByOpenAngleOrColon() + public void DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon() { + // ParseBlockDoesNotParseMarkupStatementOrExpressionOnSwitchCharacterNotFollowedByOpenAngleOrColon // Arrange - ParseBlockTest("if(foo) { @\"Foo\".ToString(); }", - new StatementBlock( - Factory.Code("if(foo) { @\"Foo\".ToString(); }").AsStatement())); + ParseBlockTest("if(foo) { @\"Foo\".ToString(); }"); } [Fact] @@ -809,448 +612,78 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); + " }" + Environment.NewLine + " " + Environment.NewLine + " " + Environment.NewLine - + " }", - new StatementBlock( - Factory.Code("foreach(var c in db.Categories) {" + Environment.NewLine).AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("
", AcceptedCharactersInternal.None), - Factory.Markup(Environment.NewLine + " "), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("c.Name") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(Environment.NewLine + " "), - BlockFactory.MarkupTagBlock("
    ", AcceptedCharactersInternal.None), - Factory.Markup(Environment.NewLine), - new StatementBlock( - Factory.Code(@" ").AsStatement(), - Factory.CodeTransition(), - Factory.Code("foreach(var p in c.Products) {" + Environment.NewLine).AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("
  • ", AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("(" href=\"", 183 + Environment.NewLine.Length * 5, 5, 30), - new LocationTagged("\"", 246 + Environment.NewLine.Length * 5, 5, 93)), - Factory.Markup(" href=\"").With(SpanChunkGenerator.Null), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged(string.Empty, 190 + Environment.NewLine.Length * 5, 5, 37), 190 + Environment.NewLine.Length * 5, 5, 37), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Html.ActionUrl(\"Products\", \"Detail\", new { id = p.Id })") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup("\"").With(SpanChunkGenerator.Null)), - Factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("p.Name") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None), - BlockFactory.MarkupTagBlock("
  • ", AcceptedCharactersInternal.None), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code(" }" + Environment.NewLine).AsStatement().Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("
", AcceptedCharactersInternal.None), - Factory.Markup(Environment.NewLine + " "), - BlockFactory.MarkupTagBlock("
", AcceptedCharactersInternal.None), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code(" }").AsStatement().Accepts(AcceptedCharactersInternal.None))); - } - - public static TheoryData BlockWithEscapedTransitionData - { - get - { - var factory = new SpanFactory(); - var datetimeBlock = new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)); - - return new TheoryData - { - { - // Double transition in attribute value - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 14, 0, 14)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("@", 12, 0, 12))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - // Double transition at the end of attribute value - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 17, 0, 17)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - factory.Markup("abc").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("abc", 12, 0, 12))), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 15, 0, 15), new LocationTagged("@", 15, 0, 15))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - // Double transition at the beginning attribute value - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 17, 0, 17)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("@", 12, 0, 12))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("def").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 14, 0, 14), new LocationTagged("def", 14, 0, 14))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - // Double transition in between attribute value - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 22, 0, 22)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - factory.Markup("abc").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("abc", 12, 0, 12))), - new MarkupBlock( - factory.Markup(" @").With(new LiteralAttributeChunkGenerator(new LocationTagged(" ", 15, 0, 15), new LocationTagged("@", 16, 0, 16))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup(" def").With(new LiteralAttributeChunkGenerator(new LocationTagged(" ", 18, 0, 18), new LocationTagged("def", 19, 0, 19))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - // Double transition with expression block - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 27, 0, 27)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("@", 12, 0, 12))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 14, 0, 14), 14, 0, 14), - factory.EmptyHtml().With(SpanChunkGenerator.Null), - datetimeBlock), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 28, 0, 28)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), 12, 0, 12), - datetimeBlock), - new MarkupBlock( - factory.Markup(" @").With(new LiteralAttributeChunkGenerator(new LocationTagged(" ", 25, 0, 25), new LocationTagged("@", 26, 0, 26))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 27, 0, 27)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), 12, 0, 12), - datetimeBlock), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 25, 0, 25), new LocationTagged("@", 25, 0, 25))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 33, 0, 33)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), 12, 0, 12), - new ExpressionBlock( - factory.CodeTransition(), - factory.MetaCode("(").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None), - factory.Code("2+3").AsExpression(), - factory.MetaCode(")").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None))), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 18, 0, 18), new LocationTagged("@", 18, 0, 18))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 20, 0, 20), 20, 0, 20), - factory.EmptyHtml().With(SpanChunkGenerator.Null), - datetimeBlock), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 20, 0, 20)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("@", 12, 0, 12))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 14, 0, 14), 14, 0, 14), - factory.EmptyHtml().With(SpanChunkGenerator.Null), - new ExpressionBlock( - factory.CodeTransition(), - factory.MetaCode("(").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None), - factory.Code("2+3").AsExpression(), - factory.MetaCode(")").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - // Double transition with email in attribute value - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 26, 0, 26)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - factory.Markup("abc@def.com").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("abc@def.com", 12, 0, 12))), - new MarkupBlock( - factory.Markup(" @").With(new LiteralAttributeChunkGenerator(new LocationTagged(" ", 23, 0, 23), new LocationTagged("@", 24, 0, 24))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - "{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 27, 0, 27)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - factory.Markup("abc").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("abc", 12, 0, 12))), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 15, 0, 15), new LocationTagged("@", 15, 0, 15))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("def.com").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 17, 0, 17), new LocationTagged("def.com", 17, 0, 17))), - new MarkupBlock( - factory.Markup(" @").With(new LiteralAttributeChunkGenerator(new LocationTagged(" ", 24, 0, 24), new LocationTagged("@", 25, 0, 25))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - { - // Double transition in complex regex in attribute value - @"{}", - CreateStatementBlock( - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo=\"", 6, 0, 6), new LocationTagged("\"", 112, 0, 112)), - factory.Markup(" foo=\"").With(SpanChunkGenerator.Null), - factory.Markup(@"/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged(@"/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+", 12, 0, 12))), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 44, 0, 44), new LocationTagged("@", 44, 0, 44))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup(@"[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 46, 0, 46), new LocationTagged(@"[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i", 46, 0, 46))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))) - }, - }; - } - } - - [Theory] - [MemberData(nameof(BlockWithEscapedTransitionData))] - public void ParseBlock_WithDoubleTransition_DoesNotThrow(string input, object expected) - { - FixupSpans = true; - - // Act & Assert - ParseBlockTest(input, (Block)expected); + + " }"); } [Fact] - public void ParseBlock_WithDoubleTransition_EndOfFile_Throws() + public void WithDoubleTransitionInAttributeValue_DoesNotThrow() { - // Arrange - var expected = new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" foo='", 6, 0, 6), new LocationTagged(string.Empty, 14, 0, 14)), - Factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - Factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), new LocationTagged("@", 12, 0, 12))).Accepts(AcceptedCharactersInternal.None), - Factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)))), - Factory.EmptyHtml())); - var expectedErrors = new RazorDiagnostic[] - { - RazorDiagnosticFactory.CreateParsing_UnfinishedTag( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 4), "span"), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{"), - }; - - // Act & Assert - ParseBlockTest("{}"; + ParseBlockTest(input); } [Fact] - public void ParseBlock_WithUnexpectedTransitionsInAttributeValue_Throws() + public void WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow() { - // Arrange - var expected = new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" foo='", 6, 0, 6), new LocationTagged("'", 15, 0, 15)), - Factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 12, 0, 12), 12, 0, 12), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp().AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(" ", 13, 0, 13), 13, 0, 13), - Factory.Markup(" ").With(SpanChunkGenerator.Null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp().AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None))), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)); - var expectedErrors = new RazorDiagnostic[] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 5), - "' />}"), - }; + var input = "{}"; + ParseBlockTest(input); + } - // Act & Assert - ParseBlockTest("{}", expected, expectedErrors); + [Fact] + public void WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow() + { + var input = "{}"; + ParseBlockTest(input); + } + + [Fact] + public void WithDoubleTransitionBetweenAttributeValue_DoesNotThrow() + { + var input = "{}"; + ParseBlockTest(input); + } + + [Fact] + public void WithDoubleTransitionWithExpressionBlock_DoesNotThrow() + { + var input = "{}"; + ParseBlockTest(input); + } + + [Fact] + public void WithDoubleTransitionInEmail_DoesNotThrow() + { + var input = "{}"; + ParseBlockTest(input); + } + + [Fact] + public void WithDoubleTransitionInRegex_DoesNotThrow() + { + var input = @"{}"; + ParseBlockTest(input); + } + + [Fact] + public void WithDoubleTransition_EndOfFile_Throws() + { + ParseBlockTest("{}"); } private void RunRazorCommentBetweenClausesTest(string preComment, string postComment, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.Any) { - ParseBlockTest(preComment + "@* Foo *@ @* Bar *@" + postComment, - new StatementBlock( - Factory.Code(preComment).AsStatement(), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharactersInternal.None), - Factory.Comment(" Foo ", CSharpSymbolType.RazorComment), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharactersInternal.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - ), - Factory.Code(" ").AsStatement(), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharactersInternal.None), - Factory.Comment(" Bar ", CSharpSymbolType.RazorComment), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar).Accepts(AcceptedCharactersInternal.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - ), - Factory.Code(postComment).AsStatement().Accepts(acceptedCharacters))); + ParseBlockTest(preComment + "@* Foo *@ @* Bar *@" + postComment); } - private void RunSimpleWrappedMarkupTest(string prefix, string markup, string suffix, MarkupBlock expectedMarkup, SourceLocation expectedStart, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.Any) + private void RunSimpleWrappedMarkupTest(string prefix, string markup, string suffix) { - var expected = new StatementBlock( - Factory.Code(prefix).AsStatement(), - expectedMarkup, - Factory.Code(suffix).AsStatement().Accepts(acceptedCharacters)); - - // Since we're building the 'expected' input out of order we need to do some trickery - // to get the locations right. - SpancestryCorrector.Correct(expected); - expected.FindFirstDescendentSpan().ChangeStart(SourceLocation.Zero); - - // We make the caller pass a start location so we can verify that nothing has gone awry. - Assert.Equal(expectedStart, expectedMarkup.Start); - - ParseBlockTest(prefix + markup + suffix, expected); - } - - private void NamespaceImportTest(string content, string expectedNS, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.None, SourceLocation? location = null) - { - ParseBlockTest(content, - new DirectiveBlock( - Factory.Code(content) - .AsNamespaceImport(expectedNS) - .Accepts(acceptedCharacters))); - } - - private static StatementBlock CreateStatementBlock(MarkupBlock block) - { - var factory = new SpanFactory(); - return new StatementBlock( - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - block, - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)); + ParseBlockTest(prefix + markup + suffix); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpCodeParserTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpCodeParserTest.cs new file mode 100644 index 0000000000..ea86c72226 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpCodeParserTest.cs @@ -0,0 +1,215 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy +{ + public class CSharpCodeParserTest + { + public static TheoryData InvalidTagHelperPrefixData + { + get + { + var directiveLocation = new SourceLocation(1, 2, 3); + + RazorDiagnostic InvalidPrefixError(int length, char character, string prefix) + { + return RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(directiveLocation, length), SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix); + } + + return new TheoryData> + { + { + "th ", + directiveLocation, + new[] + { + InvalidPrefixError(3, ' ', "th "), + } + }, + { + "th\t", + directiveLocation, + new[] + { + InvalidPrefixError(3, '\t', "th\t"), + } + }, + { + "th" + Environment.NewLine, + directiveLocation, + new[] + { + InvalidPrefixError(2 + Environment.NewLine.Length, Environment.NewLine[0], "th" + Environment.NewLine), + } + }, + { + " th ", + directiveLocation, + new[] + { + InvalidPrefixError(4, ' ', " th "), + } + }, + { + "@", + directiveLocation, + new[] + { + InvalidPrefixError(1, '@', "@"), + } + }, + { + "t@h", + directiveLocation, + new[] + { + InvalidPrefixError(3, '@', "t@h"), + } + }, + { + "!", + directiveLocation, + new[] + { + InvalidPrefixError(1, '!', "!"), + } + }, + { + "!th", + directiveLocation, + new[] + { + InvalidPrefixError(3, '!', "!th"), + } + }, + }; + } + } + + [Theory] + [MemberData(nameof(InvalidTagHelperPrefixData))] + public void ValidateTagHelperPrefix_ValidatesPrefix( + string directiveText, + SourceLocation directiveLocation, + object expectedErrors) + { + // Arrange + var expectedDiagnostics = (IEnumerable)expectedErrors; + var source = TestRazorSourceDocument.Create(); + var options = RazorParserOptions.CreateDefault(); + var context = new ParserContext(source, options); + + var parser = new CSharpCodeParser(context); + var diagnostics = new List(); + + // Act + parser.ValidateTagHelperPrefix(directiveText, directiveLocation, diagnostics); + + // Assert + Assert.Equal(expectedDiagnostics, diagnostics); + } + + [Theory] + [InlineData("foo,assemblyName", 4)] + [InlineData("foo, assemblyName", 5)] + [InlineData(" foo, assemblyName", 8)] + [InlineData(" foo , assemblyName", 11)] + [InlineData("foo, assemblyName", 8)] + [InlineData(" foo , assemblyName ", 14)] + public void ParseAddOrRemoveDirective_CalculatesAssemblyLocationInLookupText(string text, int assemblyLocation) + { + // Arrange + var source = TestRazorSourceDocument.Create(); + var options = RazorParserOptions.CreateDefault(); + var context = new ParserContext(source, options); + + var parser = new CSharpCodeParser(context); + + var directive = new CSharpCodeParser.ParsedDirective() + { + DirectiveText = text, + }; + + var diagnostics = new List(); + var expected = new SourceLocation(assemblyLocation, 0, assemblyLocation); + + // Act + var result = parser.ParseAddOrRemoveDirective(directive, SourceLocation.Zero, diagnostics); + + // Assert + Assert.Empty(diagnostics); + Assert.Equal("foo", result.TypePattern); + Assert.Equal("assemblyName", result.AssemblyName); + } + + [Theory] + [InlineData("", 1)] + [InlineData("*,", 2)] + [InlineData("?,", 2)] + [InlineData(",", 1)] + [InlineData(",,,", 3)] + [InlineData("First, ", 7)] + [InlineData("First , ", 8)] + [InlineData(" ,Second", 8)] + [InlineData(" , Second", 9)] + [InlineData("SomeType,", 9)] + [InlineData("SomeAssembly", 12)] + [InlineData("First,Second,Third", 18)] + public void ParseAddOrRemoveDirective_CreatesErrorIfInvalidLookupText_DoesNotThrow(string directiveText, int errorLength) + { + // Arrange + var source = TestRazorSourceDocument.Create(); + var options = RazorParserOptions.CreateDefault(); + var context = new ParserContext(source, options); + + var parser = new CSharpCodeParser(context); + + var directive = new CSharpCodeParser.ParsedDirective() + { + DirectiveText = directiveText + }; + + var diagnostics = new List(); + var expectedError = RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(1, 2, 3), errorLength), directiveText); + + // Act + var result = parser.ParseAddOrRemoveDirective(directive, new SourceLocation(1, 2, 3), diagnostics); + + // Assert + Assert.Same(directive, result); + + var error = Assert.Single(diagnostics); + Assert.Equal(expectedError, error); + } + + [Fact] + public void TagHelperPrefixDirective_DuplicatesCauseError() + { + // Arrange + var expectedDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( + new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16), "tagHelperPrefix"); + var source = TestRazorSourceDocument.Create( + @"@tagHelperPrefix ""th:"" +@tagHelperPrefix ""th""", + filePath: null); + + // Act + var document = RazorSyntaxTree.Parse(source); + + // Assert + var directive = document.Root.Children.OfType().Last(); + var erroredSpan = (Span)directive.Children.Last(); + var chunkGenerator = Assert.IsType(erroredSpan.ChunkGenerator); + var diagnostic = Assert.Single(chunkGenerator.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs index 23cda39e22..2452e64f88 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs @@ -28,22 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest( @"@custom System.Text.Encoding.ASCIIEncoding @custom System.Text.Encoding.UTF8Encoding", - new[] { descriptor }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, Environment.NewLine, markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace)), - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.UTF8Encoding", markup: false).AsDirectiveToken(descriptor.Tokens[0])), - Factory.EmptyHtml())); + new[] { descriptor }); } [Fact] @@ -58,37 +43,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; builder.AddTypeToken(); }); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DuplicateDirective( - new SourceSpan(new SourceLocation(42 + Environment.NewLine.Length, 1, 0), 7), "custom")); // Act & Assert ParseDocumentTest( @"@custom System.Text.Encoding.ASCIIEncoding @custom System.Text.Encoding.UTF8Encoding", - new[] { descriptor }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, Environment.NewLine, markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace)), - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.UTF8Encoding", markup: false).AsDirectiveToken(descriptor.Tokens[0])), - Factory.EmptyHtml())); + new[] { descriptor }); } - [Theory] - [InlineData(DirectiveUsage.FileScopedSinglyOccurring)] - [InlineData(DirectiveUsage.FileScopedMultipleOccurring)] - public void DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives(DirectiveUsage directiveUsage) + [Fact] + public void DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives() { // Arrange var customDescriptor = DirectiveDescriptor.CreateDirective( @@ -96,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy DirectiveKind.SingleLine, builder => { - builder.Usage = directiveUsage; + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; builder.AddTypeToken(); }); var somethingDescriptor = DirectiveDescriptor.CreateDirective( @@ -104,7 +68,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy DirectiveKind.SingleLine, builder => { - builder.Usage = directiveUsage; + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; builder.AddMemberToken(); }); @@ -112,28 +76,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest( @"@custom System.Text.Encoding.ASCIIEncoding @something Else", - new[] { customDescriptor, somethingDescriptor }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(customDescriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(customDescriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, Environment.NewLine, markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace)), - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(somethingDescriptor), - Factory.CodeTransition(), - Factory.MetaCode("something").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Else", markup: false).AsDirectiveToken(somethingDescriptor.Tokens[0])), - Factory.EmptyHtml())); + new[] { customDescriptor, somethingDescriptor }); } - [Theory] - [InlineData(DirectiveUsage.FileScopedSinglyOccurring)] - [InlineData(DirectiveUsage.FileScopedMultipleOccurring)] - public void DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives(DirectiveUsage directiveUsage) + [Fact] + public void DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives() { // Arrange var customDescriptor = DirectiveDescriptor.CreateDirective( @@ -141,7 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy DirectiveKind.SingleLine, builder => { - builder.Usage = directiveUsage; + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; builder.AddTypeToken(); }); var somethingDescriptor = DirectiveDescriptor.CreateDirective( @@ -149,7 +96,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy DirectiveKind.SingleLine, builder => { - builder.Usage = directiveUsage; + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; builder.AddMemberToken(); }); @@ -161,33 +108,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy @something Else

This is extra

", - new[] { customDescriptor, somethingDescriptor }, - new MarkupBlock( - Factory.EmptyHtml(), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition).Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol(" There are two directives beneath this ", HtmlSymbolType.RazorComment)).Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition).Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine), - new DirectiveBlock(new DirectiveChunkGenerator(customDescriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(customDescriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, Environment.NewLine, markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace)), - Factory.Markup(Environment.NewLine), - new DirectiveBlock(new DirectiveChunkGenerator(somethingDescriptor), - Factory.CodeTransition(), - Factory.MetaCode("something").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Else", markup: false).AsDirectiveToken(somethingDescriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, Environment.NewLine, markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace)), - Factory.Markup(Environment.NewLine), - BlockFactory.MarkupTagBlock("

"), - Factory.Markup("This is extra"), - BlockFactory.MarkupTagBlock("

"))); + new[] { customDescriptor, somethingDescriptor }); } [Fact] @@ -198,20 +119,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddStringToken().AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace( - new SourceSpan(new SourceLocation(17, 0, 17), 9), "custom")); // Act & Assert ParseCodeBlockTest( "@custom \"string1\"\"string2\"", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"string1\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -222,19 +134,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( - new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( "@custom System.", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -245,19 +149,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( - new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( "@custom System<", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] public void DirectiveDescriptor_CanHandleIncompleteNamespaceTokens() @@ -267,19 +163,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( - new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( "@custom System." + Environment.NewLine, - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -290,19 +178,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( - new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( "@custom System<" + Environment.NewLine, - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -316,68 +196,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest(Environment.NewLine + " @custom System.Text.Encoding.ASCIIEncoding", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.Code(Environment.NewLine + " ").AsStatement(), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] public void BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace() { // Act & Assert - ParseCodeBlockTest(Environment.NewLine + " @addTagHelper \"*, Foo\"", - Enumerable.Empty(), - new DirectiveBlock( - Factory.Code(Environment.NewLine + " ").AsStatement(), - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"*, Foo\"") - .AsAddTagHelper( - "\"*, Foo\"", - "*, Foo", - "*", - "Foo"))); + ParseCodeBlockTest(Environment.NewLine + " @addTagHelper \"*, Foo\""); } [Fact] public void BuiltInDirectiveErrorsIfNotAtStartOfLine() { // Act & Assert - ParseCodeBlockTest("{ @addTagHelper \"*, Foo\"" + Environment.NewLine + "}", - Enumerable.Empty(), - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null, atEndOfSpan: false), - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"*, Foo\"") - .AsAddTagHelper( - "\"*, Foo\"", - "*, Foo", - "*", - "Foo", - RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( - new SourceSpan(new SourceLocation(4, 0, 4), 12), "addTagHelper"))), - Factory.Code(Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + ParseCodeBlockTest("{ @addTagHelper \"*, Foo\"" + Environment.NewLine + "}"); } [Fact] @@ -388,28 +221,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddTypeToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( - new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 6), "custom")); // Act & Assert ParseCodeBlockTest( "{ @custom System.Text.Encoding.ASCIIEncoding" + Environment.NewLine + "}", - new[] { descriptor }, - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null, atEndOfSpan: false), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, Environment.NewLine, markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace)), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + new[] { descriptor }); } [Fact] @@ -424,13 +240,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom System.Text.Encoding.ASCIIEncoding", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -445,13 +255,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom Some_Member", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Some_Member", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -466,13 +270,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom BaseNamespace", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "BaseNamespace", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -487,13 +285,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom BaseNamespace.Foo.Bar", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "BaseNamespace.Foo.Bar", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -508,13 +300,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom \"AString\"", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"AString\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -525,19 +311,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 7), "custom")); // Act & Assert ParseCodeBlockTest( "@custom AString", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -548,19 +326,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "custom")); // Act & Assert ParseCodeBlockTest( "@custom {foo?}", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -571,19 +341,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 9), "custom")); // Act & Assert ParseCodeBlockTest( "@custom 'AString'", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -594,19 +356,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 7), "custom")); // Act & Assert ParseCodeBlockTest( "@custom AString\"", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -621,20 +375,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom System.Text.Encoding.ASCIIEncoding Some_Member \"AString\"", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Some_Member", markup: false).AsDirectiveToken(descriptor.Tokens[1]), - - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"AString\"", markup: false).AsDirectiveToken(descriptor.Tokens[2]))); + new[] { descriptor }); } [Fact] @@ -649,26 +390,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom \"Header\" {

F{o}o

}", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"Header\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{") - .AutoCompleteWith(null, atEndOfSpan: true) - .Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("F", "{", "o", "}", "o"), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + new[] { descriptor }); } [Fact] @@ -683,19 +405,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom \"Name\" { foo(); bar(); }", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"Name\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{") - .AutoCompleteWith(null, atEndOfSpan: true) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code(" foo(); bar(); ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + new[] { descriptor }); } [Fact] @@ -710,19 +420,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom System.Text.Encoding.ASCIIEncoding Some_Member ", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Text.Encoding.ASCIIEncoding", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Some_Member", markup: false).AsDirectiveToken(descriptor.Tokens[1]), - - Factory.Span(SpanKindInternal.None, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -733,19 +431,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddMemberToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "custom")); // Act & Assert ParseCodeBlockTest( "@custom -Some_Member", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -760,70 +450,83 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom \"hello\" ; ", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"hello\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.None, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.MetaCode(";").Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } - [Theory] - [InlineData("string?")] - [InlineData("string?[]")] - [InlineData("global::System.Int32?")] - [InlineData("KeyValuePair?")] - [InlineData("KeyValuePair?[]")] - [InlineData("global::System.Collections.Generic.KeyValuePair?[]")] - public void DirectiveDescriptor_AllowsNullableTypes(string expectedType) + [Fact] + public void DirectiveDescriptor_AllowsNullableTypes() { // Arrange + var variants = new[] + { + "string?", + "string?[]", + "global::System.Int32?", + "KeyValuePair?", + "KeyValuePair?[]", + "global::System.Collections.Generic.KeyValuePair?[]", + }; + + var directiveName = "custom"; + var source = $"@{directiveName}"; var descriptor = DirectiveDescriptor.CreateDirective( - "custom", + directiveName, DirectiveKind.SingleLine, - b => b.AddTypeToken()); + b => + { + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + }); + + for (var i = 0; i < variants.Length; i++) + { + source += $" {variants[i]}"; + } // Act & Assert - ParseCodeBlockTest( - $"@custom {expectedType}", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, expectedType, markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + ParseCodeBlockTest(source, new[] { descriptor }); } - [Theory] - [InlineData("(bool, int)")] - [InlineData("(int aa, string bb)?")] - [InlineData("( int? q , bool w )")] - [InlineData("( int ? q, bool ?w ,(long ? [])) ?")] - [InlineData("(List<(int, string)?> aa, string bb)")] - [InlineData("(string ss, (int u, List<(string, int)> k, (Char c, bool b, List l)), global::System.Int32[] a)")] - public void DirectiveDescriptor_AllowsTupleTypes(string expectedType) + [Fact] + public void DirectiveDescriptor_AllowsTupleTypes() { // Arrange + var variants = new[] + { + "(bool, int)", + "(int aa, string bb)?", + "( int? q , bool w )", + "( int ? q, bool ?w ,(long ? [])) ?", + "(List<(int, string)?> aa, string bb)", + "(string ss, (int u, List<(string, int)> k, (Char c, bool b, List l)), global::System.Int32[] a)", + }; + + var directiveName = "custom"; + var source = $"@{directiveName}"; var descriptor = DirectiveDescriptor.CreateDirective( - "custom", + directiveName, DirectiveKind.SingleLine, - b => b.AddTypeToken()); + b => + { + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + }); + + for (var i = 0; i < variants.Length; i++) + { + source += $" {variants[i]}"; + } // Act & Assert - ParseCodeBlockTest( - $"@custom {expectedType}", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, expectedType, markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + ParseCodeBlockTest(source, new[] { descriptor }); } [Fact] @@ -838,14 +541,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( $"@custom (bool, int?) ", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "(bool, int?)", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.None, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -856,22 +552,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.SingleLine, b => b.AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( - new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 7), "custom", "line break")); // Act & Assert ParseCodeBlockTest( "@custom \"hello\" \"world\"", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"hello\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - - Factory.Span(SpanKindInternal.None, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -882,22 +567,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.CodeBlock, b => b.AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( - new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 5), "custom", "{")); // Act & Assert ParseCodeBlockTest( "@custom \"Hello\" World { foo(); bar(); }", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"Hello\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.AllWhiteSpace))); + new[] { descriptor }); } [Fact] @@ -908,20 +582,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.CodeBlock, b => b.AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( - new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "custom", "{")); // Act & Assert ParseCodeBlockTest( "@custom \"Hello\"", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"Hello\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -932,572 +597,144 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "custom", DirectiveKind.CodeBlock, b => b.AddStringToken()); - var chunkGenerator = new DirectiveChunkGenerator(descriptor); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "custom", "}", "{")); // Act & Assert ParseCodeBlockTest( "@custom \"Hello\" {", - new[] { descriptor }, - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"Hello\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{") - .AutoCompleteWith("}", atEndOfSpan: true) - .Accepts(AcceptedCharactersInternal.None))); - } - - [Fact] - public void TagHelperPrefixDirective_DuplicatesCauseError() - { - // Arrange - var expectedDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( - new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16), "tagHelperPrefix"); - - // Act - var document = ParseDocument( -@"@tagHelperPrefix ""th:"" -@tagHelperPrefix ""th""", - directives: null, - designTime: false); - - // Assert - var directive = document.Root.Children.OfType().Last(); - var erroredSpan = (Span)directive.Children.Last(); - var chunkGenerator = Assert.IsType(erroredSpan.ChunkGenerator); - var diagnostic = Assert.Single(chunkGenerator.Diagnostics); - Assert.Equal(expectedDiagnostic, diagnostic); + new[] { descriptor }); } [Fact] public void TagHelperPrefixDirective_NoValueSucceeds() { - ParseBlockTest("@tagHelperPrefix \"\"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.TagHelperPrefixKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\"") - .AsTagHelperPrefixDirective("\"\"", string.Empty))); + ParseBlockTest("@tagHelperPrefix \"\""); } [Fact] public void TagHelperPrefixDirective_Succeeds() { - ParseBlockTest("@tagHelperPrefix Foo", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.TagHelperPrefixKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("Foo") - .AsTagHelperPrefixDirective("Foo", "Foo"))); + ParseBlockTest("@tagHelperPrefix Foo"); } [Fact] public void TagHelperPrefixDirective_WithQuotes_Succeeds() { - ParseBlockTest("@tagHelperPrefix \"Foo\"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.TagHelperPrefixKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"Foo\"") - .AsTagHelperPrefixDirective("\"Foo\"", "Foo"))); + ParseBlockTest("@tagHelperPrefix \"Foo\""); } [Fact] public void TagHelperPrefixDirective_RequiresValue() { - // Arrange - var expectedError = RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( - new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 15), SyntaxConstants.CSharp.TagHelperPrefixKeyword); - - // Act & Assert - ParseBlockTest("@tagHelperPrefix ", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.TagHelperPrefixKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsTagHelperPrefixDirective(string.Empty, string.Empty, expectedError) - .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); + ParseBlockTest("@tagHelperPrefix "); } [Fact] public void TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue() { - // Arrange - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), - RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.TagHelperPrefixKeyword), - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.TagHelperPrefixKeyword, '"', "\"Foo"), - }; - - // Act & Assert - ParseBlockTest("@tagHelperPrefix \"Foo", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.TagHelperPrefixKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"Foo") - .AsTagHelperPrefixDirective("\"Foo", "\"Foo", expectedErrors))); + ParseBlockTest("@tagHelperPrefix \"Foo"); } [Fact] public void TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue() { - // Arrange - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(filePath: null, absoluteIndex: 23, lineIndex: 0, characterIndex: 23, length: 1)), - RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 7), SyntaxConstants.CSharp.TagHelperPrefixKeyword), - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 7), SyntaxConstants.CSharp.TagHelperPrefixKeyword, ' ', "Foo \""), - }; - - // Act & Assert - ParseBlockTest("@tagHelperPrefix Foo \"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.TagHelperPrefixKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("Foo \"") - .AsTagHelperPrefixDirective("Foo \"", "Foo \"", expectedErrors))); + ParseBlockTest("@tagHelperPrefix Foo \""); } [Fact] public void RemoveTagHelperDirective_NoValue_Invalid() { - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(18, 0, 18), contentLength: 1), string.Empty) - }; - - ParseBlockTest("@removeTagHelper \"\"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.RemoveTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\"") - .AsRemoveTagHelper( - "\"\"", - string.Empty, - errors: expectedErrors))); + ParseBlockTest("@removeTagHelper \"\""); } [Fact] public void RemoveTagHelperDirective_InvalidLookupText_AddsError() { - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 3), "Foo") - }; - - ParseBlockTest("@removeTagHelper Foo", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.RemoveTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("Foo") - .AsRemoveTagHelper( - "Foo", - "Foo", - errors: expectedErrors))); + ParseBlockTest("@removeTagHelper Foo"); } [Fact] public void RemoveTagHelperDirective_SingleQuotes_AddsError() { - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 8), "'*, Foo'") - }; - - ParseBlockTest("@removeTagHelper '*, Foo'", - new DirectiveBlock( - Factory.CodeTransition(), - Factory.MetaCode(SyntaxConstants.CSharp.RemoveTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("'*, Foo'") - .AsRemoveTagHelper( - "'*, Foo'", - "'*, Foo'", - errors: expectedErrors))); + ParseBlockTest("@removeTagHelper '*, Foo'"); } [Fact] public void RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError() { - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(18, 0, 18), contentLength: 3), "Foo") - }; - - ParseBlockTest("@removeTagHelper \"Foo\"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.RemoveTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"Foo\"") - .AsRemoveTagHelper( - "\"Foo\"", - "Foo", - errors: expectedErrors))); + ParseBlockTest("@removeTagHelper \"Foo\""); } [Fact] public void RemoveTagHelperDirective_SupportsSpaces() { - ParseBlockTest("@removeTagHelper Foo, Bar ", - new DirectiveBlock( - Factory.CodeTransition(), - Factory.MetaCode(SyntaxConstants.CSharp.RemoveTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("Foo, Bar ") - .AsRemoveTagHelper( - "Foo, Bar", - "Foo, Bar", - "Foo", - "Bar") - .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); + ParseBlockTest("@removeTagHelper Foo, Bar "); } [Fact] public void RemoveTagHelperDirective_RequiresValue() { - // Arrange - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( - new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 15), SyntaxConstants.CSharp.RemoveTagHelperKeyword), - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 1), string.Empty), - }; - - // Act & Assert - ParseBlockTest("@removeTagHelper ", - new DirectiveBlock( - Factory.CodeTransition(), - Factory.MetaCode(SyntaxConstants.CSharp.RemoveTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsRemoveTagHelper(string.Empty, string.Empty, errors: expectedErrors) - .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); + ParseBlockTest("@removeTagHelper "); } [Fact] public void RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue() { // Arrange - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), - RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.RemoveTagHelperKeyword), - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 4), "\"Foo"), - }; - - // Act & Assert - ParseBlockTest("@removeTagHelper \"Foo", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.RemoveTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"Foo") - .AsRemoveTagHelper("\"Foo", "\"Foo", errors: expectedErrors))); + ParseBlockTest("@removeTagHelper \"Foo"); } [Fact] public void RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue() { - // Arrange - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(absoluteIndex: 20, lineIndex: 0, characterIndex: 20), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.RemoveTagHelperKeyword), - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 4), "Foo\""), - }; - - // Act & Assert - ParseBlockTest("@removeTagHelper Foo\"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.RemoveTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("Foo\"") - .AsRemoveTagHelper("Foo\"", "Foo\"", errors: expectedErrors) - .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); + ParseBlockTest("@removeTagHelper Foo\""); } [Fact] public void AddTagHelperDirective_NoValue_Invalid() { - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), string.Empty), - }; - - ParseBlockTest("@addTagHelper \"\"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\"") - .AsAddTagHelper( - "\"\"", - string.Empty, - errors: expectedErrors))); + ParseBlockTest("@addTagHelper \"\""); } [Fact] public void AddTagHelperDirective_InvalidLookupText_AddsError() { - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 3), "Foo"), - }; - - ParseBlockTest("@addTagHelper Foo", - new DirectiveBlock( - Factory.CodeTransition(), - Factory.MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("Foo") - .AsAddTagHelper( - "Foo", - "Foo", - errors: expectedErrors))); + ParseBlockTest("@addTagHelper Foo"); } [Fact] public void AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError() { - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 3), "Foo") - }; - - ParseBlockTest("@addTagHelper \"Foo\"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"Foo\"") - .AsAddTagHelper( - "\"Foo\"", - "Foo", - errors: expectedErrors))); + ParseBlockTest("@addTagHelper \"Foo\""); } [Fact] public void AddTagHelperDirective_SingleQuotes_AddsError() { - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 8), "'*, Foo'") - }; - - ParseBlockTest("@addTagHelper '*, Foo'", - new DirectiveBlock( - Factory.CodeTransition(), - Factory.MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("'*, Foo'") - .AsAddTagHelper( - "'*, Foo'", - "'*, Foo'", - errors: expectedErrors))); + ParseBlockTest("@addTagHelper '*, Foo'"); } [Fact] public void AddTagHelperDirective_SupportsSpaces() { - ParseBlockTest("@addTagHelper Foo, Bar ", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("Foo, Bar ") - .AsAddTagHelper( - "Foo, Bar", - "Foo, Bar", - "Foo", - "Bar") - .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); + ParseBlockTest("@addTagHelper Foo, Bar "); } [Fact] public void AddTagHelperDirective_RequiresValue() { - // Arrange - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( - new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 12), SyntaxConstants.CSharp.AddTagHelperKeyword), - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), string.Empty), - }; - - // Act & Assert - ParseBlockTest("@addTagHelper ", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsAddTagHelper(string.Empty, string.Empty, errors: expectedErrors) - .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); + ParseBlockTest("@addTagHelper "); } [Fact] public void AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue() { - // Arrange - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 1)), - RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( - new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 4), SyntaxConstants.CSharp.AddTagHelperKeyword), - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), "\"Foo"), - }; - - // Act & Assert - ParseBlockTest("@addTagHelper \"Foo", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"Foo") - .AsAddTagHelper("\"Foo", "\"Foo", errors: expectedErrors))); + ParseBlockTest("@addTagHelper \"Foo"); } [Fact] public void AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue() { - // Arrange - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), - RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( - new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 4), SyntaxConstants.CSharp.AddTagHelperKeyword), - RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), "Foo\""), - }; - - // Act & Assert - ParseBlockTest("@addTagHelper Foo\"", - new DirectiveBlock( - Factory.CodeTransition(), - Factory - .MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword) - .Accepts(AcceptedCharactersInternal.None), - Factory - .Span(SpanKindInternal.Markup, " ", markup: false) - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("Foo\"") - .AsAddTagHelper("Foo\"", "Foo\"", errors: expectedErrors) - .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); + ParseBlockTest("@addTagHelper Foo\""); } [Fact] @@ -1505,15 +742,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseDocumentTest( "@inherits string[[]][]", - new[] { InheritsDirective.Directive, }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(InheritsDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "string[[]][]", markup: false).AsDirectiveToken(InheritsDirective.Directive.Tokens.First())), - Factory.EmptyHtml())); + new[] { InheritsDirective.Directive, }); } [Fact] @@ -1521,16 +750,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseDocumentTest( "@inherits System.Web.Mvc.WebViewPage>", - new[] { InheritsDirective.Directive, }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(InheritsDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.Web.Mvc.WebViewPage>", markup: false) - .AsDirectiveToken(InheritsDirective.Directive.Tokens.First())), - Factory.EmptyHtml())); + new[] { InheritsDirective.Directive, }); } [Fact] @@ -1538,16 +758,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseDocumentTest( "@inherits string", - new[] { InheritsDirective.Directive, }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(InheritsDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "string", markup: false) - .AsDirectiveToken(InheritsDirective.Directive.Tokens.First())), - Factory.EmptyHtml())); + new[] { InheritsDirective.Directive, }); } [Fact] @@ -1555,14 +766,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseCodeBlockTest( "@functions { foo(); bar(); }", - new[] { FunctionsDirective.Directive, }, - new DirectiveBlock(new DirectiveChunkGenerator(FunctionsDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("functions").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - Factory.Code(" foo(); bar(); ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + new[] { FunctionsDirective.Directive, }); } [Fact] @@ -1570,14 +774,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseCodeBlockTest( "@functions { }", - new[] { FunctionsDirective.Directive, }, - new DirectiveBlock(new DirectiveChunkGenerator(FunctionsDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("functions").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - Factory.Code(" ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + new[] { FunctionsDirective.Directive, }); } [Fact] @@ -1585,25 +782,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseCodeBlockTest( "@section Header {

F{o}o

}", - new[] { SectionDirective.Directive, }, - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Header", CSharpSymbolType.Identifier) - .AsDirectiveToken(SectionDirective.Directive.Tokens.First()), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("F", "{", "o", "}", "o"), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(" ")), - Factory.MetaCode("}") - .Accepts(AcceptedCharactersInternal.None))); + new[] { SectionDirective.Directive, }); } [Fact] @@ -1618,12 +797,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom ", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace))); + new[] { descriptor }); } [Fact] @@ -1638,14 +812,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom \"simple-value\"", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"simple-value\"", markup: false) - .AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -1660,14 +827,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom \"{formaction}?/{id}?\"", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"{formaction}?/{id}?\"", markup: false) - .AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -1682,15 +842,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@custom \"{formaction}?/{id}?\" System.String", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("custom").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "\"{formaction}?/{id}?\"", markup: false).AsDirectiveToken(descriptor.Tokens[0]), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "System.String", markup: false).AsDirectiveToken(descriptor.Tokens.Last()))); + new[] { descriptor }); } [Fact] @@ -1705,14 +857,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@TestDirective ", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("TestDirective").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) - .AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -1727,13 +872,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@TestDirective PropertyName", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("TestDirective").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", markup: false).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "PropertyName", markup: false).AsDirectiveToken(descriptor.Tokens[0]))); + new[] { descriptor }); } [Fact] @@ -1747,11 +886,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@class", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("class").Accepts(AcceptedCharactersInternal.None))); + new[] { descriptor }); } [Fact] @@ -1765,201 +900,23 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseCodeBlockTest( "@namespace", - new[] { descriptor }, - new DirectiveBlock( - new DirectiveChunkGenerator(descriptor), - Factory.CodeTransition(), - Factory.MetaCode("namespace").Accepts(AcceptedCharactersInternal.None))); + new[] { descriptor }); } - public static TheoryData InvalidTagHelperPrefixData + internal virtual void ParseCodeBlockTest(string document) { - get - { - var directiveLocation = new SourceLocation(1, 2, 3); - - RazorDiagnostic InvalidPrefixError(int length, char character, string prefix) - { - return RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( - new SourceSpan(directiveLocation, length), SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix); - } - - return new TheoryData> - { - { - "th ", - directiveLocation, - new[] - { - InvalidPrefixError(3, ' ', "th "), - } - }, - { - "th\t", - directiveLocation, - new[] - { - InvalidPrefixError(3, '\t', "th\t"), - } - }, - { - "th" + Environment.NewLine, - directiveLocation, - new[] - { - InvalidPrefixError(2 + Environment.NewLine.Length, Environment.NewLine[0], "th" + Environment.NewLine), - } - }, - { - " th ", - directiveLocation, - new[] - { - InvalidPrefixError(4, ' ', " th "), - } - }, - { - "@", - directiveLocation, - new[] - { - InvalidPrefixError(1, '@', "@"), - } - }, - { - "t@h", - directiveLocation, - new[] - { - InvalidPrefixError(3, '@', "t@h"), - } - }, - { - "!", - directiveLocation, - new[] - { - InvalidPrefixError(1, '!', "!"), - } - }, - { - "!th", - directiveLocation, - new[] - { - InvalidPrefixError(3, '!', "!th"), - } - }, - }; - } - } - - [Theory] - [MemberData(nameof(InvalidTagHelperPrefixData))] - public void ValidateTagHelperPrefix_ValidatesPrefix( - string directiveText, - SourceLocation directiveLocation, - object expectedErrors) - { - // Arrange - var expectedDiagnostics = (IEnumerable)expectedErrors; - var source = TestRazorSourceDocument.Create(); - var options = RazorParserOptions.CreateDefault(); - var context = new ParserContext(source, options); - - var parser = new CSharpCodeParser(context); - var diagnostics = new List(); - - // Act - parser.ValidateTagHelperPrefix(directiveText, directiveLocation, diagnostics); - - // Assert - Assert.Equal(expectedDiagnostics, diagnostics); - } - - [Theory] - [InlineData("foo,assemblyName", 4)] - [InlineData("foo, assemblyName", 5)] - [InlineData(" foo, assemblyName", 8)] - [InlineData(" foo , assemblyName", 11)] - [InlineData("foo, assemblyName", 8)] - [InlineData(" foo , assemblyName ", 14)] - public void ParseAddOrRemoveDirective_CalculatesAssemblyLocationInLookupText(string text, int assemblyLocation) - { - // Arrange - var source = TestRazorSourceDocument.Create(); - var options = RazorParserOptions.CreateDefault(); - var context = new ParserContext(source, options); - - var parser = new CSharpCodeParser(context); - - var directive = new CSharpCodeParser.ParsedDirective() - { - DirectiveText = text, - }; - - var diagnostics = new List(); - var expected = new SourceLocation(assemblyLocation, 0, assemblyLocation); - - // Act - var result = parser.ParseAddOrRemoveDirective(directive, SourceLocation.Zero, diagnostics); - - // Assert - Assert.Empty(diagnostics); - Assert.Equal("foo", result.TypePattern); - Assert.Equal("assemblyName", result.AssemblyName); - } - - [Theory] - [InlineData("", 1)] - [InlineData("*,", 2)] - [InlineData("?,", 2)] - [InlineData(",", 1)] - [InlineData(",,,", 3)] - [InlineData("First, ", 7)] - [InlineData("First , ", 8)] - [InlineData(" ,Second", 8)] - [InlineData(" , Second", 9)] - [InlineData("SomeType,", 9)] - [InlineData("SomeAssembly", 12)] - [InlineData("First,Second,Third", 18)] - public void ParseAddOrRemoveDirective_CreatesErrorIfInvalidLookupText_DoesNotThrow(string directiveText, int errorLength) - { - // Arrange - var source = TestRazorSourceDocument.Create(); - var options = RazorParserOptions.CreateDefault(); - var context = new ParserContext(source, options); - - var parser = new CSharpCodeParser(context); - - var directive = new CSharpCodeParser.ParsedDirective() - { - DirectiveText = directiveText - }; - - var diagnostics = new List(); - var expectedError = RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( - new SourceSpan(new SourceLocation(1, 2, 3), errorLength), directiveText); - - // Act - var result = parser.ParseAddOrRemoveDirective(directive, new SourceLocation(1, 2, 3), diagnostics); - - // Assert - Assert.Same(directive, result); - - var error = Assert.Single(diagnostics); - Assert.Equal(expectedError, error); + ParseCodeBlockTest(document, Array.Empty()); } internal virtual void ParseCodeBlockTest( string document, IEnumerable descriptors, - Block expected, + Block expected = null, params RazorDiagnostic[] expectedErrors) { var result = ParseCodeBlock(RazorLanguageVersion.Latest, document, descriptors, designTime: false); - EvaluateResults(result, expected, expectedErrors); + BaselineTest(result); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs index 4d792c1a31..a5cf944e98 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs @@ -10,645 +10,336 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public class CSharpErrorTest : CsHtmlCodeParserTestBase { [Fact] - public void ParseBlockHandlesQuotesAfterTransition() + public void HandlesQuotesAfterTransition() { - ParseBlockTest("@\"", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(KeywordSet) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), - "\"")); + ParseBlockTest("@\""); } [Fact] - public void ParseBlockWithHelperDirectiveProducesError() + public void WithHelperDirectiveProducesError() { - ParseBlockTest("@helper fooHelper { }", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("helper") - .AsImplicitExpression(KeywordSet) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 6))); + ParseBlockTest("@helper fooHelper { }"); } [Fact] - public void ParseBlockWithNestedCodeBlockProducesError() + public void WithNestedCodeBlockProducesError() { - ParseBlockTest("@if { @{} }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if { ") - .AsStatement() - .Accepts(AcceptedCharactersInternal.Any), - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.Code(" }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.Any)), - RazorDiagnosticFactory.CreateParsing_UnexpectedNestedCodeBlock( - new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1))); + ParseBlockTest("@if { @{} }"); } [Fact] - public void ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode() + public void CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode() { + // ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode ParseBlockTest("using " + Environment.NewLine - + Environment.NewLine, - new StatementBlock( - Factory.Code("using " + Environment.NewLine).AsStatement() - )); + + Environment.NewLine); } [Fact] - public void ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace() + public void MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace() { - ParseBlockTest("{", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); + ParseBlockTest("{"); } [Fact] - public void ParseBlockMethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty() + public void MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty() { - ParseBlockTest("{}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("{}"); } [Fact] - public void ParseBlockMethodProducesErrorIfNewlineFollowsTransition() + public void MethodProducesErrorIfNewlineFollowsTransition() { - ParseBlockTest("@" + Environment.NewLine, - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), Environment.NewLine.Length))); + ParseBlockTest("@" + Environment.NewLine); } [Fact] - public void ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression() + public void MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr() { + // ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression ParseBlockTest("{" + Environment.NewLine + " @ {}" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + " ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Code(" {}" + Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), - RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 3))); + + "}"); } [Fact] - public void ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression() + public void MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression() { ParseBlockTest("{" + Environment.NewLine - + " @", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + " ") - .AsStatement() - .AutoCompleteWith("}"), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.EmptyCSharp().AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); + + " @"); } [Fact] - public void ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace() + public void MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace() { - ParseBlockTest("@!!!", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), - "!")); + ParseBlockTest("@!!!"); } [Fact] - public void ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed() + public void ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed() { + // ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed ParseBlockTest("(foo bar" + Environment.NewLine - + "baz", - new ExpressionBlock( - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code($"foo bar{Environment.NewLine}baz").AsExpression() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_ExplicitExpression, ")", "(")); + + "baz"); } [Fact] - public void ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed() + public void ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed() { + // ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed ParseBlockTest("(foo bar" + Environment.NewLine + "" + Environment.NewLine + "baz" + Environment.NewLine - + "@Html.Foo(Bar);" + Environment.NewLine, - new ExpressionBlock( - Factory.Code("Href(" + Environment.NewLine) - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); + + "

@Html.Foo(Bar);

" + Environment.NewLine); } [Fact] // Test for fix to Dev10 884975 - Incorrect Error Messaging - public void ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed() + public void ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed() { + // ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed ParseBlockTest("Foo(Bar(Baz)" + Environment.NewLine + "Biz" + Environment.NewLine - + "Boz", - new ExpressionBlock( - Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}Boz") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "(", ")")); + + "Boz"); } [Fact] // Test for fix to Dev10 884975 - Incorrect Error Messaging - public void ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed() + public void ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed() { + // ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed ParseBlockTest("Foo(Bar(Baz)" + Environment.NewLine + "Biz" + Environment.NewLine + "" + Environment.NewLine + "Boz" + Environment.NewLine - + "", - new ExpressionBlock( - Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "(", ")")); + + ""); } [Fact] // Test for fix to Dev10 884975 - Incorrect Error Messaging - public void ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed() + public void ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed() { + // ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed ParseBlockTest("Foo[Bar[Baz]" + Environment.NewLine + "Biz" + Environment.NewLine - + "Boz", - new ExpressionBlock( - Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}Boz") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "[", "]")); + + "Boz"); } [Fact] // Test for fix to Dev10 884975 - Incorrect Error Messaging - public void ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed() + public void ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed() { + // ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed ParseBlockTest("Foo[Bar[Baz]" + Environment.NewLine + "Biz" + Environment.NewLine + "" + Environment.NewLine + "Boz" + Environment.NewLine - + "", - new ExpressionBlock( - Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "[", "]")); + + ""); } // Simple EOF handling errors: [Fact] - public void ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF() + public void ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF() { - ParseBlockTest("{ var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = bar; if(foo != null) { bar(); } ") - .AsStatement() - .AutoCompleteWith("}")), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); + ParseBlockTest("{ var foo = bar; if(foo != null) { bar(); } "); } [Fact] - public void ParseBlockReportsErrorIfClassBlockUnterminatedAtEOF() + public void ReportsErrorIfClassBlockUnterminatedAtEOF() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); - - // Act & Assert ParseBlockTest( "functions { var foo = bar; if(foo != null) { bar(); } ", - new[] { FunctionsDirective.Directive }, - new DirectiveBlock(chunkGenerator, - Factory.MetaCode("functions").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = bar; if(foo != null) { bar(); } ").AsStatement())); + new[] { FunctionsDirective.Directive }); } [Fact] - public void ParseBlockReportsErrorIfIfBlockUnterminatedAtEOF() + public void ReportsErrorIfIfBlockUnterminatedAtEOF() { RunUnterminatedSimpleKeywordBlock("if"); } [Fact] - public void ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF() + public void ReportsErrorIfElseBlockUnterminatedAtEOF() { - ParseBlockTest("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else", "}", "{")); + ParseBlockTest("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } "); } [Fact] - public void ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF() + public void ReportsErrorIfElseIfBlockUnterminatedAtEOF() { - ParseBlockTest("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else if", "}", "{")); + ParseBlockTest("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } "); } [Fact] - public void ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF() + public void ReportsErrorIfDoBlockUnterminatedAtEOF() { - ParseBlockTest("do { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "do", "}", "{")); + ParseBlockTest("do { var foo = bar; if(foo != null) { bar(); } "); } [Fact] - public void ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF() + public void ReportsErrorIfTryBlockUnterminatedAtEOF() { - ParseBlockTest("try { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "try", "}", "{")); + ParseBlockTest("try { var foo = bar; if(foo != null) { bar(); } "); } [Fact] - public void ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF() + public void ReportsErrorIfCatchBlockUnterminatedAtEOF() { - ParseBlockTest("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "catch", "}", "{")); + ParseBlockTest("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } "); } [Fact] - public void ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF() + public void ReportsErrorIfFinallyBlockUnterminatedAtEOF() { - ParseBlockTest("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "finally", "}", "{")); + ParseBlockTest("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } "); } [Fact] - public void ParseBlockReportsErrorIfForBlockUnterminatedAtEOF() + public void ReportsErrorIfForBlockUnterminatedAtEOF() { RunUnterminatedSimpleKeywordBlock("for"); } [Fact] - public void ParseBlockReportsErrorIfForeachBlockUnterminatedAtEOF() + public void ReportsErrorIfForeachBlockUnterminatedAtEOF() { RunUnterminatedSimpleKeywordBlock("foreach"); } [Fact] - public void ParseBlockReportsErrorIfWhileBlockUnterminatedAtEOF() + public void ReportsErrorIfWhileBlockUnterminatedAtEOF() { RunUnterminatedSimpleKeywordBlock("while"); } [Fact] - public void ParseBlockReportsErrorIfSwitchBlockUnterminatedAtEOF() + public void ReportsErrorIfSwitchBlockUnterminatedAtEOF() { RunUnterminatedSimpleKeywordBlock("switch"); } [Fact] - public void ParseBlockReportsErrorIfLockBlockUnterminatedAtEOF() + public void ReportsErrorIfLockBlockUnterminatedAtEOF() { RunUnterminatedSimpleKeywordBlock("lock"); } [Fact] - public void ParseBlockReportsErrorIfUsingBlockUnterminatedAtEOF() + public void ReportsErrorIfUsingBlockUnterminatedAtEOF() { RunUnterminatedSimpleKeywordBlock("using"); } [Fact] - public void ParseBlockRequiresControlFlowStatementsToHaveBraces() + public void RequiresControlFlowStatementsToHaveBraces() { - var expectedMessage = Resources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", "<"); - ParseBlockTest("if(foo)

Bar

else if(bar)

Baz

else

Boz

", - new StatementBlock( - Factory.Code("if(foo) ").AsStatement(), - new MarkupBlock( - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Bar"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("else if(bar) ").AsStatement(), - new MarkupBlock( - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Baz"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("else ").AsStatement(), - new MarkupBlock( - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Boz"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None)), - Factory.EmptyCSharp().AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "{", "<"), - RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(new SourceLocation(32, 0, 32), contentLength: 1), "{", "<"), - RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(new SourceLocation(48, 0, 48), contentLength: 1), "{", "<")); + ParseBlockTest("if(foo)

Bar

else if(bar)

Baz

else

Boz

"); } [Fact] - public void ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError() + public void IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError() { - ParseBlockTest("if(foo)) { var bar = foo; }", - new StatementBlock( - Factory.Code("if(foo)) { var bar = foo; }").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "{", ")")); + ParseBlockTest("if(foo)) { var bar = foo; }"); } [Fact] - public void ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart() + public void OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart() { - ParseBlockTest("if(foo) { @

Bar

}", - new StatementBlock( - Factory.Code("if(foo) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - Factory.MarkupTransition(), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Bar"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( - new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1))); + ParseBlockTest("if(foo) { @

Bar

}"); } [Fact] - public void ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen() + public void TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen() { ParseBlockTest("if(foo bar" + Environment.NewLine - + "baz", - new StatementBlock( - Factory.Code("if(foo bar" + Environment.NewLine).AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), "(", ")")); + + "baz"); } [Fact] - public void ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen() + public void TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen() { ParseBlockTest("foreach(foo bar" + Environment.NewLine - + "baz", - new StatementBlock( - Factory.Code("foreach(foo bar" + Environment.NewLine).AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "(", ")")); + + "baz"); } [Fact] - public void ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen() + public void TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen() { ParseBlockTest("do { } while(foo bar" + Environment.NewLine - + "baz", - new StatementBlock( - Factory.Code("do { } while(foo bar" + Environment.NewLine).AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1), "(", ")")); + + "baz"); } [Fact] - public void ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen() + public void TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen() { ParseBlockTest("using(foo bar" + Environment.NewLine - + "baz", - new StatementBlock( - Factory.Code("using(foo bar" + Environment.NewLine).AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 1), "(", ")")); + + "baz"); } [Fact] - public void ParseBlockResumesIfStatementAfterOpenParen() + public void ResumesIfStatementAfterOpenParen() { ParseBlockTest("if(" + Environment.NewLine - + "else {

Foo

}", - new StatementBlock( - Factory.Code($"if({Environment.NewLine}else {{").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), "(", ")")); + + "else {

Foo

}"); } [Fact] - public void ParseBlockTerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing() + public void TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing() { SingleSpanBlockTest("if(foo) {" + Environment.NewLine + " var p = \"foo bar baz" + Environment.NewLine + ";" + Environment.NewLine - + "}", - BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(21 + Environment.NewLine.Length, 1, 12), contentLength: 1))); + + "}"); } [Fact] - public void ParseBlockTerminatesNormalStringAtEndOfFile() + public void TerminatesNormalStringAtEndOfFile() { - SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); + SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah"); } [Fact] - public void ParseBlockTerminatesVerbatimStringAtEndOfFile() + public void TerminatesVerbatimStringAtEndOfFile() { SingleSpanBlockTest("if(foo) { var foo = @\"blah " + Environment.NewLine + "blah; " + Environment.NewLine + "

Foo

" + Environment.NewLine + "blah " + Environment.NewLine - + "blah", - BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); + + "blah"); } [Fact] - public void ParseBlockCorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement() + public void CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement() { ParseBlockTest("if(foo) {" + Environment.NewLine + " var foo = \"foo bar baz" + Environment.NewLine + "

Foo is @foo

" + Environment.NewLine - + "}", - new StatementBlock( - Factory.Code($"if(foo) {{{Environment.NewLine} var foo = \"foo bar baz{Environment.NewLine} ").AsStatement(), - new MarkupBlock( - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo is "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(23 + Environment.NewLine.Length, 1, 14), contentLength: 1))); + + "}"); } [Fact] - public void ParseBlockCorrectlyParsesAtSignInDelimitedBlock() + public void CorrectlyParsesAtSignInDelimitedBlock() { - ParseBlockTest("(Request[\"description\"] ?? @photo.Description)", - new ExpressionBlock( - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("Request[\"description\"] ?? @photo.Description").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("(Request[\"description\"] ?? @photo.Description)"); } [Fact] - public void ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode() + public void CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode() { - ParseBlockTest(@"{string.Format(}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code("string.Format(") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None), - BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None)), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - expectedErrors: new[] - { - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "(", ")"), - }); + ParseBlockTest(@"{string.Format(}"); } private void RunUnterminatedSimpleKeywordBlock(string keyword) { SingleSpanBlockTest( - keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ", - BlockKindInternal.Statement, - SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), keyword, "}", "{")); + keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } "); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs index afc2afa90a..9d15295d99 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs @@ -9,131 +9,68 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public class CSharpExplicitExpressionTest : CsHtmlCodeParserTestBase { [Fact] - public void ParseBlockShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty() + public void ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty() { - ParseBlockTest("@()", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp().AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@()"); } [Fact] - public void ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression() + public void ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr() { - ParseBlockTest("@(", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp().AsExpression() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), - Resources.BlockName_ExplicitExpression, - ")", - "(")); + // ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression + ParseBlockTest("@("); } [Fact] - public void ParseBlockShouldAcceptEscapedQuoteInNonVerbatimStrings() + public void ShouldAcceptEscapedQuoteInNonVerbatimStrings() { - ParseBlockTest("@(\"\\\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\\\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(\"\\\"\")"); } [Fact] - public void ParseBlockShouldAcceptEscapedQuoteInVerbatimStrings() + public void ShouldAcceptEscapedQuoteInVerbatimStrings() { - ParseBlockTest("@(@\"\"\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("@\"\"\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(@\"\"\"\")"); } [Fact] - public void ParseBlockShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings() + public void ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings() { - ParseBlockTest("@(@\"\"\"\"\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("@\"\"\"\"\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(@\"\"\"\"\"\")"); } [Fact] - public void ParseBlockShouldAcceptMultiLineVerbatimStrings() + public void ShouldAcceptMultiLineVerbatimStrings() { ParseBlockTest(@"@(@""" + Environment.NewLine + @"Foo" + Environment.NewLine + @"Bar" + Environment.NewLine + @"Baz" + Environment.NewLine - + @""")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code($"@\"{Environment.NewLine}Foo{Environment.NewLine}Bar{Environment.NewLine}Baz{Environment.NewLine}\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + + @""")"); } [Fact] - public void ParseBlockShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings() + public void ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings() { - ParseBlockTest("@(\"\\\"hello, world\\\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\\\"hello, world\\\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(\"\\\"hello, world\\\"\")"); } [Fact] - public void ParseBlockShouldAcceptMultipleEscapedQuotesInVerbatimStrings() + public void ShouldAcceptMultipleEscapedQuotesInVerbatimStrings() { - ParseBlockTest("@(@\"\"\"hello, world\"\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("@\"\"\"hello, world\"\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(@\"\"\"hello, world\"\"\")"); } [Fact] - public void ParseBlockShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings() + public void ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings() { - ParseBlockTest("@(\"\\\"\\\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\\\"\\\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(\"\\\"\\\"\")"); } [Fact] - public void ParseBlockShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings() + public void ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings() { - ParseBlockTest("@(@\"\"\"\"\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("@\"\"\"\"\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(@\"\"\"\"\"\")"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs index 3a013a6ec8..f46d227df9 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs @@ -1,282 +1,379 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpImplicitExpressionTest : CsHtmlCodeParserTestBase { - private const string TestExtraKeyword = "model"; - - public static TheoryData NullConditionalOperatorData_Bracket - { - get - { - var noErrors = new RazorDiagnostic[0]; - Func missingEndBracketError = (index) => - new RazorDiagnostic[1] - { - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(index, 0, index), contentLength: 1), "[", "]"), - }; - - // implicitExpression, expectedImplicitExpression, acceptedCharacters, expectedErrors - return new TheoryData - { - { "val??[", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val??[0", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[", "val?[", AcceptedCharactersInternal.Any, missingEndBracketError(5) }, - { "val?(", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[more", "val?[more", AcceptedCharactersInternal.Any, missingEndBracketError(5) }, - { "val?[0]", "val?[0]", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[

", "val?[", AcceptedCharactersInternal.Any, missingEndBracketError(5) }, - { "val?[more.

", "val?[more.", AcceptedCharactersInternal.Any, missingEndBracketError(5) }, - { "val??[more

", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[-1]?", "val?[-1]", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[abc]?[def", "val?[abc]?[def", AcceptedCharactersInternal.Any, missingEndBracketError(11) }, - { "val?[abc]?[2]", "val?[abc]?[2]", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[abc]?.more?[def]", "val?[abc]?.more?[def]", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[abc]?.more?.abc", "val?[abc]?.more?.abc", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[null ?? true]", "val?[null ?? true]", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - { "val?[abc?.gef?[-1]]", "val?[abc?.gef?[-1]]", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, - }; - } - } - - [Theory] - [MemberData(nameof(NullConditionalOperatorData_Bracket))] - public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket( - string implicitExpresison, - string expectedImplicitExpression, - object acceptedCharacters, - object expectedErrors) + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket1() { // Act & Assert - ImplicitExpressionTest( - implicitExpresison, - expectedImplicitExpression, - (AcceptedCharactersInternal)acceptedCharacters, - (RazorDiagnostic[])expectedErrors); + ImplicitExpressionTest("val??["); } - public static TheoryData NullConditionalOperatorData_Dot - { - get - { - // implicitExpression, expectedImplicitExpression - return new TheoryData - { - { "val?", "val" }, - { "val??", "val" }, - { "val??more", "val" }, - { "val?!", "val" }, - { "val?.", "val?." }, - { "val??.", "val" }, - { "val?.(abc)", "val?." }, - { "val?.

", "val?." }, - { "val?.more", "val?.more" }, - { "val?.more

", "val?.more" }, - { "val??.more

", "val" }, - { "val?.more(false)?.

", "val?.more(false)?." }, - { "val?.more(false)?.abc", "val?.more(false)?.abc" }, - { "val?.more(null ?? true)?.abc", "val?.more(null ?? true)?.abc" }, - }; - } - } - - [Theory] - [MemberData(nameof(NullConditionalOperatorData_Dot))] - public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot( - string implicitExpresison, - string expectedImplicitExpression) + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket2() { // Act & Assert - ImplicitExpressionTest(implicitExpresison, expectedImplicitExpression); + ImplicitExpressionTest("val??[0"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket3() + { + // Act & Assert + ImplicitExpressionTest("val?["); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket4() + { + // Act & Assert + ImplicitExpressionTest("val?("); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket5() + { + // Act & Assert + ImplicitExpressionTest("val?[more"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket6() + { + // Act & Assert + ImplicitExpressionTest("val?[0]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket7() + { + // Act & Assert + ImplicitExpressionTest("val?[

"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket8() + { + // Act & Assert + ImplicitExpressionTest("val?[more.

"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket9() + { + // Act & Assert + ImplicitExpressionTest("val??[more

"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket10() + { + // Act & Assert + ImplicitExpressionTest("val?[-1]?"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket11() + { + // Act & Assert + ImplicitExpressionTest("val?[abc]?[def"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket12() + { + // Act & Assert + ImplicitExpressionTest("val?[abc]?[2]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket13() + { + // Act & Assert + ImplicitExpressionTest("val?[abc]?.more?[def]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket14() + { + // Act & Assert + ImplicitExpressionTest("val?[abc]?.more?.abc"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket15() + { + // Act & Assert + ImplicitExpressionTest("val?[null ?? true]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket16() + { + // Act & Assert + ImplicitExpressionTest("val?[abc?.gef?[-1]]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot1() + { + // Act & Assert + ImplicitExpressionTest("val?"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot2() + { + // Act & Assert + ImplicitExpressionTest("val??"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot3() + { + // Act & Assert + ImplicitExpressionTest("val??more"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot4() + { + // Act & Assert + ImplicitExpressionTest("val?!"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot5() + { + // Act & Assert + ImplicitExpressionTest("val?."); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot6() + { + // Act & Assert + ImplicitExpressionTest("val??."); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot7() + { + // Act & Assert + ImplicitExpressionTest("val?.(abc)"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot8() + { + // Act & Assert + ImplicitExpressionTest("val?.

"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot9() + { + // Act & Assert + ImplicitExpressionTest("val?.more"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot10() + { + // Act & Assert + ImplicitExpressionTest("val?.more

"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot11() + { + // Act & Assert + ImplicitExpressionTest("val??.more

"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot12() + { + // Act & Assert + ImplicitExpressionTest("val?.more(false)?.

"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot13() + { + // Act & Assert + ImplicitExpressionTest("val?.more(false)?.abc"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot14() + { + // Act & Assert + ImplicitExpressionTest("val?.more(null ?? true)?.abc"); } [Fact] public void NestedImplicitExpression() { - ParseBlockTest("if (true) { @foo }", - new StatementBlock( - Factory.Code("if (true) { ").AsStatement(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Code(" }").AsStatement())); + ParseBlockTest("if (true) { @foo }"); } [Fact] - public void ParseBlockAcceptsNonEnglishCharactersThatAreValidIdentifiers() + public void AcceptsNonEnglishCharactersThatAreValidIdentifiers() { - ImplicitExpressionTest("हळूँजद॔.", "हळूँजद॔"); + ImplicitExpressionTest("हळूँजद॔."); } [Fact] - public void ParseBlockOutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition() + public void OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition() { - ParseBlockTest("@/", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(KeywordSet) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), - "/")); + ParseBlockTest("@/"); } [Fact] - public void ParseBlockOutputsZeroLengthCodeSpanIfEOFOccursAfterTransition() + public void OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition() { - ParseBlockTest("@", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(KeywordSet) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1))); + ParseBlockTest("@"); } [Fact] - public void ParseBlockSupportsSlashesWithinComplexImplicitExpressions() + public void SupportsSlashesWithinComplexImplicitExpressions() { ImplicitExpressionTest("DataGridColumn.Template(\"Years of Service\", e => (int)Math.Round((DateTime.Now - dt).TotalDays / 365))"); } [Fact] - public void ParseBlockMethodParsesSingleIdentifierAsImplicitExpression() + public void ParsesSingleIdentifierAsImplicitExpression() { ImplicitExpressionTest("foo"); } [Fact] - public void ParseBlockMethodDoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace() + public void DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace() { - ImplicitExpressionTest("foo ;", "foo"); + ImplicitExpressionTest("foo ;"); } [Fact] - public void ParseBlockMethodIgnoresSemicolonAtEndOfSimpleImplicitExpression() + public void IgnoresSemicolonAtEndOfSimpleImplicitExpression() { RunTrailingSemicolonTest("foo"); } [Fact] - public void ParseBlockMethodParsesDottedIdentifiersAsImplicitExpression() + public void ParsesDottedIdentifiersAsImplicitExpression() { ImplicitExpressionTest("foo.bar.baz"); } [Fact] - public void ParseBlockMethodIgnoresSemicolonAtEndOfDottedIdentifiers() + public void IgnoresSemicolonAtEndOfDottedIdentifiers() { RunTrailingSemicolonTest("foo.bar.baz"); } [Fact] - public void ParseBlockMethodDoesNotIncludeDotAtEOFInImplicitExpression() + public void DoesNotIncludeDotAtEOFInImplicitExpression() { - ImplicitExpressionTest("foo.bar.", "foo.bar"); + ImplicitExpressionTest("foo.bar."); } [Fact] - public void ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression() + public void DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1() { - ImplicitExpressionTest("foo.bar.0", "foo.bar"); - ImplicitExpressionTest("foo.bar.

", "foo.bar"); + // ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression1 + ImplicitExpressionTest("foo.bar.0"); } [Fact] - public void ParseBlockMethodDoesNotIncludeSemicolonAfterDot() + public void DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2() { - ImplicitExpressionTest("foo.bar.;", "foo.bar"); + // ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression2 + ImplicitExpressionTest("foo.bar.

"); } [Fact] - public void ParseBlockMethodTerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpression() + public void DoesNotIncludeSemicolonAfterDot() { - ImplicitExpressionTest("foo.bar

", "foo.bar"); + ImplicitExpressionTest("foo.bar.;"); } [Fact] - public void ParseBlockProperlyParsesParenthesesAndBalancesThemInImplicitExpression() + public void TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr() + { + // ParseBlockMethodTerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpression + ImplicitExpressionTest("foo.bar

"); + } + + [Fact] + public void ProperlyParsesParenthesesAndBalancesThemInImplicitExpression() { ImplicitExpressionTest(@"foo().bar(""bi\""z"", 4)(""chained method; call"").baz(@""bo""""z"", '\'', () => { return 4; }, (4+5+new { foo = bar[4] }))"); } [Fact] - public void ParseBlockProperlyParsesBracketsAndBalancesThemInImplicitExpression() + public void ProperlyParsesBracketsAndBalancesThemInImplicitExpression() { ImplicitExpressionTest(@"foo.bar[4 * (8 + 7)][""fo\""o""].baz"); } [Fact] - public void ParseBlockTerminatesImplicitExpressionAtHtmlEndTag() + public void TerminatesImplicitExpressionAtHtmlEndTag() { - ImplicitExpressionTest("foo().bar.baz

zoop", "foo().bar.baz"); + ImplicitExpressionTest("foo().bar.baz

zoop"); } [Fact] - public void ParseBlockTerminatesImplicitExpressionAtHtmlStartTag() + public void TerminatesImplicitExpressionAtHtmlStartTag() { - ImplicitExpressionTest("foo().bar.baz

zoop", "foo().bar.baz"); + ImplicitExpressionTest("foo().bar.baz

zoop"); } [Fact] - public void ParseBlockTerminatesImplicitExpressionBeforeDotIfDotNotFollowedByIdentifierStartCharacter() + public void TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar() { - ImplicitExpressionTest("foo().bar.baz.42", "foo().bar.baz"); + // ParseBlockTerminatesImplicitExpressionBeforeDotIfDotNotFollowedByIdentifierStartCharacter + ImplicitExpressionTest("foo().bar.baz.42"); } [Fact] - public void ParseBlockStopsBalancingParenthesesAtEOF() + public void StopsBalancingParenthesesAtEOF() { - ImplicitExpressionTest( - "foo(()", "foo(()", - acceptedCharacters: AcceptedCharactersInternal.Any, - errors: RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); + ImplicitExpressionTest("foo(()"); } [Fact] - public void ParseBlockTerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace() + public void TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace() { - ImplicitExpressionTest("foo.bar() (baz)", "foo.bar()"); + ImplicitExpressionTest("foo.bar() (baz)"); } [Fact] - public void ParseBlockTerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace() + public void TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace() { - ImplicitExpressionTest("foo .bar() (baz)", "foo"); + ImplicitExpressionTest("foo .bar() (baz)"); } [Fact] - public void ParseBlockTerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace() + public void TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace() { - ImplicitExpressionTest("foo. bar() (baz)", "foo"); + ImplicitExpressionTest("foo. bar() (baz)"); } [Fact] - public void ParseBlockOutputExpressionIfModuleTokenNotFollowedByBrace() + public void OutputExpressionIfModuleTokenNotFollowedByBrace() { ImplicitExpressionTest("module.foo()"); } private void RunTrailingSemicolonTest(string expr) { - ParseBlockTest(SyntaxConstants.TransitionString + expr + ";", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code(expr) - .AsImplicitExpression(KeywordSet) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - )); + ParseBlockTest(SyntaxConstants.TransitionString + expr + ";"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpLanguageCharacteristicsTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpLanguageCharacteristicsTest.cs index 1ab365c98a..e8eeb8c586 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpLanguageCharacteristicsTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpLanguageCharacteristicsTest.cs @@ -8,13 +8,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public class CSharpLanguageCharacteristicsTest { [Fact] - public void GetSample_RightShiftAssign_ReturnsCorrectSymbol() + public void GetSample_RightShiftAssign_ReturnsCorrectToken() { // Arrange & Act - var symbol = CSharpLanguageCharacteristics.Instance.GetSample(CSharpSymbolType.RightShiftAssign); + var token = CSharpLanguageCharacteristics.Instance.GetSample(CSharpTokenType.RightShiftAssign); // Assert - Assert.Equal(">>=", symbol); + Assert.Equal(">>=", token); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpNestedStatementsTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpNestedStatementsTest.cs index 9cc91b0a32..ee07b634e7 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpNestedStatementsTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpNestedStatementsTest.cs @@ -10,95 +10,37 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void NestedSimpleStatement() { - ParseBlockTest("@while(true) { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("while(true) { foo(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("@while(true) { foo(); }"); } [Fact] public void NestedKeywordStatement() { - ParseBlockTest("@while(true) { for(int i = 0; i < 10; i++) { foo(); } }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("while(true) { for(int i = 0; i < 10; i++) { foo(); } }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("@while(true) { for(int i = 0; i < 10; i++) { foo(); } }"); } [Fact] public void NestedCodeBlock() { - ParseBlockTest("@while(true) { { { { foo(); } } } }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("while(true) { { { { foo(); } } } }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("@while(true) { { { { foo(); } } } }"); } [Fact] public void NestedImplicitExpression() { - ParseBlockTest("@while(true) { @foo }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("while(true) { ") - .AsStatement(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Code(" }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("@while(true) { @foo }"); } [Fact] public void NestedExplicitExpression() { - ParseBlockTest("@while(true) { @(foo) }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("while(true) { ") - .AsStatement(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(") - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("foo") - .AsExpression(), - Factory.MetaCode(")") - .Accepts(AcceptedCharactersInternal.None)), - Factory.Code(" }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("@while(true) { @(foo) }"); } [Fact] public void NestedMarkupBlock() { - ParseBlockTest("@while(true) {

Hello

}", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("while(true) {") - .AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Hello"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("}") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("@while(true) {

Hello

}"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs index eb626f3abe..bcc8974b86 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs @@ -11,99 +11,26 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void UnterminatedRazorComment() { - ParseDocumentTest("@*", - new MarkupBlock( - Factory.EmptyHtml(), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span( - SpanKindInternal.Comment, - new HtmlSymbol( - string.Empty, - HtmlSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any))), - RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( - new SourceSpan(SourceLocation.Zero, contentLength: 2))); + ParseDocumentTest("@*"); } [Fact] public void EmptyRazorComment() { - ParseDocumentTest("@**@", - new MarkupBlock( - Factory.EmptyHtml(), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - string.Empty, - HtmlSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + ParseDocumentTest("@**@"); } [Fact] public void RazorCommentInImplicitExpressionMethodCall() { ParseDocumentTest("@foo(" + Environment.NewLine - + "@**@" + Environment.NewLine, - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo(" + Environment.NewLine) - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new CSharpSymbol( - string.Empty, - CSharpSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Code(Environment.NewLine) - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords))), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); + + "@**@" + Environment.NewLine); } [Fact] public void UnterminatedRazorCommentInImplicitExpressionMethodCall() { - ParseDocumentTest("@foo(@*", - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo(") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - new CommentBlock( - Factory.CodeTransition(CSharpSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaCode("*", CSharpSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new CSharpSymbol( - string.Empty, - CSharpSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any)))), - RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( - new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 2)), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); + ParseDocumentTest("@foo(@*"); } [Fact] @@ -112,66 +39,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest("@{" + Environment.NewLine + " " + Environment.NewLine + "@**@" + Environment.NewLine - + "

", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(Environment.NewLine), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - string.Empty, - HtmlSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null), - new MarkupTagBlock( - Factory.Markup("

")) - )); + + "

"); } [Fact] @@ -211,43 +64,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "

" + Environment.NewLine + " @**@ " + Environment.NewLine + "@**@" + Environment.NewLine - + "

", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(Environment.NewLine), - Factory.Markup(" ").With(SpanChunkGenerator.Null), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - string.Empty, - HtmlSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" " + Environment.NewLine).With(SpanChunkGenerator.Null), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - string.Empty, - HtmlSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null), - new MarkupTagBlock( - Factory.Markup("

")) - )); + + "

"); } [Fact] @@ -256,43 +73,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest( "

" + Environment.NewLine + "@**@ @**@" + Environment.NewLine - + "

", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(Environment.NewLine), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - string.Empty, - HtmlSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml(), - Factory.Markup(" ").With(SpanChunkGenerator.Null), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - string.Empty, - HtmlSymbolType.Unknown)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null), - new MarkupTagBlock( - Factory.Markup("

")) - )); + + "

"); } [Fact] @@ -301,42 +82,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest( "

" + Environment.NewLine + "@* hello *@ content @* world *@" + Environment.NewLine - + "

", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(Environment.NewLine), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - " hello ", - HtmlSymbolType.RazorComment)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" content "), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - " world ", - HtmlSymbolType.RazorComment)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine), - new MarkupTagBlock( - Factory.Markup("

")) - )); + + "

"); } [Fact] @@ -348,43 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "@*" + Environment.NewLine + "content" + Environment.NewLine + "*@" + Environment.NewLine + Environment.NewLine - + "

", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(Environment.NewLine + Environment.NewLine), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - " content ", - HtmlSymbolType.RazorComment)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol( - Environment.NewLine + "content" + Environment.NewLine, - HtmlSymbolType.RazorComment)) - .Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar) - .Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition) - .Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null), - Factory.Markup(Environment.NewLine), - new MarkupTagBlock( - Factory.Markup("

")) - )); + + "

"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs index 21a2dacf19..eae67d0168 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs @@ -7,34 +7,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpReservedWordsTest : CsHtmlCodeParserTestBase { - [Theory] - [InlineData("namespace")] - [InlineData("class")] - public void ReservedWords(string word) + [Fact] + public void ReservedWord() { - ParseBlockTest(word, - new DirectiveBlock( - Factory.MetaCode(word).Accepts(AcceptedCharactersInternal.None) - ), - RazorDiagnosticFactory.CreateParsing_ReservedWord( - new SourceSpan(SourceLocation.Zero, word.Length), word)); + ParseBlockTest("namespace"); } - [Theory] - [InlineData("Namespace")] - [InlineData("Class")] - [InlineData("NAMESPACE")] - [InlineData("CLASS")] - [InlineData("nameSpace")] - [InlineData("NameSpace")] - private void ReservedWordsAreCaseSensitive(string word) + [Fact] + private void ReservedWordIsCaseSensitive() { - ParseBlockTest(word, - new ExpressionBlock( - Factory.Code(word) - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - )); + ParseBlockTest("NameSpace"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs index 3e2fbac20f..52bca860e1 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs @@ -10,299 +10,120 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public class CSharpSectionTest : CsHtmlMarkupParserTestBase { [Fact] - public void ParseSectionBlockCapturesNewlineImmediatelyFollowing() + public void CapturesNewlineImmediatelyFollowing() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: Environment.NewLine.Length), SectionDirective.Directive.Directive)); - - // Act & Assert ParseDocumentTest( "@section" + Environment.NewLine, - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) - .AsDirectiveToken(DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Member))), - Factory.Markup(Environment.NewLine))); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockCapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace() + public void CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( - new SourceSpan(new SourceLocation(25 + Environment.NewLine.Length, 1, 4), contentLength: 1), - SectionDirective.Directive.Directive, - "{")); - - // Act & Assert ParseDocumentTest( "@section Foo " + Environment.NewLine + " ", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " " + Environment.NewLine + " ", markup: false).Accepts(AcceptedCharactersInternal.AllWhiteSpace)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockCapturesWhitespaceToEndOfLineInSectionStatementMissingName() + public void CapturesWhitespaceToEndOfLineInSectionStatementMissingName() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( - new SourceSpan(new SourceLocation(17, 0, 17), contentLength: Environment.NewLine.Length), SectionDirective.Directive.Directive)); - - // Act & Assert ParseDocumentTest( "@section " + Environment.NewLine + " ", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory - .Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) - .AsDirectiveToken(DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Member))), - Factory.Markup(Environment.NewLine + " "))); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockIgnoresSectionUnlessAllLowerCase() + public void IgnoresSectionUnlessAllLowerCase() { ParseDocumentTest( "@Section foo", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Section") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Markup(" foo"))); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartCharacter() + public void ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( - new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 1), SectionDirective.Directive.Directive)); - - // Act & Assert + // ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartCharacter ParseDocumentTest( "@section 9 {

Foo

}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace)), - Factory.Markup("9 { "), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(" }"))); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace() + public void ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( - new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1), - SectionDirective.Directive.Directive, - "{")); - - // Act & Assert + // ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace ParseDocumentTest( "@section foo-bar {

Foo

}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0])), - Factory.Markup("-bar { "), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(" }"))); + new[] { SectionDirective.Directive }); } [Fact] public void ParserOutputsErrorOnNestedSections() { - // Arrange - var erroredChunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - erroredChunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( - new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 7), "section")); - erroredChunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_SectionsCannotBeNested( - new SourceSpan(new SourceLocation(15, 0, 15), 8))); - - // Act & Assert ParseDocumentTest( "@section foo { @section bar {

Foo

} }", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new DirectiveBlock(erroredChunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "bar", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockHandlesEOFAfterOpenBrace() + public void HandlesEOFAfterOpenBrace() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), SectionDirective.Directive.Directive, "}", "{")); - - // Act & Assert ParseDocumentTest( "@section foo {", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.EmptyHtml())))); - } - - [Theory] - [InlineData(" ")] - [InlineData("\n")] - [InlineData(" abc")] - [InlineData(" \n abc")] - public void ParseSectionBlockHandlesEOFAfterOpenContent(string postStartBrace) - { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), "section", "}", "{")); - - // Act & Assert - ParseDocumentTest( - "@section foo {" + postStartBrace, - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(postStartBrace))))); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockHandlesUnterminatedSection() + public void HandlesEOFAfterOpenContent1() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), "section", "}", "{")); + + ParseDocumentTest( + "@section foo { ", + new[] { SectionDirective.Directive }); + } - // Act & Assert + [Fact] + public void HandlesEOFAfterOpenContent2() + { + + ParseDocumentTest( + "@section foo {\n", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesEOFAfterOpenContent3() + { + + ParseDocumentTest( + "@section foo {abc", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesEOFAfterOpenContent4() + { + + ParseDocumentTest( + "@section foo {\n abc", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesUnterminatedSection() + { ParseDocumentTest( "@section foo {

Foo{}

", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

")), - // Need to provide the markup span as fragments, since the parser will split the {} into separate symbols. - Factory.Markup("Foo", "{", "}"), - new MarkupTagBlock( - Factory.Markup("

")))))); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockHandlesUnterminatedSectionWithNestedIf() + public void HandlesUnterminatedSectionWithNestedIf() { // Arrange var newLine = Environment.NewLine; - var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(13 + newLine.Length, 1, 0), contentLength: 1), "section", "}", "{")); var spaces = " "; // Act & Assert @@ -311,34 +132,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "@section Test{0}{{{0}{1}@if(true){0}{1}{{{0}{1}{1}

Hello World

{0}{1}}}", newLine, spaces), - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Test", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, Environment.NewLine, CSharpSymbolType.NewLine).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(newLine), - new StatementBlock( - Factory.Code(spaces).AsStatement(), - Factory.CodeTransition(), - Factory.Code($"if(true){newLine}{spaces}{{{newLine}").AsStatement(), - new MarkupBlock( - Factory.Markup($"{spaces}{spaces}"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Hello World"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(newLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code($"{spaces}}}").AsStatement()))))); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockReportsErrorAndAcceptsWhitespaceToEndOfLineIfSectionNotFollowedByOpenBrace() + public void ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace() { + // ParseSectionBlockReportsErrorAndAcceptsWhitespaceToEndOfLineIfSectionNotFollowedByOpenBrace // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( @@ -350,22 +150,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Act & Assert ParseDocumentTest( "@section foo " + Environment.NewLine, - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " " + Environment.NewLine, markup: false).Accepts(AcceptedCharactersInternal.AllWhiteSpace)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockAcceptsOpenBraceMultipleLinesBelowSectionName() + public void AcceptsOpenBraceMultipleLinesBelowSectionName() { - // Act & Assert ParseDocumentTest( "@section foo " + Environment.NewLine @@ -377,390 +167,116 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "{" + Environment.NewLine + "

Foo

" + Environment.NewLine + "}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " " + string.Format("{0}{0}{0}{0}{0}{0}", Environment.NewLine), markup: false).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(Environment.NewLine), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(Environment.NewLine)), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockParsesNamedSectionCorrectly() + public void ParsesNamedSectionCorrectly() { - // Act & Assert ParseDocumentTest( "@section foo {

Foo

}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockDoesNotRequireSpaceBetweenSectionNameAndOpenBrace() + public void DoesNotRequireSpaceBetweenSectionNameAndOpenBrace() { - // Act & Assert ParseDocumentTest( "@section foo{

Foo

}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

")), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockBalancesBraces() + public void BalancesBraces() { - // Act & Assert ParseDocumentTest( "@section foo { }", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("")), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockAllowsBracesInCSharpExpression() + public void AllowsBracesInCSharpExpression() { - // Act & Assert ParseDocumentTest( "@section foo { I really want to render a close brace, so here I go: @(\"}\") }", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" I really want to render a close brace, so here I go: "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"}\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] public void SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock() { - // Act & Assert ParseDocumentTest( "@section Foo {" + Environment.NewLine + "@if(true) {" + Environment.NewLine + "}" + Environment.NewLine + "}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(Environment.NewLine), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code($"if(true) {{{Environment.NewLine}}}{Environment.NewLine}").AsStatement() - )), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlockNoWhitespace() + public void SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace() { - // Act & Assert + // SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlockNoWhitespace ParseDocumentTest( "@section Foo {" + Environment.NewLine + "@if(true) {" + Environment.NewLine + "}}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(Environment.NewLine), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code($"if(true) {{{Environment.NewLine}}}").AsStatement() - )), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockCorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup() + public void CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup() { - // Act & Assert ParseDocumentTest( "@section foo {something}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup("something")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockParsesComment() + public void ParsesComment() { - // Act & Assert ParseDocumentTest( "@section s {}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "s", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - BlockFactory.HtmlCommentBlock(" "), - Factory.EmptyHtml()), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } // This was a user reported bug (codeplex #710), the section parser wasn't handling // comments. [Fact] - public void ParseSectionBlockParsesCommentWithDelimiters() + public void ParsesCommentWithDelimiters() { - // Act & Assert ParseDocumentTest( "@section s {}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "s", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - BlockFactory.HtmlCommentBlock(" > \" '"), - Factory.EmptyHtml()), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockCommentRecoversFromUnclosedTag() + public void CommentRecoversFromUnclosedTag() { - // Act & Assert ParseDocumentTest( "@section s {" + Environment.NewLine + " \" '-->}", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "s", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(Environment.NewLine), - new MarkupTagBlock( - Factory.Markup(" \" '"), - Factory.EmptyHtml()), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } [Fact] - public void ParseSectionBlockParsesXmlProcessingInstruction() + public void ParsesXmlProcessingInstruction() { - // Act & Assert ParseDocumentTest( "@section s { }", - new[] { SectionDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "s", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive }); } - public static TheoryData SectionWithEscapedTransitionData + [Fact] + public void _WithDoubleTransition1() { - get - { - var factory = new SpanFactory(); - - return new TheoryData - { - { - "@section s {}", - new MarkupBlock( - factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - factory.CodeTransition(), - factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - factory.Span(SpanKindInternal.Code, "s", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 17, 0, 17), new LocationTagged("'", 25, 0, 25)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 23, 0, 23), new LocationTagged("@", 23, 0, 23))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />"))), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()) - }, - { - "@section s {}", - new MarkupBlock( - factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - factory.CodeTransition(), - factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - factory.Span(SpanKindInternal.Code, "s", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" foo='", 17, 0, 17), new LocationTagged("'", 39, 0, 39)), - factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 23, 0, 23), 23, 0, 23), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - new MarkupBlock( - factory.Markup(" @").With(new LiteralAttributeChunkGenerator(new LocationTagged(" ", 36, 0, 36), new LocationTagged("@", 37, 0, 37))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(" />"))), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()) - }, - }; - } + ParseDocumentTest("@section s {}", new[] { SectionDirective.Directive }); } - [Theory] - [MemberData(nameof(SectionWithEscapedTransitionData))] - public void ParseSectionBlock_WithDoubleTransition_DoesNotThrow(string input, object expected) + [Fact] + public void _WithDoubleTransition2() { - FixupSpans = true; - - ParseDocumentTest(input, new[] { SectionDirective.Directive }, (Block)expected); + ParseDocumentTest("@section s {}", new[] { SectionDirective.Directive }); } + } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs index ca472f33f5..3015010516 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs @@ -2,245 +2,61 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Razor.Language.Extensions; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpSpecialBlockTest : CsHtmlCodeParserTestBase { - [Fact] - public void ParseInheritsStatementMarksInheritsSpanAsCanGrowIfMissingTrailingSpace() - { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(InheritsDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( - new SourceSpan(new SourceLocation(9, 0, 9), 1), InheritsDirective.Directive.Directive, "type")); - - // Act & Assert - ParseDocumentTest( - "@inherits", - new[] { InheritsDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) - .AsDirectiveToken(DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Type))), - Factory.EmptyHtml())); - } - - [Fact] - public void InheritsBlockAcceptsMultipleGenericArguments() - { - ParseDocumentTest( - "@inherits Foo.Bar, string, int>.Baz", - new[] { InheritsDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(InheritsDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Foo.Bar, string, int>.Baz", markup: false).AsDirectiveToken(InheritsDirective.Directive.Tokens[0])), - Factory.EmptyHtml())); - } - - [Fact] - public void InheritsBlockOutputsErrorIfInheritsNotFollowedByTypeButAcceptsEntireLineAsCode() - { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(InheritsDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_DirectiveExpectsTypeName( - new SourceSpan(new SourceLocation(25, 0, 25), Environment.NewLine.Length), - InheritsDirective.Directive.Directive)); - - // Act & Assert - ParseDocumentTest( - "@inherits " + Environment.NewLine + "foo", - new[] { InheritsDirective.Directive }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(chunkGenerator, - Factory.CodeTransition(), - Factory.MetaCode("inherits").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, string.Empty, CSharpSymbolType.Unknown) - .AsDirectiveToken(DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Type))), - Factory.Markup(Environment.NewLine + "foo"))); - } - [Fact] public void NamespaceImportInsideCodeBlockCausesError() { - ParseBlockTest("{ using Foo.Bar.Baz; var foo = bar; }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" using Foo.Bar.Baz; var foo = bar; ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), - RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 5))); + ParseBlockTest("{ using Foo.Bar.Baz; var foo = bar; }"); } [Fact] public void TypeAliasInsideCodeBlockIsNotHandledSpecially() { - ParseBlockTest("{ using Foo = Bar.Baz; var foo = bar; }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" using Foo = Bar.Baz; var foo = bar; ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), - RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 5))); - } - - [Fact] - public void Plan9FunctionsKeywordInsideCodeBlockIsNotHandledSpecially() - { - ParseBlockTest("{ functions Foo; }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" functions Foo; ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("{ using Foo = Bar.Baz; var foo = bar; }"); } [Fact] public void NonKeywordStatementInCodeBlockIsHandledCorrectly() { - ParseBlockTest("{" + Environment.NewLine - + " List photos = gallery.Photo.ToList();" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code($"{Environment.NewLine} List photos = gallery.Photo.ToList();{Environment.NewLine}") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); - } - - [Fact] - public void ParseBlockBalancesBracesOutsideStringsIfFirstCharacterIsBraceAndReturnsSpanOfTypeCode() - { - // Arrange - const string code = "foo\"b}ar\" if(condition) { string.Format(\"{0}\"); } "; - - // Act/Assert - ParseBlockTest("{" + code + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(code) - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); - } - - [Fact] - public void ParseBlockBalancesParensOutsideStringsIfFirstCharacterIsParenAndReturnsSpanOfTypeExpression() - { - // Arrange - const string code = "foo\"b)ar\" if(condition) { string.Format(\"{0}\"); } "; - - // Act/Assert - ParseBlockTest("(" + code + ")", - new ExpressionBlock( - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code(code).AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); - } - - [Fact] - public void ParseBlockBalancesBracesAndOutputsContentAsClassLevelCodeSpanIfFirstIdentifierIsFunctionsKeyword() - { - const string code = " foo(); \"bar}baz\" "; ParseBlockTest( - "functions {" + code + "} zoop", - new[] { FunctionsDirective.Directive }, - new DirectiveBlock(new DirectiveChunkGenerator(FunctionsDirective.Directive), - Factory.MetaCode("functions").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - Factory.Code(code).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); +@"{ + List photos = gallery.Photo.ToList(); +}"); } [Fact] - public void ParseBlockDoesNoErrorRecoveryForFunctionsBlock() + public void BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); - - // Act & Assert - ParseBlockTest( - "functions { { { { { } zoop", - new[] { FunctionsDirective.Directive }, - new DirectiveBlock(chunkGenerator, - Factory.MetaCode("functions").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - Factory.Code(" { { { { } zoop").AsStatement())); + // ParseBlockBalancesBracesOutsideStringsIfFirstCharacterIsBraceAndReturnsSpanOfTypeCode + ParseBlockTest("{foo\"b}ar\" if(condition) { string.Format(\"{0}\"); } }"); } [Fact] - public void ParseBlockIgnoresFunctionsUnlessAllLowerCase() + public void BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr() { - ParseBlockTest("Functions { foo() }", - new ExpressionBlock( - Factory.Code("Functions") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))); + // ParseBlockBalancesParensOutsideStringsIfFirstCharacterIsParenAndReturnsSpanOfTypeExpression + ParseBlockTest("(foo\"b)ar\" if(condition) { string.Format(\"{0}\"); } )"); } [Fact] public void ParseBlockIgnoresSingleSlashAtStart() { - ParseBlockTest("@/ foo", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), - "/")); + ParseBlockTest("@/ foo"); } [Fact] public void ParseBlockTerminatesSingleLineCommentAtEndOfLine() { - ParseBlockTest("if(!false) {" + Environment.NewLine - + " // Foo" + Environment.NewLine - + "\t

A real tag!

" + Environment.NewLine - + "}", - new StatementBlock( - Factory.Code($"if(!false) {{{Environment.NewLine} // Foo{Environment.NewLine}").AsStatement(), - new MarkupBlock( - Factory.Markup("\t"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("A real tag!"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement() - )); + ParseBlockTest( +"if(!false) {" + Environment.NewLine + +" // Foo" + Environment.NewLine + +"\t

A real tag!

" + Environment.NewLine + +"}"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs index 0d3a485441..ea167f4934 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.Legacy @@ -20,413 +19,205 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void ForStatement() { - ParseBlockTest("@for(int i = 0; i++; i < length) { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("for(int i = 0; i++; i < length) { foo(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@for(int i = 0; i++; i < length) { foo(); }"); } [Fact] public void ForEachStatement() { - ParseBlockTest("@foreach(var foo in bar) { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("foreach(var foo in bar) { foo(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@foreach(var foo in bar) { foo(); }"); } [Fact] public void WhileStatement() { - ParseBlockTest("@while(true) { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("while(true) { foo(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@while(true) { foo(); }"); } [Fact] public void SwitchStatement() { - ParseBlockTest("@switch(foo) { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("switch(foo) { foo(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@switch(foo) { foo(); }"); } [Fact] public void LockStatement() { - ParseBlockTest("@lock(baz) { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("lock(baz) { foo(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@lock(baz) { foo(); }"); } [Fact] public void IfStatement() { - ParseBlockTest("@if(true) { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(true) { foo(); }") - .AsStatement() - )); + ParseBlockTest("@if(true) { foo(); }"); } [Fact] public void ElseIfClause() { - ParseBlockTest("@if(true) { foo(); } else if(false) { foo(); } else if(!false) { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(true) { foo(); } else if(false) { foo(); } else if(!false) { foo(); }") - .AsStatement() - )); + ParseBlockTest("@if(true) { foo(); } else if(false) { foo(); } else if(!false) { foo(); }"); } [Fact] public void ElseClause() { - ParseBlockTest("@if(true) { foo(); } else { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(true) { foo(); } else { foo(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@if(true) { foo(); } else { foo(); }"); } [Fact] public void TryStatement() { - ParseBlockTest("@try { foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("try { foo(); }") - .AsStatement() - )); + ParseBlockTest("@try { foo(); }"); } [Fact] public void CatchClause() { - ParseBlockTest("@try { foo(); } catch(IOException ioex) { handleIO(); } catch(Exception ex) { handleOther(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("try { foo(); } catch(IOException ioex) { handleIO(); } catch(Exception ex) { handleOther(); }") - .AsStatement() - )); + ParseBlockTest("@try { foo(); } catch(IOException ioex) { handleIO(); } catch(Exception ex) { handleOther(); }"); } - public static TheoryData ExceptionFilterData + [Fact] + public void ExceptionFilter_TryCatchWhenComplete_SingleLine() { - get - { - var factory = new SpanFactory(); - - // document, expectedStatement - return new TheoryData - { - { - "@try { someMethod(); } catch(Exception) when (true) { handleIO(); }", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { someMethod(); } catch(Exception) when (true) { handleIO(); }") - .AsStatement()) - }, - { - "@try { A(); } catch(Exception) when (true) { B(); } finally { C(); }", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { A(); } catch(Exception) when (true) { B(); } finally { C(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None)) - }, - { - "@try { A(); } catch(Exception) when (true) { B(); } catch(IOException) when (false) { C(); }", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { A(); } catch(Exception) when (true) { B(); } catch(IOException) " + - "when (false) { C(); }") - .AsStatement()) - }, - { - string.Format("@try{0}{{{0} A();{0}}}{0}catch(Exception) when (true)", Environment.NewLine) + - string.Format("{0}{{{0} B();{0}}}{0}catch(IOException) when (false)", Environment.NewLine) + - string.Format("{0}{{{0} C();{0}}}", Environment.NewLine), - new StatementBlock( - factory.CodeTransition(), - factory - .Code( - string.Format("try{0}{{{0} A();{0}}}{0}catch(Exception) ", Environment.NewLine) + - string.Format("when (true){0}{{{0} B();{0}}}{0}", Environment.NewLine) + - string.Format("catch(IOException) when (false){0}{{{0} ", Environment.NewLine) + - string.Format("C();{0}}}", Environment.NewLine)) - .AsStatement()) - }, - - // Wrapped in @{ block. - { - "@{try { someMethod(); } catch(Exception) when (true) { handleIO(); }}", - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - factory - .Code("try { someMethod(); } catch(Exception) when (true) { handleIO(); }") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)) - }, - - // Partial exception filter data - { - "@try { someMethod(); } catch(Exception) when", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { someMethod(); } catch(Exception) when") - .AsStatement()) - }, - { - "@try { someMethod(); } when", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { someMethod(); }") - .AsStatement()) - }, - { - "@try { someMethod(); } catch(Exception) when { anotherMethod(); }", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { someMethod(); } catch(Exception) when { anotherMethod(); }") - .AsStatement()) - }, - { - "@try { someMethod(); } catch(Exception) when (true)", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { someMethod(); } catch(Exception) when (true)") - .AsStatement()) - }, - }; - } + ParseBlockTest("@try { someMethod(); } catch(Exception) when (true) { handleIO(); }"); } - [Theory] - [MemberData(nameof(ExceptionFilterData))] - public void ExceptionFilters(string document, object expectedStatement) + [Fact] + public void ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine() { - FixupSpans = true; - - // Act & Assert - ParseBlockTest(document, (StatementBlock)expectedStatement); + ParseBlockTest("@try { A(); } catch(Exception) when (true) { B(); } finally { C(); }"); } - public static TheoryData ExceptionFilterErrorData + [Fact] + public void ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine() { - get - { - var factory = new SpanFactory(); - - // document, expectedStatement, expectedErrors - return new TheoryData - { - { - "@try { someMethod(); } catch(Exception) when (", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { someMethod(); } catch(Exception) when (") - .AsStatement()), - new[] - { - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(45, 0, 45), contentLength: 1), "(", ")"), - } - }, - { - "@try { someMethod(); } catch(Exception) when (someMethod(", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { someMethod(); } catch(Exception) when (someMethod(") - .AsStatement()), - new[] - { - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(45, 0, 45), contentLength: 1), "(", ")"), - } - }, - { - "@try { someMethod(); } catch(Exception) when (true) {", - new StatementBlock( - factory.CodeTransition(), - factory - .Code("try { someMethod(); } catch(Exception) when (true) {") - .AsStatement()), - new[] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(23, 0, 23), contentLength: 1), "catch", "}", "{"), - } - }, - }; - } + ParseBlockTest("@try { A(); } catch(Exception) when (true) { B(); } catch(IOException) when (false) { C(); }"); } - [Theory] - [MemberData(nameof(ExceptionFilterErrorData))] - public void ExceptionFilterErrors( - string document, - object expectedStatement, - object expectedErrors) + [Fact] + public void ExceptionFilter_MultiLine() { - FixupSpans = true; + ParseBlockTest( +@"@try +{ +A(); +} +catch(Exception) when (true) +{ +B(); +} +catch(IOException) when (false) +{ +C(); +}"); + } - // Act & Assert - ParseBlockTest(document, (StatementBlock)expectedStatement, (RazorDiagnostic[])expectedErrors); + [Fact] + public void ExceptionFilter_NestedTryCatchWhen() + { + ParseBlockTest("@{try { someMethod(); } catch(Exception) when (true) { handleIO(); }}"); + } + + [Fact] + public void ExceptionFilter_IncompleteTryCatchWhen() + { + ParseBlockTest("@try { someMethod(); } catch(Exception) when"); + } + + [Fact] + public void ExceptionFilter_IncompleteTryWhen() + { + ParseBlockTest("@try { someMethod(); } when"); + } + + [Fact] + public void ExceptionFilter_IncompleteTryCatchNoBodyWhen() + { + ParseBlockTest("@try { someMethod(); } catch(Exception) when { anotherMethod(); }"); + } + + [Fact] + public void ExceptionFilter_IncompleteTryCatchWhenNoBodies() + { + ParseBlockTest("@try { someMethod(); } catch(Exception) when (true)"); + } + + [Fact] + public void ExceptionFilterError_TryCatchWhen_InCompleteCondition() + { + ParseBlockTest("@try { someMethod(); } catch(Exception) when ("); + } + + [Fact] + public void ExceptionFilterError_TryCatchWhen_InCompleteBody() + { + ParseBlockTest("@try { someMethod(); } catch(Exception) when (true) {"); } [Fact] public void FinallyClause() { - ParseBlockTest("@try { foo(); } finally { Dispose(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("try { foo(); } finally { Dispose(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@try { foo(); } finally { Dispose(); }"); } - public static TheoryData StaticUsingData + [Fact] + public void StaticUsing_NoUsing() { - get - { - var factory = new SpanFactory(); - Func createUsing = (code, import) => - new DirectiveBlock( - factory.CodeTransition(), - factory.Code(code) - .AsNamespaceImport(import) - .Accepts(AcceptedCharactersInternal.AnyExceptNewline)); - - // document, expectedResult - return new TheoryData - { - { "@using static", createUsing("using static", " static") }, - { "@using static ", createUsing("using static ", " static ") }, - { "@using static ", createUsing("using static ", " static ") }, - { "@using static System", createUsing("using static System", " static System") }, - { - "@using static System", - createUsing("using static System", " static System") - }, - { - "@using static System.Console", - createUsing("using static System.Console", " static System.Console") - }, - { - "@using static global::System.Console", - createUsing("using static global::System.Console", " static global::System.Console") - }, - { - "@using static global::System.Console ", - createUsing("using static global::System.Console", " static global::System.Console") - }, - }; - } + ParseBlockTest("@using static"); } - [Theory] - [MemberData(nameof(StaticUsingData))] - public void StaticUsingImport(string document, object expectedResult) + [Fact] + public void StaticUsing_SingleIdentifier() { - FixupSpans = true; + ParseBlockTest("@using static System"); + } - // Act & Assert - ParseBlockTest(document, (DirectiveBlock)expectedResult); + [Fact] + public void StaticUsing_MultipleIdentifiers() + { + ParseBlockTest("@using static System.Console"); + } + + [Fact] + public void StaticUsing_GlobalPrefix() + { + ParseBlockTest("@using static global::System.Console"); + } + + [Fact] + public void StaticUsing_Complete_Spaced() + { + ParseBlockTest("@using static global::System.Console "); } [Fact] public void UsingStatement() { - ParseBlockTest("@using(var foo = new Foo()) { foo.Bar(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("using(var foo = new Foo()) { foo.Bar(); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@using(var foo = new Foo()) { foo.Bar(); }"); } [Fact] public void UsingTypeAlias() { - ParseBlockTest("@using StringDictionary = System.Collections.Generic.Dictionary", - new DirectiveBlock( - Factory.CodeTransition(), - Factory.Code("using StringDictionary = System.Collections.Generic.Dictionary") - .AsNamespaceImport(" StringDictionary = System.Collections.Generic.Dictionary") - .Accepts(AcceptedCharactersInternal.AnyExceptNewline) - )); + ParseBlockTest("@using StringDictionary = System.Collections.Generic.Dictionary"); } [Fact] public void UsingNamespaceImport() { - ParseBlockTest("@using System.Text.Encoding.ASCIIEncoding", - new DirectiveBlock( - Factory.CodeTransition(), - Factory.Code("using System.Text.Encoding.ASCIIEncoding") - .AsNamespaceImport(" System.Text.Encoding.ASCIIEncoding") - .Accepts(AcceptedCharactersInternal.AnyExceptNewline) - )); + ParseBlockTest("@using System.Text.Encoding.ASCIIEncoding"); } [Fact] public void DoStatement() { - ParseBlockTest("@do { foo(); } while(true);", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("do { foo(); } while(true);") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@do { foo(); } while(true);"); } [Fact] public void NonBlockKeywordTreatedAsImplicitExpression() { - ParseBlockTest("@is foo", - new ExpressionBlock(new ExpressionChunkGenerator(), - Factory.CodeTransition(), - Factory.Code("is") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - )); + ParseBlockTest("@is foo"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs index 0631ff1c7f..b672bcff91 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs @@ -8,314 +8,85 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpTemplateTest : CsHtmlCodeParserTestBase { - private const string TestTemplateCode = " @

Foo #@item

"; - - private TemplateBlock TestTemplate() + [Fact] + public void HandlesSingleLineTemplate() { - return new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo #"), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("item") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)) - ) - ); - } - - private const string TestNestedTemplateCode = " @

Foo #@Html.Repeat(10, @

@item

)

"; - - private TemplateBlock TestNestedTemplate() - { - return new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo #"), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Html.Repeat(10, ") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("item") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)) - ) - ), - Factory.Code(")") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)) - ) - ); + ParseBlockTest("{ var foo = @: bar" + Environment.NewLine + "; }"); } [Fact] - public void ParseBlockHandlesSingleLineTemplate() + public void HandlesSingleLineImmediatelyFollowingStatementChar() { - ParseBlockTest("{ var foo = @: bar" + Environment.NewLine - + "; }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup(" bar" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)) - .Accepts(AcceptedCharactersInternal.None) - ) - ), - Factory.Code("; ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("{i@: bar" + Environment.NewLine + "}"); } [Fact] - public void ParseBlockHandlesSingleLineImmediatelyFollowingStatementChar() + public void HandlesSimpleTemplateInExplicitExpressionParens() { - ParseBlockTest("{i@: bar" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code("i") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup(" bar" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)) - .Accepts(AcceptedCharactersInternal.None) - ) - ), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("(Html.Repeat(10, @

Foo #@item

))"); } [Fact] - public void ParseBlockHandlesSimpleTemplateInExplicitExpressionParens() + public void HandlesSimpleTemplateInImplicitExpressionParens() { - ParseBlockTest("(Html.Repeat(10," + TestTemplateCode + "))", - new ExpressionBlock( - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("Html.Repeat(10, ").AsExpression(), - TestTemplate(), - Factory.Code(")").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("Html.Repeat(10, @

Foo #@item

)"); } [Fact] - public void ParseBlockHandlesSimpleTemplateInImplicitExpressionParens() + public void HandlesTwoTemplatesInImplicitExpressionParens() { - ParseBlockTest("Html.Repeat(10," + TestTemplateCode + ")", - new ExpressionBlock( - Factory.Code("Html.Repeat(10, ") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - TestTemplate(), - Factory.Code(")") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - )); + ParseBlockTest("Html.Repeat(10, @

Foo #@item

, @

Foo #@item

)"); } [Fact] - public void ParseBlockHandlesTwoTemplatesInImplicitExpressionParens() + public void ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens() { - ParseBlockTest("Html.Repeat(10," + TestTemplateCode + "," + TestTemplateCode + ")", - new ExpressionBlock( - Factory.Code("Html.Repeat(10, ") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - TestTemplate(), - Factory.Code(", ") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - TestTemplate(), - Factory.Code(")") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace) - )); + // ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInImplicitExpressionParens + ParseBlockTest("Html.Repeat(10, @

Foo #@Html.Repeat(10, @

@item

)

)"); } [Fact] - public void ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInImplicitExpressionParens() + public void HandlesSimpleTemplateInStatementWithinCodeBlock() { - ParseBlockTest("Html.Repeat(10," + TestNestedTemplateCode + ")", - new ExpressionBlock( - Factory.Code("Html.Repeat(10, ") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - TestNestedTemplate(), - Factory.Code(")") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - GetNestedTemplateError(42)); + ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

Foo #@item

); }"); } [Fact] - public void ParseBlockHandlesSimpleTemplateInStatementWithinCodeBlock() + public void HandlesTwoTemplatesInStatementWithinCodeBlock() { - ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo," + TestTemplateCode + "); }", - new StatementBlock( - Factory.Code("foreach(foo in Bar) { Html.ExecuteTemplate(foo, ").AsStatement(), - TestTemplate(), - Factory.Code("); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

Foo #@item

, @

Foo #@item

); }"); } [Fact] - public void ParseBlockHandlesTwoTemplatesInStatementWithinCodeBlock() + public void ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock() { - ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo," + TestTemplateCode + "," + TestTemplateCode + "); }", - new StatementBlock( - Factory.Code("foreach(foo in Bar) { Html.ExecuteTemplate(foo, ").AsStatement(), - TestTemplate(), - Factory.Code(", ").AsStatement(), - TestTemplate(), - Factory.Code("); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - )); + // ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinCodeBlock + ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

Foo #@Html.Repeat(10, @

@item

)

); }"); } [Fact] - public void ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinCodeBlock() + public void HandlesSimpleTemplateInStatementWithinStatementBlock() { - ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo," + TestNestedTemplateCode + "); }", - new StatementBlock( - Factory.Code("foreach(foo in Bar) { Html.ExecuteTemplate(foo, ") - .AsStatement(), - TestNestedTemplate(), - Factory.Code("); }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None) - ), - GetNestedTemplateError(74)); + ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @

Foo #@item

); }"); } [Fact] - public void ParseBlockHandlesSimpleTemplateInStatementWithinStatementBlock() + public void HandlessTwoTemplatesInStatementWithinStatementBlock() { - ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo," + TestTemplateCode + "); }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = bar; Html.ExecuteTemplate(foo, ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - TestTemplate(), - Factory.Code("); ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @

Foo #@item

, @

Foo #@item

); }"); } [Fact] - public void ParseBlockHandlessTwoTemplatesInStatementWithinStatementBlock() + public void ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock() { - ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo," + TestTemplateCode + "," + TestTemplateCode + "); }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = bar; Html.ExecuteTemplate(foo, ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - TestTemplate(), - Factory.Code(", ").AsStatement(), - TestTemplate(), - Factory.Code("); ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); + // ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinStatementBlock + ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @

Foo #@Html.Repeat(10, @

@item

)

); }"); } [Fact] - public void ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinStatementBlock() + public void _WithDoubleTransition_DoesNotThrow() { - ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo," + TestNestedTemplateCode + "); }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = bar; Html.ExecuteTemplate(foo, ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - TestNestedTemplate(), - Factory.Code("); ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), - GetNestedTemplateError(69)); - } - - [Fact] - public void ParseBlock_WithDoubleTransition_DoesNotThrow() - { - FixupSpans = true; - - // Arrange - var testTemplateWithDoubleTransitionCode = " @

Foo #@item

"; - var testTemplateWithDoubleTransition = new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - new MarkupTagBlock( - Factory.Markup("(" foo='", 46, 0, 46), new LocationTagged("'", 54, 0, 54)), - Factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - Factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 52, 0, 52), new LocationTagged("@", 52, 0, 52))).Accepts(AcceptedCharactersInternal.None), - Factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo #"), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("item") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)) - ) - ); - - var expected = new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = bar; Html.ExecuteTemplate(foo, ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - testTemplateWithDoubleTransition, - Factory.Code("); ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)); - - // Act & Assert - ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo," + testTemplateWithDoubleTransitionCode + "); }", expected); - } - - private static RazorDiagnostic GetNestedTemplateError(int characterIndex) - { - return RazorDiagnosticFactory.CreateParsing_InlineMarkupBlocksCannotBeNested( - new SourceSpan(new SourceLocation(characterIndex, 0, characterIndex), contentLength: 1)); + ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @

Foo #@item

); }"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs index 1d96a65590..510fb281f4 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs @@ -11,167 +11,57 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated() { - ParseBlockTest("{ List< }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" List< ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("{ List< }"); } [Fact] - public void ParseBlockGivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode() + public void GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode() { - ParseBlockTest("Foo( @

Foo

)", - new ExpressionBlock( - Factory.Code("Foo( ") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.Any), - new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)) - ) - ), - Factory.Code(" )") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), designTime: true); + ParseBlockTest("Foo( @

Foo

)", designTime: true); } [Fact] - public void ParseBlockGivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode() + public void GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode() { ParseBlockTest("Foo( " + Environment.NewLine + "@:

Foo

" + Environment.NewLine - + ")", - new ExpressionBlock( - Factory.Code("Foo( " + Environment.NewLine).AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("

Foo

" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ) - ), - Factory.Code(")") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), designTime: true); + + ")", designTime: true); } [Fact] - public void ParseBlockGivesSpacesToCodeOnTagTransitionInDesignTimeMode() + public void GivesSpacesToCodeOnTagTransitionInDesignTimeMode() { ParseBlockTest("{" + Environment.NewLine + "

Foo

" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + " ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)) - ), - Factory.Code(" " + Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), designTime: true); + + "}", designTime: true); } [Fact] - public void ParseBlockGivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode() + public void GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode() { ParseBlockTest("{" + Environment.NewLine + " @

Foo

" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + " ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - Factory.MarkupTransition(), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)) - ), - Factory.Code(" " + Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), true, - RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( - new SourceSpan(new SourceLocation(5 + Environment.NewLine.Length, 1, 4), contentLength: 1))); + + "}", designTime: true); } [Fact] - public void ParseBlockGivesSpacesToCodeOnAtColonTransitionInDesignTimeMode() + public void GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode() { ParseBlockTest("{" + Environment.NewLine + " @:

Foo

" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + " ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("

Foo

" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), designTime: true); + + "}", designTime: true); } [Fact] - public void ParseBlockShouldSupportSingleLineMarkupContainingStatementBlock() + public void ShouldSupportSingleLineMarkupContainingStatementBlock() { ParseBlockTest("Repeat(10," + Environment.NewLine + " @: @{}" + Environment.NewLine - + ")", - new ExpressionBlock( - Factory.Code($"Repeat(10,{Environment.NewLine} ") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords), - new TemplateBlock( - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup(" ") - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)), - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Markup(Environment.NewLine) - .Accepts(AcceptedCharactersInternal.None) - ) - ), - Factory.Code(")") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - )); + + ")"); } [Fact] - public void ParseBlockShouldSupportMarkupWithoutPreceedingWhitespace() + public void ShouldSupportMarkupWithoutPreceedingWhitespace() { ParseBlockTest("foreach(var file in files){" + Environment.NewLine + Environment.NewLine @@ -180,40 +70,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "
" + Environment.NewLine + "Foo" + Environment.NewLine + "@:Bar" + Environment.NewLine - + "}", - new StatementBlock( - Factory.Code(string.Format("foreach(var file in files){{{0}{0}{0}", Environment.NewLine)).AsStatement(), - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("Baz" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("
").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("Bar" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None) - )); + + "}"); } [Fact] - public void ParseBlockGivesAllWhitespaceOnSameLineExcludingPreceedingNewlineButIncludingTrailingNewLineToMarkup() + public void GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline() { + // ParseBlockGivesAllWhitespaceOnSameLineExcludingPreceedingNewlineButIncludingTrailingNewLineToMarkup ParseBlockTest("if(foo) {" + Environment.NewLine + " var foo = \"After this statement there are 10 spaces\"; " + Environment.NewLine + "

" + Environment.NewLine @@ -222,119 +85,23 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "

" + Environment.NewLine + " @:Hello!" + Environment.NewLine + " var biz = boz;" + Environment.NewLine - + "}", - new StatementBlock( - Factory.Code( - $"if(foo) {{{Environment.NewLine} var foo = \"After this statement there are " + - "10 spaces\"; " + Environment.NewLine).AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup($"{Environment.NewLine} Foo{Environment.NewLine}"), - new ExpressionBlock( - Factory.Code(" ").AsStatement(), - Factory.CodeTransition(), - Factory.Code("bar").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - Factory.Markup(Environment.NewLine + " "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - new MarkupBlock( - Factory.Markup(" "), - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("Hello!" + Environment.NewLine).With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - Factory.Code($" var biz = boz;{Environment.NewLine}}}").AsStatement())); + + "}"); } [Fact] - public void ParseBlockAllowsMarkupInIfBodyWithBraces() + public void AllowsMarkupInIfBodyWithBraces() { - ParseBlockTest("if(foo) {

Bar

} else if(bar) {

Baz

} else {

Boz

}", - new StatementBlock( - Factory.Code("if(foo) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Bar"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("} else if(bar) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Baz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("} else {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Boz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("if(foo) {

Bar

} else if(bar) {

Baz

} else {

Boz

}"); } [Fact] - public void ParseBlockAllowsMarkupInIfBodyWithBracesWithinCodeBlock() + public void AllowsMarkupInIfBodyWithBracesWithinCodeBlock() { - ParseBlockTest("{ if(foo) {

Bar

} else if(bar) {

Baz

} else {

Boz

} }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" if(foo) {") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Bar"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("} else if(bar) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Baz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("} else {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Boz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("} ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("{ if(foo) {

Bar

} else if(bar) {

Baz

} else {

Boz

} }"); } [Fact] - public void ParseBlockSupportsMarkupInCaseAndDefaultBranchesOfSwitch() + public void SupportsMarkupInCaseAndDefaultBranchesOfSwitch() { // Arrange ParseBlockTest("switch(foo) {" + Environment.NewLine @@ -351,64 +118,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + " }" + Environment.NewLine + " default:" + Environment.NewLine + "

Biz

" + Environment.NewLine - + "}", - new StatementBlock( - Factory.Code($"switch(foo) {{{Environment.NewLine} case 0:{Environment.NewLine}").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code($" break;{Environment.NewLine} case 1:{Environment.NewLine}").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Bar"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code( - $" return;{Environment.NewLine} case 2:{Environment.NewLine}" + - " {" + Environment.NewLine).AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Baz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Boz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code($" }}{Environment.NewLine} default:{Environment.NewLine}").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Biz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None))); + + "}"); } [Fact] - public void ParseBlockSupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock() + public void SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock() { // Arrange ParseBlockTest("{ switch(foo) {" + Environment.NewLine @@ -425,220 +139,68 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + " }" + Environment.NewLine + " default:" + Environment.NewLine + "

Biz

" + Environment.NewLine - + "} }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code($" switch(foo) {{{Environment.NewLine} case 0:{Environment.NewLine}") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code($" break;{Environment.NewLine} case 1:{Environment.NewLine}").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Bar"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code( - $" return;{Environment.NewLine} case 2:{Environment.NewLine}" + - " {" + Environment.NewLine).AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Baz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Boz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code($" }}{Environment.NewLine} default:{Environment.NewLine}").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Biz"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("} ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + + "} }"); } [Fact] - public void ParseBlockParsesMarkupStatementOnOpenAngleBracket() + public void ParsesMarkupStatementOnOpenAngleBracket() { - ParseBlockTest("for(int i = 0; i < 10; i++) {

Foo

}", - new StatementBlock( - Factory.Code("for(int i = 0; i < 10; i++) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("for(int i = 0; i < 10; i++) {

Foo

}"); } [Fact] - public void ParseBlockParsesMarkupStatementOnOpenAngleBracketInCodeBlock() + public void ParsesMarkupStatementOnOpenAngleBracketInCodeBlock() { - ParseBlockTest("{ for(int i = 0; i < 10; i++) {

Foo

} }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" for(int i = 0; i < 10; i++) {") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code("} ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("{ for(int i = 0; i < 10; i++) {

Foo

} }"); } [Fact] - public void ParseBlockParsesMarkupStatementOnSwitchCharacterFollowedByColon() + public void ParsesMarkupStatementOnSwitchCharacterFollowedByColon() { // Arrange ParseBlockTest("if(foo) { @:Bar" + Environment.NewLine - + "} zoop", - new StatementBlock( - Factory.Code("if(foo) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("Bar" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - Factory.Code("}").AsStatement())); + + "} zoop"); } [Fact] - public void ParseBlockParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon() + public void ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon() { // Arrange ParseBlockTest("if(foo) { @::Sometext" + Environment.NewLine - + "}", - new StatementBlock( - Factory.Code("if(foo) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup(":Sometext" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - Factory.Code("}").AsStatement())); + + "}"); } [Fact] - public void ParseBlockParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon() + public void ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon() { // Arrange ParseBlockTest("if(foo) { @:::Sometext" + Environment.NewLine - + "}", - new StatementBlock( - Factory.Code("if(foo) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("::Sometext" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - Factory.Code("}").AsStatement())); + + "}"); } [Fact] - public void ParseBlockParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock() + public void ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock() { // Arrange ParseBlockTest("{ if(foo) { @:Bar" + Environment.NewLine - + "} } zoop", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" if(foo) {") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - Factory.Markup(" "), - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("Bar" + Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - Factory.Code("} ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + + "} } zoop"); } [Fact] - public void ParseBlockCorrectlyReturnsFromMarkupBlockWithPseudoTag() + public void CorrectlyReturnsFromMarkupBlockWithPseudoTag() { - ParseBlockTest("if (i > 0) { ; }", - new StatementBlock( - Factory.Code("if (i > 0) { ").AsStatement(), - new MarkupBlock( - new MarkupTagBlock( - Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(";").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.None))), - Factory.Code(" }").AsStatement())); + ParseBlockTest("if (i > 0) { ; }"); } [Fact] - public void ParseBlockCorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock() + public void CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock() { - ParseBlockTest("{ if (i > 0) { ; } }", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" if (i > 0) { ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - new MarkupTagBlock( - Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(";").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.None))), - Factory.Code(" } ").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("{ if (i > 0) { ; } }"); } [Fact] - public void ParseBlockSupportsAllKindsOfImplicitMarkupInCodeBlock() + public void SupportsAllKindsOfImplicitMarkupInCodeBlock() { ParseBlockTest("{" + Environment.NewLine + " if(true) {" + Environment.NewLine @@ -650,42 +212,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + " if(!false) {" + Environment.NewLine + "

A real tag!

" + Environment.NewLine + " }" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code($"{Environment.NewLine} if(true) {{{Environment.NewLine}") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - Factory.Markup(" "), - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("Single Line Markup" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - ), - Factory.Code($" }}{Environment.NewLine} foreach (var p in Enumerable.Range(1, 10)) {{{Environment.NewLine} ").AsStatement(), - new MarkupBlock( - new MarkupTagBlock( - Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("The number is ").Accepts(AcceptedCharactersInternal.None), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("p").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - new MarkupTagBlock( - Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.None))), - Factory.Code($"{Environment.NewLine} }}{Environment.NewLine} if(!false) {{{Environment.NewLine}").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("A real tag!"), - new MarkupTagBlock( - Factory.Markup("

").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None) - ), - Factory.Code(" }" + Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + + "}"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerCommentTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerCommentTest.cs index 2ff59a679b..64dafafa16 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerCommentTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerCommentTest.cs @@ -7,16 +7,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpTokenizerCommentTest : CSharpTokenizerTestBase { - private new CSharpSymbol IgnoreRemaining => (CSharpSymbol)base.IgnoreRemaining; + private new CSharpToken IgnoreRemaining => (CSharpToken)base.IgnoreRemaining; [Fact] public void Next_Ignores_Star_At_EOF_In_RazorComment() { TestTokenizer( "@* Foo * Bar * Baz *", - new CSharpSymbol("@", CSharpSymbolType.RazorCommentTransition), - new CSharpSymbol("*", CSharpSymbolType.RazorCommentStar), - new CSharpSymbol(" Foo * Bar * Baz *", CSharpSymbolType.RazorComment)); + new CSharpToken("@", CSharpTokenType.RazorCommentTransition), + new CSharpToken("*", CSharpTokenType.RazorCommentStar), + new CSharpToken(" Foo * Bar * Baz *", CSharpTokenType.RazorComment)); } [Fact] @@ -24,11 +24,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "@* Foo * Bar * Baz *@", - new CSharpSymbol("@", CSharpSymbolType.RazorCommentTransition), - new CSharpSymbol("*", CSharpSymbolType.RazorCommentStar), - new CSharpSymbol(" Foo * Bar * Baz ", CSharpSymbolType.RazorComment), - new CSharpSymbol("*", CSharpSymbolType.RazorCommentStar), - new CSharpSymbol("@", CSharpSymbolType.RazorCommentTransition)); + new CSharpToken("@", CSharpTokenType.RazorCommentTransition), + new CSharpToken("*", CSharpTokenType.RazorCommentStar), + new CSharpToken(" Foo * Bar * Baz ", CSharpTokenType.RazorComment), + new CSharpToken("*", CSharpTokenType.RazorCommentStar), + new CSharpToken("@", CSharpTokenType.RazorCommentTransition)); } [Fact] @@ -36,59 +36,59 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "@* Foo Bar Baz *@", - new CSharpSymbol("@", CSharpSymbolType.RazorCommentTransition), - new CSharpSymbol("*", CSharpSymbolType.RazorCommentStar), - new CSharpSymbol(" Foo Bar Baz ", CSharpSymbolType.RazorComment), - new CSharpSymbol("*", CSharpSymbolType.RazorCommentStar), - new CSharpSymbol("@", CSharpSymbolType.RazorCommentTransition)); + new CSharpToken("@", CSharpTokenType.RazorCommentTransition), + new CSharpToken("*", CSharpTokenType.RazorCommentStar), + new CSharpToken(" Foo Bar Baz ", CSharpTokenType.RazorComment), + new CSharpToken("*", CSharpTokenType.RazorCommentStar), + new CSharpToken("@", CSharpTokenType.RazorCommentTransition)); } [Fact] public void Next_Returns_Comment_Token_For_Entire_Single_Line_Comment() { - TestTokenizer("// Foo Bar Baz", new CSharpSymbol("// Foo Bar Baz", CSharpSymbolType.Comment)); + TestTokenizer("// Foo Bar Baz", new CSharpToken("// Foo Bar Baz", CSharpTokenType.Comment)); } [Fact] public void Single_Line_Comment_Is_Terminated_By_Newline() { - TestTokenizer("// Foo Bar Baz\na", new CSharpSymbol("// Foo Bar Baz", CSharpSymbolType.Comment), IgnoreRemaining); + TestTokenizer("// Foo Bar Baz\na", new CSharpToken("// Foo Bar Baz", CSharpTokenType.Comment), IgnoreRemaining); } [Fact] public void Multi_Line_Comment_In_Single_Line_Comment_Has_No_Effect() { - TestTokenizer("// Foo/*Bar*/ Baz\na", new CSharpSymbol("// Foo/*Bar*/ Baz", CSharpSymbolType.Comment), IgnoreRemaining); + TestTokenizer("// Foo/*Bar*/ Baz\na", new CSharpToken("// Foo/*Bar*/ Baz", CSharpTokenType.Comment), IgnoreRemaining); } [Fact] public void Next_Returns_Comment_Token_For_Entire_Multi_Line_Comment() { - TestTokenizer("/* Foo\nBar\nBaz */", new CSharpSymbol("/* Foo\nBar\nBaz */", CSharpSymbolType.Comment)); + TestTokenizer("/* Foo\nBar\nBaz */", new CSharpToken("/* Foo\nBar\nBaz */", CSharpTokenType.Comment)); } [Fact] public void Multi_Line_Comment_Is_Terminated_By_End_Sequence() { - TestTokenizer("/* Foo\nBar\nBaz */a", new CSharpSymbol("/* Foo\nBar\nBaz */", CSharpSymbolType.Comment), IgnoreRemaining); + TestTokenizer("/* Foo\nBar\nBaz */a", new CSharpToken("/* Foo\nBar\nBaz */", CSharpTokenType.Comment), IgnoreRemaining); } [Fact] public void Unterminated_Multi_Line_Comment_Captures_To_EOF() { - TestTokenizer("/* Foo\nBar\nBaz", new CSharpSymbol("/* Foo\nBar\nBaz", CSharpSymbolType.Comment), IgnoreRemaining); + TestTokenizer("/* Foo\nBar\nBaz", new CSharpToken("/* Foo\nBar\nBaz", CSharpTokenType.Comment), IgnoreRemaining); } [Fact] public void Nested_Multi_Line_Comments_Terminated_At_First_End_Sequence() { - TestTokenizer("/* Foo/*\nBar\nBaz*/ */", new CSharpSymbol("/* Foo/*\nBar\nBaz*/", CSharpSymbolType.Comment), IgnoreRemaining); + TestTokenizer("/* Foo/*\nBar\nBaz*/ */", new CSharpToken("/* Foo/*\nBar\nBaz*/", CSharpTokenType.Comment), IgnoreRemaining); } [Fact] public void Nested_Multi_Line_Comments_Terminated_At_Full_End_Sequence() { - TestTokenizer("/* Foo\nBar\nBaz* */", new CSharpSymbol("/* Foo\nBar\nBaz* */", CSharpSymbolType.Comment), IgnoreRemaining); + TestTokenizer("/* Foo\nBar\nBaz* */", new CSharpToken("/* Foo\nBar\nBaz* */", CSharpTokenType.Comment), IgnoreRemaining); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerIdentifierTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerIdentifierTest.cs index fe17606261..b24c976dc9 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerIdentifierTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerIdentifierTest.cs @@ -10,73 +10,73 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void Simple_Identifier_Is_Recognized() { - TestTokenizer("foo", new CSharpSymbol("foo", CSharpSymbolType.Identifier)); + TestTokenizer("foo", new CSharpToken("foo", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Starting_With_Underscore_Is_Recognized() { - TestTokenizer("_foo", new CSharpSymbol("_foo", CSharpSymbolType.Identifier)); + TestTokenizer("_foo", new CSharpToken("_foo", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Contain_Digits() { - TestTokenizer("foo4", new CSharpSymbol("foo4", CSharpSymbolType.Identifier)); + TestTokenizer("foo4", new CSharpToken("foo4", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Start_With_Titlecase_Letter() { - TestTokenizer("ῼfoo", new CSharpSymbol("ῼfoo", CSharpSymbolType.Identifier)); + TestTokenizer("ῼfoo", new CSharpToken("ῼfoo", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Start_With_Letter_Modifier() { - TestTokenizer("ᵊfoo", new CSharpSymbol("ᵊfoo", CSharpSymbolType.Identifier)); + TestTokenizer("ᵊfoo", new CSharpToken("ᵊfoo", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Start_With_Other_Letter() { - TestTokenizer("ƻfoo", new CSharpSymbol("ƻfoo", CSharpSymbolType.Identifier)); + TestTokenizer("ƻfoo", new CSharpToken("ƻfoo", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Start_With_Number_Letter() { - TestTokenizer("Ⅽool", new CSharpSymbol("Ⅽool", CSharpSymbolType.Identifier)); + TestTokenizer("Ⅽool", new CSharpToken("Ⅽool", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Contain_Non_Spacing_Mark() { - TestTokenizer("foo\u0300", new CSharpSymbol("foo\u0300", CSharpSymbolType.Identifier)); + TestTokenizer("foo\u0300", new CSharpToken("foo\u0300", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Contain_Spacing_Combining_Mark() { - TestTokenizer("fooः", new CSharpSymbol("fooः", CSharpSymbolType.Identifier)); + TestTokenizer("fooः", new CSharpToken("fooः", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Contain_Non_English_Digit() { - TestTokenizer("foo١", new CSharpSymbol("foo١", CSharpSymbolType.Identifier)); + TestTokenizer("foo١", new CSharpToken("foo١", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Contain_Connector_Punctuation() { - TestTokenizer("foo‿bar", new CSharpSymbol("foo‿bar", CSharpSymbolType.Identifier)); + TestTokenizer("foo‿bar", new CSharpToken("foo‿bar", CSharpTokenType.Identifier)); } [Fact] public void Identifier_Can_Contain_Format_Character() { - TestTokenizer("foo؃bar", new CSharpSymbol("foo؃bar", CSharpSymbolType.Identifier)); + TestTokenizer("foo؃bar", new CSharpToken("foo؃bar", CSharpTokenType.Identifier)); } [Fact] @@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void TestKeyword(string keyword, CSharpKeyword keywordType) { - TestTokenizer(keyword, new CSharpSymbol(keyword, CSharpSymbolType.Keyword) { Keyword = keywordType }); + TestTokenizer(keyword, new CSharpToken(keyword, CSharpTokenType.Keyword) { Keyword = keywordType }); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerLiteralTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerLiteralTest.cs index 0d614bf84a..a10aea8ba9 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerLiteralTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerLiteralTest.cs @@ -8,280 +8,280 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpTokenizerLiteralTest : CSharpTokenizerTestBase { - private new CSharpSymbol IgnoreRemaining => (CSharpSymbol)base.IgnoreRemaining; + private new CSharpToken IgnoreRemaining => (CSharpToken)base.IgnoreRemaining; [Fact] public void Simple_Integer_Literal_Is_Recognized() { - TestSingleToken("01189998819991197253", CSharpSymbolType.IntegerLiteral); + TestSingleToken("01189998819991197253", CSharpTokenType.IntegerLiteral); } [Fact] public void Integer_Type_Suffix_Is_Recognized() { - TestSingleToken("42U", CSharpSymbolType.IntegerLiteral); - TestSingleToken("42u", CSharpSymbolType.IntegerLiteral); + TestSingleToken("42U", CSharpTokenType.IntegerLiteral); + TestSingleToken("42u", CSharpTokenType.IntegerLiteral); - TestSingleToken("42L", CSharpSymbolType.IntegerLiteral); - TestSingleToken("42l", CSharpSymbolType.IntegerLiteral); + TestSingleToken("42L", CSharpTokenType.IntegerLiteral); + TestSingleToken("42l", CSharpTokenType.IntegerLiteral); - TestSingleToken("42UL", CSharpSymbolType.IntegerLiteral); - TestSingleToken("42Ul", CSharpSymbolType.IntegerLiteral); + TestSingleToken("42UL", CSharpTokenType.IntegerLiteral); + TestSingleToken("42Ul", CSharpTokenType.IntegerLiteral); - TestSingleToken("42uL", CSharpSymbolType.IntegerLiteral); - TestSingleToken("42ul", CSharpSymbolType.IntegerLiteral); + TestSingleToken("42uL", CSharpTokenType.IntegerLiteral); + TestSingleToken("42ul", CSharpTokenType.IntegerLiteral); - TestSingleToken("42LU", CSharpSymbolType.IntegerLiteral); - TestSingleToken("42Lu", CSharpSymbolType.IntegerLiteral); + TestSingleToken("42LU", CSharpTokenType.IntegerLiteral); + TestSingleToken("42Lu", CSharpTokenType.IntegerLiteral); - TestSingleToken("42lU", CSharpSymbolType.IntegerLiteral); - TestSingleToken("42lu", CSharpSymbolType.IntegerLiteral); + TestSingleToken("42lU", CSharpTokenType.IntegerLiteral); + TestSingleToken("42lu", CSharpTokenType.IntegerLiteral); } [Fact] public void Trailing_Letter_Is_Not_Part_Of_Integer_Literal_If_Not_Type_Sufix() { - TestTokenizer("42a", new CSharpSymbol("42", CSharpSymbolType.IntegerLiteral), IgnoreRemaining); + TestTokenizer("42a", new CSharpToken("42", CSharpTokenType.IntegerLiteral), IgnoreRemaining); } [Fact] public void Simple_Hex_Literal_Is_Recognized() { - TestSingleToken("0x0123456789ABCDEF", CSharpSymbolType.IntegerLiteral); + TestSingleToken("0x0123456789ABCDEF", CSharpTokenType.IntegerLiteral); } [Fact] public void Integer_Type_Suffix_Is_Recognized_In_Hex_Literal() { - TestSingleToken("0xDEADBEEFU", CSharpSymbolType.IntegerLiteral); - TestSingleToken("0xDEADBEEFu", CSharpSymbolType.IntegerLiteral); + TestSingleToken("0xDEADBEEFU", CSharpTokenType.IntegerLiteral); + TestSingleToken("0xDEADBEEFu", CSharpTokenType.IntegerLiteral); - TestSingleToken("0xDEADBEEFL", CSharpSymbolType.IntegerLiteral); - TestSingleToken("0xDEADBEEFl", CSharpSymbolType.IntegerLiteral); + TestSingleToken("0xDEADBEEFL", CSharpTokenType.IntegerLiteral); + TestSingleToken("0xDEADBEEFl", CSharpTokenType.IntegerLiteral); - TestSingleToken("0xDEADBEEFUL", CSharpSymbolType.IntegerLiteral); - TestSingleToken("0xDEADBEEFUl", CSharpSymbolType.IntegerLiteral); + TestSingleToken("0xDEADBEEFUL", CSharpTokenType.IntegerLiteral); + TestSingleToken("0xDEADBEEFUl", CSharpTokenType.IntegerLiteral); - TestSingleToken("0xDEADBEEFuL", CSharpSymbolType.IntegerLiteral); - TestSingleToken("0xDEADBEEFul", CSharpSymbolType.IntegerLiteral); + TestSingleToken("0xDEADBEEFuL", CSharpTokenType.IntegerLiteral); + TestSingleToken("0xDEADBEEFul", CSharpTokenType.IntegerLiteral); - TestSingleToken("0xDEADBEEFLU", CSharpSymbolType.IntegerLiteral); - TestSingleToken("0xDEADBEEFLu", CSharpSymbolType.IntegerLiteral); + TestSingleToken("0xDEADBEEFLU", CSharpTokenType.IntegerLiteral); + TestSingleToken("0xDEADBEEFLu", CSharpTokenType.IntegerLiteral); - TestSingleToken("0xDEADBEEFlU", CSharpSymbolType.IntegerLiteral); - TestSingleToken("0xDEADBEEFlu", CSharpSymbolType.IntegerLiteral); + TestSingleToken("0xDEADBEEFlU", CSharpTokenType.IntegerLiteral); + TestSingleToken("0xDEADBEEFlu", CSharpTokenType.IntegerLiteral); } [Fact] public void Trailing_Letter_Is_Not_Part_Of_Hex_Literal_If_Not_Type_Sufix() { - TestTokenizer("0xDEADBEEFz", new CSharpSymbol("0xDEADBEEF", CSharpSymbolType.IntegerLiteral), IgnoreRemaining); + TestTokenizer("0xDEADBEEFz", new CSharpToken("0xDEADBEEF", CSharpTokenType.IntegerLiteral), IgnoreRemaining); } [Fact] public void Dot_Followed_By_Non_Digit_Is_Not_Part_Of_Real_Literal() { - TestTokenizer("3.a", new CSharpSymbol("3", CSharpSymbolType.IntegerLiteral), IgnoreRemaining); + TestTokenizer("3.a", new CSharpToken("3", CSharpTokenType.IntegerLiteral), IgnoreRemaining); } [Fact] public void Simple_Real_Literal_Is_Recognized() { - TestTokenizer("3.14159", new CSharpSymbol("3.14159", CSharpSymbolType.RealLiteral)); + TestTokenizer("3.14159", new CSharpToken("3.14159", CSharpTokenType.RealLiteral)); } [Fact] public void Real_Literal_Between_Zero_And_One_Is_Recognized() { - TestTokenizer(".14159", new CSharpSymbol(".14159", CSharpSymbolType.RealLiteral)); + TestTokenizer(".14159", new CSharpToken(".14159", CSharpTokenType.RealLiteral)); } [Fact] public void Integer_With_Real_Type_Suffix_Is_Recognized() { - TestSingleToken("42F", CSharpSymbolType.RealLiteral); - TestSingleToken("42f", CSharpSymbolType.RealLiteral); - TestSingleToken("42D", CSharpSymbolType.RealLiteral); - TestSingleToken("42d", CSharpSymbolType.RealLiteral); - TestSingleToken("42M", CSharpSymbolType.RealLiteral); - TestSingleToken("42m", CSharpSymbolType.RealLiteral); + TestSingleToken("42F", CSharpTokenType.RealLiteral); + TestSingleToken("42f", CSharpTokenType.RealLiteral); + TestSingleToken("42D", CSharpTokenType.RealLiteral); + TestSingleToken("42d", CSharpTokenType.RealLiteral); + TestSingleToken("42M", CSharpTokenType.RealLiteral); + TestSingleToken("42m", CSharpTokenType.RealLiteral); } [Fact] public void Integer_With_Exponent_Is_Recognized() { - TestSingleToken("1e10", CSharpSymbolType.RealLiteral); - TestSingleToken("1E10", CSharpSymbolType.RealLiteral); - TestSingleToken("1e+10", CSharpSymbolType.RealLiteral); - TestSingleToken("1E+10", CSharpSymbolType.RealLiteral); - TestSingleToken("1e-10", CSharpSymbolType.RealLiteral); - TestSingleToken("1E-10", CSharpSymbolType.RealLiteral); + TestSingleToken("1e10", CSharpTokenType.RealLiteral); + TestSingleToken("1E10", CSharpTokenType.RealLiteral); + TestSingleToken("1e+10", CSharpTokenType.RealLiteral); + TestSingleToken("1E+10", CSharpTokenType.RealLiteral); + TestSingleToken("1e-10", CSharpTokenType.RealLiteral); + TestSingleToken("1E-10", CSharpTokenType.RealLiteral); } [Fact] public void Real_Number_With_Type_Suffix_Is_Recognized() { - TestSingleToken("3.14F", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14f", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14D", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14d", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14M", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14m", CSharpSymbolType.RealLiteral); + TestSingleToken("3.14F", CSharpTokenType.RealLiteral); + TestSingleToken("3.14f", CSharpTokenType.RealLiteral); + TestSingleToken("3.14D", CSharpTokenType.RealLiteral); + TestSingleToken("3.14d", CSharpTokenType.RealLiteral); + TestSingleToken("3.14M", CSharpTokenType.RealLiteral); + TestSingleToken("3.14m", CSharpTokenType.RealLiteral); } [Fact] public void Real_Number_With_Exponent_Is_Recognized() { - TestSingleToken("3.14E10", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14e10", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14E+10", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14e+10", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14E-10", CSharpSymbolType.RealLiteral); - TestSingleToken("3.14e-10", CSharpSymbolType.RealLiteral); + TestSingleToken("3.14E10", CSharpTokenType.RealLiteral); + TestSingleToken("3.14e10", CSharpTokenType.RealLiteral); + TestSingleToken("3.14E+10", CSharpTokenType.RealLiteral); + TestSingleToken("3.14e+10", CSharpTokenType.RealLiteral); + TestSingleToken("3.14E-10", CSharpTokenType.RealLiteral); + TestSingleToken("3.14e-10", CSharpTokenType.RealLiteral); } [Fact] public void Real_Number_With_Exponent_And_Type_Suffix_Is_Recognized() { - TestSingleToken("3.14E+10F", CSharpSymbolType.RealLiteral); + TestSingleToken("3.14E+10F", CSharpTokenType.RealLiteral); } [Fact] public void Single_Character_Literal_Is_Recognized() { - TestSingleToken("'f'", CSharpSymbolType.CharacterLiteral); + TestSingleToken("'f'", CSharpTokenType.CharacterLiteral); } [Fact] public void Multi_Character_Literal_Is_Recognized() { - TestSingleToken("'foo'", CSharpSymbolType.CharacterLiteral); + TestSingleToken("'foo'", CSharpTokenType.CharacterLiteral); } [Fact] public void Character_Literal_Is_Terminated_By_EOF_If_Unterminated() { - TestSingleToken("'foo bar", CSharpSymbolType.CharacterLiteral); + TestSingleToken("'foo bar", CSharpTokenType.CharacterLiteral); } [Fact] public void Character_Literal_Not_Terminated_By_Escaped_Quote() { - TestSingleToken("'foo\\'bar'", CSharpSymbolType.CharacterLiteral); + TestSingleToken("'foo\\'bar'", CSharpTokenType.CharacterLiteral); } [Fact] public void Character_Literal_Is_Terminated_By_EOL_If_Unterminated() { - TestTokenizer("'foo\n", new CSharpSymbol("'foo", CSharpSymbolType.CharacterLiteral), IgnoreRemaining); + TestTokenizer("'foo\n", new CSharpToken("'foo", CSharpTokenType.CharacterLiteral), IgnoreRemaining); } [Fact] public void Character_Literal_Terminated_By_EOL_Even_When_Last_Char_Is_Slash() { - TestTokenizer("'foo\\\n", new CSharpSymbol("'foo\\", CSharpSymbolType.CharacterLiteral), IgnoreRemaining); + TestTokenizer("'foo\\\n", new CSharpToken("'foo\\", CSharpTokenType.CharacterLiteral), IgnoreRemaining); } [Fact] public void Character_Literal_Terminated_By_EOL_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff() { - TestTokenizer("'foo\\\nflarg", new CSharpSymbol("'foo\\", CSharpSymbolType.CharacterLiteral), IgnoreRemaining); + TestTokenizer("'foo\\\nflarg", new CSharpToken("'foo\\", CSharpTokenType.CharacterLiteral), IgnoreRemaining); } [Fact] public void Character_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash() { - TestTokenizer("'foo\\" + Environment.NewLine, new CSharpSymbol("'foo\\", CSharpSymbolType.CharacterLiteral), IgnoreRemaining); + TestTokenizer("'foo\\" + Environment.NewLine, new CSharpToken("'foo\\", CSharpTokenType.CharacterLiteral), IgnoreRemaining); } [Fact] public void Character_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff() { - TestTokenizer($"'foo\\{Environment.NewLine}flarg", new CSharpSymbol("'foo\\", CSharpSymbolType.CharacterLiteral), IgnoreRemaining); + TestTokenizer($"'foo\\{Environment.NewLine}flarg", new CSharpToken("'foo\\", CSharpTokenType.CharacterLiteral), IgnoreRemaining); } [Fact] public void Character_Literal_Allows_Escaped_Escape() { - TestTokenizer("'foo\\\\'blah", new CSharpSymbol("'foo\\\\'", CSharpSymbolType.CharacterLiteral), IgnoreRemaining); + TestTokenizer("'foo\\\\'blah", new CSharpToken("'foo\\\\'", CSharpTokenType.CharacterLiteral), IgnoreRemaining); } [Fact] public void String_Literal_Is_Recognized() { - TestSingleToken("\"foo\"", CSharpSymbolType.StringLiteral); + TestSingleToken("\"foo\"", CSharpTokenType.StringLiteral); } [Fact] public void String_Literal_Is_Terminated_By_EOF_If_Unterminated() { - TestSingleToken("\"foo bar", CSharpSymbolType.StringLiteral); + TestSingleToken("\"foo bar", CSharpTokenType.StringLiteral); } [Fact] public void String_Literal_Not_Terminated_By_Escaped_Quote() { - TestSingleToken("\"foo\\\"bar\"", CSharpSymbolType.StringLiteral); + TestSingleToken("\"foo\\\"bar\"", CSharpTokenType.StringLiteral); } [Fact] public void String_Literal_Is_Terminated_By_EOL_If_Unterminated() { - TestTokenizer("\"foo\n", new CSharpSymbol("\"foo", CSharpSymbolType.StringLiteral), IgnoreRemaining); + TestTokenizer("\"foo\n", new CSharpToken("\"foo", CSharpTokenType.StringLiteral), IgnoreRemaining); } [Fact] public void String_Literal_Terminated_By_EOL_Even_When_Last_Char_Is_Slash() { - TestTokenizer("\"foo\\\n", new CSharpSymbol("\"foo\\", CSharpSymbolType.StringLiteral), IgnoreRemaining); + TestTokenizer("\"foo\\\n", new CSharpToken("\"foo\\", CSharpTokenType.StringLiteral), IgnoreRemaining); } [Fact] public void String_Literal_Terminated_By_EOL_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff() { - TestTokenizer("\"foo\\\nflarg", new CSharpSymbol("\"foo\\", CSharpSymbolType.StringLiteral), IgnoreRemaining); + TestTokenizer("\"foo\\\nflarg", new CSharpToken("\"foo\\", CSharpTokenType.StringLiteral), IgnoreRemaining); } [Fact] public void String_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash() { - TestTokenizer("\"foo\\" + Environment.NewLine, new CSharpSymbol("\"foo\\", CSharpSymbolType.StringLiteral), IgnoreRemaining); + TestTokenizer("\"foo\\" + Environment.NewLine, new CSharpToken("\"foo\\", CSharpTokenType.StringLiteral), IgnoreRemaining); } [Fact] public void String_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff() { - TestTokenizer($"\"foo\\{Environment.NewLine}flarg", new CSharpSymbol("\"foo\\", CSharpSymbolType.StringLiteral), IgnoreRemaining); + TestTokenizer($"\"foo\\{Environment.NewLine}flarg", new CSharpToken("\"foo\\", CSharpTokenType.StringLiteral), IgnoreRemaining); } [Fact] public void String_Literal_Allows_Escaped_Escape() { - TestTokenizer("\"foo\\\\\"blah", new CSharpSymbol("\"foo\\\\\"", CSharpSymbolType.StringLiteral), IgnoreRemaining); + TestTokenizer("\"foo\\\\\"blah", new CSharpToken("\"foo\\\\\"", CSharpTokenType.StringLiteral), IgnoreRemaining); } [Fact] public void Verbatim_String_Literal_Can_Contain_Newlines() { - TestSingleToken("@\"foo\nbar\nbaz\"", CSharpSymbolType.StringLiteral); + TestSingleToken("@\"foo\nbar\nbaz\"", CSharpTokenType.StringLiteral); } [Fact] public void Verbatim_String_Literal_Not_Terminated_By_Escaped_Double_Quote() { - TestSingleToken("@\"foo\"\"bar\"", CSharpSymbolType.StringLiteral); + TestSingleToken("@\"foo\"\"bar\"", CSharpTokenType.StringLiteral); } [Fact] public void Verbatim_String_Literal_Is_Terminated_By_Slash_Double_Quote() { - TestTokenizer("@\"foo\\\"bar\"", new CSharpSymbol("@\"foo\\\"", CSharpSymbolType.StringLiteral), IgnoreRemaining); + TestTokenizer("@\"foo\\\"bar\"", new CSharpToken("@\"foo\\\"", CSharpTokenType.StringLiteral), IgnoreRemaining); } [Fact] public void Verbatim_String_Literal_Is_Terminated_By_EOF() { - TestSingleToken("@\"foo", CSharpSymbolType.StringLiteral); + TestSingleToken("@\"foo", CSharpTokenType.StringLiteral); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerOperatorsTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerOperatorsTest.cs index 67000e950b..0b600ea9bc 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerOperatorsTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerOperatorsTest.cs @@ -10,287 +10,287 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void LeftBrace_Is_Recognized() { - TestSingleToken("{", CSharpSymbolType.LeftBrace); + TestSingleToken("{", CSharpTokenType.LeftBrace); } [Fact] public void Plus_Is_Recognized() { - TestSingleToken("+", CSharpSymbolType.Plus); + TestSingleToken("+", CSharpTokenType.Plus); } [Fact] public void Assign_Is_Recognized() { - TestSingleToken("=", CSharpSymbolType.Assign); + TestSingleToken("=", CSharpTokenType.Assign); } [Fact] public void Arrow_Is_Recognized() { - TestSingleToken("->", CSharpSymbolType.Arrow); + TestSingleToken("->", CSharpTokenType.Arrow); } [Fact] public void AndAssign_Is_Recognized() { - TestSingleToken("&=", CSharpSymbolType.AndAssign); + TestSingleToken("&=", CSharpTokenType.AndAssign); } [Fact] public void RightBrace_Is_Recognized() { - TestSingleToken("}", CSharpSymbolType.RightBrace); + TestSingleToken("}", CSharpTokenType.RightBrace); } [Fact] public void Minus_Is_Recognized() { - TestSingleToken("-", CSharpSymbolType.Minus); + TestSingleToken("-", CSharpTokenType.Minus); } [Fact] public void LessThan_Is_Recognized() { - TestSingleToken("<", CSharpSymbolType.LessThan); + TestSingleToken("<", CSharpTokenType.LessThan); } [Fact] public void Equals_Is_Recognized() { - TestSingleToken("==", CSharpSymbolType.Equals); + TestSingleToken("==", CSharpTokenType.Equals); } [Fact] public void OrAssign_Is_Recognized() { - TestSingleToken("|=", CSharpSymbolType.OrAssign); + TestSingleToken("|=", CSharpTokenType.OrAssign); } [Fact] public void LeftBracket_Is_Recognized() { - TestSingleToken("[", CSharpSymbolType.LeftBracket); + TestSingleToken("[", CSharpTokenType.LeftBracket); } [Fact] public void Star_Is_Recognized() { - TestSingleToken("*", CSharpSymbolType.Star); + TestSingleToken("*", CSharpTokenType.Star); } [Fact] public void GreaterThan_Is_Recognized() { - TestSingleToken(">", CSharpSymbolType.GreaterThan); + TestSingleToken(">", CSharpTokenType.GreaterThan); } [Fact] public void NotEqual_Is_Recognized() { - TestSingleToken("!=", CSharpSymbolType.NotEqual); + TestSingleToken("!=", CSharpTokenType.NotEqual); } [Fact] public void XorAssign_Is_Recognized() { - TestSingleToken("^=", CSharpSymbolType.XorAssign); + TestSingleToken("^=", CSharpTokenType.XorAssign); } [Fact] public void RightBracket_Is_Recognized() { - TestSingleToken("]", CSharpSymbolType.RightBracket); + TestSingleToken("]", CSharpTokenType.RightBracket); } [Fact] public void Slash_Is_Recognized() { - TestSingleToken("/", CSharpSymbolType.Slash); + TestSingleToken("/", CSharpTokenType.Slash); } [Fact] public void QuestionMark_Is_Recognized() { - TestSingleToken("?", CSharpSymbolType.QuestionMark); + TestSingleToken("?", CSharpTokenType.QuestionMark); } [Fact] public void LessThanEqual_Is_Recognized() { - TestSingleToken("<=", CSharpSymbolType.LessThanEqual); + TestSingleToken("<=", CSharpTokenType.LessThanEqual); } [Fact] public void LeftShift_Is_Not_Specially_Recognized() { TestTokenizer("<<", - new CSharpSymbol("<", CSharpSymbolType.LessThan), - new CSharpSymbol("<", CSharpSymbolType.LessThan)); + new CSharpToken("<", CSharpTokenType.LessThan), + new CSharpToken("<", CSharpTokenType.LessThan)); } [Fact] public void LeftParen_Is_Recognized() { - TestSingleToken("(", CSharpSymbolType.LeftParenthesis); + TestSingleToken("(", CSharpTokenType.LeftParenthesis); } [Fact] public void Modulo_Is_Recognized() { - TestSingleToken("%", CSharpSymbolType.Modulo); + TestSingleToken("%", CSharpTokenType.Modulo); } [Fact] public void NullCoalesce_Is_Recognized() { - TestSingleToken("??", CSharpSymbolType.NullCoalesce); + TestSingleToken("??", CSharpTokenType.NullCoalesce); } [Fact] public void GreaterThanEqual_Is_Recognized() { - TestSingleToken(">=", CSharpSymbolType.GreaterThanEqual); + TestSingleToken(">=", CSharpTokenType.GreaterThanEqual); } [Fact] public void EqualGreaterThan_Is_Recognized() { - TestSingleToken("=>", CSharpSymbolType.GreaterThanEqual); + TestSingleToken("=>", CSharpTokenType.GreaterThanEqual); } [Fact] public void RightParen_Is_Recognized() { - TestSingleToken(")", CSharpSymbolType.RightParenthesis); + TestSingleToken(")", CSharpTokenType.RightParenthesis); } [Fact] public void And_Is_Recognized() { - TestSingleToken("&", CSharpSymbolType.And); + TestSingleToken("&", CSharpTokenType.And); } [Fact] public void DoubleColon_Is_Recognized() { - TestSingleToken("::", CSharpSymbolType.DoubleColon); + TestSingleToken("::", CSharpTokenType.DoubleColon); } [Fact] public void PlusAssign_Is_Recognized() { - TestSingleToken("+=", CSharpSymbolType.PlusAssign); + TestSingleToken("+=", CSharpTokenType.PlusAssign); } [Fact] public void Semicolon_Is_Recognized() { - TestSingleToken(";", CSharpSymbolType.Semicolon); + TestSingleToken(";", CSharpTokenType.Semicolon); } [Fact] public void Tilde_Is_Recognized() { - TestSingleToken("~", CSharpSymbolType.Tilde); + TestSingleToken("~", CSharpTokenType.Tilde); } [Fact] public void DoubleOr_Is_Recognized() { - TestSingleToken("||", CSharpSymbolType.DoubleOr); + TestSingleToken("||", CSharpTokenType.DoubleOr); } [Fact] public void ModuloAssign_Is_Recognized() { - TestSingleToken("%=", CSharpSymbolType.ModuloAssign); + TestSingleToken("%=", CSharpTokenType.ModuloAssign); } [Fact] public void Colon_Is_Recognized() { - TestSingleToken(":", CSharpSymbolType.Colon); + TestSingleToken(":", CSharpTokenType.Colon); } [Fact] public void Not_Is_Recognized() { - TestSingleToken("!", CSharpSymbolType.Not); + TestSingleToken("!", CSharpTokenType.Not); } [Fact] public void DoubleAnd_Is_Recognized() { - TestSingleToken("&&", CSharpSymbolType.DoubleAnd); + TestSingleToken("&&", CSharpTokenType.DoubleAnd); } [Fact] public void DivideAssign_Is_Recognized() { - TestSingleToken("/=", CSharpSymbolType.DivideAssign); + TestSingleToken("/=", CSharpTokenType.DivideAssign); } [Fact] public void Comma_Is_Recognized() { - TestSingleToken(",", CSharpSymbolType.Comma); + TestSingleToken(",", CSharpTokenType.Comma); } [Fact] public void Xor_Is_Recognized() { - TestSingleToken("^", CSharpSymbolType.Xor); + TestSingleToken("^", CSharpTokenType.Xor); } [Fact] public void Decrement_Is_Recognized() { - TestSingleToken("--", CSharpSymbolType.Decrement); + TestSingleToken("--", CSharpTokenType.Decrement); } [Fact] public void MultiplyAssign_Is_Recognized() { - TestSingleToken("*=", CSharpSymbolType.MultiplyAssign); + TestSingleToken("*=", CSharpTokenType.MultiplyAssign); } [Fact] public void Dot_Is_Recognized() { - TestSingleToken(".", CSharpSymbolType.Dot); + TestSingleToken(".", CSharpTokenType.Dot); } [Fact] public void Or_Is_Recognized() { - TestSingleToken("|", CSharpSymbolType.Or); + TestSingleToken("|", CSharpTokenType.Or); } [Fact] public void Increment_Is_Recognized() { - TestSingleToken("++", CSharpSymbolType.Increment); + TestSingleToken("++", CSharpTokenType.Increment); } [Fact] public void MinusAssign_Is_Recognized() { - TestSingleToken("-=", CSharpSymbolType.MinusAssign); + TestSingleToken("-=", CSharpTokenType.MinusAssign); } [Fact] public void RightShift_Is_Not_Specially_Recognized() { TestTokenizer(">>", - new CSharpSymbol(">", CSharpSymbolType.GreaterThan), - new CSharpSymbol(">", CSharpSymbolType.GreaterThan)); + new CSharpToken(">", CSharpTokenType.GreaterThan), + new CSharpToken(">", CSharpTokenType.GreaterThan)); } [Fact] public void Hash_Is_Recognized() { - TestSingleToken("#", CSharpSymbolType.Hash); + TestSingleToken("#", CSharpTokenType.Hash); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerTest.cs index c4dabc0399..cf98382ef4 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpTokenizerTest : CSharpTokenizerTestBase { - private new CSharpSymbol IgnoreRemaining => (CSharpSymbol)base.IgnoreRemaining; + private new CSharpToken IgnoreRemaining => (CSharpToken)base.IgnoreRemaining; [Fact] public void Next_Returns_Null_When_EOF_Reached() @@ -20,8 +20,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "\r\ra", - new CSharpSymbol("\r", CSharpSymbolType.NewLine), - new CSharpSymbol("\r", CSharpSymbolType.NewLine), + new CSharpToken("\r", CSharpTokenType.NewLine), + new CSharpToken("\r", CSharpTokenType.NewLine), IgnoreRemaining); } @@ -30,8 +30,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "\n\na", - new CSharpSymbol("\n", CSharpSymbolType.NewLine), - new CSharpSymbol("\n", CSharpSymbolType.NewLine), + new CSharpToken("\n", CSharpTokenType.NewLine), + new CSharpToken("\n", CSharpTokenType.NewLine), IgnoreRemaining); } @@ -41,8 +41,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // NEL: Unicode "Next Line" U+0085 TestTokenizer( "\u0085\u0085a", - new CSharpSymbol("\u0085", CSharpSymbolType.NewLine), - new CSharpSymbol("\u0085", CSharpSymbolType.NewLine), + new CSharpToken("\u0085", CSharpTokenType.NewLine), + new CSharpToken("\u0085", CSharpTokenType.NewLine), IgnoreRemaining); } @@ -52,8 +52,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Unicode "Line Separator" U+2028 TestTokenizer( "\u2028\u2028a", - new CSharpSymbol("\u2028", CSharpSymbolType.NewLine), - new CSharpSymbol("\u2028", CSharpSymbolType.NewLine), + new CSharpToken("\u2028", CSharpTokenType.NewLine), + new CSharpToken("\u2028", CSharpTokenType.NewLine), IgnoreRemaining); } @@ -63,8 +63,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Unicode "Paragraph Separator" U+2029 TestTokenizer( "\u2029\u2029a", - new CSharpSymbol("\u2029", CSharpSymbolType.NewLine), - new CSharpSymbol("\u2029", CSharpSymbolType.NewLine), + new CSharpToken("\u2029", CSharpTokenType.NewLine), + new CSharpToken("\u2029", CSharpTokenType.NewLine), IgnoreRemaining); } @@ -73,8 +73,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "\r\n\r\na", - new CSharpSymbol("\r\n", CSharpSymbolType.NewLine), - new CSharpSymbol("\r\n", CSharpSymbolType.NewLine), + new CSharpToken("\r\n", CSharpTokenType.NewLine), + new CSharpToken("\r\n", CSharpTokenType.NewLine), IgnoreRemaining); } @@ -83,15 +83,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( " \f\t\u000B \n ", - new CSharpSymbol(" \f\t\u000B ", CSharpSymbolType.WhiteSpace), - new CSharpSymbol("\n", CSharpSymbolType.NewLine), - new CSharpSymbol(" ", CSharpSymbolType.WhiteSpace)); + new CSharpToken(" \f\t\u000B ", CSharpTokenType.WhiteSpace), + new CSharpToken("\n", CSharpTokenType.NewLine), + new CSharpToken(" ", CSharpTokenType.WhiteSpace)); } [Fact] public void Transition_Is_Recognized() { - TestSingleToken("@", CSharpSymbolType.Transition); + TestSingleToken("@", CSharpTokenType.Transition); } [Fact] @@ -99,8 +99,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "@(", - new CSharpSymbol("@", CSharpSymbolType.Transition), - new CSharpSymbol("(", CSharpSymbolType.LeftParenthesis)); + new CSharpToken("@", CSharpTokenType.Transition), + new CSharpToken("(", CSharpTokenType.LeftParenthesis)); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerTestBase.cs index a22d0d5ef1..6869138c1e 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTokenizerTestBase.cs @@ -5,7 +5,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public abstract class CSharpTokenizerTestBase : TokenizerTestBase { - private static CSharpSymbol _ignoreRemaining = new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown); + private static CSharpToken _ignoreRemaining = new CSharpToken(string.Empty, CSharpTokenType.Unknown); internal override object IgnoreRemaining { @@ -17,14 +17,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return new CSharpTokenizer(source); } - internal void TestSingleToken(string text, CSharpSymbolType expectedSymbolType) + internal void TestSingleToken(string text, CSharpTokenType expectedTokenType) { - TestTokenizer(text, new CSharpSymbol(text, expectedSymbolType)); + TestTokenizer(text, new CSharpToken(text, expectedTokenType)); } - internal void TestTokenizer(string input, params CSharpSymbol[] expectedSymbols) + internal void TestTokenizer(string input, params CSharpToken[] expectedTokens) { - base.TestTokenizer(input, expectedSymbols); + base.TestTokenizer(input, expectedTokens); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs index 903e68f313..f6e5085d91 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs @@ -13,122 +13,37 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void VerbatimBlock() { - ParseBlockTest("@{ foo(); }", - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{") - .Accepts(AcceptedCharactersInternal.None), - Factory.Code(" foo(); ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}") - .Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@{ foo(); }"); } [Fact] - public void InnerImplicitExpressionWithOnlySingleAtOutputsZeroLengthCodeSpan() + public void InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan() { - ParseBlockTest("{@}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp().AsImplicitExpression(KeywordSet, acceptTrailingDot: true).Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - designTime: true, - expectedErrors: new[] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), - "}") - }); + ParseBlockTest("{@}"); } [Fact] - public void InnerImplicitExpressionDoesNotAcceptDotAfterAt() + public void InnerImplicitExprDoesNotAcceptDotAfterAt() { - ParseBlockTest("{@.}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp().AsImplicitExpression(KeywordSet, acceptTrailingDot: true).Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - Factory.Code(".").AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - designTime: true, - expectedErrors: new[] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), - ".") - }); + ParseBlockTest("{@.}"); } [Fact] - public void InnerImplicitExpressionWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime() + public void InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime() { - ParseBlockTest("{" + Environment.NewLine - + " @" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + " ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp().AsImplicitExpression(KeywordSet, acceptTrailingDot: true).Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - Factory.Code(Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - /* designTimeParser */ true, - RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), Environment.NewLine.Length))); + ParseBlockTest("{" + Environment.NewLine + " @" + Environment.NewLine + "}", designTime: true); } [Fact] - public void InnerImplicitExpressionDoesNotAcceptTrailingNewlineInRunTimeMode() + public void InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode() { - ParseBlockTest("{@foo." + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo.").AsImplicitExpression(KeywordSet, acceptTrailingDot: true).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Code(Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("{@foo." + Environment.NewLine + "}"); } [Fact] - public void InnerImplicitExpressionAcceptsTrailingNewlineInDesignTimeMode() + public void InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode() { - ParseBlockTest("{@foo." + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo.").AsImplicitExpression(KeywordSet, acceptTrailingDot: true).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Code(Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - designTime: true); + ParseBlockTest("{@foo." + Environment.NewLine + "}", designTime: true); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpWhitespaceHandlingTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpWhitespaceHandlingTest.cs index d33ad7d8c7..44a642ce8b 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpWhitespaceHandlingTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpWhitespaceHandlingTest.cs @@ -9,26 +9,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public class CSharpWhitespaceHandlingTest : CsHtmlMarkupParserTestBase { [Fact] - public void StatementBlockDoesNotAcceptTrailingNewlineIfNewlinesAreSignificantToAncestor() + public void StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor() { - ParseBlockTest("@: @if (true) { }" + Environment.NewLine - + "}", - new MarkupBlock( - Factory.MarkupTransition() - .Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup(" ") - .With(new SpanEditHandler( - CSharpLanguageCharacteristics.Instance.TokenizeString, - AcceptedCharactersInternal.Any)), - new StatementBlock( - Factory.CodeTransition() - .Accepts(AcceptedCharactersInternal.None), - Factory.Code("if (true) { }") - .AsStatement() - ), - Factory.Markup(Environment.NewLine) - .Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("@: @if (true) { }" + Environment.NewLine + "}"); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeBlockEditHandlerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeBlockEditHandlerTest.cs new file mode 100644 index 0000000000..df17deb584 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeBlockEditHandlerTest.cs @@ -0,0 +1,221 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy +{ + public class CodeBlockEditHandlerTest + { + [Fact] + public void IsAcceptableReplacement_AcceptableReplacement_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 5), "H3ll0"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableReplacement_ChangeModifiesInvalidContent_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(6, 1), "!"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableReplacement_ChangeContainsInvalidContent_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 0), "{"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableReplacement_NotReplace_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 5), string.Empty); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletion_ValidChange_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 5), string.Empty); + + // Act + var result = CodeBlockEditHandler.IsAcceptableDeletion(span, change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableDeletion_InvalidChange_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(5, 3), string.Empty); + + // Act + var result = CodeBlockEditHandler.IsAcceptableDeletion(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletion_NotDelete_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "world"); + var change = new SourceChange(new SourceSpan(0, 0), "hello"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableDeletion(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void ModifiesInvalidContent_ValidContent_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 5), string.Empty); + + // Act + var result = CodeBlockEditHandler.ModifiesInvalidContent(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void ModifiesInvalidContent_InvalidContent_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(5, 7), string.Empty); + + // Act + var result = CodeBlockEditHandler.ModifiesInvalidContent(span, change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableInsertion_ValidChange_ReturnsTrue() + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), "hello"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableInsertion(change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableInsertion_InvalidChange_ReturnsFalse() + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), "{"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableInsertion(change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableInsertion_NotInsert_ReturnsFalse() + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 2), string.Empty); + + // Act + var result = CodeBlockEditHandler.IsAcceptableInsertion(change); + + // Assert + Assert.False(result); + } + + [Theory] + [InlineData("{")] + [InlineData("}")] + [InlineData("if (true) { }")] + public void ContainsInvalidContent_InvalidContent_ReturnsTrue(string content) + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), content); + + // Act + var result = CodeBlockEditHandler.ContainsInvalidContent(change); + + // Assert + Assert.True(result); + } + + [Theory] + [InlineData("var x = true;")] + [InlineData("if (true) Console.WriteLine('!')")] + public void ContainsInvalidContent_ValidContent_ReturnsFalse(string content) + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), content); + + // Act + var result = CodeBlockEditHandler.ContainsInvalidContent(change); + + // Assert + Assert.False(result); + } + + private static Span GetSpan(SourceLocation start, string content) + { + var spanBuilder = new SpanBuilder(start); + var tokens = CSharpLanguageCharacteristics.Instance.TokenizeString(content).ToArray(); + foreach (var token in tokens) + { + spanBuilder.Accept(token); + } + var span = spanBuilder.Build(); + + return span; + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs index 923a25a441..c3425055b4 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs @@ -58,22 +58,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedErrors) - { - var b = CreateSimpleBlockAndSpan(spanContent, blockKind, spanType, acceptedCharacters); - ParseBlockTest(document, b, expectedErrors ?? new RazorDiagnostic[0]); - } - internal void ImplicitExpressionTest(string input, string expected, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] errors) { - var factory = CreateSpanFactory(); - ParseBlockTest(SyntaxConstants.TransitionString + input, - new ExpressionBlock( - factory.CodeTransition(), - factory.Code(expected) - .AsImplicitExpression(KeywordSet) - .Accepts(acceptedCharacters)), - errors); + ParseBlockTest(SyntaxConstants.TransitionString + input); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/DirectiveCSharpTokenizerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/DirectiveCSharpTokenizerTest.cs index dcbbd2b1ef..7a1e0c070a 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/DirectiveCSharpTokenizerTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/DirectiveCSharpTokenizerTest.cs @@ -12,12 +12,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "\r\n @something \r\n @this is ignored", - new CSharpSymbol("\r\n", CSharpSymbolType.NewLine), - new CSharpSymbol(" ", CSharpSymbolType.WhiteSpace), - new CSharpSymbol("@", CSharpSymbolType.Transition), - new CSharpSymbol("something", CSharpSymbolType.Identifier), - new CSharpSymbol(" ", CSharpSymbolType.WhiteSpace), - new CSharpSymbol("\r\n", CSharpSymbolType.NewLine)); + new CSharpToken("\r\n", CSharpTokenType.NewLine), + new CSharpToken(" ", CSharpTokenType.WhiteSpace), + new CSharpToken("@", CSharpTokenType.Transition), + new CSharpToken("something", CSharpTokenType.Identifier), + new CSharpToken(" ", CSharpTokenType.WhiteSpace), + new CSharpToken("\r\n", CSharpTokenType.NewLine)); } [Fact] @@ -25,18 +25,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "@*included*@\r\n @something \"value\"\r\n @this is ignored", - new CSharpSymbol("@", CSharpSymbolType.RazorCommentTransition), - new CSharpSymbol("*", CSharpSymbolType.RazorCommentStar), - new CSharpSymbol("included", CSharpSymbolType.RazorComment), - new CSharpSymbol("*", CSharpSymbolType.RazorCommentStar), - new CSharpSymbol("@", CSharpSymbolType.RazorCommentTransition), - new CSharpSymbol("\r\n", CSharpSymbolType.NewLine), - new CSharpSymbol(" ", CSharpSymbolType.WhiteSpace), - new CSharpSymbol("@", CSharpSymbolType.Transition), - new CSharpSymbol("something", CSharpSymbolType.Identifier), - new CSharpSymbol(" ", CSharpSymbolType.WhiteSpace), - new CSharpSymbol("\"value\"", CSharpSymbolType.StringLiteral), - new CSharpSymbol("\r\n", CSharpSymbolType.NewLine)); + new CSharpToken("@", CSharpTokenType.RazorCommentTransition), + new CSharpToken("*", CSharpTokenType.RazorCommentStar), + new CSharpToken("included", CSharpTokenType.RazorComment), + new CSharpToken("*", CSharpTokenType.RazorCommentStar), + new CSharpToken("@", CSharpTokenType.RazorCommentTransition), + new CSharpToken("\r\n", CSharpTokenType.NewLine), + new CSharpToken(" ", CSharpTokenType.WhiteSpace), + new CSharpToken("@", CSharpTokenType.Transition), + new CSharpToken("something", CSharpTokenType.Identifier), + new CSharpToken(" ", CSharpTokenType.WhiteSpace), + new CSharpToken("\"value\"", CSharpTokenType.StringLiteral), + new CSharpToken("\r\n", CSharpTokenType.NewLine)); } internal override object CreateTokenizer(ITextDocument source) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/DirectiveHtmlTokenizerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/DirectiveHtmlTokenizerTest.cs index b75874b681..cffd0a0d0d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/DirectiveHtmlTokenizerTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/DirectiveHtmlTokenizerTest.cs @@ -12,9 +12,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "\r\n
Ignored
", - new HtmlSymbol("\r\n", HtmlSymbolType.NewLine), - new HtmlSymbol(" ", HtmlSymbolType.WhiteSpace), - new HtmlSymbol("<", HtmlSymbolType.OpenAngle)); + new HtmlToken("\r\n", HtmlTokenType.NewLine), + new HtmlToken(" ", HtmlTokenType.WhiteSpace), + new HtmlToken("<", HtmlTokenType.OpenAngle)); } [Fact] @@ -22,15 +22,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "\r\n @*included*@
Ignored
", - new HtmlSymbol("\r\n", HtmlSymbolType.NewLine), - new HtmlSymbol(" ", HtmlSymbolType.WhiteSpace), - new HtmlSymbol("@", HtmlSymbolType.RazorCommentTransition), - new HtmlSymbol("*", HtmlSymbolType.RazorCommentStar), - new HtmlSymbol("included", HtmlSymbolType.RazorComment), - new HtmlSymbol("*", HtmlSymbolType.RazorCommentStar), - new HtmlSymbol("@", HtmlSymbolType.RazorCommentTransition), - new HtmlSymbol(" ", HtmlSymbolType.WhiteSpace), - new HtmlSymbol("<", HtmlSymbolType.OpenAngle)); + new HtmlToken("\r\n", HtmlTokenType.NewLine), + new HtmlToken(" ", HtmlTokenType.WhiteSpace), + new HtmlToken("@", HtmlTokenType.RazorCommentTransition), + new HtmlToken("*", HtmlTokenType.RazorCommentStar), + new HtmlToken("included", HtmlTokenType.RazorComment), + new HtmlToken("*", HtmlTokenType.RazorCommentStar), + new HtmlToken("@", HtmlTokenType.RazorCommentTransition), + new HtmlToken(" ", HtmlTokenType.WhiteSpace), + new HtmlToken("<", HtmlTokenType.OpenAngle)); } internal override object CreateTokenizer(ITextDocument source) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ExceptionHelpers.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ExceptionHelpers.cs deleted file mode 100644 index c5ae54dea8..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ExceptionHelpers.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - public static class ExceptionHelpers - { - public static void ValidateArgumentException(string parameterName, string expectedMessage, ArgumentException exception) - { - Assert.Equal(string.Format("{0}{1}Parameter name: {2}", expectedMessage, Environment.NewLine, parameterName), exception.Message); - } - } -} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs index 64686c9fbb..1fae85afba 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs @@ -3,465 +3,220 @@ using System; using System.Linq; -using Moq; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class HtmlAttributeTest : CsHtmlMarkupParserTestBase { - public static TheoryData SymbolBoundAttributeNames + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace1() { - get - { - return new TheoryData - { - "[item]", - "[(item,", - "(click)", - "(^click)", - "*something", - "#local", - }; - } + var attributeName = "[item]"; + ParseBlockTest($""); } - [Theory] - [MemberData(nameof(SymbolBoundAttributeNames))] - public void SymbolBoundAttributes_BeforeEqualWhitespace(string attributeName) + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace2() { - // Arrange - var attributeNameLength = attributeName.Length; - var newlineLength = Environment.NewLine.Length; - var prefixLocation1 = new SourceLocation( - absoluteIndex: 2, - lineIndex: 0, - characterIndex: 2); - var suffixLocation1 = new SourceLocation( - absoluteIndex: 8 + newlineLength + attributeNameLength, - lineIndex: 1, - characterIndex: 5); - var valueLocation1 = new SourceLocation( - absoluteIndex: 5 + attributeNameLength + newlineLength, - lineIndex: 1, - characterIndex: 2); - var prefixLocation2 = SourceLocationTracker.Advance(suffixLocation1, "'"); - var suffixLocation2 = new SourceLocation( - absoluteIndex: 15 + attributeNameLength * 2 + newlineLength * 2, - lineIndex: 2, - characterIndex: 4); - var valueLocation2 = new SourceLocation( - absoluteIndex: 12 + attributeNameLength * 2 + newlineLength * 2, - lineIndex: 2, - characterIndex: 1); - - // Act & Assert - ParseBlockTest( - $"", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("( - $" {attributeName}{Environment.NewLine}='", prefixLocation1), - suffix: new LocationTagged("'", suffixLocation1)), - Factory.Markup($" {attributeName}{Environment.NewLine}='").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, valueLocation1), - value: new LocationTagged("Foo", valueLocation1))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - attributeName, - prefix: new LocationTagged( - $"\t{attributeName}={Environment.NewLine}'", prefixLocation2), - suffix: new LocationTagged("'", suffixLocation2)), - Factory.Markup($"\t{attributeName}={Environment.NewLine}'").With(SpanChunkGenerator.Null), - Factory.Markup("Bar").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, valueLocation2), - value: new LocationTagged("Bar", valueLocation2))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + var attributeName = "[(item,"; + ParseBlockTest($""); } - [Theory] - [MemberData(nameof(SymbolBoundAttributeNames))] - public void SymbolBoundAttributes_Whitespace(string attributeName) + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace3() { - // Arrange - var attributeNameLength = attributeName.Length; - var newlineLength = Environment.NewLine.Length; - var prefixLocation1 = new SourceLocation( - absoluteIndex: 2, - lineIndex: 0, - characterIndex: 2); - var suffixLocation1 = new SourceLocation( - absoluteIndex: 10 + newlineLength + attributeNameLength, - lineIndex: 1, - characterIndex: 7 + attributeNameLength); - var valueLocation1 = new SourceLocation( - absoluteIndex: 7 + attributeNameLength + newlineLength, - lineIndex: 1, - characterIndex: 4 + attributeNameLength); - var prefixLocation2 = SourceLocationTracker.Advance(suffixLocation1, "'"); - var suffixLocation2 = new SourceLocation( - absoluteIndex: 17 + attributeNameLength * 2 + newlineLength * 2, - lineIndex: 2, - characterIndex: 5 + attributeNameLength); - var valueLocation2 = new SourceLocation( - absoluteIndex: 14 + attributeNameLength * 2 + newlineLength * 2, - lineIndex: 2, - characterIndex: 2 + attributeNameLength); - - // Act & Assert - ParseBlockTest( - $"", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("( - $" {Environment.NewLine} {attributeName}='", prefixLocation1), - suffix: new LocationTagged("'", suffixLocation1)), - Factory.Markup($" {Environment.NewLine} {attributeName}='").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, valueLocation1), - value: new LocationTagged("Foo", valueLocation1))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - attributeName, - prefix: new LocationTagged( - $"\t{Environment.NewLine}{attributeName}='", prefixLocation2), - suffix: new LocationTagged("'", suffixLocation2)), - Factory.Markup($"\t{Environment.NewLine}{attributeName}='").With(SpanChunkGenerator.Null), - Factory.Markup("Bar").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, valueLocation2), - value: new LocationTagged("Bar", valueLocation2))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + var attributeName = "(click)"; + ParseBlockTest($""); } - [Theory] - [MemberData(nameof(SymbolBoundAttributeNames))] - public void SymbolBoundAttributes(string attributeName) + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace4() { - // Arrange - var attributeNameLength = attributeName.Length; - var suffixLocation = 8 + attributeNameLength; - var valueLocation = 5 + attributeNameLength; + var attributeName = "(^click)"; + ParseBlockTest($""); + } - // Act & Assert - ParseBlockTest($"", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("($" {attributeName}='", 2, 0, 2), - suffix: new LocationTagged("'", suffixLocation, 0, suffixLocation)), - Factory.Markup($" {attributeName}='").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, valueLocation, 0, valueLocation), - value: new LocationTagged("Foo", valueLocation, 0, valueLocation))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace5() + { + var attributeName = "*something"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace6() + { + var attributeName = "#local"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace1() + { + var attributeName = "[item]"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace2() + { + var attributeName = "[(item,"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace3() + { + var attributeName = "(click)"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace4() + { + var attributeName = "(^click)"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace5() + { + var attributeName = "*something"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace6() + { + var attributeName = "#local"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes1() + { + var attributeName = "[item]"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes2() + { + var attributeName = "[(item,"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes3() + { + var attributeName = "(click)"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes4() + { + var attributeName = "(^click)"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes5() + { + var attributeName = "*something"; + ParseBlockTest($""); + } + + [Fact] + public void SymbolBoundAttributes6() + { + var attributeName = "#local"; + ParseBlockTest($""); } [Fact] public void SimpleLiteralAttribute() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 12, 0, 12)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 9, 0, 9), value: new LocationTagged("Foo", 9, 0, 9))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void SimpleLiteralAttributeWithWhitespaceSurroundingEquals() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href \f\r\n= \t\n'", 2, 0, 2), - suffix: new LocationTagged("'", 19, 2, 4)), - Factory.Markup(" href \f\r\n= \t\n'").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 2, 1), value: new LocationTagged("Foo", 16, 2, 1))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void DynamicAttributeWithWhitespaceSurroundingEquals() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href \n= \r\n'", 2, 0, 2), - suffix: new LocationTagged("'", 18, 2, 5)), - Factory.Markup(" href \n= \r\n'").With(SpanChunkGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 14, 2, 1), 14, 2, 1), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void MultiPartLiteralAttribute() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 20, 0, 20)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(string.Empty, 9, 0, 9), value: new LocationTagged("Foo", 9, 0, 9))), - Factory.Markup(" Bar").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(" ", 12, 0, 12), value: new LocationTagged("Bar", 13, 0, 13))), - Factory.Markup(" Baz").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(" ", 16, 0, 16), value: new LocationTagged("Baz", 17, 0, 17))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void DoubleQuotedLiteralAttribute() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href=\"", 2, 0, 2), suffix: new LocationTagged("\"", 20, 0, 20)), - Factory.Markup(" href=\"").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(string.Empty, 9, 0, 9), value: new LocationTagged("Foo", 9, 0, 9))), - Factory.Markup(" Bar").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(" ", 12, 0, 12), value: new LocationTagged("Bar", 13, 0, 13))), - Factory.Markup(" Baz").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(" ", 16, 0, 16), value: new LocationTagged("Baz", 17, 0, 17))), - Factory.Markup("\"").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void NewLinePrecedingAttribute() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("("\r\nhref='", 2, 0, 2), - suffix: new LocationTagged("'", 13, 1, 9)), - Factory.Markup("\r\nhref='").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 10, 1, 6), - value: new LocationTagged("Foo", 10, 1, 6))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void NewLineBetweenAttributes() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("("\nhref='", 2, 0, 2), - suffix: new LocationTagged("'", 12, 1, 9)), - Factory.Markup("\nhref='").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 9, 1, 6), - value: new LocationTagged("Foo", 9, 1, 6))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "abcd", - prefix: new LocationTagged("\r\nabcd='", 13, 1, 10), - suffix: new LocationTagged("'", 24, 2, 9)), - Factory.Markup("\r\nabcd='").With(SpanChunkGenerator.Null), - Factory.Markup("Bar").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 21, 2, 6), - value: new LocationTagged("Bar", 21, 2, 6))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void WhitespaceAndNewLinePrecedingAttribute() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" \t\r\nhref='", 2, 0, 2), - suffix: new LocationTagged("'", 15, 1, 9)), - Factory.Markup(" \t\r\nhref='").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 12, 1, 6), - value: new LocationTagged("Foo", 12, 1, 6))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void UnquotedLiteralAttribute() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href=", 2, 0, 2), suffix: new LocationTagged(string.Empty, 11, 0, 11)), - Factory.Markup(" href=").With(SpanChunkGenerator.Null), - Factory.Markup("Foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(string.Empty, 8, 0, 8), value: new LocationTagged("Foo", 8, 0, 8)))), - new MarkupBlock(Factory.Markup(" Bar")), - new MarkupBlock(Factory.Markup(" Baz")), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void SimpleExpressionAttribute() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 13, 0, 13)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), 9, 0, 9), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void MultiValueExpressionAttribute() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 22, 0, 22)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), 9, 0, 9), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup(" bar").With(new LiteralAttributeChunkGenerator(new LocationTagged(" ", 13, 0, 13), new LocationTagged("bar", 14, 0, 14))), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(" ", 17, 0, 17), 18, 0, 18), - Factory.Markup(" ").With(SpanChunkGenerator.Null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("baz") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void VirtualPathAttributesWorkWithConditionalAttributes() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 23, 0, 23)), - Factory.Markup(" href='").With(SpanChunkGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), 9, 0, 9), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup(" ~/Foo/Bar") - .With(new LiteralAttributeChunkGenerator( - new LocationTagged(" ", 13, 0, 13), - new LocationTagged("~/Foo/Bar", 14, 0, 14))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void UnquotedAttributeWithCodeWithSpacesInBlock() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" value=", 6, 0, 6), suffix: new LocationTagged(string.Empty, 17, 0, 17)), - Factory.Markup(" value=").With(SpanChunkGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 13, 0, 13), 13, 0, 13), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)))), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void UnquotedAttributeWithCodeWithSpacesInDocument() { - ParseDocumentTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" value=", 6, 0, 6), suffix: new LocationTagged(string.Empty, 17, 0, 17)), - Factory.Markup(" value=").With(SpanChunkGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 13, 0, 13), 13, 0, 13), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)))), - Factory.Markup(" />")))); + ParseDocumentTest(""); } [Fact] @@ -473,18 +228,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var rewritten = attributeCollapser.Rewrite(results.Root); // Assert - EvaluateParseTree(rewritten, - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" foo='", 5, 0, 5), new LocationTagged("'", 13, 0, 13)), - Factory.Markup(" foo='").With(SpanChunkGenerator.Null), - new MarkupBlock( - Factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 11, 0, 11), new LocationTagged("@", 11, 0, 11))).Accepts(AcceptedCharactersInternal.None), - Factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />")))); + BaselineTest(rewritten); } [Fact] @@ -564,144 +308,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseBlockTest( RazorLanguageVersion.Experimental, - "", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" data-foo='", 5, 0, 5), new LocationTagged("'", 20, 0, 20)), - Factory.Markup(" data-foo='").With(SpanChunkGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 16, 0, 16), 16, 0, 16), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("
").Accepts(AcceptedCharactersInternal.None)))); + ""); } [Fact] public void ConditionalAttributesAreDisabledForDataAttributesInBlock() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("
").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInBlock() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("
").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void ConditionalAttributesAreDisabledForDataAttributesInDocument() { - ParseDocumentTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("")), - new MarkupTagBlock( - Factory.Markup("
")))); + ParseDocumentTest(""); } [Fact] public void ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInDocument() { - ParseDocumentTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("")), - new MarkupTagBlock( - Factory.Markup("
")))); - } - - private class EmptyTestDocument : ITextDocument - { - public int Length - { - get - { - throw new NotImplementedException(); - } - } - - public SourceLocation Location - { - get - { - throw new NotImplementedException(); - } - } - - public int Position - { - get - { - throw new NotImplementedException(); - } - - set - { - throw new NotImplementedException(); - } - } - - public int Peek() - { - throw new NotImplementedException(); - } - - public int Read() - { - throw new NotImplementedException(); - } + ParseDocumentTest(""); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs index 3abd53b105..b87eb28aa3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs @@ -9,649 +9,265 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public class HtmlBlockTest : CsHtmlMarkupParserTestBase { [Fact] - public void ParseBlockHandlesUnbalancedTripleDashHTMLComments() + public void HandlesUnbalancedTripleDashHTMLComments() { ParseDocumentTest( @"@{ -}", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine).AsStatement().AutoCompleteWith(null), - new MarkupBlock( - Factory.Markup(" "), - BlockFactory.HtmlCommentBlock(" Hello, I'm a comment that shouldn't break razor -"), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml()), - new RazorDiagnostic[0]); +}"); } [Fact] - public void ParseBlockHandlesOpenAngleAtEof() + public void HandlesOpenAngleAtEof() { ParseDocumentTest("@{" + Environment.NewLine - + "<", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine) - .AsStatement() - .AutoCompleteWith("}"), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("<"))))), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); + + "<"); } [Fact] - public void ParseBlockHandlesOpenAngleWithProperTagFollowingIt() + public void HandlesOpenAngleWithProperTagFollowingIt() { ParseDocumentTest("@{" + Environment.NewLine + "<" + Environment.NewLine + "", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine) - .AsStatement() - .AutoCompleteWith("}"), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("<" + Environment.NewLine)) - ), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)) - ), - Factory.EmptyCSharp().AsStatement() - ) - ), - designTime: true, - expectedErrors: new[] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2), contentLength: 4), "html"), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - }); + designTime: true); } [Fact] public void TagWithoutCloseAngleDoesNotTerminateBlock() { ParseBlockTest("< " + Environment.NewLine - + " ", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup($"< {Environment.NewLine} "))), - designTime: true, - expectedErrors: RazorDiagnosticFactory.CreateParsing_UnfinishedTag( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), string.Empty)); + + " "); } [Fact] - public void ParseBlockAllowsStartAndEndTagsToDifferInCase() + public void AllowsStartAndEndTagsToDifferInCase() { - ParseBlockTest("
  • Foo

  • ", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("
  • ").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("

    ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

    ").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("
  • ").Accepts(AcceptedCharactersInternal.None)) - )); + ParseBlockTest("
  • Foo

  • "); } [Fact] - public void ParseBlockReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon() + public void ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon() { ParseBlockTest("@:
  • Foo Bar Baz" + Environment.NewLine - + "bork", - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("
  • Foo Bar Baz" + Environment.NewLine) - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None)) - )); + + "bork"); } [Fact] - public void ParseBlockStopsParsingSingleLineBlockAtEOFIfNoEOLReached() + public void StopsParsingSingleLineBlockAtEOFIfNoEOLReached() { - ParseBlockTest("@:foo bar", - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup(@"foo bar") - .With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)) - )); + ParseBlockTest("@:foo bar"); } [Fact] - public void ParseBlockStopsAtMatchingCloseTagToStartTag() + public void StopsAtMatchingCloseTagToStartTag() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)) - )); + ParseBlockTest(""); } [Fact] - public void ParseBlockParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag() + public void ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)) - )); + ParseBlockTest(""); } [Fact] - public void ParseBlockAllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag() + public void AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)) - )); + ParseBlockTest(""); } [Fact] - public void ParseBlockWithSelfClosingTagJustEmitsTag() + public void WithSelfClosingTagJustEmitsTag() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)) - )); + ParseBlockTest(""); } [Fact] - public void ParseBlockCanHandleSelfClosingTagsWithinBlock() + public void CanHandleSelfClosingTagsWithinBlock() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)) - )); + ParseBlockTest(""); } [Fact] - public void ParseBlockSupportsTagsWithAttributes() + public void SupportsTagsWithAttributes() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" bar=\"", 4, 0, 4), new LocationTagged("\"", 13, 0, 13)), - Factory.Markup(" bar=\"").With(SpanChunkGenerator.Null), - Factory.Markup("baz").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 10, 0, 10), new LocationTagged("baz", 10, 0, 10))), - Factory.Markup("\"").With(SpanChunkGenerator.Null)), - Factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("(" zoop=", 24, 0, 24), new LocationTagged(string.Empty, 34, 0, 34)), - Factory.Markup(" zoop=").With(SpanChunkGenerator.Null), - Factory.Markup("zork").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 30, 0, 30), new LocationTagged("zork", 30, 0, 30)))), - Factory.Markup("/>").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockAllowsCloseAngleBracketInAttributeValueIfDoubleQuoted() + public void AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted() { - ParseBlockTest("\" />", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("(" baz=\"", 9, 0, 9), new LocationTagged("\"", 16, 0, 16)), - Factory.Markup(" baz=\"").With(SpanChunkGenerator.Null), - Factory.Markup(">").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 15, 0, 15), new LocationTagged(">", 15, 0, 15))), - Factory.Markup("\"").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest("\" />"); } [Fact] - public void ParseBlockAllowsCloseAngleBracketInAttributeValueIfSingleQuoted() + public void AllowsCloseAngleBracketInAttributeValueIfSingleQuoted() { - ParseBlockTest("\' />", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("(" baz='", 9, 0, 9), new LocationTagged("'", 16, 0, 16)), - Factory.Markup(" baz='").With(SpanChunkGenerator.Null), - Factory.Markup(">").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 15, 0, 15), new LocationTagged(">", 15, 0, 15))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest("\' />"); } [Fact] - public void ParseBlockAllowsSlashInAttributeValueIfDoubleQuoted() + public void AllowsSlashInAttributeValueIfDoubleQuoted() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("(" baz=\"", 9, 0, 9), new LocationTagged("\"", 16, 0, 16)), - Factory.Markup(" baz=\"").With(SpanChunkGenerator.Null), - Factory.Markup("/").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 15, 0, 15), new LocationTagged("/", 15, 0, 15))), - Factory.Markup("\"").With(SpanChunkGenerator.Null)), - Factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockAllowsSlashInAttributeValueIfSingleQuoted() + public void AllowsSlashInAttributeValueIfSingleQuoted() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("(" baz='", 9, 0, 9), new LocationTagged("'", 16, 0, 16)), - Factory.Markup(" baz='").With(SpanChunkGenerator.Null), - Factory.Markup("/").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 15, 0, 15), new LocationTagged("/", 15, 0, 15))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockTerminatesAtEOF() + public void TerminatesAtEOF() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None))), - RazorDiagnosticFactory.CreateParsing_MissingEndTag( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); + ParseBlockTest(""); } [Fact] - public void ParseBlockSupportsCommentAsBlock() + public void SupportsCommentAsBlock() { - ParseBlockTest("", new MarkupBlock(BlockFactory.HtmlCommentBlock(" foo "))); + ParseBlockTest(""); } [Fact] - public void ParseBlockSupportsCommentWithExtraDashAsBlock() + public void SupportsCommentWithExtraDashAsBlock() { - ParseBlockTest("", new MarkupBlock(BlockFactory.HtmlCommentBlock(" foo -"))); + ParseBlockTest(""); } [Fact] - public void ParseBlockSupportsCommentWithinBlock() + public void SupportsCommentWithinBlock() { - ParseBlockTest("barbaz", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("bar"), - BlockFactory.HtmlCommentBlock(" zoop "), - Factory.Markup("baz").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); - } - - public static TheoryData HtmlCommentSupportsMultipleDashesData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - return new TheoryData - { - { - "
    ", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None)), - blockFactory.HtmlCommentBlock("- Hello World -"), - new MarkupTagBlock( - factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None))) - }, - { - "
    ", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None)), - blockFactory.HtmlCommentBlock("-- Hello World --"), - new MarkupTagBlock( - factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None))) - }, - { - "
    ", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None)), - blockFactory.HtmlCommentBlock("--- Hello World ---"), - new MarkupTagBlock( - factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None))) - }, - { - "
    ", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None)), - blockFactory.HtmlCommentBlock("--- Hello < --- > World
    ---"), - new MarkupTagBlock( - factory.Markup("").Accepts(AcceptedCharactersInternal.None))) - }, - }; - } - } - - [Theory] - [MemberData(nameof(HtmlCommentSupportsMultipleDashesData))] - public void HtmlCommentSupportsMultipleDashes(string documentContent, object expectedOutput) - { - FixupSpans = true; - - ParseBlockTest(documentContent, (MarkupBlock)expectedOutput); + ParseBlockTest("barbaz"); } [Fact] - public void ParseBlockProperlyBalancesCommentStartAndEndTags() + public void HtmlCommentSupportsMultipleDashes() { - ParseBlockTest("", new MarkupBlock(BlockFactory.HtmlCommentBlock(""))); + ParseDocumentTest( +@"
    +
    +
    +
    +"); } [Fact] - public void ParseBlockTerminatesAtEOFWhenParsingComment() + public void ProperlyBalancesCommentStartAndEndTags() { - ParseBlockTest( - ""); } [Fact] - public void ParseBlockOnlyTerminatesCommentOnFullEndSequence() + public void TerminatesAtEOFWhenParsingComment() { - ParseBlockTest("", new MarkupBlock(BlockFactory.HtmlCommentBlock("--"))); + ParseBlockTest("-->", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - BlockFactory.HtmlCommentBlock("").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockTreatsMalformedTagsAsContent() + public void TerminatesCommentAtFirstOccurrenceOfEndSequence() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None))), - RazorDiagnosticFactory.CreateParsing_MissingEndTag( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); + ParseBlockTest("-->"); + } + + [Fact] + public void TreatsMalformedTagsAsContent() + { + ParseBlockTest(""); } [Fact] - public void ParseBlockParsesSGMLDeclarationAsEmptyTag() + public void ParsesSGMLDeclarationAsEmptyTag() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockTerminatesSGMLDeclarationAtFirstCloseAngle() + public void TerminatesSGMLDeclarationAtFirstCloseAngle() { - ParseBlockTest(" baz>", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - Factory.Markup(" baz>"), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(" baz>"); } [Fact] - public void ParseBlockParsesXMLProcessingInstructionAsEmptyTag() + public void ParsesXMLProcessingInstructionAsEmptyTag() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockTerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair() + public void TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair() { - ParseBlockTest(" baz", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - Factory.Markup(" baz"), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(" baz"); } [Fact] - public void ParseBlockDoesNotTerminateXMLProcessingInstructionAtCloseAngleUnlessPreceededByQuestionMark() + public void DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark() { - ParseBlockTest(" baz?>", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" baz?>").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + // ParseBlockDoesNotTerminateXMLProcessingInstructionAtCloseAngleUnlessPreceededByQuestionMark + ParseBlockTest(" baz?>"); } [Fact] - public void ParseBlockSupportsScriptTagsWithLessThanSignsInThem() + public void SupportsScriptTagsWithLessThanSignsInThem() { - ParseBlockTest(@"", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(@""); } [Fact] - public void ParseBlockSupportsScriptTagsWithSpacedLessThanSignsInThem() + public void SupportsScriptTagsWithSpacedLessThanSignsInThem() { - ParseBlockTest(@"", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(@""); } [Fact] - public void ParseBlockAcceptsEmptyTextTag() + public void AcceptsEmptyTextTag() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.MarkupTransition("")) - )); + ParseBlockTest(""); } [Fact] - public void ParseBlockAcceptsTextTagAsOuterTagButDoesNotRender() + public void AcceptsTextTagAsOuterTagButDoesNotRender() { - ParseBlockTest("Foo Bar Baz zoop", - new MarkupBlock( - new MarkupTagBlock( - Factory.MarkupTransition("")), - Factory.Markup("Foo Bar ").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" Baz"), - new MarkupTagBlock( - Factory.MarkupTransition("")))); + ParseBlockTest("Foo Bar Baz zoop"); } [Fact] - public void ParseBlockRendersLiteralTextTagIfDoubled() + public void RendersLiteralTextTagIfDoubled() { - ParseBlockTest("Foo Bar Baz zoop", - new MarkupBlock( - new MarkupTagBlock( - Factory.MarkupTransition("")), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo Bar "), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" Baz"), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.MarkupTransition("")))); + ParseBlockTest("Foo Bar Baz zoop"); } [Fact] - public void ParseBlockDoesNotConsiderPsuedoTagWithinMarkupBlock() + public void DoesNotConsiderPsuedoTagWithinMarkupBlock() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)) - )); + ParseBlockTest(""); } [Fact] - public void ParseBlockStopsParsingMidEmptyTagIfEOFReached() + public void StopsParsingMidEmptyTagIfEOFReached() { - ParseBlockTest("
    Foo @if(true) {} Bar", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Foo "), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(true) {}").AsStatement()), - Factory.Markup(" Bar"), - new MarkupTagBlock( - Factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest("
    Foo @if(true) {} Bar
    "); } [Fact] - public void ParseBlockIgnoresTagsInContentsOfScriptTag() + public void IgnoresTagsInContentsOfScriptTag() { - ParseBlockTest(@"", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(@""); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs index b7f5eeb87d..f77ee48b60 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs @@ -13,460 +13,182 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private static readonly TestFile Nested1000 = TestFile.Create("TestFiles/nested-1000.html", typeof(HtmlDocumentTest)); [Fact] - public void ParseDocument_NestedCodeBlockWithMarkupSetsDotAsMarkup() + public void NestedCodeBlockWithMarkupSetsDotAsMarkup() { - ParseDocumentTest("@if (true) { @if(false) {
    @something.
    } }", - new MarkupBlock( - Factory.EmptyHtml(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if (true) { ").AsStatement(), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(false) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("
    ", AcceptedCharactersInternal.None), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("something") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: false) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Markup("."), - BlockFactory.MarkupTagBlock("
    ", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement()), - Factory.Code(" }").AsStatement()))); + ParseDocumentTest("@if (true) { @if(false) {
    @something.
    } }"); } [Fact] - public void ParseDocumentOutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString() + public void OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString() { - ParseDocumentTest(string.Empty, new MarkupBlock(Factory.EmptyHtml())); + ParseDocumentTest(string.Empty); } [Fact] - public void ParseDocumentOutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan() + public void OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan() { - SingleSpanDocumentTest(" ", BlockKindInternal.Markup, SpanKindInternal.Markup); + ParseDocumentTest(" "); } [Fact] - public void ParseDocumentAcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan() + public void AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan() { - ParseDocumentTest("@", - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.EmptyHtml()), - RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1))); + ParseDocumentTest("@"); } [Fact] - public void ParseDocumentCorrectlyHandlesOddlySpacedHTMLElements() + public void CorrectlyHandlesOddlySpacedHTMLElements() { - ParseDocumentTest("

    Foo

    ", - new MarkupBlock( - BlockFactory.MarkupTagBlock("
    "), - new MarkupTagBlock( - Factory.Markup("(" class = '", 8, 0, 8), suffix: new LocationTagged("'", 21, 0, 21)), - Factory.Markup(" class = '").With(SpanChunkGenerator.Null), - Factory.Markup("bar").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(string.Empty, 18, 0, 18), value: new LocationTagged("bar", 18, 0, 18))), - Factory.Markup("'").With(SpanChunkGenerator.Null)), - Factory.Markup(">")), - Factory.Markup(" Foo "), - BlockFactory.MarkupTagBlock("

    "), - BlockFactory.MarkupTagBlock("
    "))); + ParseDocumentTest("

    Foo

    "); } [Fact] - public void ParseDocumentCorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement() + public void CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement() { - ParseDocumentTest("
    Foo @if(true) {} Bar
    ", - new MarkupBlock( - BlockFactory.MarkupTagBlock("
    "), - Factory.Markup("Foo "), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if(true) {}").AsStatement()), - Factory.Markup(" Bar"), - BlockFactory.MarkupTagBlock("
    "))); + ParseDocumentTest("
    Foo @if(true) {} Bar
    "); } [Fact] - public void ParseDocumentWithinSectionDoesNotCreateDocumentLevelSpan() + public void WithinSectionDoesNotCreateDocumentLevelSpan() { ParseDocumentTest("@section Foo {" + Environment.NewLine + " " + Environment.NewLine + "}", - new[] { SectionDirective.Directive, }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(Environment.NewLine + " "), - BlockFactory.MarkupTagBlock(""), - BlockFactory.MarkupTagBlock(""), - Factory.Markup(Environment.NewLine)), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive, }); } [Fact] - public void ParseDocumentParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered() + public void ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered() { - SingleSpanDocumentTest("foo baz", BlockKindInternal.Markup, SpanKindInternal.Markup); + ParseDocumentTest("foo baz"); } [Fact] - public void ParseDocumentHandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput() + public void HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput() { - ParseDocumentTest("foo @bar baz", - new MarkupBlock( - Factory.Markup("foo "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("bar") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Markup(" baz"))); + ParseDocumentTest("foo @bar baz"); } [Fact] - public void ParseDocumentEmitsAtSignAsMarkupIfAtEndOfFile() + public void EmitsAtSignAsMarkupIfAtEndOfFile() { - ParseDocumentTest("foo @", - new MarkupBlock( - Factory.Markup("foo "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.EmptyHtml()), - RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 1))); + ParseDocumentTest("foo @"); } [Fact] - public void ParseDocumentEmitsCodeBlockIfFirstCharacterIsSwapCharacter() + public void EmitsCodeBlockIfFirstCharacterIsSwapCharacter() { - ParseDocumentTest("@bar", - new MarkupBlock( - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("bar") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.EmptyHtml())); + ParseDocumentTest("@bar"); } [Fact] public void ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText() { - SingleSpanDocumentTest("anurse@microsoft.com", BlockKindInternal.Markup, SpanKindInternal.Markup); + ParseDocumentTest("example@microsoft.com"); } [Fact] - public void ParseDocumentDoesNotSwitchToCodeOnEmailAddressInAttribute() + public void DoesNotSwitchToCodeOnEmailAddressInAttribute() { - ParseDocumentTest("Email me", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href=\"", 2, 0, 2), new LocationTagged("\"", 36, 0, 36)), - Factory.Markup(" href=\"").With(SpanChunkGenerator.Null), - Factory.Markup("mailto:anurse@microsoft.com") - .With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), new LocationTagged("mailto:anurse@microsoft.com", 9, 0, 9))), - Factory.Markup("\"").With(SpanChunkGenerator.Null)), - Factory.Markup(">")), - Factory.Markup("Email me"), - BlockFactory.MarkupTagBlock(""))); + ParseDocumentTest("Email me"); } [Fact] - public void ParseDocumentDoesNotReturnErrorOnMismatchedTags() + public void DoesNotReturnErrorOnMismatchedTags() { - ParseDocumentTest("Foo

    Baz", - new MarkupBlock( - Factory.Markup("Foo "), - BlockFactory.MarkupTagBlock("
    "), - BlockFactory.MarkupTagBlock("

    "), - BlockFactory.MarkupTagBlock("

    "), - BlockFactory.MarkupTagBlock("

    "), - Factory.Markup(" Baz"))); + ParseDocumentTest("Foo

    Baz"); } [Fact] - public void ParseDocumentReturnsOneMarkupSegmentIfNoCodeBlocksEncountered() + public void ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered() { - ParseDocumentTest("Foo BazBarBar"); // Act - var symbol = sut.AcceptAllButLastDoubleHyphens(); + var token = sut.AcceptAllButLastDoubleHyphens(); // Assert - Assert.Equal(doubleHyphenSymbol, symbol); - Assert.True(sut.At(HtmlSymbolType.CloseAngle)); - Assert.Equal(doubleHyphenSymbol, sut.PreviousSymbol); + Assert.Equal(doubleHyphenToken, token); + Assert.True(sut.At(HtmlTokenType.CloseAngle)); + Assert.Equal(doubleHyphenToken, sut.PreviousToken); } [Fact] - public void AcceptAllButLastDoubleHypens_ReturnsTheDoubleHyphenSymbolAfterAcceptingTheDash() + public void AcceptAllButLastDoubleHypens_ReturnsTheDoubleHyphenTokenAfterAcceptingTheDash() { // Arrange var sut = CreateTestParserForContent("--->"); // Act - var symbol = sut.AcceptAllButLastDoubleHyphens(); + var token = sut.AcceptAllButLastDoubleHyphens(); // Assert - Assert.Equal(doubleHyphenSymbol, symbol); - Assert.True(sut.At(HtmlSymbolType.CloseAngle)); - Assert.True(HtmlMarkupParser.IsHyphen(sut.PreviousSymbol)); + Assert.Equal(doubleHyphenToken, token); + Assert.True(sut.At(HtmlTokenType.CloseAngle)); + Assert.True(HtmlMarkupParser.IsHyphen(sut.PreviousToken)); } [Fact] @@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy public void IsHtmlCommentAhead_ReturnsTrueForValidCommentTagWithExtraInfoAfter() { // Arrange - var sut = CreateTestParserForContent("-- comment --> the first part is a valid comment without the Open angle and bang symbols"); + var sut = CreateTestParserForContent("-- comment --> the first part is a valid comment without the Open angle and bang tokens"); // Act & Assert Assert.True(sut.IsHtmlCommentAhead()); @@ -157,8 +157,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy public void IsCommentContentEndingInvalid_ReturnsFalseForAllowedContent() { // Arrange - var expectedSymbol1 = new HtmlSymbol("a", HtmlSymbolType.Text); - var sequence = Enumerable.Range((int)'a', 26).Select(item => new HtmlSymbol(((char)item).ToString(), HtmlSymbolType.Text)); + var expectedToken1 = new HtmlToken("a", HtmlTokenType.Text); + var sequence = Enumerable.Range((int)'a', 26).Select(item => new HtmlToken(((char)item).ToString(), HtmlTokenType.Text)); // Act & Assert Assert.False(HtmlMarkupParser.IsCommentContentEndingInvalid(sequence)); @@ -168,8 +168,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy public void IsCommentContentEndingInvalid_ReturnsTrueForDisallowedContent() { // Arrange - var expectedSymbol1 = new HtmlSymbol("a", HtmlSymbolType.Text); - var sequence = new[] { new HtmlSymbol("<", HtmlSymbolType.OpenAngle), new HtmlSymbol("!", HtmlSymbolType.Bang), new HtmlSymbol("-", HtmlSymbolType.Text) }; + var expectedToken1 = new HtmlToken("a", HtmlTokenType.Text); + var sequence = new[] { new HtmlToken("<", HtmlTokenType.OpenAngle), new HtmlToken("!", HtmlTokenType.Bang), new HtmlToken("-", HtmlTokenType.Text) }; // Act & Assert Assert.True(HtmlMarkupParser.IsCommentContentEndingInvalid(sequence)); @@ -179,8 +179,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy public void IsCommentContentEndingInvalid_ReturnsFalseForEmptyContent() { // Arrange - var expectedSymbol1 = new HtmlSymbol("a", HtmlSymbolType.Text); - var sequence = Array.Empty(); + var expectedToken1 = new HtmlToken("a", HtmlTokenType.Text); + var sequence = Array.Empty(); // Act & Assert Assert.False(HtmlMarkupParser.IsCommentContentEndingInvalid(sequence)); @@ -188,9 +188,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy private class TestHtmlMarkupParser : HtmlMarkupParser { - public new HtmlSymbol PreviousSymbol + public new HtmlToken PreviousToken { - get => base.PreviousSymbol; + get => base.PreviousToken; } public new bool IsHtmlCommentAhead() @@ -203,7 +203,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy this.EnsureCurrent(); } - public new HtmlSymbol AcceptAllButLastDoubleHyphens() + public new HtmlToken AcceptAllButLastDoubleHyphens() { return base.AcceptAllButLastDoubleHyphens(); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlParserTestUtils.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlParserTestUtils.cs deleted file mode 100644 index 3aa1829169..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlParserTestUtils.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - internal class HtmlParserTestUtils - { - public static void RunSingleAtEscapeTest(Action testMethod, AcceptedCharactersInternal lastSpanAcceptedCharacters = AcceptedCharactersInternal.None) - { - var factory = new SpanFactory(); - testMethod("@@bar", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("").Accepts(lastSpanAcceptedCharacters)), - factory.Markup("@").Hidden(), - factory.Markup("@bar"), - new MarkupTagBlock( - factory.Markup("").Accepts(lastSpanAcceptedCharacters)))); - } - - public static void RunMultiAtEscapeTest(Action testMethod, AcceptedCharactersInternal lastSpanAcceptedCharacters = AcceptedCharactersInternal.None) - { - var factory = new SpanFactory(); - testMethod("@@@@@bar", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("").Accepts(lastSpanAcceptedCharacters)), - factory.Markup("@").Hidden(), - factory.Markup("@"), - factory.Markup("@").Hidden(), - factory.Markup("@"), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("bar") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - factory.Markup("").Accepts(lastSpanAcceptedCharacters)))); - } - } -} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs index 5f22a1bae7..4b200db19e 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs @@ -1,46 +1,37 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Collections.Generic; +using System.Text; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class HtmlTagsTest : CsHtmlMarkupParserTestBase { - public static IEnumerable VoidElementNames + private static readonly string[] VoidElementNames = new[] { - get - { - yield return new[] { "area" }; - yield return new[] { "base" }; - yield return new[] { "br" }; - yield return new[] { "col" }; - yield return new[] { "command" }; - yield return new[] { "embed" }; - yield return new[] { "hr" }; - yield return new[] { "img" }; - yield return new[] { "input" }; - yield return new[] { "keygen" }; - yield return new[] { "link" }; - yield return new[] { "meta" }; - yield return new[] { "param" }; - yield return new[] { "source" }; - yield return new[] { "track" }; - yield return new[] { "wbr" }; - } - } + "area", + "base", + "br", + "col", + "command", + "embed", + "hr", + "img", + "input", + "keygen", + "link", + "meta", + "param", + "source", + "track", + "wbr", + }; [Fact] public void EmptyTagNestsLikeNormalTag() { - ParseBlockTest("

    Bar", - new MarkupBlock( - BlockFactory.MarkupTagBlock("

    ", AcceptedCharactersInternal.None), - BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - RazorDiagnosticFactory.CreateParsing_MissingEndTag( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p")); + ParseBlockTest("

    Bar"); } [Fact] @@ -48,159 +39,137 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // This can happen in situations where a user is in VS' HTML editor and they're modifying // the contents of an HTML tag. - ParseBlockTest("<> Bar", - new MarkupBlock( - BlockFactory.MarkupTagBlock("<>", AcceptedCharactersInternal.None), - BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("<> Bar"); } [Fact] public void CommentTag() { - ParseBlockTest(" Bar", - new MarkupBlock( - BlockFactory.HtmlCommentBlock("Foo"), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest(" Bar"); } [Fact] public void DocTypeTag() { - ParseBlockTest(" foo", - new MarkupBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest(" foo"); } [Fact] public void ProcessingInstructionTag() { - ParseBlockTest(" foo", - new MarkupBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest(" foo"); } [Fact] public void ElementTags() { - ParseBlockTest("

    Foo

    Bar", - new MarkupBlock( - BlockFactory.MarkupTagBlock("

    ", AcceptedCharactersInternal.None), - Factory.Markup("Foo"), - BlockFactory.MarkupTagBlock("

    ", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest("

    Foo

    Bar"); } [Fact] public void TextTags() { - ParseBlockTest("Foo}", - new MarkupBlock( - new MarkupTagBlock( - Factory.MarkupTransition("")), - Factory.Markup("Foo").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.MarkupTransition("")))); + ParseBlockTest("Foo}"); } [Fact] public void CDataTag() { - ParseBlockTest(" Bar", - new MarkupBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None))); + ParseBlockTest(" Bar"); } [Fact] public void ScriptTag() { - ParseDocumentTest("", - new MarkupBlock( - BlockFactory.MarkupTagBlock(""))); + ParseDocumentTest(""); } [Fact] public void ScriptTag_WithNestedMalformedTag() { - ParseDocumentTest("", - new MarkupBlock( - BlockFactory.MarkupTagBlock(""))); + ParseDocumentTest(""); } [Fact] public void ScriptTag_WithNestedEndTag() { - ParseDocumentTest("", - new MarkupBlock( - BlockFactory.MarkupTagBlock(""))); + ParseDocumentTest(""); } [Fact] public void ScriptTag_WithNestedBeginTag() { - ParseDocumentTest("", - new MarkupBlock( - BlockFactory.MarkupTagBlock(""))); + ParseDocumentTest(""); } [Fact] public void ScriptTag_WithNestedTag() { - ParseDocumentTest("", - new MarkupBlock( - BlockFactory.MarkupTagBlock(""))); + ParseDocumentTest(""); } - [Theory] - [MemberData(nameof(VoidElementNames))] - public void VoidElementFollowedByContent(string tagName) + [Fact] + public void VoidElementFollowedByContent() { - ParseBlockTest("<" + tagName + ">foo", - new MarkupBlock( - BlockFactory.MarkupTagBlock("<" + tagName + ">", AcceptedCharactersInternal.None))); + // Arrange + var content = new StringBuilder(); + foreach (var tagName in VoidElementNames) + { + content.AppendLine("@{"); + content.AppendLine("<" + tagName + ">var x = true;"); + content.AppendLine("}"); + } + + // Act & Assert + ParseDocumentTest(content.ToString()); } - [Theory] - [MemberData(nameof(VoidElementNames))] - public void VoidElementFollowedByOtherTag(string tagName) + [Fact] + public void VoidElementFollowedByOtherTag() { - ParseBlockTest("<" + tagName + ">foo", - new MarkupBlock( - BlockFactory.MarkupTagBlock("<" + tagName + ">", AcceptedCharactersInternal.None))); + // Arrange + var content = new StringBuilder(); + foreach (var tagName in VoidElementNames) + { + content.AppendLine(@"{"); + content.AppendLine("<" + tagName + "> var x = true;"); + content.AppendLine("}"); + } + + // Act & Assert + ParseDocumentTest(content.ToString()); } - [Theory] - [MemberData(nameof(VoidElementNames))] - public void VoidElementFollowedByCloseTag(string tagName) + [Fact] + public void VoidElementFollowedByCloseTag() { - ParseBlockTest("<" + tagName + "> foo", - new MarkupBlock( - BlockFactory.MarkupTagBlock("<" + tagName + ">", AcceptedCharactersInternal.None), - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None))); + // Arrange + var content = new StringBuilder(); + foreach (var tagName in VoidElementNames) + { + content.AppendLine("@{"); + content.AppendLine("<" + tagName + "> var x = true;"); + content.AppendLine("}"); + } + + // Act & Assert + ParseDocumentTest(content.ToString()); } - [Theory] - [MemberData(nameof(VoidElementNames))] - public void IncompleteVoidElementEndTag(string tagName) + [Fact] + public void IncompleteVoidElementEndTag() { - ParseBlockTest("<" + tagName + ">", AcceptedCharactersInternal.None), - BlockFactory.MarkupTagBlock("foo#@i

    ", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("

    ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("foo#"), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("i").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("

    ").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest("

    foo#@i

    "); } [Fact] - public void ParseBlockSwitchesToCodeWhenSwapCharacterEncounteredMidTag() + public void SwitchesToCodeWhenSwapCharacterEncounteredMidTag() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockSwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue() + public void SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" bar=\"", 4, 0, 4), new LocationTagged("\"", 14, 0, 14)), - Factory.Markup(" bar=\"").With(SpanChunkGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockChunkGenerator(new LocationTagged(string.Empty, 10, 0, 10), 10, 0, 10), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("baz") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - Factory.Markup("\"").With(SpanChunkGenerator.Null)), - Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockSwitchesToCodeWhenSwapCharacterEncounteredInTagContent() + public void SwitchesToCodeWhenSwapCharacterEncounteredInTagContent() { - ParseBlockTest("@bar@boz", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("bar") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("boz") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest("@bar@boz"); } [Fact] - public void ParseBlockParsesCodeWithinSingleLineMarkup() + public void ParsesCodeWithinSingleLineMarkup() { // TODO: Fix at a later date, HTML should be a tag block: https://github.com/aspnet/Razor/issues/101 ParseBlockTest("@:
  • Foo @Bar Baz" + Environment.NewLine - + "bork", - new MarkupBlock( - Factory.MarkupTransition(), - Factory.MetaMarkup(":", HtmlSymbolType.Colon), - Factory.Markup("
  • Foo ").With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("Bar") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Markup(" Baz" + Environment.NewLine) - .Accepts(AcceptedCharactersInternal.None))); + + "bork"); } [Fact] - public void ParseBlockSupportsCodeWithinComment() + public void SupportsCodeWithinComment() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - BlockFactory.HtmlCommentBlock(Factory, f => new SyntaxTreeNode[] { - f.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace), - new ExpressionBlock( - f.CodeTransition(), - f.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - f.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace) }), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockSupportsCodeWithinSGMLDeclaration() + public void SupportsCodeWithinSGMLDeclaration() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockSupportsCodeWithinCDataDeclaration() + public void SupportsCodeWithinCDataDeclaration() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] - public void ParseBlockSupportsCodeWithinXMLProcessingInstruction() + public void SupportsCodeWithinXMLProcessingInstruction() { - ParseBlockTest("", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest(""); } [Fact] public void ParseBlockDoesNotSwitchToCodeOnEmailAddressInText() { - ParseBlockTest("anurse@microsoft.com", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("anurse@microsoft.com"), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest("anurse@microsoft.com"); } [Fact] - public void ParseBlockDoesNotSwitchToCodeOnEmailAddressInAttribute() + public void DoesNotSwitchToCodeOnEmailAddressInAttribute() { - ParseBlockTest("Email me", - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("(" href=\"", 2, 0, 2), new LocationTagged("\"", 36, 0, 36)), - Factory.Markup(" href=\"").With(SpanChunkGenerator.Null), - Factory.Markup("mailto:anurse@microsoft.com") - .With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), new LocationTagged("mailto:anurse@microsoft.com", 9, 0, 9))), - Factory.Markup("\"").With(SpanChunkGenerator.Null)), - Factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Email me"), - new MarkupTagBlock( - Factory.Markup("").Accepts(AcceptedCharactersInternal.None)))); + ParseBlockTest("Email me"); } [Fact] - public void ParseBlockGivesWhitespacePreceedingAtToCodeIfThereIsNoMarkupOnThatLine() + public void GivesWhitespacePreceedingAtToCodeIfThereIsNoMarkupOnThatLine() { ParseBlockTest("
      " + Environment.NewLine + " @foreach(var p in Products) {" + Environment.NewLine + "
    • Product: @p.Name
    • " + Environment.NewLine + " }" + Environment.NewLine - + "
    ", - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
      ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine), - new StatementBlock( - Factory.Code(" ").AsStatement(), - Factory.CodeTransition(), - Factory.Code("foreach(var p in Products) {" + Environment.NewLine).AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
    • ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Product: "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("p.Name") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("
    • ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code(" }" + Environment.NewLine).AsStatement().Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None)))); + + " "); } [Fact] @@ -251,33 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + " @foreach(var p in Products) {" + Environment.NewLine + "
  • Product: @p.Name
  • " + Environment.NewLine + " }" + Environment.NewLine - + " ", - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
      ")), - Factory.Markup(Environment.NewLine), - new StatementBlock( - Factory.Code(" ").AsStatement(), - Factory.CodeTransition(), - Factory.Code("foreach(var p in Products) {" + Environment.NewLine).AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
    • ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Product: "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("p.Name") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("
    • ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code(" }" + Environment.NewLine).AsStatement().Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
    ")))); + + " "); } [Fact] @@ -291,45 +108,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + " }" + Environment.NewLine + " " + Environment.NewLine + "}", - new[] { SectionDirective.Directive, }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(Environment.NewLine + " "), - new MarkupTagBlock( - Factory.Markup("
      ")), - Factory.Markup(Environment.NewLine), - new StatementBlock( - Factory.Code(" ").AsStatement(), - Factory.CodeTransition(), - Factory.Code("foreach(var p in Products) {" + Environment.NewLine).AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
    • ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Product: "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("p.Name") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("
    • ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code(" }" + Environment.NewLine).AsStatement().Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
    ")), - Factory.Markup(Environment.NewLine)), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive, }); } [Fact] @@ -340,53 +119,33 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "
  • Product: @p.Name
  • " + Environment.NewLine + " }" + Environment.NewLine + " ", - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("
      ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine + " "), - new StatementBlock( - Factory.CodeTransition(), - Factory.Code($"foreach(var p in Products) {{{Environment.NewLine} ").AsStatement(), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("
    • ").Accepts(AcceptedCharactersInternal.None)), - Factory.Markup("Product: "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("p.Name").AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("
    • ").Accepts(AcceptedCharactersInternal.None))), - Factory.Code(Environment.NewLine + " }").AsStatement().Accepts(AcceptedCharactersInternal.None)), - Factory.Markup(Environment.NewLine + " "), - new MarkupTagBlock( - Factory.Markup("
    ").Accepts(AcceptedCharactersInternal.None))), designTime: true); } // Tests for "@@" escape sequence: [Fact] - public void ParseBlockTreatsTwoAtSignsAsEscapeSequence() + public void TreatsTwoAtSignsAsEscapeSequence() { - HtmlParserTestUtils.RunSingleAtEscapeTest(ParseBlockTest); + ParseBlockTest("@@bar"); } [Fact] - public void ParseBlockTreatsPairsOfAtSignsAsEscapeSequence() + public void TreatsPairsOfAtSignsAsEscapeSequence() { - HtmlParserTestUtils.RunMultiAtEscapeTest(ParseBlockTest); + ParseBlockTest("@@@@@bar"); } [Fact] public void ParseDocumentTreatsTwoAtSignsAsEscapeSequence() { - HtmlParserTestUtils.RunSingleAtEscapeTest(ParseDocumentTest, lastSpanAcceptedCharacters: AcceptedCharactersInternal.Any); + ParseDocumentTest("@@bar"); } [Fact] public void ParseDocumentTreatsPairsOfAtSignsAsEscapeSequence() { - HtmlParserTestUtils.RunMultiAtEscapeTest(ParseDocumentTest, lastSpanAcceptedCharacters: AcceptedCharactersInternal.Any); + var factory = new SpanFactory(); + ParseDocumentTest("@@@@@bar"); } [Fact] @@ -394,27 +153,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseDocumentTest( "@section Foo { @@bar }", - new[] { SectionDirective.Directive, }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("")), - Factory.Markup("@").Hidden(), - Factory.Markup("@bar"), - new MarkupTagBlock( - Factory.Markup("")), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive, }); } [Fact] @@ -422,34 +161,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseDocumentTest( "@section Foo { @@@@@bar }", - new[] { SectionDirective.Directive, }, - new MarkupBlock( - Factory.EmptyHtml(), - new DirectiveBlock(new DirectiveChunkGenerator(SectionDirective.Directive), - Factory.CodeTransition(), - Factory.MetaCode("section").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Code, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.WhiteSpace), - Factory.Span(SpanKindInternal.Code, "Foo", CSharpSymbolType.Identifier).AsDirectiveToken(SectionDirective.Directive.Tokens[0]), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith(null, atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - Factory.Markup(" "), - new MarkupTagBlock( - Factory.Markup("")), - Factory.Markup("@").Hidden(), - Factory.Markup("@"), - Factory.Markup("@").Hidden(), - Factory.Markup("@"), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("bar") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("")), - Factory.Markup(" ")), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml())); + new[] { SectionDirective.Directive, }); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTokenizerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTokenizerTest.cs index 529c2f9118..9b54d75957 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTokenizerTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTokenizerTest.cs @@ -17,113 +17,113 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public void Text_Is_Recognized() { TestTokenizer("foo-9309&smlkmb;::-3029022,.sdkq92384", - new HtmlSymbol("foo-9309&smlkmb;::-3029022,.sdkq92384", HtmlSymbolType.Text)); + new HtmlToken("foo-9309&smlkmb;::-3029022,.sdkq92384", HtmlTokenType.Text)); } [Fact] public void Whitespace_Is_Recognized() { TestTokenizer(" \t\f ", - new HtmlSymbol(" \t\f ", HtmlSymbolType.WhiteSpace)); + new HtmlToken(" \t\f ", HtmlTokenType.WhiteSpace)); } [Fact] public void Newline_Is_Recognized() { TestTokenizer("\n\r\r\n", - new HtmlSymbol("\n", HtmlSymbolType.NewLine), - new HtmlSymbol("\r", HtmlSymbolType.NewLine), - new HtmlSymbol("\r\n", HtmlSymbolType.NewLine)); + new HtmlToken("\n", HtmlTokenType.NewLine), + new HtmlToken("\r", HtmlTokenType.NewLine), + new HtmlToken("\r\n", HtmlTokenType.NewLine)); } [Fact] public void Transition_Is_Not_Recognized_Mid_Text_If_Surrounded_By_Alphanumeric_Characters() { - TestSingleToken("foo@bar", HtmlSymbolType.Text); + TestSingleToken("foo@bar", HtmlTokenType.Text); } [Fact] public void OpenAngle_Is_Recognized() { - TestSingleToken("<", HtmlSymbolType.OpenAngle); + TestSingleToken("<", HtmlTokenType.OpenAngle); } [Fact] public void Bang_Is_Recognized() { - TestSingleToken("!", HtmlSymbolType.Bang); + TestSingleToken("!", HtmlTokenType.Bang); } [Fact] public void Solidus_Is_Recognized() { - TestSingleToken("/", HtmlSymbolType.ForwardSlash); + TestSingleToken("/", HtmlTokenType.ForwardSlash); } [Fact] public void QuestionMark_Is_Recognized() { - TestSingleToken("?", HtmlSymbolType.QuestionMark); + TestSingleToken("?", HtmlTokenType.QuestionMark); } [Fact] public void LeftBracket_Is_Recognized() { - TestSingleToken("[", HtmlSymbolType.LeftBracket); + TestSingleToken("[", HtmlTokenType.LeftBracket); } [Fact] public void CloseAngle_Is_Recognized() { - TestSingleToken(">", HtmlSymbolType.CloseAngle); + TestSingleToken(">", HtmlTokenType.CloseAngle); } [Fact] public void RightBracket_Is_Recognized() { - TestSingleToken("]", HtmlSymbolType.RightBracket); + TestSingleToken("]", HtmlTokenType.RightBracket); } [Fact] public void Equals_Is_Recognized() { - TestSingleToken("=", HtmlSymbolType.Equals); + TestSingleToken("=", HtmlTokenType.Equals); } [Fact] public void DoubleQuote_Is_Recognized() { - TestSingleToken("\"", HtmlSymbolType.DoubleQuote); + TestSingleToken("\"", HtmlTokenType.DoubleQuote); } [Fact] public void SingleQuote_Is_Recognized() { - TestSingleToken("'", HtmlSymbolType.SingleQuote); + TestSingleToken("'", HtmlTokenType.SingleQuote); } [Fact] public void Transition_Is_Recognized() { - TestSingleToken("@", HtmlSymbolType.Transition); + TestSingleToken("@", HtmlTokenType.Transition); } [Fact] public void DoubleHyphen_Is_Recognized() { - TestSingleToken("--", HtmlSymbolType.DoubleHyphen); + TestSingleToken("--", HtmlTokenType.DoubleHyphen); } [Fact] public void SingleHyphen_Is_Not_Recognized() { - TestSingleToken("-", HtmlSymbolType.Text); + TestSingleToken("-", HtmlTokenType.Text); } [Fact] public void SingleHyphen_Mid_Text_Is_Not_Recognized_As_Separate_Token() { - TestSingleToken("foo-bar", HtmlSymbolType.Text); + TestSingleToken("foo-bar", HtmlTokenType.Text); } [Fact] @@ -131,9 +131,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "@* Foo * Bar * Baz *", - new HtmlSymbol("@", HtmlSymbolType.RazorCommentTransition), - new HtmlSymbol("*", HtmlSymbolType.RazorCommentStar), - new HtmlSymbol(" Foo * Bar * Baz *", HtmlSymbolType.RazorComment)); + new HtmlToken("@", HtmlTokenType.RazorCommentTransition), + new HtmlToken("*", HtmlTokenType.RazorCommentStar), + new HtmlToken(" Foo * Bar * Baz *", HtmlTokenType.RazorComment)); } [Fact] @@ -141,11 +141,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "@* Foo * Bar * Baz *@", - new HtmlSymbol("@", HtmlSymbolType.RazorCommentTransition), - new HtmlSymbol("*", HtmlSymbolType.RazorCommentStar), - new HtmlSymbol(" Foo * Bar * Baz ", HtmlSymbolType.RazorComment), - new HtmlSymbol("*", HtmlSymbolType.RazorCommentStar), - new HtmlSymbol("@", HtmlSymbolType.RazorCommentTransition)); + new HtmlToken("@", HtmlTokenType.RazorCommentTransition), + new HtmlToken("*", HtmlTokenType.RazorCommentStar), + new HtmlToken(" Foo * Bar * Baz ", HtmlTokenType.RazorComment), + new HtmlToken("*", HtmlTokenType.RazorCommentStar), + new HtmlToken("@", HtmlTokenType.RazorCommentTransition)); } [Fact] @@ -153,11 +153,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { TestTokenizer( "@* Foo Bar Baz *@", - new HtmlSymbol("@", HtmlSymbolType.RazorCommentTransition), - new HtmlSymbol("*", HtmlSymbolType.RazorCommentStar), - new HtmlSymbol(" Foo Bar Baz ", HtmlSymbolType.RazorComment), - new HtmlSymbol("*", HtmlSymbolType.RazorCommentStar), - new HtmlSymbol("@", HtmlSymbolType.RazorCommentTransition)); + new HtmlToken("@", HtmlTokenType.RazorCommentTransition), + new HtmlToken("*", HtmlTokenType.RazorCommentStar), + new HtmlToken(" Foo Bar Baz ", HtmlTokenType.RazorComment), + new HtmlToken("*", HtmlTokenType.RazorCommentStar), + new HtmlToken("@", HtmlTokenType.RazorCommentTransition)); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTokenizerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTokenizerTestBase.cs index 5e9a2d489e..6416496b32 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTokenizerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTokenizerTestBase.cs @@ -5,7 +5,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public abstract class HtmlTokenizerTestBase : TokenizerTestBase { - private static HtmlSymbol _ignoreRemaining = new HtmlSymbol(string.Empty, HtmlSymbolType.Unknown); + private static HtmlToken _ignoreRemaining = new HtmlToken(string.Empty, HtmlTokenType.Unknown); internal override object IgnoreRemaining { @@ -17,14 +17,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return new HtmlTokenizer(source); } - internal void TestSingleToken(string text, HtmlSymbolType expectedSymbolType) + internal void TestSingleToken(string text, HtmlTokenType expectedTokenType) { - TestTokenizer(text, new HtmlSymbol(text, expectedSymbolType)); + TestTokenizer(text, new HtmlToken(text, expectedTokenType)); } - internal void TestTokenizer(string input, params HtmlSymbol[] expectedSymbols) + internal void TestTokenizer(string input, params HtmlToken[] expectedTokens) { - base.TestTokenizer(input, expectedSymbols); + base.TestTokenizer(input, expectedTokens); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ImplicitExpressionEditHandlerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ImplicitExpressionEditHandlerTest.cs new file mode 100644 index 0000000000..f96e7920af --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/ImplicitExpressionEditHandlerTest.cs @@ -0,0 +1,463 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class ImplicitExpressionEditHandlerTest + { + [Fact] + public void IsAcceptableDeletionInBalancedParenthesis_DeletionStartNotInBalancedParenthesis_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "(Hell)(o)"); + var change = new SourceChange(new SourceSpan(6, 1), string.Empty); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableDeletionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletionInBalancedParenthesis_DeletionEndNotInBalancedParenthesis_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "(Hell)(o)"); + var change = new SourceChange(new SourceSpan(5, 1), string.Empty); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableDeletionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletionInBalancedParenthesis_DeletionOverlapsBalancedParenthesis_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "(Hell)(o)"); + var change = new SourceChange(new SourceSpan(5, 2), string.Empty); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableDeletionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletionInBalancedParenthesis_DeletionDoesNotImpactBalancedParenthesis_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "(H(ell)o)"); + var change = new SourceChange(new SourceSpan(3, 3), string.Empty); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableDeletionInBalancedParenthesis(span, change); + + // Assert + Assert.True(result); + } + + [Theory] + [InlineData("(")] + [InlineData(")")] + public void IsAcceptableInsertionInBalancedParenthesis_ReturnsFalseIfChangeIsParenthesis(string changeText) + { + // Arrange + var change = new SourceChange(0, 1, changeText); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableInsertionInBalancedParenthesis(null, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryUpdateCountFromContent_SingleLeftParenthesis_CountsCorrectly() + { + // Arrange + var content = "("; + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.True(result); + Assert.Equal(1, count); + } + + [Fact] + public void TryUpdateCountFromContent_SingleRightParenthesis_CountsCorrectly() + { + // Arrange + var content = ")"; + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.True(result); + Assert.Equal(1, count); + } + + [Fact] + public void TryUpdateCountFromContent_CorrectCount_ReturnsTrue() + { + // Arrange + var content = "\"(()("; + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.True(result); + Assert.Equal(2, count); + } + + [Fact] + public void TryUpdateCountFromContent_ExistingCountAndNonParenthesisContent_ReturnsTrue() + { + // Arrange + var content = "'(abc)de)fg"; + var count = 1; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.True(result); + Assert.Equal(0, count); + } + + [Fact] + public void TryUpdateCountFromContent_InvalidParenthesis_ReturnsFalse() + { + // Arrange + var content = "'())))))"; + var count = 4; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.False(result); + Assert.Equal(4, count); + } + + [Fact] + public void TryUpdateBalanceCount_SingleLeftParenthesis_CountsCorrectly() + { + // Arrange + var token = new CSharpToken("(", CSharpTokenType.LeftParenthesis); + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(1, count); + } + + [Fact] + public void TryUpdateBalanceCount_SingleRightParenthesis_CountsCorrectly() + { + // Arrange + var token = new CSharpToken(")", CSharpTokenType.RightParenthesis); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(1, count); + } + + [Fact] + public void TryUpdateBalanceCount_IncompleteStringLiteral_CountsCorrectly() + { + // Arrange + var token = new CSharpToken("\"((", CSharpTokenType.StringLiteral); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(4, count); + } + + [Fact] + public void TryUpdateBalanceCount_IncompleteCharacterLiteral_CountsCorrectly() + { + // Arrange + var token = new CSharpToken("'((", CSharpTokenType.CharacterLiteral); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(4, count); + } + + [Fact] + public void TryUpdateBalanceCount_CompleteStringLiteral_CountsCorrectly() + { + // Arrange + var token = new CSharpToken("\"((\"", CSharpTokenType.StringLiteral); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(2, count); + } + + [Fact] + public void TryUpdateBalanceCount_CompleteCharacterLiteral_CountsCorrectly() + { + // Arrange + var token = new CSharpToken("'('", CSharpTokenType.CharacterLiteral); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(2, count); + } + + [Fact] + public void TryUpdateBalanceCount_InvalidParenthesis_ReturnsFalse() + { + // Arrange + var token = new CSharpToken(")", CSharpTokenType.RightParenthesis); + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.False(result); + Assert.Equal(0, count); + } + + [Fact] + public void TryUpdateBalanceCount_InvalidParenthesisStringLiteral_ReturnsFalse() + { + // Arrange + var token = new CSharpToken("\")", CSharpTokenType.StringLiteral); + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.False(result); + Assert.Equal(0, count); + } + + [Fact] + public void TryUpdateBalanceCount_InvalidParenthesisCharacterLiteral_ReturnsFalse() + { + // Arrange + var token = new CSharpToken("')", CSharpTokenType.CharacterLiteral); + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.False(result); + Assert.Equal(0, count); + } + + [Fact] + public void ContainsPosition_AtStartOfToken_ReturnsTrue() + { + // Arrange + var token = GetTokens(new SourceLocation(4, 1, 2), "hello").Single(); + + // Act + var result = ImplicitExpressionEditHandler.ContainsPosition(4, token); + + // Assert + Assert.True(result); + } + + [Fact] + public void ContainsPosition_InsideOfToken_ReturnsTrue() + { + // Arrange + var token = GetTokens(new SourceLocation(4, 1, 2), "hello").Single(); + + // Act + var result = ImplicitExpressionEditHandler.ContainsPosition(6, token); + + // Assert + Assert.True(result); + } + + [Fact] + public void ContainsPosition_AtEndOfToken_ReturnsFalse() + { + // Arrange + var token = GetTokens(new SourceLocation(4, 1, 2), "hello").Single(); + + // Act + var result = ImplicitExpressionEditHandler.ContainsPosition(9, token); + + // Assert + Assert.False(result); + } + + [Theory] + [InlineData(10)] + [InlineData(2)] + public void ContainsPosition_OutsideOfToken_ReturnsFalse(int position) + { + // Arrange + var token = GetTokens(new SourceLocation(4, 1, 2), "hello").Single(); + + // Act + var result = ImplicitExpressionEditHandler.ContainsPosition(position, token); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsInsideParenthesis_SurroundedByCompleteParenthesis_ReturnsFalse() + { + // Arrange + var tokens = GetTokens(SourceLocation.Zero, "(hello)point(world)"); + + // Act + var result = ImplicitExpressionEditHandler.IsInsideParenthesis(9, tokens); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsInsideParenthesis_InvalidParenthesis_ReturnsFalse() + { + // Arrange + var tokens = GetTokens(SourceLocation.Zero, "(hello))point)"); + + // Act + var result = ImplicitExpressionEditHandler.IsInsideParenthesis(10, tokens); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsInsideParenthesis_NoParenthesis_ReturnsFalse() + { + // Arrange + var tokens = GetTokens(SourceLocation.Zero, "Hello World"); + + // Act + var result = ImplicitExpressionEditHandler.IsInsideParenthesis(3, tokens); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsInsideParenthesis_InBalancedParenthesis_ReturnsTrue() + { + // Arrange + var tokens = GetTokens(SourceLocation.Zero, "Foo(GetValue(), DoSomething(point))"); + + // Act + var result = ImplicitExpressionEditHandler.IsInsideParenthesis(30, tokens); + + // Assert + Assert.True(result); + } + + [Theory] + [InlineData("(")] + [InlineData(")")] + public void IsAcceptableInsertionInBalancedParenthesis_InsertingParenthesis_ReturnsFalse(string text) + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "(Hello World)"); + var change = new SourceChange(new SourceSpan(3, 0), text); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableInsertionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableInsertionInBalancedParenthesis_UnbalancedParenthesis_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "(Hello"); + var change = new SourceChange(new SourceSpan(6, 0), " World"); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableInsertionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableInsertionInBalancedParenthesis_BalancedParenthesis_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "(Hello)"); + var change = new SourceChange(new SourceSpan(6, 0), " World"); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableInsertionInBalancedParenthesis(span, change); + + // Assert + Assert.True(result); + } + + private static Span GetSpan(SourceLocation start, string content) + { + var spanBuilder = new SpanBuilder(start); + var tokens = CSharpLanguageCharacteristics.Instance.TokenizeString(content).ToArray(); + foreach (var token in tokens) + { + spanBuilder.Accept(token); + } + var span = spanBuilder.Build(); + + return span; + } + + private static IReadOnlyList GetTokens(SourceLocation start, string content) + { + var parent = GetSpan(start, content); + var tokens = parent.Tokens.Cast().ToArray(); + return tokens; + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MarkupParserTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MarkupParserTestBase.cs index 16b1f43c1f..d81ebee9e3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MarkupParserTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MarkupParserTestBase.cs @@ -15,11 +15,5 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { return ParseHtmlBlock(version, document, directives, designTime); } - - internal virtual void SingleSpanDocumentTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType) - { - var b = CreateSimpleBlockAndSpan(document, blockKind, spanType); - ParseDocumentTest(document, b); - } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MiscUtils.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MiscUtils.cs deleted file mode 100644 index e014d24830..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/MiscUtils.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -#if DEBUG -using System.Diagnostics; -using System.Threading; -#endif -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - class MiscUtils - { - public const int TimeoutInSeconds = 1; - - public static void DoWithTimeoutIfNotDebugging(Func withTimeout) - { -#if DEBUG - if (Debugger.IsAttached) - { - withTimeout(Timeout.Infinite); - } - else - { -#endif - Assert.True(withTimeout((int)TimeSpan.FromSeconds(TimeoutInSeconds).TotalMilliseconds), "Timeout expired!"); -#if DEBUG - } -#endif - } - } -} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorParserTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorParserTest.cs index 589a147e4c..15dacfdaf8 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorParserTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorParserTest.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.IO; using System.Linq; using Xunit; @@ -26,7 +25,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var factory = new SpanFactory(); var parser = new RazorParser(); - // Act/Assert + // Act + var syntaxTree = parser.Parse(TestRazorSourceDocument.Create("foo @bar baz")); + + // Assert ParserTestBase.EvaluateResults(parser.Parse(TestRazorSourceDocument.Create("foo @bar baz")), new MarkupBlock( factory.Markup("foo "), diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs index 5c52dd7967..96c856848c 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs @@ -12,10 +12,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Arrange var builder = new SpanBuilder(SourceLocation.Zero); - builder.Accept(new HtmlSymbol("hello", HtmlSymbolType.Text)); + builder.Accept(new HtmlToken("hello", HtmlTokenType.Text)); var span = builder.Build(); var newBuilder = new SpanBuilder(SourceLocation.Zero); - newBuilder.Accept(new HtmlSymbol("hi", HtmlSymbolType.Text)); + newBuilder.Accept(new HtmlToken("hi", HtmlTokenType.Text)); var originalLength = span.Length; // Act @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Arrange var spanBuilder = new SpanBuilder(SourceLocation.Zero); - spanBuilder.Accept(new HtmlSymbol("hello", HtmlSymbolType.Text)); + spanBuilder.Accept(new HtmlToken("hello", HtmlTokenType.Text)); var span = spanBuilder.Build(); var blockBuilder = new BlockBuilder() { @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy span.Parent = block; var originalBlockLength = block.Length; var newSpanBuilder = new SpanBuilder(SourceLocation.Zero); - newSpanBuilder.Accept(new HtmlSymbol("hi", HtmlSymbolType.Text)); + newSpanBuilder.Accept(new HtmlToken("hi", HtmlTokenType.Text)); // Act span.ReplaceWith(newSpanBuilder); @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Kind = SpanKindInternal.Transition, ChunkGenerator = new ExpressionChunkGenerator(), }; - spanBuilder.Accept(new CSharpSymbol("@", CSharpSymbolType.Transition)); + spanBuilder.Accept(new CSharpToken("@", CSharpTokenType.Transition)); var span = spanBuilder.Build(); // Act diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs index 06131ae599..09431eddde 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs @@ -3,320 +3,136 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.Linq; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class TagHelperBlockRewriterTest : TagHelperRewritingTestBase { - public static TheoryData SymbolBoundAttributeData + public static TagHelperDescriptor[] SymbolBoundAttributes_Descriptors = new[] { - get - { - var factory = new SpanFactory(); + TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(attribute => attribute.Name("bound"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("[item]") + .PropertyName("ListItems") + .TypeName(typeof(List).Namespace + "List")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("[(item)]") + .PropertyName("ArrayItems") + .TypeName(typeof(string[]).Namespace + "System.String[]")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("(click)") + .PropertyName("Event1") + .TypeName(typeof(Action).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("(^click)") + .PropertyName("Event2") + .TypeName(typeof(Action).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("*something") + .PropertyName("StringProperty1") + .TypeName(typeof(string).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("#local") + .PropertyName("StringProperty2") + .TypeName(typeof(string).FullName)) + .Build() + }; - return new TheoryData - { - { - "
      ", - new MarkupBlock( - new MarkupTagHelperBlock("ul", - attributes: new List - { - new TagHelperAttributeNode("bound", null, AttributeStructure.Minimized), - new TagHelperAttributeNode( - "[item]", - factory.CodeMarkup("items").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes) - })) - }, - { - "
        ", - new MarkupBlock( - new MarkupTagHelperBlock("ul", - attributes: new List - { - new TagHelperAttributeNode("bound", null, AttributeStructure.Minimized), - new TagHelperAttributeNode( - "[(item)]", - factory.CodeMarkup("items").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("button", - attributes: new List - { - new TagHelperAttributeNode("bound", null, AttributeStructure.Minimized), - new TagHelperAttributeNode( - "(click)", - factory.CodeMarkup("doSomething()").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes) - }, - children: factory.Markup("Click Me"))) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("button", - attributes: new List - { - new TagHelperAttributeNode("bound", null, AttributeStructure.Minimized), - new TagHelperAttributeNode( - "(^click)", - factory.CodeMarkup("doSomething()").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes) - }, - children: factory.Markup("Click Me"))) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("template", - attributes: new List - { - new TagHelperAttributeNode("bound", null, AttributeStructure.Minimized), - new TagHelperAttributeNode( - "*something", - factory.Markup("value"), - AttributeStructure.SingleQuotes) - })) - }, - { - "
        ", - new MarkupBlock( - new MarkupTagHelperBlock("div", - attributes: new List - { - new TagHelperAttributeNode("bound", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("#localminimized", null, AttributeStructure.Minimized) - })) - }, - { - "
        ", - new MarkupBlock( - new MarkupTagHelperBlock("div", - attributes: new List - { - new TagHelperAttributeNode("bound", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("#local", factory.Markup("value"), AttributeStructure.SingleQuotes) - })) - }, - }; - } + [Fact] + public void CanHandleSymbolBoundAttributes1() + { + EvaluateData(SymbolBoundAttributes_Descriptors, "
          "); } - [Theory] - [MemberData(nameof(SymbolBoundAttributeData))] - public void Rewrite_CanHandleSymbolBoundAttributes(string documentContent, object expectedOutput) + [Fact] + public void CanHandleSymbolBoundAttributes2() { - // Arrange - var descriptors = new[] - { - TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("*") - .RequireAttributeDescriptor(attribute => attribute.Name("bound"))) - .BoundAttributeDescriptor(attribute => - attribute - .Name("[item]") - .PropertyName("ListItems") - .TypeName(typeof(List).Namespace + "List")) - .BoundAttributeDescriptor(attribute => - attribute - .Name("[(item)]") - .PropertyName("ArrayItems") - .TypeName(typeof(string[]).Namespace + "System.String[]")) - .BoundAttributeDescriptor(attribute => - attribute - .Name("(click)") - .PropertyName("Event1") - .TypeName(typeof(Action).FullName)) - .BoundAttributeDescriptor(attribute => - attribute - .Name("(^click)") - .PropertyName("Event2") - .TypeName(typeof(Action).FullName)) - .BoundAttributeDescriptor(attribute => - attribute - .Name("*something") - .PropertyName("StringProperty1") - .TypeName(typeof(string).FullName)) - .BoundAttributeDescriptor(attribute => - attribute - .Name("#local") - .PropertyName("StringProperty2") - .TypeName(typeof(string).FullName)) - .Build() - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); + EvaluateData(SymbolBoundAttributes_Descriptors, "
            "); } - public static TheoryData WithoutEndTagElementData + [Fact] + public void CanHandleSymbolBoundAttributes3() { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - // documentContent, expectedOutput - return new TheoryData - { - { - "", - new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.StartTagOnly)) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.StartTagOnly, - attributes: new List - { - new TagHelperAttributeNode("type", factory.Markup("text"), AttributeStructure.SingleQuotes) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("input", TagMode.StartTagOnly), - new MarkupTagHelperBlock("input", TagMode.StartTagOnly)) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.StartTagOnly, - attributes: new List - { - new TagHelperAttributeNode("type", factory.Markup("text"), AttributeStructure.SingleQuotes) - }), - new MarkupTagHelperBlock("input", TagMode.StartTagOnly)) - }, - { - "
            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("
            "), - new MarkupTagHelperBlock("input", TagMode.StartTagOnly), - new MarkupTagHelperBlock("input", TagMode.StartTagOnly), - blockFactory.MarkupTagBlock("
            ")) - }, - }; - } + EvaluateData(SymbolBoundAttributes_Descriptors, ""); } - [Theory] - [MemberData(nameof(WithoutEndTagElementData))] - public void Rewrite_CanHandleWithoutEndTagTagStructure(string documentContent, object expectedOutput) + [Fact] + public void CanHandleSymbolBoundAttributes4() { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("input") - .RequireTagStructure(TagStructure.WithoutEndTag)) - .Build() - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); + EvaluateData(SymbolBoundAttributes_Descriptors, ""); } - public static TheoryData TagStructureCompatibilityData + [Fact] + public void CanHandleSymbolBoundAttributes5() { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - // documentContent, structure1, structure2, expectedOutput - return new TheoryData - { - { - "", - TagStructure.Unspecified, - TagStructure.Unspecified, - new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.StartTagAndEndTag)) - }, - { - "", - TagStructure.Unspecified, - TagStructure.Unspecified, - new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.SelfClosing)) - }, - { - "", - TagStructure.Unspecified, - TagStructure.WithoutEndTag, - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.StartTagOnly, - attributes: new List - { - new TagHelperAttributeNode("type", factory.Markup("text"), AttributeStructure.SingleQuotes) - })) - }, - { - "", - TagStructure.WithoutEndTag, - TagStructure.WithoutEndTag, - new MarkupBlock( - new MarkupTagHelperBlock("input", TagMode.StartTagOnly), - new MarkupTagHelperBlock("input", TagMode.StartTagOnly)) - }, - { - "", - TagStructure.Unspecified, - TagStructure.NormalOrSelfClosing, - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.StartTagAndEndTag, - attributes: new List - { - new TagHelperAttributeNode("type", factory.Markup("text"), AttributeStructure.SingleQuotes) - })) - }, - { - "", - TagStructure.Unspecified, - TagStructure.WithoutEndTag, - new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.SelfClosing)) - }, - - { - "", - TagStructure.NormalOrSelfClosing, - TagStructure.Unspecified, - new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.SelfClosing)) - }, - }; - } + EvaluateData(SymbolBoundAttributes_Descriptors, ""); } - [Theory] - [MemberData(nameof(TagStructureCompatibilityData))] - public void Rewrite_AllowsCompatibleTagStructures( - string documentContent, - TagStructure structure1, - TagStructure structure2, - object expectedOutput) + [Fact] + public void CanHandleSymbolBoundAttributes6() + { + EvaluateData(SymbolBoundAttributes_Descriptors, "
            "); + } + + [Fact] + public void CanHandleSymbolBoundAttributes7() + { + EvaluateData(SymbolBoundAttributes_Descriptors, "
            "); + } + + public static TagHelperDescriptor[] WithoutEndTag_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build() + }; + + [Fact] + public void CanHandleWithoutEndTagTagStructure1() + { + EvaluateData(WithoutEndTag_Descriptors, ""); + } + + [Fact] + public void CanHandleWithoutEndTagTagStructure2() + { + EvaluateData(WithoutEndTag_Descriptors, ""); + } + + [Fact] + public void CanHandleWithoutEndTagTagStructure3() + { + EvaluateData(WithoutEndTag_Descriptors, ""); + } + + [Fact] + public void CanHandleWithoutEndTagTagStructure4() + { + EvaluateData(WithoutEndTag_Descriptors, ""); + } + + [Fact] + public void CanHandleWithoutEndTagTagStructure5() + { + EvaluateData(WithoutEndTag_Descriptors, "
            "); + } + + public static TagHelperDescriptor[] GetTagStructureCompatibilityDescriptors(TagStructure structure1, TagStructure structure2) { - // Arrange - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") @@ -333,3576 +149,1933 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Build() }; - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); - } - - public static TheoryData MalformedTagHelperAttributeBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - Func createInvalidDoBlock = extraCode => - { - return new MarkupBlock( - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - string.Empty, - new SourceLocation(10, 0, 10)), - new SourceLocation(10, 0, 10)), - new StatementBlock( - factory.CodeTransition(), - factory.Code("do {" + extraCode).AsStatement()))); - }; - - return new TheoryData - { - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode( - "bar", - new MarkupBlock(factory.Markup("false"), factory.Markup(" ")), - AttributeStructure.SingleQuotes) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            - { - new TagHelperAttributeNode( - "bar", - new MarkupBlock( - factory.Markup("false"), - factory.Markup(" - { - new TagHelperAttributeNode( - "bar", - factory.Markup("false"), - AttributeStructure.NoQuotes) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperAttributeListMustBeWellFormed( - new SourceSpan(12, 0, 12, 1)) - } - }, - { - "

            - { - new TagHelperAttributeNode( - "bar", - factory.Markup("false'")) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode( - "bar", - new MarkupBlock( - factory.Markup("false'"), - factory.Markup(" >

            "))) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("foo", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bar", null, AttributeStructure.Minimized) - }, - new MarkupTagHelperBlock("strong"))), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(11, 0, 11), contentLength: 6), "strong"), - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.NoQuotes) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.NoQuotes) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode( - "class", - new MarkupBlock(factory.Markup("btn"), factory.Markup(" bar="))), - new TagHelperAttributeNode("foo", null, AttributeStructure.Minimized) - }, - new MarkupTagHelperBlock("strong"))), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(24, 0, 24), contentLength: 6), "strong") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode( - "class", - new MarkupBlock(factory.Markup("btn"), factory.Markup(" bar="))), - new TagHelperAttributeNode("foo", null, AttributeStructure.Minimized), - })), - new RazorDiagnostic[0] - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p")), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(new SourceSpan(3, 0, 3, 13), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p")), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(new SourceSpan(3, 0, 3, 13), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode( - "class", - new MarkupBlock( - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - string.Empty, - new SourceLocation(9, 0, 9)), - new SourceLocation(9, 0, 9)), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)))), - AttributeStructure.DoubleQuotes) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            - { - new TagHelperAttributeNode( - "class", - createInvalidDoBlock(string.Empty)) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(11, 0, 11), contentLength: 1), "do", "}", "{"), - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", createInvalidDoBlock("\">

            ")) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(11, 0, 11), contentLength: 1), "do", "}", "{"), - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(filePath: null, absoluteIndex: 15, lineIndex: 0, characterIndex: 15, length: 1)) - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p")), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(new SourceSpan(3, 0, 3, 30), "p"), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "do", "}", "{"), - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(filePath: null, absoluteIndex: 31, lineIndex: 0, characterIndex: 31, length: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("some"), AttributeStructure.NoQuotes) - })), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperAttributeListMustBeWellFormed(new SourceSpan(13, 0, 13, 13)) - } - }, - }; - } - } - - [Theory] - [MemberData(nameof(MalformedTagHelperAttributeBlockData))] - public void Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes( - string documentContent, - object expectedOutput, - object expectedErrors) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); - } - - public static TheoryData MalformedTagHelperBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - return new TheoryData - { - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("strong", - new MarkupTagHelperBlock("p"))), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 6), "strong"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 6), "strong"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 1), "p") - } - }, - { - " <

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("<"), - blockFactory.MarkupTagBlock("<"), - blockFactory.MarkupTagBlock(""), - factory.Markup(" "), - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("p")), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 6), "strong"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "p") - } - }, - { - "<<> <<>>", - new MarkupBlock( - blockFactory.MarkupTagBlock("<"), - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("strong", - factory.Markup("> "), - blockFactory.MarkupTagBlock("<"), - blockFactory.MarkupTagBlock("<>"), - factory.Markup(">"))), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 6), "strong") - } - }, - { - "

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock(""))), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "p") - } - } - }; - } - } - - [Theory] - [MemberData(nameof(MalformedTagHelperBlockData))] - public void Rewrite_CreatesErrorForMalformedTagHelper( - string documentContent, - object expectedOutput, - object expectedErrors) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); - } - - public static TheoryData CodeTagHelperAttributesData - { - get - { - var factory = new SpanFactory(); - var dateTimeNow = new MarkupBlock( - factory.Markup(" "), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))); - - return new TheoryData - { - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("age", factory.CodeMarkup("12").With(new ExpressionChunkGenerator())) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "birthday", - factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "age", - new MarkupBlock( - new MarkupBlock( - new ExpressionBlock( - factory.CodeTransition(), - factory - .CSharpCodeMarkup("DateTime.Now.Year") - .With(new ExpressionChunkGenerator()))))) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "age", - new MarkupBlock( - new MarkupBlock( - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()), - new ExpressionBlock( - factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()), - factory - .CSharpCodeMarkup("DateTime.Now.Year") - .With(new ExpressionChunkGenerator()))))) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("name", factory.Markup("John")) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "name", - new MarkupBlock(factory.Markup("Time:"), dateTimeNow)) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "age", - new MarkupBlock( - factory.CodeMarkup("1").With(new ExpressionChunkGenerator()), - factory.CodeMarkup(" +").With(new ExpressionChunkGenerator()), - new MarkupBlock( - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()), - new ExpressionBlock( - factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()), - factory.CSharpCodeMarkup("value") - .With(new ExpressionChunkGenerator()))), - factory.CodeMarkup(" +").With(new ExpressionChunkGenerator()), - factory.CodeMarkup(" 2").With(new ExpressionChunkGenerator()))), - new TagHelperAttributeNode( - "birthday", - new MarkupBlock( - factory.CodeMarkup("(bool)").With(new ExpressionChunkGenerator()), - new MarkupBlock( - new ExpressionBlock( - factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()), - factory - .CSharpCodeMarkup("Bag[\"val\"]") - .With(new ExpressionChunkGenerator()))), - factory.CodeMarkup(" ?").With(new ExpressionChunkGenerator()), - new MarkupBlock( - factory.CodeMarkup(" @").With(new ExpressionChunkGenerator()) - .As(SpanKindInternal.Code), - factory.CodeMarkup("@").With(SpanChunkGenerator.Null) - .As(SpanKindInternal.Code)), - factory.CodeMarkup("DateTime").With(new ExpressionChunkGenerator()), - factory.CodeMarkup(" :").With(new ExpressionChunkGenerator()), - new MarkupBlock( - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()), - new ExpressionBlock( - factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()), - factory - .CSharpCodeMarkup("DateTime.Now") - .With(new ExpressionChunkGenerator())))), - AttributeStructure.SingleQuotes) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("age", factory.CodeMarkup("12").With(new ExpressionChunkGenerator())), - new TagHelperAttributeNode( - "birthday", - factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())), - new TagHelperAttributeNode( - "name", - new MarkupBlock(factory.Markup("Time:"), dateTimeNow)) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("age", factory.CodeMarkup("12").With(new ExpressionChunkGenerator())), - new TagHelperAttributeNode( - "birthday", - factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())), - new TagHelperAttributeNode( - "name", - new MarkupBlock( - factory.Markup("Time:"), - new MarkupBlock( - factory.Markup(" @").Accepts(AcceptedCharactersInternal.None), - factory.Markup("@") - .With(SpanChunkGenerator.Null) - .Accepts(AcceptedCharactersInternal.None)), - dateTimeNow)) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("age", factory.CodeMarkup("12").With(new ExpressionChunkGenerator())), - new TagHelperAttributeNode( - "birthday", - factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())), - new TagHelperAttributeNode( - "name", - new MarkupBlock( - new MarkupBlock( - factory.Markup("@").Accepts(AcceptedCharactersInternal.None), - factory.Markup("@") - .With(SpanChunkGenerator.Null) - .Accepts(AcceptedCharactersInternal.None)), - factory.Markup("BoundStringAttribute"))) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("person", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "age", - new MarkupBlock( - new MarkupBlock( - factory.CodeMarkup("@").With(new ExpressionChunkGenerator()), - factory.CodeMarkup("@").With(SpanChunkGenerator.Null)), - new MarkupBlock( - factory.EmptyHtml() - .AsCodeMarkup().With(new ExpressionChunkGenerator()) - .As(SpanKindInternal.Code), - new ExpressionBlock( - factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()), - factory.CSharpCodeMarkup("(").With(new ExpressionChunkGenerator()), - factory.CSharpCodeMarkup("11+1") - .With(new ExpressionChunkGenerator()), - factory.CSharpCodeMarkup(")").With(new ExpressionChunkGenerator()))))), - new TagHelperAttributeNode( - "birthday", - factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())), - new TagHelperAttributeNode( - "name", - new MarkupBlock(factory.Markup("Time:"), dateTimeNow)) - })) - }, - }; - } - } - - [Theory] - [MemberData(nameof(CodeTagHelperAttributesData))] - public void Rewrite_CreatesMarkupCodeSpansForNonStringTagHelperAttributes( - string documentContent, - object expectedOutput) - { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("PersonTagHelper", "personAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("person")) - .BoundAttributeDescriptor(attribute => - attribute - .Name("age") - .PropertyName("Age") - .TypeName(typeof(int).FullName)) - .BoundAttributeDescriptor(attribute => - attribute - .Name("birthday") - .PropertyName("BirthDay") - .TypeName(typeof(DateTime).FullName)) - .BoundAttributeDescriptor(attribute => - attribute - .Name("name") - .PropertyName("Name") - .TypeName(typeof(string).FullName)) - .Build() - }; - - // Act & Assert - EvaluateData( - descriptors, - documentContent, - (MarkupBlock)expectedOutput, - expectedErrors: Enumerable.Empty()); - } - - public static IEnumerable IncompleteHelperBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - yield return new object[] - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes), - new TagHelperAttributeNode( - "dynamic", - new MarkupBlock( - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - string.Empty, - new SourceLocation(21, 0, 21)), - new SourceLocation(21, 0, 21)), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)))), - AttributeStructure.DoubleQuotes), - new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes) - }, - new MarkupTagHelperBlock("strong")), - blockFactory.MarkupTagBlock("
            ")), - new RazorDiagnostic[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 53, lineIndex: 0, characterIndex: 53, length: 6), "strong"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 66, lineIndex: 0, characterIndex: 66, length: 6), "strong") - } - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("
            "), - new MarkupTagHelperBlock("p", - factory.Markup("Hello "), - new MarkupTagHelperBlock("strong", - factory.Markup("World")), - blockFactory.MarkupTagBlock("
            "))), - new RazorDiagnostic[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 1), "p") - } - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("
            "), - new MarkupTagHelperBlock("p", - factory.Markup("Hello "), - new MarkupTagHelperBlock("strong", - factory.Markup("World"), - blockFactory.MarkupTagBlock("
            ")))), - new RazorDiagnostic[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 15, lineIndex: 0, characterIndex: 15, length: 6), "strong") - } - }; - yield return new object[] - { - "

            Hello

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")) - }, - factory.Markup("Hello "), - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - }, - factory.Markup("World")))), - new RazorDiagnostic[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }; - } - } - - [Theory] - [MemberData(nameof(IncompleteHelperBlockData))] - public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper( - string documentContent, - object expectedOutput, - object expectedErrors) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); - } - - - public static IEnumerable OddlySpacedBlockData - { - get - { - var factory = new SpanFactory(); - - yield return new object[] - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup(" foo")), - new TagHelperAttributeNode( - "style", - new MarkupBlock( - factory.Markup(" color"), - factory.Markup(" :"), - factory.Markup(" red"), - factory.Markup(" ;"), - factory.Markup(" "))) - })) - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup(" foo")), - new TagHelperAttributeNode( - "style", - new MarkupBlock( - factory.Markup(" color"), - factory.Markup(" :"), - factory.Markup(" red"), - factory.Markup(" ;"), - factory.Markup(" "))) - }, - factory.Markup("Hello World"))) - }; - yield return new object[] - { - "

            Hello

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode( - "class", - new MarkupBlock(factory.Markup(" foo"), factory.Markup(" "))) - }, - factory.Markup("Hello")), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode( - "style", - new MarkupBlock(factory.Markup(" color:red;"), factory.Markup(" "))) - }, - factory.Markup("World"))) - }; - } - } - - [Theory] - [MemberData(nameof(OddlySpacedBlockData))] - public void TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p"); - } - - public static IEnumerable ComplexAttributeTagHelperBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var dateTimeNowString = "@DateTime.Now"; - var dateTimeNow = new Func(index => - new MarkupBlock( - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - string.Empty, - new SourceLocation(index, 0, index)), - new SourceLocation(index, 0, index)), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))))); - var doWhileString = "@do { var foo = bar; Foo foo++; } while (foo);"; - var doWhile = new Func(index => - new MarkupBlock( - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - string.Empty, - new SourceLocation(index, 0, index)), - new SourceLocation(index, 0, index)), - new StatementBlock( - factory.CodeTransition(), - factory.Code("do { var foo = bar; ").AsStatement(), - new MarkupBlock( - new MarkupTagBlock( - factory.MarkupTransition("")), - factory.Markup("Foo").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - factory.MarkupTransition(""))), - factory - .Code(" foo++; } while (foo);") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None))))); - - var currentFormattedString = "

            "; - yield return new object[] - { - string.Format(currentFormattedString, dateTimeNowString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", dateTimeNow(10)), - new TagHelperAttributeNode("style", dateTimeNow(32), AttributeStructure.SingleQuotes) - })) - }; - yield return new object[] - { - string.Format(currentFormattedString, doWhileString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", doWhile(10)), - new TagHelperAttributeNode("style", doWhile(83), AttributeStructure.SingleQuotes) - })) - }; - - currentFormattedString = "

            Hello World

            "; - yield return new object[] - { - string.Format(currentFormattedString, dateTimeNowString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", dateTimeNow(10)), - new TagHelperAttributeNode("style", dateTimeNow(32), AttributeStructure.SingleQuotes) - }, - factory.Markup("Hello World"))) - }; - yield return new object[] - { - string.Format(currentFormattedString, doWhileString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", doWhile(10)), - new TagHelperAttributeNode("style", doWhile(83), AttributeStructure.SingleQuotes) - }, - factory.Markup("Hello World"))) - }; - - currentFormattedString = "

            Hello

            World

            "; - yield return new object[] - { - string.Format(currentFormattedString, dateTimeNowString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", dateTimeNow(10)) - }, - factory.Markup("Hello")), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("style", dateTimeNow(45), AttributeStructure.SingleQuotes) - }, - factory.Markup("World"))) - }; - yield return new object[] - { - string.Format(currentFormattedString, doWhileString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", doWhile(10)) - }, - factory.Markup("Hello")), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("style", doWhile(96), AttributeStructure.SingleQuotes) - }, - factory.Markup("World"))) - }; - - currentFormattedString = - "

            Hello World inside of strong tag

            "; - yield return new object[] - { - string.Format(currentFormattedString, dateTimeNowString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", dateTimeNow(10)), - new TagHelperAttributeNode("style", dateTimeNow(32), AttributeStructure.SingleQuotes) - }, - factory.Markup("Hello World "), - new MarkupTagBlock( - factory.Markup("(" class=\"", 66, 0, 66), - suffix: new LocationTagged("\"", 87, 0, 87)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged(string.Empty, 74, 0, 74), 74, 0, 74), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - factory.Markup("inside of strong tag"), - blockFactory.MarkupTagBlock("
            "))) - }; - } - } - - [Theory] - [MemberData(nameof(ComplexAttributeTagHelperBlockData))] - public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p"); - } - - public static IEnumerable ComplexTagHelperBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var dateTimeNowString = "@DateTime.Now"; - var dateTimeNow = new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)); - var doWhileString = "@do { var foo = bar;

            Foo

            foo++; } while (foo);"; - var doWhile = new StatementBlock( - factory.CodeTransition(), - factory.Code("do { var foo = bar;").AsStatement(), - new MarkupBlock( - factory.Markup(" "), - new MarkupTagHelperBlock("p", - factory.Markup("Foo")), - factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - factory.Code("foo++; } while (foo);") - .AsStatement() - .Accepts(AcceptedCharactersInternal.None)); - - var currentFormattedString = "

            {0}

            "; - yield return new object[] - { - string.Format(currentFormattedString, dateTimeNowString), - new MarkupBlock( - new MarkupTagHelperBlock("p", dateTimeNow)) - }; - yield return new object[] - { - string.Format(currentFormattedString, doWhileString), - new MarkupBlock( - new MarkupTagHelperBlock("p", doWhile)) - }; - - currentFormattedString = "

            Hello World {0}

            "; - yield return new object[] - { - string.Format(currentFormattedString, dateTimeNowString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello World "), - dateTimeNow)) - }; - yield return new object[] - { - string.Format(currentFormattedString, doWhileString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello World "), - doWhile)) - }; - - currentFormattedString = "

            {0}

            {0}

            "; - yield return new object[] - { - string.Format(currentFormattedString, dateTimeNowString), - new MarkupBlock( - new MarkupTagHelperBlock("p", dateTimeNow), - factory.Markup(" "), - new MarkupTagHelperBlock("p", dateTimeNow)) - }; - yield return new object[] - { - string.Format(currentFormattedString, doWhileString), - new MarkupBlock( - new MarkupTagHelperBlock("p", doWhile), - factory.Markup(" "), - new MarkupTagHelperBlock("p", doWhile)) - }; - - currentFormattedString = "

            Hello {0}inside of {0} strong tag

            "; - yield return new object[] - { - string.Format(currentFormattedString, dateTimeNowString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello "), - dateTimeNow, - blockFactory.MarkupTagBlock(""), - factory.Markup("inside of "), - dateTimeNow, - factory.Markup(" strong tag"), - blockFactory.MarkupTagBlock(""))) - }; - yield return new object[] - { - string.Format(currentFormattedString, doWhileString), - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello "), - doWhile, - blockFactory.MarkupTagBlock(""), - factory.Markup("inside of "), - doWhile, - factory.Markup(" strong tag"), - blockFactory.MarkupTagBlock(""))) - }; - } - } - - [Theory] - [MemberData(nameof(ComplexTagHelperBlockData))] - public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p"); - } - - - public static TheoryData InvalidHtmlBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var dateTimeNow = new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)); - - return new TheoryData - { - { - "<<

            >>

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("<"), - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("p", - factory.Markup(">>"))) - }, - { - "<

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("p", TagMode.SelfClosing)) - }, - { - "< p />", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - new MarkupBlock( - factory.Markup(" p")), - factory.Markup(" />"))) - }, - { - "", - new MarkupBlock( - blockFactory.MarkupTagBlock("", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 1, 0, 1), - suffix: new LocationTagged("\"", 12, 0, 12)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("foo").With(new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 9, 0, 9), - value: new LocationTagged("foo", 9, 0, 9))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(" ")), - new MarkupTagHelperBlock("p", TagMode.SelfClosing)) - }, - { - "/>

            >", - new MarkupBlock( - blockFactory.MarkupTagBlock("")), - factory.Markup(">")) - }, - { - "/>

            >", - new MarkupBlock( - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("")), - factory.Markup(">")) - }, - { - "@DateTime.Now/>

            >", - new MarkupBlock( - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("")), - factory.Markup(">")) - }, - { - "

            @DateTime.Now / >

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock(""), - new MarkupTagHelperBlock("p", - dateTimeNow, - factory.Markup(" / >"), - blockFactory.MarkupTagBlock("")), - blockFactory.MarkupTagBlock("")) - }, - { - "

            < @DateTime.Now >

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagBlock( - factory.Markup("< "), - dateTimeNow, - factory.Markup(" >")), - blockFactory.MarkupTagBlock(""))) - } - }; - } - } - - [Theory] - [MemberData(nameof(InvalidHtmlBlockData))] - public void TagHelperParseTreeRewriter_AllowsInvalidHtml(string documentContent, object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p"); - } - - public static TheoryData EmptyAttributeTagHelperData - { - get - { - var factory = new SpanFactory(); - - // documentContent, expectedOutput - return new TheoryData - { - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", new MarkupBlock()) - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", new MarkupBlock(), AttributeStructure.SingleQuotes) - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - // We expected a markup node here because attribute values without quotes can only ever - // be a single item, hence don't need to be enclosed by a block. - new TagHelperAttributeNode( - "class", - factory.Markup("").With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes), - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class1", new MarkupBlock(), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode( - "class2", - factory.Markup(string.Empty).With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes), - new TagHelperAttributeNode("class3", new MarkupBlock()), - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class1", new MarkupBlock(), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("class2", new MarkupBlock()), - new TagHelperAttributeNode( - "class3", - factory.Markup(string.Empty).With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes), - })) - }, - }; - } - } - - [Theory] - [MemberData(nameof(EmptyAttributeTagHelperData))] - public void Rewrite_UnderstandsEmptyAttributeTagHelpers(string documentContent, object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorDiagnostic[0], "p"); - } - - public static TheoryData EmptyTagHelperBoundAttributeData - { - get - { - var factory = new SpanFactory(); - var boolTypeName = typeof(bool).FullName; - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("bound", new MarkupBlock(), AttributeStructure.SingleQuotes) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "bound", - "myth", - boolTypeName) - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup(" true").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes) - })), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "bound", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("bound", new MarkupBlock(), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound", new MarkupBlock()) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "bound", - "myth", - boolTypeName), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(16, 0, 16, 5), - "bound", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes), - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup(" ")) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "bound", - "myth", - boolTypeName), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(17, 0, 17, 5), - "bound", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup("true").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes), - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup(string.Empty).With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(19, 0, 19, 5), - "bound", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup(string.Empty).With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes), - new TagHelperAttributeNode("name", new MarkupBlock(), AttributeStructure.SingleQuotes) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "bound", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup(string.Empty).With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes), - new TagHelperAttributeNode("name", factory.Markup(" "), AttributeStructure.SingleQuotes) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "bound", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup("true").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("name", factory.Markup("john"), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode( - "bound", - factory.CodeMarkup(string.Empty).With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes), - new TagHelperAttributeNode( - "name", - factory.Markup(string.Empty).With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(31, 0, 31, 5), - "bound", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("BouND", new MarkupBlock(), AttributeStructure.SingleQuotes) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "BouND", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("BOUND", new MarkupBlock(), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bOUnd", new MarkupBlock()) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "BOUND", - "myth", - boolTypeName), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(18, 0, 18, 5), - "bOUnd", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - new List - { - new TagHelperAttributeNode( - "BOUND", - factory.CodeMarkup(string.Empty).With(SpanChunkGenerator.Null), - AttributeStructure.DoubleQuotes), - new TagHelperAttributeNode("nAMe", factory.Markup("john"), AttributeStructure.SingleQuotes) - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 5), - "BOUND", - "myth", - boolTypeName), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - { - new TagHelperAttributeNode( - "bound", - new MarkupBlock( - new MarkupBlock( - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()), - new ExpressionBlock( - factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()), - factory.CSharpCodeMarkup("true") - .With(new ExpressionChunkGenerator()))), - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator())), - AttributeStructure.SingleQuotes) - } - })), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "myth", - TagMode.SelfClosing, - attributes: new List - { - { - new TagHelperAttributeNode( - "bound", - new MarkupBlock( - new MarkupBlock( - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()), - new ExpressionBlock( - factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()), - factory.CSharpCodeMarkup("(").With(new ExpressionChunkGenerator()), - factory.CSharpCodeMarkup("true") - .With(new ExpressionChunkGenerator()), - factory.CSharpCodeMarkup(")").With(new ExpressionChunkGenerator()))), - factory.CodeMarkup(" ").With(new ExpressionChunkGenerator())), - AttributeStructure.SingleQuotes) - } - })), - new RazorDiagnostic[0] - }, - }; - } - } - - [Theory] - [MemberData(nameof(EmptyTagHelperBoundAttributeData))] - public void Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes( - string documentContent, - object expectedOutput, - object expectedErrors) - { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("mythTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("myth")) - .BoundAttributeDescriptor(attribute => - attribute - .Name("bound") - .PropertyName("Bound") - .TypeName(typeof(bool).FullName)) - .BoundAttributeDescriptor(attribute => - attribute - .Name("name") - .PropertyName("Name") - .TypeName(typeof(string).FullName)) - .Build() - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); - } - - public static IEnumerable ScriptBlockData - { - get - { - var factory = new SpanFactory(); - - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("script", - factory.Markup("", - new MarkupBlock( - new MarkupTagHelperBlock("script", - factory.Markup("Hello World

            "))) - }; - yield return new object[] - { - "

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("script", - factory.Markup("Hel

            lo

            ")), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("div", - factory.Markup("World")))) - }; - yield return new object[] - { - " ", - new MarkupBlock( - new MarkupTagHelperBlock("script", - factory.Markup("Hello")), - factory.Markup(" "), - new MarkupTagHelperBlock("script", - factory.Markup("World"))) - }; - yield return new object[] - { - " World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello "), - new MarkupTagHelperBlock("script", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")), - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - }), - factory.Markup(" World"))) - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello "), - new MarkupTagHelperBlock("script", - new List - { - new TagHelperAttributeNode( - "class", - new MarkupBlock( - new MarkupBlock( - factory.Markup("@").Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("foo@bar.com"))), - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - }), - factory.Markup(" World"))) - }; - } - } - - [Theory] - [MemberData(nameof(ScriptBlockData))] - public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p", "div", "script"); - } - - public static IEnumerable SelfClosingBlockData - { - get - { - var factory = new SpanFactory(); - - yield return new object[] - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")), - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - })) - }; - yield return new object[] - { - "

            Hello

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - children: new SyntaxTreeNode[] - { - factory.Markup("Hello "), - new MarkupTagHelperBlock( - "p", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")), - new TagHelperAttributeNode( - "style", - factory.Markup("color:red;")) - }), - factory.Markup(" World") - })) - }; - yield return new object[] - { - "Hello

            World", - new MarkupBlock( - factory.Markup("Hello"), - new MarkupTagHelperBlock("p", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")) - }), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - }), - factory.Markup("World")) - }; - } - } - - [Theory] - [MemberData(nameof(SelfClosingBlockData))] - public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p"); - } - - public static IEnumerable QuotelessAttributeBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var dateTimeNow = new Func(index => - new MarkupBlock( - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - string.Empty, - new SourceLocation(index, 0, index)), - new SourceLocation(index, 0, index)), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))))); - - yield return new object[] - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes), - new TagHelperAttributeNode("dynamic", dateTimeNow(21)), - new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes) - })) - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes), - new TagHelperAttributeNode("dynamic", dateTimeNow(21)), - new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes) - }, - factory.Markup("Hello World"))) - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes), - new TagHelperAttributeNode("dynamic", dateTimeNow(21)), - new TagHelperAttributeNode( - "style", - new MarkupBlock( - factory.Markup("color"), - new MarkupBlock( - factory.Markup("@").Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup(":red;")), - AttributeStructure.DoubleQuotes) - }, - factory.Markup("Hello World"))) - }; - yield return new object[] - { - "

            Hello

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes), - new TagHelperAttributeNode("dynamic", dateTimeNow(21)) - }, - factory.Markup("Hello")), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes), - new TagHelperAttributeNode("dynamic", dateTimeNow(73)) - }, - factory.Markup("World"))) - }; - yield return new object[] - { - "

            Hello World inside of strong tag

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes), - new TagHelperAttributeNode("dynamic", dateTimeNow(21)), - new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes) - }, - factory.Markup("Hello World "), - new MarkupTagBlock( - factory.Markup("(" class=\"", 71, 0, 71), - suffix: new LocationTagged("\"", 82, 0, 82)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(string.Empty, 79, 0, 79), - value: new LocationTagged("foo", 79, 0, 79))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - factory.Markup("inside of strong tag"), - blockFactory.MarkupTagBlock("
            "))) - }; - } - } - - [Theory] - [MemberData(nameof(QuotelessAttributeBlockData))] - public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p"); - } - - public static IEnumerable PlainAttributeBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - yield return new object[] - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")), - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - })) - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")), - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - }, - factory.Markup("Hello World"))) - }; - yield return new object[] - { - "

            Hello

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")) - }, - factory.Markup("Hello")), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - }, - factory.Markup("World"))) - }; - yield return new object[] - { - "

            Hello World inside of strong tag

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new List - { - new TagHelperAttributeNode("class", factory.Markup("foo")), - new TagHelperAttributeNode("style", factory.Markup("color:red;")) - }, - factory.Markup("Hello World "), - new MarkupTagBlock( - factory.Markup("(" class=\"", 53, 0, 53), - suffix: new LocationTagged("\"", 64, 0, 64)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(string.Empty, 61, 0, 61), - value: new LocationTagged("foo", 61, 0, 61))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - factory.Markup("inside of strong tag"), - blockFactory.MarkupTagBlock("
            "))) - }; - } - } - - [Theory] - [MemberData(nameof(PlainAttributeBlockData))] - public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p"); - } - - public static IEnumerable PlainBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - yield return new object[] - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p")) - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello World"))) - }; - yield return new object[] - { - "

            Hello

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello")), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - factory.Markup("World"))) - }; - yield return new object[] - { - "

            Hello World inside of strong tag

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello World "), - blockFactory.MarkupTagBlock(""), - factory.Markup("inside of strong tag"), - blockFactory.MarkupTagBlock(""))) - }; - } - } - - [Theory] - [MemberData(nameof(PlainBlockData))] - public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p"); - } - - public static TheoryData DataDashAttributeData_Document - { - get - { - var factory = new SpanFactory(); - var dateTimeNowString = "@DateTime.Now"; - var dateTimeNow = new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)); - - // documentContent, expectedOutput - return new TheoryData - { - { - $"", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode( - "data-required", - new MarkupBlock(dateTimeNow), - AttributeStructure.SingleQuotes), - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("data-required", factory.Markup("value"), AttributeStructure.SingleQuotes), - })) - }, - { - $"", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode( - "data-required", - new MarkupBlock(factory.Markup("prefix "), dateTimeNow), - AttributeStructure.SingleQuotes), - })) - }, - { - $"", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode( - "data-required", - new MarkupBlock(dateTimeNow, factory.Markup(" suffix")), - AttributeStructure.SingleQuotes), - })) - }, - { - $"", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode( - "data-required", - new MarkupBlock( - factory.Markup("prefix "), - dateTimeNow, - factory.Markup(" suffix")), - AttributeStructure.SingleQuotes), - })) - }, - { - $"", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("pre-attribute", value: null, attributeStructure: AttributeStructure.Minimized), - new TagHelperAttributeNode( - "data-required", - new MarkupBlock( - factory.Markup("prefix "), - dateTimeNow, - factory.Markup(" suffix")), - AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("post-attribute", value: null, attributeStructure: AttributeStructure.Minimized), - })) - }, - { - $"", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode( - "data-required", - new MarkupBlock( - dateTimeNow, - factory.Markup(" middle "), - dateTimeNow), - AttributeStructure.SingleQuotes), - })) - }, - }; - } - } - - public static TheoryData DataDashAttributeData_CSharpBlock - { - get - { - var factory = new SpanFactory(); - var documentData = DataDashAttributeData_Document; - Func, MarkupBlock> buildStatementBlock = (insideBuilder) => - { - return new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - insideBuilder(), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()); - }; - - foreach (var data in documentData) - { - data[0] = $"@{{{data[0]}}}"; - data[1] = buildStatementBlock(() => data[1] as MarkupBlock); - } - - return documentData; - } - } - - [Theory] - [MemberData(nameof(DataDashAttributeData_Document))] - [MemberData(nameof(DataDashAttributeData_CSharpBlock))] - public void Rewrite_GeneratesExpectedOutputForUnboundDataDashAttributes( - string documentContent, - object expectedOutput) - { - // Act & Assert - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, Enumerable.Empty(), "input"); - } - - public static TheoryData MinimizedAttributeData_Document - { - get - { - var factory = new SpanFactory(); - var noErrors = new RazorDiagnostic[0]; - var stringType = typeof(string).FullName; - var intType = typeof(int).FullName; - var expressionString = "@DateTime.Now + 1"; - var expression = new Func(index => - new MarkupBlock( - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - string.Empty, - new SourceLocation(index, 0, index)), - new SourceLocation(index, 0, index)), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - factory.Markup(" +") - .With(new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", index + 13, 0, index + 13), - value: new LocationTagged("+", index + 14, 0, index + 14))), - factory.Markup(" 1") - .With(new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", index + 15, 0, index + 15), - value: new LocationTagged("1", index + 16, 0, index + 16))))); - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - })), - noErrors - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 12), - "bound-string", - "p", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 21), - "bound-required-string", - "input", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 18), - "bound-required-int", - "input", - intType), - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 9), - "bound-int", - "p", - intType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("int-dictionary", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 14), - "int-dictionary", - "input", - typeof(IDictionary).Namespace + ".IDictionary"), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("string-dictionary", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 17), - "string-dictionary", - "input", - typeof(IDictionary).Namespace + ".IDictionary"), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("int-prefix-", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 11), - "int-prefix-", - "input", - intType), - RazorDiagnosticFactory.CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey( - new SourceSpan(7, 0, 7, 11), - "int-prefix-", - "input"), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("string-prefix-", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 14), - "string-prefix-", - "input", - stringType), - RazorDiagnosticFactory.CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey( - new SourceSpan(7, 0, 7, 14), - "string-prefix-", - "input"), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("int-prefix-value", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 16), - "int-prefix-value", - "input", - intType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("string-prefix-value", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 19), - "string-prefix-value", - "input", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("int-prefix-value", new MarkupBlock(), AttributeStructure.SingleQuotes), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 16), - "int-prefix-value", - "input", - intType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("string-prefix-value", new MarkupBlock(), AttributeStructure.SingleQuotes), - })), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "int-prefix-value", - factory.CodeMarkup("3").With(new ExpressionChunkGenerator()), - AttributeStructure.SingleQuotes), - })), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode( - "string-prefix-value", - new MarkupBlock( - factory.Markup("some"), - factory.Markup(" string")), - AttributeStructure.SingleQuotes), - })), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(24, 0, 24, 21), - "bound-required-string", - "input", - stringType), - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 9), - "bound-int", - "p", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(13, 0, 13, 12), - "bound-string", - "p", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 18), - "bound-required-int", - "input", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(43, 0, 43, 21), - "bound-required-string", - "input", - stringType), - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 9), - "bound-int", - "p", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(13, 0, 13, 12), - "bound-string", - "p", - stringType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(26, 0, 26, 12), - "bound-string", - "p", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - })), - noErrors - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 12), - "bound-string", - "p", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - })), - noErrors - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(15, 0, 15, 12), - "bound-string", - "p", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 21), - "bound-required-string", - "input", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(19, 0, 19, 21), - "bound-required-string", - "input", - stringType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 18), - "bound-required-int", - "input", - intType), - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 9), - "bound-int", - "p", - intType), - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(19, 0, 19, 18), - "bound-required-int", - "input", - intType), - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(15, 0, 15, 9), - "bound-int", - "p", - intType), - } - }, - { - $"", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("class", expression(14), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(33, 0, 33, 18), - "bound-required-int", - "input", - intType), - } - }, - { - $"

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("class", expression(10), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(29, 0, 29, 9), - "bound-int", - "p", - intType), - } - }, - { - $"", - new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", expression(36), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", expression(86), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(10, 0, 10, 18), - "bound-required-int", - "input", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(57, 0, 57, 21), - "bound-required-string", - "input", - stringType), - } - }, - { - $"

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", expression(23), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("class", expression(64), AttributeStructure.SingleQuotes), - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(6, 0, 6, 9), - "bound-int", - "p", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(44, 0, 44, 12), - "bound-string", - "p", - stringType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(84, 0, 84, 12), - "bound-string", - "p", - stringType), - } - }, - }; - } - } - - public static TheoryData MinimizedAttributeData_CSharpBlock - { - get - { - var factory = new SpanFactory(); - var documentData = MinimizedAttributeData_Document; - Func, MarkupBlock> buildStatementBlock = (insideBuilder) => - { - return new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - insideBuilder(), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()); - }; - Action updateDynamicChunkGenerators = (block) => - { - var tagHelperBlock = block.Children.First() as MarkupTagHelperBlock; - - for (var i = 0; i < tagHelperBlock.Attributes.Count; i++) - { - var attribute = tagHelperBlock.Attributes[i]; - var holderBlock = attribute.Value as Block; - - if (holderBlock == null) - { - continue; - } - - var valueBlock = holderBlock.Children.FirstOrDefault() as Block; - if (valueBlock != null) - { - var chunkGenerator = valueBlock.ChunkGenerator as DynamicAttributeBlockChunkGenerator; - - if (chunkGenerator != null) - { - var blockBuilder = new BlockBuilder(holderBlock); - var expressionBlockBuilder = new BlockBuilder(valueBlock); - var newChunkGenerator = new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - chunkGenerator.Prefix.Value, - new SourceLocation( - chunkGenerator.Prefix.Location.AbsoluteIndex + 2, - chunkGenerator.Prefix.Location.LineIndex, - chunkGenerator.Prefix.Location.CharacterIndex + 2)), - new SourceLocation( - chunkGenerator.ValueStart.AbsoluteIndex + 2, - chunkGenerator.ValueStart.LineIndex, - chunkGenerator.ValueStart.CharacterIndex + 2)); - - expressionBlockBuilder.ChunkGenerator = newChunkGenerator; - blockBuilder.Children[0] = expressionBlockBuilder.Build(); - - for (var j = 1; j < blockBuilder.Children.Count; j++) - { - var span = blockBuilder.Children[j] as Span; - if (span != null) - { - var literalChunkGenerator = - span.ChunkGenerator as LiteralAttributeChunkGenerator; - - var spanBuilder = new SpanBuilder(span); - spanBuilder.ChunkGenerator = new LiteralAttributeChunkGenerator( - prefix: new LocationTagged( - literalChunkGenerator.Prefix.Value, - new SourceLocation( - literalChunkGenerator.Prefix.Location.AbsoluteIndex + 2, - literalChunkGenerator.Prefix.Location.LineIndex, - literalChunkGenerator.Prefix.Location.CharacterIndex + 2)), - value: new LocationTagged( - literalChunkGenerator.Value.Value, - new SourceLocation( - literalChunkGenerator.Value.Location.AbsoluteIndex + 2, - literalChunkGenerator.Value.Location.LineIndex, - literalChunkGenerator.Value.Location.CharacterIndex + 2))); - - blockBuilder.Children[j] = spanBuilder.Build(); - } - } - - tagHelperBlock.Attributes[i] = new TagHelperAttributeNode( - attribute.Name, - blockBuilder.Build(), - attribute.AttributeStructure); - } - } - } - }; - - foreach (var data in documentData) - { - data[0] = $"@{{{data[0]}}}"; - - updateDynamicChunkGenerators(data[1] as MarkupBlock); - - data[1] = buildStatementBlock(() => data[1] as MarkupBlock); - - var errors = data[2] as RazorDiagnostic[]; - - for (var i = 0; i < errors.Length; i++) - { - var error = errors[i] as DefaultRazorDiagnostic; - var currentErrorLocation = new SourceLocation(error.Span.AbsoluteIndex, error.Span.LineIndex, error.Span.CharacterIndex); - var newErrorLocation = SourceLocationTracker.Advance(currentErrorLocation, "@{"); - var copiedDiagnostic = new DefaultRazorDiagnostic(error.Descriptor, new SourceSpan(newErrorLocation, error.Span.Length), error.Args); - errors[i] = copiedDiagnostic; - } - } - - return documentData; - } - } - - public static TheoryData MinimizedAttributeData_PartialTags - { - get - { - var factory = new SpanFactory(); - var noErrors = new RazorDiagnostic[0]; - var stringType = typeof(string).FullName; - var intType = typeof(int).FullName; - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "() - { - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - } - }, - { - "() - { - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 21), - "bound-required-string", - "input", - stringType), - } - }, - { - "() - { - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 18), - "bound-required-int", - "input", - intType), - } - }, - { - "() - { - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 18), - "bound-required-int", - "input", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(43, 0, 43, 21), - "bound-required-string", - "input", - stringType), - } - }, - { - "

            () - { - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 12), - "bound-string", - "p", - stringType), - } - }, - { - "

            () - { - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 9), - "bound-int", - "p", - intType), - } - }, - { - "

            () - { - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(3, 0, 3, 9), - "bound-int", - "p", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(13, 0, 13, 12), - "bound-string", - "p", - stringType), - } - }, - { - "() - { - new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized), - }, - children: new MarkupTagHelperBlock( - "p", - TagMode.StartTagAndEndTag, - attributes: new List() - { - new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized), - }))), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 18), - "bound-required-int", - "input", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(43, 0, 43, 21), - "bound-required-string", - "input", - stringType), - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(65, 0, 65), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(65, 0, 65), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(67, 0, 67, 9), - "bound-int", - "p", - intType), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(77, 0, 77, 12), - "bound-string", - "p", - stringType), - } - }, - }; - } - } - - [Theory] - [MemberData(nameof(MinimizedAttributeData_Document))] - [MemberData(nameof(MinimizedAttributeData_CSharpBlock))] - [MemberData(nameof(MinimizedAttributeData_PartialTags))] - public void Rewrite_UnderstandsMinimizedAttributes( - string documentContent, - object expectedOutput, - object expectedErrors) - { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("input") - .RequireAttributeDescriptor(attribute => attribute.Name("unbound-required"))) - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("input") - .RequireAttributeDescriptor(attribute => attribute.Name("bound-required-string"))) - .BoundAttributeDescriptor(attribute => - attribute - .Name("bound-required-string") - .PropertyName("BoundRequiredString") - .TypeName(typeof(string).FullName)) - .Build(), - TagHelperDescriptorBuilder.Create("InputTagHelper2", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("input") - .RequireAttributeDescriptor(attribute => attribute.Name("bound-required-int"))) - .BoundAttributeDescriptor(attribute => - attribute - .Name("bound-required-int") - .PropertyName("BoundRequiredInt") - .TypeName(typeof(int).FullName)) - .Build(), - TagHelperDescriptorBuilder.Create("InputTagHelper3", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("input")) - .BoundAttributeDescriptor(attribute => - attribute - .Name("int-dictionary") - .PropertyName("DictionaryOfIntProperty") - .TypeName(typeof(IDictionary).Namespace + ".IDictionary") - .AsDictionaryAttribute("int-prefix-", typeof(int).FullName)) - .BoundAttributeDescriptor(attribute => - attribute - .Name("string-dictionary") - .PropertyName("DictionaryOfStringProperty") - .TypeName(typeof(IDictionary).Namespace + ".IDictionary") - .AsDictionaryAttribute("string-prefix-", typeof(string).FullName)) - .Build(), - TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) - .BoundAttributeDescriptor(attribute => - attribute - .Name("bound-string") - .PropertyName("BoundRequiredString") - .TypeName(typeof(string).FullName)) - .BoundAttributeDescriptor(attribute => - attribute - .Name("bound-int") - .PropertyName("BoundRequiredString") - .TypeName(typeof(int).FullName)) - .Build(), - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); + return descriptors; } [Fact] - public void Rewrite_UnderstandsMinimizedBooleanBoundAttributes() + public void AllowsCompatibleTagStructures1() { // Arrange - var documentContent = ""; + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.Unspecified); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures2() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.Unspecified); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures3() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.WithoutEndTag); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures4() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.WithoutEndTag, TagStructure.WithoutEndTag); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures5() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.NormalOrSelfClosing); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures6() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.WithoutEndTag); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures7() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.NormalOrSelfClosing, TagStructure.Unspecified); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes1() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes4() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes8() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes9() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes10() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes11() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes12() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes13() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes14() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes15() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes16() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes18() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes19() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelper1() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelper5() + { + RunParseTreeRewriterTest(" <

            ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelper7() + { + RunParseTreeRewriterTest("<<> <<>>", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelper8() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + public static TagHelperDescriptor[] CodeTagHelperAttributes_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PersonTagHelper", "personAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("person")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("age") + .PropertyName("Age") + .TypeName(typeof(int).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("birthday") + .PropertyName("BirthDay") + .TypeName(typeof(DateTime).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("name") + .PropertyName("Name") + .TypeName(typeof(string).FullName)) + .Build() + }; + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes1() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes2() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes3() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes4() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes5() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes6() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes7() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes8() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes9() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes10() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes11() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2() + { + RunParseTreeRewriterTest("

            Hello World

            ", "strong", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3() + { + RunParseTreeRewriterTest("

            Hello World

            ", "strong", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4() + { + RunParseTreeRewriterTest("

            Hello

            World

            ", "strong", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2() + { + RunParseTreeRewriterTest("

            Hello World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3() + { + RunParseTreeRewriterTest("

            Hello

            World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

            "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2() + { + // Arrange + var doWhileString = "@do { var foo = bar; Foo foo++; } while (foo);"; + var currentFormattedString = "

            "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

            Hello World

            "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4() + { + // Arrange + var doWhileString = "@do { var foo = bar; Foo foo++; } while (foo);"; + var currentFormattedString = "

            Hello World

            "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

            Hello

            World

            "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6() + { + // Arrange + var doWhileString = "@do { var foo = bar; Foo foo++; } while (foo);"; + var currentFormattedString = "

            Hello

            World

            "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

            Hello World inside of strong tag

            "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

            {0}

            "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2() + { + // Arrange + var doWhileString = "@do { var foo = bar;

            Foo

            foo++; } while (foo);"; + var currentFormattedString = "

            {0}

            "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

            Hello World {0}

            "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4() + { + // Arrange + var doWhileString = "@do { var foo = bar;

            Foo

            foo++; } while (foo);"; + var currentFormattedString = "

            Hello World {0}

            "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

            {0}

            {0}

            "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6() + { + // Arrange + var doWhileString = "@do { var foo = bar;

            Foo

            foo++; } while (foo);"; + var currentFormattedString = "

            {0}

            {0}

            "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

            Hello {0}inside of {0} strong tag

            "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8() + { + // Arrange + var doWhileString = "@do { var foo = bar;

            Foo

            foo++; } while (foo);"; + var currentFormattedString = "

            Hello {0}inside of {0} strong tag

            "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml1() + { + RunParseTreeRewriterTest("<<

            >>

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml2() + { + RunParseTreeRewriterTest("<

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml3() + { + RunParseTreeRewriterTest("< p />", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml4() + { + RunParseTreeRewriterTest("", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml5() + { + RunParseTreeRewriterTest("< class=\"foo\"

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml6() + { + RunParseTreeRewriterTest("/>

            >", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml7() + { + RunParseTreeRewriterTest("/>

            >", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml8() + { + RunParseTreeRewriterTest("@DateTime.Now/>

            >", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml9() + { + RunParseTreeRewriterTest("

            @DateTime.Now / >

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml10() + { + RunParseTreeRewriterTest("

            < @DateTime.Now >

            ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers1() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers2() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers3() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers4() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers5() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + public static TagHelperDescriptor[] EmptyTagHelperBoundAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("mythTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("myth")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound") + .PropertyName("Bound") + .TypeName(typeof(bool).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("name") + .PropertyName("Name") + .TypeName(typeof(string).FullName)) + .Build() + }; + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes1() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes2() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes3() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes4() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes5() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes6() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes7() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes8() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes9() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes10() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes11() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes12() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes13() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes14() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers1() + { + RunParseTreeRewriterTest("", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers2() + { + RunParseTreeRewriterTest("", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers3() + { + RunParseTreeRewriterTest("

            World

            ", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers4() + { + RunParseTreeRewriterTest(" ", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers5() + { + RunParseTreeRewriterTest(" World

            ", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers7() + { + RunParseTreeRewriterTest("

            Hello World

            ", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + + [Fact] + public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2() + { + RunParseTreeRewriterTest("

            Hello

            World

            ", "p"); + } + + + [Fact] + public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3() + { + RunParseTreeRewriterTest("Hello

            World", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2() + { + RunParseTreeRewriterTest("

            Hello World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3() + { + RunParseTreeRewriterTest("

            Hello World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4() + { + RunParseTreeRewriterTest("

            Hello

            World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5() + { + RunParseTreeRewriterTest("

            Hello World inside of strong tag

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2() + { + RunParseTreeRewriterTest("

            Hello World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3() + { + RunParseTreeRewriterTest("

            Hello

            World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4() + { + RunParseTreeRewriterTest("

            Hello World inside of strong tag

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1() + { + RunParseTreeRewriterTest("

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2() + { + RunParseTreeRewriterTest("

            Hello World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3() + { + RunParseTreeRewriterTest("

            Hello

            World

            ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4() + { + RunParseTreeRewriterTest("

            Hello World inside of strong tag

            ", "p"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document1() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document2() + { + // Arrange + var document = ""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document3() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document4() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document5() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document6() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document7() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block1() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block2() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block3() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block4() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block5() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block6() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block7() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + public static TagHelperDescriptor[] MinimizedAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("unbound-required"))) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("bound-required-string"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound-required-string") + .PropertyName("BoundRequiredString") + .TypeName(typeof(string).FullName)) + .Build(), + TagHelperDescriptorBuilder.Create("InputTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("bound-required-int"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound-required-int") + .PropertyName("BoundRequiredInt") + .TypeName(typeof(int).FullName)) + .Build(), + TagHelperDescriptorBuilder.Create("InputTagHelper3", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("input")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("int-dictionary") + .PropertyName("DictionaryOfIntProperty") + .TypeName(typeof(IDictionary).Namespace + ".IDictionary") + .AsDictionaryAttribute("int-prefix-", typeof(int).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("string-dictionary") + .PropertyName("DictionaryOfStringProperty") + .TypeName(typeof(IDictionary).Namespace + ".IDictionary") + .AsDictionaryAttribute("string-prefix-", typeof(string).FullName)) + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound-string") + .PropertyName("BoundRequiredString") + .TypeName(typeof(string).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound-int") + .PropertyName("BoundRequiredString") + .TypeName(typeof(int).FullName)) + .Build(), + }; + + [Fact] + public void UnderstandsMinimizedAttributes_Document1() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document2() + { + // Arrange + var document = "

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document3() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document4() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document5() + { + // Arrange + var document = "

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document6() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document7() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document8() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document9() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document10() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document11() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document12() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document13() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document14() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document15() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document16() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document17() + { + // Arrange + var document = "

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document18() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document19() + { + // Arrange + var document = "

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document20() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document21() + { + // Arrange + var document = "

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document22() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document23() + { + // Arrange + var document = "

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document24() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document25() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document26() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document27() + { + // Arrange + var document = "

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document28() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document29() + { + // Arrange + var document = "

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document30() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document31() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $"

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document32() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document33() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $"

            "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block1() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block2() + { + // Arrange + var document = "

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block3() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block4() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block5() + { + // Arrange + var document = "

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block6() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block7() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block8() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block9() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block10() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block11() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block12() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block13() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block14() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block15() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block16() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block17() + { + // Arrange + var document = "

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block18() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block19() + { + // Arrange + var document = "

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block20() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block21() + { + // Arrange + var document = "

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block22() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block23() + { + // Arrange + var document = "

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block24() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block25() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block26() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block27() + { + // Arrange + var document = "

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block28() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block29() + { + // Arrange + var document = "

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block30() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block31() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $"

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block32() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block33() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $"

            "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_PartialTags1() + { + EvaluateData(MinimizedAttribute_Descriptors, "() - { - new TagHelperAttributeNode("boundbool", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("boundbooldict-key", null, AttributeStructure.Minimized), - })); - // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, new RazorDiagnostic[] { }); + EvaluateData(descriptors, document); } [Fact] - public void Rewrite_FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes() + public void FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes() { // Arrange - var documentContent = ""; + var document = ""; var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") @@ -3964,32 +2127,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var featureFlags = new TestRazorParserFeatureFlags(); - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock( - "input", - TagMode.SelfClosing, - attributes: new List() - { - new TagHelperAttributeNode("boundbool", null, AttributeStructure.Minimized), - new TagHelperAttributeNode("boundbooldict-key", null, AttributeStructure.Minimized), - })); - - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(7, 0, 7, 9), - "boundbool", - "input", - "System.Boolean"), - RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( - new SourceSpan(17, 0, 17, 17), - "boundbooldict-key", - "input", - "System.Boolean"), - }; - // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors, featureFlags: featureFlags); + EvaluateData(descriptors, document, featureFlags: featureFlags); } private class TestRazorParserFeatureFlags : RazorParserFeatureFlags diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs index 3f37c82c4d..76ef95f37a 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using Xunit; @@ -68,299 +67,198 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Assert.Equal(expectedPairs, pairs); } - public static TheoryData PartialRequiredParentData + public static TagHelperDescriptor[] PartialRequiredParentTags_Descriptors = new TagHelperDescriptor[] { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - Func errorFormatUnclosed = (location, tagName) => - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(location, 0, location), tagName.Length), tagName); + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .Build(), + TagHelperDescriptorBuilder.Create("CatchALlTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + }; - Func errorFormatNoCloseAngle = (location, tagName) => - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(location, 0, location), tagName.Length), tagName); - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong"))), - new[] { errorFormatUnclosed(1, "p"), errorFormatUnclosed(4, "strong") } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong"))), - new[] { errorFormatUnclosed(1, "p") } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong")), - new MarkupTagHelperBlock("strong")), - new[] { errorFormatUnclosed(4, "strong"), errorFormatUnclosed(16, "strong") } - }, - { - "<

            <

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("strong", - blockFactory.MarkupTagBlock(""))), - new[] { errorFormatNoCloseAngle(17, "strong"), errorFormatUnclosed(25, "strong") } - }, - { - "<

            <

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("strong", - blockFactory.MarkupTagBlock(""))), - new[] { errorFormatUnclosed(26, "strong") } - }, - - { - "<

            <

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("<"), - new MarkupTagHelperBlock("custom", - blockFactory.MarkupTagBlock(""))), - new[] { errorFormatUnclosed(27, "custom") } - }, - }; - } - } - - [Theory] - [MemberData(nameof(PartialRequiredParentData))] - public void Rewrite_UnderstandsPartialRequiredParentTags( - string documentContent, - object expectedOutput, - object expectedErrors) + [Fact] + public void UnderstandsPartialRequiredParentTags1() { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong")) - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) - .Build(), - TagHelperDescriptorBuilder.Create("CatchALlTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) - .Build(), - TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) - .Build(), - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); - } - - public static TheoryData NestedVoidSelfClosingRequiredParentData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - // documentContent, expectedOutput - return new TheoryData - { - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("input", TagMode.StartTagOnly), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("")) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("input", TagMode.StartTagOnly), - new MarkupTagHelperBlock("strong"))) - }, - { - "


            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("
            "), - new MarkupTagHelperBlock("strong"))) - }, - { - "


            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("
            ")), - new MarkupTagHelperBlock("strong"))) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("input", TagMode.StartTagOnly), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("")) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("input", TagMode.SelfClosing), - new MarkupTagHelperBlock("strong", TagMode.SelfClosing))) - }, - { - "


            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("
            "), - new MarkupTagHelperBlock("strong", TagMode.SelfClosing))) - }, - { - "


            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("
            ")), - new MarkupTagHelperBlock("strong", TagMode.SelfClosing))) - }, - }; - } - } - - [Theory] - [MemberData(nameof(NestedVoidSelfClosingRequiredParentData))] - public void Rewrite_UnderstandsNestedVoidSelfClosingRequiredParent( - string documentContent, - object expectedOutput) - { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("input") - .RequireTagStructure(TagStructure.WithoutEndTag)) - .Build(), - TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("strong") - .RequireParentTag("p")) - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("strong") - .RequireParentTag("input")) - .Build(), - TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) - .Build(), - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); - } - - public static TheoryData NestedRequiredParentData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - // documentContent, expectedOutput - return new TheoryData - { - { - "", - new MarkupBlock( - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("")) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong"))) - }, - { - "
            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("
            "), - new MarkupTagHelperBlock("strong"), - blockFactory.MarkupTagBlock("
            ")) - }, - { - "", - new MarkupBlock( - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("")) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong", - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("")))) - }, - }; - } - } - - [Theory] - [MemberData(nameof(NestedRequiredParentData))] - public void Rewrite_UnderstandsNestedRequiredParent(string documentContent, object expectedOutput) - { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("strong") - .RequireParentTag("p")) - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("strong") - .RequireParentTag("div")) - .Build(), - TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) - .Build(), - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); + var document = "

            "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); } [Fact] - public void Rewrite_UnderstandsTagHelperPrefixAndAllowedChildren() + public void UnderstandsPartialRequiredParentTags2() + { + var document = "

            "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags3() + { + var document = "

            "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags4() + { + var document = "<

            <

            "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags5() + { + var document = "<

            <

            "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags6() + { + var document = "<

            <

            "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + public static TagHelperDescriptor[] NestedVoidSelfClosingRequiredParent_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build(), + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("p")) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("input")) + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + }; + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent1() + { + var document = ""; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent2() + { + var document = "

            "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent3() + { + var document = "


            "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent4() + { + var document = "


            "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent5() + { + var document = ""; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent6() + { + var document = "

            "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent7() + { + var document = "


            "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent8() + { + var document = "


            "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + public static TagHelperDescriptor[] NestedRequiredParent_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("p")) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("div")) + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + }; + + [Fact] + public void UnderstandsNestedRequiredParent1() + { + var document = ""; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedRequiredParent2() + { + var document = "

            "; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedRequiredParent3() + { + var document = "
            "; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedRequiredParent4() + { + var document = ""; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedRequiredParent5() + { + var document = "

            "; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsTagHelperPrefixAndAllowedChildren() { // Arrange var documentContent = ""; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("th:p", - new MarkupTagHelperBlock("th:strong"))); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") @@ -376,19 +274,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy EvaluateData( descriptors, documentContent, - expectedOutput, - expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } [Fact] - public void Rewrite_UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent() + public void UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent() { // Arrange var documentContent = ""; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("th:p", - new MarkupTagHelperBlock("th:strong"))); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") @@ -404,20 +297,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy EvaluateData( descriptors, documentContent, - expectedOutput, - expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } [Fact] - public void Rewrite_InvalidStructure_UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent() + public void InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent() { + // Rewrite_InvalidStructure_UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent // Arrange var documentContent = ""; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("th:p", - new MarkupTagBlock( - Factory.Markup("")))); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") @@ -428,32 +316,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong").RequireParentTag("p")) .Build(), }; - var expectedErrors = new[] { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(filePath: null, absoluteIndex: 8, lineIndex: 0, characterIndex: 8, length: 9), - "th:strong"), - }; // Act & Assert EvaluateData( descriptors, documentContent, - expectedOutput, - expectedErrors: expectedErrors, tagHelperPrefix: "th:"); } [Fact] - public void Rewrite_NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren() + public void NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren() { // Arrange var documentContent = ""; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("th:p", - new MarkupTagBlock( - Factory.Markup("")), - new MarkupTagBlock( - Factory.Markup("")))); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") @@ -466,298 +341,71 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy EvaluateData( descriptors, documentContent, - expectedOutput, - expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } - public static TheoryData InvalidHtmlScriptBlockData + [Fact] + public void DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags1() { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - return new TheoryData - { - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - factory.Markup(""), - blockFactory.MarkupTagBlock("")) - }, - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" types='", 7, 0, 7), - suffix: new LocationTagged("'", 24, 0, 24)), - factory.Markup(" types='").With(SpanChunkGenerator.Null), - factory.Markup("text/html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 15, 0, 15), - value: new LocationTagged("text/html", 15, 0, 15))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - factory.Markup(""), - blockFactory.MarkupTagBlock("")) - }, - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" type='", 7, 0, 7), - suffix: new LocationTagged("'", 31, 0, 31)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 14, 0, 14), - value: new LocationTagged("text/html", 14, 0, 14))), - factory.Markup(" invalid").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", 23, 0, 23), - value: new LocationTagged("invalid", 24, 0, 24))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - factory.Markup(""), - blockFactory.MarkupTagBlock("")) - }, - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" type='", 7, 0, 7), - suffix: new LocationTagged("'", 23, 0, 23)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/ng-*").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 14, 0, 14), - value: new LocationTagged("text/ng-*", 14, 0, 14))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "type", - prefix: new LocationTagged(" type='", 24, 0, 24), - suffix: new LocationTagged("'", 40, 0, 40)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 31, 0, 31), - value: new LocationTagged("text/html", 31, 0, 31))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - factory.Markup(""), - blockFactory.MarkupTagBlock("")) - }, - }; - } - } - - [Theory] - [MemberData(nameof(InvalidHtmlScriptBlockData))] - public void TagHelperParseTreeRewriter_DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "input"); - } - - public static TheoryData HtmlScriptBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - return new TheoryData - { - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" type='", 7, 0, 7), - suffix: new LocationTagged("'", 23, 0, 23)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 14, 0, 14), - value: new LocationTagged("text/html", 14, 0, 14))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - new MarkupTagHelperBlock("input", TagMode.SelfClosing), - blockFactory.MarkupTagBlock("")) - }, - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" id='", 7, 0, 7), - suffix: new LocationTagged("'", 21, 0, 21)), - factory.Markup(" id='").With(SpanChunkGenerator.Null), - factory.Markup("scriptTag").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 12, 0, 12), - value: new LocationTagged("scriptTag", 12, 0, 12))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "type", - prefix: new LocationTagged(" type='", 22, 0, 22), - suffix: new LocationTagged("'", 38, 0, 38)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 29, 0, 29), - value: new LocationTagged("text/html", 29, 0, 29))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class='", 39, 0, 39), - suffix: new LocationTagged("'", 56, 0, 56)), - factory.Markup(" class='").With(SpanChunkGenerator.Null), - factory.Markup("something").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 47, 0, 47), - value: new LocationTagged("something", 47, 0, 47))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - new MarkupTagHelperBlock("input", TagMode.SelfClosing), - blockFactory.MarkupTagBlock("")) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" type='", 7, 0, 7), - suffix: new LocationTagged("'", 23, 0, 23)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 14, 0, 14), - value: new LocationTagged("text/html", 14, 0, 14))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - new MarkupTagHelperBlock("p", - new MarkupTagBlock( - factory.Markup("(" type='", 35, 0, 35), - suffix: new LocationTagged("'", 51, 0, 51)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 42, 0, 42), - value: new LocationTagged("text/html", 42, 0, 42))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - new MarkupTagHelperBlock("input", TagMode.SelfClosing), - blockFactory.MarkupTagBlock("")), - blockFactory.MarkupTagBlock("")) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" type='", 7, 0, 7), - suffix: new LocationTagged("'", 23, 0, 23)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 14, 0, 14), - value: new LocationTagged("text/html", 14, 0, 14))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - new MarkupTagHelperBlock("p", - new MarkupTagBlock( - factory.Markup("(" type='", 35, 0, 35), - suffix: new LocationTagged("'", 52, 0, 52)), - factory.Markup(" type='").With(SpanChunkGenerator.Null), - factory.Markup("text/").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 42, 0, 42), - value: new LocationTagged("text/", 42, 0, 42))), - factory.Markup(" html").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", 47, 0, 47), - value: new LocationTagged("html", 48, 0, 48))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - factory.Markup(""), - blockFactory.MarkupTagBlock("")), - blockFactory.MarkupTagBlock("")) - }, - }; - } - } - - [Theory] - [MemberData(nameof(HtmlScriptBlockData))] - public void TagHelperParseTreeRewriter_UnderstandsTagHelpersInHtmlTypedScriptTags( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p", "input"); + var document = ""; + RunParseTreeRewriterTest(document, "input"); } [Fact] - public void Rewrite_CanHandleInvalidChildrenWithWhitespace() + public void DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags2() + { + var document = ""; + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags3() + { + var document = ""; + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags4() + { + var document = ""; + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void UnderstandsTagHelpersInHtmlTypedScriptTags1() + { + var document = ""; + RunParseTreeRewriterTest(document, "p", "input"); + } + + [Fact] + public void UnderstandsTagHelpersInHtmlTypedScriptTags2() + { + var document = ""; + RunParseTreeRewriterTest(document, "p", "input"); + } + + [Fact] + public void UnderstandsTagHelpersInHtmlTypedScriptTags3() + { + var document = "

            "; + RunParseTreeRewriterTest(document, "p", "input"); + } + + [Fact] + public void UnderstandsTagHelpersInHtmlTypedScriptTags4() + { + var document = "

            "; + RunParseTreeRewriterTest(document, "p", "input"); + } + + [Fact] + public void CanHandleInvalidChildrenWithWhitespace() { // Arrange - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); var documentContent = $"

            {Environment.NewLine} {Environment.NewLine} Hello" + $"{Environment.NewLine} {Environment.NewLine}

            "; - var newLineLength = Environment.NewLine.Length; - var expectedErrors = new[] { - RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( - new SourceSpan(absoluteIndex: 8 + newLineLength, lineIndex: 1, characterIndex: 5, length: 6), "strong", "p", "br"), - }; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup(Environment.NewLine + " "), - blockFactory.MarkupTagBlock(""), - factory.Markup(Environment.NewLine + " Hello" + Environment.NewLine + " "), - blockFactory.MarkupTagBlock(""), - factory.Markup(Environment.NewLine))); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") @@ -767,29 +415,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors); + EvaluateData(descriptors, documentContent); } [Fact] - public void Rewrite_RecoversWhenRequiredAttributeMismatchAndRestrictedChildren() + public void RecoversWhenRequiredAttributeMismatchAndRestrictedChildren() { // Arrange - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); var documentContent = ""; - - var expectedErrors = new[] { - RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( - new SourceSpan(absoluteIndex: 18, lineIndex: 0, characterIndex: 18, length: 6), "strong", "strong", "br") - }; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("strong", - new List - { - new TagHelperAttributeNode("required", null, AttributeStructure.Minimized) - }, - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""))); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") @@ -802,20 +435,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors); + EvaluateData(descriptors, documentContent); } [Fact] - public void Rewrite_CanHandleMultipleTagHelpersWithAllowedChildren_OneNull() + public void CanHandleMultipleTagHelpersWithAllowedChildren_OneNull() { // Arrange - var factory = new SpanFactory(); var documentContent = "

            Hello World

            "; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong", - factory.Markup("Hello World")), - new MarkupTagHelperBlock("br", TagMode.StartTagOnly))); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("PTagHelper1", "SomeAssembly") @@ -838,20 +465,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); + EvaluateData(descriptors, documentContent); } [Fact] - public void Rewrite_CanHandleMultipleTagHelpersWithAllowedChildren() + public void CanHandleMultipleTagHelpersWithAllowedChildren() { // Arrange - var factory = new SpanFactory(); var documentContent = "

            Hello World

            "; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong", - factory.Markup("Hello World")), - new MarkupTagHelperBlock("br", TagMode.StartTagOnly))); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("PTagHelper1", "SomeAssembly") @@ -874,214 +495,165 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); + EvaluateData(descriptors, documentContent); } - public static TheoryData AllowedChildrenData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - Func nestedTagError = - (childName, parentName, allowed, location, length) => - RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( - new SourceSpan(absoluteIndex: location, lineIndex: 0, characterIndex: location, length: length), childName, parentName, allowed); - Func nestedContentError = - (parentName, allowed, location, length) => - RazorDiagnosticFactory.CreateTagHelper_CannotHaveNonTagContent( - new SourceSpan(absoluteIndex: location, lineIndex: 0, characterIndex: location, length: length), parentName, allowed); - - return new TheoryData, MarkupBlock, RazorDiagnostic[]> - { - { - "


            ", - new[] { "br" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("br", TagMode.SelfClosing))), - new RazorDiagnostic[0] - }, - { - $"

            {Environment.NewLine}
            {Environment.NewLine}

            ", - new[] { "br" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup(Environment.NewLine), - new MarkupTagHelperBlock("br", TagMode.SelfClosing), - factory.Markup(Environment.NewLine))), - new RazorDiagnostic[0] - }, - { - "


            ", - new[] { "strong" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("br", TagMode.StartTagOnly))), - new[] { nestedTagError("br", "p", "strong", 4, 2) } - }, - { - "

            Hello

            ", - new[] { "strong" }, - new MarkupBlock(new MarkupTagHelperBlock("p", factory.Markup("Hello"))), - new[] { nestedContentError("p", "strong", 3, 5) } - }, - { - "


            ", - new[] { "br", "strong" }, - new MarkupBlock(new MarkupTagHelperBlock("p", blockFactory.MarkupTagBlock("
            "))), - new[] { nestedTagError("hr", "p", "br, strong", 4, 2) } - }, - { - "


            Hello

            ", - new[] { "strong" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("br", TagMode.StartTagOnly), - factory.Markup("Hello"))), - new[] { nestedTagError("br", "p", "strong", 4, 2), nestedContentError("p", "strong", 7, 5) } - }, - { - "

            Title:
            Something

            ", - new[] { "strong" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong", factory.Markup("Title:")), - new MarkupTagHelperBlock("br", TagMode.SelfClosing), - factory.Markup("Something"))), - new[] - { - nestedContentError("strong", "strong", 11, 6), - nestedTagError("br", "p", "strong", 27, 2), - nestedContentError("p", "strong", 32, 9), - } - }, - { - "

            Title:
            Something

            ", - new[] { "strong", "br" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong", factory.Markup("Title:")), - new MarkupTagHelperBlock("br", TagMode.SelfClosing), - factory.Markup("Something"))), - new[] - { - nestedContentError("strong", "strong, br", 11, 6), - nestedContentError("p", "strong, br", 32, 9), - } - }, - { - "

            Title:
            Something

            ", - new[] { "strong", "br" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup(" "), - new MarkupTagHelperBlock("strong", factory.Markup("Title:")), - factory.Markup(" "), - new MarkupTagHelperBlock("br", TagMode.SelfClosing), - factory.Markup(" Something"))), - new[] - { - nestedContentError("strong", "strong, br", 13, 6), - nestedContentError("p", "strong, br", 38, 9), - } - }, - { - "

            Title:
            A Very Cool

            Something

            ", - new[] { "strong" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong", - factory.Markup("Title:"), - new MarkupTagHelperBlock("br", TagMode.StartTagOnly), - blockFactory.MarkupTagBlock(""), - factory.Markup("A Very Cool"), - blockFactory.MarkupTagBlock("")), - new MarkupTagHelperBlock("br", TagMode.SelfClosing), - factory.Markup("Something"))), - new[] - { - nestedContentError("strong", "strong", 11, 6), - nestedTagError("br", "strong", "strong", 18, 2), - nestedTagError("em", "strong", "strong", 22, 2), - nestedTagError("br", "p", "strong", 51, 2), - nestedContentError("p", "strong", 56, 9) - } - }, - { - "

            Title:
            A Very Cool

            Something

            ", - new[] { "custom" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock(""), - factory.Markup("Title:"), - new MarkupTagHelperBlock("br", TagMode.StartTagOnly), - blockFactory.MarkupTagBlock(""), - factory.Markup("A Very Cool"), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - new MarkupTagHelperBlock("br", TagMode.SelfClosing), - factory.Markup("Something"))), - new[] - { - nestedTagError("br", "p", "custom", 51, 2), - nestedContentError("p", "custom", 56, 9) - } - }, - { - "

            ", - new[] { "custom" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("<

            ", - new[] { "custom" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock("<"))), - new[] - { - nestedContentError("p", "custom", 3, 1), - } - }, - { - "


            :Hello:

            ", - new[] { "custom", "strong" }, - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock(""), - new MarkupTagHelperBlock("br", TagMode.StartTagOnly), - factory.Markup(":"), - new MarkupTagHelperBlock("strong", - new MarkupTagHelperBlock("strong", - factory.Markup("Hello"))), - factory.Markup(":"), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""))), - new[] - { - nestedContentError("strong", "custom, strong", 32, 5), - } - }, - }; - } - } - - [Theory] - [MemberData(nameof(AllowedChildrenData))] - public void Rewrite_UnderstandsAllowedChildren( - string documentContent, - IEnumerable allowedChildren, - object expectedOutput, - object expectedErrors) + [Fact] + public void UnderstandsAllowedChildren1() { // Arrange + var documentContent = "


            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "br" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren2() + { + // Arrange + var documentContent = $"

            {Environment.NewLine}
            {Environment.NewLine}

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "br" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren3() + { + // Arrange + var documentContent = "


            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren4() + { + // Arrange + var documentContent = "

            Hello

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren5() + { + // Arrange + var documentContent = "


            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "br", "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren6() + { + // Arrange + var documentContent = "


            Hello

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren7() + { + // Arrange + var documentContent = "

            Title:
            Something

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren8() + { + // Arrange + var documentContent = "

            Title:
            Something

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong", "br" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren9() + { + // Arrange + var documentContent = "

            Title:
            Something

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong", "br" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren10() + { + // Arrange + var documentContent = "

            Title:
            A Very Cool

            Something

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren11() + { + // Arrange + var documentContent = "

            Title:
            A Very Cool

            Something

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "custom" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren12() + { + // Arrange + var documentContent = "

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "custom" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren13() + { + // Arrange + var documentContent = "

            <

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "custom" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren14() + { + // Arrange + var documentContent = "


            :Hello:

            "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "custom", "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + private TagHelperDescriptor[] GetAllowedChildrenTagHelperDescriptors(string[] allowedChildren) + { var pTagHelperBuilder = TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")); var strongTagHelperBuilder = TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") @@ -1104,18 +676,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Build(), }; - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); + return descriptors; } [Fact] - public void Rewrite_AllowsSimpleHtmlCommentsAsChildren() + public void AllowsSimpleHtmlCommentsAsChildren() { // Arrange - IEnumerable allowedChildren = new List { "b" }; - string literal = "asdf"; - string commentOutput = "Hello World"; - string expectedOutput = $"

            {literal}

            "; + var allowedChildren = new List { "b" }; + var literal = "asdf"; + var commentOutput = "Hello World"; + var document = $"

            {literal}

            "; var pTagHelperBuilder = TagHelperDescriptorBuilder .Create("PTagHelper", "SomeAssembly") @@ -1130,40 +701,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy pTagHelperBuilder.Build() }; - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - var expectedMarkup = new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock(""), - factory.Markup(literal), - blockFactory.MarkupTagBlock(""), - blockFactory.HtmlCommentBlock(commentOutput))); - // Act & Assert - EvaluateData( - descriptors, - expectedOutput, - expectedMarkup, - Array.Empty()); + EvaluateData(descriptors, document); } [Fact] - public void Rewrite_DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff() + public void DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff() { // Arrange - Func nestedTagError = - (childName, parentName, allowed, location, length) => - RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( - new SourceSpan(absoluteIndex: location, lineIndex: 0, characterIndex: location, length: length), childName, parentName, allowed); - Func nestedContentError = - (parentName, allowed, location, length) => - RazorDiagnosticFactory.CreateTagHelper_CannotHaveNonTagContent( - new SourceSpan(absoluteIndex: location, lineIndex: 0, characterIndex: location, length: length), parentName, allowed); - - IEnumerable allowedChildren = new List { "b" }; - string comment1 = "Hello"; - string expectedOutput = $"

            "; + var allowedChildren = new List { "b" }; + var comment1 = "Hello"; + var document = $"

            "; var pTagHelperBuilder = TagHelperDescriptorBuilder .Create("PTagHelper", "SomeAssembly") @@ -1178,45 +726,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy pTagHelperBuilder.Build() }; - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - var expectedMarkup = new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.HtmlCommentBlock(comment1))); - // Act & Assert EvaluateData( descriptors, - expectedOutput, - expectedMarkup, - new[] - { - nestedContentError("p", "b", 3, 4), - nestedContentError("p", "b", 7, 5), - nestedContentError("p", "b", 12, 3), - }, + document, featureFlags: RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_2_0)); } [Fact] - public void Rewrite_FailsForContentWithCommentsAsChildren() + public void FailsForContentWithCommentsAsChildren() { // Arrange - Func nestedTagError = - (childName, parentName, allowed, location, length) => - RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( - new SourceSpan(absoluteIndex: location, lineIndex: 0, characterIndex: location, length: length), childName, parentName, allowed); - Func nestedContentError = - (parentName, allowed, location, length) => - RazorDiagnosticFactory.CreateTagHelper_CannotHaveNonTagContent( - new SourceSpan(absoluteIndex: location, lineIndex: 0, characterIndex: location, length: length), parentName, allowed); - - IEnumerable allowedChildren = new List { "b" }; - string comment1 = "Hello"; - string literal = "asdf"; - string comment2 = "World"; - string expectedOutput = $"

            {literal}

            "; + var allowedChildren = new List { "b" }; + var comment1 = "Hello"; + var literal = "asdf"; + var comment2 = "World"; + var document = $"

            {literal}

            "; var pTagHelperBuilder = TagHelperDescriptorBuilder .Create("PTagHelper", "SomeAssembly") @@ -1231,34 +756,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy pTagHelperBuilder.Build() }; - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - var expectedMarkup = new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.HtmlCommentBlock(comment1), - factory.Markup(literal), - blockFactory.HtmlCommentBlock(comment2))); - // Act & Assert - EvaluateData( - descriptors, - expectedOutput, - expectedMarkup, - new[] - { - nestedContentError("p", "b", 15, 4), - }); + EvaluateData(descriptors, document); } [Fact] - public void Rewrite_AllowsRazorCommentsAsChildren() + public void AllowsRazorCommentsAsChildren() { // Arrange - IEnumerable allowedChildren = new List { "b" }; - string literal = "asdf"; - string commentOutput = $"@*{literal}*@"; - string expectedOutput = $"

            {literal}{commentOutput}

            "; + var allowedChildren = new List { "b" }; + var literal = "asdf"; + var commentOutput = $"@*{literal}*@"; + var document = $"

            {literal}{commentOutput}

            "; var pTagHelperBuilder = TagHelperDescriptorBuilder .Create("PTagHelper", "SomeAssembly") @@ -1273,40 +782,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy pTagHelperBuilder.Build() }; - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - var expectedMarkup = new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock(""), - factory.Markup(literal), - blockFactory.MarkupTagBlock(""), - new CommentBlock( - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition).Accepts(AcceptedCharactersInternal.None), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Comment, new HtmlSymbol(literal, HtmlSymbolType.RazorComment)).Accepts(AcceptedCharactersInternal.Any), - Factory.MetaMarkup("*", HtmlSymbolType.RazorCommentStar).Accepts(AcceptedCharactersInternal.None), - Factory.MarkupTransition(HtmlSymbolType.RazorCommentTransition).Accepts(AcceptedCharactersInternal.None)))); - // Act & Assert - EvaluateData( - descriptors, - expectedOutput, - expectedMarkup, - Array.Empty()); + EvaluateData(descriptors, document); } [Fact] - public void Rewrite_AllowsRazorMarkupInHtmlComment() + public void AllowsRazorMarkupInHtmlComment() { // Arrange - IEnumerable allowedChildren = new List { "b" }; - string literal = "asdf"; - string part1 = "Hello "; - string part2 = "World"; - string commentStart = ""; - string expectedOutput = $"

            {literal}{commentStart}{part1}@{part2}{commentEnd}

            "; + var allowedChildren = new List { "b" }; + var literal = "asdf"; + var part1 = "Hello "; + var part2 = "World"; + var commentStart = ""; + var document = $"

            {literal}{commentStart}{part1}@{part2}{commentEnd}

            "; var pTagHelperBuilder = TagHelperDescriptorBuilder .Create("PTagHelper", "SomeAssembly") @@ -1321,32 +811,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy pTagHelperBuilder.Build() }; - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - var expectedMarkup = new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock(""), - factory.Markup(literal), - blockFactory.MarkupTagBlock(""), - BlockFactory.HtmlCommentBlock(factory, f => new SyntaxTreeNode[] { - f.Markup(part1).Accepts(AcceptedCharactersInternal.WhiteSpace), - new ExpressionBlock( - f.CodeTransition(), - f.Code(part2) - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)) }))); - // Act & Assert - EvaluateData( - descriptors, - expectedOutput, - expectedMarkup, - Array.Empty()); + EvaluateData(descriptors, document); } [Fact] - public void Rewrite_UnderstandsNullTagNameWithAllowedChildrenForCatchAll() + public void UnderstandsNullTagNameWithAllowedChildrenForCatchAll() { // Arrange var documentContent = "

            "; @@ -1360,21 +830,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) .Build(), }; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("p", - BlockFactory.MarkupTagBlock(""; @@ -1388,25 +850,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) .Build(), }; - var expectedOutput = new MarkupBlock( - new MarkupTagHelperBlock("th:p", - BlockFactory.MarkupTagBlock(""; - var expectedOutput = new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.StartTagOnly)); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") @@ -1418,22 +871,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); + EvaluateData(descriptors, documentContent); } [Fact] - public void Rewrite_CreatesErrorForWithoutEndTagTagStructureForEndTags() + public void CreatesErrorForWithoutEndTagTagStructureForEndTags() { // Arrange - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var expectedError = RazorDiagnosticFactory.CreateParsing_TagHelperMustNotHaveAnEndTag( - new SourceSpan(filePath: null, absoluteIndex: 2, lineIndex: 0, characterIndex: 2, length: 5), - "input", - "InputTagHelper", - TagStructure.WithoutEndTag); var documentContent = ""; - var expectedOutput = new MarkupBlock(blockFactory.MarkupTagBlock("")); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") @@ -1445,19 +890,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new[] { expectedError }); + EvaluateData(descriptors, documentContent); } [Fact] - public void Rewrite_CreatesErrorForInconsistentTagStructures() + public void CreatesErrorForInconsistentTagStructures() { // Arrange - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var expectedError = RazorDiagnosticFactory.CreateTagHelper_InconsistentTagStructure( - new SourceSpan(absoluteIndex: 0, lineIndex: 0, characterIndex: 0, length: 7), "InputTagHelper1", "InputTagHelper2", "input"); var documentContent = ""; - var expectedOutput = new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.StartTagOnly)); var descriptors = new TagHelperDescriptor[] { TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") @@ -1475,2872 +915,960 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new[] { expectedError }); + EvaluateData(descriptors, documentContent); } - public static TheoryData RequiredAttributeData + public static TagHelperDescriptor[] RequiredAttribute_Descriptors = new TagHelperDescriptor[] { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var dateTimeNow = new Func(index => - new MarkupBlock( - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged( - string.Empty, - new SourceLocation(index, 0, index)), - new SourceLocation(index, 0, index)), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))))); + TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("p") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(), + TagHelperDescriptorBuilder.Create("divTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("div") + .RequireAttributeDescriptor(attribute => attribute.Name("class")) + .RequireAttributeDescriptor(attribute => attribute.Name("style"))) + .Build(), + TagHelperDescriptorBuilder.Create("catchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(attribute => attribute.Name("catchAll"))) + .Build() + }; - // documentContent, expectedOutput - return new TheoryData - { - { - "

            ", - new MarkupBlock(blockFactory.MarkupTagBlock("

            ")) - }, - { - "

            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("

            ")) - }, - { - "
            ", - new MarkupBlock(blockFactory.MarkupTagBlock("
            ")) - }, - { - "
            ", - new MarkupBlock( - blockFactory.MarkupTagBlock("
            "), - blockFactory.MarkupTagBlock("
            ")) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class", dateTimeNow(10)) - })) - }, - { - "

            words and spaces

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: factory.Markup("words and spaces"))) - }, - { - "

            words and spaces

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", dateTimeNow(10)) - }, - children: factory.Markup("words and spaces"))) - }, - { - "

            wordsandspaces

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new SyntaxTreeNode[] - { - factory.Markup("words"), - blockFactory.MarkupTagBlock(""), - factory.Markup("and"), - blockFactory.MarkupTagBlock(""), - factory.Markup("spaces") - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("catchAll", dateTimeNow(18)) - })) - }, - { - "words and spaces", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: factory.Markup("words and spaces"))) - }, - { - "words and spaces", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", dateTimeNow(18)) - }, - children: factory.Markup("words and spaces"))) - }, - { - "
            ", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" class=\"", 4, 0, 4), - suffix: new LocationTagged("\"", 15, 0, 15)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 12, 0, 12), - value: new LocationTagged("btn", 12, 0, 12))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(" />"))) - }, - { - "
            ", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("(" class=\"", 4, 0, 4), - suffix: new LocationTagged("\"", 15, 0, 15)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 12, 0, 12), - value: new LocationTagged("btn", 12, 0, 12))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - blockFactory.MarkupTagBlock("
            ")) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("notRequired", factory.Markup("a")), - new TagHelperAttributeNode("class", factory.Markup("btn")) - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("notRequired", dateTimeNow(16)), - new TagHelperAttributeNode("class", factory.Markup("btn")) - })) - }, - { - "

            words and spaces

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("notRequired", factory.Markup("a")), - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: factory.Markup("words and spaces"))) - }, - { - "
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("style", new MarkupBlock()), - new TagHelperAttributeNode("class", factory.Markup("btn")) - })) - }, - { - "
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("style", dateTimeNow(12)), - new TagHelperAttributeNode("class", factory.Markup("btn")) - })) - }, - { - "
            words and spaces
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - attributes: new List - { - new TagHelperAttributeNode("style", new MarkupBlock()), - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: factory.Markup("words and spaces"))) - }, - { - "
            words and spaces
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - attributes: new List - { - new TagHelperAttributeNode("style", dateTimeNow(12)), - new TagHelperAttributeNode("class", dateTimeNow(34)) - }, - children: factory.Markup("words and spaces"))) - }, - { - "
            wordsandspaces
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - attributes: new List - { - new TagHelperAttributeNode("style", new MarkupBlock()), - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new SyntaxTreeNode[] - { - factory.Markup("words"), - blockFactory.MarkupTagBlock(""), - factory.Markup("and"), - blockFactory.MarkupTagBlock(""), - factory.Markup("spaces") - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")), - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - })) - }, - { - "

            words and spaces

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")), - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: factory.Markup("words and spaces"))) - }, - { - "
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("style", new MarkupBlock()), - new TagHelperAttributeNode("class", factory.Markup("btn")), - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - })) - }, - { - "
            words and spaces
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - attributes: new List - { - new TagHelperAttributeNode("style", new MarkupBlock()), - new TagHelperAttributeNode("class", factory.Markup("btn")), - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: factory.Markup("words and spaces"))) - }, - { - "
            words and spaces
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - attributes: new List - { - new TagHelperAttributeNode("style", new MarkupBlock()), - new TagHelperAttributeNode("class", factory.Markup("btn")), - new TagHelperAttributeNode("catchAll", - new MarkupBlock( - new MarkupBlock( - factory.Markup("@").Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("hi"))), - }, - children: factory.Markup("words and spaces"))) - }, - { - "
            words and " + - "spaces
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - attributes: new List - { - new TagHelperAttributeNode("style", dateTimeNow(12)), - new TagHelperAttributeNode("class", dateTimeNow(34)), - new TagHelperAttributeNode("catchAll", dateTimeNow(59)) - }, - children: factory.Markup("words and spaces"))) - }, - { - "
            wordsandspaces
            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "div", - attributes: new List - { - new TagHelperAttributeNode("style", new MarkupBlock()), - new TagHelperAttributeNode("class", factory.Markup("btn")), - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new SyntaxTreeNode[] - { - factory.Markup("words"), - blockFactory.MarkupTagBlock(""), - factory.Markup("and"), - blockFactory.MarkupTagBlock(""), - factory.Markup("spaces") - })) - }, - }; - } - } - - [Theory] - [MemberData(nameof(RequiredAttributeData))] - public void Rewrite_RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly( - string documentContent, - object expectedOutput) + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1() { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("p") - .RequireAttributeDescriptor(attribute => attribute.Name("class"))) - .Build(), - TagHelperDescriptorBuilder.Create("divTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("div") - .RequireAttributeDescriptor(attribute => attribute.Name("class")) - .RequireAttributeDescriptor(attribute => attribute.Name("style"))) - .Build(), - TagHelperDescriptorBuilder.Create("catchAllTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("*") - .RequireAttributeDescriptor(attribute => attribute.Name("catchAll"))) - .Build() - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); - } - - public static TheoryData NestedRequiredAttributeData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var dateTimeNow = new MarkupBlock( - new MarkupBlock( - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)))); - - // documentContent, expectedOutput - return new TheoryData - { - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new[] - { - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("

            ") - })) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new SyntaxTreeNode[] - { - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new[] - { - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("
            "), - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new SyntaxTreeNode[] - { - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock("

            "), - })) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new[] - { - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("

            ") - }))) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new[] - { - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - }))) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new[] - { - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("

            ") - }))) - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new[] - { - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - }))) - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new[] - { - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("

            "), - new MarkupTagHelperBlock( - "p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: new[] - { - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("

            ") - }), - blockFactory.MarkupTagBlock("

            "), - blockFactory.MarkupTagBlock("

            "), - })) - }, - { - "" + - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new[] - { - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - new MarkupTagHelperBlock( - "strong", - attributes: new List - { - new TagHelperAttributeNode("catchAll", factory.Markup("hi")) - }, - children: new[] - { - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - }), - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""), - })) - }, - }; - } - } - - [Theory] - [MemberData(nameof(NestedRequiredAttributeData))] - public void Rewrite_NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly( - string documentContent, - object expectedOutput) - { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("p") - .RequireAttributeDescriptor(attribute => attribute.Name("class"))) - .Build(), - TagHelperDescriptorBuilder.Create("catchAllTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("*") - .RequireAttributeDescriptor(attribute => attribute.Name("catchAll"))) - .Build(), - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); - } - - public static TheoryData MalformedRequiredAttributeData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - " - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            - { - new TagHelperAttributeNode("notRequired", factory.Markup("hi")), - new TagHelperAttributeNode("class", factory.Markup("btn")) - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            "), - blockFactory.MarkupTagBlock(" - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 1), "p") - } - }, - { - "

            - { - new TagHelperAttributeNode("notRequired", factory.Markup("hi")), - new TagHelperAttributeNode("class", factory.Markup("btn")) - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(34, 0, 34), contentLength: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: blockFactory.MarkupTagBlock("

            "))), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - attributes: new List - { - new TagHelperAttributeNode("notRequired", factory.Markup("hi")), - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: blockFactory.MarkupTagBlock("

            "))), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - } - }, - { - "

            - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 1), "p") - } - }, - { - "

            - { - new TagHelperAttributeNode("notRequired", factory.Markup("hi")), - new TagHelperAttributeNode("class", factory.Markup("btn")) - })), - new[] - { - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( - new SourceSpan(new SourceLocation(34, 0, 34), contentLength: 1), "p") - } - }, - }; - } - } - - [Theory] - [MemberData(nameof(MalformedRequiredAttributeData))] - public void Rewrite_RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly( - string documentContent, - object expectedOutput, - object expectedErrors) - { - // Arrange - var descriptors = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => - rule - .RequireTagName("p") - .RequireAttributeDescriptor(attribute => attribute.Name("class"))) - .Build(), - }; - - // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); - } - - public static TheoryData PrefixedTagHelperBoundData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - var availableDescriptorsColon = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("mythTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("myth")) - .Build(), - TagHelperDescriptorBuilder.Create("mythTagHelper2", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("myth2")) - .BoundAttributeDescriptor(attribute => - attribute - .Name("bound") - .PropertyName("Bound") - .TypeName(typeof(bool).FullName)) - .Build() - }; - var availableDescriptorsCatchAll = new TagHelperDescriptor[] - { - TagHelperDescriptorBuilder.Create("mythTagHelper", "SomeAssembly") - .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) - .Build(), - }; - - // documentContent, expectedOutput, availableDescriptors - return new TheoryData> - { - { - "", - new MarkupBlock(blockFactory.MarkupTagBlock("")), - availableDescriptorsCatchAll - }, - { - "words and spaces", - new MarkupBlock( - blockFactory.MarkupTagBlock(""), - factory.Markup("words and spaces"), - blockFactory.MarkupTagBlock("")), - availableDescriptorsCatchAll - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("th:myth", tagMode: TagMode.SelfClosing)), - availableDescriptorsColon - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("th:myth")), - availableDescriptorsColon - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "th:myth", - blockFactory.MarkupTagBlock(""), - blockFactory.MarkupTagBlock(""))), - availableDescriptorsColon - }, - { - "", - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "th:myth />")), - availableDescriptorsColon - }, - { - "", - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "th:myth>"), - blockFactory.EscapedMarkupTagBlock("")), - availableDescriptorsColon - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "th:myth", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - })), - availableDescriptorsColon - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "th:myth2", - tagMode: TagMode.SelfClosing, - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - })), - availableDescriptorsColon - }, - { - "words and spaces", - new MarkupBlock( - new MarkupTagHelperBlock( - "th:myth", - attributes: new List - { - new TagHelperAttributeNode("class", factory.Markup("btn")) - }, - children: factory.Markup("words and spaces"))), - availableDescriptorsColon - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock( - "th:myth2", - tagMode: TagMode.SelfClosing, - attributes: new List - { - { - new TagHelperAttributeNode( - "bound", - new MarkupBlock( - new MarkupBlock( - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.AnyExceptNewline))))) - } - })), - availableDescriptorsColon - }, - }; - } - } - - [Theory] - [MemberData(nameof(PrefixedTagHelperBoundData))] - public void Rewrite_AllowsPrefixedTagHelpers( - string documentContent, - object expectedOutput, - object availableDescriptors) - { - // Act & Assert - EvaluateData( - (IEnumerable)availableDescriptors, - documentContent, - (MarkupBlock)expectedOutput, - expectedErrors: Enumerable.Empty(), - tagHelperPrefix: "th:"); - } - - public static TheoryData OptOut_WithAttributeTextTagData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - Func, MarkupBlock> buildStatementBlock = (insideBuilder) => - { - return new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - insideBuilder(), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()); - }; - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "@{}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 8, 0, 8), - suffix: new LocationTagged("\"", 19, 0, 19)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 0, 16), - value: new LocationTagged("btn", 16, 0, 16))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - factory.Markup("}")))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - RazorDiagnosticFactory.CreateParsing_MissingEndTag( - new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 5), "!text"), - } - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 8, 0, 8), - suffix: new LocationTagged("\"", 19, 0, 19)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 0, 16), - value: new LocationTagged("btn", 16, 0, 16))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{words with spaces}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 8, 0, 8), - suffix: new LocationTagged("\"", 19, 0, 19)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 0, 16), - value: new LocationTagged("btn", 16, 0, 16))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - factory.Markup("words with spaces"), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class='", 8, 0, 8), - suffix: new LocationTagged("'", 25, 0, 25)), - factory.Markup(" class='").With(SpanChunkGenerator.Null), - factory.Markup("btn1").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 0, 16), - value: new LocationTagged("btn1", 16, 0, 16))), - factory.Markup(" btn2").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", 20, 0, 20), - value: new LocationTagged("btn2", 21, 0, 21))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class2", - prefix: new LocationTagged(" class2=", 26, 0, 26), - suffix: new LocationTagged(string.Empty, 37, 0, 37)), - factory.Markup(" class2=").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 34, 0, 34), - value: new LocationTagged("btn", 34, 0, 34)))), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class='", 8, 0, 8), - suffix: new LocationTagged("'", 39, 0, 39)), - factory.Markup(" class='").With(SpanChunkGenerator.Null), - factory.Markup("btn1").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 0, 16), - value: new LocationTagged("btn1", 16, 0, 16))), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged(" ", 20, 0, 20), 21, 0, 21), - factory.Markup(" ").With(SpanChunkGenerator.Null), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - factory.Markup(" btn2").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", 34, 0, 34), - value: new LocationTagged("btn2", 35, 0, 35))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - }; - } - } - - public static TheoryData OptOut_WithBlockTextTagData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - RazorDiagnostic MissingEndTagError(string tagName) - { - return RazorDiagnosticFactory.CreateParsing_MissingEndTag( - new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: tagName.Length), tagName); - } - - Func, MarkupBlock> buildStatementBlock = (insideBuilder) => - { - return new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - insideBuilder(), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()); - }; - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "@{}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), - factory.Markup("}")))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - MissingEndTagError("!text"), - } - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new [] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(filePath: null, absoluteIndex: 4, lineIndex: 0, characterIndex: 4, length: 5), "!text"), - } - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{words and spaces}", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), - factory.Markup("words and spaces"), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), - blockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None))), - new [] - { - MissingEndTagError("!text"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 11, lineIndex: 0, characterIndex: 11, length: 4), "text") - } - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock(factory.MarkupTransition("")), - new MarkupTagBlock( - factory.Markup("").Accepts(AcceptedCharactersInternal.None)))), - new [] - { - MissingEndTagError("text"), - } - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), - new MarkupTagHelperBlock("text"), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock(factory.MarkupTransition("")), - new MarkupTagBlock( - factory.Markup("<").Accepts(AcceptedCharactersInternal.None), - factory.BangEscape(), - factory.Markup("text>").Accepts(AcceptedCharactersInternal.None)), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None), - factory.Markup("}")))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - MissingEndTagError("text"), - } - }, - { - "@{}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)), - new MarkupBlock( - blockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None)), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()), - new [] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(filePath: null, absoluteIndex: 19, lineIndex: 0, characterIndex: 19, length: 4), "text"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 19, lineIndex: 0, characterIndex: 19, length: 4), "text") - } - }, - }; - } - } - - [Theory] - [MemberData(nameof(OptOut_WithAttributeTextTagData))] - [MemberData(nameof(OptOut_WithBlockTextTagData))] - public void Rewrite_AllowsTagHelperElementOptForCompleteTextTagInCSharpBlock( - string documentContent, - object expectedOutput, - object expectedErrors) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "p", "text"); - } - - public static TheoryData OptOut_WithPartialTextTagData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - RazorDiagnostic UnfinishedTagError(string tagName, int length) - { - return RazorDiagnosticFactory.CreateParsing_UnfinishedTag( - new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: length), - tagName); - } - - Func, MarkupBlock> buildPartialStatementBlock = (insideBuilder) => - { - return new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - insideBuilder())); - }; - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "text}"))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!text}", 6), - } - }, - { - "@{ new MarkupBlock( - blockFactory.EscapedMarkupTagBlock( - "<", - "text /", - new MarkupBlock(factory.Markup("}"))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!text", 5), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=", 8, 0, 8), - suffix: new LocationTagged(string.Empty, 16, 0, 16)), - factory.Markup(" class=").With(SpanChunkGenerator.Null), - factory.Markup("}").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 15, 0, 15), - value: new LocationTagged("}", 15, 0, 15))))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!text", 5), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 8, 0, 8), - suffix: new LocationTagged(string.Empty, 20, 0, 20)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn}").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 0, 16), - value: new LocationTagged("btn}", 16, 0, 16))))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!text", 5), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 8, 0, 8), - suffix: new LocationTagged("\"", 19, 0, 19)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 0, 16), - value: new LocationTagged("btn", 16, 0, 16))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - new MarkupBlock(factory.Markup("}"))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!text", 5), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("text"), - - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 8, 0, 8), - suffix: new LocationTagged("\"", 19, 0, 19)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 16, 0, 16), - value: new LocationTagged("btn", 16, 0, 16))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(" /"), - new MarkupBlock(factory.Markup("}"))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!text", 5), - } - } - }; - } - } - - [Theory] - [MemberData(nameof(OptOut_WithPartialTextTagData))] - public void Rewrite_AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock( - string documentContent, - object expectedOutput, - object expectedErrors) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "text"); - } - - public static TheoryData OptOut_WithPartialData_CSharp - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - RazorDiagnostic UnfinishedTagError(string tagName) - { - return RazorDiagnosticFactory.CreateParsing_UnfinishedTag( - new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: tagName.Length), - tagName); - } - - Func, MarkupBlock> buildPartialStatementBlock = (insideBuilder) => - { - return new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - insideBuilder())); - }; - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "}"))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!}"), - } - }, - { - "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "p}"))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!p}"), - } - }, - { - "@{ new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p /", new MarkupBlock(factory.Markup("}"))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!p"), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=", 5, 0, 5), - suffix: new LocationTagged(string.Empty, 13, 0, 13)), - factory.Markup(" class=").With(SpanChunkGenerator.Null), - factory.Markup("}").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 12, 0, 12), - value: new LocationTagged("}", 12, 0, 12))))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!p"), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 5, 0, 5), - suffix: new LocationTagged(string.Empty, 17, 0, 17)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn}").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn}", 13, 0, 13))))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!p"), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 5, 0, 5), - suffix: new LocationTagged(string.Empty, 19, 0, 19)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn", 13, 0, 13))), - new MarkupBlock( - factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 16, 0, 16), new LocationTagged("@", 16, 0, 16))).Accepts(AcceptedCharactersInternal.None), - factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), - factory.Markup("}").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 18, 0, 18), - value: new LocationTagged("}", 18, 0, 18))))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!p"), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 5, 0, 5), - suffix: new LocationTagged("\"", 16, 0, 16)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn", 13, 0, 13))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - new MarkupBlock(factory.Markup("}"))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!p"), - } - }, - { - "@{ new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 5, 0, 5), - suffix: new LocationTagged("\"", 16, 0, 16)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn", 13, 0, 13))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(" /"), - new MarkupBlock( - factory.Markup("}"))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - UnfinishedTagError("!p"), - } - } - }; - } - } - - [Theory] - [MemberData(nameof(OptOut_WithPartialData_CSharp))] - public void Rewrite_AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock( - string documentContent, - object expectedOutput, - object expectedErrors) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); - } - - public static TheoryData OptOut_WithPartialData_HTML - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - // documentContent, expectedOutput - return new TheoryData - { - { - "(" class=", 3, 0, 3), - suffix: new LocationTagged(string.Empty, 10, 0, 10)), - factory.Markup(" class=").With(SpanChunkGenerator.Null)))) - }, - { - "(" class=\"", 3, 0, 3), - suffix: new LocationTagged(string.Empty, 14, 0, 14)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 11, 0, 11), - value: new LocationTagged("btn", 11, 0, 11)))))) - }, - { - "(" class=\"", 3, 0, 3), - suffix: new LocationTagged("\"", 14, 0, 14)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 11, 0, 11), - value: new LocationTagged("btn", 11, 0, 11))), - factory.Markup("\"").With(SpanChunkGenerator.Null)))) - }, - { - "(" class=\"", 3, 0, 3), - suffix: new LocationTagged("\"", 14, 0, 14)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 11, 0, 11), - value: new LocationTagged("btn", 11, 0, 11))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(" /"))) - } - }; - } - } - - [Theory] - [MemberData(nameof(OptOut_WithPartialData_HTML))] - public void Rewrite_AllowsTagHelperElementOptForIncompleteHTML( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorDiagnostic[0], "strong", "p"); - } - - public static TheoryData OptOut_WithBlockData_CSharp - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - RazorDiagnostic MissingEndTagError(string tagName, int index = 3) - { - return RazorDiagnosticFactory.CreateParsing_MissingEndTag( - new SourceSpan(filePath: null, absoluteIndex: index, lineIndex: 0, characterIndex: index, length: tagName.Length), tagName); - } - - Func, MarkupBlock> buildStatementBlock = (insideBuilder) => - { - return new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - insideBuilder(), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()); - }; - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "@{}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - factory.Markup("}")))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - MissingEndTagError("!p"), - } - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new [] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(filePath: null, absoluteIndex: 4, lineIndex: 0, characterIndex: 4, length: 2), "!p"), - } - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{words and spaces}", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - factory.Markup("words and spaces"), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{

            }", - buildStatementBlock( - () => new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - blockFactory.MarkupTagBlock("

            ", AcceptedCharactersInternal.None))), - new [] - { - MissingEndTagError("!p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 8, lineIndex: 0, characterIndex: 8, length: 1), "p") - } - }, - { - "@{

            }", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), - new [] - { - MissingEndTagError("p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 1), "p") - } - }, - { - "@{

            }", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), - new RazorDiagnostic[0] - }, - { - "@{

            }", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None), - factory.Markup("}"))))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - MissingEndTagError("p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 1), "p") - } - }, - { - "@{

            }", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)), - new MarkupBlock( - blockFactory.MarkupTagBlock("

            ", AcceptedCharactersInternal.None)), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()), - new [] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(filePath: null, absoluteIndex: 13, lineIndex: 0, characterIndex: 13, length: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 13, lineIndex: 0, characterIndex: 13, length: 1), "p") - } - }, - { - "@{}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagHelperBlock("strong", - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new MarkupBlock( - blockFactory.MarkupTagBlock("
            ", AcceptedCharactersInternal.None)), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()), - new [] - { - MissingEndTagError("strong"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 6), "strong"), - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 6), "strong"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 6), "strong") - } - }, - { - "@{}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagHelperBlock("strong")), - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()), - new RazorDiagnostic[0] - }, - { - "@{

            }", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong", - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), - blockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None)), - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()), - new [] - { - MissingEndTagError("p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 1), "p"), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 6), "strong"), - MissingEndTagError("!p", index: 24), - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 29, lineIndex: 0, characterIndex: 29, length: 6), "strong"), - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(filePath: null, absoluteIndex: 38, lineIndex: 0, characterIndex: 38, length: 2), "!p"), - } - }, - }; - } - } - - public static TheoryData OptOut_WithAttributeData_CSharp - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - Func, MarkupBlock> buildStatementBlock = (insideBuilder) => - { - return new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - insideBuilder(), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()); - }; - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "@{}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 5, 0, 5), - suffix: new LocationTagged("\"", 16, 0, 16)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn", 13, 0, 13))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - factory.Markup("}")))), - new [] - { - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), - RazorDiagnosticFactory.CreateParsing_MissingEndTag( - new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 2), "!p"), - } - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 5, 0, 5), - suffix: new LocationTagged("\"", 16, 0, 16)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn", 13, 0, 13))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{words with spaces}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 5, 0, 5), - suffix: new LocationTagged("\"", 16, 0, 16)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn", 13, 0, 13))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - factory.Markup("words with spaces"), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class='", 5, 0, 5), - suffix: new LocationTagged("'", 22, 0, 22)), - factory.Markup(" class='").With(SpanChunkGenerator.Null), - factory.Markup("btn1").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn1", 13, 0, 13))), - factory.Markup(" btn2").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", 17, 0, 17), - value: new LocationTagged("btn2", 18, 0, 18))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class2", - prefix: new LocationTagged(" class2=", 23, 0, 23), - suffix: new LocationTagged(string.Empty, 34, 0, 34)), - factory.Markup(" class2=").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 31, 0, 31), - value: new LocationTagged("btn", 31, 0, 31)))), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - { - "@{}", - buildStatementBlock( - () => new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class='", 5, 0, 5), - suffix: new LocationTagged("'", 36, 0, 36)), - factory.Markup(" class='").With(SpanChunkGenerator.Null), - factory.Markup("btn1").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 13, 0, 13), - value: new LocationTagged("btn1", 13, 0, 13))), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged(" ", 17, 0, 17), 18, 0, 18), - factory.Markup(" ").With(SpanChunkGenerator.Null), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - factory.Markup(" btn2").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", 31, 0, 31), - value: new LocationTagged("btn2", 32, 0, 32))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), - blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorDiagnostic[0] - }, - }; - } - } - - [Theory] - [MemberData(nameof(OptOut_WithBlockData_CSharp))] - [MemberData(nameof(OptOut_WithAttributeData_CSharp))] - public void Rewrite_AllowsTagHelperElementOptOutCSharp( - string documentContent, - object expectedOutput, - object expectedErrors) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); - } - - public static TheoryData OptOut_WithBlockData_HTML - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "", - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>")), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("")), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>"), - blockFactory.EscapedMarkupTagBlock("")), - new RazorDiagnostic[0] - }, - { - "words and spaces", - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>"), - factory.Markup("words and spaces"), - blockFactory.EscapedMarkupTagBlock("")), - new RazorDiagnostic[0] - }, - { - "

            ", - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>"), - blockFactory.MarkupTagBlock("

            ")), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock(""))), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.EscapedMarkupTagBlock("<", "p>"), - blockFactory.EscapedMarkupTagBlock(""))), - new RazorDiagnostic[0] - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - blockFactory.EscapedMarkupTagBlock("<", "p>"), - blockFactory.EscapedMarkupTagBlock(""))), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - { - "

            ", - new MarkupBlock( - blockFactory.EscapedMarkupTagBlock("<", "p>"), - blockFactory.EscapedMarkupTagBlock(""), - blockFactory.MarkupTagBlock("

            ")), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(11, 0, 11), contentLength: 1), "p") - } - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("strong", - blockFactory.EscapedMarkupTagBlock(""))), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagHelperBlock("strong"), - blockFactory.EscapedMarkupTagBlock("<", "p>"), - blockFactory.EscapedMarkupTagBlock("")), - new RazorDiagnostic[0] - }, - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("strong", - blockFactory.EscapedMarkupTagBlock(""), - blockFactory.EscapedMarkupTagBlock("<", "p>")), - blockFactory.EscapedMarkupTagBlock(""))), - new [] - { - RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") - } - }, - }; - } - } - - public static TheoryData OptOut_WithAttributeData_HTML - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - // documentContent, expectedOutput, expectedErrors - return new TheoryData - { - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 3, 0, 3), - suffix: new LocationTagged("\"", 14, 0, 14)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 11, 0, 11), - value: new LocationTagged("btn", 11, 0, 11))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">"))), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 3, 0, 3), - suffix: new LocationTagged("\"", 14, 0, 14)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 11, 0, 11), - value: new LocationTagged("btn", 11, 0, 11))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - blockFactory.EscapedMarkupTagBlock("")), - new RazorDiagnostic[0] - }, - { - "words and spaces", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class=\"", 3, 0, 3), - suffix: new LocationTagged("\"", 14, 0, 14)), - factory.Markup(" class=\"").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 11, 0, 11), - value: new LocationTagged("btn", 11, 0, 11))), - factory.Markup("\"").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - factory.Markup("words and spaces"), - blockFactory.EscapedMarkupTagBlock("")), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class='", 3, 0, 3), - suffix: new LocationTagged("'", 20, 0, 20)), - factory.Markup(" class='").With(SpanChunkGenerator.Null), - factory.Markup("btn1").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 11, 0, 11), - value: new LocationTagged("btn1", 11, 0, 11))), - factory.Markup(" btn2").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", 15, 0, 15), - value: new LocationTagged("btn2", 16, 0, 16))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class2", - prefix: new LocationTagged(" class2=", 21, 0, 21), - suffix: new LocationTagged(string.Empty, 32, 0, 32)), - factory.Markup(" class2=").With(SpanChunkGenerator.Null), - factory.Markup("btn").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 29, 0, 29), - value: new LocationTagged("btn", 29, 0, 29)))), - factory.Markup(">")), - blockFactory.EscapedMarkupTagBlock("")), - new RazorDiagnostic[0] - }, - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("<"), - factory.BangEscape(), - factory.Markup("p"), - new MarkupBlock( - new AttributeBlockChunkGenerator( - name: "class", - prefix: new LocationTagged(" class='", 3, 0, 3), - suffix: new LocationTagged("'", 34, 0, 34)), - factory.Markup(" class='").With(SpanChunkGenerator.Null), - factory.Markup("btn1").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(string.Empty, 11, 0, 11), - value: new LocationTagged("btn1", 11, 0, 11))), - new MarkupBlock( - new DynamicAttributeBlockChunkGenerator( - new LocationTagged(" ", 15, 0, 15), 16, 0, 16), - factory.Markup(" ").With(SpanChunkGenerator.Null), - new ExpressionBlock( - factory.CodeTransition(), - factory.Code("DateTime.Now") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace))), - factory.Markup(" btn2").With( - new LiteralAttributeChunkGenerator( - prefix: new LocationTagged(" ", 29, 0, 29), - value: new LocationTagged("btn2", 30, 0, 30))), - factory.Markup("'").With(SpanChunkGenerator.Null)), - factory.Markup(">")), - blockFactory.EscapedMarkupTagBlock("")), - new RazorDiagnostic[0] - }, - }; - } - } - - [Theory] - [MemberData(nameof(OptOut_WithBlockData_HTML))] - [MemberData(nameof(OptOut_WithAttributeData_HTML))] - public void Rewrite_AllowsTagHelperElementOptOutHTML( - string documentContent, - object expectedOutput, - object expectedErrors) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); - } - - public static IEnumerable TextTagsBlockData - { - get - { - var factory = new SpanFactory(); - - // Should re-write text tags that aren't in C# blocks - yield return new object[] - { - "Hello World", - new MarkupBlock( - new MarkupTagHelperBlock("text", - factory.Markup("Hello World"))) - }; - yield return new object[] - { - "@{Hello World}", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - factory.MarkupTransition("")), - factory.Markup("Hello World").Accepts(AcceptedCharactersInternal.None), - new MarkupTagBlock( - factory.MarkupTransition(""))), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()) - }; - yield return new object[] - { - "@{

            Hello World

            }", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - factory.MarkupTransition("")), - new MarkupTagHelperBlock("p", - factory.Markup("Hello World")), - new MarkupTagBlock( - factory.MarkupTransition(""))), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()) - }; - yield return new object[] - { - "@{

            Hello World

            }", - new MarkupBlock( - factory.EmptyHtml(), - new StatementBlock( - factory.CodeTransition(), - factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("text", - factory.Markup("Hello World")))), - factory.EmptyCSharp().AsStatement(), - factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - factory.EmptyHtml()) - }; - } - } - - [Theory] - [MemberData(nameof(TextTagsBlockData))] - public void TagHelperParseTreeRewriter_DoesNotRewriteTextTagTransitionTagHelpers( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p", "text"); - } - - public static IEnumerable SpecialTagsBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - blockFactory.HtmlCommentBlock (" Hello World "), - new MarkupTagBlock( - factory.Markup(""))) - }; - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - BlockFactory.HtmlCommentBlock(factory, f=> new SyntaxTreeNode[]{ - f.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace), - new ExpressionBlock( - f.CodeTransition(), - f.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - factory.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace) }), - new MarkupTagBlock( - factory.Markup(""))) - }; - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - factory.Markup(""), - new MarkupTagBlock( - factory.Markup(""))) - }; - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - factory.Markup(""), - new MarkupTagBlock( - factory.Markup(""))) - }; - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - factory.Markup(""), - new MarkupTagBlock( - factory.Markup(""))) - }; - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - factory.Markup(""), - new MarkupTagBlock( - factory.Markup(""))) - }; - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - factory.Markup(""), - new MarkupTagBlock( - factory.Markup(""))) - }; - yield return new object[] - { - "", - new MarkupBlock( - new MarkupTagBlock( - factory.Markup("")), - factory.Markup(""), - new MarkupTagBlock( - factory.Markup(""))) - }; - } - } - - [Theory] - [MemberData(nameof(SpecialTagsBlockData))] - public void TagHelperParseTreeRewriter_DoesNotRewriteSpecialTagTagHelpers( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "!--", "?xml", "![CDATA[", "!DOCTYPE"); - } - - public static IEnumerable NestedBlockData - { - get - { - var factory = new SpanFactory(); - var blockFactory = new BlockFactory(factory); - - yield return new object[] - { - "

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("div"))) - }; - yield return new object[] - { - "

            Hello World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hello World "), - new MarkupTagHelperBlock("div"))) - }; - yield return new object[] - { - "

            Hel

            lo

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hel"), - new MarkupTagHelperBlock("p", - factory.Markup("lo"))), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - new MarkupTagHelperBlock("div", - factory.Markup("World")))) - }; - yield return new object[] - { - "

            Hello

            World

            ", - new MarkupBlock( - new MarkupTagHelperBlock("p", - factory.Markup("Hel"), - blockFactory.MarkupTagBlock(""), - factory.Markup("lo"), - blockFactory.MarkupTagBlock("")), - factory.Markup(" "), - new MarkupTagHelperBlock("p", - blockFactory.MarkupTagBlock(""), - factory.Markup("World"), - blockFactory.MarkupTagBlock(""))) - }; - } - } - - [Theory] - [MemberData(nameof(NestedBlockData))] - public void TagHelperParseTreeRewriter_RewritesNestedTagHelperTagBlocks( - string documentContent, - object expectedOutput) - { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p", "div"); + EvaluateData(RequiredAttribute_Descriptors, "

            "); } [Fact] - public void Rewrite_HandlesMalformedNestedNonTagHelperTags_Correctly() + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2() { - var documentContent = "

            @{
            }"; - var expectedOutput = new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("
            ")), - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - new MarkupBlock( - new MarkupTagBlock( - Factory.Markup("
            ").Accepts(AcceptedCharactersInternal.None))), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.EmptyHtml()); - var expectedErrors = new[] - { - RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( - new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 3), "div"), - }; + EvaluateData(RequiredAttribute_Descriptors, "

            "); + } - RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors); + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3() + { + EvaluateData(RequiredAttribute_Descriptors, "
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4() + { + EvaluateData(RequiredAttribute_Descriptors, "
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5() + { + EvaluateData(RequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6() + { + EvaluateData(RequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7() + { + EvaluateData(RequiredAttribute_Descriptors, "

            words and spaces

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8() + { + EvaluateData(RequiredAttribute_Descriptors, "

            words and spaces

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9() + { + EvaluateData(RequiredAttribute_Descriptors, "

            wordsandspaces

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10() + { + EvaluateData(RequiredAttribute_Descriptors, ""); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11() + { + EvaluateData(RequiredAttribute_Descriptors, ""); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12() + { + EvaluateData(RequiredAttribute_Descriptors, "words and spaces"); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13() + { + EvaluateData(RequiredAttribute_Descriptors, "words and spaces"); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly14() + { + EvaluateData(RequiredAttribute_Descriptors, "
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly15() + { + EvaluateData(RequiredAttribute_Descriptors, "
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16() + { + EvaluateData(RequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17() + { + EvaluateData(RequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18() + { + EvaluateData(RequiredAttribute_Descriptors, "

            words and spaces

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19() + { + EvaluateData(RequiredAttribute_Descriptors, "
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20() + { + EvaluateData(RequiredAttribute_Descriptors, "
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21() + { + EvaluateData(RequiredAttribute_Descriptors, "
            words and spaces
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22() + { + EvaluateData(RequiredAttribute_Descriptors, "
            words and spaces
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23() + { + EvaluateData(RequiredAttribute_Descriptors, "
            wordsandspaces
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24() + { + EvaluateData(RequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25() + { + EvaluateData(RequiredAttribute_Descriptors, "

            words and spaces

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26() + { + EvaluateData(RequiredAttribute_Descriptors, "
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27() + { + EvaluateData(RequiredAttribute_Descriptors, "
            words and spaces
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28() + { + EvaluateData(RequiredAttribute_Descriptors, "
            words and spaces
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29() + { + EvaluateData(RequiredAttribute_Descriptors, "
            words and spaces
            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30() + { + EvaluateData(RequiredAttribute_Descriptors, "
            wordsandspaces
            "); + } + + public static TagHelperDescriptor[] NestedRequiredAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("p") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(), + TagHelperDescriptorBuilder.Create("catchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(attribute => attribute.Name("catchAll"))) + .Build(), + }; + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2() + { + EvaluateData(NestedRequiredAttribute_Descriptors, ""); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8() + { + EvaluateData(NestedRequiredAttribute_Descriptors, ""); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10() + { + EvaluateData(NestedRequiredAttribute_Descriptors, ""); + } + + public static TagHelperDescriptor[] MalformedRequiredAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("p") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(), + }; + + [Fact] + public void RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly1() + { + EvaluateData(MalformedRequiredAttribute_Descriptors, ""); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8() + { + EvaluateData(MalformedRequiredAttribute_Descriptors, "

            "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9() + { + EvaluateData(MalformedRequiredAttribute_Descriptors, "

            rule.RequireTagName("myth")) + .Build(), + TagHelperDescriptorBuilder.Create("mythTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("myth2")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound") + .PropertyName("Bound") + .TypeName(typeof(bool).FullName)) + .Build() + }; + + public static TagHelperDescriptor[] PrefixedTagHelperCatchAll_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("mythTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) + .Build(), + }; + + [Fact] + public void AllowsPrefixedTagHelpers1() + { + EvaluateData(PrefixedTagHelperCatchAll_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers2() + { + EvaluateData(PrefixedTagHelperCatchAll_Descriptors, "words and spaces", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers3() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers4() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers5() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers6() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers7() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers8() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers9() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers10() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "words and spaces", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers11() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag2() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag3() + { + RunParseTreeRewriterTest("@{words with spaces}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag4() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag5() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag3() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag4() + { + RunParseTreeRewriterTest("@{words and spaces}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData2() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData3() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData4() + { + RunParseTreeRewriterTest("@{words and spaces}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData5() + { + RunParseTreeRewriterTest("@{

            }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData6() + { + RunParseTreeRewriterTest("@{

            }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData7() + { + RunParseTreeRewriterTest("@{

            }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData8() + { + RunParseTreeRewriterTest("@{

            }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData9() + { + RunParseTreeRewriterTest("@{

            }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData10() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData11() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData12() + { + RunParseTreeRewriterTest("@{

            }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData1() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData2() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData3() + { + RunParseTreeRewriterTest("@{words with spaces}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData4() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData5() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData1() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData2() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData3() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData4() + { + RunParseTreeRewriterTest("words and spaces", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData5() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData6() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData7() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData8() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData9() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData10() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData11() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData12() + { + RunParseTreeRewriterTest("

            ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData1() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData2() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData3() + { + RunParseTreeRewriterTest("words and spaces", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData4() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData5() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void DoesNotRewriteTextTagTransitionTagHelpers1() + { + RunParseTreeRewriterTest("Hello World", "p", "text"); + } + + [Fact] + public void DoesNotRewriteTextTagTransitionTagHelpers2() + { + RunParseTreeRewriterTest("@{Hello World}", "p", "text"); + } + + [Fact] + public void DoesNotRewriteTextTagTransitionTagHelpers3() + { + RunParseTreeRewriterTest("@{

            Hello World

            }", "p", "text"); + } + + [Fact] + public void DoesNotRewriteTextTagTransitionTagHelpers4() + { + RunParseTreeRewriterTest("@{

            Hello World

            }", "p", "text"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers1() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers2() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers3() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers4() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers5() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers6() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers7() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers8() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void RewritesNestedTagHelperTagBlocks1() + { + RunParseTreeRewriterTest("

            ", "p", "div"); + } + + [Fact] + public void RewritesNestedTagHelperTagBlocks2() + { + RunParseTreeRewriterTest("

            Hello World

            ", "p", "div"); + } + + [Fact] + public void RewritesNestedTagHelperTagBlocks3() + { + RunParseTreeRewriterTest("

            Hel

            lo

            World

            ", "p", "div"); + } + + [Fact] + public void RewritesNestedTagHelperTagBlocks4() + { + RunParseTreeRewriterTest("

            Hello

            World

            ", "p", "div"); + } + + [Fact] + public void HandlesMalformedNestedNonTagHelperTags_Correctly() + { + RunParseTreeRewriterTest("
            @{
            }"); } } } \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs index 8271cee1a9..a6db68b3c7 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; using System.Linq; @@ -8,6 +9,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class TagHelperRewritingTestBase : CsHtmlMarkupParserTestBase { + internal void RunParseTreeRewriterTest(string documentContent, params string[] tagNames) + { + RunParseTreeRewriterTest(documentContent, expectedOutput: null, tagNames: tagNames); + } + internal void RunParseTreeRewriterTest( string documentContent, MarkupBlock expectedOutput, @@ -46,6 +52,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return descriptors; } + internal void EvaluateData( + IEnumerable descriptors, + string documentContent, + string tagHelperPrefix = null, + RazorParserFeatureFlags featureFlags = null) + { + EvaluateData(descriptors, documentContent, null, Array.Empty(), tagHelperPrefix, featureFlags); + } + internal void EvaluateData( IEnumerable descriptors, string documentContent, @@ -68,8 +83,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .OrderBy(error => error.Span.AbsoluteIndex) .ToList(); - EvaluateRazorErrors(actualErrors, expectedErrors.ToList()); - EvaluateParseTree(actualTree, expectedOutput); + BaselineTest(actualTree, filePath: null, verifySyntaxTree: false, actualErrors.ToArray()); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs index aa9ea560cc..23a1df23dc 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs @@ -57,51 +57,51 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } [Fact] - public void LookaheadUntil_PassesThePreviousSymbolsInTheSameOrder() + public void LookaheadUntil_PassesThePreviousTokensInTheSameOrder() { // Arrange var tokenizer = CreateContentTokenizer("asdf--fvd--<"); // Act var i = 3; - IEnumerable previousSymbols = null; - var symbolFound = tokenizer.LookaheadUntil((s, p) => + IEnumerable previousTokens = null; + var tokenFound = tokenizer.LookaheadUntil((s, p) => { - previousSymbols = p; + previousTokens = p; return --i == 0; }); // Assert - Assert.Equal(4, previousSymbols.Count()); + Assert.Equal(4, previousTokens.Count()); // For the very first element, there will be no previous items, so null is expected var orderIndex = 0; - Assert.Null(previousSymbols.ElementAt(orderIndex++)); - Assert.Equal(new HtmlSymbol("asdf", HtmlSymbolType.Text), previousSymbols.ElementAt(orderIndex++)); - Assert.Equal(new HtmlSymbol("--", HtmlSymbolType.DoubleHyphen), previousSymbols.ElementAt(orderIndex++)); - Assert.Equal(new HtmlSymbol("fvd", HtmlSymbolType.Text), previousSymbols.ElementAt(orderIndex++)); + Assert.Null(previousTokens.ElementAt(orderIndex++)); + Assert.Equal(new HtmlToken("asdf", HtmlTokenType.Text), previousTokens.ElementAt(orderIndex++)); + Assert.Equal(new HtmlToken("--", HtmlTokenType.DoubleHyphen), previousTokens.ElementAt(orderIndex++)); + Assert.Equal(new HtmlToken("fvd", HtmlTokenType.Text), previousTokens.ElementAt(orderIndex++)); } [Fact] - public void LookaheadUntil_ReturnsFalseAfterIteratingOverAllSymbolsIfConditionIsNotMet() + public void LookaheadUntil_ReturnsFalseAfterIteratingOverAllTokensIfConditionIsNotMet() { // Arrange var tokenizer = CreateContentTokenizer("asdf--fvd"); // Act - var symbols = new Stack(); - var symbolFound = tokenizer.LookaheadUntil((s, p) => + var tokens = new Stack(); + var tokenFound = tokenizer.LookaheadUntil((s, p) => { - symbols.Push(s); + tokens.Push(s); return false; }); // Assert - Assert.False(symbolFound); - Assert.Equal(3, symbols.Count); - Assert.Equal(new HtmlSymbol("fvd", HtmlSymbolType.Text), symbols.Pop()); - Assert.Equal(new HtmlSymbol("--", HtmlSymbolType.DoubleHyphen), symbols.Pop()); - Assert.Equal(new HtmlSymbol("asdf", HtmlSymbolType.Text), symbols.Pop()); + Assert.False(tokenFound); + Assert.Equal(3, tokens.Count); + Assert.Equal(new HtmlToken("fvd", HtmlTokenType.Text), tokens.Pop()); + Assert.Equal(new HtmlToken("--", HtmlTokenType.DoubleHyphen), tokens.Pop()); + Assert.Equal(new HtmlToken("asdf", HtmlTokenType.Text), tokens.Pop()); } [Fact] @@ -111,18 +111,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var tokenizer = CreateContentTokenizer("asdf--fvd"); // Act - var symbols = new Stack(); - var symbolFound = tokenizer.LookaheadUntil((s, p) => + var tokens = new Stack(); + var tokenFound = tokenizer.LookaheadUntil((s, p) => { - symbols.Push(s); - return s.Type == HtmlSymbolType.DoubleHyphen; + tokens.Push(s); + return s.Type == HtmlTokenType.DoubleHyphen; }); // Assert - Assert.True(symbolFound); - Assert.Equal(2, symbols.Count); - Assert.Equal(new HtmlSymbol("--", HtmlSymbolType.DoubleHyphen), symbols.Pop()); - Assert.Equal(new HtmlSymbol("asdf", HtmlSymbolType.Text), symbols.Pop()); + Assert.True(tokenFound); + Assert.Equal(2, tokens.Count); + Assert.Equal(new HtmlToken("--", HtmlTokenType.DoubleHyphen), tokens.Pop()); + Assert.Equal(new HtmlToken("asdf", HtmlTokenType.Text), tokens.Pop()); } private static TestTokenizerBackedParser CreateContentTokenizer(string content) @@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return tokenizer; } - private class ExposedTokenizer : Tokenizer + private class ExposedTokenizer : Tokenizer { public ExposedTokenizer(string input) : base(new SeekableTextReader(input, filePath: null)) @@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - public override CSharpSymbolType RazorCommentStarType + public override CSharpTokenType RazorCommentStarType { get { @@ -158,7 +158,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - public override CSharpSymbolType RazorCommentTransitionType + public override CSharpTokenType RazorCommentTransitionType { get { @@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - public override CSharpSymbolType RazorCommentType + public override CSharpTokenType RazorCommentType { get { @@ -182,9 +182,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - protected override CSharpSymbol CreateSymbol( + protected override CSharpToken CreateToken( string content, - CSharpSymbolType type, + CSharpTokenType type, IReadOnlyList errors) { throw new NotImplementedException(); @@ -196,9 +196,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - private class TestTokenizerBackedParser : TokenizerBackedParser + private class TestTokenizerBackedParser : TokenizerBackedParser { - internal TestTokenizerBackedParser(LanguageCharacteristics language, ParserContext context) : base(language, context) + internal TestTokenizerBackedParser(LanguageCharacteristics language, ParserContext context) : base(language, context) { } @@ -207,12 +207,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy throw new NotImplementedException(); } - protected override bool SymbolTypeEquals(HtmlSymbolType x, HtmlSymbolType y) + protected override bool TokenTypeEquals(HtmlTokenType x, HtmlTokenType y) { throw new NotImplementedException(); } - internal new bool LookaheadUntil(Func, bool> condition) + internal new bool LookaheadUntil(Func, bool> condition) { return base.LookaheadUntil(condition); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerTestBase.cs index bcd2eff90b..307ccad3a7 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerTestBase.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy internal void TestTokenizer(string input, params TSymbol[] expectedSymbols) where TSymbolType : struct - where TSymbol : SymbolBase + where TSymbol : TokenBase { // Arrange var success = true; @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var tokenizer = (Tokenizer)CreateTokenizer(source); var counter = 0; TSymbol current = null; - while ((current = tokenizer.NextSymbol()) != null) + while ((current = tokenizer.NextToken()) != null) { if (counter >= expectedSymbols.Length) { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/WhiteSpaceRewriterTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/WhiteSpaceRewriterTest.cs index 96531135c3..856172a104 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/WhiteSpaceRewriterTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/WhiteSpaceRewriterTest.cs @@ -1,40 +1,29 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.Legacy { - public class WhiteSpaceRewriterTest + public class WhiteSpaceRewriterTest : CsHtmlMarkupParserTestBase { [Fact] - public void Rewrite_Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block() + public void Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block() { // Arrange - var factory = new SpanFactory(); - var start = new MarkupBlock( - factory.Markup("test"), - new ExpressionBlock( - factory.Code(" ").AsExpression(), - factory.CodeTransition(SyntaxConstants.TransitionString), - factory.Code("foo").AsExpression()), - factory.Markup("test")); + var parsed = ParseDocument( + RazorLanguageVersion.Latest, + "test @foo test", + Array.Empty()); + var rewriter = new WhiteSpaceRewriter(); // Act - var rewritten = rewriter.Rewrite(start); - factory.Reset(); + var rewritten = rewriter.Rewrite(parsed.Root); // Assert - ParserTestBase.EvaluateParseTree( - rewritten, - new MarkupBlock( - factory.Markup("test"), - factory.Markup(" "), - new ExpressionBlock( - factory.CodeTransition(SyntaxConstants.TransitionString), - factory.Code("foo").AsExpression()), - factory.Markup("test"))); + BaselineTest(parsed); } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj index 68d1243acf..57a0000191 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj @@ -1,8 +1,7 @@ - + $(DeveloperBuildTestTfms) - $(TargetFrameworks) $(TargetFrameworks);net46 $(DefaultItemExcludes);TestFiles\**\* $(DefineConstants);GENERATE_BASELINES diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs index 41f899512b..ceccb7f057 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs @@ -56,6 +56,22 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Same(expected, actual); } + [Fact] + public void GetAndSetTagHelpers_ReturnsTagHelpers() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = new[] { TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build() }; + codeDocument.SetTagHelpers(expected); + + // Act + var actual = codeDocument.GetTagHelpers(); + + // Assert + Assert.Same(expected, actual); + } + [Fact] public void GetIRDocument_ReturnsIRDocument() { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/SourceChangeTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/SourceChangeTest.cs index f3f1b9320e..470b69720a 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/SourceChangeTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/SourceChangeTest.cs @@ -104,8 +104,8 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var builder = new SpanBuilder(new SourceLocation(0, 0, 0)); - builder.Accept(new RawTextSymbol(new SourceLocation(0, 0, 0), "Hello, ")); - builder.Accept(new RawTextSymbol(new SourceLocation(7, 0, 7), "World")); + builder.Accept(new RawTextToken(new SourceLocation(0, 0, 0), "Hello, ")); + builder.Accept(new RawTextToken(new SourceLocation(7, 0, 7), "World")); var span = new Span(builder); @@ -123,8 +123,8 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var builder = new SpanBuilder(new SourceLocation(13, 0, 0)); - builder.Accept(new RawTextSymbol(new SourceLocation(13, 0, 13), "Hello, ")); - builder.Accept(new RawTextSymbol(new SourceLocation(20, 0, 20), "World")); + builder.Accept(new RawTextToken(new SourceLocation(13, 0, 13), "Hello, ")); + builder.Accept(new RawTextToken(new SourceLocation(20, 0, 20), "World")); var span = new Span(builder); @@ -142,8 +142,8 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var builder = new SpanBuilder(new SourceLocation(13, 0, 0)); - builder.Accept(new RawTextSymbol(new SourceLocation(13, 0, 13), "Hello, ")); - builder.Accept(new RawTextSymbol(new SourceLocation(20, 0, 20), "World")); + builder.Accept(new RawTextToken(new SourceLocation(13, 0, 13), "Hello, ")); + builder.Accept(new RawTextToken(new SourceLocation(20, 0, 20), "World")); var span = new Span(builder); @@ -161,8 +161,8 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var builder = new SpanBuilder(new SourceLocation(13, 0, 0)); - builder.Accept(new RawTextSymbol(new SourceLocation(13, 0, 13), "Hello, ")); - builder.Accept(new RawTextSymbol(new SourceLocation(20, 0, 20), "World")); + builder.Accept(new RawTextToken(new SourceLocation(13, 0, 13), "Hello, ")); + builder.Accept(new RawTextToken(new SourceLocation(20, 0, 20), "World")); var span = new Span(builder); @@ -180,8 +180,8 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var builder = new SpanBuilder(new SourceLocation(13, 0, 0)); - builder.Accept(new RawTextSymbol(new SourceLocation(13, 0, 13), "Hello, ")); - builder.Accept(new RawTextSymbol(new SourceLocation(20, 0, 20), "World")); + builder.Accept(new RawTextToken(new SourceLocation(13, 0, 13), "Hello, ")); + builder.Accept(new RawTextToken(new SourceLocation(20, 0, 20), "World")); var span = new Span(builder); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.cs index 6baa07bacf..72db8cb380 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.cs @@ -30,13 +30,21 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + +#line default +#line hidden #line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" __o = await Foo(); #line default #line hidden - +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + +#line default +#line hidden #line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" __o = await; @@ -67,13 +75,21 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + +#line default +#line hidden #line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" __o = await Foo(boolValue: false); #line default #line hidden - +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + +#line default +#line hidden #line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" __o = await ("wrrronggg"); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.mappings.txt index 739f6092e2..f16bc10af3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.mappings.txt @@ -15,67 +15,67 @@ Generated Location: (1080:28,39 [14] ) Source Location: (371:12,46 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) | | -Generated Location: (1185:32,58 [1] ) +Generated Location: (1255:33,46 [1] ) | | Source Location: (376:12,51 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) |await Foo()| -Generated Location: (1321:34,51 [11] ) +Generated Location: (1422:38,51 [11] ) |await Foo()| Source Location: (391:12,66 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) | | -Generated Location: (1444:38,78 [1] ) +Generated Location: (1615:43,66 [1] ) | | Source Location: (448:13,49 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) |await| -Generated Location: (1578:40,49 [5] ) +Generated Location: (1780:48,49 [5] ) |await| Source Location: (578:18,42 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) |await Foo(1, 2)| -Generated Location: (1741:45,42 [15] ) +Generated Location: (1943:53,42 [15] ) |await Foo(1, 2)| Source Location: (650:19,51 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) |await Foo.Bar(1, 2)| -Generated Location: (1923:50,51 [19] ) +Generated Location: (2125:58,51 [19] ) |await Foo.Bar(1, 2)| Source Location: (716:20,41 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) |await Foo("bob", true)| -Generated Location: (2099:55,41 [22] ) +Generated Location: (2301:63,41 [22] ) |await Foo("bob", true)| Source Location: (787:21,42 [39] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) | await Foo(something, hello: "world"); | -Generated Location: (2279:60,42 [39] ) +Generated Location: (2481:68,42 [39] ) | await Foo(something, hello: "world"); | Source Location: (884:22,51 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) | await Foo.Bar(1, 2) | -Generated Location: (2484:65,51 [21] ) +Generated Location: (2686:73,51 [21] ) | await Foo.Bar(1, 2) | Source Location: (961:23,49 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) | | -Generated Location: (2599:69,61 [1] ) +Generated Location: (2871:78,49 [1] ) | | Source Location: (966:23,54 [27] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) |await Foo(boolValue: false)| -Generated Location: (2738:71,54 [27] ) +Generated Location: (3041:83,54 [27] ) |await Foo(boolValue: false)| Source Location: (997:23,85 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) | | -Generated Location: (2896:75,97 [1] ) +Generated Location: (3269:88,85 [1] ) | | Source Location: (1057:24,52 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) |await ("wrrronggg")| -Generated Location: (3033:77,52 [19] ) +Generated Location: (3437:93,52 [19] ) |await ("wrrronggg")| Source Location: (12:0,12 [76] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) @@ -85,7 +85,7 @@ Source Location: (12:0,12 [76] TestFiles/IntegrationTests/CodeGenerationIntegrat return "Bar"; } | -Generated Location: (3228:84,12 [76] ) +Generated Location: (3632:100,12 [76] ) | public async Task Foo() { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml deleted file mode 100644 index bf4d925aea..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml +++ /dev/null @@ -1 +0,0 @@ -

            Hi there!

            diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.codegen.cs deleted file mode 100644 index b6226ce38a..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.codegen.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -#pragma warning disable 1591 -namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles -{ - #line hidden -#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml" -using System.Globalization; - -#line default -#line hidden -#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml" -using System.ComponentModel; - -#line default -#line hidden -#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports1.cshtml" -using System.Text; - -#line default -#line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_DesignTime : Hello - { - #pragma warning disable 219 - private void __RazorDirectiveTokenHelpers__() { - } - #pragma warning restore 219 - #pragma warning disable 0414 - private static System.Object __o = null; - #pragma warning restore 0414 - #pragma warning disable 1998 - public async System.Threading.Tasks.Task ExecuteAsync() - { - } - #pragma warning restore 1998 - } -} -#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.ir.txt deleted file mode 100644 index fab53bac03..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.ir.txt +++ /dev/null @@ -1,20 +0,0 @@ -Document - - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles - UsingDirective - (1:0,1 [26] BasicImports_Imports0.cshtml) - System.Globalization - UsingDirective - (30:1,1 [27] BasicImports_Imports0.cshtml) - System.ComponentModel - UsingDirective - (23:1,1 [18] BasicImports_Imports1.cshtml) - System.Text - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_DesignTime - Hello - - DesignTimeDirective - - DirectiveToken - (69:2,10 [5] BasicImports_Imports0.cshtml) - Hello - CSharpCode - - IntermediateToken - - CSharp - #pragma warning disable 0414 - CSharpCode - - IntermediateToken - - CSharp - private static System.Object __o = null; - CSharpCode - - IntermediateToken - - CSharp - #pragma warning restore 0414 - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync - HtmlContent - (0:0,0 [18] BasicImports.cshtml) - IntermediateToken - (0:0,0 [3] BasicImports.cshtml) - Html -

            - IntermediateToken - (3:0,3 [9] BasicImports.cshtml) - Html - Hi there! - IntermediateToken - (12:0,12 [4] BasicImports.cshtml) - Html -

            - IntermediateToken - (16:0,16 [2] BasicImports.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml deleted file mode 100644 index b71f569138..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml +++ /dev/null @@ -1,5 +0,0 @@ -@using System.Globalization -@using System.ComponentModel -@inherits Hello -@("And also this") -

            This will get ignored

            diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports1.cshtml b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports1.cshtml deleted file mode 100644 index bac4a38695..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports1.cshtml +++ /dev/null @@ -1,2 +0,0 @@ -@section ignored { } -@using System.Text; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs deleted file mode 100644 index ed71849611..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs +++ /dev/null @@ -1,36 +0,0 @@ -#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d5e5d28c0c504a7b0c5207a5230a5b7327ce5e09" -// -#pragma warning disable 1591 -[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml")] -namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles -{ - #line hidden -#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml" -using System.Globalization; - -#line default -#line hidden -#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml" -using System.ComponentModel; - -#line default -#line hidden -#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports1.cshtml" -using System.Text; - -#line default -#line hidden - [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d5e5d28c0c504a7b0c5207a5230a5b7327ce5e09", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml")] - [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"39c22940acc420eb6d46b6ff85ef6d5a2ab35fa1", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml")] - [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ede697b6fb90aac312d589ae96a93289cdeb506f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports1.cshtml")] - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_Runtime : Hello - { - #pragma warning disable 1998 - public async System.Threading.Tasks.Task ExecuteAsync() - { - WriteLiteral("

            Hi there!

            \r\n"); - } - #pragma warning restore 1998 - } -} -#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt deleted file mode 100644 index 014ca50451..0000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt +++ /dev/null @@ -1,16 +0,0 @@ -Document - - RazorCompiledItemAttribute - - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles - UsingDirective - (1:0,1 [28] BasicImports_Imports0.cshtml) - System.Globalization - UsingDirective - (30:1,1 [29] BasicImports_Imports0.cshtml) - System.ComponentModel - UsingDirective - (23:1,1 [20] BasicImports_Imports1.cshtml) - System.Text - RazorSourceChecksumAttribute - - RazorSourceChecksumAttribute - - RazorSourceChecksumAttribute - - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_Runtime - Hello - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync - HtmlContent - (0:0,0 [18] BasicImports.cshtml) - IntermediateToken - (0:0,0 [3] BasicImports.cshtml) - Html -

            - IntermediateToken - (3:0,3 [9] BasicImports.cshtml) - Html - Hi there! - IntermediateToken - (12:0,12 [4] BasicImports.cshtml) - Html -

            - IntermediateToken - (16:0,16 [2] BasicImports.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.cs index 8160ceea8d..b608d96706 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.cs @@ -15,7 +15,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { - +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml" + + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.mappings.txt index 91017073c6..35a86fcf82 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (2:0,2 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml) || -Generated Location: (651:17,14 [0] ) +Generated Location: (729:18,2 [0] ) || diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.cs index 5df492cc3c..cf0042aff3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.cs @@ -32,8 +32,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.mappings.txt index 5279d46d18..3810200a52 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.mappings.txt @@ -20,7 +20,7 @@ Generated Location: (1123:30,38 [3] ) Source Location: (80:2,40 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml) | | -Generated Location: (1221:34,61 [2] ) +Generated Location: (1309:35,49 [2] ) | | diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.codegen.cs index 37b7b26436..e2ff79fdb5 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.codegen.cs @@ -73,8 +73,12 @@ __TestNamespace_PTagHelper.Age = @@(1+2); #line default #line hidden __TestNamespace_PTagHelper = CreateTagHelper(); - +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + + +#line default +#line hidden __TestNamespace_InputTagHelper = CreateTagHelper(); __TestNamespace_InputTagHelper2 = CreateTagHelper(); #line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" @@ -84,8 +88,12 @@ __TestNamespace_PTagHelper.Age = @@(1+2); #line hidden __TestNamespace_InputTagHelper.Type = string.Empty; __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; - +#line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + + +#line default +#line hidden __TestNamespace_InputTagHelper = CreateTagHelper(); __TestNamespace_InputTagHelper2 = CreateTagHelper(); #line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.mappings.txt index 35f9f98fe8..5a3c14354f 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.mappings.txt @@ -81,213 +81,213 @@ Generated Location: (3077:70,63 [4] ) Source Location: (523:16,74 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | | -Generated Location: (3296:75,86 [18] ) +Generated Location: (3378:76,74 [18] ) | | Source Location: (556:17,31 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |true ? "checkbox" : "anything"| -Generated Location: (3649:80,31 [30] ) +Generated Location: (3762:84,31 [30] ) |true ? "checkbox" : "anything"| Source Location: (591:17,66 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | | -Generated Location: (3945:86,78 [18] ) +Generated Location: (4140:91,66 [18] ) | | Source Location: (623:18,30 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |if(true) { | -Generated Location: (4297:91,30 [11] ) +Generated Location: (4523:99,30 [11] ) |if(true) { | Source Location: (655:18,62 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | } else { | -Generated Location: (4497:96,62 [10] ) +Generated Location: (4723:104,62 [10] ) | } else { | Source Location: (686:18,93 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | }| -Generated Location: (4727:101,93 [2] ) +Generated Location: (4953:109,93 [2] ) | }| Source Location: (690:18,97 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | }| -Generated Location: (5107:108,97 [15] ) +Generated Location: (5333:116,97 [15] ) | }| Source Location: (212:8,32 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |DateTime.Now| -Generated Location: (5375:115,32 [12] ) +Generated Location: (5601:123,32 [12] ) |DateTime.Now| Source Location: (832:22,14 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | var @object = false;| -Generated Location: (5529:120,14 [21] ) +Generated Location: (5755:128,14 [21] ) | var @object = false;| Source Location: (885:23,29 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |(| -Generated Location: (5927:127,42 [1] ) +Generated Location: (6153:135,42 [1] ) |(| Source Location: (886:23,30 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |@object| -Generated Location: (5928:127,43 [7] ) +Generated Location: (6154:135,43 [7] ) |@object| Source Location: (893:23,37 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |)| -Generated Location: (5935:127,50 [1] ) +Generated Location: (6161:135,50 [1] ) |)| Source Location: (760:21,39 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |DateTimeOffset.Now.Year| -Generated Location: (6197:133,38 [23] ) +Generated Location: (6423:141,38 [23] ) |DateTimeOffset.Now.Year| Source Location: (783:21,62 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | -| -Generated Location: (6220:133,61 [2] ) +Generated Location: (6446:141,61 [2] ) | -| Source Location: (785:21,64 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | 1970| -Generated Location: (6222:133,63 [5] ) +Generated Location: (6448:141,63 [5] ) | 1970| Source Location: (1025:26,61 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |(| -Generated Location: (6623:140,60 [1] ) +Generated Location: (6849:148,60 [1] ) |(| Source Location: (1026:26,62 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |DateTimeOffset.Now.Year > 2014| -Generated Location: (6624:140,61 [30] ) +Generated Location: (6850:148,61 [30] ) |DateTimeOffset.Now.Year > 2014| Source Location: (1056:26,92 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |)| -Generated Location: (6654:140,91 [1] ) +Generated Location: (6880:148,91 [1] ) |)| Source Location: (928:25,16 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |-1970| -Generated Location: (6911:146,33 [5] ) +Generated Location: (7137:154,33 [5] ) |-1970| Source Location: (933:25,21 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | +| -Generated Location: (6916:146,38 [2] ) +Generated Location: (7142:154,38 [2] ) | +| Source Location: (935:25,23 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | | -Generated Location: (6918:146,40 [1] ) +Generated Location: (7144:154,40 [1] ) | | Source Location: (936:25,24 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |@| -Generated Location: (6919:146,41 [1] ) +Generated Location: (7145:154,41 [1] ) |@| Source Location: (937:25,25 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |DateTimeOffset.Now.Year| -Generated Location: (6920:146,42 [23] ) +Generated Location: (7146:154,42 [23] ) |DateTimeOffset.Now.Year| Source Location: (1155:29,28 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |DateTimeOffset.Now.Year > 2014| -Generated Location: (7321:153,42 [30] ) +Generated Location: (7547:161,42 [30] ) |DateTimeOffset.Now.Year > 2014| Source Location: (1093:28,16 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |DateTimeOffset.Now.Year - 1970| -Generated Location: (7607:159,33 [30] ) +Generated Location: (7833:167,33 [30] ) |DateTimeOffset.Now.Year - 1970| Source Location: (1283:32,28 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | | -Generated Location: (8015:166,42 [3] ) +Generated Location: (8241:174,42 [3] ) | | Source Location: (1286:32,31 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |@| -Generated Location: (8018:166,45 [1] ) +Generated Location: (8244:174,45 [1] ) |@| Source Location: (1287:32,32 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |(| -Generated Location: (8019:166,46 [1] ) +Generated Location: (8245:174,46 [1] ) |(| Source Location: (1288:32,33 [27] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | DateTimeOffset.Now.Year | -Generated Location: (8020:166,47 [27] ) +Generated Location: (8246:174,47 [27] ) | DateTimeOffset.Now.Year | Source Location: (1315:32,60 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |)| -Generated Location: (8047:166,74 [1] ) +Generated Location: (8273:174,74 [1] ) |)| Source Location: (1316:32,61 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | >| -Generated Location: (8048:166,75 [2] ) +Generated Location: (8274:174,75 [2] ) | >| Source Location: (1318:32,63 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | 2014| -Generated Location: (8050:166,77 [5] ) +Generated Location: (8276:174,77 [5] ) | 2014| Source Location: (1323:32,68 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | | -Generated Location: (8055:166,82 [3] ) +Generated Location: (8281:174,82 [3] ) | | Source Location: (1220:31,17 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |(| -Generated Location: (8314:172,33 [1] ) +Generated Location: (8540:180,33 [1] ) |(| Source Location: (1221:31,18 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |"My age is this long.".Length| -Generated Location: (8315:172,34 [29] ) +Generated Location: (8541:180,34 [29] ) |"My age is this long.".Length| Source Location: (1250:31,47 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |)| -Generated Location: (8344:172,63 [1] ) +Generated Location: (8570:180,63 [1] ) |)| Source Location: (1355:34,9 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |someMethod(| -Generated Location: (8482:177,9 [11] ) +Generated Location: (8708:185,9 [11] ) |someMethod(| Source Location: (1410:34,64 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |checked| -Generated Location: (8900:181,63 [7] ) +Generated Location: (9126:189,63 [7] ) |checked| Source Location: (1375:34,29 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |123| -Generated Location: (9155:187,33 [3] ) +Generated Location: (9381:195,33 [3] ) |123| Source Location: (1424:34,78 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) |)| -Generated Location: (9196:192,1 [1] ) +Generated Location: (9422:200,1 [1] ) |)| Source Location: (1437:35,10 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) | }| -Generated Location: (9335:197,10 [3] ) +Generated Location: (9561:205,10 [3] ) | }| diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.cs index d603d44201..f03a621125 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.cs @@ -23,43 +23,67 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden #line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" __o = cls; #line default #line hidden - +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden #line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" __o = cls; #line default #line hidden - +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden #line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" __o = cls; #line default #line hidden - +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden #line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" __o = ch; #line default #line hidden - +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden #line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" __o = ch; #line default #line hidden - +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden #line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" if(cls != null) { @@ -75,26 +99,45 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + - + +#line default +#line hidden +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden #line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" __o = Url.Content("~/Scripts/jquery-1.6.2.min.js"); #line default #line hidden - +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden #line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" __o = Url.Content("~/Scripts/modernizr-2.0.6-development-only.js"); #line default #line hidden - +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + - +#line default +#line hidden +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.mappings.txt index 6824785c85..49fdb956d9 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.mappings.txt @@ -12,127 +12,127 @@ Generated Location: (743:18,2 [48] ) Source Location: (66:3,20 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (856:25,32 [6] ) +Generated Location: (941:26,20 [6] ) | | Source Location: (83:4,15 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |cls| -Generated Location: (976:28,15 [3] ) +Generated Location: (1092:32,15 [3] ) |cls| Source Location: (90:4,22 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (1047:32,34 [6] ) +Generated Location: (1248:37,22 [6] ) | | Source Location: (111:5,19 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |cls| -Generated Location: (1171:35,19 [3] ) +Generated Location: (1403:43,19 [3] ) |cls| Source Location: (118:5,26 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (1246:39,38 [6] ) +Generated Location: (1563:48,26 [6] ) | | Source Location: (135:6,15 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |cls| -Generated Location: (1366:42,15 [3] ) +Generated Location: (1714:54,15 [3] ) |cls| Source Location: (146:6,26 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (1441:46,38 [6] ) +Generated Location: (1874:59,26 [6] ) | | Source Location: (185:7,37 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |ch| -Generated Location: (1583:49,37 [2] ) +Generated Location: (2047:65,37 [2] ) |ch| Source Location: (191:7,43 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (1674:53,55 [6] ) +Generated Location: (2223:70,43 [6] ) | | Source Location: (234:8,41 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |ch| -Generated Location: (1820:56,41 [2] ) +Generated Location: (2400:76,41 [2] ) |ch| Source Location: (240:8,47 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (1915:60,59 [6] ) +Generated Location: (2580:81,47 [6] ) | | Source Location: (257:9,15 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |if(cls != null) { | -Generated Location: (2036:63,15 [18] ) +Generated Location: (2732:87,15 [18] ) |if(cls != null) { | Source Location: (276:9,34 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |cls| -Generated Location: (2219:68,34 [3] ) +Generated Location: (2915:92,34 [3] ) |cls| Source Location: (279:9,37 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | }| -Generated Location: (2391:73,37 [2] ) +Generated Location: (3087:97,37 [2] ) | }| Source Location: (285:9,43 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (2481:77,55 [6] ) +Generated Location: (3263:102,43 [6] ) | | Source Location: (309:10,22 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (2523:79,34 [6] ) +Generated Location: (3422:108,22 [6] ) | | Source Location: (329:11,18 [44] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |Url.Content("~/Scripts/jquery-1.6.2.min.js")| -Generated Location: (2647:82,18 [44] ) +Generated Location: (3577:114,18 [44] ) |Url.Content("~/Scripts/jquery-1.6.2.min.js")| Source Location: (407:11,96 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (2833:86,108 [6] ) +Generated Location: (3849:119,96 [6] ) | | Source Location: (427:12,18 [60] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) |Url.Content("~/Scripts/modernizr-2.0.6-development-only.js")| -Generated Location: (2957:89,18 [60] ) +Generated Location: (4004:125,18 [60] ) |Url.Content("~/Scripts/modernizr-2.0.6-development-only.js")| Source Location: (521:12,112 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (3175:93,124 [6] ) +Generated Location: (4308:130,112 [6] ) | | Source Location: (638:13,115 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) | | -Generated Location: (3310:95,127 [2] ) +Generated Location: (4560:136,115 [2] ) | | diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.cs index 6927c99f10..c0c4004a57 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.cs @@ -15,7 +15,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { - +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml" + + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.mappings.txt index be686c9435..7e37fe345d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (20:2,2 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml) || -Generated Location: (651:17,14 [0] ) +Generated Location: (729:18,2 [0] ) || diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.cs index 2f466f8132..b288005187 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.cs @@ -15,15 +15,22 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { - +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" + + +#line default +#line hidden #line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" __o = ; #line default #line hidden - +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.mappings.txt index 8fde4acc1b..37e96b1d2d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.mappings.txt @@ -1,19 +1,19 @@ Source Location: (2:0,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml) | | -Generated Location: (666:17,14 [6] ) +Generated Location: (759:18,2 [6] ) | | Source Location: (9:1,5 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml) || -Generated Location: (785:20,6 [0] ) +Generated Location: (909:24,6 [0] ) || Source Location: (9:1,5 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml) | | -Generated Location: (836:24,17 [2] ) +Generated Location: (1053:29,5 [2] ) | | diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.cs index ac6848c885..36ff974c05 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.cs @@ -22,9 +22,12 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line hidden } #pragma warning restore 1998 - +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" + +#line default +#line hidden #line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" Random _rand = new Random(); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.mappings.txt index 91a2fbde86..262325f0cb 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.mappings.txt @@ -7,7 +7,7 @@ Source Location: (12:0,12 [4] TestFiles/IntegrationTests/CodeGenerationIntegrati | | -Generated Location: (867:24,20 [4] ) +Generated Location: (949:25,12 [4] ) | | @@ -19,7 +19,7 @@ Source Location: (33:4,12 [104] TestFiles/IntegrationTests/CodeGenerationIntegra return _rand.Next(); } | -Generated Location: (975:28,12 [104] ) +Generated Location: (1086:31,12 [104] ) | Random _rand = new Random(); private int RandomInt() { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.cs index 77d9135c5a..1b8baa0064 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.cs @@ -15,8 +15,12 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { - +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml" + + +#line default +#line hidden #line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml" @Da diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.mappings.txt index e56c1f5b1f..80b903cc64 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.mappings.txt @@ -1,14 +1,14 @@ Source Location: (2:0,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml) | | -Generated Location: (654:17,14 [6] ) +Generated Location: (735:18,2 [6] ) | | Source Location: (9:1,5 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml) |@Da | -Generated Location: (760:20,5 [5] ) +Generated Location: (872:24,5 [5] ) |@Da | diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs index 03f5c03321..9e76084ccd 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -63,6 +63,11 @@ global::System.Object __typeHelper = "; #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index b01ced2ed2..1eb0531be3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,15 +1,15 @@ TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ1018: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ1018: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1036: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ1018: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ1018: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1036: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt index f21273aeb2..ba9fae429d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -82,3 +82,5 @@ Document - HtmlContent - (339:23,9 [3] IncompleteDirectives.cshtml) IntermediateToken - (339:23,9 [3] IncompleteDirectives.cshtml) - Html - {\n MalformedDirective - (342:24,0 [12] IncompleteDirectives.cshtml) - functions + CSharpCode - (354:24,12 [0] IncompleteDirectives.cshtml) + IntermediateToken - (354:24,12 [0] IncompleteDirectives.cshtml) - CSharp - diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt index b5f9ac8df5..41510ddf4d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -63,3 +63,8 @@ Source Location: (326:21,9 [0] TestFiles/IntegrationTests/CodeGenerationIntegrat Generated Location: (1463:55,0 [0] ) || +Source Location: (354:24,12 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1879:66,12 [0] ) +|| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt index b01ced2ed2..1eb0531be3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -1,15 +1,15 @@ TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ1018: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ1018: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1036: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ1018: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ1018: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1036: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt index ecffead8c5..5a369ff69c 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -52,3 +52,5 @@ Document - HtmlContent - (339:23,9 [3] IncompleteDirectives.cshtml) IntermediateToken - (339:23,9 [3] IncompleteDirectives.cshtml) - Html - {\n MalformedDirective - (342:24,0 [12] IncompleteDirectives.cshtml) - functions + CSharpCode - (354:24,12 [0] IncompleteDirectives.cshtml) + IntermediateToken - (354:24,12 [0] IncompleteDirectives.cshtml) - CSharp - diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.cs index 04f1daad49..d9c39802a7 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.cs @@ -31,9 +31,16 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - - +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + +#line default +#line hidden +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + + +#line default +#line hidden #line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" while(i <= 10) { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.mappings.txt index 4165c88fa9..2a622f4808 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.mappings.txt @@ -16,33 +16,33 @@ Generated Location: (1003:28,25 [7] ) Source Location: (68:4,0 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) | | -Generated Location: (1043:33,0 [4] ) +Generated Location: (1131:34,0 [4] ) | | Source Location: (91:4,23 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) | | -Generated Location: (1096:34,35 [2] ) +Generated Location: (1279:39,23 [2] ) | | Source Location: (99:7,1 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) |while(i <= 10) { | -Generated Location: (1189:37,1 [22] ) +Generated Location: (1401:44,1 [22] ) |while(i <= 10) { | Source Location: (142:8,25 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) |i| -Generated Location: (1357:43,25 [1] ) +Generated Location: (1569:50,25 [1] ) |i| Source Location: (148:8,31 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) | i += 1; }| -Generated Location: (1511:48,31 [16] ) +Generated Location: (1723:55,31 [16] ) | i += 1; }| @@ -50,14 +50,14 @@ Generated Location: (1511:48,31 [16] ) Source Location: (169:12,1 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) |if(i == 11) { | -Generated Location: (1650:55,1 [19] ) +Generated Location: (1862:62,1 [19] ) |if(i == 11) { | Source Location: (213:13,29 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) | }| -Generated Location: (1820:61,29 [3] ) +Generated Location: (2032:68,29 [3] ) | }| @@ -65,7 +65,7 @@ Source Location: (221:16,1 [35] TestFiles/IntegrationTests/CodeGenerationIntegra |switch(i) { case 11: | -Generated Location: (1946:67,1 [35] ) +Generated Location: (2158:74,1 [35] ) |switch(i) { case 11: | @@ -75,7 +75,7 @@ Source Location: (292:18,44 [40] TestFiles/IntegrationTests/CodeGenerationIntegr break; default: | -Generated Location: (2147:74,44 [40] ) +Generated Location: (2359:81,44 [40] ) | break; default: @@ -85,7 +85,7 @@ Source Location: (361:21,37 [19] TestFiles/IntegrationTests/CodeGenerationIntegr | break; }| -Generated Location: (2346:82,37 [19] ) +Generated Location: (2558:89,37 [19] ) | break; }| @@ -93,26 +93,26 @@ Generated Location: (2346:82,37 [19] ) Source Location: (385:25,1 [39] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) |for(int j = 1; j <= 10; j += 2) { | -Generated Location: (2488:89,1 [39] ) +Generated Location: (2700:96,1 [39] ) |for(int j = 1; j <= 10; j += 2) { | Source Location: (451:26,31 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) |j| -Generated Location: (2680:95,31 [1] ) +Generated Location: (2892:102,31 [1] ) |j| Source Location: (457:26,37 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) | }| -Generated Location: (2841:100,37 [3] ) +Generated Location: (3053:107,37 [3] ) | }| Source Location: (465:29,1 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) |try { | -Generated Location: (2967:106,1 [11] ) +Generated Location: (3179:113,1 [11] ) |try { | @@ -120,34 +120,34 @@ Source Location: (511:30,39 [31] TestFiles/IntegrationTests/CodeGenerationIntegr | } catch(Exception ex) { | -Generated Location: (3139:112,39 [31] ) +Generated Location: (3351:119,39 [31] ) | } catch(Exception ex) { | Source Location: (573:32,35 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) |ex.Message| -Generated Location: (3327:119,35 [10] ) +Generated Location: (3539:126,35 [10] ) |ex.Message| Source Location: (588:32,50 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) | }| -Generated Location: (3510:124,50 [3] ) +Generated Location: (3722:131,50 [3] ) | }| Source Location: (596:35,1 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) |lock(new object()) { | -Generated Location: (3636:130,1 [26] ) +Generated Location: (3848:137,1 [26] ) |lock(new object()) { | Source Location: (669:36,51 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) | }| -Generated Location: (3835:136,51 [3] ) +Generated Location: (4047:143,51 [3] ) | }| diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.cs index ad9d4de7e5..763d09cac3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.cs @@ -15,8 +15,12 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { - +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + + +#line default +#line hidden #line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" foreach (var result in (dynamic)Url) { @@ -35,8 +39,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.mappings.txt index a3a8e67f53..d07593ae24 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.mappings.txt @@ -1,7 +1,7 @@ Source Location: (2:0,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) | | -Generated Location: (649:17,14 [6] ) +Generated Location: (725:18,2 [6] ) | | @@ -9,27 +9,27 @@ Source Location: (9:1,5 [53] TestFiles/IntegrationTests/CodeGenerationIntegratio |foreach (var result in (dynamic)Url) { | -Generated Location: (750:20,5 [53] ) +Generated Location: (857:24,5 [53] ) |foreach (var result in (dynamic)Url) { | Source Location: (82:4,13 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) |result.SomeValue| -Generated Location: (937:27,13 [16] ) +Generated Location: (1044:31,13 [16] ) |result.SomeValue| Source Location: (115:5,14 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) | }| -Generated Location: (1089:32,14 [7] ) +Generated Location: (1196:36,14 [7] ) | }| Source Location: (122:6,5 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) | | -Generated Location: (1146:37,17 [2] ) +Generated Location: (1329:42,5 [2] ) | | diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.cs index a800b83828..9e127a7992 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.cs @@ -115,7 +115,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + + +#line default +#line hidden #line 34 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" __o = i; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.mappings.txt index 349b695abd..e0965c9452 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.mappings.txt @@ -124,25 +124,25 @@ Generated Location: (3201:111,50 [7] ) Source Location: (556:32,34 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) || -Generated Location: (3285:117,46 [0] ) +Generated Location: (3363:118,34 [0] ) || Source Location: (571:33,13 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) |i| -Generated Location: (3390:119,13 [1] ) +Generated Location: (3499:123,13 [1] ) |i| Source Location: (581:35,1 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) |lock(new object()) { | -Generated Location: (3516:124,1 [26] ) +Generated Location: (3625:128,1 [26] ) |lock(new object()) { | Source Location: (654:36,51 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) | }| -Generated Location: (3716:130,51 [3] ) +Generated Location: (3825:134,51 [3] ) | }| diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.cs index a380c6449e..ce0052fdd8 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.cs @@ -15,36 +15,55 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { - +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + +#line default +#line hidden #line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" __o = ViewBag?.Data; #line default #line hidden - +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + +#line default +#line hidden #line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" __o = ViewBag.IntIndexer?[0]; #line default #line hidden - +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + +#line default +#line hidden #line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" __o = ViewBag.StrIndexer?["key"]; #line default #line hidden - +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + +#line default +#line hidden #line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" __o = ViewBag?.Method(Value?[23]?.More)?["key"]; #line default #line hidden - +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + +#line default +#line hidden #line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" __o = ViewBag?.Data; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.mappings.txt index 0f7b77a97c..1811d93f1f 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.mappings.txt @@ -1,75 +1,75 @@ Source Location: (2:0,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) | | -Generated Location: (663:17,14 [6] ) +Generated Location: (753:18,2 [6] ) | | Source Location: (9:1,5 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) |ViewBag?.Data| -Generated Location: (779:20,6 [13] ) +Generated Location: (900:24,6 [13] ) |ViewBag?.Data| Source Location: (22:1,18 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) | | -Generated Location: (856:24,30 [6] ) +Generated Location: (1067:29,18 [6] ) | | Source Location: (29:2,5 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) |ViewBag.IntIndexer?[0]| -Generated Location: (972:27,6 [22] ) +Generated Location: (1214:35,6 [22] ) |ViewBag.IntIndexer?[0]| Source Location: (51:2,27 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) | | -Generated Location: (1067:31,39 [6] ) +Generated Location: (1399:40,27 [6] ) | | Source Location: (58:3,5 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) |ViewBag.StrIndexer?["key"]| -Generated Location: (1183:34,6 [26] ) +Generated Location: (1546:46,6 [26] ) |ViewBag.StrIndexer?["key"]| Source Location: (84:3,31 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) | | -Generated Location: (1286:38,43 [6] ) +Generated Location: (1739:51,31 [6] ) | | Source Location: (91:4,5 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) |ViewBag?.Method(Value?[23]?.More)?["key"]| -Generated Location: (1402:41,6 [41] ) +Generated Location: (1886:57,6 [41] ) |ViewBag?.Method(Value?[23]?.More)?["key"]| Source Location: (132:4,46 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) | | -Generated Location: (1535:45,58 [2] ) +Generated Location: (2109:62,46 [2] ) | | Source Location: (140:7,1 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) |ViewBag?.Data| -Generated Location: (1647:48,6 [13] ) +Generated Location: (2250:67,6 [13] ) |ViewBag?.Data| Source Location: (156:8,1 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) |ViewBag.IntIndexer?[0]| -Generated Location: (1802:53,6 [22] ) +Generated Location: (2405:72,6 [22] ) |ViewBag.IntIndexer?[0]| Source Location: (181:9,1 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) |ViewBag.StrIndexer?["key"]| -Generated Location: (1967:58,6 [26] ) +Generated Location: (2570:77,6 [26] ) |ViewBag.StrIndexer?["key"]| Source Location: (210:10,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) |ViewBag?.Method(Value?[23]?.More)?["key"]| -Generated Location: (2136:63,6 [41] ) +Generated Location: (2739:82,6 [41] ) |ViewBag?.Method(Value?[23]?.More)?["key"]| diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.cs index cbf0fbd1b9..40f50f1e8b 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.cs @@ -20,9 +20,16 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #line default #line hidden - +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" + - +#line default +#line hidden +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" + + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.mappings.txt index 0e07728ecc..96e7303e2b 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.mappings.txt @@ -8,12 +8,12 @@ Generated Location: (716:18,1 [14] ) Source Location: (38:3,7 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml) | | -Generated Location: (780:22,19 [2] ) +Generated Location: (852:23,7 [2] ) | | Source Location: (47:4,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml) || -Generated Location: (803:24,19 [0] ) +Generated Location: (976:28,7 [0] ) || diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.cs index a21ac99866..de5d6f8ac6 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.cs @@ -15,8 +15,12 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { - +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + + +#line default +#line hidden #line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" Exception foo = diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.mappings.txt index 3278641353..3357a58b2f 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.mappings.txt @@ -1,14 +1,14 @@ Source Location: (81:3,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) | | -Generated Location: (650:17,14 [6] ) +Generated Location: (727:18,2 [6] ) | | Source Location: (122:4,39 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) | Exception foo = | -Generated Location: (786:20,39 [22] ) +Generated Location: (894:24,39 [22] ) | Exception foo = | @@ -18,7 +18,7 @@ Source Location: (173:5,49 [58] TestFiles/IntegrationTests/CodeGenerationIntegra throw foo; } | -Generated Location: (979:26,49 [58] ) +Generated Location: (1087:30,49 [58] ) | null; if(foo != null) { throw foo; @@ -27,21 +27,21 @@ Generated Location: (979:26,49 [58] ) Source Location: (238:11,2 [24] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) | var bar = "@* bar *@"; | -Generated Location: (1160:34,2 [24] ) +Generated Location: (1268:38,2 [24] ) | var bar = "@* bar *@"; | Source Location: (310:12,45 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) |bar| -Generated Location: (1352:39,45 [3] ) +Generated Location: (1460:43,45 [3] ) |bar| Source Location: (323:14,2 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) |a| -Generated Location: (1485:44,6 [1] ) +Generated Location: (1593:48,6 [1] ) |a| Source Location: (328:14,7 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) |b| -Generated Location: (1486:44,7 [1] ) +Generated Location: (1594:48,7 [1] ) |b| diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs index e71dc97f63..f1b77b164c 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs @@ -40,8 +40,11 @@ __o = foo(""); #line default #line hidden - +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + +#line default +#line hidden #line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" Func bar = @@ -67,8 +70,11 @@ __o = bar("myclass"); #line default #line hidden - +#line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + +#line default +#line hidden #line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = Repeat(10, item => new Template(async(__razor_template_writer) => { #line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt index 3c35d4c99a..6f779cac97 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt @@ -25,125 +25,125 @@ Generated Location: (1343:38,6 [7] ) Source Location: (364:12,12 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) | | -Generated Location: (1408:42,24 [2] ) +Generated Location: (1482:43,12 [2] ) | | Source Location: (373:15,2 [35] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) | Func bar = | -Generated Location: (1500:45,2 [35] ) +Generated Location: (1603:48,2 [35] ) | Func bar = | Source Location: (420:16,44 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (1768:52,44 [4] ) +Generated Location: (1871:55,44 [4] ) |item| Source Location: (435:16,59 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |; | -Generated Location: (1981:59,59 [7] ) +Generated Location: (2084:62,59 [7] ) |; | Source Location: (443:17,5 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |bar("myclass")| -Generated Location: (2113:65,6 [14] ) +Generated Location: (2216:68,6 [14] ) |bar("myclass")| Source Location: (457:17,19 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) | | -Generated Location: (2192:69,31 [2] ) +Generated Location: (2369:73,19 [2] ) | | Source Location: (472:21,2 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (2288:72,6 [11] ) +Generated Location: (2494:78,6 [11] ) |Repeat(10, | Source Location: (495:21,25 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (2468:74,25 [4] ) +Generated Location: (2674:80,25 [4] ) |item| Source Location: (504:21,34 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (2510:79,1 [1] ) +Generated Location: (2716:85,1 [1] ) |)| Source Location: (523:25,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (2637:84,6 [16] ) +Generated Location: (2843:90,6 [16] ) |Repeat(10, | Source Location: (556:26,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (2818:87,21 [4] ) +Generated Location: (3024:93,21 [4] ) |item| Source Location: (577:27,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (2860:92,1 [1] ) +Generated Location: (3066:98,1 [1] ) |)| Source Location: (594:31,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (2987:97,6 [16] ) +Generated Location: (3193:103,6 [16] ) |Repeat(10, | Source Location: (628:32,22 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (3169:100,22 [4] ) +Generated Location: (3375:106,22 [4] ) |item| Source Location: (650:33,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (3211:105,1 [1] ) +Generated Location: (3417:111,1 [1] ) |)| Source Location: (667:37,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (3338:110,6 [16] ) +Generated Location: (3544:116,6 [16] ) |Repeat(10, | Source Location: (702:38,23 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (3521:113,23 [4] ) +Generated Location: (3727:119,23 [4] ) |item| Source Location: (724:39,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (3563:118,1 [1] ) +Generated Location: (3769:124,1 [1] ) |)| Source Location: (748:44,5 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (3690:123,6 [11] ) +Generated Location: (3896:129,6 [11] ) |Repeat(10, | Source Location: (781:45,15 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (3860:125,15 [4] ) +Generated Location: (4066:131,15 [4] ) |item| Source Location: (797:46,10 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |var parent = item;| -Generated Location: (3994:130,10 [18] ) +Generated Location: (4200:136,10 [18] ) |var parent = item;| Source Location: (956:51,9 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (4049:135,1 [1] ) +Generated Location: (4255:141,1 [1] ) |)| Source Location: (12:0,12 [265] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) @@ -156,7 +156,7 @@ Source Location: (12:0,12 [265] TestFiles/IntegrationTests/CodeGenerationIntegra }); } | -Generated Location: (4230:142,12 [265] ) +Generated Location: (4436:148,12 [265] ) | public HelperResult Repeat(int times, Func template) { return new HelperResult((writer) => { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_DesignTime.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_DesignTime.codegen.cs index dab1c558b9..67dcb7e986 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_DesignTime.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_DesignTime.codegen.cs @@ -15,15 +15,21 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles #pragma warning disable 1998 public async System.Threading.Tasks.Task ExecuteAsync() { - +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml" + +#line default +#line hidden #line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml" __o = DateTime.; #line default #line hidden - +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml" + +#line default +#line hidden } #pragma warning restore 1998 } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_DesignTime.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_DesignTime.mappings.txt index df11ba8f84..b3394a56b8 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_DesignTime.mappings.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_DesignTime.mappings.txt @@ -1,19 +1,19 @@ Source Location: (2:0,2 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml) | | -Generated Location: (663:17,14 [2] ) +Generated Location: (753:18,2 [2] ) | | Source Location: (5:1,1 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml) |DateTime.| -Generated Location: (775:20,6 [9] ) +Generated Location: (894:23,6 [9] ) |DateTime.| Source Location: (14:1,10 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml) | | -Generated Location: (840:24,22 [2] ) +Generated Location: (1049:28,10 [2] ) | | diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtEOF.cspans.txt new file mode 100644 index 0000000000..a7545b4c7d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtEOF.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [11] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [11] ) +Code span at (11:0,11 [0] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [11] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtEOF.stree.txt new file mode 100644 index 0000000000..4d7733a74b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtEOF.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 11 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [functions] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[functions]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (10:0,10) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [] - CodeBlockEditHandler;Accepts:Any;CodeBlock - (11:0,11) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtStartOfFile.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtStartOfFile.cspans.txt new file mode 100644 index 0000000000..17060f8ef6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtStartOfFile.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Code span at (11:0,11 [5] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [16] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtStartOfFile.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtStartOfFile.stree.txt new file mode 100644 index 0000000000..18a654401d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/FunctionsDirectiveAutoCompleteAtStartOfFile.stree.txt @@ -0,0 +1,10 @@ +Directive block - Gen - 16 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [functions] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[functions]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (10:0,10) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [LFfoo] - CodeBlockEditHandler;Accepts:Any;CodeBlock - (11:0,11) - Tokens:2 + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtEOF.cspans.txt new file mode 100644 index 0000000000..a7489e366c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtEOF.cspans.txt @@ -0,0 +1,7 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (9:0,9 [6] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (15:0,15 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (17:0,17 [0] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [0] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtEOF.stree.txt new file mode 100644 index 0000000000..25e7638666 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtEOF.stree.txt @@ -0,0 +1,16 @@ +Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Header] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[Header]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (16:0,16) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 0 - (17:0,17) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtStartOfFile.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtStartOfFile.cspans.txt new file mode 100644 index 0000000000..94d6f8ac64 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtStartOfFile.cspans.txt @@ -0,0 +1,10 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [29] ) +Code span at (9:0,9 [6] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [29] ) +Markup span at (15:0,15 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [29] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +Markup span at (17:0,17 [2] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [12] ) +Markup span at (19:1,0 [3] ) (Accepts:Any) - Parent: Tag block at (19:1,0 [3] ) +Markup span at (22:1,3 [3] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [12] ) +Markup span at (25:1,6 [4] ) (Accepts:Any) - Parent: Tag block at (25:1,6 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtStartOfFile.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtStartOfFile.stree.txt new file mode 100644 index 0000000000..cab4006af3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/SectionDirectiveAutoCompleteAtStartOfFile.stree.txt @@ -0,0 +1,29 @@ +Directive block - Gen - 29 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Header] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[Header]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (16:0,16) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (17:0,17) + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 3 - (19:1,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (19:1,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (22:1,3) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (25:1,6) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (25:1,6) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.cspans.txt new file mode 100644 index 0000000000..e0cca20068 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [2] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [2] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [2] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.diag.txt new file mode 100644 index 0000000000..1ced8c1b88 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.stree.txt new file mode 100644 index 0000000000..5c1bcb1c4a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtEOF.stree.txt @@ -0,0 +1,7 @@ +Statement block - Gen - 2 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (2:0,2) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.cspans.txt new file mode 100644 index 0000000000..7ba86c0cee --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.cspans.txt @@ -0,0 +1,6 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (4:1,0 [3] ) (Accepts:None) - Parent: Tag block at (4:1,0 [3] ) +Markup span at (7:1,3 [4] ) (Accepts:None) - Parent: Tag block at (7:1,3 [4] ) +Code span at (11:1,7 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.diag.txt new file mode 100644 index 0000000000..1ced8c1b88 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.stree.txt new file mode 100644 index 0000000000..9be89463a8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpAutoCompleteTest/VerbatimBlockAutoCompleteAtStartOfFile.stree.txt @@ -0,0 +1,21 @@ +Statement block - Gen - 11 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [LF] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (2:0,2) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + Markup block - Gen - 7 - (4:1,0) + Tag block - Gen - 3 - (4:1,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (4:1,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Tag block - Gen - 4 - (7:1,3) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (7:1,3) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (11:1,7) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsElseIfWithNoCondition.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsElseIfWithNoCondition.cspans.txt new file mode 100644 index 0000000000..5b65dc4a8d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsElseIfWithNoCondition.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [106] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [106] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsElseIfWithNoCondition.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsElseIfWithNoCondition.stree.txt new file mode 100644 index 0000000000..7b74209f11 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsElseIfWithNoCondition.stree.txt @@ -0,0 +1,60 @@ +Statement block - Gen - 106 - (0:0,0) + Code span - Gen - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if { foo(); }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:58 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode.cspans.txt new file mode 100644 index 0000000000..f0caa5ab82 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode.cspans.txt @@ -0,0 +1,4 @@ +Code span at (0:0,0 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [5] ) +Code span at (11:0,11 [4] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (10:0,10 [5] ) +Code span at (15:0,15 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode.stree.txt new file mode 100644 index 0000000000..a32c45341c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode.stree.txt @@ -0,0 +1,18 @@ +Statement block - Gen - 17 - (0:0,0) + Code span - Gen - [if(foo) { ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:7 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Expression block - Gen - 5 - (10:0,10) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (10:0,10) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[ATD];K14 - (11:0,11) - Tokens:2 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (15:0,15) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AllowsEmptyBlockStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AllowsEmptyBlockStatement.cspans.txt new file mode 100644 index 0000000000..7ae9e301e0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AllowsEmptyBlockStatement.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [13] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [13] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AllowsEmptyBlockStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AllowsEmptyBlockStatement.stree.txt new file mode 100644 index 0000000000..78000ba7a0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/AllowsEmptyBlockStatement.stree.txt @@ -0,0 +1,10 @@ +Statement block - Gen - 13 - (0:0,0) + Code span - Gen - [if(false) { }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:8 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBrackets.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBrackets.cspans.txt new file mode 100644 index 0000000000..b7f74c81c8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBrackets.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [47] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [47] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBrackets.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBrackets.stree.txt new file mode 100644 index 0000000000..e2a2903cf4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBrackets.stree.txt @@ -0,0 +1,19 @@ +Statement block - Gen - 47 - (0:0,0) + Code span - Gen - [if(foo) {LF // bar } " baz 'LF zoop();LF}] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:17 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[// bar } " baz ']; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[zoop]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideBlockComments.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideBlockComments.cspans.txt new file mode 100644 index 0000000000..7d764a8ab7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideBlockComments.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [54] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideBlockComments.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideBlockComments.stree.txt new file mode 100644 index 0000000000..f9d3e2b176 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideBlockComments.stree.txt @@ -0,0 +1,21 @@ +Statement block - Gen - 54 - (0:0,0) + Code span - Gen - [if(foo) {LF /* bar } " */ ' baz } 'LF zoop();LF}] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:19 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* bar } " */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.CharacterLiteral;[' baz } ']; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[zoop]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CapturesNewlineAfterUsing.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CapturesNewlineAfterUsing.cspans.txt new file mode 100644 index 0000000000..b2b0e3a465 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CapturesNewlineAfterUsing.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [11] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [11] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CapturesNewlineAfterUsing.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CapturesNewlineAfterUsing.stree.txt new file mode 100644 index 0000000000..4f557730af --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CapturesNewlineAfterUsing.stree.txt @@ -0,0 +1,6 @@ +Directive block - Gen - 11 - (0:0,0) + Code span - Gen - [using FooLF] - SpanEditHandler;Accepts:AnyExceptNewline - (0:0,0) - Tokens:4 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlock.cspans.txt new file mode 100644 index 0000000000..9f3a379afe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlock.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [40] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlock.stree.txt new file mode 100644 index 0000000000..b30314d849 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlock.stree.txt @@ -0,0 +1,26 @@ +Statement block - Gen - 40 - (0:0,0) + Code span - Gen - [do { var foo = bar; } while(foo != bar);] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:24 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingSemicolon.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingSemicolon.cspans.txt new file mode 100644 index 0000000000..4a799713e8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingSemicolon.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [39] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [39] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingSemicolon.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingSemicolon.stree.txt new file mode 100644 index 0000000000..ca898906ac --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingSemicolon.stree.txt @@ -0,0 +1,25 @@ +Statement block - Gen - 39 - (0:0,0) + Code span - Gen - [do { var foo = bar; } while(foo != bar)] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:23 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely.cspans.txt new file mode 100644 index 0000000000..5c33eaa590 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [21] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely.stree.txt new file mode 100644 index 0000000000..ba8d12a4e0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely.stree.txt @@ -0,0 +1,16 @@ +Statement block - Gen - 21 - (0:0,0) + Code span - Gen - [do { var foo = bar; }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:14 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileCondition.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileCondition.cspans.txt new file mode 100644 index 0000000000..0e1dd1aeef --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileCondition.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [27] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileCondition.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileCondition.stree.txt new file mode 100644 index 0000000000..f5ab356933 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileCondition.stree.txt @@ -0,0 +1,18 @@ +Statement block - Gen - 27 - (0:0,0) + Code span - Gen - [do { var foo = bar; } while] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:16 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon.cspans.txt new file mode 100644 index 0000000000..8a6e4d4508 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [28] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon.stree.txt new file mode 100644 index 0000000000..e93c870c6f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon.stree.txt @@ -0,0 +1,19 @@ +Statement block - Gen - 28 - (0:0,0) + Code span - Gen - [do { var foo = bar; } while;] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:17 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesMarkupInDoWhileBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesMarkupInDoWhileBlock.cspans.txt new file mode 100644 index 0000000000..883eb7ee71 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesMarkupInDoWhileBlock.cspans.txt @@ -0,0 +1,8 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [58] ) +Code span at (1:0,1 [19] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [58] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (20:0,20 [12] ) +Markup span at (21:0,21 [3] ) (Accepts:None) - Parent: Tag block at (21:0,21 [3] ) +Markup span at (24:0,24 [3] ) (Accepts:Any) - Parent: Markup block at (20:0,20 [12] ) +Markup span at (27:0,27 [4] ) (Accepts:None) - Parent: Tag block at (27:0,27 [4] ) +Markup span at (31:0,31 [1] ) (Accepts:None) - Parent: Markup block at (20:0,20 [12] ) +Code span at (32:0,32 [26] ) (Accepts:None) - Parent: Statement block at (0:0,0 [58] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesMarkupInDoWhileBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesMarkupInDoWhileBlock.stree.txt new file mode 100644 index 0000000000..ea36eb7e97 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/CorrectlyParsesMarkupInDoWhileBlock.stree.txt @@ -0,0 +1,50 @@ +Statement block - Gen - 58 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [do { var foo = bar;] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:12 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + Markup block - Gen - 12 - (20:0,20) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (20:0,20) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (21:0,21) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (24:0,24) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (27:0,27) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (27:0,27) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (31:0,31) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo++; } while (foo);] - SpanEditHandler;Accepts:None - (32:0,32) - Tokens:15 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Increment;[++]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotAllowMultipleFinallyBlocks.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotAllowMultipleFinallyBlocks.cspans.txt new file mode 100644 index 0000000000..c8f7004f6a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotAllowMultipleFinallyBlocks.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [55] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotAllowMultipleFinallyBlocks.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotAllowMultipleFinallyBlocks.stree.txt new file mode 100644 index 0000000000..c9a0cb5fa2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotAllowMultipleFinallyBlocks.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 55 - (0:0,0) + Code span - Gen - [try { var foo = new { } } finally { var foo = new { } }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon.cspans.txt new file mode 100644 index 0000000000..40c1f1b195 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [30] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [30] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon.stree.txt new file mode 100644 index 0000000000..7eb0dd4ec7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon.stree.txt @@ -0,0 +1,17 @@ +Statement block - Gen - 30 - (0:0,0) + Code span - Gen - [if(foo) { @"Foo".ToString(); }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:15 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;[@"Foo"]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ToString]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesntCaptureWhitespaceAfterUsing.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesntCaptureWhitespaceAfterUsing.cspans.txt new file mode 100644 index 0000000000..fbf6a392f0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesntCaptureWhitespaceAfterUsing.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [9] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [9] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesntCaptureWhitespaceAfterUsing.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesntCaptureWhitespaceAfterUsing.stree.txt new file mode 100644 index 0000000000..5c5013b233 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/DoesntCaptureWhitespaceAfterUsing.stree.txt @@ -0,0 +1,5 @@ +Directive block - Gen - 9 - (0:0,0) + Code span - Gen - [using Foo] - SpanEditHandler;Accepts:AnyExceptNewline - (0:0,0) - Tokens:3 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceAliasMissingSemicolon.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceAliasMissingSemicolon.cspans.txt new file mode 100644 index 0000000000..01799b73fc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceAliasMissingSemicolon.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [29] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [29] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceAliasMissingSemicolon.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceAliasMissingSemicolon.stree.txt new file mode 100644 index 0000000000..ceb649cba3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceAliasMissingSemicolon.stree.txt @@ -0,0 +1,13 @@ +Directive block - Gen - 29 - (0:0,0) + Code span - Gen - [using Foo.Bar.Baz = FooBarBaz] - SpanEditHandler;Accepts:AnyExceptNewline - (0:0,0) - Tokens:11 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[FooBarBaz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceImportMissingSemicolon.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceImportMissingSemicolon.cspans.txt new file mode 100644 index 0000000000..fd0b552efe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceImportMissingSemicolon.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [17] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceImportMissingSemicolon.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceImportMissingSemicolon.stree.txt new file mode 100644 index 0000000000..0e214796db --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/HasErrorsIfNamespaceImportMissingSemicolon.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 17 - (0:0,0) + Code span - Gen - [using Foo.Bar.Baz] - SpanEditHandler;Accepts:AnyExceptNewline - (0:0,0) - Tokens:7 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithAtDoesntCauseError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithAtDoesntCauseError.cspans.txt new file mode 100644 index 0000000000..84053192bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithAtDoesntCauseError.cspans.txt @@ -0,0 +1,4 @@ +Code span at (0:0,0 [12] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Statement block at (12:0,12 [14] ) +Code span at (13:0,13 [13] ) (Accepts:Any) - Parent: Statement block at (12:0,12 [14] ) +Code span at (26:0,26 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithAtDoesntCauseError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithAtDoesntCauseError.stree.txt new file mode 100644 index 0000000000..f0d580e422 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithAtDoesntCauseError.stree.txt @@ -0,0 +1,25 @@ +Statement block - Gen - 28 - (0:0,0) + Code span - Gen - [if (true) { ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:8 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Statement block - Gen - 14 - (12:0,12) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if(false) { }] - SpanEditHandler;Accepts:Any - (13:0,13) - Tokens:8 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (26:0,26) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithCSharpAt.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithCSharpAt.cspans.txt new file mode 100644 index 0000000000..66ea6d55f2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithCSharpAt.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Code span at (1:0,1 [47] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [49] ) +MetaCode span at (48:0,48 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithCSharpAt.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithCSharpAt.stree.txt new file mode 100644 index 0000000000..80065e6122 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithCSharpAt.stree.txt @@ -0,0 +1,41 @@ +Statement block - Gen - 49 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ if (true) { var val = @x; if (val != 3) { } } ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:35 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[val]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Transition;[@]; + CSharpTokenType.Identifier;[x]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[val]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[3]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (48:0,48) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.cspans.txt new file mode 100644 index 0000000000..1836f2b2e5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.cspans.txt @@ -0,0 +1,13 @@ +Code span at (0:0,0 [12] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [51] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Statement block at (12:0,12 [37] ) +Code span at (13:0,13 [11] ) (Accepts:Any) - Parent: Statement block at (12:0,12 [37] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [24] ) +Markup span at (25:0,25 [5] ) (Accepts:None) - Parent: Tag block at (25:0,25 [5] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [24] ) +Transition span at (30:0,30 [1] ) (Accepts:None) - Parent: Expression block at (30:0,30 [10] ) +Code span at (31:0,31 [9] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (30:0,30 [10] ) +Markup span at (40:0,40 [1] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [24] ) +Markup span at (41:0,41 [6] ) (Accepts:None) - Parent: Tag block at (41:0,41 [6] ) +Markup span at (47:0,47 [1] ) (Accepts:None) - Parent: Markup block at (24:0,24 [24] ) +Code span at (48:0,48 [1] ) (Accepts:Any) - Parent: Statement block at (12:0,12 [37] ) +Code span at (49:0,49 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [51] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.stree.txt new file mode 100644 index 0000000000..28fa9d02af --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.stree.txt @@ -0,0 +1,50 @@ +Statement block - Gen - 51 - (0:0,0) + Code span - Gen - [if (true) { ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:8 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Statement block - Gen - 37 - (12:0,12) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if(false) {] - SpanEditHandler;Accepts:Any - (13:0,13) - Tokens:6 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 24 - (24:0,24) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (24:0,24) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 5 - (25:0,25) + Markup span - Gen - [
            ] - SpanEditHandler;Accepts:None - (25:0,25) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[div]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (30:0,30) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 10 - (30:0,30) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (30:0,30) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [something] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (31:0,31) - Tokens:1 + CSharpTokenType.Identifier;[something]; + Markup span - Gen - [.] - SpanEditHandler;Accepts:Any - (40:0,40) - Tokens:1 + HtmlTokenType.Text;[.]; + Tag block - Gen - 6 - (41:0,41) + Markup span - Gen - [
            ] - SpanEditHandler;Accepts:None - (41:0,41) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[div]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (47:0,47) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (48:0,48) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (49:0,49) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsersCanNestRecursively.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsersCanNestRecursively.cspans.txt new file mode 100644 index 0000000000..b7f50cae33 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsersCanNestRecursively.cspans.txt @@ -0,0 +1,36 @@ +Code span at (0:0,0 [35] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [351] ) +Markup span at (35:1,0 [12] ) (Accepts:Any) - Parent: Markup block at (35:1,0 [307] ) +Markup span at (47:1,12 [5] ) (Accepts:None) - Parent: Tag block at (47:1,12 [5] ) +Markup span at (52:1,17 [18] ) (Accepts:Any) - Parent: Markup block at (35:1,0 [307] ) +Markup span at (70:2,16 [4] ) (Accepts:None) - Parent: Tag block at (70:2,16 [4] ) +Markup span at (74:2,20 [0] ) (Accepts:Any) - Parent: Markup block at (35:1,0 [307] ) +Transition span at (74:2,20 [1] ) (Accepts:None) - Parent: Expression block at (74:2,20 [7] ) +Code span at (75:2,21 [6] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (74:2,20 [7] ) +Markup span at (81:2,27 [5] ) (Accepts:None) - Parent: Tag block at (81:2,27 [5] ) +Markup span at (86:2,32 [18] ) (Accepts:Any) - Parent: Markup block at (35:1,0 [307] ) +Markup span at (104:3,16 [4] ) (Accepts:None) - Parent: Tag block at (104:3,16 [4] ) +Markup span at (108:3,20 [2] ) (Accepts:Any) - Parent: Markup block at (35:1,0 [307] ) +Code span at (110:4,0 [20] ) (Accepts:Any) - Parent: Statement block at (110:4,0 [189] ) +Transition span at (130:4,20 [1] ) (Accepts:None) - Parent: Statement block at (110:4,0 [189] ) +Code span at (131:4,21 [32] ) (Accepts:Any) - Parent: Statement block at (110:4,0 [189] ) +Markup span at (163:5,0 [24] ) (Accepts:Any) - Parent: Markup block at (163:5,0 [113] ) +Markup span at (187:5,24 [4] ) (Accepts:None) - Parent: Tag block at (187:5,24 [4] ) +Markup span at (191:5,28 [2] ) (Accepts:Any) - Parent: Tag block at (191:5,28 [67] ) +Markup span at (193:5,30 [7] ) (Accepts:Any) - Parent: Markup block at (193:5,30 [64] ) +Transition span at (200:5,37 [1] ) (Accepts:None) - Parent: Expression block at (200:5,37 [56] ) +Code span at (201:5,38 [55] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (200:5,37 [56] ) +Markup span at (256:5,93 [1] ) (Accepts:Any) - Parent: Markup block at (193:5,30 [64] ) +Markup span at (257:5,94 [1] ) (Accepts:None) - Parent: Tag block at (191:5,28 [67] ) +Markup span at (258:5,95 [0] ) (Accepts:Any) - Parent: Markup block at (163:5,0 [113] ) +Transition span at (258:5,95 [1] ) (Accepts:None) - Parent: Expression block at (258:5,95 [7] ) +Code span at (259:5,96 [6] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (258:5,95 [7] ) +Markup span at (265:5,102 [4] ) (Accepts:None) - Parent: Tag block at (265:5,102 [4] ) +Markup span at (269:5,106 [5] ) (Accepts:None) - Parent: Tag block at (269:5,106 [5] ) +Markup span at (274:5,111 [2] ) (Accepts:None) - Parent: Markup block at (163:5,0 [113] ) +Code span at (276:6,0 [23] ) (Accepts:None) - Parent: Statement block at (110:4,0 [189] ) +Markup span at (299:7,0 [16] ) (Accepts:Any) - Parent: Markup block at (35:1,0 [307] ) +Markup span at (315:7,16 [5] ) (Accepts:None) - Parent: Tag block at (315:7,16 [5] ) +Markup span at (320:7,21 [14] ) (Accepts:Any) - Parent: Markup block at (35:1,0 [307] ) +Markup span at (334:8,12 [6] ) (Accepts:None) - Parent: Tag block at (334:8,12 [6] ) +Markup span at (340:8,18 [2] ) (Accepts:None) - Parent: Markup block at (35:1,0 [307] ) +Code span at (342:9,0 [9] ) (Accepts:None) - Parent: Statement block at (0:0,0 [351] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsersCanNestRecursively.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsersCanNestRecursively.stree.txt new file mode 100644 index 0000000000..13ca10275e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsersCanNestRecursively.stree.txt @@ -0,0 +1,179 @@ +Statement block - Gen - 351 - (0:0,0) + Code span - Gen - [foreach(var c in db.Categories) {LF] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:15 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[c]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[in]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[db]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Categories]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + Markup block - Gen - 307 - (35:1,0) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (35:1,0) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 5 - (47:1,12) + Markup span - Gen - [
            ] - SpanEditHandler;Accepts:None - (47:1,12) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[div]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF ] - SpanEditHandler;Accepts:Any - (52:1,17) - Tokens:2 + HtmlTokenType.NewLine;[LF]; + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 4 - (70:2,16) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (70:2,16) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[h1]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (74:2,20) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 7 - (74:2,20) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (74:2,20) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [c.Name] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (75:2,21) - Tokens:3 + CSharpTokenType.Identifier;[c]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Name]; + Tag block - Gen - 5 - (81:2,27) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (81:2,27) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[h1]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF ] - SpanEditHandler;Accepts:Any - (86:2,32) - Tokens:2 + HtmlTokenType.NewLine;[LF]; + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 4 - (104:3,16) + Markup span - Gen - [
              ] - SpanEditHandler;Accepts:None - (104:3,16) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[ul]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (108:3,20) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Statement block - Gen - 189 - (110:4,0) + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (110:4,0) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (130:4,20) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foreach(var p in c.Products) {LF] - SpanEditHandler;Accepts:Any - (131:4,21) - Tokens:15 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[p]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[in]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[c]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Products]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + Markup block - Gen - 113 - (163:5,0) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (163:5,0) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 4 - (187:5,24) + Markup span - Gen - [
            • ] - SpanEditHandler;Accepts:None - (187:5,24) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[li]; + HtmlTokenType.CloseAngle;[>]; + Tag block - Gen - 67 - (191:5,28) + Markup span - Gen - [ - 64 - (193:5,30) + Markup span - Gen - [ href="] - SpanEditHandler;Accepts:Any - (193:5,30) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[href]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.DoubleQuote;["]; + Markup block - Gen - 56 - (200:5,37) + Expression block - Gen - 56 - (200:5,37) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (200:5,37) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [Html.ActionUrl("Products", "Detail", new { id = p.Id })] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (201:5,38) - Tokens:24 + CSharpTokenType.Identifier;[Html]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ActionUrl]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;["Products"]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["Detail"]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[id]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[p]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Id]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + Markup span - Gen - ["] - SpanEditHandler;Accepts:Any - (256:5,93) - Tokens:1 + HtmlTokenType.DoubleQuote;["]; + Markup span - Gen - [>] - SpanEditHandler;Accepts:None - (257:5,94) - Tokens:1 + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (258:5,95) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 7 - (258:5,95) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (258:5,95) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [p.Name] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (259:5,96) - Tokens:3 + CSharpTokenType.Identifier;[p]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Name]; + Tag block - Gen - 4 - (265:5,102) + Markup span - Gen - [] - SpanEditHandler;Accepts:None - (265:5,102) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[a]; + HtmlTokenType.CloseAngle;[>]; + Tag block - Gen - 5 - (269:5,106) + Markup span - Gen - [
            • ] - SpanEditHandler;Accepts:None - (269:5,106) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[li]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:None - (274:5,111) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Code span - Gen - [ }LF] - SpanEditHandler;Accepts:None - (276:6,0) - Tokens:3 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (299:7,0) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 5 - (315:7,16) + Markup span - Gen - [
            ] - SpanEditHandler;Accepts:None - (315:7,16) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[ul]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF ] - SpanEditHandler;Accepts:Any - (320:7,21) - Tokens:2 + HtmlTokenType.NewLine;[LF]; + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 6 - (334:8,12) + Markup span - Gen - [
            ] - SpanEditHandler;Accepts:None - (334:8,12) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[div]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:None - (340:8,18) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:None - (342:9,0) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.cspans.txt new file mode 100644 index 0000000000..d3331d7c7d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [180] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [180] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.stree.txt new file mode 100644 index 0000000000..5563401047 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.stree.txt @@ -0,0 +1,95 @@ +Statement block - Gen - 180 - (0:0,0) + Code span - Gen - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF}] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:93 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.cspans.txt new file mode 100644 index 0000000000..2295e35eba --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.cspans.txt @@ -0,0 +1,4 @@ +Code span at (0:0,0 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [13] ) +Code span at (11:0,11 [12] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (10:0,10 [13] ) +Code span at (23:0,23 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.stree.txt new file mode 100644 index 0000000000..45b2fc09d2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.stree.txt @@ -0,0 +1,24 @@ +Statement block - Gen - 25 - (0:0,0) + Code span - Gen - [if(foo) { ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:7 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Expression block - Gen - 13 - (10:0,10) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (10:0,10) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo[4].bar()] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[ATD];K14 - (11:0,11) - Tokens:8 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.IntegerLiteral;[4]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (23:0,23) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.cspans.txt new file mode 100644 index 0000000000..eabbbc0e28 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.cspans.txt @@ -0,0 +1,6 @@ +Code span at (0:0,0 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [12] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [12] ) +Code span at (12:0,12 [9] ) (Accepts:Any) - Parent: Expression block at (10:0,10 [12] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [12] ) +Code span at (22:0,22 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.stree.txt new file mode 100644 index 0000000000..09618cf66e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.stree.txt @@ -0,0 +1,25 @@ +Statement block - Gen - 24 - (0:0,0) + Code span - Gen - [if(foo) { ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:7 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Expression block - Gen - 12 - (10:0,10) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (10:0,10) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (11:0,11) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [foo + bar] - SpanEditHandler;Accepts:Any - (12:0,12) - Tokens:5 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Plus;[+]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (22:0,22) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.cspans.txt new file mode 100644 index 0000000000..71c535a8d1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [459] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [459] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.stree.txt new file mode 100644 index 0000000000..05d2542f80 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.stree.txt @@ -0,0 +1,239 @@ +Statement block - Gen - 459 - (0:0,0) + Code span - Gen - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF}] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:237 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.cspans.txt new file mode 100644 index 0000000000..ba23d87bc8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [313] ) (Accepts:None) - Parent: Statement block at (0:0,0 [313] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.stree.txt new file mode 100644 index 0000000000..766f7e4ddd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.stree.txt @@ -0,0 +1,157 @@ +Statement block - Gen - 313 - (0:0,0) + Code span - Gen - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else { Debug.WriteLine(@"bar } baz"); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:155 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt new file mode 100644 index 0000000000..0cc21c464d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [28] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [28] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt new file mode 100644 index 0000000000..9b0810ec74 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt @@ -0,0 +1,10 @@ +Directive block - Gen - 28 - (0:0,0) + Code span - Gen - [using FooBarBaz = FooBarBaz;] - SpanEditHandler;Accepts:AnyExceptNewline - (0:0,0) - Tokens:8 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[FooBarBaz]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[FooBarBaz]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt new file mode 100644 index 0000000000..213fb230e6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [18] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [18] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt new file mode 100644 index 0000000000..d9f8d37923 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt @@ -0,0 +1,10 @@ +Directive block - Gen - 18 - (0:0,0) + Code span - Gen - [using Foo.Bar.Baz;] - SpanEditHandler;Accepts:AnyExceptNewline - (0:0,0) - Tokens:8 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.cspans.txt new file mode 100644 index 0000000000..cf2c77a81f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [82] ) (Accepts:None) - Parent: Statement block at (0:0,0 [82] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.stree.txt new file mode 100644 index 0000000000..c19dcce9b3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.stree.txt @@ -0,0 +1,46 @@ +Statement block - Gen - 82 - (0:0,0) + Code span - Gen - [for(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:44 + CSharpTokenType.Keyword;[for]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.cspans.txt new file mode 100644 index 0000000000..3899e6a80a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [86] ) (Accepts:None) - Parent: Statement block at (0:0,0 [86] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.stree.txt new file mode 100644 index 0000000000..8e095ff484 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.stree.txt @@ -0,0 +1,46 @@ +Statement block - Gen - 86 - (0:0,0) + Code span - Gen - [foreach(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:44 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.cspans.txt new file mode 100644 index 0000000000..20cc9b3df9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [81] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [81] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.stree.txt new file mode 100644 index 0000000000..bb4eee2f14 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.stree.txt @@ -0,0 +1,46 @@ +Statement block - Gen - 81 - (0:0,0) + Code span - Gen - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:44 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.cspans.txt new file mode 100644 index 0000000000..b4d23d1764 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [161] ) (Accepts:None) - Parent: Statement block at (0:0,0 [161] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.stree.txt new file mode 100644 index 0000000000..f0e5015b28 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.stree.txt @@ -0,0 +1,54 @@ +Statement block - Gen - 161 - (0:0,0) + Code span - Gen - [switch(foo) {LF case 0:LF break;LF case 1:LF {LF break;LF }LF case 2:LF return;LF default:LF return;LF}] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:52 + CSharpTokenType.Keyword;[switch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[case]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Colon;[:]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[break]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[case]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[1]; + CSharpTokenType.Colon;[:]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[break]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[case]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[2]; + CSharpTokenType.Colon;[:]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[return]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[default]; + CSharpTokenType.Colon;[:]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[return]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.cspans.txt new file mode 100644 index 0000000000..bd3a07598c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [84] ) (Accepts:None) - Parent: Statement block at (0:0,0 [84] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.stree.txt new file mode 100644 index 0000000000..261becea48 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.stree.txt @@ -0,0 +1,46 @@ +Statement block - Gen - 84 - (0:0,0) + Code span - Gen - [while(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:44 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.cspans.txt new file mode 100644 index 0000000000..bd3a07598c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [84] ) (Accepts:None) - Parent: Statement block at (0:0,0 [84] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.stree.txt new file mode 100644 index 0000000000..aaabf8bbd5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.stree.txt @@ -0,0 +1,46 @@ +Statement block - Gen - 84 - (0:0,0) + Code span - Gen - [using(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:44 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.cspans.txt new file mode 100644 index 0000000000..c8f7004f6a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [55] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.stree.txt new file mode 100644 index 0000000000..c9a0cb5fa2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 55 - (0:0,0) + Code span - Gen - [try { var foo = new { } } finally { var foo = new { } }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.cspans.txt new file mode 100644 index 0000000000..ec3a77bef4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [220] ) (Accepts:None) - Parent: Statement block at (0:0,0 [220] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.stree.txt new file mode 100644 index 0000000000..8aea7b10e3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.stree.txt @@ -0,0 +1,109 @@ +Statement block - Gen - 220 - (0:0,0) + Code span - Gen - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else { Debug.WriteLine(@"bar } baz"); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:107 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bar } baz"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.cspans.txt new file mode 100644 index 0000000000..12cdfd930d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [87] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [87] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.stree.txt new file mode 100644 index 0000000000..a6fde6d036 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.stree.txt @@ -0,0 +1,47 @@ +Statement block - Gen - 87 - (0:0,0) + Code span - Gen - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF}] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:45 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..0f9b943730 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [75] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.stree.txt new file mode 100644 index 0000000000..4dd24cad32 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.stree.txt @@ -0,0 +1,41 @@ +Statement block - Gen - 75 - (0:0,0) + Code span - Gen - [try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:39 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Foo */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Bar */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[biz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.cspans.txt new file mode 100644 index 0000000000..1c01f6e3b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [54] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.stree.txt new file mode 100644 index 0000000000..89aeaa49b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.stree.txt @@ -0,0 +1,26 @@ +Statement block - Gen - 54 - (0:0,0) + Code span - Gen - [do { var foo = bar; } /* Foo */ /* Bar */ while(true);] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:24 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Foo */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Bar */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..c4a5cd9ad0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [78] ) (Accepts:None) - Parent: Statement block at (0:0,0 [78] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.stree.txt new file mode 100644 index 0000000000..8beb9c4062 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.stree.txt @@ -0,0 +1,46 @@ +Statement block - Gen - 78 - (0:0,0) + Code span - Gen - [if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:44 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Foo */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Bar */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[biz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..1c01f6e3b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [54] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.stree.txt new file mode 100644 index 0000000000..c00834cb33 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.stree.txt @@ -0,0 +1,30 @@ +Statement block - Gen - 54 - (0:0,0) + Code span - Gen - [if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:28 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Foo */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Bar */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.cspans.txt new file mode 100644 index 0000000000..bf06b79010 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [62] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [62] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.stree.txt new file mode 100644 index 0000000000..35a7c0c0e2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.stree.txt @@ -0,0 +1,35 @@ +Statement block - Gen - 62 - (0:0,0) + Code span - Gen - [if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:33 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Foo */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Bar */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.cspans.txt new file mode 100644 index 0000000000..3776f70a65 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [56] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.stree.txt new file mode 100644 index 0000000000..4fb861d57f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.stree.txt @@ -0,0 +1,30 @@ +Statement block - Gen - 56 - (0:0,0) + Code span - Gen - [try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:28 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Foo */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Bar */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..084d801dff --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [53] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.stree.txt new file mode 100644 index 0000000000..659643d83f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.stree.txt @@ -0,0 +1,27 @@ +Statement block - Gen - 53 - (0:0,0) + Code span - Gen - [try { bar(); } /* Foo */ /* Bar */ finally { baz(); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:25 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Foo */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* Bar */]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.cspans.txt new file mode 100644 index 0000000000..aa1f2379ca --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [53] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.stree.txt new file mode 100644 index 0000000000..bb84c5607a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 53 - (0:0,0) + Code span - Gen - [try { var foo = new { } } catch { var foo = new { } }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..e688f27cb5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [72] ) (Accepts:None) - Parent: Statement block at (0:0,0 [72] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.stree.txt new file mode 100644 index 0000000000..b09a7b573c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.stree.txt @@ -0,0 +1,41 @@ +Statement block - Gen - 72 - (0:0,0) + Code span - Gen - [try { bar(); } catch(bar) { baz(); }LF// FooLF// BarLFfinally { biz(); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:39 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Foo]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Bar]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[biz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.cspans.txt new file mode 100644 index 0000000000..953c0f4158 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [51] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.stree.txt new file mode 100644 index 0000000000..17b8ff17eb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.stree.txt @@ -0,0 +1,26 @@ +Statement block - Gen - 51 - (0:0,0) + Code span - Gen - [do { var foo = bar; }LF// FooLF// BarLFwhile(true);] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:24 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Foo]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Bar]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..0f9b943730 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [75] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.stree.txt new file mode 100644 index 0000000000..eb193d4c42 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.stree.txt @@ -0,0 +1,46 @@ +Statement block - Gen - 75 - (0:0,0) + Code span - Gen - [if(foo) { bar(); } else if(bar) { baz(); }LF// FooLF// BarLFelse { biz(); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:44 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Foo]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Bar]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[biz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..953c0f4158 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [51] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.stree.txt new file mode 100644 index 0000000000..5494eeaffe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.stree.txt @@ -0,0 +1,30 @@ +Statement block - Gen - 51 - (0:0,0) + Code span - Gen - [if(foo) { bar(); }LF// FooLF// BarLFelse { baz(); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:28 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Foo]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Bar]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.cspans.txt new file mode 100644 index 0000000000..69587fdbc5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [59] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [59] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.stree.txt new file mode 100644 index 0000000000..9359227eaf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.stree.txt @@ -0,0 +1,35 @@ +Statement block - Gen - 59 - (0:0,0) + Code span - Gen - [if(foo) { bar(); }LF// FooLF// BarLFelse if(bar) { baz(); }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:33 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Foo]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Bar]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.cspans.txt new file mode 100644 index 0000000000..aa1f2379ca --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [53] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.stree.txt new file mode 100644 index 0000000000..fd741d9327 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.stree.txt @@ -0,0 +1,30 @@ +Statement block - Gen - 53 - (0:0,0) + Code span - Gen - [try { bar(); }LF// FooLF// BarLFcatch(bar) { baz(); }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:28 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Foo]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Bar]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..b0bf6cf1bf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [50] ) (Accepts:None) - Parent: Statement block at (0:0,0 [50] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.stree.txt new file mode 100644 index 0000000000..4f6a067875 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.stree.txt @@ -0,0 +1,27 @@ +Statement block - Gen - 50 - (0:0,0) + Code span - Gen - [try { bar(); }LF// FooLF// BarLFfinally { baz(); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:25 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Foo]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Comment;[// Bar]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.cspans.txt new file mode 100644 index 0000000000..34ef0446dd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.cspans.txt @@ -0,0 +1,7 @@ +Code span at (0:0,0 [128] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [141] ) +Markup span at (128:0,128 [1] ) (Accepts:Any) - Parent: Markup block at (128:0,128 [12] ) +Markup span at (129:0,129 [3] ) (Accepts:None) - Parent: Tag block at (129:0,129 [3] ) +Markup span at (132:0,132 [3] ) (Accepts:Any) - Parent: Markup block at (128:0,128 [12] ) +Markup span at (135:0,135 [4] ) (Accepts:None) - Parent: Tag block at (135:0,135 [4] ) +Markup span at (139:0,139 [1] ) (Accepts:None) - Parent: Markup block at (128:0,128 [12] ) +Code span at (140:0,140 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [141] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.stree.txt new file mode 100644 index 0000000000..12d1fbf839 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.stree.txt @@ -0,0 +1,100 @@ +Statement block - Gen - 141 - (0:0,0) + Code span - Gen - [try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) {] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:78 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (128:0,128) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (128:0,128) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (129:0,129) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (129:0,129) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (132:0,132) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (135:0,135) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (135:0,135) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (139:0,139) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (140:0,140) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.cspans.txt new file mode 100644 index 0000000000..e099594ff3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.cspans.txt @@ -0,0 +1,7 @@ +Code span at (0:0,0 [46] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [59] ) +Markup span at (46:0,46 [1] ) (Accepts:Any) - Parent: Markup block at (46:0,46 [12] ) +Markup span at (47:0,47 [3] ) (Accepts:None) - Parent: Tag block at (47:0,47 [3] ) +Markup span at (50:0,50 [3] ) (Accepts:Any) - Parent: Markup block at (46:0,46 [12] ) +Markup span at (53:0,53 [4] ) (Accepts:None) - Parent: Tag block at (53:0,53 [4] ) +Markup span at (57:0,57 [1] ) (Accepts:None) - Parent: Markup block at (46:0,46 [12] ) +Code span at (58:0,58 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [59] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.stree.txt new file mode 100644 index 0000000000..eb1512a038 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.stree.txt @@ -0,0 +1,50 @@ +Statement block - Gen - 59 - (0:0,0) + Code span - Gen - [try { var foo = new { } } catch(Foo Bar Baz) {] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:28 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (46:0,46) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (46:0,46) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (47:0,47) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (47:0,47) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (50:0,50) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (53:0,53) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (53:0,53) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (57:0,57) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (58:0,58) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.cspans.txt new file mode 100644 index 0000000000..1237a8b354 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.cspans.txt @@ -0,0 +1,7 @@ +Code span at (0:0,0 [35] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) +Markup span at (35:0,35 [1] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [12] ) +Markup span at (36:0,36 [3] ) (Accepts:None) - Parent: Tag block at (36:0,36 [3] ) +Markup span at (39:0,39 [3] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [12] ) +Markup span at (42:0,42 [4] ) (Accepts:None) - Parent: Tag block at (42:0,42 [4] ) +Markup span at (46:0,46 [1] ) (Accepts:None) - Parent: Markup block at (35:0,35 [12] ) +Code span at (47:0,47 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.stree.txt new file mode 100644 index 0000000000..4af8d90e1a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.stree.txt @@ -0,0 +1,43 @@ +Statement block - Gen - 48 - (0:0,0) + Code span - Gen - [try { var foo = new { } } finally {] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:21 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (35:0,35) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (35:0,35) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (36:0,36) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (36:0,36) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (39:0,39) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (42:0,42) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (42:0,42) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (46:0,46) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:None - (47:0,47) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.cspans.txt new file mode 100644 index 0000000000..5ad2687a0f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.cspans.txt @@ -0,0 +1,7 @@ +Code span at (0:0,0 [5] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [18] ) +Markup span at (5:0,5 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (6:0,6 [3] ) (Accepts:None) - Parent: Tag block at (6:0,6 [3] ) +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (12:0,12 [4] ) (Accepts:None) - Parent: Tag block at (12:0,12 [4] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Markup block at (5:0,5 [12] ) +Code span at (17:0,17 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [18] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.stree.txt new file mode 100644 index 0000000000..f7fc9e38f9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.stree.txt @@ -0,0 +1,25 @@ +Statement block - Gen - 18 - (0:0,0) + Code span - Gen - [try {] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:3 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (5:0,5) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (5:0,5) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (6:0,6) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (6:0,6) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (9:0,9) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (12:0,12) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..0d234809be --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.cspans.txt @@ -0,0 +1,13 @@ +Code span at (0:0,0 [37] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [75] ) +Transition span at (37:0,37 [1] ) (Accepts:None) - Parent: Comment block at (37:0,37 [9] ) +MetaCode span at (38:0,38 [1] ) (Accepts:None) - Parent: Comment block at (37:0,37 [9] ) +Comment span at (39:0,39 [5] ) (Accepts:Any) - Parent: Comment block at (37:0,37 [9] ) +MetaCode span at (44:0,44 [1] ) (Accepts:None) - Parent: Comment block at (37:0,37 [9] ) +Transition span at (45:0,45 [1] ) (Accepts:None) - Parent: Comment block at (37:0,37 [9] ) +Code span at (46:0,46 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [75] ) +Transition span at (47:0,47 [1] ) (Accepts:None) - Parent: Comment block at (47:0,47 [9] ) +MetaCode span at (48:0,48 [1] ) (Accepts:None) - Parent: Comment block at (47:0,47 [9] ) +Comment span at (49:0,49 [5] ) (Accepts:Any) - Parent: Comment block at (47:0,47 [9] ) +MetaCode span at (54:0,54 [1] ) (Accepts:None) - Parent: Comment block at (47:0,47 [9] ) +Transition span at (55:0,55 [1] ) (Accepts:None) - Parent: Comment block at (47:0,47 [9] ) +Code span at (56:0,56 [19] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.stree.txt new file mode 100644 index 0000000000..7ebe9d2b86 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.stree.txt @@ -0,0 +1,63 @@ +Statement block - Gen - 75 - (0:0,0) + Code span - Gen - [try { bar(); } catch(bar) { baz(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:25 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (37:0,37) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (37:0,37) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (38:0,38) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Foo ] - SpanEditHandler;Accepts:Any - (39:0,39) - Tokens:1 + CSharpTokenType.RazorComment;[ Foo ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (44:0,44) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (45:0,45) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (46:0,46) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (47:0,47) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (47:0,47) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (48:0,48) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Bar ] - SpanEditHandler;Accepts:Any - (49:0,49) - Tokens:1 + CSharpTokenType.RazorComment;[ Bar ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (54:0,54) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (55:0,55) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ finally { biz(); }] - SpanEditHandler;Accepts:None - (56:0,56) - Tokens:11 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[biz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.cspans.txt new file mode 100644 index 0000000000..3ef83ceaf3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.cspans.txt @@ -0,0 +1,13 @@ +Code span at (0:0,0 [22] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) +Transition span at (22:0,22 [1] ) (Accepts:None) - Parent: Comment block at (22:0,22 [9] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Comment block at (22:0,22 [9] ) +Comment span at (24:0,24 [5] ) (Accepts:Any) - Parent: Comment block at (22:0,22 [9] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Comment block at (22:0,22 [9] ) +Transition span at (30:0,30 [1] ) (Accepts:None) - Parent: Comment block at (22:0,22 [9] ) +Code span at (31:0,31 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) +Transition span at (32:0,32 [1] ) (Accepts:None) - Parent: Comment block at (32:0,32 [9] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Comment block at (32:0,32 [9] ) +Comment span at (34:0,34 [5] ) (Accepts:Any) - Parent: Comment block at (32:0,32 [9] ) +MetaCode span at (39:0,39 [1] ) (Accepts:None) - Parent: Comment block at (32:0,32 [9] ) +Transition span at (40:0,40 [1] ) (Accepts:None) - Parent: Comment block at (32:0,32 [9] ) +Code span at (41:0,41 [13] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.stree.txt new file mode 100644 index 0000000000..e31ec364b4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.stree.txt @@ -0,0 +1,48 @@ +Statement block - Gen - 54 - (0:0,0) + Code span - Gen - [do { var foo = bar; } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:15 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (22:0,22) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (22:0,22) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (23:0,23) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Foo ] - SpanEditHandler;Accepts:Any - (24:0,24) - Tokens:1 + CSharpTokenType.RazorComment;[ Foo ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (29:0,29) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (30:0,30) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (31:0,31) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (32:0,32) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (32:0,32) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (33:0,33) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Bar ] - SpanEditHandler;Accepts:Any - (34:0,34) - Tokens:1 + CSharpTokenType.RazorComment;[ Bar ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (39:0,39) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (40:0,40) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ while(true);] - SpanEditHandler;Accepts:None - (41:0,41) - Tokens:6 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..9bcc613a1d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.cspans.txt @@ -0,0 +1,13 @@ +Code span at (0:0,0 [43] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [78] ) +Transition span at (43:0,43 [1] ) (Accepts:None) - Parent: Comment block at (43:0,43 [9] ) +MetaCode span at (44:0,44 [1] ) (Accepts:None) - Parent: Comment block at (43:0,43 [9] ) +Comment span at (45:0,45 [5] ) (Accepts:Any) - Parent: Comment block at (43:0,43 [9] ) +MetaCode span at (50:0,50 [1] ) (Accepts:None) - Parent: Comment block at (43:0,43 [9] ) +Transition span at (51:0,51 [1] ) (Accepts:None) - Parent: Comment block at (43:0,43 [9] ) +Code span at (52:0,52 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [78] ) +Transition span at (53:0,53 [1] ) (Accepts:None) - Parent: Comment block at (53:0,53 [9] ) +MetaCode span at (54:0,54 [1] ) (Accepts:None) - Parent: Comment block at (53:0,53 [9] ) +Comment span at (55:0,55 [5] ) (Accepts:Any) - Parent: Comment block at (53:0,53 [9] ) +MetaCode span at (60:0,60 [1] ) (Accepts:None) - Parent: Comment block at (53:0,53 [9] ) +Transition span at (61:0,61 [1] ) (Accepts:None) - Parent: Comment block at (53:0,53 [9] ) +Code span at (62:0,62 [16] ) (Accepts:None) - Parent: Statement block at (0:0,0 [78] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.stree.txt new file mode 100644 index 0000000000..36f17bd744 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.stree.txt @@ -0,0 +1,68 @@ +Statement block - Gen - 78 - (0:0,0) + Code span - Gen - [if(foo) { bar(); } else if(bar) { baz(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:30 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (43:0,43) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (43:0,43) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (44:0,44) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Foo ] - SpanEditHandler;Accepts:Any - (45:0,45) - Tokens:1 + CSharpTokenType.RazorComment;[ Foo ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (50:0,50) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (51:0,51) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (52:0,52) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (53:0,53) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (53:0,53) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (54:0,54) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Bar ] - SpanEditHandler;Accepts:Any - (55:0,55) - Tokens:1 + CSharpTokenType.RazorComment;[ Bar ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (60:0,60) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (61:0,61) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ else { baz(); }] - SpanEditHandler;Accepts:None - (62:0,62) - Tokens:11 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..e21110505f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.cspans.txt @@ -0,0 +1,13 @@ +Code span at (0:0,0 [19] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) +Transition span at (19:0,19 [1] ) (Accepts:None) - Parent: Comment block at (19:0,19 [9] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Comment block at (19:0,19 [9] ) +Comment span at (21:0,21 [5] ) (Accepts:Any) - Parent: Comment block at (19:0,19 [9] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Comment block at (19:0,19 [9] ) +Transition span at (27:0,27 [1] ) (Accepts:None) - Parent: Comment block at (19:0,19 [9] ) +Code span at (28:0,28 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) +Transition span at (29:0,29 [1] ) (Accepts:None) - Parent: Comment block at (29:0,29 [9] ) +MetaCode span at (30:0,30 [1] ) (Accepts:None) - Parent: Comment block at (29:0,29 [9] ) +Comment span at (31:0,31 [5] ) (Accepts:Any) - Parent: Comment block at (29:0,29 [9] ) +MetaCode span at (36:0,36 [1] ) (Accepts:None) - Parent: Comment block at (29:0,29 [9] ) +Transition span at (37:0,37 [1] ) (Accepts:None) - Parent: Comment block at (29:0,29 [9] ) +Code span at (38:0,38 [16] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.stree.txt new file mode 100644 index 0000000000..6a9926895b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.stree.txt @@ -0,0 +1,52 @@ +Statement block - Gen - 54 - (0:0,0) + Code span - Gen - [if(foo) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:14 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (19:0,19) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (19:0,19) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (20:0,20) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Foo ] - SpanEditHandler;Accepts:Any - (21:0,21) - Tokens:1 + CSharpTokenType.RazorComment;[ Foo ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (26:0,26) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (27:0,27) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (28:0,28) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (29:0,29) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (29:0,29) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (30:0,30) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Bar ] - SpanEditHandler;Accepts:Any - (31:0,31) - Tokens:1 + CSharpTokenType.RazorComment;[ Bar ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (36:0,36) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (37:0,37) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ else { baz(); }] - SpanEditHandler;Accepts:None - (38:0,38) - Tokens:11 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.cspans.txt new file mode 100644 index 0000000000..ea37207843 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.cspans.txt @@ -0,0 +1,13 @@ +Code span at (0:0,0 [19] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [62] ) +Transition span at (19:0,19 [1] ) (Accepts:None) - Parent: Comment block at (19:0,19 [9] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Comment block at (19:0,19 [9] ) +Comment span at (21:0,21 [5] ) (Accepts:Any) - Parent: Comment block at (19:0,19 [9] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Comment block at (19:0,19 [9] ) +Transition span at (27:0,27 [1] ) (Accepts:None) - Parent: Comment block at (19:0,19 [9] ) +Code span at (28:0,28 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [62] ) +Transition span at (29:0,29 [1] ) (Accepts:None) - Parent: Comment block at (29:0,29 [9] ) +MetaCode span at (30:0,30 [1] ) (Accepts:None) - Parent: Comment block at (29:0,29 [9] ) +Comment span at (31:0,31 [5] ) (Accepts:Any) - Parent: Comment block at (29:0,29 [9] ) +MetaCode span at (36:0,36 [1] ) (Accepts:None) - Parent: Comment block at (29:0,29 [9] ) +Transition span at (37:0,37 [1] ) (Accepts:None) - Parent: Comment block at (29:0,29 [9] ) +Code span at (38:0,38 [24] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [62] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.stree.txt new file mode 100644 index 0000000000..f25afcea4d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.stree.txt @@ -0,0 +1,57 @@ +Statement block - Gen - 62 - (0:0,0) + Code span - Gen - [if(foo) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:14 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (19:0,19) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (19:0,19) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (20:0,20) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Foo ] - SpanEditHandler;Accepts:Any - (21:0,21) - Tokens:1 + CSharpTokenType.RazorComment;[ Foo ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (26:0,26) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (27:0,27) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (28:0,28) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (29:0,29) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (29:0,29) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (30:0,30) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Bar ] - SpanEditHandler;Accepts:Any - (31:0,31) - Tokens:1 + CSharpTokenType.RazorComment;[ Bar ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (36:0,36) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (37:0,37) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ else if(bar) { baz(); }] - SpanEditHandler;Accepts:Any - (38:0,38) - Tokens:16 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.cspans.txt new file mode 100644 index 0000000000..ca213900cc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.cspans.txt @@ -0,0 +1,13 @@ +Code span at (0:0,0 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) +Transition span at (14:0,14 [1] ) (Accepts:None) - Parent: Comment block at (14:0,14 [9] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Comment block at (14:0,14 [9] ) +Comment span at (16:0,16 [5] ) (Accepts:Any) - Parent: Comment block at (14:0,14 [9] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Comment block at (14:0,14 [9] ) +Transition span at (22:0,22 [1] ) (Accepts:None) - Parent: Comment block at (14:0,14 [9] ) +Code span at (23:0,23 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Comment block at (24:0,24 [9] ) +MetaCode span at (25:0,25 [1] ) (Accepts:None) - Parent: Comment block at (24:0,24 [9] ) +Comment span at (26:0,26 [5] ) (Accepts:Any) - Parent: Comment block at (24:0,24 [9] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Comment block at (24:0,24 [9] ) +Transition span at (32:0,32 [1] ) (Accepts:None) - Parent: Comment block at (24:0,24 [9] ) +Code span at (33:0,33 [22] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.stree.txt new file mode 100644 index 0000000000..7ca64561f4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.stree.txt @@ -0,0 +1,51 @@ +Statement block - Gen - 55 - (0:0,0) + Code span - Gen - [try { bar(); }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:10 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + Comment block - Gen - 9 - (14:0,14) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (14:0,14) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Foo ] - SpanEditHandler;Accepts:Any - (16:0,16) - Tokens:1 + CSharpTokenType.RazorComment;[ Foo ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (22:0,22) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (23:0,23) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (24:0,24) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (24:0,24) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (25:0,25) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Bar ] - SpanEditHandler;Accepts:Any - (26:0,26) - Tokens:1 + CSharpTokenType.RazorComment;[ Bar ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (31:0,31) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (32:0,32) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ catch(bar) { baz(); }] - SpanEditHandler;Accepts:Any - (33:0,33) - Tokens:14 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..23a25a7925 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.cspans.txt @@ -0,0 +1,13 @@ +Code span at (0:0,0 [15] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Comment block at (15:0,15 [9] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Comment block at (15:0,15 [9] ) +Comment span at (17:0,17 [5] ) (Accepts:Any) - Parent: Comment block at (15:0,15 [9] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Comment block at (15:0,15 [9] ) +Transition span at (23:0,23 [1] ) (Accepts:None) - Parent: Comment block at (15:0,15 [9] ) +Code span at (24:0,24 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) +Transition span at (25:0,25 [1] ) (Accepts:None) - Parent: Comment block at (25:0,25 [9] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Comment block at (25:0,25 [9] ) +Comment span at (27:0,27 [5] ) (Accepts:Any) - Parent: Comment block at (25:0,25 [9] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Comment block at (25:0,25 [9] ) +Transition span at (33:0,33 [1] ) (Accepts:None) - Parent: Comment block at (25:0,25 [9] ) +Code span at (34:0,34 [19] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.stree.txt new file mode 100644 index 0000000000..bb040a642a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.stree.txt @@ -0,0 +1,49 @@ +Statement block - Gen - 53 - (0:0,0) + Code span - Gen - [try { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:11 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (15:0,15) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Foo ] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + CSharpTokenType.RazorComment;[ Foo ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (22:0,22) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (23:0,23) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (24:0,24) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Comment block - Gen - 9 - (25:0,25) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (25:0,25) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (26:0,26) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ Bar ] - SpanEditHandler;Accepts:Any - (27:0,27) - Tokens:1 + CSharpTokenType.RazorComment;[ Bar ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (32:0,32) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (33:0,33) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [ finally { biz(); }] - SpanEditHandler;Accepts:None - (34:0,34) - Tokens:11 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[biz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.cspans.txt new file mode 100644 index 0000000000..c8f7004f6a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [55] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.stree.txt new file mode 100644 index 0000000000..c9a0cb5fa2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 55 - (0:0,0) + Code span - Gen - [try { var foo = new { } } finally { var foo = new { } }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.cspans.txt new file mode 100644 index 0000000000..a1bdc4fc91 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [148] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [148] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.stree.txt new file mode 100644 index 0000000000..b4bab579d7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.stree.txt @@ -0,0 +1,94 @@ +Statement block - Gen - 148 - (0:0,0) + Code span - Gen - [try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:92 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.cspans.txt new file mode 100644 index 0000000000..04f904b866 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [25] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.stree.txt new file mode 100644 index 0000000000..8db73b2757 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.stree.txt @@ -0,0 +1,19 @@ +Statement block - Gen - 25 - (0:0,0) + Code span - Gen - [try { var foo = new { } }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:17 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.cspans.txt new file mode 100644 index 0000000000..57f987b6a9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [66] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [66] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.stree.txt new file mode 100644 index 0000000000..e83ac8d8ba --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.stree.txt @@ -0,0 +1,44 @@ +Statement block - Gen - 66 - (0:0,0) + Code span - Gen - [try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:42 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.cspans.txt new file mode 100644 index 0000000000..dddc1672d8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [96] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [96] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.stree.txt new file mode 100644 index 0000000000..4618359626 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.stree.txt @@ -0,0 +1,55 @@ +Statement block - Gen - 96 - (0:0,0) + Code span - Gen - [if(foo) { using(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); } }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:53 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[using]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["baz"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..77e1f6ca0b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [38] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.diag.txt new file mode 100644 index 0000000000..ad0b9a4c86 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.diag.txt @@ -0,0 +1,2 @@ +(1,25): Error RZ1001: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. +(1,1): Error RZ1006: The foreach block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.stree.txt new file mode 100644 index 0000000000..c1ef9144c7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.stree.txt @@ -0,0 +1,16 @@ +Statement block - Gen - 38 - (0:0,0) + Code span - Gen - [foreach(var f in Foo) { /* foo bar baz] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:14 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[f]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[in]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[/* foo bar baz];RZ1001(24:0,24 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.cspans.txt new file mode 100644 index 0000000000..d4f90972e4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [15] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [15] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.diag.txt new file mode 100644 index 0000000000..a40df1a410 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.stree.txt new file mode 100644 index 0000000000..74aaae6293 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.stree.txt @@ -0,0 +1,11 @@ +Expression block - Gen - 15 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [Html.En(code()] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:7 + CSharpTokenType.Identifier;[Html]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[En]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[code]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..77e1f6ca0b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [38] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.diag.txt new file mode 100644 index 0000000000..ad3a00985c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The foreach block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.stree.txt new file mode 100644 index 0000000000..132a174cc4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.stree.txt @@ -0,0 +1,16 @@ +Statement block - Gen - 38 - (0:0,0) + Code span - Gen - [foreach(var f in Foo) { // foo bar baz] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:14 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[f]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[in]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[// foo bar baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..4e5b53d801 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [37] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [37] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.diag.txt new file mode 100644 index 0000000000..ad3a00985c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The foreach block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.stree.txt new file mode 100644 index 0000000000..fc3d51a91d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.stree.txt @@ -0,0 +1,22 @@ +Statement block - Gen - 37 - (0:0,0) + Code span - Gen - [foreach(var f in Foo) { / foo bar baz] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:20 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[f]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[in]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Slash;[/]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.cspans.txt new file mode 100644 index 0000000000..04f904b866 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [25] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.stree.txt new file mode 100644 index 0000000000..96f6f0f501 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.stree.txt @@ -0,0 +1,4 @@ +Statement block - Gen - 25 - (0:0,0) + Code span - Gen - [using ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:2 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.cspans.txt new file mode 100644 index 0000000000..1f1ddc2455 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [44] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.stree.txt new file mode 100644 index 0000000000..d1aea3ef3c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.stree.txt @@ -0,0 +1,18 @@ +Statement block - Gen - 44 - (0:0,0) + Code span - Gen - [lock(foo) { Debug.WriteLine(@"foo } bar"); }] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:16 + CSharpTokenType.Keyword;[lock]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Debug]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WriteLine]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"foo } bar"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.cspans.txt new file mode 100644 index 0000000000..232bc6c829 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.cspans.txt @@ -0,0 +1,3 @@ +Code span at (0:0,0 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +Code span at (10:0,10 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +Code span at (11:0,11 [16] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.stree.txt new file mode 100644 index 0000000000..2adfba5136 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.stree.txt @@ -0,0 +1,22 @@ +Statement block - Gen - 27 - (0:0,0) + Code span - Gen - [if(foo) { ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:7 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [@] - SpanEditHandler;Accepts:Any - (10:0,10) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [@@@class.Foo() }] - SpanEditHandler;Accepts:Any - (11:0,11) - Tokens:10 + CSharpTokenType.Transition;[@]; + CSharpTokenType.Transition;[@]; + CSharpTokenType.Transition;[@]; + CSharpTokenType.Keyword;[class]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.cspans.txt new file mode 100644 index 0000000000..bb97b9e592 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.cspans.txt @@ -0,0 +1,3 @@ +Code span at (0:0,0 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +Code span at (10:0,10 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +Code span at (11:0,11 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.stree.txt new file mode 100644 index 0000000000..2b2e1a980f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.stree.txt @@ -0,0 +1,20 @@ +Statement block - Gen - 25 - (0:0,0) + Code span - Gen - [if(foo) { ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:7 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [@] - SpanEditHandler;Accepts:Any - (10:0,10) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [@class.Foo() }] - SpanEditHandler;Accepts:Any - (11:0,11) - Tokens:8 + CSharpTokenType.Transition;[@]; + CSharpTokenType.Keyword;[class]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..906a1b4413 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.cspans.txt @@ -0,0 +1,10 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [20] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [12] ) +Markup span at (12:0,12 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [2] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [2] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [12] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [12] ) +Markup span at (18:0,18 [3] ) (Accepts:None) - Parent: Tag block at (1:0,1 [20] ) +Code span at (21:0,21 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..ac7bda2f5e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.stree.txt @@ -0,0 +1,31 @@ +Statement block - Gen - 22 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 20 - (1:0,1) + Tag block - Gen - 20 - (1:0,1) + Markup span - Gen - [ - 12 - (6:0,6) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (6:0,6) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 2 - (12:0,12) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [def] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.Text;[def]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:None - (18:0,18) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (21:0,21) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..372c36c8ed --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.cspans.txt @@ -0,0 +1,10 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [20] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [12] ) +Markup span at (12:0,12 [3] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [12] ) +Markup span at (15:0,15 [1] ) (Accepts:None) - Parent: Markup block at (15:0,15 [2] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Markup block at (15:0,15 [2] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [12] ) +Markup span at (18:0,18 [3] ) (Accepts:None) - Parent: Tag block at (1:0,1 [20] ) +Code span at (21:0,21 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..d7426b2aac --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.stree.txt @@ -0,0 +1,31 @@ +Statement block - Gen - 22 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 20 - (1:0,1) + Tag block - Gen - 20 - (1:0,1) + Markup span - Gen - [ - 12 - (6:0,6) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (6:0,6) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [abc] - SpanEditHandler;Accepts:Any - (12:0,12) - Tokens:1 + HtmlTokenType.Text;[abc]; + Markup block - Gen - 2 - (15:0,15) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:None - (18:0,18) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (21:0,21) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..ac10d80167 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.cspans.txt @@ -0,0 +1,11 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [25] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [17] ) +Markup span at (12:0,12 [3] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [17] ) +Markup span at (15:0,15 [2] ) (Accepts:None) - Parent: Markup block at (15:0,15 [3] ) +Markup span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (15:0,15 [3] ) +Markup span at (18:0,18 [4] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [17] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [17] ) +Markup span at (23:0,23 [3] ) (Accepts:None) - Parent: Tag block at (1:0,1 [25] ) +Code span at (26:0,26 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..6ec5d3f78a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.stree.txt @@ -0,0 +1,35 @@ +Statement block - Gen - 27 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 25 - (1:0,1) + Tag block - Gen - 25 - (1:0,1) + Markup span - Gen - [ - 17 - (6:0,6) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (6:0,6) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [abc] - SpanEditHandler;Accepts:Any - (12:0,12) - Tokens:1 + HtmlTokenType.Text;[abc]; + Markup block - Gen - 3 - (15:0,15) + Markup span - Gen - [ @] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (17:0,17) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [ def] - SpanEditHandler;Accepts:Any - (18:0,18) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[def]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (22:0,22) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:None - (23:0,23) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (26:0,26) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (26:0,26) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..def3facc07 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.cspans.txt @@ -0,0 +1,9 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [17] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [9] ) +Markup span at (12:0,12 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [2] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [2] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [9] ) +Markup span at (15:0,15 [3] ) (Accepts:None) - Parent: Tag block at (1:0,1 [17] ) +Code span at (18:0,18 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (18:0,18 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..89200d1412 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.stree.txt @@ -0,0 +1,29 @@ +Statement block - Gen - 19 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 17 - (1:0,1) + Tag block - Gen - 17 - (1:0,1) + Markup span - Gen - [ - 9 - (6:0,6) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (6:0,6) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 2 - (12:0,12) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (18:0,18) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (18:0,18) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..97ddd7c53d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.cspans.txt @@ -0,0 +1,14 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [42] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [34] ) +Markup span at (12:0,12 [11] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [34] ) +Markup span at (23:0,23 [4] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [34] ) +Markup span at (27:0,27 [1] ) (Accepts:None) - Parent: Markup block at (27:0,27 [2] ) +Markup span at (28:0,28 [1] ) (Accepts:None) - Parent: Markup block at (27:0,27 [2] ) +Markup span at (29:0,29 [7] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [34] ) +Markup span at (36:0,36 [2] ) (Accepts:None) - Parent: Markup block at (36:0,36 [3] ) +Markup span at (38:0,38 [1] ) (Accepts:None) - Parent: Markup block at (36:0,36 [3] ) +Markup span at (39:0,39 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [34] ) +Markup span at (40:0,40 [3] ) (Accepts:None) - Parent: Tag block at (1:0,1 [42] ) +Code span at (43:0,43 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [44] ) +MetaCode span at (43:0,43 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..5ff6c98e4d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.stree.txt @@ -0,0 +1,42 @@ +Statement block - Gen - 44 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 42 - (1:0,1) + Tag block - Gen - 42 - (1:0,1) + Markup span - Gen - [ - 34 - (6:0,6) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (6:0,6) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [abc@def.com] - SpanEditHandler;Accepts:Any - (12:0,12) - Tokens:1 + HtmlTokenType.Text;[abc@def.com]; + Markup span - Gen - [ abc] - SpanEditHandler;Accepts:Any - (23:0,23) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[abc]; + Markup block - Gen - 2 - (27:0,27) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (27:0,27) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (28:0,28) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [def.com] - SpanEditHandler;Accepts:Any - (29:0,29) - Tokens:1 + HtmlTokenType.Text;[def.com]; + Markup block - Gen - 3 - (36:0,36) + Markup span - Gen - [ @] - SpanEditHandler;Accepts:None - (36:0,36) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (38:0,38) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (39:0,39) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:None - (40:0,40) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (43:0,43) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (43:0,43) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..35ae9731f0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.cspans.txt @@ -0,0 +1,11 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [117] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [115] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [107] ) +Markup span at (12:0,12 [32] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [107] ) +Markup span at (44:0,44 [1] ) (Accepts:None) - Parent: Markup block at (44:0,44 [2] ) +Markup span at (45:0,45 [1] ) (Accepts:None) - Parent: Markup block at (44:0,44 [2] ) +Markup span at (46:0,46 [66] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [107] ) +Markup span at (112:0,112 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [107] ) +Markup span at (113:0,113 [3] ) (Accepts:None) - Parent: Tag block at (1:0,1 [115] ) +Code span at (116:0,116 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [117] ) +MetaCode span at (116:0,116 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [117] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..ae6eb40508 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.stree.txt @@ -0,0 +1,75 @@ +Statement block - Gen - 117 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 115 - (1:0,1) + Tag block - Gen - 115 - (1:0,1) + Markup span - Gen - [ - 107 - (6:0,6) + Markup span - Gen - [ foo="] - SpanEditHandler;Accepts:Any - (6:0,6) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.DoubleQuote;["]; + Markup span - Gen - [/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+] - SpanEditHandler;Accepts:Any - (12:0,12) - Tokens:14 + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[^]; + HtmlTokenType.LeftBracket;[[]; + HtmlTokenType.Text;[a-z0-9]; + HtmlTokenType.Bang;[!]; + HtmlTokenType.Text;[#$%&]; + HtmlTokenType.SingleQuote;[']; + HtmlTokenType.Text;[*+\]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.QuestionMark;[?]; + HtmlTokenType.Text;[^_`{|}~.-]; + HtmlTokenType.RightBracket;[]]; + HtmlTokenType.Text;[+]; + Markup block - Gen - 2 - (44:0,44) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (44:0,44) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (45:0,45) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i] - SpanEditHandler;Accepts:Any - (46:0,46) - Tokens:30 + HtmlTokenType.LeftBracket;[[]; + HtmlTokenType.Text;[a-z0-9]; + HtmlTokenType.RightBracket;[]]; + HtmlTokenType.Text;[(]; + HtmlTokenType.LeftBracket;[[]; + HtmlTokenType.Text;[a-z0-9-]; + HtmlTokenType.RightBracket;[]]; + HtmlTokenType.Text;[*]; + HtmlTokenType.LeftBracket;[[]; + HtmlTokenType.Text;[a-z0-9]; + HtmlTokenType.RightBracket;[]]; + HtmlTokenType.Text;[)]; + HtmlTokenType.QuestionMark;[?]; + HtmlTokenType.Text;[\.(]; + HtmlTokenType.LeftBracket;[[]; + HtmlTokenType.Text;[a-z0-9]; + HtmlTokenType.RightBracket;[]]; + HtmlTokenType.Text;[(]; + HtmlTokenType.LeftBracket;[[]; + HtmlTokenType.Text;[a-z0-9-]; + HtmlTokenType.RightBracket;[]]; + HtmlTokenType.Text;[*]; + HtmlTokenType.LeftBracket;[[]; + HtmlTokenType.Text;[a-z0-9]; + HtmlTokenType.RightBracket;[]]; + HtmlTokenType.Text;[)]; + HtmlTokenType.QuestionMark;[?]; + HtmlTokenType.Text;[)*$]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[i]; + Markup span - Gen - ["] - SpanEditHandler;Accepts:Any - (112:0,112) - Tokens:1 + HtmlTokenType.DoubleQuote;["]; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:None - (113:0,113) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (116:0,116) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (116:0,116) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..6f209128d6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.cspans.txt @@ -0,0 +1,44 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [120] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [118] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [15] ) +Markup span at (12:0,12 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [2] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [2] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [6] ) +Transition span at (14:0,14 [1] ) (Accepts:None) - Parent: Expression block at (14:0,14 [6] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (14:0,14 [6] ) +Code span at (16:0,16 [3] ) (Accepts:Any) - Parent: Expression block at (14:0,14 [6] ) +MetaCode span at (19:0,19 [1] ) (Accepts:None) - Parent: Expression block at (14:0,14 [6] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [15] ) +Markup span at (21:0,21 [6] ) (Accepts:Any) - Parent: Markup block at (21:0,21 [28] ) +Transition span at (27:0,27 [1] ) (Accepts:None) - Parent: Expression block at (27:0,27 [6] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Expression block at (27:0,27 [6] ) +Code span at (29:0,29 [3] ) (Accepts:Any) - Parent: Expression block at (27:0,27 [6] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Expression block at (27:0,27 [6] ) +Markup span at (33:0,33 [1] ) (Accepts:None) - Parent: Markup block at (33:0,33 [2] ) +Markup span at (34:0,34 [1] ) (Accepts:None) - Parent: Markup block at (33:0,33 [2] ) +Markup span at (35:0,35 [0] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [13] ) +Transition span at (35:0,35 [1] ) (Accepts:None) - Parent: Expression block at (35:0,35 [13] ) +Code span at (36:0,36 [12] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (35:0,35 [13] ) +Markup span at (48:0,48 [1] ) (Accepts:Any) - Parent: Markup block at (21:0,21 [28] ) +Markup span at (49:0,49 [6] ) (Accepts:Any) - Parent: Markup block at (49:0,49 [22] ) +Transition span at (55:0,55 [1] ) (Accepts:None) - Parent: Expression block at (55:0,55 [13] ) +Code span at (56:0,56 [12] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (55:0,55 [13] ) +Markup span at (68:0,68 [1] ) (Accepts:None) - Parent: Markup block at (68:0,68 [2] ) +Markup span at (69:0,69 [1] ) (Accepts:None) - Parent: Markup block at (68:0,68 [2] ) +Markup span at (70:0,70 [1] ) (Accepts:Any) - Parent: Markup block at (49:0,49 [22] ) +Markup span at (71:0,71 [6] ) (Accepts:Any) - Parent: Markup block at (71:0,71 [23] ) +Transition span at (77:0,77 [1] ) (Accepts:None) - Parent: Expression block at (77:0,77 [13] ) +Code span at (78:0,78 [12] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (77:0,77 [13] ) +Markup span at (90:0,90 [2] ) (Accepts:None) - Parent: Markup block at (90:0,90 [3] ) +Markup span at (92:0,92 [1] ) (Accepts:None) - Parent: Markup block at (90:0,90 [3] ) +Markup span at (93:0,93 [1] ) (Accepts:Any) - Parent: Markup block at (71:0,71 [23] ) +Markup span at (94:0,94 [6] ) (Accepts:Any) - Parent: Markup block at (94:0,94 [22] ) +Markup span at (100:0,100 [1] ) (Accepts:None) - Parent: Markup block at (100:0,100 [2] ) +Markup span at (101:0,101 [1] ) (Accepts:None) - Parent: Markup block at (100:0,100 [2] ) +Markup span at (102:0,102 [0] ) (Accepts:Any) - Parent: Markup block at (102:0,102 [13] ) +Transition span at (102:0,102 [1] ) (Accepts:None) - Parent: Expression block at (102:0,102 [13] ) +Code span at (103:0,103 [12] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (102:0,102 [13] ) +Markup span at (115:0,115 [1] ) (Accepts:Any) - Parent: Markup block at (94:0,94 [22] ) +Markup span at (116:0,116 [3] ) (Accepts:None) - Parent: Tag block at (1:0,1 [118] ) +Code span at (119:0,119 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [120] ) +MetaCode span at (119:0,119 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [120] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..c50182aa59 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.stree.txt @@ -0,0 +1,144 @@ +Statement block - Gen - 120 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 118 - (1:0,1) + Tag block - Gen - 118 - (1:0,1) + Markup span - Gen - [ - 15 - (6:0,6) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (6:0,6) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 2 - (12:0,12) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup block - Gen - 6 - (14:0,14) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 6 - (14:0,14) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (14:0,14) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [2+3] - SpanEditHandler;Accepts:Any - (16:0,16) - Tokens:3 + CSharpTokenType.IntegerLiteral;[2]; + CSharpTokenType.Plus;[+]; + CSharpTokenType.IntegerLiteral;[3]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (19:0,19) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (20:0,20) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 28 - (21:0,21) + Markup span - Gen - [ bar='] - SpanEditHandler;Accepts:Any - (21:0,21) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[bar]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 6 - (27:0,27) + Expression block - Gen - 6 - (27:0,27) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (27:0,27) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (28:0,28) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [2+3] - SpanEditHandler;Accepts:Any - (29:0,29) - Tokens:3 + CSharpTokenType.IntegerLiteral;[2]; + CSharpTokenType.Plus;[+]; + CSharpTokenType.IntegerLiteral;[3]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (32:0,32) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; + Markup block - Gen - 2 - (33:0,33) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (33:0,33) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (34:0,34) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup block - Gen - 13 - (35:0,35) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (35:0,35) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 13 - (35:0,35) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (35:0,35) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [DateTime.Now] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (36:0,36) - Tokens:3 + CSharpTokenType.Identifier;[DateTime]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Now]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (48:0,48) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 22 - (49:0,49) + Markup span - Gen - [ baz='] - SpanEditHandler;Accepts:Any - (49:0,49) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[baz]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 13 - (55:0,55) + Expression block - Gen - 13 - (55:0,55) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (55:0,55) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [DateTime.Now] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (56:0,56) - Tokens:3 + CSharpTokenType.Identifier;[DateTime]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Now]; + Markup block - Gen - 2 - (68:0,68) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (68:0,68) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (69:0,69) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (70:0,70) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 23 - (71:0,71) + Markup span - Gen - [ bat='] - SpanEditHandler;Accepts:Any - (71:0,71) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[bat]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 13 - (77:0,77) + Expression block - Gen - 13 - (77:0,77) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (77:0,77) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [DateTime.Now] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (78:0,78) - Tokens:3 + CSharpTokenType.Identifier;[DateTime]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Now]; + Markup block - Gen - 3 - (90:0,90) + Markup span - Gen - [ @] - SpanEditHandler;Accepts:None - (90:0,90) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (92:0,92) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (93:0,93) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 22 - (94:0,94) + Markup span - Gen - [ zoo='] - SpanEditHandler;Accepts:Any - (94:0,94) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[zoo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 2 - (100:0,100) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (100:0,100) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (101:0,101) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup block - Gen - 13 - (102:0,102) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (102:0,102) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 13 - (102:0,102) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (102:0,102) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [DateTime.Now] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (103:0,103) - Tokens:3 + CSharpTokenType.Identifier;[DateTime]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Now]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (115:0,115) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:None - (116:0,116) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (119:0,119) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (119:0,119) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.cspans.txt new file mode 100644 index 0000000000..d8f8c09b0c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.cspans.txt @@ -0,0 +1,6 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [14] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [13] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [8] ) +Markup span at (12:0,12 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [2] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [2] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (1:0,1 [13] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.diag.txt new file mode 100644 index 0000000000..24f11b3532 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.diag.txt @@ -0,0 +1,2 @@ +(1,3): Error RZ1024: End of file or an unexpected character was reached before the "span" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
            ") or have matching end tags ("

            Hello

            "). If you intended to display a "<" character, use the "<" HTML entity. +(1,1): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.stree.txt new file mode 100644 index 0000000000..2f4c6d6bfd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.stree.txt @@ -0,0 +1,21 @@ +Statement block - Gen - 14 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 13 - (1:0,1) + Tag block - Gen - 13 - (1:0,1) + Markup span - Gen - [ - 2 - (12:0,12) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.cspans.txt new file mode 100644 index 0000000000..0625febbf9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.cspans.txt @@ -0,0 +1,12 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [18] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [10] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [1] ) +Code span at (13:0,13 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (12:0,12 [1] ) +Markup span at (13:0,13 [1] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [2] ) +Transition span at (14:0,14 [1] ) (Accepts:None) - Parent: Expression block at (14:0,14 [1] ) +Code span at (15:0,15 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (14:0,14 [1] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [10] ) +Markup span at (16:0,16 [3] ) (Accepts:None) - Parent: Tag block at (1:0,1 [18] ) +Code span at (19:0,19 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (19:0,19 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.diag.txt new file mode 100644 index 0000000000..cbdffd5de4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.diag.txt @@ -0,0 +1,2 @@ +(1,14): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. +(1,16): Error RZ1005: "' />}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt new file mode 100644 index 0000000000..cfd73bfa96 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt @@ -0,0 +1,38 @@ +Statement block - Gen - 20 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 18 - (1:0,1) + Tag block - Gen - 18 - (1:0,1) + Markup span - Gen - [ - 10 - (6:0,6) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (6:0,6) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 1 - (12:0,12) + Expression block - Gen - 1 - (12:0,12) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (13:0,13) - Tokens:1 + CSharpTokenType.Unknown;[]; + Markup block - Gen - 2 - (13:0,13) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (13:0,13) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Expression block - Gen - 1 - (14:0,14) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (14:0,14) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (15:0,15) - Tokens:1 + CSharpTokenType.Unknown;[]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (15:0,15) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (19:0,19) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (19:0,19) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..8fa8983d5e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +Code span at (14:0,14 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [18] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..93afe6d654 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,10 @@ +Directive block - Gen - 18 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo"] - SpanEditHandler;Accepts:AnyExceptNewline - (14:0,14) - Tokens:2 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.StringLiteral;["];RZ1000(17:0,17 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.cspans.txt new file mode 100644 index 0000000000..46934861be --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (14:0,14 [3] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.stree.txt new file mode 100644 index 0000000000..c6f41fdd2d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo] - SpanEditHandler;Accepts:AnyExceptNewline - (14:0,14) - Tokens:1 + CSharpTokenType.Identifier;[Foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_NoValue_Invalid.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_NoValue_Invalid.cspans.txt new file mode 100644 index 0000000000..6691c76927 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_NoValue_Invalid.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Code span at (14:0,14 [2] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [16] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_NoValue_Invalid.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_NoValue_Invalid.stree.txt new file mode 100644 index 0000000000..2008fd4abe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_NoValue_Invalid.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 16 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [""] - SpanEditHandler;Accepts:AnyExceptNewline - (14:0,14) - Tokens:1 + CSharpTokenType.StringLiteral;[""]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_RequiresValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_RequiresValue.cspans.txt new file mode 100644 index 0000000000..b1d833a6db --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_RequiresValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Code span at (14:0,14 [0] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [14] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_RequiresValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_RequiresValue.stree.txt new file mode 100644 index 0000000000..f3c8121f69 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_RequiresValue.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 14 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [] - SpanEditHandler;Accepts:AnyExceptNewline - (14:0,14) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.cspans.txt new file mode 100644 index 0000000000..2739fb7f95 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Code span at (14:0,14 [8] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.stree.txt new file mode 100644 index 0000000000..38b2a96f76 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ['*, Foo'] - SpanEditHandler;Accepts:AnyExceptNewline - (14:0,14) - Tokens:1 + CSharpTokenType.CharacterLiteral;['*, Foo']; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..8fa8983d5e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +Code span at (14:0,14 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [18] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..1067f0e6c2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 18 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Foo] - SpanEditHandler;Accepts:AnyExceptNewline - (14:0,14) - Tokens:1 + CSharpTokenType.StringLiteral;["Foo];RZ1000(14:0,14 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SupportsSpaces.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SupportsSpaces.cspans.txt new file mode 100644 index 0000000000..a4a9f85b10 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SupportsSpaces.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (13:0,13 [5] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Code span at (18:0,18 [14] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [32] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SupportsSpaces.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SupportsSpaces.stree.txt new file mode 100644 index 0000000000..7b55abb278 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_SupportsSpaces.stree.txt @@ -0,0 +1,13 @@ +Directive block - Gen - 32 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo, Bar ] - SpanEditHandler;Accepts:AnyExceptNewline - (18:0,18) - Tokens:5 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt new file mode 100644 index 0000000000..7868088eef --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (14:0,14 [5] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt new file mode 100644 index 0000000000..bae8b5002c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 19 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Foo"] - SpanEditHandler;Accepts:AnyExceptNewline - (14:0,14) - Tokens:1 + CSharpTokenType.StringLiteral;["Foo"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt new file mode 100644 index 0000000000..dd5b3b78c7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt @@ -0,0 +1,5 @@ +Code span at (0:0,0 [4] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [26] ) +Transition span at (4:1,2 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (5:1,3 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (17:1,15 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Code span at (18:1,16 [8] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [26] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt new file mode 100644 index 0000000000..642f0611e8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt @@ -0,0 +1,12 @@ +Directive block - Gen - 26 - (0:0,0) + Code span - Gen - [LF ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:2 + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (4:1,2) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (5:1,3) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (17:1,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["*, Foo"] - SpanEditHandler;Accepts:AnyExceptNewline - (18:1,16) - Tokens:1 + CSharpTokenType.StringLiteral;["*, Foo"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.cspans.txt new file mode 100644 index 0000000000..a5e15b9d8e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.cspans.txt @@ -0,0 +1,8 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Code span at (1:0,1 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Directive block at (3:0,3 [22] ) +MetaCode span at (4:0,4 [12] ) (Accepts:None) - Parent: Directive block at (3:0,3 [22] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (3:0,3 [22] ) +Code span at (17:0,17 [8] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (3:0,3 [22] ) +Code span at (25:0,25 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +MetaCode span at (27:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.stree.txt new file mode 100644 index 0000000000..2d4ada75c3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.stree.txt @@ -0,0 +1,18 @@ +Statement block - Gen - 28 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Directive block - Gen - 22 - (3:0,3) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (3:0,3) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [addTagHelper] - SpanEditHandler;Accepts:None - (4:0,4) - Tokens:1 + CSharpTokenType.Identifier;[addTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["*, Foo"] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.StringLiteral;["*, Foo"]; + Code span - Gen - [LF] - SpanEditHandler;Accepts:Any - (25:0,25) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (27:1,0) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.cspans.txt new file mode 100644 index 0000000000..39e6ab11a0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.cspans.txt @@ -0,0 +1,14 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [176] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [176] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (15:0,15 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (16:0,16 [9] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (25:0,25 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (26:0,26 [21] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (47:0,47 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (48:0,48 [29] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (77:0,77 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (78:0,78 [31] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (109:0,109 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (110:0,110 [66] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [176] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.stree.txt new file mode 100644 index 0000000000..9c4daa1e93 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.stree.txt @@ -0,0 +1,71 @@ +Directive block - Gen - 176 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [string?] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:2 + CSharpTokenType.Keyword;[string]; + CSharpTokenType.QuestionMark;[?]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [string?[]] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (16:0,16) - Tokens:4 + CSharpTokenType.Keyword;[string]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.RightBracket;[]]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (25:0,25) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [global::System.Int32?] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (26:0,26) - Tokens:6 + CSharpTokenType.Identifier;[global]; + CSharpTokenType.DoubleColon;[::]; + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Int32]; + CSharpTokenType.QuestionMark;[?]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (47:0,47) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [KeyValuePair?] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (48:0,48) - Tokens:8 + CSharpTokenType.Identifier;[KeyValuePair]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.QuestionMark;[?]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (77:0,77) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [KeyValuePair?[]] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (78:0,78) - Tokens:10 + CSharpTokenType.Identifier;[KeyValuePair]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.RightBracket;[]]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (109:0,109) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [global::System.Collections.Generic.KeyValuePair?[]] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (110:0,110) - Tokens:18 + CSharpTokenType.Identifier;[global]; + CSharpTokenType.DoubleColon;[::]; + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Collections]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Generic]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[KeyValuePair]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.RightBracket;[]]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.cspans.txt new file mode 100644 index 0000000000..0ab29a7f29 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.cspans.txt @@ -0,0 +1,14 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [246] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [246] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (8:0,8 [11] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (19:0,19 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (20:0,20 [20] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (40:0,40 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (41:0,41 [29] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (70:0,70 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (71:0,71 [37] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (108:0,108 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (109:0,109 [36] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (145:0,145 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (146:0,146 [100] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [246] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.stree.txt new file mode 100644 index 0000000000..f9e21e7409 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.stree.txt @@ -0,0 +1,155 @@ +Directive block - Gen - 246 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [(bool, int)] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:6 + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[bool]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.RightParenthesis;[)]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (19:0,19) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [(int aa, string bb)?] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (20:0,20) - Tokens:11 + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[aa]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bb]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.QuestionMark;[?]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (40:0,40) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [( int? q , bool w )] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (41:0,41) - Tokens:14 + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[q]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[bool]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[w]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightParenthesis;[)]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (70:0,70) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [( int ? q, bool ?w ,(long ? [])) ?] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (71:0,71) - Tokens:26 + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[q]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[bool]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Identifier;[w]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[long]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.QuestionMark;[?]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (108:0,108) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [(List<(int, string)?> aa, string bb)] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (109:0,109) - Tokens:19 + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[List]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[aa]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bb]; + CSharpTokenType.RightParenthesis;[)]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (145:0,145) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [(string ss, (int u, List<(string, int)> k, (Char c, bool b, List l)), global::System.Int32[] a)] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (146:0,146) - Tokens:56 + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[ss]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[u]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[List]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[k]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Char]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[c]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[bool]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[b]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[List]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[l]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[global]; + CSharpTokenType.DoubleColon;[::]; + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Int32]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[a]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.cspans.txt new file mode 100644 index 0000000000..38b5d16324 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.cspans.txt @@ -0,0 +1,5 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [23] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [23] ) +Code span at (8:0,8 [12] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [23] ) +None span at (20:0,20 [3] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [23] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.stree.txt new file mode 100644 index 0000000000..6116fb54b7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.stree.txt @@ -0,0 +1,17 @@ +Directive block - Gen - 23 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [(bool, int?)] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:7 + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[bool]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.RightParenthesis;[)]; + None span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (20:0,20) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.cspans.txt new file mode 100644 index 0000000000..50c951eaaa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.cspans.txt @@ -0,0 +1,7 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +Code span at (7:0,7 [4] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [67] ) +Code span at (11:0,11 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [67] ) +Code span at (45:0,45 [7] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [67] ) +Code span at (52:0,52 [11] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [67] ) +None span at (63:0,63 [4] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [67] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.stree.txt new file mode 100644 index 0000000000..28cca39386 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.stree.txt @@ -0,0 +1,21 @@ +Directive block - Gen - 67 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (11:0,11) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (45:0,45) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Some_Member] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (52:0,52) - Tokens:1 + CSharpTokenType.Identifier;[Some_Member]; + None span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (63:0,63) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.cspans.txt new file mode 100644 index 0000000000..f8535e27f8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.stree.txt new file mode 100644 index 0000000000..1fee4f1796 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.cspans.txt new file mode 100644 index 0000000000..f8535e27f8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.stree.txt new file mode 100644 index 0000000000..1fee4f1796 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.cspans.txt new file mode 100644 index 0000000000..f8535e27f8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.stree.txt new file mode 100644 index 0000000000..1fee4f1796 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.cspans.txt new file mode 100644 index 0000000000..f8535e27f8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.stree.txt new file mode 100644 index 0000000000..1fee4f1796 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.cspans.txt new file mode 100644 index 0000000000..08eda0a4f3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.cspans.txt @@ -0,0 +1,5 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +None span at (15:0,15 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [16] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.stree.txt new file mode 100644 index 0000000000..b108f825f7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.stree.txt @@ -0,0 +1,11 @@ +Directive block - Gen - 16 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["hello"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["hello"]; + None span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.cspans.txt new file mode 100644 index 0000000000..f8535e27f8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.stree.txt new file mode 100644 index 0000000000..66c8f9e22b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.cspans.txt new file mode 100644 index 0000000000..41583f7ddd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [15] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [15] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.stree.txt new file mode 100644 index 0000000000..785e17335e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 15 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Hello"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["Hello"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.cspans.txt new file mode 100644 index 0000000000..a1cf9382b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.cspans.txt @@ -0,0 +1,5 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (15:0,15 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [16] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.stree.txt new file mode 100644 index 0000000000..d4346b5102 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.stree.txt @@ -0,0 +1,11 @@ +Directive block - Gen - 16 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Hello"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["Hello"]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.cspans.txt new file mode 100644 index 0000000000..2bd242fa71 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.cspans.txt @@ -0,0 +1,7 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (15:0,15 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (17:0,17 [0] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.stree.txt new file mode 100644 index 0000000000..15be232395 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.stree.txt @@ -0,0 +1,15 @@ +Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Hello"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["Hello"]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (16:0,16) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [] - CodeBlockEditHandler;Accepts:Any;CodeBlock - (17:0,17) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.cspans.txt new file mode 100644 index 0000000000..04bf3c5828 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (42:0,42 [2] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:1,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (44:1,0 [1] ) (Accepts:None) - Parent: Directive block at (44:1,0 [41] ) +MetaCode span at (45:1,1 [6] ) (Accepts:None) - Parent: Directive block at (44:1,0 [41] ) +Code span at (51:1,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (44:1,0 [41] ) +Code span at (52:1,8 [33] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (44:1,0 [41] ) +Markup span at (85:1,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.stree.txt new file mode 100644 index 0000000000..f9f16307e7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.stree.txt @@ -0,0 +1,39 @@ +Markup block - Gen - 85 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 44 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:WhiteSpace - (42:0,42) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (44:1,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 41 - (44:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (44:1,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (45:1,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (51:1,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.UTF8Encoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (52:1,8) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[UTF8Encoding]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (85:1,41) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.cspans.txt new file mode 100644 index 0000000000..04bf3c5828 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (42:0,42 [2] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:1,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (44:1,0 [1] ) (Accepts:None) - Parent: Directive block at (44:1,0 [41] ) +MetaCode span at (45:1,1 [6] ) (Accepts:None) - Parent: Directive block at (44:1,0 [41] ) +Code span at (51:1,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (44:1,0 [41] ) +Code span at (52:1,8 [33] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (44:1,0 [41] ) +Markup span at (85:1,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.stree.txt new file mode 100644 index 0000000000..ed97532104 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.stree.txt @@ -0,0 +1,39 @@ +Markup block - Gen - 85 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 44 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:WhiteSpace - (42:0,42) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (44:1,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 41 - (44:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (44:1,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (45:1,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (51:1,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.UTF8Encoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (52:1,8) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[UTF8Encoding]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (85:1,41) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.cspans.txt new file mode 100644 index 0000000000..0d5ab809f3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (42:0,42 [2] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:1,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Transition span at (44:1,0 [1] ) (Accepts:None) - Parent: Directive block at (44:1,0 [15] ) +MetaCode span at (45:1,1 [9] ) (Accepts:None) - Parent: Directive block at (44:1,0 [15] ) +Code span at (54:1,10 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (44:1,0 [15] ) +Code span at (55:1,11 [4] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (44:1,0 [15] ) +Markup span at (59:1,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.stree.txt new file mode 100644 index 0000000000..dabeb41382 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.stree.txt @@ -0,0 +1,33 @@ +Markup block - Gen - 59 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 44 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:WhiteSpace - (42:0,42) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (44:1,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 15 - (44:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (44:1,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [something] - SpanEditHandler;Accepts:None - (45:1,1) - Tokens:1 + CSharpTokenType.Identifier;[something]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (54:1,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Else] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (55:1,11) - Tokens:1 + CSharpTokenType.Identifier;[Else]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (59:1,15) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.cspans.txt new file mode 100644 index 0000000000..a345090d3e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.cspans.txt @@ -0,0 +1,22 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [43] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [43] ) +Comment span at (2:0,2 [39] ) (Accepts:Any) - Parent: Comment block at (0:0,0 [43] ) +MetaCode span at (41:0,41 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [43] ) +Transition span at (42:0,42 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [43] ) +Markup span at (43:0,43 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Transition span at (45:1,0 [1] ) (Accepts:None) - Parent: Directive block at (45:1,0 [44] ) +MetaCode span at (46:1,1 [6] ) (Accepts:None) - Parent: Directive block at (45:1,0 [44] ) +Code span at (52:1,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (45:1,0 [44] ) +Code span at (53:1,8 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (45:1,0 [44] ) +Markup span at (87:1,42 [2] ) (Accepts:WhiteSpace) - Parent: Directive block at (45:1,0 [44] ) +Markup span at (89:2,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Transition span at (91:3,0 [1] ) (Accepts:None) - Parent: Directive block at (91:3,0 [17] ) +MetaCode span at (92:3,1 [9] ) (Accepts:None) - Parent: Directive block at (91:3,0 [17] ) +Code span at (101:3,10 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (91:3,0 [17] ) +Code span at (102:3,11 [4] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (91:3,0 [17] ) +Markup span at (106:3,15 [2] ) (Accepts:WhiteSpace) - Parent: Directive block at (91:3,0 [17] ) +Markup span at (108:4,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Markup span at (110:5,0 [3] ) (Accepts:Any) - Parent: Tag block at (110:5,0 [3] ) +Markup span at (113:5,3 [13] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Markup span at (126:5,16 [4] ) (Accepts:Any) - Parent: Tag block at (126:5,16 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.stree.txt new file mode 100644 index 0000000000..203fd7aee0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.stree.txt @@ -0,0 +1,65 @@ +Markup block - Gen - 130 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Comment block - Gen - 43 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ There are two directives beneath this ] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + HtmlTokenType.RazorComment;[ There are two directives beneath this ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (41:0,41) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (42:0,42) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (43:0,43) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Directive block - Gen - 44 - (45:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (45:1,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (46:1,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (52:1,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (53:1,8) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:WhiteSpace - (87:1,42) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (89:2,0) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Directive block - Gen - 17 - (91:3,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (91:3,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [something] - SpanEditHandler;Accepts:None - (92:3,1) - Tokens:1 + CSharpTokenType.Identifier;[something]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (101:3,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Else] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (102:3,11) - Tokens:1 + CSharpTokenType.Identifier;[Else]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:WhiteSpace - (106:3,15) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (108:4,0) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 3 - (110:5,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (110:5,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [This is extra] - SpanEditHandler;Accepts:Any - (113:5,3) - Tokens:5 + HtmlTokenType.Text;[This]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[is]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[extra]; + Tag block - Gen - 4 - (126:5,16) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (126:5,16) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.cspans.txt new file mode 100644 index 0000000000..e25b16bc6a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.cspans.txt @@ -0,0 +1,7 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [19] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [19] ) +None span at (15:0,15 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (16:0,16 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (17:0,17 [2] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.stree.txt new file mode 100644 index 0000000000..6feb3829cd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.stree.txt @@ -0,0 +1,15 @@ +Directive block - Gen - 19 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["hello"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["hello"]; + None span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [;] - SpanEditHandler;Accepts:WhiteSpace - (16:0,16) - Tokens:1 + CSharpTokenType.Semicolon;[;]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (17:0,17) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.cspans.txt new file mode 100644 index 0000000000..f1fd6cb92b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.stree.txt new file mode 100644 index 0000000000..8dfad4bd3c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.cspans.txt new file mode 100644 index 0000000000..f1fd6cb92b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.stree.txt new file mode 100644 index 0000000000..fd51b1bf91 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.cspans.txt new file mode 100644 index 0000000000..f1fd6cb92b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.stree.txt new file mode 100644 index 0000000000..b65823863d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.cspans.txt new file mode 100644 index 0000000000..f1fd6cb92b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.stree.txt new file mode 100644 index 0000000000..fd51b1bf91 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.cspans.txt new file mode 100644 index 0000000000..de1247ad81 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [9] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.stree.txt new file mode 100644 index 0000000000..7c8de4fbc1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["string1"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["string1"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.cspans.txt new file mode 100644 index 0000000000..a4003deee6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.cspans.txt @@ -0,0 +1,8 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [32] ) +Code span at (8:0,8 [6] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (14:0,14 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Code span at (16:0,16 [15] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.stree.txt new file mode 100644 index 0000000000..64c88fe4f9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.stree.txt @@ -0,0 +1,27 @@ +Directive block - Gen - 32 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Name"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["Name"]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (14:0,14) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (15:0,15) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ foo(); bar(); ] - CodeBlockEditHandler;Accepts:Any;CodeBlock - (16:0,16) - Tokens:11 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (31:0,31) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.cspans.txt new file mode 100644 index 0000000000..3bd36e8664 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [19] ) +Code span at (8:0,8 [11] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.stree.txt new file mode 100644 index 0000000000..c51aa18acd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 19 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Some_Member] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.Identifier;[Some_Member]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.cspans.txt new file mode 100644 index 0000000000..07dfcef1d7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.cspans.txt @@ -0,0 +1,8 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [64] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [64] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [64] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [64] ) +Code span at (42:0,42 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [64] ) +Code span at (43:0,43 [11] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [64] ) +Markup span at (54:0,54 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [64] ) +Code span at (55:0,55 [9] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [64] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.stree.txt new file mode 100644 index 0000000000..1cca925839 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.stree.txt @@ -0,0 +1,23 @@ +Directive block - Gen - 64 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (42:0,42) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Some_Member] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (43:0,43) - Tokens:1 + CSharpTokenType.Identifier;[Some_Member]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (54:0,54) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["AString"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (55:0,55) - Tokens:1 + CSharpTokenType.StringLiteral;["AString"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.cspans.txt new file mode 100644 index 0000000000..1a375c2158 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.cspans.txt @@ -0,0 +1,12 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +Code span at (8:0,8 [8] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (16:0,16 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (17:0,17 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (18:0,18 [14] ) +Markup span at (19:0,19 [3] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [3] ) +Markup span at (22:0,22 [5] ) (Accepts:Any) - Parent: Markup block at (18:0,18 [14] ) +Markup span at (27:0,27 [4] ) (Accepts:Any) - Parent: Tag block at (27:0,27 [4] ) +Markup span at (31:0,31 [1] ) (Accepts:Any) - Parent: Markup block at (18:0,18 [14] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.stree.txt new file mode 100644 index 0000000000..c5bde0c85c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.stree.txt @@ -0,0 +1,37 @@ +Directive block - Gen - 33 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Header"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["Header"]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (17:0,17) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 14 - (18:0,18) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (18:0,18) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (19:0,19) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (19:0,19) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [F{o}o] - SpanEditHandler;Accepts:Any - (22:0,22) - Tokens:5 + HtmlTokenType.Text;[F]; + HtmlTokenType.Text;[{]; + HtmlTokenType.Text;[o]; + HtmlTokenType.Text;[}]; + HtmlTokenType.Text;[o]; + Tag block - Gen - 4 - (27:0,27) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (27:0,27) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (31:0,31) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (32:0,32) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.cspans.txt new file mode 100644 index 0000000000..de1247ad81 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [9] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.stree.txt new file mode 100644 index 0000000000..3413cd7516 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["AString"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["AString"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.cspans.txt new file mode 100644 index 0000000000..1bbf8de3f4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [42] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [42] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [42] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [42] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.stree.txt new file mode 100644 index 0000000000..4032e9314f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.stree.txt @@ -0,0 +1,15 @@ +Directive block - Gen - 42 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Class.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Class.cspans.txt new file mode 100644 index 0000000000..edcf8072b2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Class.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [6] ) +MetaCode span at (1:0,1 [5] ) (Accepts:None) - Parent: Directive block at (0:0,0 [6] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Class.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Class.stree.txt new file mode 100644 index 0000000000..32fae95183 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Class.stree.txt @@ -0,0 +1,5 @@ +Directive block - Gen - 6 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [class] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Keyword;[class]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Namespace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Namespace.cspans.txt new file mode 100644 index 0000000000..c92fb77651 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Namespace.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Namespace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Namespace.stree.txt new file mode 100644 index 0000000000..2beaf1fc4f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Directives_CanUseReservedWord_Namespace.stree.txt @@ -0,0 +1,5 @@ +Directive block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [namespace] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Keyword;[namespace]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/EmptyFunctionsDirective.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/EmptyFunctionsDirective.cspans.txt new file mode 100644 index 0000000000..17a8238d63 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/EmptyFunctionsDirective.cspans.txt @@ -0,0 +1,6 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Markup span at (10:0,10 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Code span at (12:0,12 [1] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/EmptyFunctionsDirective.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/EmptyFunctionsDirective.stree.txt new file mode 100644 index 0000000000..f4f2d2009c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/EmptyFunctionsDirective.stree.txt @@ -0,0 +1,13 @@ +Directive block - Gen - 14 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [functions] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[functions]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (11:0,11) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ ] - CodeBlockEditHandler;Accepts:Any;CodeBlock - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (13:0,13) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt new file mode 100644 index 0000000000..13f5f32062 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt @@ -0,0 +1,5 @@ +Code span at (0:0,0 [4] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [46] ) +Transition span at (4:1,2 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +MetaCode span at (5:1,3 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +Code span at (11:1,9 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [46] ) +Code span at (12:1,10 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [46] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt new file mode 100644 index 0000000000..cb071c8170 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt @@ -0,0 +1,18 @@ +Directive block - Gen - 46 - (0:0,0) + Code span - Gen - [LF ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:2 + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (4:1,2) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (5:1,3) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (11:1,9) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (12:1,10) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.cspans.txt new file mode 100644 index 0000000000..4cadbefff0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.cspans.txt @@ -0,0 +1,9 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) +Code span at (1:0,1 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Directive block at (3:0,3 [44] ) +MetaCode span at (4:0,4 [6] ) (Accepts:None) - Parent: Directive block at (3:0,3 [44] ) +Code span at (10:0,10 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (3:0,3 [44] ) +Code span at (11:0,11 [34] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (3:0,3 [44] ) +Markup span at (45:0,45 [2] ) (Accepts:WhiteSpace) - Parent: Directive block at (3:0,3 [44] ) +Code span at (47:1,0 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) +MetaCode span at (47:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.stree.txt new file mode 100644 index 0000000000..ceac2d5c09 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.stree.txt @@ -0,0 +1,26 @@ +Statement block - Gen - 48 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Directive block - Gen - 44 - (3:0,3) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (3:0,3) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (4:0,4) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Text.Encoding.ASCIIEncoding] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (11:0,11) - Tokens:7 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:WhiteSpace - (45:0,45) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (47:1,0) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (47:1,0) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsArrays.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsArrays.cspans.txt new file mode 100644 index 0000000000..3147ee9712 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsArrays.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [8] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Code span at (9:0,9 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [22] ) +Code span at (10:0,10 [12] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsArrays.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsArrays.stree.txt new file mode 100644 index 0000000000..4dba3c76e7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsArrays.stree.txt @@ -0,0 +1,20 @@ +Markup block - Gen - 22 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [inherits] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[inherits]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [string[[]][]] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (10:0,10) - Tokens:7 + CSharpTokenType.Keyword;[string]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.RightBracket;[]]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (22:0,22) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsNestedGenerics.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsNestedGenerics.cspans.txt new file mode 100644 index 0000000000..2b3f6f0879 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsNestedGenerics.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [87] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [87] ) +MetaCode span at (1:0,1 [8] ) (Accepts:None) - Parent: Directive block at (0:0,0 [87] ) +Code span at (9:0,9 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [87] ) +Code span at (10:0,10 [77] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [87] ) +Markup span at (87:0,87 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [87] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsNestedGenerics.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsNestedGenerics.stree.txt new file mode 100644 index 0000000000..598a5043f8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsNestedGenerics.stree.txt @@ -0,0 +1,30 @@ +Markup block - Gen - 87 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 87 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [inherits] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[inherits]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.Web.Mvc.WebViewPage>] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (10:0,10) - Tokens:17 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Web]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Mvc]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[WebViewPage]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Identifier;[IEnumerable]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Identifier;[MvcApplication2]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Models]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[RegisterModel]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.GreaterThan;[>]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (87:0,87) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsTypeKeywords.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsTypeKeywords.cspans.txt new file mode 100644 index 0000000000..814c89b4eb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsTypeKeywords.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [8] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Code span at (9:0,9 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +Code span at (10:0,10 [6] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (16:0,16 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsTypeKeywords.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsTypeKeywords.stree.txt new file mode 100644 index 0000000000..a65a1bba4c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/InheritsDirectiveSupportsTypeKeywords.stree.txt @@ -0,0 +1,14 @@ +Markup block - Gen - 16 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 16 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [inherits] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[inherits]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [string] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.Keyword;[string]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (16:0,16) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_AreSkipped.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_AreSkipped.cspans.txt new file mode 100644 index 0000000000..f1fd6cb92b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_AreSkipped.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_AreSkipped.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_AreSkipped.stree.txt new file mode 100644 index 0000000000..5b7ca1b209 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_AreSkipped.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.cspans.txt new file mode 100644 index 0000000000..a54168ebd2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [29] ) +Code span at (8:0,8 [21] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [29] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.stree.txt new file mode 100644 index 0000000000..1951c2e8a1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 29 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["{formaction}?/{id}?"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["{formaction}?/{id}?"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.cspans.txt new file mode 100644 index 0000000000..39ac31cfc7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.cspans.txt @@ -0,0 +1,6 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [43] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [43] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [43] ) +Code span at (8:0,8 [21] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [43] ) +Code span at (29:0,29 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [43] ) +Code span at (30:0,30 [13] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [43] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.stree.txt new file mode 100644 index 0000000000..4f534b5d86 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.stree.txt @@ -0,0 +1,15 @@ +Directive block - Gen - 43 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["{formaction}?/{id}?"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["{formaction}?/{id}?"]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (29:0,29) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [System.String] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (30:0,30) - Tokens:3 + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[String]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.cspans.txt new file mode 100644 index 0000000000..2fca4ed7c1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [22] ) +Code span at (8:0,8 [14] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.stree.txt new file mode 100644 index 0000000000..1e6bb057fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["simple-value"] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.StringLiteral;["simple-value"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.cspans.txt new file mode 100644 index 0000000000..0e09c28b92 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [13] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Code span at (14:0,14 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +Code span at (15:0,15 [12] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [27] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.stree.txt new file mode 100644 index 0000000000..114b39032d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 27 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [TestDirective] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[TestDirective]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (14:0,14) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [PropertyName] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.Identifier;[PropertyName]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.cspans.txt new file mode 100644 index 0000000000..bd5a26dfaf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [13] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +Code span at (14:0,14 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [15] ) +Code span at (15:0,15 [0] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [15] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.stree.txt new file mode 100644 index 0000000000..ee0063aa4b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 15 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [TestDirective] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[TestDirective]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (14:0,14) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_FunctionsDirective.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_FunctionsDirective.cspans.txt new file mode 100644 index 0000000000..d5fc0c09b5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_FunctionsDirective.cspans.txt @@ -0,0 +1,6 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Markup span at (10:0,10 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Code span at (12:0,12 [15] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_FunctionsDirective.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_FunctionsDirective.stree.txt new file mode 100644 index 0000000000..119a7b047b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_FunctionsDirective.stree.txt @@ -0,0 +1,23 @@ +Directive block - Gen - 28 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [functions] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[functions]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (11:0,11) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ foo(); bar(); ] - CodeBlockEditHandler;Accepts:Any;CodeBlock - (12:0,12) - Tokens:11 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (27:0,27) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_SectionDirective.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_SectionDirective.cspans.txt new file mode 100644 index 0000000000..4e1fdc7d0c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_SectionDirective.cspans.txt @@ -0,0 +1,12 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [32] ) +Code span at (9:0,9 [6] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (15:0,15 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [14] ) +Markup span at (18:0,18 [3] ) (Accepts:Any) - Parent: Tag block at (18:0,18 [3] ) +Markup span at (21:0,21 [5] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [14] ) +Markup span at (26:0,26 [4] ) (Accepts:Any) - Parent: Tag block at (26:0,26 [4] ) +Markup span at (30:0,30 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [14] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_SectionDirective.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_SectionDirective.stree.txt new file mode 100644 index 0000000000..2af805b4b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parse_SectionDirective.stree.txt @@ -0,0 +1,37 @@ +Directive block - Gen - 32 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Header] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[Header]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (15:0,15) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (16:0,16) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 14 - (17:0,17) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (18:0,18) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (18:0,18) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [F{o}o] - SpanEditHandler;Accepts:Any - (21:0,21) - Tokens:5 + HtmlTokenType.Text;[F]; + HtmlTokenType.Text;[{]; + HtmlTokenType.Text;[o]; + HtmlTokenType.Text;[}]; + HtmlTokenType.Text;[o]; + Tag block - Gen - 4 - (26:0,26) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (26:0,26) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (30:0,30) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (31:0,31) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.cspans.txt new file mode 100644 index 0000000000..37abb54fcf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [29] ) +Code span at (8:0,8 [21] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [29] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.stree.txt new file mode 100644 index 0000000000..9776383715 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.stree.txt @@ -0,0 +1,13 @@ +Directive block - Gen - 29 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [BaseNamespace.Foo.Bar] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:5 + CSharpTokenType.Identifier;[BaseNamespace]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Bar]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.cspans.txt new file mode 100644 index 0000000000..6b4d8a5908 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (7:0,7 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [21] ) +Code span at (8:0,8 [13] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.stree.txt new file mode 100644 index 0000000000..8a637f25e1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [custom] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[custom]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (7:0,7) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [BaseNamespace] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.Identifier;[BaseNamespace]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..814a67e317 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (17:0,17 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..2d3bc151de --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,10 @@ +Directive block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [removeTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[removeTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo"] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:2 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.StringLiteral;["];RZ1000(20:0,20 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.cspans.txt new file mode 100644 index 0000000000..d6dde5b7a8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (17:0,17 [3] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [20] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.stree.txt new file mode 100644 index 0000000000..062b5be2d7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 20 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [removeTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[removeTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.Identifier;[Foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.cspans.txt new file mode 100644 index 0000000000..d847da62f5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (17:0,17 [2] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.stree.txt new file mode 100644 index 0000000000..b800b7d52b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 19 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [removeTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[removeTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [""] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.StringLiteral;[""]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_RequiresValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_RequiresValue.cspans.txt new file mode 100644 index 0000000000..adc30c55d8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_RequiresValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (17:0,17 [0] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_RequiresValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_RequiresValue.stree.txt new file mode 100644 index 0000000000..072bd0d67f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_RequiresValue.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [removeTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[removeTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.cspans.txt new file mode 100644 index 0000000000..82433192e9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [25] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [25] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [25] ) +Code span at (17:0,17 [8] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [25] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.stree.txt new file mode 100644 index 0000000000..09c45b5793 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 25 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [removeTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[removeTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ['*, Foo'] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.CharacterLiteral;['*, Foo']; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..814a67e317 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (17:0,17 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..f441701e1a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [removeTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[removeTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Foo] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.StringLiteral;["Foo];RZ1000(17:0,17 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.cspans.txt new file mode 100644 index 0000000000..7047bf83e0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [35] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [35] ) +Markup span at (16:0,16 [5] ) (Accepts:None) - Parent: Directive block at (0:0,0 [35] ) +Code span at (21:0,21 [14] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [35] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.stree.txt new file mode 100644 index 0000000000..2bcd74c5e6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.stree.txt @@ -0,0 +1,13 @@ +Directive block - Gen - 35 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [removeTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[removeTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo, Bar ] - SpanEditHandler;Accepts:AnyExceptNewline - (21:0,21) - Tokens:5 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt new file mode 100644 index 0000000000..e34deac84b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Code span at (17:0,17 [5] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt new file mode 100644 index 0000000000..70b0ecf8e8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [removeTagHelper] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[removeTagHelper]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Foo"] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.StringLiteral;["Foo"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..3de0fa6980 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Code span at (17:0,17 [7] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [24] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..6377f48d15 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,11 @@ +Directive block - Gen - 24 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [tagHelperPrefix] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[tagHelperPrefix]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo "] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:3 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["];RZ1000(23:0,23 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.cspans.txt new file mode 100644 index 0000000000..d847da62f5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (17:0,17 [2] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.stree.txt new file mode 100644 index 0000000000..5a5e18da25 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 19 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [tagHelperPrefix] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[tagHelperPrefix]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [""] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.StringLiteral;[""]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_RequiresValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_RequiresValue.cspans.txt new file mode 100644 index 0000000000..adc30c55d8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_RequiresValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (17:0,17 [0] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_RequiresValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_RequiresValue.stree.txt new file mode 100644 index 0000000000..d63b77168e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_RequiresValue.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [tagHelperPrefix] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[tagHelperPrefix]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..814a67e317 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (17:0,17 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..277fbd3a51 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [tagHelperPrefix] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[tagHelperPrefix]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Foo] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.StringLiteral;["Foo];RZ1000(17:0,17 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_Succeeds.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_Succeeds.cspans.txt new file mode 100644 index 0000000000..d6dde5b7a8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_Succeeds.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (17:0,17 [3] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [20] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_Succeeds.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_Succeeds.stree.txt new file mode 100644 index 0000000000..7e9a17d299 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_Succeeds.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 20 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [tagHelperPrefix] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[tagHelperPrefix]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.Identifier;[Foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.cspans.txt new file mode 100644 index 0000000000..e34deac84b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Code span at (17:0,17 [5] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.stree.txt new file mode 100644 index 0000000000..1c5a3a9321 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [tagHelperPrefix] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[tagHelperPrefix]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - ["Foo"] - SpanEditHandler;Accepts:AnyExceptNewline - (17:0,17) - Tokens:1 + CSharpTokenType.StringLiteral;["Foo"]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.cspans.txt new file mode 100644 index 0000000000..7dee009374 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [17] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.stree.txt new file mode 100644 index 0000000000..6f18195cab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.stree.txt @@ -0,0 +1,5 @@ +Statement block - Gen - 17 - (0:0,0) + Code span - Gen - [using LF] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:3 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.cspans.txt new file mode 100644 index 0000000000..110e3a8b71 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [7] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [7] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diag.txt new file mode 100644 index 0000000000..ade6c85b25 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.stree.txt new file mode 100644 index 0000000000..c0c22405e9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 7 - (0:0,0) + Code span - Gen - [Href(LF] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Tokens:3 + CSharpTokenType.Identifier;[Href]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.cspans.txt new file mode 100644 index 0000000000..1578e4491e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [46] ) +Code span at (1:0,1 [44] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [46] ) +MetaCode span at (45:0,45 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [46] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.stree.txt new file mode 100644 index 0000000000..604a9bb8b6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.stree.txt @@ -0,0 +1,17 @@ +Expression block - Gen - 46 - (0:0,0) + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [Request["description"] ?? @photo.Description] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:11 + CSharpTokenType.Identifier;[Request]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.StringLiteral;["description"]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NullCoalesce;[??]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Transition;[@]; + CSharpTokenType.Identifier;[photo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Description]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (45:0,45) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.cspans.txt new file mode 100644 index 0000000000..df42b12e56 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.cspans.txt @@ -0,0 +1,8 @@ +Code span at (0:0,0 [43] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [64] ) +Markup span at (43:2,4 [3] ) (Accepts:None) - Parent: Tag block at (43:2,4 [3] ) +Markup span at (46:2,7 [7] ) (Accepts:Any) - Parent: Markup block at (43:2,4 [20] ) +Transition span at (53:2,14 [1] ) (Accepts:None) - Parent: Expression block at (53:2,14 [4] ) +Code span at (54:2,15 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (53:2,14 [4] ) +Markup span at (57:2,18 [4] ) (Accepts:None) - Parent: Tag block at (57:2,18 [4] ) +Markup span at (61:2,22 [2] ) (Accepts:None) - Parent: Markup block at (43:2,4 [20] ) +Code span at (63:3,0 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [64] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diag.txt new file mode 100644 index 0000000000..749c29cf56 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diag.txt @@ -0,0 +1 @@ +(2,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.stree.txt new file mode 100644 index 0000000000..5f1e30a96d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.stree.txt @@ -0,0 +1,45 @@ +Statement block - Gen - 64 - (0:0,0) + Code span - Gen - [if(foo) {LF var foo = "foo bar bazLF ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:17 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["foo bar baz];RZ1000(25:1,14 [1] ) + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + Markup block - Gen - 20 - (43:2,4) + Tag block - Gen - 3 - (43:2,4) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (43:2,4) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo is ] - SpanEditHandler;Accepts:Any - (46:2,7) - Tokens:4 + HtmlTokenType.Text;[Foo]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[is]; + HtmlTokenType.WhiteSpace;[ ]; + Expression block - Gen - 4 - (53:2,14) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (53:2,14) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (54:2,15) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Tag block - Gen - 4 - (57:2,18) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (57:2,18) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:None - (61:2,22) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (63:3,0) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.cspans.txt new file mode 100644 index 0000000000..0d0c890348 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.cspans.txt @@ -0,0 +1,6 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (15:0,15 [6] ) (Accepts:None) - Parent: Tag block at (15:0,15 [6] ) +Markup span at (21:0,21 [7] ) (Accepts:None) - Parent: Tag block at (21:0,21 [7] ) +Code span at (28:0,28 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diag.txt new file mode 100644 index 0000000000..994acd46f2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diag.txt @@ -0,0 +1 @@ +(1,15): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.stree.txt new file mode 100644 index 0000000000..7832ba2cb6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.stree.txt @@ -0,0 +1,24 @@ +Statement block - Gen - 29 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [string.Format(] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:4 + CSharpTokenType.Keyword;[string]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Format]; + CSharpTokenType.LeftParenthesis;[(]; + Markup block - Gen - 13 - (15:0,15) + Tag block - Gen - 6 - (15:0,15) + Markup span - Gen - [] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[html]; + HtmlTokenType.CloseAngle;[>]; + Tag block - Gen - 7 - (21:0,21) + Markup span - Gen - [] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[html]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (28:0,28) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (28:0,28) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.cspans.txt new file mode 100644 index 0000000000..df81e75cc2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.diag.txt new file mode 100644 index 0000000000..0179da5b14 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: """ is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.stree.txt new file mode 100644 index 0000000000..8f8de632d0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.cspans.txt new file mode 100644 index 0000000000..0e1dd1aeef --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [27] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diag.txt new file mode 100644 index 0000000000..07f83443c3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diag.txt @@ -0,0 +1,10 @@ +(1,8): Error RZ1008: Expected a "{" but found a ")". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) +

            Hello, @user

            + +Instead, wrap the contents of the block in "{}": + +@if(isLoggedIn) { +

            Hello, @user

            +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.stree.txt new file mode 100644 index 0000000000..14a29b0b80 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.stree.txt @@ -0,0 +1,20 @@ +Statement block - Gen - 27 - (0:0,0) + Code span - Gen - [if(foo)) { var bar = foo; }] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:18 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.cspans.txt new file mode 100644 index 0000000000..c23fc20c01 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.cspans.txt @@ -0,0 +1,2 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diag.txt new file mode 100644 index 0000000000..3b54961cc8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.stree.txt new file mode 100644 index 0000000000..2a25f6f7de --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.stree.txt @@ -0,0 +1,5 @@ +Statement block - Gen - 1 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (1:0,1) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.cspans.txt new file mode 100644 index 0000000000..5584b0b636 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [2] ) +Code span at (1:0,1 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [2] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [2] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.stree.txt new file mode 100644 index 0000000000..898717d0f5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.stree.txt @@ -0,0 +1,7 @@ +Statement block - Gen - 2 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.cspans.txt new file mode 100644 index 0000000000..df81e75cc2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diag.txt new file mode 100644 index 0000000000..84fe5838bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.stree.txt new file mode 100644 index 0000000000..8f8de632d0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.cspans.txt new file mode 100644 index 0000000000..a8ccb8bc5e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.cspans.txt @@ -0,0 +1,5 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [8] ) +Code span at (1:0,1 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [8] ) +Transition span at (7:1,4 [1] ) (Accepts:None) - Parent: Expression block at (7:1,4 [1] ) +Code span at (8:1,5 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (7:1,4 [1] ) +Code span at (8:1,5 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diag.txt new file mode 100644 index 0000000000..cd939667f4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diag.txt @@ -0,0 +1,2 @@ +(2,6): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" +(1,1): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.stree.txt new file mode 100644 index 0000000000..d7a2344f3c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.stree.txt @@ -0,0 +1,13 @@ +Statement block - Gen - 8 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [LF ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (1:0,1) - Tokens:2 + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + Expression block - Gen - 1 - (7:1,4) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (7:1,4) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[ATD];K14 - (8:1,5) - Tokens:1 + CSharpTokenType.Unknown;[]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (8:1,5) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.cspans.txt new file mode 100644 index 0000000000..df81e75cc2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.diag.txt new file mode 100644 index 0000000000..1a4e7725a4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.stree.txt new file mode 100644 index 0000000000..8f8de632d0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.cspans.txt new file mode 100644 index 0000000000..fdf5c8e1ef --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.cspans.txt @@ -0,0 +1,6 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Code span at (1:0,1 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [16] ) +Transition span at (7:1,4 [1] ) (Accepts:None) - Parent: Expression block at (7:1,4 [1] ) +Code span at (8:1,5 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (7:1,4 [1] ) +Code span at (8:1,5 [7] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (15:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.diag.txt new file mode 100644 index 0000000000..a8f6dc0930 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.diag.txt @@ -0,0 +1 @@ +(2,6): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.stree.txt new file mode 100644 index 0000000000..cea41801d1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.stree.txt @@ -0,0 +1,18 @@ +Statement block - Gen - 16 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [LF ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:2 + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + Expression block - Gen - 1 - (7:1,4) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (7:1,4) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[ATD];K14 - (8:1,5) - Tokens:1 + CSharpTokenType.Unknown;[]; + Code span - Gen - [ {}LF] - SpanEditHandler;Accepts:Any - (8:1,5) - Tokens:4 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (15:2,0) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.cspans.txt new file mode 100644 index 0000000000..f34e083373 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.cspans.txt @@ -0,0 +1,8 @@ +Code span at (0:0,0 [9] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (9:0,9 [1] ) (Accepts:Any) - Parent: Markup block at (9:0,9 [13] ) +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Markup block at (9:0,9 [13] ) +Markup span at (11:0,11 [3] ) (Accepts:None) - Parent: Tag block at (11:0,11 [3] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Markup block at (9:0,9 [13] ) +Markup span at (17:0,17 [4] ) (Accepts:None) - Parent: Tag block at (17:0,17 [4] ) +Markup span at (21:0,21 [1] ) (Accepts:None) - Parent: Markup block at (9:0,9 [13] ) +Code span at (22:0,22 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diag.txt new file mode 100644 index 0000000000..81a565a43a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diag.txt @@ -0,0 +1,5 @@ +(1,11): Error RZ1009: The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: + +@if(isLoggedIn) { +

            Hello, @user!

            +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.stree.txt new file mode 100644 index 0000000000..691f6016fb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.stree.txt @@ -0,0 +1,30 @@ +Statement block - Gen - 23 - (0:0,0) + Code span - Gen - [if(foo) {] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:6 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 13 - (9:0,9) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (9:0,9) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (10:0,10) - Tokens:1 + HtmlTokenType.Transition;[@]; + Tag block - Gen - 3 - (11:0,11) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (11:0,11) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Bar] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.Text;[Bar]; + Tag block - Gen - 4 - (17:0,17) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (17:0,17) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (22:0,22) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..117b42b3e2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [70] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [70] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..b9e68acd22 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,16): Error RZ1006: The catch block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..dce1789d78 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,47 @@ +Statement block - Gen - 70 - (0:0,0) + Code span - Gen - [try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:45 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..8944928f75 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,4 @@ +MetaCode span at (0:0,0 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [54] ) +Markup span at (9:0,9 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [54] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [54] ) +Code span at (11:0,11 [43] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [54] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..08147658a8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,36 @@ +Directive block - Gen - 54 - (0:0,0) + MetaCode span - Gen - [functions] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Identifier;[functions]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (10:0,10) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ var foo = bar; if(foo != null) { bar(); } ] - CodeBlockEditHandler;Accepts:Any;CodeBlock - (11:0,11) - Tokens:28 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..b7f74c81c8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [47] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [47] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..848ff180d7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The do block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..73e25271f0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,33 @@ +Statement block - Gen - 47 - (0:0,0) + Code span - Gen - [do { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:31 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..cecf4145df --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [68] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [68] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..00f5c555f9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,20): Error RZ1006: The else block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..652f403cec --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,47 @@ +Statement block - Gen - 68 - (0:0,0) + Code span - Gen - [if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:45 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..f16c8b4133 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [71] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [71] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..aa78495b19 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,20): Error RZ1006: The else if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..4750dbca0e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,49 @@ +Statement block - Gen - 71 - (0:0,0) + Code span - Gen - [if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:47 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..5e9f2d6502 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,2 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +Code span at (1:0,1 [43] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [44] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..3b54961cc8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..de02008232 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,32 @@ +Statement block - Gen - 44 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ var foo = bar; if(foo != null) { bar(); } ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (1:0,1) - Tokens:28 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..5de6b936db --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [67] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [67] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..8abedf47a1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,16): Error RZ1006: The finally block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..17ec773583 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,44 @@ +Statement block - Gen - 67 - (0:0,0) + Code span - Gen - [try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:42 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..7d764a8ab7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [54] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..01cc5cb7b6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The for block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..f896c4413c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 54 - (0:0,0) + Code span - Gen - [for (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[for]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..53f1391d54 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [58] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [58] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..ad3a00985c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The foreach block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..f040273553 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 58 - (0:0,0) + Code span - Gen - [foreach (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..aa1f2379ca --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [53] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..8f817baa43 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..8940e51eb3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 53 - (0:0,0) + Code span - Gen - [if (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..6d4cff2b18 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [55] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..f5a5f37b3d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The lock block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..2db346c06b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 55 - (0:0,0) + Code span - Gen - [lock (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[lock]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..a73fdccd82 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [57] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [57] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..245372b7fc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The switch block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..274707aa24 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 57 - (0:0,0) + Code span - Gen - [switch (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[switch]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..38d6ea4454 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [48] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..6bb5602c0c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The try block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..b8edb26e7e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,33 @@ +Statement block - Gen - 48 - (0:0,0) + Code span - Gen - [try { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:31 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..3776f70a65 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [56] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..65d152b240 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The using block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..50ee1fda7f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 56 - (0:0,0) + Code span - Gen - [using (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..3776f70a65 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [56] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..aa7f1b2bf2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The while block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..cef398b06c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 56 - (0:0,0) + Code span - Gen - [while (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:35 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NotEqual;[!=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.cspans.txt new file mode 100644 index 0000000000..060e2c559a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.cspans.txt @@ -0,0 +1,15 @@ +Code span at (0:0,0 [8] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [58] ) +Markup span at (8:0,8 [3] ) (Accepts:None) - Parent: Tag block at (8:0,8 [3] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [11] ) +Markup span at (14:0,14 [4] ) (Accepts:None) - Parent: Tag block at (14:0,14 [4] ) +Markup span at (18:0,18 [1] ) (Accepts:None) - Parent: Markup block at (8:0,8 [11] ) +Code span at (19:0,19 [13] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [58] ) +Markup span at (32:0,32 [3] ) (Accepts:None) - Parent: Tag block at (32:0,32 [3] ) +Markup span at (35:0,35 [3] ) (Accepts:Any) - Parent: Markup block at (32:0,32 [11] ) +Markup span at (38:0,38 [4] ) (Accepts:None) - Parent: Tag block at (38:0,38 [4] ) +Markup span at (42:0,42 [1] ) (Accepts:None) - Parent: Markup block at (32:0,32 [11] ) +Code span at (43:0,43 [5] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [58] ) +Markup span at (48:0,48 [3] ) (Accepts:None) - Parent: Tag block at (48:0,48 [3] ) +Markup span at (51:0,51 [3] ) (Accepts:Any) - Parent: Markup block at (48:0,48 [10] ) +Markup span at (54:0,54 [4] ) (Accepts:None) - Parent: Tag block at (54:0,54 [4] ) +Code span at (58:0,58 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [58] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt new file mode 100644 index 0000000000..1c1f35257d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt @@ -0,0 +1,30 @@ +(1,9): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) +

            Hello, @user

            + +Instead, wrap the contents of the block in "{}": + +@if(isLoggedIn) { +

            Hello, @user

            +} +(1,33): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) +

            Hello, @user

            + +Instead, wrap the contents of the block in "{}": + +@if(isLoggedIn) { +

            Hello, @user

            +} +(1,49): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) +

            Hello, @user

            + +Instead, wrap the contents of the block in "{}": + +@if(isLoggedIn) { +

            Hello, @user

            +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.stree.txt new file mode 100644 index 0000000000..b7e771e87f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.stree.txt @@ -0,0 +1,66 @@ +Statement block - Gen - 58 - (0:0,0) + Code span - Gen - [if(foo) ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:5 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + Markup block - Gen - 11 - (8:0,8) + Tag block - Gen - 3 - (8:0,8) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (8:0,8) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Bar] - SpanEditHandler;Accepts:Any - (11:0,11) - Tokens:1 + HtmlTokenType.Text;[Bar]; + Tag block - Gen - 4 - (14:0,14) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (14:0,14) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (18:0,18) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [else if(bar) ] - SpanEditHandler;Accepts:Any - (19:0,19) - Tokens:7 + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + Markup block - Gen - 11 - (32:0,32) + Tag block - Gen - 3 - (32:0,32) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (32:0,32) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Baz] - SpanEditHandler;Accepts:Any - (35:0,35) - Tokens:1 + HtmlTokenType.Text;[Baz]; + Tag block - Gen - 4 - (38:0,38) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (38:0,38) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (42:0,42) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [else ] - SpanEditHandler;Accepts:Any - (43:0,43) - Tokens:2 + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + Markup block - Gen - 10 - (48:0,48) + Tag block - Gen - 3 - (48:0,48) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (48:0,48) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Boz] - SpanEditHandler;Accepts:Any - (51:0,51) - Tokens:1 + HtmlTokenType.Text;[Boz]; + Tag block - Gen - 4 - (54:0,54) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (54:0,54) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (58:0,58) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.cspans.txt new file mode 100644 index 0000000000..81ae90f80d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.cspans.txt @@ -0,0 +1,7 @@ +Code span at (0:0,0 [11] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (11:1,6 [1] ) (Accepts:Any) - Parent: Markup block at (11:1,6 [12] ) +Markup span at (12:1,7 [3] ) (Accepts:None) - Parent: Tag block at (12:1,7 [3] ) +Markup span at (15:1,10 [3] ) (Accepts:Any) - Parent: Markup block at (11:1,6 [12] ) +Markup span at (18:1,13 [4] ) (Accepts:None) - Parent: Tag block at (18:1,13 [4] ) +Markup span at (22:1,17 [1] ) (Accepts:None) - Parent: Markup block at (11:1,6 [12] ) +Code span at (23:1,18 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.diag.txt new file mode 100644 index 0000000000..409c3a530f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.diag.txt @@ -0,0 +1 @@ +(1,3): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.stree.txt new file mode 100644 index 0000000000..f1e59db50a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.stree.txt @@ -0,0 +1,28 @@ +Statement block - Gen - 24 - (0:0,0) + Code span - Gen - [if(LFelse {] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:6 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (11:1,6) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (11:1,6) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (12:1,7) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (12:1,7) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (15:1,10) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (18:1,13) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (18:1,13) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (22:1,17) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:None - (23:1,18) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.cspans.txt new file mode 100644 index 0000000000..715dbd7f9e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [22] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diag.txt new file mode 100644 index 0000000000..2355923768 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.stree.txt new file mode 100644 index 0000000000..72e23a8a3c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.stree.txt @@ -0,0 +1,12 @@ +Expression block - Gen - 22 - (0:0,0) + Code span - Gen - [Foo[Bar[Baz]LFBizLFBoz] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Tokens:10 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[Biz]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[Boz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.cspans.txt new file mode 100644 index 0000000000..c31341dd46 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.cspans.txt @@ -0,0 +1,2 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [13] ) +Code span at (1:0,1 [12] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [13] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.diag.txt new file mode 100644 index 0000000000..2996b166be --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.stree.txt new file mode 100644 index 0000000000..78cdf0005e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 13 - (0:0,0) + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [foo barLFbaz] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:5 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.cspans.txt new file mode 100644 index 0000000000..715dbd7f9e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [22] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.diag.txt new file mode 100644 index 0000000000..a08a836e65 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.stree.txt new file mode 100644 index 0000000000..8a2b46772d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.stree.txt @@ -0,0 +1,12 @@ +Expression block - Gen - 22 - (0:0,0) + Code span - Gen - [Foo(Bar(Baz)LFBizLFBoz] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Tokens:10 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[Biz]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[Boz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.cspans.txt new file mode 100644 index 0000000000..4c86f2e2df --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [19] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.diag.txt new file mode 100644 index 0000000000..2355923768 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.stree.txt new file mode 100644 index 0000000000..ec70a45174 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.stree.txt @@ -0,0 +1,11 @@ +Expression block - Gen - 19 - (0:0,0) + Code span - Gen - [Foo[Bar[Baz]LFBizLF] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Tokens:9 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[Biz]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.cspans.txt new file mode 100644 index 0000000000..9043c487d5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.cspans.txt @@ -0,0 +1,2 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.diag.txt new file mode 100644 index 0000000000..2996b166be --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.stree.txt new file mode 100644 index 0000000000..c23684a3e4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.stree.txt @@ -0,0 +1,8 @@ +Expression block - Gen - 10 - (0:0,0) + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [foo barLF] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:4 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.cspans.txt new file mode 100644 index 0000000000..4c86f2e2df --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [19] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diag.txt new file mode 100644 index 0000000000..a08a836e65 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.stree.txt new file mode 100644 index 0000000000..e8a7af923b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.stree.txt @@ -0,0 +1,11 @@ +Expression block - Gen - 19 - (0:0,0) + Code span - Gen - [Foo(Bar(Baz)LFBizLF] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Tokens:9 + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[Biz]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt new file mode 100644 index 0000000000..7dee009374 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [17] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt new file mode 100644 index 0000000000..b30a1516ec --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt new file mode 100644 index 0000000000..7bbc78e8ff --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt @@ -0,0 +1,8 @@ +Statement block - Gen - 17 - (0:0,0) + Code span - Gen - [foreach(foo barLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:6 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt new file mode 100644 index 0000000000..2f5362f59f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [12] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [12] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt new file mode 100644 index 0000000000..409c3a530f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt @@ -0,0 +1 @@ +(1,3): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt new file mode 100644 index 0000000000..d12e4eeb98 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt @@ -0,0 +1,8 @@ +Statement block - Gen - 12 - (0:0,0) + Code span - Gen - [if(foo barLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:6 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.cspans.txt new file mode 100644 index 0000000000..6409475acb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [41] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [41] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diag.txt new file mode 100644 index 0000000000..73d5e27b67 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diag.txt @@ -0,0 +1 @@ +(2,13): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.stree.txt new file mode 100644 index 0000000000..83c5c0e7bc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.stree.txt @@ -0,0 +1,21 @@ +Statement block - Gen - 41 - (0:0,0) + Code span - Gen - [if(foo) {LF var p = "foo bar bazLF;LF}] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:19 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[p]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["foo bar baz];RZ1000(23:1,12 [1] ) + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..36f4320778 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [45] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [45] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.diag.txt new file mode 100644 index 0000000000..87d10aab25 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.diag.txt @@ -0,0 +1,2 @@ +(1,21): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +(1,1): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.stree.txt new file mode 100644 index 0000000000..f62bdc8820 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.stree.txt @@ -0,0 +1,16 @@ +Statement block - Gen - 45 - (0:0,0) + Code span - Gen - [if(foo) { var foo = "blah blah blah blah blah] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:14 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;["blah blah blah blah blah];RZ1000(20:0,20 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt new file mode 100644 index 0000000000..c6a64c939b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [15] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [15] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt new file mode 100644 index 0000000000..6cb7c82385 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt new file mode 100644 index 0000000000..c0593ccb6f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt @@ -0,0 +1,8 @@ +Statement block - Gen - 15 - (0:0,0) + Code span - Gen - [using(foo barLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:6 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..38b7004fed --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [60] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [60] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.diag.txt new file mode 100644 index 0000000000..87d10aab25 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.diag.txt @@ -0,0 +1,2 @@ +(1,21): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +(1,1): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.stree.txt new file mode 100644 index 0000000000..b657dfb7d1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.stree.txt @@ -0,0 +1,16 @@ +Statement block - Gen - 60 - (0:0,0) + Code span - Gen - [if(foo) { var foo = @"blah LFblah; LF

            Foo

            LFblah LFblah] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:14 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.StringLiteral;[@"blah LFblah; LF

            Foo

            LFblah LFblah];RZ1000(20:0,20 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt new file mode 100644 index 0000000000..e4dc080bcb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [22] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.diag.txt new file mode 100644 index 0000000000..8ae5df0726 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.diag.txt @@ -0,0 +1 @@ +(1,13): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.stree.txt new file mode 100644 index 0000000000..9f5bb09d03 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.stree.txt @@ -0,0 +1,14 @@ +Statement block - Gen - 22 - (0:0,0) + Code span - Gen - [do { } while(foo barLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:12 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.cspans.txt new file mode 100644 index 0000000000..aa175869a4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (1:0,1 [6] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [7] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.diag.txt new file mode 100644 index 0000000000..dafdc8f2e9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1002: The helper directive is not supported. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.stree.txt new file mode 100644 index 0000000000..1454016ba1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 7 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [helper] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[helper]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.cspans.txt new file mode 100644 index 0000000000..2dc048c890 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.cspans.txt @@ -0,0 +1,7 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) +Transition span at (6:0,6 [1] ) (Accepts:None) - Parent: Statement block at (6:0,6 [3] ) +MetaCode span at (7:0,7 [1] ) (Accepts:None) - Parent: Statement block at (6:0,6 [3] ) +Code span at (8:0,8 [0] ) (Accepts:Any) - Parent: Statement block at (6:0,6 [3] ) +MetaCode span at (8:0,8 [1] ) (Accepts:None) - Parent: Statement block at (6:0,6 [3] ) +Code span at (9:0,9 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.diag.txt new file mode 100644 index 0000000000..302b641580 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ1010: Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.stree.txt new file mode 100644 index 0000000000..bf52f4c935 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.stree.txt @@ -0,0 +1,20 @@ +Statement block - Gen - 11 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if { ] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:4 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Statement block - Gen - 3 - (6:0,6) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (6:0,6) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (7:0,7) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (8:0,8) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (8:0,8) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (9:0,9) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..1805200b11 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [9] ) +MetaCode span at (8:0,8 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.stree.txt new file mode 100644 index 0000000000..ab2776cd54 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 9 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - ["\"\""] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.StringLiteral;["\"\""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (8:0,8) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..b9217b9912 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (2:0,2 [7] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [10] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.stree.txt new file mode 100644 index 0000000000..173672adb1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [@""""""] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.StringLiteral;[@""""""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (9:0,9) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..9ce40e483d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (2:0,2 [4] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [7] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.stree.txt new file mode 100644 index 0000000000..28ef6bad21 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 7 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - ["\""] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.StringLiteral;["\""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (6:0,6) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..afe90c7ff2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (2:0,2 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [8] ) +MetaCode span at (7:0,7 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.stree.txt new file mode 100644 index 0000000000..e8c4fd0f60 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [@""""] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.StringLiteral;[@""""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (7:0,7) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..3e85e0720c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [23] ) +Code span at (2:0,2 [20] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [23] ) +MetaCode span at (22:4,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [23] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.stree.txt new file mode 100644 index 0000000000..c30fec9476 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 23 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [@"LFFooLFBarLFBazLF"] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.StringLiteral;[@"LFFooLFBarLFBazLF"]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (22:4,1) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..fef1e1fc84 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) +Code span at (2:0,2 [18] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [21] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.stree.txt new file mode 100644 index 0000000000..054fbe06a9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - ["\"hello, world\""] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.StringLiteral;["\"hello, world\""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (20:0,20) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..1b2d2bf3ef --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +Code span at (2:0,2 [19] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.stree.txt new file mode 100644 index 0000000000..a77e2669da --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [@"""hello, world"""] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.StringLiteral;[@"""hello, world"""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..b9217b9912 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (2:0,2 [7] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [10] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.stree.txt new file mode 100644 index 0000000000..173672adb1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [@""""""] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.StringLiteral;[@""""""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (9:0,9) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.cspans.txt new file mode 100644 index 0000000000..f85c4eb540 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [2] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [2] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [2] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.diag.txt new file mode 100644 index 0000000000..0b063402e6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.stree.txt new file mode 100644 index 0000000000..f477a803b1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 2 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.cspans.txt new file mode 100644 index 0000000000..11224bc884 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [3] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [3] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [3] ) +MetaCode span at (2:0,2 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [3] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.stree.txt new file mode 100644 index 0000000000..ac2afba6aa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 3 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (2:0,2) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.cspans.txt new file mode 100644 index 0000000000..befccd6124 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.stree.txt new file mode 100644 index 0000000000..7d0e4caeab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [हळूँजद॔] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[हळूँजद॔]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.stree.txt new file mode 100644 index 0000000000..8967206fd1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.cspans.txt new file mode 100644 index 0000000000..befccd6124 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.stree.txt new file mode 100644 index 0000000000..a319543617 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.cspans.txt new file mode 100644 index 0000000000..befccd6124 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.stree.txt new file mode 100644 index 0000000000..a319543617 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.cspans.txt new file mode 100644 index 0000000000..befccd6124 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.stree.txt new file mode 100644 index 0000000000..a319543617 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.cspans.txt new file mode 100644 index 0000000000..befccd6124 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.stree.txt new file mode 100644 index 0000000000..a319543617 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.cspans.txt new file mode 100644 index 0000000000..4c546c5213 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [12] ) +Code span at (1:0,1 [11] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [12] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.stree.txt new file mode 100644 index 0000000000..b130a21495 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 12 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar.baz] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:5 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.stree.txt new file mode 100644 index 0000000000..8967206fd1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.cspans.txt new file mode 100644 index 0000000000..345383cbb0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Code span at (0:0,0 [12] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [18] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [4] ) +Code span at (13:0,13 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (12:0,12 [4] ) +Code span at (16:0,16 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [18] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.stree.txt new file mode 100644 index 0000000000..ca459f326c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.stree.txt @@ -0,0 +1,18 @@ +Statement block - Gen - 18 - (0:0,0) + Code span - Gen - [if (true) { ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:8 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Expression block - Gen - 4 - (12:0,12) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (12:0,12) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[ATD];K14 - (13:0,13) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (16:0,16) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.cspans.txt new file mode 100644 index 0000000000..91506cb48b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [13] ) +Code span at (1:0,1 [12] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [13] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.stree.txt new file mode 100644 index 0000000000..e32608be70 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 13 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [module.foo()] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:5 + CSharpTokenType.Identifier;[module]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.cspans.txt new file mode 100644 index 0000000000..df81e75cc2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.diag.txt new file mode 100644 index 0000000000..c6d6925451 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.stree.txt new file mode 100644 index 0000000000..8f8de632d0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.cspans.txt new file mode 100644 index 0000000000..df81e75cc2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.diag.txt new file mode 100644 index 0000000000..6d8d0cd1bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: "/" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.stree.txt new file mode 100644 index 0000000000..8f8de632d0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.cspans.txt new file mode 100644 index 0000000000..4c546c5213 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [12] ) +Code span at (1:0,1 [11] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [12] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.stree.txt new file mode 100644 index 0000000000..b130a21495 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 12 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar.baz] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:5 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.cspans.txt new file mode 100644 index 0000000000..76e4befa6f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) +Code span at (1:0,1 [8] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [9] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.stree.txt new file mode 100644 index 0000000000..a03e6f1514 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.stree.txt @@ -0,0 +1,10 @@ +Expression block - Gen - 9 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[-1]] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:6 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Minus;[-]; + CSharpTokenType.IntegerLiteral;[1]; + CSharpTokenType.RightBracket;[]]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.cspans.txt new file mode 100644 index 0000000000..d4f90972e4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [15] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [15] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.diag.txt new file mode 100644 index 0000000000..a6129d65d7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.diag.txt @@ -0,0 +1 @@ +(1,12): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.stree.txt new file mode 100644 index 0000000000..2445b36952 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.stree.txt @@ -0,0 +1,12 @@ +Expression block - Gen - 15 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[abc]?[def] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:8 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[abc]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[def]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.cspans.txt new file mode 100644 index 0000000000..bde230d5d2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [14] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.stree.txt new file mode 100644 index 0000000000..fcfaadd462 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.stree.txt @@ -0,0 +1,13 @@ +Expression block - Gen - 14 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[abc]?[2]] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:9 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[abc]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.IntegerLiteral;[2]; + CSharpTokenType.RightBracket;[]]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.cspans.txt new file mode 100644 index 0000000000..234d8ba877 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +Code span at (1:0,1 [21] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.stree.txt new file mode 100644 index 0000000000..3c1fe5005f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.stree.txt @@ -0,0 +1,16 @@ +Expression block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[abc]?.more?[def]] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:12 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[abc]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[more]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[def]; + CSharpTokenType.RightBracket;[]]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.cspans.txt new file mode 100644 index 0000000000..49e8605cc5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) +Code span at (1:0,1 [20] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.stree.txt new file mode 100644 index 0000000000..24b8db6eaf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.stree.txt @@ -0,0 +1,15 @@ +Expression block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[abc]?.more?.abc] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:11 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[abc]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[more]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[abc]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.cspans.txt new file mode 100644 index 0000000000..8df3e04068 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [19] ) +Code span at (1:0,1 [18] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.stree.txt new file mode 100644 index 0000000000..d8b3eb81dd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.stree.txt @@ -0,0 +1,13 @@ +Expression block - Gen - 19 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[null ?? true]] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:9 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NullCoalesce;[??]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightBracket;[]]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.cspans.txt new file mode 100644 index 0000000000..9c65443a64 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [20] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.stree.txt new file mode 100644 index 0000000000..6cef2a04b9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.stree.txt @@ -0,0 +1,17 @@ +Expression block - Gen - 20 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[abc?.gef?[-1]]] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:13 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[abc]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[gef]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Minus;[-]; + CSharpTokenType.IntegerLiteral;[1]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.RightBracket;[]]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.cspans.txt new file mode 100644 index 0000000000..07cb5c264d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [6] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.stree.txt new file mode 100644 index 0000000000..6323d68f11 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 6 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.cspans.txt new file mode 100644 index 0000000000..f8322b2de0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.stree.txt new file mode 100644 index 0000000000..a46eeb9133 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.stree.txt @@ -0,0 +1,8 @@ +Expression block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[more] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:4 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[more]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.cspans.txt new file mode 100644 index 0000000000..befccd6124 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.stree.txt new file mode 100644 index 0000000000..b57c6e2517 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[0]] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:5 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.RightBracket;[]]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.cspans.txt new file mode 100644 index 0000000000..07cb5c264d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [6] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.stree.txt new file mode 100644 index 0000000000..6323d68f11 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 6 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.cspans.txt new file mode 100644 index 0000000000..54b541935f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [11] ) +Code span at (1:0,1 [10] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [11] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.stree.txt new file mode 100644 index 0000000000..61ca8525a6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 11 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?[more.] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:5 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.Identifier;[more]; + CSharpTokenType.Dot;[.]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.cspans.txt new file mode 100644 index 0000000000..6c0269d3fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.stree.txt new file mode 100644 index 0000000000..957c73bbe7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.stree.txt @@ -0,0 +1,8 @@ +Expression block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?.more] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:4 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[more]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.cspans.txt new file mode 100644 index 0000000000..8df3e04068 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [19] ) +Code span at (1:0,1 [18] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [19] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.stree.txt new file mode 100644 index 0000000000..0a0c3e1a67 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.stree.txt @@ -0,0 +1,13 @@ +Expression block - Gen - 19 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?.more(false)?.] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:9 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[more]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.cspans.txt new file mode 100644 index 0000000000..234d8ba877 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +Code span at (1:0,1 [21] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.stree.txt new file mode 100644 index 0000000000..8f54d19b74 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.stree.txt @@ -0,0 +1,14 @@ +Expression block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?.more(false)?.abc] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:10 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[more]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[abc]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.cspans.txt new file mode 100644 index 0000000000..451e06d958 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [29] ) +Code span at (1:0,1 [28] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [29] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.stree.txt new file mode 100644 index 0000000000..bfb8b54625 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.stree.txt @@ -0,0 +1,18 @@ +Expression block - Gen - 29 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?.more(null ?? true)?.abc] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:14 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[more]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[null]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NullCoalesce;[??]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[abc]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.cspans.txt new file mode 100644 index 0000000000..dd3f06b886 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [6] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.stree.txt new file mode 100644 index 0000000000..3860072ffb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 6 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?.] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.stree.txt new file mode 100644 index 0000000000..d0922098d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[val]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.cspans.txt new file mode 100644 index 0000000000..dd3f06b886 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [6] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.stree.txt new file mode 100644 index 0000000000..3860072ffb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 6 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?.] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.cspans.txt new file mode 100644 index 0000000000..dd3f06b886 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [6] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.stree.txt new file mode 100644 index 0000000000..3860072ffb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 6 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?.] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.cspans.txt new file mode 100644 index 0000000000..6c0269d3fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.stree.txt new file mode 100644 index 0000000000..957c73bbe7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.stree.txt @@ -0,0 +1,8 @@ +Expression block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [val?.more] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:4 + CSharpTokenType.Identifier;[val]; + CSharpTokenType.QuestionMark;[?]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[more]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.stree.txt new file mode 100644 index 0000000000..8967206fd1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.cspans.txt new file mode 100644 index 0000000000..5daaaee8dd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [34] ) +Code span at (1:0,1 [33] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [34] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.stree.txt new file mode 100644 index 0000000000..b600515ce2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.stree.txt @@ -0,0 +1,25 @@ +Expression block - Gen - 34 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar[4 * (8 + 7)]["fo\"o"].baz] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:21 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.IntegerLiteral;[4]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Star;[*]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.IntegerLiteral;[8]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Plus;[+]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[7]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.StringLiteral;["fo\"o"]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.cspans.txt new file mode 100644 index 0000000000..f685dcc492 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [115] ) +Code span at (1:0,1 [114] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [115] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.stree.txt new file mode 100644 index 0000000000..860b824f83 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.stree.txt @@ -0,0 +1,63 @@ +Expression block - Gen - 115 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo().bar("bi\"z", 4)("chained method; call").baz(@"bo""z", '\'', () => { return 4; }, (4+5+new { foo = bar[4] }))] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:59 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;["bi\"z"]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[4]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;["chained method; call"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;[@"bo""z"]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.CharacterLiteral;['\'']; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.GreaterThanEqual;[=>]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[return]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[4]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.IntegerLiteral;[4]; + CSharpTokenType.Plus;[+]; + CSharpTokenType.IntegerLiteral;[5]; + CSharpTokenType.Plus;[+]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftBracket;[[]; + CSharpTokenType.IntegerLiteral;[4]; + CSharpTokenType.RightBracket;[]]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.cspans.txt new file mode 100644 index 0000000000..a736fc1a28 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (1:0,1 [6] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [7] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.diag.txt new file mode 100644 index 0000000000..ade6c85b25 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.stree.txt new file mode 100644 index 0000000000..baef337685 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.stree.txt @@ -0,0 +1,8 @@ +Expression block - Gen - 7 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo(()] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:4 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.cspans.txt new file mode 100644 index 0000000000..a9cb762b3d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [103] ) +Code span at (1:0,1 [102] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [103] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.stree.txt new file mode 100644 index 0000000000..00f9a55723 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.stree.txt @@ -0,0 +1,39 @@ +Expression block - Gen - 103 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [DataGridColumn.Template("Years of Service", e => (int)Math.Round((DateTime.Now - dt).TotalDays / 365))] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:35 + CSharpTokenType.Identifier;[DataGridColumn]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Template]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;["Years of Service"]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[e]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.GreaterThanEqual;[=>]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Identifier;[Math]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Round]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[DateTime]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Now]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Minus;[-]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[dt]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[TotalDays]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Slash;[/]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[365]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.cspans.txt new file mode 100644 index 0000000000..befccd6124 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [8] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.stree.txt new file mode 100644 index 0000000000..a319543617 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.stree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.cspans.txt new file mode 100644 index 0000000000..bde230d5d2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [14] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.stree.txt new file mode 100644 index 0000000000..505ddd1f05 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.stree.txt @@ -0,0 +1,11 @@ +Expression block - Gen - 14 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo().bar.baz] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:7 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.cspans.txt new file mode 100644 index 0000000000..bde230d5d2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [14] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.stree.txt new file mode 100644 index 0000000000..505ddd1f05 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.stree.txt @@ -0,0 +1,11 @@ +Expression block - Gen - 14 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo().bar.baz] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:7 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.cspans.txt new file mode 100644 index 0000000000..bde230d5d2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [14] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.stree.txt new file mode 100644 index 0000000000..505ddd1f05 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.stree.txt @@ -0,0 +1,11 @@ +Expression block - Gen - 14 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo().bar.baz] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:7 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[baz]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.stree.txt new file mode 100644 index 0000000000..8967206fd1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.cspans.txt new file mode 100644 index 0000000000..6c0269d3fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.stree.txt new file mode 100644 index 0000000000..7dc1a3a043 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.stree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo.bar()] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:5 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.cspans.txt new file mode 100644 index 0000000000..cdb23fb755 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.stree.txt new file mode 100644 index 0000000000..8967206fd1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.cspans.txt new file mode 100644 index 0000000000..a8e36b11c4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Code span at (1:0,1 [34] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.stree.txt new file mode 100644 index 0000000000..f34e002cbb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.stree.txt @@ -0,0 +1,29 @@ +Statement block - Gen - 35 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [while(true) { { { { foo(); } } } }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:25 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.cspans.txt new file mode 100644 index 0000000000..541106b6ac --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.cspans.txt @@ -0,0 +1,7 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +Code span at (17:0,17 [3] ) (Accepts:Any) - Parent: Expression block at (15:0,15 [6] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +Code span at (21:0,21 [2] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.stree.txt new file mode 100644 index 0000000000..e7571bdb11 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.stree.txt @@ -0,0 +1,23 @@ +Statement block - Gen - 23 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [while(true) { ] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:7 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Expression block - Gen - 6 - (15:0,15) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [foo] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (20:0,20) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:None - (21:0,21) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.cspans.txt new file mode 100644 index 0000000000..6f05c63fa9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.cspans.txt @@ -0,0 +1,5 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [4] ) +Code span at (16:0,16 [3] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (15:0,15 [4] ) +Code span at (19:0,19 [2] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.stree.txt new file mode 100644 index 0000000000..2f0e49b1ad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.stree.txt @@ -0,0 +1,19 @@ +Statement block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [while(true) { ] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:7 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + Expression block - Gen - 4 - (15:0,15) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[ATD];K14 - (16:0,16) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:None - (19:0,19) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.cspans.txt new file mode 100644 index 0000000000..6c20e8c513 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Code span at (1:0,1 [54] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.stree.txt new file mode 100644 index 0000000000..f7c3782b99 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.stree.txt @@ -0,0 +1,43 @@ +Statement block - Gen - 55 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [while(true) { for(int i = 0; i < 10; i++) { foo(); } }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:39 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[for]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.Increment;[++]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.cspans.txt new file mode 100644 index 0000000000..5d9abf510b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.cspans.txt @@ -0,0 +1,8 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Code span at (1:0,1 [13] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [14] ) +Markup span at (15:0,15 [3] ) (Accepts:None) - Parent: Tag block at (15:0,15 [3] ) +Markup span at (18:0,18 [5] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [14] ) +Markup span at (23:0,23 [4] ) (Accepts:None) - Parent: Tag block at (23:0,23 [4] ) +Markup span at (27:0,27 [1] ) (Accepts:None) - Parent: Markup block at (14:0,14 [14] ) +Code span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.stree.txt new file mode 100644 index 0000000000..8293783918 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.stree.txt @@ -0,0 +1,30 @@ +Statement block - Gen - 29 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [while(true) {] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:6 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 14 - (14:0,14) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (15:0,15) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Hello] - SpanEditHandler;Accepts:Any - (18:0,18) - Tokens:1 + HtmlTokenType.Text;[Hello]; + Tag block - Gen - 4 - (23:0,23) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (23:0,23) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (27:0,27) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:None - (28:0,28) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.cspans.txt new file mode 100644 index 0000000000..2a8edbf4a0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.stree.txt new file mode 100644 index 0000000000..5a2eb3d2e3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.stree.txt @@ -0,0 +1,17 @@ +Statement block - Gen - 23 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [while(true) { foo(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:13 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.cspans.txt new file mode 100644 index 0000000000..2dcfb49765 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [4] ) +Comment span at (2:0,2 [0] ) (Accepts:Any) - Parent: Comment block at (0:0,0 [4] ) +MetaCode span at (2:0,2 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [4] ) +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [4] ) +Markup span at (4:0,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.stree.txt new file mode 100644 index 0000000000..23850e4407 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.stree.txt @@ -0,0 +1,16 @@ +Markup block - Gen - 4 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Comment block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (2:0,2) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (3:0,3) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (4:0,4) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.cspans.txt new file mode 100644 index 0000000000..290c517695 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (5:1,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (7:1,2 [1] ) (Accepts:None) - Parent: Comment block at (7:1,2 [4] ) +MetaCode span at (8:1,3 [1] ) (Accepts:None) - Parent: Comment block at (7:1,2 [4] ) +Comment span at (9:1,4 [0] ) (Accepts:Any) - Parent: Comment block at (7:1,2 [4] ) +MetaCode span at (9:1,4 [1] ) (Accepts:None) - Parent: Comment block at (7:1,2 [4] ) +Transition span at (10:1,5 [1] ) (Accepts:None) - Parent: Comment block at (7:1,2 [4] ) +Markup span at (11:1,6 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (15:2,0 [1] ) (Accepts:None) - Parent: Comment block at (15:2,0 [4] ) +MetaCode span at (16:2,1 [1] ) (Accepts:None) - Parent: Comment block at (15:2,0 [4] ) +Comment span at (17:2,2 [0] ) (Accepts:Any) - Parent: Comment block at (15:2,0 [4] ) +MetaCode span at (17:2,2 [1] ) (Accepts:None) - Parent: Comment block at (15:2,0 [4] ) +Transition span at (18:2,3 [1] ) (Accepts:None) - Parent: Comment block at (15:2,0 [4] ) +Markup span at (19:2,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (21:3,0 [4] ) (Accepts:Any) - Parent: Tag block at (21:3,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.stree.txt new file mode 100644 index 0000000000..7c36168330 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.stree.txt @@ -0,0 +1,43 @@ +Markup block - Gen - 25 - (0:0,0) + Tag block - Gen - 3 - (0:0,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (3:0,3) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (5:1,0) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Comment block - Gen - 4 - (7:1,2) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (7:1,2) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (8:1,3) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (9:1,4) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (9:1,4) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (10:1,5) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [ LF] - SpanEditHandler;Accepts:Any - (11:1,6) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.NewLine;[LF]; + Comment block - Gen - 4 - (15:2,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (15:2,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (16:2,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (17:2,2) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (17:2,2) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (18:2,3) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (19:2,4) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 4 - (21:3,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (21:3,0) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.cspans.txt new file mode 100644 index 0000000000..45659c7dad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (5:1,0 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +MetaCode span at (6:1,1 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Comment span at (7:1,2 [0] ) (Accepts:Any) - Parent: Comment block at (5:1,0 [4] ) +MetaCode span at (7:1,2 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Transition span at (8:1,3 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Markup span at (9:1,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Markup span at (9:1,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (11:1,6 [1] ) (Accepts:None) - Parent: Comment block at (11:1,6 [4] ) +MetaCode span at (12:1,7 [1] ) (Accepts:None) - Parent: Comment block at (11:1,6 [4] ) +Comment span at (13:1,8 [0] ) (Accepts:Any) - Parent: Comment block at (11:1,6 [4] ) +MetaCode span at (13:1,8 [1] ) (Accepts:None) - Parent: Comment block at (11:1,6 [4] ) +Transition span at (14:1,9 [1] ) (Accepts:None) - Parent: Comment block at (11:1,6 [4] ) +Markup span at (15:1,10 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Markup span at (17:2,0 [4] ) (Accepts:Any) - Parent: Tag block at (17:2,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.stree.txt new file mode 100644 index 0000000000..89fc73cdc8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.stree.txt @@ -0,0 +1,42 @@ +Markup block - Gen - 21 - (0:0,0) + Tag block - Gen - 3 - (0:0,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (3:0,3) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Comment block - Gen - 4 - (5:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (5:1,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (6:1,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (7:1,2) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (7:1,2) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (8:1,3) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (9:1,4) - Tokens:1 + HtmlTokenType.Unknown;[]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (9:1,4) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Comment block - Gen - 4 - (11:1,6) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (11:1,6) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (12:1,7) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (13:1,8) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (13:1,8) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (14:1,9) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (15:1,10) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 4 - (17:2,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (17:2,0) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.cspans.txt new file mode 100644 index 0000000000..83bce06d39 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [13] ) +Code span at (1:0,1 [6] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [13] ) +Transition span at (7:1,0 [1] ) (Accepts:None) - Parent: Comment block at (7:1,0 [4] ) +MetaCode span at (8:1,1 [1] ) (Accepts:None) - Parent: Comment block at (7:1,0 [4] ) +Comment span at (9:1,2 [0] ) (Accepts:Any) - Parent: Comment block at (7:1,0 [4] ) +MetaCode span at (9:1,2 [1] ) (Accepts:None) - Parent: Comment block at (7:1,0 [4] ) +Transition span at (10:1,3 [1] ) (Accepts:None) - Parent: Comment block at (7:1,0 [4] ) +Code span at (11:1,4 [2] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [13] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.diag.txt new file mode 100644 index 0000000000..ade6c85b25 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.stree.txt new file mode 100644 index 0000000000..a720123ae4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.stree.txt @@ -0,0 +1,23 @@ +Markup block - Gen - 13 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 13 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo(LF] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:3 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.NewLine;[LF]; + Comment block - Gen - 4 - (7:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (7:1,0) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (8:1,1) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (9:1,2) - Tokens:1 + CSharpTokenType.Unknown;[]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (9:1,2) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (10:1,3) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + Code span - Gen - [LF] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (11:1,4) - Tokens:1 + CSharpTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.cspans.txt new file mode 100644 index 0000000000..cca88e4c9f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (5:1,0 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +MetaCode span at (6:1,1 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Comment span at (7:1,2 [0] ) (Accepts:Any) - Parent: Comment block at (5:1,0 [4] ) +MetaCode span at (7:1,2 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Transition span at (8:1,3 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Markup span at (9:1,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Markup span at (11:2,0 [4] ) (Accepts:Any) - Parent: Tag block at (11:2,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.stree.txt new file mode 100644 index 0000000000..d220dd0bc1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.stree.txt @@ -0,0 +1,27 @@ +Markup block - Gen - 15 - (0:0,0) + Tag block - Gen - 3 - (0:0,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (3:0,3) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Comment block - Gen - 4 - (5:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (5:1,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (6:1,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (7:1,2) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (7:1,2) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (8:1,3) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (9:1,4) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 4 - (11:2,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (11:2,0) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.cspans.txt new file mode 100644 index 0000000000..2e38229922 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +Transition span at (8:1,4 [5] ) (Accepts:Any) - Parent: Tag block at (8:1,4 [5] ) +Markup span at (13:1,9 [2] ) (Accepts:None) - Parent: Markup block at (8:1,4 [18] ) +Markup span at (15:2,0 [4] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [18] ) +Transition span at (19:2,4 [1] ) (Accepts:None) - Parent: Comment block at (19:2,4 [4] ) +MetaCode span at (20:2,5 [1] ) (Accepts:None) - Parent: Comment block at (19:2,4 [4] ) +Comment span at (21:2,6 [0] ) (Accepts:Any) - Parent: Comment block at (19:2,4 [4] ) +MetaCode span at (21:2,6 [1] ) (Accepts:None) - Parent: Comment block at (19:2,4 [4] ) +Transition span at (22:2,7 [1] ) (Accepts:None) - Parent: Comment block at (19:2,4 [4] ) +Markup span at (23:2,8 [2] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [18] ) +Markup span at (25:3,0 [1] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [18] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.diag.txt new file mode 100644 index 0000000000..1567f665b6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.diag.txt @@ -0,0 +1,3 @@ +(2,6): Error RZ1023: "" and "" tags cannot contain attributes. +(2,6): Error RZ1025: The "text" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.stree.txt new file mode 100644 index 0000000000..c83ed3402f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.stree.txt @@ -0,0 +1,35 @@ +Markup block - Gen - 26 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Statement block - Gen - 26 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [LF ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (2:0,2) - Tokens:2 + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + Markup block - Gen - 18 - (8:1,4) + Tag block - Gen - 5 - (8:1,4) + Transition span - Gen - [ - [LF] - SpanEditHandler;Accepts:None - (13:1,9) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (15:2,0) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Comment block - Gen - 4 - (19:2,4) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (19:2,4) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (20:2,5) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (21:2,6) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (21:2,6) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (22:2,7) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (23:2,8) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Markup span - Gen - [}] - SpanEditHandler;Accepts:Any - (25:3,0) - Tokens:1 + HtmlTokenType.Text;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.cspans.txt new file mode 100644 index 0000000000..d5a5996abb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (7:2,0 [1] ) (Accepts:None) - Parent: Comment block at (7:2,0 [13] ) +MetaCode span at (8:2,1 [1] ) (Accepts:None) - Parent: Comment block at (7:2,0 [13] ) +Comment span at (9:2,2 [9] ) (Accepts:Any) - Parent: Comment block at (7:2,0 [13] ) +MetaCode span at (18:2,11 [1] ) (Accepts:None) - Parent: Comment block at (7:2,0 [13] ) +Transition span at (19:2,12 [1] ) (Accepts:None) - Parent: Comment block at (7:2,0 [13] ) +Markup span at (20:2,13 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (22:3,0 [1] ) (Accepts:None) - Parent: Comment block at (22:3,0 [15] ) +MetaCode span at (23:3,1 [1] ) (Accepts:None) - Parent: Comment block at (22:3,0 [15] ) +Comment span at (24:3,2 [11] ) (Accepts:Any) - Parent: Comment block at (22:3,0 [15] ) +MetaCode span at (35:5,0 [1] ) (Accepts:None) - Parent: Comment block at (22:3,0 [15] ) +Transition span at (36:5,1 [1] ) (Accepts:None) - Parent: Comment block at (22:3,0 [15] ) +Markup span at (37:5,2 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Markup span at (39:6,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Markup span at (41:7,0 [4] ) (Accepts:Any) - Parent: Tag block at (41:7,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.stree.txt new file mode 100644 index 0000000000..f1c4b4d734 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.stree.txt @@ -0,0 +1,43 @@ +Markup block - Gen - 45 - (0:0,0) + Tag block - Gen - 3 - (0:0,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LFLF] - SpanEditHandler;Accepts:Any - (3:0,3) - Tokens:2 + HtmlTokenType.NewLine;[LF]; + HtmlTokenType.NewLine;[LF]; + Comment block - Gen - 13 - (7:2,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (7:2,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (8:2,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ content ] - SpanEditHandler;Accepts:Any - (9:2,2) - Tokens:1 + HtmlTokenType.RazorComment;[ content ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (18:2,11) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (19:2,12) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (20:2,13) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Comment block - Gen - 15 - (22:3,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (22:3,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (23:3,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [LFcontentLF] - SpanEditHandler;Accepts:Any - (24:3,2) - Tokens:1 + HtmlTokenType.RazorComment;[LFcontentLF]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (35:5,0) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (36:5,1) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (37:5,2) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (39:6,0) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 4 - (41:7,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (41:7,0) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.cspans.txt new file mode 100644 index 0000000000..4c99d23962 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (5:1,0 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [11] ) +MetaCode span at (6:1,1 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [11] ) +Comment span at (7:1,2 [7] ) (Accepts:Any) - Parent: Comment block at (5:1,0 [11] ) +MetaCode span at (14:1,9 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [11] ) +Transition span at (15:1,10 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [11] ) +Markup span at (16:1,11 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (25:1,20 [1] ) (Accepts:None) - Parent: Comment block at (25:1,20 [11] ) +MetaCode span at (26:1,21 [1] ) (Accepts:None) - Parent: Comment block at (25:1,20 [11] ) +Comment span at (27:1,22 [7] ) (Accepts:Any) - Parent: Comment block at (25:1,20 [11] ) +MetaCode span at (34:1,29 [1] ) (Accepts:None) - Parent: Comment block at (25:1,20 [11] ) +Transition span at (35:1,30 [1] ) (Accepts:None) - Parent: Comment block at (25:1,20 [11] ) +Markup span at (36:1,31 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Markup span at (38:2,0 [4] ) (Accepts:Any) - Parent: Tag block at (38:2,0 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.stree.txt new file mode 100644 index 0000000000..b4d122ddd1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.stree.txt @@ -0,0 +1,42 @@ +Markup block - Gen - 42 - (0:0,0) + Tag block - Gen - 3 - (0:0,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (3:0,3) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Comment block - Gen - 11 - (5:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (5:1,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (6:1,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ hello ] - SpanEditHandler;Accepts:Any - (7:1,2) - Tokens:1 + HtmlTokenType.RazorComment;[ hello ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (14:1,9) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (15:1,10) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [ content ] - SpanEditHandler;Accepts:Any - (16:1,11) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[content]; + HtmlTokenType.WhiteSpace;[ ]; + Comment block - Gen - 11 - (25:1,20) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (25:1,20) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (26:1,21) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [ world ] - SpanEditHandler;Accepts:Any - (27:1,22) - Tokens:1 + HtmlTokenType.RazorComment;[ world ]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (34:1,29) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (35:1,30) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (36:1,31) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 4 - (38:2,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (38:2,0) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.cspans.txt new file mode 100644 index 0000000000..c75c972a0b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [2] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [2] ) +Comment span at (2:0,2 [0] ) (Accepts:Any) - Parent: Comment block at (0:0,0 [2] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.diag.txt new file mode 100644 index 0000000000..4f3108141d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1028: End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.stree.txt new file mode 100644 index 0000000000..a42813eed7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.stree.txt @@ -0,0 +1,10 @@ +Markup block - Gen - 2 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Comment block - Gen - 2 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + HtmlTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + HtmlTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (2:0,2) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.cspans.txt new file mode 100644 index 0000000000..3b417826e4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (1:0,1 [4] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [7] ) +Transition span at (5:0,5 [1] ) (Accepts:None) - Parent: Comment block at (5:0,5 [2] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Comment block at (5:0,5 [2] ) +Comment span at (7:0,7 [0] ) (Accepts:Any) - Parent: Comment block at (5:0,5 [2] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.diag.txt new file mode 100644 index 0000000000..b65a64c148 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.diag.txt @@ -0,0 +1,2 @@ +(1,6): Error RZ1028: End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.stree.txt new file mode 100644 index 0000000000..9e50cab6a4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.stree.txt @@ -0,0 +1,16 @@ +Markup block - Gen - 7 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 7 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foo(] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:2 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + Comment block - Gen - 2 - (5:0,5) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (5:0,5) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (6:0,6) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (7:0,7) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.cspans.txt new file mode 100644 index 0000000000..3ad5a4a25d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [4] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Comment block at (2:0,2 [2] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Comment block at (2:0,2 [2] ) +Comment span at (4:0,4 [0] ) (Accepts:Any) - Parent: Comment block at (2:0,2 [2] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.diag.txt new file mode 100644 index 0000000000..37d6bd7155 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.diag.txt @@ -0,0 +1,2 @@ +(1,3): Error RZ1028: End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.stree.txt new file mode 100644 index 0000000000..cd383fd925 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.stree.txt @@ -0,0 +1,17 @@ +Markup block - Gen - 4 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Statement block - Gen - 4 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (2:0,2) - Tokens:1 + CSharpTokenType.Unknown;[]; + Comment block - Gen - 2 - (2:0,2) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (2:0,2) - Tokens:1 + CSharpTokenType.RazorCommentTransition;[@]; + MetaCode span - Gen - [*] - SpanEditHandler;Accepts:None - (3:0,3) - Tokens:1 + CSharpTokenType.RazorCommentStar;[*]; + Comment span - Gen - [] - SpanEditHandler;Accepts:Any - (4:0,4) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.cspans.txt new file mode 100644 index 0000000000..89955b584c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.cspans.txt @@ -0,0 +1 @@ +MetaCode span at (0:0,0 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [9] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.diag.txt new file mode 100644 index 0000000000..7b748fffe4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1007: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.stree.txt new file mode 100644 index 0000000000..65ed4440a2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.stree.txt @@ -0,0 +1,3 @@ +Directive block - Gen - 9 - (0:0,0) + MetaCode span - Gen - [namespace] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Keyword;[namespace]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.cspans.txt new file mode 100644 index 0000000000..546baea6fe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.cspans.txt @@ -0,0 +1 @@ +Code span at (0:0,0 [9] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [9] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.stree.txt new file mode 100644 index 0000000000..3c97840031 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.stree.txt @@ -0,0 +1,3 @@ +Expression block - Gen - 9 - (0:0,0) + Code span - Gen - [NameSpace] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (0:0,0) - Tokens:1 + CSharpTokenType.Identifier;[NameSpace]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.cspans.txt new file mode 100644 index 0000000000..56ba50f6db --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [46] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [46] ) +Markup span at (12:0,12 [18] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [46] ) +MetaCode span at (30:6,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +Markup span at (31:6,1 [2] ) (Accepts:Any) - Parent: Markup block at (31:6,1 [14] ) +Markup span at (33:7,0 [3] ) (Accepts:Any) - Parent: Tag block at (33:7,0 [3] ) +Markup span at (36:7,3 [3] ) (Accepts:Any) - Parent: Markup block at (31:6,1 [14] ) +Markup span at (39:7,6 [4] ) (Accepts:Any) - Parent: Tag block at (39:7,6 [4] ) +Markup span at (43:7,10 [2] ) (Accepts:Any) - Parent: Markup block at (31:6,1 [14] ) +MetaCode span at (45:8,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +Markup span at (46:8,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.stree.txt new file mode 100644 index 0000000000..c601f9eed9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.stree.txt @@ -0,0 +1,44 @@ +Markup block - Gen - 46 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 46 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ LFLFLFLFLFLF] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:7 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.NewLine;[LF]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (30:6,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 14 - (31:6,1) + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (31:6,1) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 3 - (33:7,0) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (33:7,0) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (36:7,3) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (39:7,6) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (39:7,6) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (43:7,10) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (45:8,0) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (46:8,1) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.cspans.txt new file mode 100644 index 0000000000..20913b3efd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [76] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [76] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [76] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [76] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [76] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [76] ) +Markup span at (14:0,14 [54] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [61] ) +Transition span at (68:0,68 [1] ) (Accepts:None) - Parent: Expression block at (68:0,68 [6] ) +MetaCode span at (69:0,69 [1] ) (Accepts:None) - Parent: Expression block at (68:0,68 [6] ) +Code span at (70:0,70 [3] ) (Accepts:Any) - Parent: Expression block at (68:0,68 [6] ) +MetaCode span at (73:0,73 [1] ) (Accepts:None) - Parent: Expression block at (68:0,68 [6] ) +Markup span at (74:0,74 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [61] ) +MetaCode span at (75:0,75 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [76] ) +Markup span at (76:0,76 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.stree.txt new file mode 100644 index 0000000000..f0c43e199a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.stree.txt @@ -0,0 +1,58 @@ +Markup block - Gen - 76 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 76 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 61 - (14:0,14) + Markup span - Gen - [ I really want to render a close brace, so here I go: ] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:25 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[I]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[really]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[want]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[to]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[render]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[a]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[close]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[brace,]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[so]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[here]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[I]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[go:]; + HtmlTokenType.WhiteSpace;[ ]; + Expression block - Gen - 6 - (68:0,68) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (68:0,68) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (69:0,69) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - ["}"] - SpanEditHandler;Accepts:Any - (70:0,70) - Tokens:1 + CSharpTokenType.StringLiteral;["}"]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (73:0,73) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (74:0,74) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (75:0,75) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (76:0,76) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.cspans.txt new file mode 100644 index 0000000000..227fa11335 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [67] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [67] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [67] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [67] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [52] ) +Markup span at (15:0,15 [8] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [8] ) +Markup span at (23:0,23 [33] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [52] ) +Markup span at (56:0,56 [9] ) (Accepts:Any) - Parent: Tag block at (56:0,56 [9] ) +Markup span at (65:0,65 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [52] ) +MetaCode span at (66:0,66 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +Markup span at (67:0,67 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [67] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.stree.txt new file mode 100644 index 0000000000..60d6671298 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.stree.txt @@ -0,0 +1,48 @@ +Markup block - Gen - 67 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 67 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 52 - (14:0,14) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 8 - (15:0,15) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (56:0,56) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[script]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (65:0,65) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (66:0,66) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (67:0,67) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.cspans.txt new file mode 100644 index 0000000000..438f3272c6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (8:0,8 [0] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.stree.txt new file mode 100644 index 0000000000..689b12e4aa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.stree.txt @@ -0,0 +1,12 @@ +Markup block - Gen - 10 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.Unknown;[]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (8:0,8) - Tokens:1 + HtmlTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.cspans.txt new file mode 100644 index 0000000000..28235f8416 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [9] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (17:0,17 [0] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (17:0,17 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.stree.txt new file mode 100644 index 0000000000..0fde9614d9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.stree.txt @@ -0,0 +1,15 @@ +Markup block - Gen - 23 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (17:0,17) - Tokens:1 + CSharpTokenType.Unknown;[]; + Markup span - Gen - [LF ] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:2 + HtmlTokenType.NewLine;[LF]; + HtmlTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.cspans.txt new file mode 100644 index 0000000000..bff6dfd779 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (12:0,12 [15] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (27:1,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.stree.txt new file mode 100644 index 0000000000..3a2c1106da --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.stree.txt @@ -0,0 +1,18 @@ +Markup block - Gen - 27 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 27 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[Foo]; + Markup span - Gen - [ LF ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:3 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (27:1,4) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.cspans.txt new file mode 100644 index 0000000000..975ab15e40 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (10:0,10 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (12:0,12 [2] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [20] ) +Markup span at (14:1,0 [4] ) (Accepts:Any) - Parent: Tag block at (14:1,0 [4] ) +Markup span at (18:2,0 [4] ) (Accepts:None) - Parent: HtmlComment block at (18:2,0 [14] ) +Markup span at (22:2,4 [7] ) (Accepts:WhiteSpace) - Parent: HtmlComment block at (18:2,0 [14] ) +Markup span at (29:2,11 [3] ) (Accepts:None) - Parent: HtmlComment block at (18:2,0 [14] ) +Markup span at (32:2,14 [0] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [20] ) +MetaCode span at (32:2,14 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (33:2,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.stree.txt new file mode 100644 index 0000000000..e764c527f3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.stree.txt @@ -0,0 +1,45 @@ +Markup block - Gen - 33 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 33 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [s] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[s]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (11:0,11) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 20 - (12:0,12) + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (12:0,12) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Tag block - Gen - 4 - (14:1,0) + Markup span - Gen - [ - 14 - (18:2,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:None - (29:2,11) - Tokens:2 + HtmlTokenType.DoubleHyphen;[--]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (32:2,14) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (32:2,14) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (33:2,15) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.cspans.txt new file mode 100644 index 0000000000..8df309466c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [24] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [24] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [24] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Markup span at (14:0,14 [9] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [9] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Markup span at (24:0,24 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.stree.txt new file mode 100644 index 0000000000..6bc6ea89b2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.stree.txt @@ -0,0 +1,23 @@ +Markup block - Gen - 24 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 24 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 9 - (14:0,14) + Markup span - Gen - [something] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.Text;[something]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (23:0,23) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (24:0,24) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.cspans.txt new file mode 100644 index 0000000000..bd03ebf705 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [26] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (12:0,12 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (13:0,13 [1] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [12] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [3] ) +Markup span at (17:0,17 [3] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [12] ) +Markup span at (20:0,20 [4] ) (Accepts:Any) - Parent: Tag block at (20:0,20 [4] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [12] ) +MetaCode span at (25:0,25 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (26:0,26 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.stree.txt new file mode 100644 index 0000000000..55381a524f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.stree.txt @@ -0,0 +1,36 @@ +Markup block - Gen - 26 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 26 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (12:0,12) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (13:0,13) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (13:0,13) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (14:0,14) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (20:0,20) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (20:0,20) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (24:0,24) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (25:0,25) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (26:0,26) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.cspans.txt new file mode 100644 index 0000000000..2ae2e13090 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [14] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [14] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [0] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.stree.txt new file mode 100644 index 0000000000..19018c5dbe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.stree.txt @@ -0,0 +1,19 @@ +Markup block - Gen - 14 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 14 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 0 - (14:0,14) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.cspans.txt new file mode 100644 index 0000000000..92cb61d49b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [15] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [15] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [15] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.stree.txt new file mode 100644 index 0000000000..134177d6a6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.stree.txt @@ -0,0 +1,19 @@ +Markup block - Gen - 15 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 15 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 1 - (14:0,14) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.cspans.txt new file mode 100644 index 0000000000..b485a40f1e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (14:0,14 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [2] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.stree.txt new file mode 100644 index 0000000000..0a934073ea --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.stree.txt @@ -0,0 +1,19 @@ +Markup block - Gen - 16 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 16 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 2 - (14:0,14) + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.NewLine;[LF]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.cspans.txt new file mode 100644 index 0000000000..81962d91a4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [3] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.stree.txt new file mode 100644 index 0000000000..d828a581f0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.stree.txt @@ -0,0 +1,19 @@ +Markup block - Gen - 17 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 17 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 3 - (14:0,14) + Markup span - Gen - [abc] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.Text;[abc]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.cspans.txt new file mode 100644 index 0000000000..f180faa3a8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [20] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (14:0,14 [6] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [6] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.stree.txt new file mode 100644 index 0000000000..dfd8d9e423 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.stree.txt @@ -0,0 +1,21 @@ +Markup block - Gen - 20 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 20 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 6 - (14:0,14) + Markup span - Gen - [LF abc] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:3 + HtmlTokenType.NewLine;[LF]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[abc]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.cspans.txt new file mode 100644 index 0000000000..83b4408923 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [13] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [3] ) +Markup span at (18:0,18 [5] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [13] ) +Markup span at (23:0,23 [4] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [4] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.stree.txt new file mode 100644 index 0000000000..bc5eedd22b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.stree.txt @@ -0,0 +1,34 @@ +Markup block - Gen - 27 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 27 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 13 - (14:0,14) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (15:0,15) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (15:0,15) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo{}] - SpanEditHandler;Accepts:Any - (18:0,18) - Tokens:3 + HtmlTokenType.Text;[Foo]; + HtmlTokenType.Text;[{]; + HtmlTokenType.Text;[}]; + Tag block - Gen - 4 - (23:0,23) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (23:0,23) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.cspans.txt new file mode 100644 index 0000000000..ee6a1dfb85 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [73] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [73] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [73] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [73] ) +Code span at (9:0,9 [4] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [73] ) +Markup span at (13:0,13 [2] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [73] ) +MetaCode span at (15:1,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [73] ) +Markup span at (16:1,1 [2] ) (Accepts:Any) - Parent: Markup block at (16:1,1 [57] ) +Code span at (18:2,0 [4] ) (Accepts:Any) - Parent: Statement block at (18:2,0 [55] ) +Transition span at (22:2,4 [1] ) (Accepts:None) - Parent: Statement block at (18:2,0 [55] ) +Code span at (23:2,5 [17] ) (Accepts:Any) - Parent: Statement block at (18:2,0 [55] ) +Markup span at (40:4,0 [8] ) (Accepts:Any) - Parent: Markup block at (40:4,0 [28] ) +Markup span at (48:4,8 [3] ) (Accepts:None) - Parent: Tag block at (48:4,8 [3] ) +Markup span at (51:4,11 [11] ) (Accepts:Any) - Parent: Markup block at (40:4,0 [28] ) +Markup span at (62:4,22 [4] ) (Accepts:None) - Parent: Tag block at (62:4,22 [4] ) +Markup span at (66:4,26 [2] ) (Accepts:None) - Parent: Markup block at (40:4,0 [28] ) +Code span at (68:5,0 [5] ) (Accepts:Any) - Parent: Statement block at (18:2,0 [55] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.stree.txt new file mode 100644 index 0000000000..4090ca154c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.stree.txt @@ -0,0 +1,56 @@ +Markup block - Gen - 73 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 73 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Test] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[Test]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:AllWhiteSpace - (13:0,13) - Tokens:1 + CSharpTokenType.NewLine;[LF]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (15:1,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 57 - (16:1,1) + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (16:1,1) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Statement block - Gen - 55 - (18:2,0) + Code span - Gen - [ ] - SpanEditHandler;Accepts:Any - (18:2,0) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (22:2,4) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if(true)LF {LF] - SpanEditHandler;Accepts:Any - (23:2,5) - Tokens:8 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + Markup block - Gen - 28 - (40:4,0) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (40:4,0) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (48:4,8) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (48:4,8) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Hello World] - SpanEditHandler;Accepts:Any - (51:4,11) - Tokens:3 + HtmlTokenType.Text;[Hello]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[World]; + Tag block - Gen - 4 - (62:4,22) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (62:4,22) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:None - (66:4,26) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (68:5,0) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.cspans.txt new file mode 100644 index 0000000000..cd444657cd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.stree.txt new file mode 100644 index 0000000000..59d3f3e25a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.stree.txt @@ -0,0 +1,11 @@ +Markup block - Gen - 12 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [Section] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K15 - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[Section]; + Markup span - Gen - [ foo] - SpanEditHandler;Accepts:Any - (8:0,8) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.cspans.txt new file mode 100644 index 0000000000..3e998dd114 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.cspans.txt @@ -0,0 +1,23 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [29] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [27] ) +MetaCode span at (16:0,16 [7] ) (Accepts:None) - Parent: Directive block at (15:0,15 [27] ) +Code span at (23:0,23 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (15:0,15 [27] ) +Code span at (24:0,24 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (15:0,15 [27] ) +Markup span at (27:0,27 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (15:0,15 [27] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [27] ) +Markup span at (29:0,29 [1] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [12] ) +Markup span at (30:0,30 [3] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [3] ) +Markup span at (33:0,33 [3] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [12] ) +Markup span at (36:0,36 [4] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [4] ) +Markup span at (40:0,40 [1] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [12] ) +MetaCode span at (41:0,41 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [27] ) +Markup span at (42:0,42 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [29] ) +MetaCode span at (43:0,43 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:0,44 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.stree.txt new file mode 100644 index 0000000000..b8abb7fa56 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.stree.txt @@ -0,0 +1,58 @@ +Markup block - Gen - 44 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 44 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 29 - (14:0,14) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Directive block - Gen - 27 - (15:0,15) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (15:0,15) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (16:0,16) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (23:0,23) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [bar] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (24:0,24) - Tokens:1 + CSharpTokenType.Identifier;[bar]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (27:0,27) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (28:0,28) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (29:0,29) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (29:0,29) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (30:0,30) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (30:0,30) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (33:0,33) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (36:0,36) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (36:0,36) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (40:0,40) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (41:0,41) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (42:0,42) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (43:0,43) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (44:0,44) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.cspans.txt new file mode 100644 index 0000000000..d48a285438 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [21] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (10:0,10 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (12:0,12 [4] ) (Accepts:None) - Parent: HtmlComment block at (12:0,12 [8] ) +Markup span at (16:0,16 [1] ) (Accepts:WhiteSpace) - Parent: HtmlComment block at (12:0,12 [8] ) +Markup span at (17:0,17 [3] ) (Accepts:None) - Parent: HtmlComment block at (12:0,12 [8] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [8] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.stree.txt new file mode 100644 index 0000000000..4bdbe3877f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.stree.txt @@ -0,0 +1,33 @@ +Markup block - Gen - 21 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [s] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[s]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (11:0,11) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 8 - (12:0,12) + HtmlComment block - Gen - 8 - (12:0,12) + Markup span - Gen - [] - SpanEditHandler;Accepts:None - (17:0,17) - Tokens:2 + HtmlTokenType.DoubleHyphen;[--]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (20:0,20) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (20:0,20) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (21:0,21) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.cspans.txt new file mode 100644 index 0000000000..dc6a5cfa46 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [26] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (10:0,10 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (12:0,12 [4] ) (Accepts:None) - Parent: HtmlComment block at (12:0,12 [13] ) +Markup span at (16:0,16 [6] ) (Accepts:WhiteSpace) - Parent: HtmlComment block at (12:0,12 [13] ) +Markup span at (22:0,22 [3] ) (Accepts:None) - Parent: HtmlComment block at (12:0,12 [13] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [13] ) +MetaCode span at (25:0,25 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (26:0,26 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.stree.txt new file mode 100644 index 0000000000..86e6444d85 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.stree.txt @@ -0,0 +1,38 @@ +Markup block - Gen - 26 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 26 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [s] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[s]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (11:0,11) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 13 - (12:0,12) + HtmlComment block - Gen - 13 - (12:0,12) + Markup span - Gen - [] - SpanEditHandler;Accepts:None - (22:0,22) - Tokens:2 + HtmlTokenType.DoubleHyphen;[--]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (25:0,25) - Tokens:1 + HtmlTokenType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (25:0,25) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (26:0,26) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.cspans.txt new file mode 100644 index 0000000000..28dd678224 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [12] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [3] ) +Markup span at (18:0,18 [3] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [12] ) +Markup span at (21:0,21 [4] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [4] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [12] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.stree.txt new file mode 100644 index 0000000000..816ec6dd7f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.stree.txt @@ -0,0 +1,38 @@ +Markup block - Gen - 27 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 27 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 12 - (14:0,14) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (15:0,15) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (15:0,15) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (18:0,18) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (21:0,21) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (21:0,21) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (25:0,25) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (26:0,26) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (27:0,27) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.cspans.txt new file mode 100644 index 0000000000..58cbbb3588 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [28] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [28] ) +Markup span at (10:0,10 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Markup span at (12:0,12 [15] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [15] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.stree.txt new file mode 100644 index 0000000000..92cd8e4296 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.stree.txt @@ -0,0 +1,32 @@ +Markup block - Gen - 28 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 28 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [s] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[s]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (11:0,11) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 15 - (12:0,12) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (12:0,12) - Tokens:10 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.QuestionMark;[?]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[xml]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[bleh]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.QuestionMark;[?]; + HtmlTokenType.CloseAngle;[>]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (27:0,27) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (28:0,28) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.cspans.txt new file mode 100644 index 0000000000..d1aebb95ee --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [20] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (12:0,12 [8] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (20:1,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.stree.txt new file mode 100644 index 0000000000..f0c5008e10 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.stree.txt @@ -0,0 +1,17 @@ +Markup block - Gen - 20 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 20 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [ LF] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:2 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.NewLine;[LF]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (20:1,0) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.cspans.txt new file mode 100644 index 0000000000..91c582c57e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [9] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [9] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [9] ) +Markup span at (9:0,9 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [3] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (19:0,19 [4] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [4] ) +Markup span at (23:0,23 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.stree.txt new file mode 100644 index 0000000000..2505742c14 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.stree.txt @@ -0,0 +1,31 @@ +Markup block - Gen - 25 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 9 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Markup span - Gen - [9 { ] - SpanEditHandler;Accepts:Any - (9:0,9) - Tokens:4 + HtmlTokenType.Text;[9]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[{]; + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (13:0,13) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (13:0,13) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (16:0,16) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (19:0,19) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (19:0,19) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ }] - SpanEditHandler;Accepts:Any - (23:0,23) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.cspans.txt new file mode 100644 index 0000000000..b96ad7e8d4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [12] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [12] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [12] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [12] ) +Markup span at (12:0,12 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Markup span at (19:0,19 [3] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [3] ) +Markup span at (22:0,22 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Markup span at (25:0,25 [4] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [4] ) +Markup span at (29:0,29 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.stree.txt new file mode 100644 index 0000000000..f9fea55241 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.stree.txt @@ -0,0 +1,33 @@ +Markup block - Gen - 31 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 12 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[foo]; + Markup span - Gen - [-bar { ] - SpanEditHandler;Accepts:Any - (12:0,12) - Tokens:4 + HtmlTokenType.Text;[-bar]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[{]; + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (19:0,19) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (19:0,19) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (22:0,22) - Tokens:1 + HtmlTokenType.Text;[Foo]; + Tag block - Gen - 4 - (25:0,25) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:Any - (25:0,25) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [ }] - SpanEditHandler;Accepts:Any - (29:0,29) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.cspans.txt new file mode 100644 index 0000000000..2e5cfb7364 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [31] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [31] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [31] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [31] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [31] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [31] ) +Markup span at (14:0,14 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [16] ) +Transition span at (16:1,0 [1] ) (Accepts:None) - Parent: Statement block at (16:1,0 [14] ) +Code span at (17:1,1 [13] ) (Accepts:Any) - Parent: Statement block at (16:1,0 [14] ) +MetaCode span at (30:2,1 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [31] ) +Markup span at (31:2,2 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.stree.txt new file mode 100644 index 0000000000..1712aafc46 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.stree.txt @@ -0,0 +1,35 @@ +Markup block - Gen - 31 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 31 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[Foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 16 - (14:0,14) + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Statement block - Gen - 14 - (16:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (16:1,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if(true) {LF}] - SpanEditHandler;Accepts:Any - (17:1,1) - Tokens:8 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (30:2,1) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (31:2,2) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.cspans.txt new file mode 100644 index 0000000000..07b903f608 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (12:0,12 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (14:0,14 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [18] ) +Transition span at (16:1,0 [1] ) (Accepts:None) - Parent: Statement block at (16:1,0 [16] ) +Code span at (17:1,1 [15] ) (Accepts:Any) - Parent: Statement block at (16:1,0 [16] ) +MetaCode span at (32:3,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (33:3,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.stree.txt new file mode 100644 index 0000000000..5b549fd8de --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.stree.txt @@ -0,0 +1,36 @@ +Markup block - Gen - 33 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 33 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [Foo] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[Foo]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (12:0,12) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (13:0,13) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 18 - (14:0,14) + Markup span - Gen - [LF] - SpanEditHandler;Accepts:Any - (14:0,14) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Statement block - Gen - 16 - (16:1,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (16:1,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if(true) {LF}LF] - SpanEditHandler;Accepts:Any - (17:1,1) - Tokens:9 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (32:3,0) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (33:3,1) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.cspans.txt new file mode 100644 index 0000000000..45000bd914 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [30] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [30] ) +Markup span at (10:0,10 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [30] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Markup span at (12:0,12 [5] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [17] ) +Markup span at (17:0,17 [6] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [9] ) +Markup span at (23:0,23 [1] ) (Accepts:None) - Parent: Markup block at (23:0,23 [2] ) +Markup span at (24:0,24 [1] ) (Accepts:None) - Parent: Markup block at (23:0,23 [2] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [9] ) +Markup span at (26:0,26 [3] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [17] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.stree.txt new file mode 100644 index 0000000000..5be347d4cf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.stree.txt @@ -0,0 +1,42 @@ +Markup block - Gen - 30 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 30 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [s] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[s]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (11:0,11) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 17 - (12:0,12) + Tag block - Gen - 17 - (12:0,12) + Markup span - Gen - [ - 9 - (17:0,17) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 2 - (23:0,23) + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (23:0,23) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (24:0,24) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (25:0,25) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:Any - (26:0,26) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (29:0,29) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (30:0,30) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.cspans.txt new file mode 100644 index 0000000000..066623b119 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [1] ) (Accepts:WhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (10:0,10 [1] ) (Accepts:AllWhiteSpace) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (12:0,12 [5] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [31] ) +Markup span at (17:0,17 [6] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [23] ) +Transition span at (23:0,23 [1] ) (Accepts:None) - Parent: Expression block at (23:0,23 [13] ) +Code span at (24:0,24 [12] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (23:0,23 [13] ) +Markup span at (36:0,36 [2] ) (Accepts:None) - Parent: Markup block at (36:0,36 [3] ) +Markup span at (38:0,38 [1] ) (Accepts:None) - Parent: Markup block at (36:0,36 [3] ) +Markup span at (39:0,39 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [23] ) +Markup span at (40:0,40 [3] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [31] ) +MetaCode span at (43:0,43 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:0,44 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.stree.txt new file mode 100644 index 0000000000..062a860adb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.stree.txt @@ -0,0 +1,51 @@ +Markup block - Gen - 44 - (0:0,0) + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:1 + HtmlTokenType.Unknown;[]; + Directive block - Gen - 44 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [section] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.Identifier;[section]; + Code span - Gen - [ ] - SpanEditHandler;Accepts:WhiteSpace - (8:0,8) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + Code span - Gen - [s] - DirectiveTokenEditHandler;Accepts:NonWhiteSpace - (9:0,9) - Tokens:1 + CSharpTokenType.Identifier;[s]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (10:0,10) - Tokens:1 + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd - (11:0,11) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Markup block - Gen - 31 - (12:0,12) + Tag block - Gen - 31 - (12:0,12) + Markup span - Gen - [ - 23 - (17:0,17) + Markup span - Gen - [ foo='] - SpanEditHandler;Accepts:Any - (17:0,17) - Tokens:4 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[foo]; + HtmlTokenType.Equals;[=]; + HtmlTokenType.SingleQuote;[']; + Markup block - Gen - 13 - (23:0,23) + Expression block - Gen - 13 - (23:0,23) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (23:0,23) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [DateTime.Now] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K15 - (24:0,24) - Tokens:3 + CSharpTokenType.Identifier;[DateTime]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Now]; + Markup block - Gen - 3 - (36:0,36) + Markup span - Gen - [ @] - SpanEditHandler;Accepts:None - (36:0,36) - Tokens:2 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Transition;[@]; + Markup span - Gen - [@] - SpanEditHandler;Accepts:None - (38:0,38) - Tokens:1 + HtmlTokenType.Transition;[@]; + Markup span - Gen - ['] - SpanEditHandler;Accepts:Any - (39:0,39) - Tokens:1 + HtmlTokenType.SingleQuote;[']; + Markup span - Gen - [ />] - SpanEditHandler;Accepts:Any - (40:0,40) - Tokens:3 + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.CloseAngle;[>]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (43:0,43) - Tokens:1 + CSharpTokenType.RightBrace;[}]; + Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (44:0,44) - Tokens:1 + HtmlTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.cspans.txt new file mode 100644 index 0000000000..527f5f4c3b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [52] ) +Code span at (1:0,1 [50] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [52] ) +MetaCode span at (51:0,51 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [52] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.stree.txt new file mode 100644 index 0000000000..19a360fd8b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.stree.txt @@ -0,0 +1,26 @@ +Statement block - Gen - 52 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [foo"b}ar" if(condition) { string.Format("{0}"); } ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:20 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.StringLiteral;["b}ar"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[condition]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Format]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;["{0}"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (51:0,51) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.cspans.txt new file mode 100644 index 0000000000..b269e8e921 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [52] ) +Code span at (1:0,1 [50] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [52] ) +MetaCode span at (51:0,51 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [52] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.stree.txt new file mode 100644 index 0000000000..757004c73b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.stree.txt @@ -0,0 +1,26 @@ +Expression block - Gen - 52 - (0:0,0) + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [foo"b)ar" if(condition) { string.Format("{0}"); } ] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:20 + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.StringLiteral;["b)ar"]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[condition]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Format]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.StringLiteral;["{0}"]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (51:0,51) - Tokens:1 + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.cspans.txt new file mode 100644 index 0000000000..c0cc9fd147 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +Code span at (1:0,1 [35] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (36:0,36 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.diag.txt new file mode 100644 index 0000000000..88b7d730e9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.diag.txt @@ -0,0 +1,6 @@ +(1,3): Error RZ2004: Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: + +@using System.Drawing; +@{ + // OK here to use types from System.Drawing in the page. +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.stree.txt new file mode 100644 index 0000000000..41fd907da2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.stree.txt @@ -0,0 +1,25 @@ +Statement block - Gen - 37 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ using Foo.Bar.Baz; var foo = bar; ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:19 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (36:0,36) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.cspans.txt new file mode 100644 index 0000000000..1efdde7829 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Code span at (1:0,1 [54] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) +MetaCode span at (55:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.stree.txt new file mode 100644 index 0000000000..25dbecb0d5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.stree.txt @@ -0,0 +1,26 @@ +Statement block - Gen - 56 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [LF List photos = gallery.Photo.ToList();LF] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:20 + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[List]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Identifier;[dynamic]; + CSharpTokenType.GreaterThan;[>]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[photos]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[gallery]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Photo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ToList]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (55:2,0) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.cspans.txt new file mode 100644 index 0000000000..df81e75cc2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [1] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.diag.txt new file mode 100644 index 0000000000..6d8d0cd1bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: "/" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.stree.txt new file mode 100644 index 0000000000..8f8de632d0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Unknown;[]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.cspans.txt new file mode 100644 index 0000000000..13416b5786 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.cspans.txt @@ -0,0 +1,7 @@ +Code span at (0:0,0 [26] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) +Markup span at (26:2,0 [1] ) (Accepts:Any) - Parent: Markup block at (26:2,0 [21] ) +Markup span at (27:2,1 [3] ) (Accepts:None) - Parent: Tag block at (27:2,1 [3] ) +Markup span at (30:2,4 [11] ) (Accepts:Any) - Parent: Markup block at (26:2,0 [21] ) +Markup span at (41:2,15 [4] ) (Accepts:None) - Parent: Tag block at (41:2,15 [4] ) +Markup span at (45:2,19 [2] ) (Accepts:None) - Parent: Markup block at (26:2,0 [21] ) +Code span at (47:3,0 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.stree.txt new file mode 100644 index 0000000000..60b8f07d27 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.stree.txt @@ -0,0 +1,38 @@ +Statement block - Gen - 48 - (0:0,0) + Code span - Gen - [if(!false) {LF // FooLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Tokens:11 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Not;[!]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Comment;[// Foo]; + CSharpTokenType.NewLine;[LF]; + Markup block - Gen - 21 - (26:2,0) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (26:2,0) - Tokens:1 + HtmlTokenType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (27:2,1) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (27:2,1) - Tokens:3 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [A real tag!] - SpanEditHandler;Accepts:Any - (30:2,4) - Tokens:6 + HtmlTokenType.Text;[A]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[real]; + HtmlTokenType.WhiteSpace;[ ]; + HtmlTokenType.Text;[tag]; + HtmlTokenType.Bang;[!]; + Tag block - Gen - 4 - (41:2,15) + Markup span - Gen - [

            ] - SpanEditHandler;Accepts:None - (41:2,15) - Tokens:4 + HtmlTokenType.OpenAngle;[<]; + HtmlTokenType.ForwardSlash;[/]; + HtmlTokenType.Text;[p]; + HtmlTokenType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:None - (45:2,19) - Tokens:1 + HtmlTokenType.NewLine;[LF]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (47:3,0) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.cspans.txt new file mode 100644 index 0000000000..79c7f62f66 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Code span at (1:0,1 [37] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (38:0,38 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.diag.txt new file mode 100644 index 0000000000..88b7d730e9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.diag.txt @@ -0,0 +1,6 @@ +(1,3): Error RZ2004: Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: + +@using System.Drawing; +@{ + // OK here to use types from System.Drawing in the page. +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.stree.txt new file mode 100644 index 0000000000..5576cf671f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.stree.txt @@ -0,0 +1,27 @@ +Statement block - Gen - 39 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [ using Foo = Bar.Baz; var foo = bar; ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Tokens:21 + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Baz]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (38:0,38) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.cspans.txt new file mode 100644 index 0000000000..38acacf818 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [94] ) +Code span at (1:0,1 [93] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [94] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.stree.txt new file mode 100644 index 0000000000..979f01d5ec --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.stree.txt @@ -0,0 +1,46 @@ +Statement block - Gen - 94 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { foo(); } catch(IOException ioex) { handleIO(); } catch(Exception ex) { handleOther(); }] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:42 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[IOException]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[ioex]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[handleIO]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[ex]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[handleOther]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.cspans.txt new file mode 100644 index 0000000000..a8a25e0ad7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Code span at (1:0,1 [26] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.stree.txt new file mode 100644 index 0000000000..3d7b1a88af --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.stree.txt @@ -0,0 +1,20 @@ +Statement block - Gen - 27 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [do { foo(); } while(true);] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:16 + CSharpTokenType.Keyword;[do]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.cspans.txt new file mode 100644 index 0000000000..8b7ee4909d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Code span at (1:0,1 [35] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.stree.txt new file mode 100644 index 0000000000..6952c9d39e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.stree.txt @@ -0,0 +1,28 @@ +Statement block - Gen - 36 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if(true) { foo(); } else { foo(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:24 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.cspans.txt new file mode 100644 index 0000000000..61a12e9263 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [73] ) +Code span at (1:0,1 [72] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [73] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.stree.txt new file mode 100644 index 0000000000..3ac82af49f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.stree.txt @@ -0,0 +1,50 @@ +Statement block - Gen - 73 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if(true) { foo(); } else if(false) { foo(); } else if(!false) { foo(); }] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:46 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[else]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Not;[!]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.cspans.txt new file mode 100644 index 0000000000..2c96e1a76e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) +Code span at (1:0,1 [52] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.diag.txt new file mode 100644 index 0000000000..821f352b2c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.diag.txt @@ -0,0 +1 @@ +(1,24): Error RZ1006: The catch block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.stree.txt new file mode 100644 index 0000000000..a65e11f6c9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.stree.txt @@ -0,0 +1,27 @@ +Statement block - Gen - 53 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { someMethod(); } catch(Exception) when (true) {] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:23 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[someMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.cspans.txt new file mode 100644 index 0000000000..15b3ba5d1c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Code span at (1:0,1 [45] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.diag.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.diag.txt new file mode 100644 index 0000000000..33043e2030 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.diag.txt @@ -0,0 +1 @@ +(1,46): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.stree.txt new file mode 100644 index 0000000000..ea80c49749 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.stree.txt @@ -0,0 +1,23 @@ +Statement block - Gen - 46 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { someMethod(); } catch(Exception) when (] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:19 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[someMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.cspans.txt new file mode 100644 index 0000000000..dfeb469285 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [65] ) +Code span at (1:0,1 [64] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [65] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.stree.txt new file mode 100644 index 0000000000..b974facb6a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.stree.txt @@ -0,0 +1,30 @@ +Statement block - Gen - 65 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { someMethod(); } catch(Exception) when { anotherMethod(); }] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:26 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[someMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[anotherMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.cspans.txt new file mode 100644 index 0000000000..bcc2dca04d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +Code span at (1:0,1 [43] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [44] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.stree.txt new file mode 100644 index 0000000000..7672a029cd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.stree.txt @@ -0,0 +1,21 @@ +Statement block - Gen - 44 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { someMethod(); } catch(Exception) when] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:17 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[someMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.cspans.txt new file mode 100644 index 0000000000..a3f38be461 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Code span at (1:0,1 [50] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [51] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.stree.txt new file mode 100644 index 0000000000..1d47290523 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.stree.txt @@ -0,0 +1,25 @@ +Statement block - Gen - 51 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { someMethod(); } catch(Exception) when (true)] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:21 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[someMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.cspans.txt new file mode 100644 index 0000000000..b51b58a6fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Code span at (1:0,1 [21] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.stree.txt new file mode 100644 index 0000000000..1d2521b0e0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.stree.txt @@ -0,0 +1,14 @@ +Statement block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { someMethod(); }] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:10 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[someMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.cspans.txt new file mode 100644 index 0000000000..cb759cf499 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [103] ) +Code span at (1:0,1 [102] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [103] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.stree.txt new file mode 100644 index 0000000000..f814178b03 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.stree.txt @@ -0,0 +1,54 @@ +Statement block - Gen - 103 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [tryLF{LFA();LF}LFcatch(Exception) when (true)LF{LFB();LF}LFcatch(IOException) when (false)LF{LFC();LF}] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:50 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[A]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[B]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[IOException]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.Identifier;[C]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.NewLine;[LF]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.cspans.txt new file mode 100644 index 0000000000..f4610dbff0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [69] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [69] ) +Code span at (2:0,2 [66] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [69] ) +MetaCode span at (68:0,68 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [69] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.stree.txt new file mode 100644 index 0000000000..c7aebf715c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.stree.txt @@ -0,0 +1,38 @@ +Statement block - Gen - 69 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:1 + CSharpTokenType.LeftBrace;[{]; + Code span - Gen - [try { someMethod(); } catch(Exception) when (true) { handleIO(); }] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (2:0,2) - Tokens:30 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[someMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[handleIO]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (68:0,68) - Tokens:1 + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.cspans.txt new file mode 100644 index 0000000000..c7bc1af9f1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [92] ) +Code span at (1:0,1 [91] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [92] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.stree.txt new file mode 100644 index 0000000000..9b61a41852 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.stree.txt @@ -0,0 +1,54 @@ +Statement block - Gen - 92 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { A(); } catch(Exception) when (true) { B(); } catch(IOException) when (false) { C(); }] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:50 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[A]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[B]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[IOException]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[false]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[C]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.cspans.txt new file mode 100644 index 0000000000..35485fcb00 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [67] ) +Code span at (1:0,1 [66] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [67] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.stree.txt new file mode 100644 index 0000000000..d4abea3d20 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.stree.txt @@ -0,0 +1,34 @@ +Statement block - Gen - 67 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { someMethod(); } catch(Exception) when (true) { handleIO(); }] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:30 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[someMethod]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[handleIO]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.cspans.txt new file mode 100644 index 0000000000..102f31c6bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +Code span at (1:0,1 [67] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.stree.txt new file mode 100644 index 0000000000..d2eb922ac6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.stree.txt @@ -0,0 +1,45 @@ +Statement block - Gen - 68 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { A(); } catch(Exception) when (true) { B(); } finally { C(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:41 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[A]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[catch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[Exception]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[when]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[B]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[C]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.cspans.txt new file mode 100644 index 0000000000..0505a22c21 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Code span at (1:0,1 [37] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.stree.txt new file mode 100644 index 0000000000..0810f3848a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.stree.txt @@ -0,0 +1,25 @@ +Statement block - Gen - 38 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { foo(); } finally { Dispose(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:21 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[finally]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Dispose]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.cspans.txt new file mode 100644 index 0000000000..a8e36b11c4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Code span at (1:0,1 [34] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.stree.txt new file mode 100644 index 0000000000..7d4a7b839e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.stree.txt @@ -0,0 +1,23 @@ +Statement block - Gen - 35 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [foreach(var foo in bar) { foo(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:19 + CSharpTokenType.Keyword;[foreach]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[in]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[bar]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.cspans.txt new file mode 100644 index 0000000000..107be000d2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Code span at (1:0,1 [42] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.stree.txt new file mode 100644 index 0000000000..073af76a08 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.stree.txt @@ -0,0 +1,34 @@ +Statement block - Gen - 43 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [for(int i = 0; i++; i < length) { foo(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:30 + CSharpTokenType.Keyword;[for]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[int]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.IntegerLiteral;[0]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.Increment;[++]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[i]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[length]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.cspans.txt new file mode 100644 index 0000000000..4c306875fc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [20] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.stree.txt new file mode 100644 index 0000000000..d01613f66d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.stree.txt @@ -0,0 +1,17 @@ +Statement block - Gen - 20 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [if(true) { foo(); }] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:13 + CSharpTokenType.Keyword;[if]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.cspans.txt new file mode 100644 index 0000000000..abd552e928 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Code span at (1:0,1 [20] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.stree.txt new file mode 100644 index 0000000000..7a8dcd7965 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.stree.txt @@ -0,0 +1,17 @@ +Statement block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [lock(baz) { foo(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:13 + CSharpTokenType.Keyword;[lock]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[baz]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.cspans.txt new file mode 100644 index 0000000000..f18c5a7565 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [3] ) +Code span at (1:0,1 [2] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (0:0,0 [3] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.stree.txt new file mode 100644 index 0000000000..7b1d379e7d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.stree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 3 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [is] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Tokens:1 + CSharpTokenType.Keyword;[is]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.cspans.txt new file mode 100644 index 0000000000..42ee1a7149 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [40] ) +Code span at (1:0,1 [39] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [40] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.stree.txt new file mode 100644 index 0000000000..6e6611d1d6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.stree.txt @@ -0,0 +1,13 @@ +Directive block - Gen - 40 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [using static global::System.Console] - SpanEditHandler;Accepts:AnyExceptNewline - (1:0,1) - Tokens:9 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[static]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[global]; + CSharpTokenType.DoubleColon;[::]; + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Console]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.cspans.txt new file mode 100644 index 0000000000..fc5012a2ca --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [36] ) +Code span at (1:0,1 [35] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [36] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.stree.txt new file mode 100644 index 0000000000..7211d38d71 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.stree.txt @@ -0,0 +1,13 @@ +Directive block - Gen - 36 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [using static global::System.Console] - SpanEditHandler;Accepts:AnyExceptNewline - (1:0,1) - Tokens:9 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[static]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[global]; + CSharpTokenType.DoubleColon;[::]; + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Console]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.cspans.txt new file mode 100644 index 0000000000..e98aef6a60 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Code span at (1:0,1 [27] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [28] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.stree.txt new file mode 100644 index 0000000000..54278101f9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.stree.txt @@ -0,0 +1,11 @@ +Directive block - Gen - 28 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [using static System.Console] - SpanEditHandler;Accepts:AnyExceptNewline - (1:0,1) - Tokens:7 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[static]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Console]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.cspans.txt new file mode 100644 index 0000000000..4d55dc5e97 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [13] ) +Code span at (1:0,1 [12] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [13] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.stree.txt new file mode 100644 index 0000000000..7d6aaac205 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.stree.txt @@ -0,0 +1,7 @@ +Directive block - Gen - 13 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [using static] - SpanEditHandler;Accepts:AnyExceptNewline - (1:0,1) - Tokens:3 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[static]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.cspans.txt new file mode 100644 index 0000000000..ccaf753d6c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [20] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.stree.txt new file mode 100644 index 0000000000..226b90f7bd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.stree.txt @@ -0,0 +1,9 @@ +Directive block - Gen - 20 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [using static System] - SpanEditHandler;Accepts:AnyExceptNewline - (1:0,1) - Tokens:5 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[static]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[System]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.cspans.txt new file mode 100644 index 0000000000..2a8edbf4a0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.stree.txt new file mode 100644 index 0000000000..dd5b38a925 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.stree.txt @@ -0,0 +1,17 @@ +Statement block - Gen - 23 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [switch(foo) { foo(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:13 + CSharpTokenType.Keyword;[switch]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.cspans.txt new file mode 100644 index 0000000000..9dc716471f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [15] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.stree.txt new file mode 100644 index 0000000000..bd13bb3059 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.stree.txt @@ -0,0 +1,14 @@ +Statement block - Gen - 15 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [try { foo(); }] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:10 + CSharpTokenType.Keyword;[try]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.cspans.txt new file mode 100644 index 0000000000..59eb12a1a1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [41] ) +Code span at (1:0,1 [40] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [41] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.stree.txt new file mode 100644 index 0000000000..4a9d2be68d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.stree.txt @@ -0,0 +1,13 @@ +Directive block - Gen - 41 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [using System.Text.Encoding.ASCIIEncoding] - SpanEditHandler;Accepts:AnyExceptNewline - (1:0,1) - Tokens:9 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Text]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Encoding]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[ASCIIEncoding]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.cspans.txt new file mode 100644 index 0000000000..f451f61065 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Code span at (1:0,1 [41] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.stree.txt new file mode 100644 index 0000000000..b8a04ea3e1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.stree.txt @@ -0,0 +1,29 @@ +Statement block - Gen - 42 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [using(var foo = new Foo()) { foo.Bar(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:25 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Identifier;[var]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[new]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[Foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Bar]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.cspans.txt new file mode 100644 index 0000000000..c61f4fe069 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [79] ) +Code span at (1:0,1 [78] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [79] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.stree.txt new file mode 100644 index 0000000000..df25b12077 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.stree.txt @@ -0,0 +1,23 @@ +Directive block - Gen - 79 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen;> - [using StringDictionary = System.Collections.Generic.Dictionary] - SpanEditHandler;Accepts:AnyExceptNewline - (1:0,1) - Tokens:19 + CSharpTokenType.Keyword;[using]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[StringDictionary]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Assign;[=]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[System]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Collections]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Generic]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Dictionary]; + CSharpTokenType.LessThan;[<]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Keyword;[string]; + CSharpTokenType.GreaterThan;[>]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.cspans.txt new file mode 100644 index 0000000000..2a8edbf4a0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.stree.txt new file mode 100644 index 0000000000..5a2eb3d2e3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.stree.txt @@ -0,0 +1,17 @@ +Statement block - Gen - 23 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.Transition;[@]; + Code span - Gen - [while(true) { foo(); }] - SpanEditHandler;Accepts:None - (1:0,1) - Tokens:13 + CSharpTokenType.Keyword;[while]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.Keyword;[true]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.LeftBrace;[{]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.Identifier;[foo]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.RightParenthesis;[)]; + CSharpTokenType.Semicolon;[;]; + CSharpTokenType.WhiteSpace;[ ]; + CSharpTokenType.RightBrace;[}]; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.cspans.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.cspans.txt new file mode 100644 index 0000000000..0684f9302c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.cspans.txt @@ -0,0 +1,10 @@ +MetaCode span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [37] ) +Code span at (1:0,1 [16] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [37] ) +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (17:0,17 [18] ) +Markup span at (18:0,18 [3] ) (Accepts:None) - Parent: Tag block at (18:0,18 [3] ) +Markup span at (21:0,21 [5] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [18] ) +Transition span at (26:0,26 [1] ) (Accepts:None) - Parent: Expression block at (26:0,26 [5] ) +Code span at (27:0,27 [4] ) (Accepts:NonWhiteSpace) - Parent: Expression block at (26:0,26 [5] ) +Markup span at (31:0,31 [4] ) (Accepts:None) - Parent: Tag block at (31:0,31 [4] ) +Code span at (35:0,35 [1] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [37] ) +MetaCode span at (36:0,36 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [37] ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.stree.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.stree.txt new file mode 100644 index 0000000000..bdcccbd8c2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.stree.txt @@ -0,0 +1,39 @@ +Expression block - Gen - 37 - (0:0,0) + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (0:0,0) - Tokens:1 + CSharpTokenType.LeftParenthesis;[(]; + Code span - Gen - [Html.Repeat(10, ] - SpanEditHandler;Accepts:Any - (1:0,1) - Tokens:7 + CSharpTokenType.Identifier;[Html]; + CSharpTokenType.Dot;[.]; + CSharpTokenType.Identifier;[Repeat]; + CSharpTokenType.LeftParenthesis;[(]; + CSharpTokenType.IntegerLiteral;[10]; + CSharpTokenType.Comma;[,]; + CSharpTokenType.WhiteSpace;[ ]; + Template block - Gen