From f13577ca957f51cf7a1a44a51918a6091b6252dd Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 6 Feb 2018 18:44:28 -0800 Subject: [PATCH 01/56] Update KoreBuild This branch roughly tracks our preview2 stuff for now --- korebuild-lock.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 181b38dcfe..35a596eb91 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15670 -commithash:49176144e03c3015d83b21e3f1d0ce093c05ecc3 +version:2.1.0-preview2-15696 +commithash:85ae1301d1a2ff19aab6837cc657699ccca719b5 From 010b43cedfc488c5b2d585bc08bc49bd046ca612 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 13 Feb 2018 12:07:21 -0800 Subject: [PATCH 02/56] Make imports work without warnings or errors when the Sdk is referenced via MsBuild and package. --- src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props | 4 +--- src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets | 8 ++++---- .../netstandard2.0/Microsoft.NET.Sdk.Razor.props | 3 +-- .../Microsoft.NET.Sdk.Razor.props | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props diff --git a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props index a02a52aed3..c95725d653 100644 --- a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props +++ b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props @@ -10,7 +10,5 @@ Copyright (c) .NET Foundation. All rights reserved. *********************************************************************************************** --> - - - + diff --git a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets index 82e5ccf1e8..441bba39f8 100644 --- a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets +++ b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets @@ -11,11 +11,11 @@ Copyright (c) .NET Foundation. All rights reserved. --> - - $(MSBuildThisFileDirectory)..\buildMultiTargeting\Sdk.Razor.CurrentVersion.MultiTargeting.targets - $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets + + <_RazorSdkTargetsPath Condition="'$(IsCrossTargetingBuild)' == 'true'">$(MSBuildThisFileDirectory)..\buildMultiTargeting\Sdk.Razor.CurrentVersion.MultiTargeting.targets + <_RazorSdkTargetsPath Condition="'$(IsCrossTargetingBuild)' != 'true'">$(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets - + diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props index 439697f9bc..413376f510 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props @@ -13,7 +13,6 @@ Copyright (c) .NET Foundation. All rights reserved. - - $(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.targets + <_RazorSdkPackageReferenced>true diff --git a/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props b/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props new file mode 100644 index 0000000000..5c775cd329 --- /dev/null +++ b/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props @@ -0,0 +1,16 @@ + + + + <_RazorSdkPackageReferenced>true + + From 82579b633328a901f78d8aa66b6fe94a20a67039 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 13 Feb 2018 13:23:56 -0800 Subject: [PATCH 03/56] Get rid of RazorConfiguration.DesignTime This change makes it so that we no longer create 'design time' engines. The choice of design time or runtime is made when we initiate a code generation operation. Options instances are now created as part of the CodeDocument initialization. Our existing code can still be created using a RazorEngine so our passes that initialize the options still support the old code path. --- .../ModelDirective.cs | 13 +- ...tFeature.cs => MvcImportProjectFeature.cs} | 2 +- .../RazorExtensions.cs | 16 +- .../AssemblyAttributeInjectionPass.cs | 5 + .../InstrumentationPass.cs | 5 + .../ModelDirective.cs | 13 +- ...tFeature.cs => MvcImportProjectFeature.cs} | 2 +- .../RazorExtensions.cs | 10 +- ...ture.cs => DefaultImportProjectFeature.cs} | 2 +- ...efaultRazorCodeGenerationOptionsBuilder.cs | 25 ++- ...eGenerationOptionsFactoryProjectFeature.cs | 32 ++++ ...efaultRazorCodeGenerationOptionsFeature.cs | 2 + ...faultRazorIntermediateNodeLoweringPhase.cs | 4 +- .../DefaultRazorParserOptionsBuilder.cs | 32 +++- ...RazorParserOptionsFactoryProjectFeature.cs | 32 ++++ .../DefaultRazorParserOptionsFeature.cs | 2 + .../DefaultRazorParsingPhase.cs | 4 +- .../DefaultRazorProjectEngine.cs | 78 +++++++-- .../DefaultRazorProjectEngineBuilder.cs | 22 +-- .../DefaultTagHelperTargetExtension.cs | 22 ++- .../Extensions/DesignTimeDirectivePass.cs | 7 + ...catedTagHelperAttributeOptimizationPass.cs | 6 + ...ortFeature.cs => IImportProjectFeature.cs} | 2 +- ...eGenerationOptionsFactoryProjectFeature.cs | 12 ++ .../IRazorCodeGenerationOptionsFeature.cs | 3 + ...RazorParserOptionsFactoryProjectFeature.cs | 12 ++ .../IRazorParserOptionsFeature.cs | 3 + .../RazorCodeDocument.cs | 17 ++ .../RazorCodeDocumentExtensions.cs | 40 +++++ .../RazorCodeGenerationOptionsBuilder.cs | 6 + .../RazorConfiguration.cs | 17 +- .../RazorEngine.cs | 14 +- .../RazorParserOptionsBuilder.cs | 9 +- .../RazorProjectEngine.cs | 153 +++++++++++++----- .../RazorProjectEngineBuilder.cs | 4 +- .../RazorProjectEngineBuilderExtensions.cs | 4 +- .../DefaultTemplateEngineFactoryService.cs | 6 +- .../AssemblyAttributeInjectionPassTest.cs | 79 ++++++++- .../DefaultMvcImportFeatureTest.cs | 6 +- .../InstrumentationPassTest.cs | 80 ++++++++- .../ModelDirectiveTest.cs | 28 +++- .../DefaultMvcImportFeatureTest.cs | 6 +- .../ModelDirectiveTest.cs | 28 +++- ...efaultRazorProjectEngineIntegrationTest.cs | 53 +++++- .../DefaultTagHelperTargetExtensionTest.cs | 24 +-- .../RazorCodeDocumentExtensionsTest.cs | 62 +++++++ .../RazorEngineTest.cs | 4 +- ...RazorProjectEngineBuilderExtensionsTest.cs | 6 +- .../RazorProjectEngineTest.cs | 85 ++++++++++ 49 files changed, 874 insertions(+), 225 deletions(-) rename src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/{DefaultMvcImportFeature.cs => MvcImportProjectFeature.cs} (97%) rename src/Microsoft.AspNetCore.Mvc.Razor.Extensions/{DefaultMvcImportFeature.cs => MvcImportProjectFeature.cs} (97%) rename src/Microsoft.AspNetCore.Razor.Language/{DefaultRazorImportFeature.cs => DefaultImportProjectFeature.cs} (80%) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs rename src/Microsoft.AspNetCore.Razor.Language/{IRazorImportFeature.cs => IImportProjectFeature.cs} (83%) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs index a2bce9974d..0c5859ce22 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X } builder.AddDirective(Directive); - builder.Features.Add(new Pass(builder.Configuration.DesignTime)); + builder.Features.Add(new Pass()); return builder; } @@ -64,13 +64,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass { - private readonly bool _designTime; - - public Pass(bool designTime) - { - _designTime = designTime; - } - // Runs after the @inherits directive public override int Order => 5; @@ -79,7 +72,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var visitor = new Visitor(); var modelType = GetModelType(documentNode, visitor); - if (_designTime) + if (documentNode.Options.DesignTime) { // Alias the TModel token to a known type. // This allows design time compilation to succeed for Razor files where the token isn't replaced. @@ -143,7 +136,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X } builder.AddDirective(Directive); - builder.Features.Add(new Pass(builder.DesignTime)); + builder.Features.Add(new Pass()); return builder; } #endregion diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/DefaultMvcImportFeature.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs similarity index 97% rename from src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/DefaultMvcImportFeature.cs rename to src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs index 055f306eb5..b7ef608871 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/DefaultMvcImportFeature.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs @@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { - internal class DefaultMvcImportFeature : RazorProjectEngineFeatureBase, IRazorImportFeature + internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature { private const string ImportsFileName = "_ViewImports.cshtml"; diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs index f94cf52abd..e8b4f0018c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs @@ -16,8 +16,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X throw new ArgumentNullException(nameof(builder)); } - EnsureDesignTime(builder); - InjectDirective.Register(builder); ModelDirective.Register(builder); @@ -37,7 +35,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X builder.Features.Add(new ModelExpressionPass()); builder.Features.Add(new MvcViewDocumentClassifierPass()); - builder.SetImportFeature(new DefaultMvcImportFeature()); + builder.SetImportFeature(new MvcImportProjectFeature()); } public static void RegisterViewComponentTagHelpers(RazorProjectEngineBuilder builder) @@ -47,22 +45,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X throw new ArgumentNullException(nameof(builder)); } - EnsureDesignTime(builder); - builder.Features.Add(new ViewComponentTagHelperPass()); builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension()); } - private static void EnsureDesignTime(RazorProjectEngineBuilder builder) - { - if (builder.Configuration.DesignTime) - { - return; - } - - throw new NotSupportedException(Resources.RuntimeCodeGenerationNotSupported); - } - #region Obsolete public static void Register(IRazorEngineBuilder builder) { diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs index 1123b1a31f..cf5549d0f5 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs @@ -14,6 +14,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + if (documentNode.Options.DesignTime) + { + return; + } + var @namespace = documentNode.FindPrimaryNamespace(); if (@namespace == null || string.IsNullOrEmpty(@namespace.Content)) { diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs index 9f271faf82..1ae0a72210 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs @@ -15,6 +15,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + if (documentNode.Options.DesignTime) + { + return; + } + var walker = new Visitor(); walker.VisitDocument(documentNode); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs index 9c16b96e57..b6e2955f22 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } builder.AddDirective(Directive); - builder.Features.Add(new Pass(builder.Configuration.DesignTime)); + builder.Features.Add(new Pass()); return builder; } @@ -71,13 +71,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass { - private readonly bool _designTime; - - public Pass(bool designTime) - { - _designTime = designTime; - } - // Runs after the @inherits directive public override int Order => 5; @@ -86,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var visitor = new Visitor(); var modelType = GetModelType(documentNode, visitor); - if (_designTime) + if (documentNode.Options.DesignTime) { // Alias the TModel token to a known type. // This allows design time compilation to succeed for Razor files where the token isn't replaced. @@ -150,7 +143,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } builder.AddDirective(Directive); - builder.Features.Add(new Pass(builder.DesignTime)); + builder.Features.Add(new Pass()); return builder; } #endregion diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/DefaultMvcImportFeature.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs similarity index 97% rename from src/Microsoft.AspNetCore.Mvc.Razor.Extensions/DefaultMvcImportFeature.cs rename to src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs index 4852951e33..999dd6fdbb 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/DefaultMvcImportFeature.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs @@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { - internal class DefaultMvcImportFeature : RazorProjectEngineFeatureBase, IRazorImportFeature + internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature { private const string ImportsFileName = "_ViewImports.cshtml"; diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs index ac1d8b35e9..c22878bd09 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs @@ -36,14 +36,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Features.Add(new ViewComponentTagHelperPass()); builder.Features.Add(new RazorPageDocumentClassifierPass()); builder.Features.Add(new MvcViewDocumentClassifierPass()); + builder.Features.Add(new AssemblyAttributeInjectionPass()); + builder.Features.Add(new InstrumentationPass()); - if (!builder.Configuration.DesignTime) - { - builder.Features.Add(new AssemblyAttributeInjectionPass()); - builder.Features.Add(new InstrumentationPass()); - } - - builder.SetImportFeature(new DefaultMvcImportFeature()); + builder.SetImportFeature(new MvcImportProjectFeature()); } #region Obsolete diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorImportFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs similarity index 80% rename from src/Microsoft.AspNetCore.Razor.Language/DefaultRazorImportFeature.cs rename to src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs index ea626e97e0..15fc2635cd 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorImportFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language { - internal class DefaultRazorImportFeature : RazorProjectEngineFeatureBase, IRazorImportFeature + internal class DefaultImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature { public IReadOnlyList GetImports(RazorProjectItem projectItem) => Array.Empty(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs index ad3dc7b83d..8dd095a04e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs @@ -1,16 +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.AspNetCore.Razor.Language { internal class DefaultRazorCodeGenerationOptionsBuilder : RazorCodeGenerationOptionsBuilder { - public DefaultRazorCodeGenerationOptionsBuilder(bool designTime) + private bool _designTime; + + public DefaultRazorCodeGenerationOptionsBuilder(RazorConfiguration configuration) { - DesignTime = designTime; + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } } - public override bool DesignTime { get; } + public DefaultRazorCodeGenerationOptionsBuilder(bool designTime) + { + _designTime = designTime; + } + + public override RazorConfiguration Configuration { get; } + + public override bool DesignTime => _designTime; public override int IndentSize { get; set; } = 4; @@ -22,5 +36,10 @@ namespace Microsoft.AspNetCore.Razor.Language { return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, SuppressChecksum, SuppressMetadataAttributes); } + + public override void SetDesignTime(bool designTime) + { + _designTime = designTime; + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..db2a25b81f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs @@ -0,0 +1,32 @@ +// 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.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorCodeGenerationOptionsFactoryProjectFeature : RazorProjectEngineFeatureBase, IRazorCodeGenerationOptionsFactoryProjectFeature + { + private IConfigureRazorCodeGenerationOptionsFeature[] _configureOptions; + + protected override void OnInitialized() + { + _configureOptions = ProjectEngine.EngineFeatures.OfType().ToArray(); + } + + public RazorCodeGenerationOptions Create(Action configure) + { + var builder = new DefaultRazorCodeGenerationOptionsBuilder(ProjectEngine.Configuration); + configure?.Invoke(builder); + + for (var i = 0; i < _configureOptions.Length; i++) + { + _configureOptions[i].Configure(builder); + } + + var options = builder.Build(); + return options; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs index 0238ee2d76..1c915364d7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs @@ -5,7 +5,9 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorCodeGenerationOptionsFeature : RazorEngineFeatureBase, IRazorCodeGenerationOptionsFeature +#pragma warning restore CS0618 // Type or member is obsolete { private readonly bool _designTime; private IConfigureRazorCodeGenerationOptionsFeature[] _configureOptions; diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs index b7047bca1b..5e3ae8a258 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorIntermediateNodeLoweringPhase : RazorEnginePhaseBase, IRazorIntermediateNodeLoweringPhase { private IRazorCodeGenerationOptionsFeature _optionsFeature; @@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Language var document = new DocumentIntermediateNode(); var builder = IntermediateNodeBuilder.Create(document); - document.Options = _optionsFeature.GetOptions(); + document.Options = codeDocument.GetCodeGenerationOptions() ?? _optionsFeature.GetOptions(); var namespaces = new Dictionary(StringComparer.Ordinal); @@ -785,4 +786,5 @@ namespace Microsoft.AspNetCore.Razor.Language private static bool IsMalformed(List diagnostics) => diagnostics.Count > 0 && diagnostics.Any(diagnostic => diagnostic.Severity == RazorDiagnosticSeverity.Error); } +#pragma warning restore CS0618 // Type or member is obsolete } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs index eadc773439..2e4d3273d2 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs @@ -9,23 +9,43 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRazorParserOptionsBuilder : RazorParserOptionsBuilder { - public DefaultRazorParserOptionsBuilder(bool designTime, RazorLanguageVersion version) + private bool _designTime; + + public DefaultRazorParserOptionsBuilder(RazorConfiguration configuration) { - DesignTime = designTime; - Version = version; + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + Configuration = configuration; + LanguageVersion = configuration.LanguageVersion; } - public override bool DesignTime { get; } + public DefaultRazorParserOptionsBuilder(bool designTime, RazorLanguageVersion version) + { + _designTime = designTime; + LanguageVersion = version; + } + + public override RazorConfiguration Configuration { get; } + + public override bool DesignTime => _designTime; public override ICollection Directives { get; } = new List(); public override bool ParseLeadingDirectives { get; set; } - public override RazorLanguageVersion Version { get; } + public override RazorLanguageVersion LanguageVersion { get; } public override RazorParserOptions Build() { - return new DefaultRazorParserOptions(Directives.ToArray(), DesignTime, ParseLeadingDirectives, Version); + return new DefaultRazorParserOptions(Directives.ToArray(), DesignTime, ParseLeadingDirectives, LanguageVersion); + } + + public override void SetDesignTime(bool designTime) + { + _designTime = designTime; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..32fb04af7f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs @@ -0,0 +1,32 @@ +// 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.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorParserOptionsFactoryProjectFeature : RazorProjectEngineFeatureBase, IRazorParserOptionsFactoryProjectFeature + { + private IConfigureRazorParserOptionsFeature[] _configureOptions; + + protected override void OnInitialized() + { + _configureOptions = ProjectEngine.EngineFeatures.OfType().ToArray(); + } + + public RazorParserOptions Create(Action configure) + { + var builder = new DefaultRazorParserOptionsBuilder(ProjectEngine.Configuration); + configure?.Invoke(builder); + + for (var i = 0; i < _configureOptions.Length; i++) + { + _configureOptions[i].Configure(builder); + } + + var options = builder.Build(); + return options; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs index 867e289ee7..eecb9bd9cc 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs @@ -5,7 +5,9 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorParserOptionsFeature : RazorEngineFeatureBase, IRazorParserOptionsFeature +#pragma warning restore CS0618 // Type or member is obsolete { private readonly bool _designTime; private readonly RazorLanguageVersion _version; diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs index 5a13e68760..8264201271 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs @@ -3,6 +3,7 @@ namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorParsingPhase : RazorEnginePhaseBase, IRazorParsingPhase { private IRazorParserOptionsFeature _optionsFeature; @@ -14,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language protected override void ExecuteCore(RazorCodeDocument codeDocument) { - var options = _optionsFeature.GetOptions(); + var options = codeDocument.GetParserOptions() ??_optionsFeature.GetOptions(); var syntaxTree = RazorSyntaxTree.Parse(codeDocument.Source, options); codeDocument.SetSyntaxTree(syntaxTree); @@ -26,4 +27,5 @@ namespace Microsoft.AspNetCore.Razor.Language codeDocument.SetImportSyntaxTrees(importSyntaxTrees); } } +#pragma warning restore CS0618 // Type or member is obsolete } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs index 6cac02dc25..6ac8e4c4cd 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs @@ -10,10 +10,16 @@ namespace Microsoft.AspNetCore.Razor.Language internal class DefaultRazorProjectEngine : RazorProjectEngine { public DefaultRazorProjectEngine( + RazorConfiguration configuration, RazorEngine engine, RazorProjectFileSystem fileSystem, - IReadOnlyList features) + IReadOnlyList projectFeatures) { + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + if (engine == null) { throw new ArgumentNullException(nameof(engine)); @@ -24,39 +30,87 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(fileSystem)); } - if (features == null) + if (projectFeatures == null) { - throw new ArgumentNullException(nameof(features)); + throw new ArgumentNullException(nameof(projectFeatures)); } + Configuration = configuration; Engine = engine; FileSystem = fileSystem; - Features = features; + ProjectFeatures = projectFeatures; - for (var i = 0; i < features.Count; i++) + for (var i = 0; i < projectFeatures.Count; i++) { - features[i].ProjectEngine = this; + projectFeatures[i].ProjectEngine = this; } } + public override RazorConfiguration Configuration { get; } + public override RazorProjectFileSystem FileSystem { get; } public override RazorEngine Engine { get; } - public override IReadOnlyList Features { get; } + public override IReadOnlyList ProjectFeatures { get; } - public override RazorCodeDocument Process(RazorProjectItem projectItem) + protected override void ConfigureParserOptions(RazorParserOptionsBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + } + + protected override void ConfigureDesignTimeParserOptions(RazorParserOptionsBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.SetDesignTime(true); + } + + protected override void ConfigureCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + } + + protected override void ConfigureDesignTimeCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.SetDesignTime(true); + builder.SuppressChecksum = true; + builder.SuppressMetadataAttributes = true; + } + + protected override RazorCodeDocument ProcessCore( + RazorProjectItem projectItem, + Action configureParser, + Action configureCodeGeneration) { if (projectItem == null) { throw new ArgumentNullException(nameof(projectItem)); } - var importFeature = GetRequiredFeature(); - var imports = importFeature.GetImports(projectItem); var sourceDocument = RazorSourceDocument.ReadFrom(projectItem); - var codeDocument = RazorCodeDocument.Create(sourceDocument, imports); + var importFeature = GetRequiredFeature(); + var imports = importFeature.GetImports(projectItem); + + var parserOptions = GetRequiredFeature().Create(configureParser); + var codeGenerationOptions = GetRequiredFeature().Create(configureCodeGeneration); + + var codeDocument = RazorCodeDocument.Create(sourceDocument, imports, parserOptions, codeGenerationOptions); Engine.Process(codeDocument); @@ -65,7 +119,7 @@ namespace Microsoft.AspNetCore.Razor.Language private TFeature GetRequiredFeature() where TFeature : IRazorProjectEngineFeature { - var feature = Features.OfType().FirstOrDefault(); + var feature = ProjectFeatures.OfType().FirstOrDefault(); if (feature == null) { throw new InvalidOperationException( diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs index 85af0c68f2..a07f4581ff 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs @@ -22,29 +22,19 @@ namespace Microsoft.AspNetCore.Razor.Language Phases = new List(); } + public override RazorConfiguration Configuration { get; } + public override RazorProjectFileSystem FileSystem { get; } public override ICollection Features { get; } public override IList Phases { get; } - - public override RazorConfiguration Configuration { get; } - + public override RazorProjectEngine Build() { - RazorEngine engine = null; - - if (Configuration.DesignTime) - { - engine = RazorEngine.CreateDesignTimeEmpty(ConfigureRazorEngine); - } - else - { - engine = RazorEngine.CreateEmpty(ConfigureRazorEngine); - } - - var projectEngineFeatures = Features.OfType().ToArray(); - var projectEngine = new DefaultRazorProjectEngine(engine, FileSystem, projectEngineFeatures); + var engine = RazorEngine.CreateEmpty(ConfigureRazorEngine); + var projectFeatures = Features.OfType().ToArray(); + var projectEngine = new DefaultRazorProjectEngine(Configuration, engine, FileSystem, projectFeatures); return projectEngine; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs index eacdf6b677..ad85ebf807 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs @@ -16,8 +16,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions { private static readonly string[] PrivateModifiers = new string[] { "private" }; - public bool DesignTime { get; set; } - public string RunnerVariableName { get; set; } = "__tagHelperRunner"; public string StringValueBufferVariableName { get; set; } = "__tagHelperStringValueBuffer"; @@ -82,7 +80,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); } @@ -136,7 +134,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions .Write(CreateTagHelperMethodName) .WriteLine("();"); - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter.WriteInstanceMethodInvocation( ExecutionContextVariableName, @@ -153,7 +151,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter .Write("await ") @@ -200,7 +198,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); } @@ -284,7 +282,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (!DesignTime) + if (!context.Options.DesignTime) { // Ensure that the property we're trying to set has initialized its dictionary bound properties. if (node.IsIndexerNameMatch && @@ -338,7 +336,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions // If we get there, this is the first time seeing this property so we need to evaluate the expression. if (node.BoundAttribute.ExpectsStringValue(node.AttributeName)) { - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); @@ -370,7 +368,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } else { - if (DesignTime) + if (context.Options.DesignTime) { var firstMappedChild = node.Children.FirstOrDefault(child => child.Source != null) as IntermediateNode; var valueStart = firstMappedChild?.Source; @@ -456,7 +454,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } } - if (!DesignTime) + if (!context.Options.DesignTime) { // We need to inform the context of the attribute value. context.CodeWriter @@ -474,7 +472,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperRuntime(CodeRenderingContext context, DefaultTagHelperRuntimeIntermediateNode node) { - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter.WriteLine("#line hidden"); @@ -566,7 +564,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } else if (node is IntermediateToken token) { - if (DesignTime && node.Source != null) + if (context.Options.DesignTime && node.Source != null) { context.AddSourceMappingFor(node); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs index 31e9cbf361..6d6d7e261d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs @@ -15,6 +15,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + // Only supports design time. This pass rewrites directives so they will have the right design time + // behavior and would break things if it ran for runtime. + if (!documentNode.Options.DesignTime) + { + return; + } + var walker = new DesignTimeHelperWalker(); walker.VisitDocument(documentNode); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs index ed9488da20..f6d0f40a3b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs @@ -15,6 +15,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + // There's no value in executing this pass at design time, it just prevents some allocations. + if (documentNode.Options.DesignTime) + { + return; + } + var walker = new PreallocatedTagHelperWalker(); walker.VisitDocument(documentNode); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorImportFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs similarity index 83% rename from src/Microsoft.AspNetCore.Razor.Language/IRazorImportFeature.cs rename to src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs index f002cd20ce..90bd6638f4 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorImportFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language { - public interface IRazorImportFeature : IRazorProjectEngineFeature + public interface IImportProjectFeature : IRazorProjectEngineFeature { IReadOnlyList GetImports(RazorProjectItem projectItem); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..6d3ed5156c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs @@ -0,0 +1,12 @@ +// 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 +{ + internal interface IRazorCodeGenerationOptionsFactoryProjectFeature : IRazorProjectEngineFeature + { + RazorCodeGenerationOptions Create(Action configure); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs index dc97b6326c..b74bcc3d8d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.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; + namespace Microsoft.AspNetCore.Razor.Language { + [Obsolete("In Razor 2.1 and newer, use RazorCodeDocument.GetCodeGenerationOptions().")] public interface IRazorCodeGenerationOptionsFeature : IRazorEngineFeature { RazorCodeGenerationOptions GetOptions(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..e73bf8babc --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs @@ -0,0 +1,12 @@ +// 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 +{ + internal interface IRazorParserOptionsFactoryProjectFeature : IRazorProjectEngineFeature + { + RazorParserOptions Create(Action configure); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs index ec4b3f1ab1..b2c1e9ec3e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.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; + namespace Microsoft.AspNetCore.Razor.Language { + [Obsolete("In Razor 2.1 and newer, use RazorCodeDocument.GetParserOptions().")] public interface IRazorParserOptionsFeature : IRazorEngineFeature { RazorParserOptions GetOptions(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs index 6ee41d0be5..0d57df2815 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs @@ -30,6 +30,23 @@ namespace Microsoft.AspNetCore.Razor.Language return new DefaultRazorCodeDocument(source, imports); } + public static RazorCodeDocument Create( + RazorSourceDocument source, + IEnumerable imports, + RazorParserOptions parserOptions, + RazorCodeGenerationOptions codeGenerationOptions) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + + var codeDocument = new DefaultRazorCodeDocument(source, imports); + codeDocument.SetParserOptions(parserOptions); + codeDocument.SetCodeGenerationOptions(codeGenerationOptions); + return codeDocument; + } + public abstract IReadOnlyList Imports { get; } public abstract ItemCollection Items { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs index 314b83d176..85df33837a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs @@ -109,6 +109,46 @@ namespace Microsoft.AspNetCore.Razor.Language document.Items[typeof(RazorCSharpDocument)] = csharp; } + public static RazorParserOptions GetParserOptions(this RazorCodeDocument document) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + return (RazorParserOptions)document.Items[typeof(RazorParserOptions)]; + } + + public static void SetParserOptions(this RazorCodeDocument document, RazorParserOptions parserOptions) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + document.Items[typeof(RazorParserOptions)] = parserOptions; + } + + public static RazorCodeGenerationOptions GetCodeGenerationOptions(this RazorCodeDocument document) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + return (RazorCodeGenerationOptions)document.Items[typeof(RazorCodeGenerationOptions)]; + } + + public static void SetCodeGenerationOptions(this RazorCodeDocument document, RazorCodeGenerationOptions codeGenerationOptions) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + document.Items[typeof(RazorCodeGenerationOptions)] = codeGenerationOptions; + } + private class ImportSyntaxTreesHolder { public ImportSyntaxTreesHolder(IReadOnlyList syntaxTrees) diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs index 55e1934ee7..be4c9dff3d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs @@ -5,6 +5,8 @@ namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorCodeGenerationOptionsBuilder { + public virtual RazorConfiguration Configuration => null; + public abstract bool DesignTime { get; } public abstract int IndentSize { get; set; } @@ -41,5 +43,9 @@ namespace Microsoft.AspNetCore.Razor.Language public virtual bool SuppressMetadataAttributes { get; set; } public abstract RazorCodeGenerationOptions Build(); + + public virtual void SetDesignTime(bool designTime) + { + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs index 0f00751497..f68db61f22 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs @@ -12,22 +12,12 @@ namespace Microsoft.AspNetCore.Razor.Language public static readonly RazorConfiguration Default = new RazorConfiguration( RazorLanguageVersion.Latest, "unnamed", - Array.Empty(), - designTime: false); - - // This is used only in some back-compat scenarios. We don't expose it because there's no - // use case for anyone else to use it. - internal static readonly RazorConfiguration DefaultDesignTime = new RazorConfiguration( - RazorLanguageVersion.Latest, - "unnamed", - Array.Empty(), - designTime: true); + Array.Empty()); public RazorConfiguration( RazorLanguageVersion languageVersion, string configurationName, - IEnumerable extensions, - bool designTime) + IEnumerable extensions) { if (languageVersion == null) { @@ -47,7 +37,6 @@ namespace Microsoft.AspNetCore.Razor.Language LanguageVersion = languageVersion; ConfigurationName = configurationName; Extensions = extensions.ToArray(); - DesignTime = designTime; } public string ConfigurationName { get; } @@ -55,7 +44,5 @@ namespace Microsoft.AspNetCore.Razor.Language public IReadOnlyList Extensions { get; } public RazorLanguageVersion LanguageVersion { get; } - - public bool DesignTime { get; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs index a48c31893a..13f2f6be73 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs @@ -17,27 +17,27 @@ namespace Microsoft.AspNetCore.Razor.Language return Create(configure: null); } - public static RazorEngine Create(Action configure) => CreateCore(RazorConfiguration.Default, configure); + public static RazorEngine Create(Action configure) => CreateCore(RazorConfiguration.Default, false, configure); public static RazorEngine CreateDesignTime() { return CreateDesignTime(configure: null); } - public static RazorEngine CreateDesignTime(Action configure) => CreateCore(RazorConfiguration.DefaultDesignTime, configure); + public static RazorEngine CreateDesignTime(Action configure) => CreateCore(RazorConfiguration.Default, true, configure); // Internal since RazorEngine APIs are going to be obsolete. - internal static RazorEngine CreateCore(RazorConfiguration configuration, Action configure) + internal static RazorEngine CreateCore(RazorConfiguration configuration, bool designTime, Action configure) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } - var builder = new DefaultRazorEngineBuilder(configuration.DesignTime); + var builder = new DefaultRazorEngineBuilder(designTime); AddDefaults(builder); - if (configuration.DesignTime) + if (designTime) { AddDefaultDesignTimeFeatures(configuration, builder.Features); } @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.Razor.Language var targetExtension = features.OfType().FirstOrDefault(); Debug.Assert(targetExtension != null); - targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension() { DesignTime = false }); + targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); targetExtension.TargetExtensions.Add(new PreallocatedAttributeTargetExtension()); } @@ -170,7 +170,7 @@ namespace Microsoft.AspNetCore.Razor.Language var targetExtension = features.OfType().FirstOrDefault(); Debug.Assert(targetExtension != null); - targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension() { DesignTime = true }); + targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); targetExtension.TargetExtensions.Add(new DesignTimeDirectiveTargetExtension()); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs index 74b11fcc26..b036e3d58d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs @@ -1,21 +1,26 @@ // 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 { public abstract class RazorParserOptionsBuilder { + public virtual RazorConfiguration Configuration => null; + public abstract bool DesignTime { get; } public abstract ICollection Directives { get; } public abstract bool ParseLeadingDirectives { get; set; } - public virtual RazorLanguageVersion Version { get; } + public virtual RazorLanguageVersion LanguageVersion { get; } public abstract RazorParserOptions Build(); + + public virtual void SetDesignTime(bool designTime) + { + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs index 7f2c03e8e3..04f86c38d3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs @@ -3,26 +3,63 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language.Extensions; namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorProjectEngine { + public abstract RazorConfiguration Configuration { get; } + public abstract RazorProjectFileSystem FileSystem { get; } public abstract RazorEngine Engine { get; } - public abstract IReadOnlyList Features { get; } + public IReadOnlyList EngineFeatures => Engine.Features; - public abstract RazorCodeDocument Process(RazorProjectItem projectItem); + public IReadOnlyList Phases => Engine.Phases; - public static RazorProjectEngine Create(RazorProjectFileSystem fileSystem) => Create(fileSystem, configure: null); + public abstract IReadOnlyList ProjectFeatures { get; } - public static RazorProjectEngine Create(RazorProjectFileSystem fileSystem, Action configure) => Create(fileSystem, RazorConfiguration.Default, configure); + protected abstract void ConfigureParserOptions(RazorParserOptionsBuilder builder); + + protected abstract void ConfigureDesignTimeParserOptions(RazorParserOptionsBuilder builder); + + protected abstract void ConfigureCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder); + + protected abstract void ConfigureDesignTimeCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder); + + public virtual RazorCodeDocument Process(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + return ProcessCore(projectItem, ConfigureParserOptions, ConfigureCodeGenerationOptions); + } + + public virtual RazorCodeDocument ProcessDesignTime(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + return ProcessCore(projectItem, ConfigureDesignTimeParserOptions, ConfigureDesignTimeCodeGenerationOptions); + } + + protected abstract RazorCodeDocument ProcessCore( + RazorProjectItem projectItem, + Action configureParser, + Action configureCodeGeneration); + + public static RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem) => Create(configuration, fileSystem, configure: null); public static RazorProjectEngine Create( - RazorProjectFileSystem fileSystem, RazorConfiguration configuration, + RazorProjectFileSystem fileSystem, Action configure) { if (fileSystem == null) @@ -37,54 +74,90 @@ namespace Microsoft.AspNetCore.Razor.Language var builder = new DefaultRazorProjectEngineBuilder(configuration, fileSystem); - AddDefaults(builder); - - if (configuration.DesignTime) - { - AddDesignTimeDefaults(builder); - } - else - { - AddRuntimeDefaults(builder); - } + RazorEngine.AddDefaultPhases(builder.Phases); + AddDefaultsFeatures(builder.Features); configure?.Invoke(builder); return builder.Build(); } - - private static void AddDefaults(RazorProjectEngineBuilder builder) + + private static void AddDefaultsFeatures(ICollection features) { - builder.Features.Add(new DefaultRazorImportFeature()); - } + features.Add(new DefaultImportProjectFeature()); - private static void AddDesignTimeDefaults(RazorProjectEngineBuilder builder) - { - var engineFeatures = new List(); - RazorEngine.AddDefaultFeatures(engineFeatures); - RazorEngine.AddDefaultDesignTimeFeatures(builder.Configuration, engineFeatures); + // General extensibility + features.Add(new DefaultRazorDirectiveFeature()); + features.Add(new DefaultMetadataIdentifierFeature()); - AddEngineFeaturesAndPhases(builder, engineFeatures); - } + // Options features + features.Add(new DefaultRazorParserOptionsFactoryProjectFeature()); + features.Add(new DefaultRazorCodeGenerationOptionsFactoryProjectFeature()); - private static void AddRuntimeDefaults(RazorProjectEngineBuilder builder) - { - var engineFeatures = new List(); - RazorEngine.AddDefaultFeatures(engineFeatures); - RazorEngine.AddDefaultRuntimeFeatures(builder.Configuration, engineFeatures); + // Legacy options features + // + // These features are obsolete as of 2.1. Our code will resolve this but not invoke them. + features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: RazorLanguageVersion.Version_2_0)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); - AddEngineFeaturesAndPhases(builder, engineFeatures); - } + // Syntax Tree passes + features.Add(new DefaultDirectiveSyntaxTreePass()); + features.Add(new HtmlNodeOptimizationPass()); + features.Add(new PreallocatedTagHelperAttributeOptimizationPass()); - private static void AddEngineFeaturesAndPhases(RazorProjectEngineBuilder builder, IReadOnlyList engineFeatures) - { - for (var i = 0; i < engineFeatures.Count; i++) + // Intermediate Node Passes + features.Add(new DefaultDocumentClassifierPass()); + features.Add(new MetadataAttributePass()); + features.Add(new DesignTimeDirectivePass()); + features.Add(new DirectiveRemovalOptimizationPass()); + features.Add(new DefaultTagHelperOptimizationPass()); + + // Default Code Target Extensions + var targetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + features.Add(targetExtensionFeature); + targetExtensionFeature.TargetExtensions.Add(new MetadataAttributeTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new PreallocatedAttributeTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new DesignTimeDirectiveTargetExtension()); + + // Default configuration + var configurationFeature = new DefaultDocumentClassifierPassFeature(); + features.Add(configurationFeature); + configurationFeature.ConfigureClass.Add((document, @class) => { - var engineFeature = engineFeatures[i]; - builder.Features.Add(engineFeature); - } + @class.ClassName = "Template"; + @class.Modifiers.Add("public"); + }); - RazorEngine.AddDefaultPhases(builder.Phases); + configurationFeature.ConfigureNamespace.Add((document, @namespace) => + { + @namespace.Content = "Razor"; + }); + + configurationFeature.ConfigureMethod.Add((document, method) => + { + method.MethodName = "ExecuteAsync"; + method.ReturnType = $"global::{typeof(Task).FullName}"; + + method.Modifiers.Add("public"); + method.Modifiers.Add("async"); + method.Modifiers.Add("override"); + }); + } + + internal static void AddDefaultRuntimeFeatures(RazorConfiguration configuration, ICollection features) + { + // Configure options + features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: configuration.LanguageVersion)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + } + + internal static void AddDefaultDesignTimeFeatures(RazorConfiguration configuration, ICollection features) + { + // Configure options + features.Add(new DefaultRazorParserOptionsFeature(designTime: true, version: configuration.LanguageVersion)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: true)); + features.Add(new SuppressChecksumOptionsFeature()); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs index 3177c4b13d..9fe4356fa9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs @@ -7,14 +7,14 @@ namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorProjectEngineBuilder { + public abstract RazorConfiguration Configuration { get; } + public abstract RazorProjectFileSystem FileSystem { get; } public abstract ICollection Features { get; } public abstract IList Phases { get; } - public abstract RazorConfiguration Configuration { get; } - public abstract RazorProjectEngine Build(); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs index 8bd17e0dd6..6d14b838eb 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language { public static class RazorProjectEngineBuilderExtensions { - public static void SetImportFeature(this RazorProjectEngineBuilder builder, IRazorImportFeature feature) + public static void SetImportFeature(this RazorProjectEngineBuilder builder, IImportProjectFeature feature) { if (builder == null) { @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Razor.Language } // Remove any existing import features in favor of the new one we're given. - var existingFeatures = builder.Features.OfType().ToArray(); + var existingFeatures = builder.Features.OfType().ToArray(); foreach (var existingFeature in existingFeatures) { builder.Features.Remove(existingFeature); diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs index 6c615077c7..f4f7c8b608 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs @@ -43,12 +43,12 @@ namespace Microsoft.VisualStudio.Editor.Razor var project = FindProject(projectPath); var configuration = (project?.Configuration as MvcExtensibilityConfiguration) ?? DefaultConfiguration; var razorLanguageVersion = configuration.LanguageVersion; - var razorConfiguration = new RazorConfiguration(razorLanguageVersion, "unnamed", Array.Empty(), designTime: true); + var razorConfiguration = new RazorConfiguration(razorLanguageVersion, "unnamed", Array.Empty()); RazorEngine engine; if (razorLanguageVersion.Major == 1) { - engine = RazorEngine.CreateCore(razorConfiguration, b => + engine = RazorEngine.CreateCore(razorConfiguration, true, b => { configure?.Invoke(b); @@ -66,7 +66,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } else { - engine = RazorEngine.CreateCore(razorConfiguration, b => + engine = RazorEngine.CreateCore(razorConfiguration, true, b => { configure?.Invoke(b); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs index 0c69be0e18..a507103fb7 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs @@ -13,7 +13,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfNamespaceNodeIsMissing() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var pass = new AssemblyAttributeInjectionPass { Engine = RazorEngine.Create(), @@ -30,7 +34,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfNamespaceNodeHasEmptyContent() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = string.Empty }; @namespace.Annotations[CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace; @@ -53,7 +60,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfClassNameNodeIsMissing() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "SomeNamespace" }; builder.Push(@namespace); @@ -67,7 +78,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); // Assert - Assert.Collection(irDocument.Children, + Assert.Collection( + irDocument.Children, node => Assert.Same(@namespace, node)); } @@ -75,7 +87,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfClassNameIsEmpty() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode { @@ -115,6 +130,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = "Default", + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "SomeNamespace" }; @@ -138,7 +154,54 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); // Assert - Assert.Collection(irDocument.Children, + Assert.Collection( + irDocument.Children, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_NoOps_ForDesignTime() + { + // Arrange + var irDocument = new DocumentIntermediateNode + { + DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDesignTimeDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = RazorEngine.Create(), + }; + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); + + // Act + pass.Execute(document, irDocument); + + // Assert + Assert.Collection( + irDocument.Children, node => Assert.Same(@namespace, node)); } @@ -150,6 +213,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode @@ -202,6 +266,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode @@ -254,6 +319,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var pageDirective = new DirectiveIntermediateNode @@ -313,6 +379,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/DefaultMvcImportFeatureTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/DefaultMvcImportFeatureTest.cs index 3ae6d8dd13..ccd59408f9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/DefaultMvcImportFeatureTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/DefaultMvcImportFeatureTest.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var imports = new List(); // Act - DefaultMvcImportFeature.AddDefaultDirectivesImport(imports); + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); // Assert var import = Assert.Single(imports); @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions new TestRazorProjectItem("/Contact/_ViewImports.cshtml"), projectItem, }); - var mvcImportFeature = new DefaultMvcImportFeature() + var mvcImportFeature = new MvcImportProjectFeature() { ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) }; @@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var imports = new List(); var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); - var mvcImportFeature = new DefaultMvcImportFeature() + var mvcImportFeature = new MvcImportProjectFeature() { ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) }; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs index 0827042ac4..d59d1ad06b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs @@ -10,11 +10,47 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { public class InstrumentationPassTest { + [Fact] + public void InstrumentationPass_NoOps_ForDesignTime() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDesignTimeDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new HtmlContentIntermediateNode()); + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.Html, + }); + builder.Pop(); + + var pass = new InstrumentationPass() + { + Engine = RazorEngine.CreateEmpty(b => { }), + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => IntermediateNodeAssert.Html("Hi", n)); + } + [Fact] public void InstrumentationPass_InstrumentsHtml() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new HtmlContentIntermediateNode() @@ -49,7 +85,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsHtml_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new HtmlContentIntermediateNode()); builder.Add(new IntermediateToken() @@ -77,7 +117,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_InstrumentsCSharpExpression() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new CSharpExpressionIntermediateNode() { @@ -109,7 +153,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new CSharpExpressionIntermediateNode()); builder.Add(new IntermediateToken() @@ -136,7 +184,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_InsideTagHelperAttribute() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); @@ -183,7 +235,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_InsideTagHelperProperty() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); @@ -230,7 +286,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_InstrumentsTagHelper() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Add(new TagHelperIntermediateNode() { @@ -257,7 +317,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsTagHelper_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs index fcf8bc2422..f6466520af 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -163,8 +163,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @inherits BaseType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -193,8 +193,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @model SomeType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -246,6 +246,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }); } + private RazorEngine CreateDesignTimeEngine() + { + return RazorEngine.CreateDesignTime(b => + { + // Notice we're not registering the ModelDirective.Pass here so we can run it on demand. + b.AddDirective(ModelDirective.Directive); + + // There's some special interaction with the inherits directive + InheritsDirective.Register(b); + }); + } + private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) { for (var i = 0; i < engine.Phases.Count; i++) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/DefaultMvcImportFeatureTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/DefaultMvcImportFeatureTest.cs index 3741760b4a..680ab9ba1e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/DefaultMvcImportFeatureTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/DefaultMvcImportFeatureTest.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var imports = new List(); // Act - DefaultMvcImportFeature.AddDefaultDirectivesImport(imports); + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); // Assert var import = Assert.Single(imports); @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X new TestRazorProjectItem("/Contact/_ViewImports.cshtml"), projectItem, }); - var mvcImportFeature = new DefaultMvcImportFeature() + var mvcImportFeature = new MvcImportProjectFeature() { ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) }; @@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var imports = new List(); var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); - var mvcImportFeature = new DefaultMvcImportFeature() + var mvcImportFeature = new MvcImportProjectFeature() { ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) }; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs index c366918999..c0319a9a0a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -163,8 +163,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X @inherits BaseType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -193,8 +193,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X @model SomeType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -246,6 +246,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X }); } + private RazorEngine CreateDesignTimeEngine() + { + return RazorEngine.CreateDesignTime(b => + { + // Notice we're not registering the ModelDirective.Pass here so we can run it on demand. + b.AddDirective(ModelDirective.Directive); + + // There's some special interaction with the inherits directive + InheritsDirective.Register(b); + }); + } + private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) { for (var i = 0; i < engine.Phases.Count; i++) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs index e767978411..0edbd89311 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs @@ -8,16 +8,61 @@ namespace Microsoft.AspNetCore.Razor.Language { public class DefaultRazorProjectEngineIntegrationTest { + [Fact] + public void Process_SetsOptions_Runtime() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var parserOptions = codeDocument.GetParserOptions(); + Assert.False(parserOptions.DesignTime); + + var codeGenerationOptions = codeDocument.GetCodeGenerationOptions(); + Assert.False(codeGenerationOptions.DesignTime); + Assert.False(codeGenerationOptions.SuppressChecksum); + Assert.False(codeGenerationOptions.SuppressMetadataAttributes); + } + + [Fact] + public void ProcessDesignTime_SetsOptions_DesignTime() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + var parserOptions = codeDocument.GetParserOptions(); + Assert.True(parserOptions.DesignTime); + + var codeGenerationOptions = codeDocument.GetCodeGenerationOptions(); + Assert.True(codeGenerationOptions.DesignTime); + Assert.True(codeGenerationOptions.SuppressChecksum); + Assert.True(codeGenerationOptions.SuppressMetadataAttributes); + } + [Fact] public void Process_GetsImportsFromFeature() { // Arrange var projectItem = new TestRazorProjectItem("Index.cshtml"); + var testImport = TestRazorSourceDocument.Create(); - var importFeature = new Mock(); - importFeature.Setup(feature => feature.GetImports(It.IsAny())) + var importFeature = new Mock(); + importFeature + .Setup(feature => feature.GetImports(It.IsAny())) .Returns(new[] { testImport }); - var projectEngine = RazorProjectEngine.Create(TestRazorProjectFileSystem.Empty, builder => + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty, builder => { builder.SetImportFeature(importFeature.Object); }); @@ -35,7 +80,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var projectItem = new TestRazorProjectItem("Index.cshtml"); - var projectEngine = RazorProjectEngine.Create(TestRazorProjectFileSystem.Empty); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); // Act var codeDocument = projectEngine.Process(projectItem); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs index 67084a4052..dcb8d6d6ff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs @@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperBody_DesignTime_WritesChildren() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperCreate_DesignTime_RendersCorrectly_UsesSpecifiedTagHelperType() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -190,7 +190,7 @@ __tagHelperExecutionContext.Add(__TestNamespace_MyTagHelper); public void WriteTagHelperExecute_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -243,7 +243,7 @@ __tagHelperExecutionContext = __tagHelperScopeManager.End(); public void WriteTagHelperHtmlAttribute_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -431,7 +431,7 @@ EndAddHtmlAttributeValues(__tagHelperExecutionContext); public void WriteTagHelperProperty_DesignTime_StringProperty_HtmlContent_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -472,7 +472,7 @@ __InputTagHelper.StringProp = ""value""; public void WriteTagHelperProperty_DesignTime_StringProperty_NonHtmlContent_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -513,7 +513,7 @@ __InputTagHelper.StringProp = string.Empty; public void WriteTagHelperProperty_DesignTime_NonStringProperty_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -560,7 +560,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringProperty_SecondUseOfAttribute() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -602,7 +602,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringProperty_RendersCorrectly_WithoutLocation() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -642,7 +642,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringIndexer_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -687,7 +687,7 @@ __InputTagHelper.IntIndexer[""bound""] = 32; public void WriteTagHelperProperty_DesignTime_NonStringIndexer_RendersCorrectly_WithoutLocation() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -1064,7 +1064,7 @@ __tagHelperExecutionContext.AddTagHelperAttribute(""foo-bound"", __InputTagHelpe public void WriteTagHelperRuntime_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var node = new DefaultTagHelperRuntimeIntermediateNode(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs index 14c6aa4453..41f899512b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs @@ -148,5 +148,67 @@ namespace Microsoft.AspNetCore.Razor.Language // Assert Assert.Same(expected, codeDocument.Items[typeof(TagHelperDocumentContext)]); } + + [Fact] + public void GetParserOptions_ReturnsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorParserOptions.CreateDefault(); + codeDocument.Items[typeof(RazorParserOptions)] = expected; + + // Act + var actual = codeDocument.GetParserOptions(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetParserOptions_SetsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorParserOptions.CreateDefault(); + + // Act + codeDocument.SetParserOptions(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorParserOptions)]); + } + + [Fact] + public void GetCodeGenerationOptions_ReturnsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCodeGenerationOptions.CreateDefault(); + codeDocument.Items[typeof(RazorCodeGenerationOptions)] = expected; + + // Act + var actual = codeDocument.GetCodeGenerationOptions(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetCodeGenerationOptions_SetsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCodeGenerationOptions.CreateDefault(); + + // Act + codeDocument.SetCodeGenerationOptions(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorCodeGenerationOptions)]); + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs index 50f9328b1b..424b5fddd4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs @@ -145,7 +145,7 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Collection( feature.TargetExtensions, extension => Assert.IsType(extension), - extension => Assert.False(Assert.IsType(extension).DesignTime), + extension => Assert.IsType(extension), extension => Assert.IsType(extension)); } @@ -190,7 +190,7 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Collection( feature.TargetExtensions, extension => Assert.IsType(extension), - extension => Assert.True(Assert.IsType(extension).DesignTime), + extension => Assert.IsType(extension), extension => Assert.IsType(extension)); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs index b3e91c29bc..f0a57128c3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs @@ -14,11 +14,11 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); - var testFeature1 = Mock.Of(); - var testFeature2 = Mock.Of(); + var testFeature1 = Mock.Of(); + var testFeature2 = Mock.Of(); builder.Features.Add(testFeature1); builder.Features.Add(testFeature2); - var newFeature = Mock.Of(); + var newFeature = Mock.Of(); // Act builder.SetImportFeature(newFeature); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs new file mode 100644 index 0000000000..d901c16199 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs @@ -0,0 +1,85 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Extensions; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test +{ + public class RazorProjectEngineTest + { + [Fact] + public void CreateDesignTime_Lambda_AddsFeaturesAndPhases() + { + // Arrange + + // Act + var engine = RazorProjectEngine.Create(RazorConfiguration.Default, Mock.Of()); + + // Assert + AssertDefaultPhases(engine); + AssertDefaultFeatures(engine); + AssertDefaultDirectives(engine); + AssertDefaultTargetExtensions(engine); + } + + private static void AssertDefaultPhases(RazorProjectEngine engine) + { + Assert.Collection( + engine.Phases, + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase)); + } + + private static void AssertDefaultFeatures(RazorProjectEngine engine) + { + var features = engine.EngineFeatures.OrderBy(f => f.GetType().Name).ToArray(); + Assert.Collection( + features, + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature)); + } + + private static void AssertDefaultDirectives(RazorProjectEngine engine) + { + var feature = engine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + Assert.Empty(feature.Directives); + } + + private static void AssertDefaultTargetExtensions(RazorProjectEngine engine) + { + var feature = engine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + + var extensions = feature.TargetExtensions.OrderBy(f => f.GetType().Name).ToArray(); + Assert.Collection( + extensions, + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension)); + } + } +} From 0c6ec099584798b5222b669633604269c75d5f15 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 13 Feb 2018 15:39:32 -0800 Subject: [PATCH 04/56] Addressed Taylors feedback --- .../DefaultRazorProjectEngine.cs | 97 ++++++++++--------- .../RazorProjectEngine.cs | 25 +++-- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs index 6ac8e4c4cd..b432fd2f9a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs @@ -54,48 +54,7 @@ namespace Microsoft.AspNetCore.Razor.Language public override IReadOnlyList ProjectFeatures { get; } - protected override void ConfigureParserOptions(RazorParserOptionsBuilder builder) - { - if (builder == null) - { - throw new ArgumentNullException(nameof(builder)); - } - } - - protected override void ConfigureDesignTimeParserOptions(RazorParserOptionsBuilder builder) - { - if (builder == null) - { - throw new ArgumentNullException(nameof(builder)); - } - - builder.SetDesignTime(true); - } - - protected override void ConfigureCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) - { - if (builder == null) - { - throw new ArgumentNullException(nameof(builder)); - } - } - - protected override void ConfigureDesignTimeCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) - { - if (builder == null) - { - throw new ArgumentNullException(nameof(builder)); - } - - builder.SetDesignTime(true); - builder.SuppressChecksum = true; - builder.SuppressMetadataAttributes = true; - } - - protected override RazorCodeDocument ProcessCore( - RazorProjectItem projectItem, - Action configureParser, - Action configureCodeGeneration) + protected override RazorCodeDocument CreateCodeDocumentCore(RazorProjectItem projectItem) { if (projectItem == null) { @@ -107,14 +66,38 @@ namespace Microsoft.AspNetCore.Razor.Language var importFeature = GetRequiredFeature(); var imports = importFeature.GetImports(projectItem); - var parserOptions = GetRequiredFeature().Create(configureParser); - var codeGenerationOptions = GetRequiredFeature().Create(configureCodeGeneration); + var parserOptions = GetRequiredFeature().Create(ConfigureParserOptions); + var codeGenerationOptions = GetRequiredFeature().Create(ConfigureCodeGenerationOptions); - var codeDocument = RazorCodeDocument.Create(sourceDocument, imports, parserOptions, codeGenerationOptions); + return RazorCodeDocument.Create(sourceDocument, imports, parserOptions, codeGenerationOptions); + } + + protected override RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var sourceDocument = RazorSourceDocument.ReadFrom(projectItem); + + var importFeature = GetRequiredFeature(); + var imports = importFeature.GetImports(projectItem); + + var parserOptions = GetRequiredFeature().Create(ConfigureDesignTimeParserOptions); + var codeGenerationOptions = GetRequiredFeature().Create(ConfigureDesignTimeCodeGenerationOptions); + + return RazorCodeDocument.Create(sourceDocument, imports, parserOptions, codeGenerationOptions); + } + + protected override void ProcessCore(RazorCodeDocument codeDocument) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } Engine.Process(codeDocument); - - return codeDocument; } private TFeature GetRequiredFeature() where TFeature : IRazorProjectEngineFeature @@ -130,5 +113,25 @@ namespace Microsoft.AspNetCore.Razor.Language return feature; } + + private void ConfigureParserOptions(RazorParserOptionsBuilder builder) + { + } + + private void ConfigureDesignTimeParserOptions(RazorParserOptionsBuilder builder) + { + builder.SetDesignTime(true); + } + + private void ConfigureCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) + { + } + + private void ConfigureDesignTimeCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) + { + builder.SetDesignTime(true); + builder.SuppressChecksum = true; + builder.SuppressMetadataAttributes = true; + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs index 04f86c38d3..09ae61dc1f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs @@ -22,14 +22,6 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract IReadOnlyList ProjectFeatures { get; } - protected abstract void ConfigureParserOptions(RazorParserOptionsBuilder builder); - - protected abstract void ConfigureDesignTimeParserOptions(RazorParserOptionsBuilder builder); - - protected abstract void ConfigureCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder); - - protected abstract void ConfigureDesignTimeCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder); - public virtual RazorCodeDocument Process(RazorProjectItem projectItem) { if (projectItem == null) @@ -37,7 +29,9 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(projectItem)); } - return ProcessCore(projectItem, ConfigureParserOptions, ConfigureCodeGenerationOptions); + var codeDocument = CreateCodeDocumentCore(projectItem); + ProcessCore(codeDocument); + return codeDocument; } public virtual RazorCodeDocument ProcessDesignTime(RazorProjectItem projectItem) @@ -47,13 +41,16 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(projectItem)); } - return ProcessCore(projectItem, ConfigureDesignTimeParserOptions, ConfigureDesignTimeCodeGenerationOptions); + var codeDocument = CreateCodeDocumentDesignTimeCore(projectItem); + ProcessCore(codeDocument); + return codeDocument; } - protected abstract RazorCodeDocument ProcessCore( - RazorProjectItem projectItem, - Action configureParser, - Action configureCodeGeneration); + protected abstract RazorCodeDocument CreateCodeDocumentCore(RazorProjectItem projectItem); + + protected abstract RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem); + + protected abstract void ProcessCore(RazorCodeDocument codeDocument); public static RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem) => Create(configuration, fileSystem, configure: null); From 133eff3119a5d80df8231a09c73148a4c7941f99 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 9 Feb 2018 17:28:16 -0800 Subject: [PATCH 05/56] Move to RazorProjectEngine. - Instead of using Razor/Mvc TemplateEngine use `RazorProjectEngine`. This involved changing several locations (each of which used `RazorTemplateEngine` in an entirely different way) to use the RazorProjectEngine's two Process methods. - Changed an unused public API `VisualStudioRazorParser.TemplateEngine` to `VisualStudioRazorParser.RazorProjectEngine`. - Ported the remainder of `RazorEngineBuilder`'s extension methods over to `RazorProjectEngineBuilder`. These were used in tests and our `RazorGenerate` tool. - Added a few test helper methods/classes to enable simple testing of the `RazorProjectEngine`. - Resolved several test hacks that were working around little discrepancies each of the `RazorTemplateEngine` APIs. - Changed the template engine factory service to be a project engine factory service. --- .../CodeGenerationBenchmark.cs | 30 ++--- .../Properties/AssemblyInfo.cs | 1 + .../RazorProjectEngineBuilderExtensions.cs | 127 ++++++++++++++++++ .../CompositeRazorProjectFileSystem.cs | 15 ++- .../GenerateCommand.cs | 32 ++--- ...cs => RazorProjectEngineFactoryService.cs} | 4 +- .../BackgroundParser.cs | 49 ++++--- .../DefaultImportDocumentManager.cs | 33 +++-- .../DefaultImportDocumentManagerFactory.cs | 4 +- ... => DefaultProjectEngineFactoryService.cs} | 26 ++-- ...aultProjectEngineFactoryServiceFactory.cs} | 6 +- .../DefaultVisualStudioRazorParser.cs | 20 +-- .../DefaultVisualStudioRazorParserFactory.cs | 12 +- ...ltVisualStudioRazorParserFactoryFactory.cs | 4 +- .../TextSnapshotProjectItem.cs | 65 +++++++++ .../TextSnapshotSourceDocument.cs | 79 ----------- .../VisualStudioRazorParser.cs | 2 +- src/RazorPageGenerator/Program.cs | 36 ++--- .../RazorProjectEngineBuilderExtensions.cs | 70 ++++++++++ .../Language/TestRazorProjectFileSystem.cs | 5 +- .../Properties/AssemblyInfo.cs | 2 + ...ultImportDocumentManagerIntegrationTest.cs | 6 +- .../DefaultImportDocumentManagerTest.cs | 4 +- ...DefaultProjectEngineFactoryServiceTest.cs} | 25 ++-- ...tVisualStudioRazorParserIntegrationTest.cs | 24 ++-- .../DefaultVisualStudioRazorParserTest.cs | 22 +-- .../RazorSyntaxTreePartialParserTest.cs | 50 +++---- .../RazorPageGeneratorTest.cs | 5 +- 28 files changed, 471 insertions(+), 287 deletions(-) rename src/Microsoft.CodeAnalysis.Razor.Workspaces/{RazorTemplateEngineFactoryService.cs => RazorProjectEngineFactoryService.cs} (61%) rename src/Microsoft.VisualStudio.Editor.Razor/{DefaultTemplateEngineFactoryService.cs => DefaultProjectEngineFactoryService.cs} (77%) rename src/Microsoft.VisualStudio.Editor.Razor/{DefaultTemplateEngineFactoryServiceFactory.cs => DefaultProjectEngineFactoryServiceFactory.cs} (60%) create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs delete mode 100644 src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotSourceDocument.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs rename test/Microsoft.VisualStudio.Editor.Razor.Test/{DefaultTemplateEngineFactoryServiceTest.cs => DefaultProjectEngineFactoryServiceTest.cs} (89%) diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs index b4320782e6..c35e1db42f 100644 --- a/benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.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 System.Collections.Generic; using System.IO; using BenchmarkDotNet.Attributes; using Microsoft.AspNetCore.Mvc.Razor.Extensions; @@ -21,33 +20,22 @@ namespace Microsoft.AspNetCore.Razor.Performance } var root = current; - - var engine = RazorEngine.Create(b => { RazorExtensions.Register(b); }); - var fileSystem = RazorProjectFileSystem.Create(root.FullName); + + ProjectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => RazorExtensions.Register(b)); ; - DesignTimeTemplateEngine = new MvcRazorTemplateEngine(RazorEngine.CreateDesignTime(b => { RazorExtensions.Register(b); }), fileSystem); - RuntimeTemplateEngine = new MvcRazorTemplateEngine(RazorEngine.Create(b => { RazorExtensions.Register(b); }), fileSystem); - - var codeDocument = RuntimeTemplateEngine.CreateCodeDocument(Path.Combine(root.FullName, "MSN.cshtml")); - - Imports = codeDocument.Imports; - MSN = codeDocument.Source; + MSN = fileSystem.GetItem(Path.Combine(root.FullName, "MSN.cshtml")); } - public RazorTemplateEngine DesignTimeTemplateEngine { get; } + public RazorProjectEngine ProjectEngine { get; } - public RazorTemplateEngine RuntimeTemplateEngine { get; } - - public IReadOnlyList Imports { get; } - - public RazorSourceDocument MSN { get; } + public RazorProjectItem MSN { get; } [Benchmark(Description = "Razor Design Time Code Generation of MSN.com")] public void CodeGeneration_DesignTime_LargeStaticFile() { - var codeDocument = RazorCodeDocument.Create(MSN, Imports); - var generated = DesignTimeTemplateEngine.GenerateCode(codeDocument); + var codeDocument = ProjectEngine.ProcessDesignTime(MSN); + var generated = codeDocument.GetCSharpDocument(); if (generated.Diagnostics.Count != 0) { @@ -58,8 +46,8 @@ namespace Microsoft.AspNetCore.Razor.Performance [Benchmark(Description = "Razor Runtime Code Generation of MSN.com")] public void CodeGeneration_Runtime_LargeStaticFile() { - var codeDocument = RazorCodeDocument.Create(MSN, Imports); - var generated = RuntimeTemplateEngine.GenerateCode(codeDocument); + var codeDocument = ProjectEngine.Process(MSN); + var generated = codeDocument.GetCSharpDocument(); if (generated.Diagnostics.Count != 0) { diff --git a/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs index 02e2547355..7214d8baca 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.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.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Performance, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.GenerateTool, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs index 6d14b838eb..4c3fe12cc7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs @@ -2,13 +2,77 @@ // 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.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language { public static class RazorProjectEngineBuilderExtensions { + /// + /// Registers a class configuration delegate that gets invoked during code generation. + /// + /// The . + /// invoked to configure + /// during code generation. + /// The . + public static RazorProjectEngineBuilder ConfigureClass( + this RazorProjectEngineBuilder builder, + Action configureClass) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (configureClass == null) + { + throw new ArgumentNullException(nameof(configureClass)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureClass.Add(configureClass); + return builder; + } + + /// + /// Sets the base type for generated types. + /// + /// The . + /// The name of the base type. + /// The . + public static RazorProjectEngineBuilder SetBaseType(this RazorProjectEngineBuilder builder, string baseType) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureClass.Add((document, @class) => @class.BaseType = baseType); + return builder; + } + + /// + /// Sets the namespace for generated types. + /// + /// The . + /// The name of the namespace. + /// The . + public static RazorProjectEngineBuilder SetNamespace(this RazorProjectEngineBuilder builder, string namespaceName) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureNamespace.Add((document, @namespace) => @namespace.Content = namespaceName); + return builder; + } + public static void SetImportFeature(this RazorProjectEngineBuilder builder, IImportProjectFeature feature) { if (builder == null) @@ -79,6 +143,27 @@ namespace Microsoft.AspNetCore.Razor.Language return builder; } + /// + /// Adds the provided documents as imports to all documents processed + /// by the . + /// + /// The . + /// The collection of imports. + /// The . + public static RazorProjectEngineBuilder AddDefaultImports(this RazorProjectEngineBuilder builder, params RazorSourceDocument[] imports) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var existingImportFeature = builder.Features.OfType().First(); + var testImportFeature = new AdditionalImportsProjectFeature(existingImportFeature, imports); + builder.SetImportFeature(testImportFeature); + + return builder; + } + private static IRazorDirectiveFeature GetDirectiveFeature(RazorProjectEngineBuilder builder) { var directiveFeature = builder.Features.OfType().FirstOrDefault(); @@ -102,5 +187,47 @@ namespace Microsoft.AspNetCore.Razor.Language return targetExtensionFeature; } + + private static DefaultDocumentClassifierPassFeature GetDefaultDocumentClassifierPassFeature(RazorProjectEngineBuilder builder) + { + var configurationFeature = builder.Features.OfType().FirstOrDefault(); + if (configurationFeature == null) + { + configurationFeature = new DefaultDocumentClassifierPassFeature(); + builder.Features.Add(configurationFeature); + } + + return configurationFeature; + } + + private class AdditionalImportsProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private readonly IImportProjectFeature _existingImportFeature; + private readonly RazorSourceDocument[] _imports; + + public override RazorProjectEngine ProjectEngine + { + get => base.ProjectEngine; + set + { + _existingImportFeature.ProjectEngine = value; + base.ProjectEngine = value; + } + } + + public AdditionalImportsProjectFeature(IImportProjectFeature existingImportFeature, params RazorSourceDocument[] imports) + { + _existingImportFeature = existingImportFeature; + _imports = imports; + } + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + var imports = _existingImportFeature.GetImports(projectItem).ToList(); + imports.AddRange(_imports); + + return imports; + } + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/CompositeRazorProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Tools/CompositeRazorProjectFileSystem.cs index 5102cf056b..63fad347ee 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/CompositeRazorProjectFileSystem.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/CompositeRazorProjectFileSystem.cs @@ -3,24 +3,25 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.AspNetCore.Razor.Tools { internal class CompositeRazorProjectFileSystem : RazorProjectFileSystem { - public CompositeRazorProjectFileSystem(IReadOnlyList projects) + public CompositeRazorProjectFileSystem(IReadOnlyList fileSystems) { - Projects = projects ?? throw new ArgumentNullException(nameof(projects)); + FileSystems = fileSystems ?? throw new ArgumentNullException(nameof(fileSystems)); } - public IReadOnlyList Projects { get; } + public IReadOnlyList FileSystems { get; } public override IEnumerable EnumerateItems(string basePath) { - foreach (var project in Projects) + foreach (var fileSystem in FileSystems) { - foreach (var result in project.EnumerateItems(basePath)) + foreach (var result in fileSystem.EnumerateItems(basePath)) { yield return result; } @@ -30,9 +31,9 @@ namespace Microsoft.AspNetCore.Razor.Tools public override RazorProjectItem GetItem(string path) { RazorProjectItem razorProjectItem = null; - foreach (var project in Projects) + foreach (var fileSystem in FileSystems) { - razorProjectItem = project.GetItem(path); + razorProjectItem = fileSystem.GetItem(path); if (razorProjectItem != null && razorProjectItem.Exists) { return razorProjectItem; diff --git a/src/Microsoft.AspNetCore.Razor.Tools/GenerateCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/GenerateCommand.cs index fc0a876940..0981cc1a03 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/GenerateCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/GenerateCommand.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Razor.Extensions; @@ -90,26 +91,20 @@ namespace Microsoft.AspNetCore.Razor.Tools tagHelperManifest = Path.Combine(projectDirectory, tagHelperManifest); var tagHelpers = GetTagHelpers(tagHelperManifest); - - var engine = RazorEngine.Create(b => + var inputItems = GetInputItems(projectDirectory, sources, outputs, relativePaths); + var compositeFileSystem = new CompositeRazorProjectFileSystem(new[] + { + GetVirtualRazorProjectSystem(inputItems), + RazorProjectFileSystem.Create(projectDirectory), + }); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, compositeFileSystem, b => { RazorExtensions.Register(b); b.Features.Add(new StaticTagHelperFeature() { TagHelpers = tagHelpers, }); }); - - var inputItems = GetInputItems(projectDirectory, sources, outputs, relativePaths); - var compositeProject = new CompositeRazorProjectFileSystem( - new[] - { - GetVirtualRazorProjectSystem(inputItems), - RazorProjectFileSystem.Create(projectDirectory), - }); - - var templateEngine = new MvcRazorTemplateEngine(engine, compositeProject); - - var results = GenerateCode(templateEngine, inputItems); + var results = GenerateCode(projectEngine, inputItems); var success = true; @@ -180,14 +175,15 @@ namespace Microsoft.AspNetCore.Razor.Tools return items; } - private OutputItem[] GenerateCode(RazorTemplateEngine templateEngine, SourceItem[] inputs) + private OutputItem[] GenerateCode(RazorProjectEngine projectEngine, SourceItem[] inputs) { var outputs = new OutputItem[inputs.Length]; - Parallel.For(0, outputs.Length, new ParallelOptions() { MaxDegreeOfParallelism = 4 }, i => + Parallel.For(0, outputs.Length, new ParallelOptions() { MaxDegreeOfParallelism = Debugger.IsAttached ? 1 : 4 }, i => { var inputItem = inputs[i]; - - var csharpDocument = templateEngine.GenerateCode(inputItem.FilePath); + var projectItem = projectEngine.FileSystem.GetItem(inputItem.FilePath); + var codeDocument = projectEngine.Process(projectItem); + var csharpDocument = codeDocument.GetCSharpDocument(); outputs[i] = new OutputItem(inputItem, csharpDocument); }); diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs similarity index 61% rename from src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs rename to src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs index 26ff5b803a..0388de4671 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs @@ -7,8 +7,8 @@ using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.Razor { - internal abstract class RazorTemplateEngineFactoryService : ILanguageService + internal abstract class RazorProjectEngineFactoryService : ILanguageService { - public abstract RazorTemplateEngine Create(string projectPath, Action configure); + public abstract RazorProjectEngine Create(string projectPath, Action configure); } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs index 887a98dab0..9a7cabb8e1 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Text; using System.Threading; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Legacy; @@ -18,10 +19,10 @@ namespace Microsoft.VisualStudio.Editor.Razor private MainThreadState _main; private BackgroundThread _bg; - public BackgroundParser(RazorTemplateEngine templateEngine, string filePath) + public BackgroundParser(RazorProjectEngine projectEngine, string filePath, string projectDirectory) { _main = new MainThreadState(filePath); - _bg = new BackgroundThread(_main, templateEngine, filePath); + _bg = new BackgroundThread(_main, projectEngine, filePath, projectDirectory); _main.ResultsReady += (sender, args) => OnResultsReady(args); } @@ -233,22 +234,25 @@ namespace Microsoft.VisualStudio.Editor.Razor private class BackgroundThread : ThreadStateBase { + private readonly string _filePath; + private readonly string _relativeFilePath; + private readonly string _projectDirectory; private MainThreadState _main; private Thread _backgroundThread; private CancellationToken _shutdownToken; - private RazorTemplateEngine _templateEngine; - private string _filePath; + private RazorProjectEngine _projectEngine; private RazorSyntaxTree _currentSyntaxTree; private IList _previouslyDiscarded = new List(); - public BackgroundThread(MainThreadState main, RazorTemplateEngine templateEngine, string fileName) + public BackgroundThread(MainThreadState main, RazorProjectEngine projectEngine, string filePath, string projectDirectory) { // Run on MAIN thread! _main = main; _shutdownToken = _main.CancelToken; - _templateEngine = templateEngine; - _filePath = fileName; - + _projectEngine = projectEngine; + _filePath = filePath; + _relativeFilePath = GetNormalizedRelativeFilePath(filePath, projectDirectory); + _projectDirectory = projectDirectory; _backgroundThread = new Thread(WorkerLoop); SetThreadId(_backgroundThread.ManagedThreadId); } @@ -262,8 +266,6 @@ namespace Microsoft.VisualStudio.Editor.Razor // **** BACKGROUND THREAD **** private void WorkerLoop() { - var fileNameOnly = Path.GetFileName(_filePath); - try { EnsureOnThread(); @@ -347,14 +349,31 @@ namespace Microsoft.VisualStudio.Editor.Razor { EnsureOnThread(); - var sourceDocument = new TextSnapshotSourceDocument(snapshot, _filePath); - var imports = _templateEngine.GetImports(_filePath); + var projectItem = new TextSnapshotProjectItem(snapshot, _projectDirectory, _relativeFilePath, _filePath); + var codeDocument = _projectEngine.ProcessDesignTime(projectItem); - var codeDocument = RazorCodeDocument.Create(sourceDocument, imports); - - _templateEngine.GenerateCode(codeDocument); return codeDocument; } + + private string GetNormalizedRelativeFilePath(string filePath, string projectDirectory) + { + if (filePath.StartsWith(projectDirectory, StringComparison.OrdinalIgnoreCase)) + { + filePath = filePath.Substring(projectDirectory.Length); + } + + if (filePath.Length > 1) + { + filePath = filePath.Replace('\\', '/'); + + if (filePath[0] != '/') + { + filePath = "/" + filePath; + } + } + + return filePath; + } } private class WorkParcel diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs index 36f600a59a..0783713d7c 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; @@ -15,7 +16,7 @@ namespace Microsoft.VisualStudio.Editor.Razor private readonly FileChangeTrackerFactory _fileChangeTrackerFactory; private readonly ForegroundDispatcher _foregroundDispatcher; private readonly ErrorReporter _errorReporter; - private readonly RazorTemplateEngineFactoryService _templateEngineFactoryService; + private readonly RazorProjectEngineFactoryService _projectEngineFactoryService; private readonly Dictionary _importTrackerCache; public override event EventHandler Changed; @@ -24,7 +25,7 @@ namespace Microsoft.VisualStudio.Editor.Razor ForegroundDispatcher foregroundDispatcher, ErrorReporter errorReporter, FileChangeTrackerFactory fileChangeTrackerFactory, - RazorTemplateEngineFactoryService templateEngineFactoryService) + RazorProjectEngineFactoryService projectEngineFactoryService) { if (foregroundDispatcher == null) { @@ -41,15 +42,15 @@ namespace Microsoft.VisualStudio.Editor.Razor throw new ArgumentNullException(nameof(fileChangeTrackerFactory)); } - if (templateEngineFactoryService == null) + if (projectEngineFactoryService == null) { - throw new ArgumentNullException(nameof(templateEngineFactoryService)); + throw new ArgumentNullException(nameof(projectEngineFactoryService)); } _foregroundDispatcher = foregroundDispatcher; _errorReporter = errorReporter; _fileChangeTrackerFactory = fileChangeTrackerFactory; - _templateEngineFactoryService = templateEngineFactoryService; + _projectEngineFactoryService = projectEngineFactoryService; _importTrackerCache = new Dictionary(StringComparer.OrdinalIgnoreCase); } @@ -115,10 +116,26 @@ namespace Microsoft.VisualStudio.Editor.Razor private IEnumerable GetImportItems(VisualStudioDocumentTracker tracker) { var projectDirectory = Path.GetDirectoryName(tracker.ProjectPath); - var templateEngine = _templateEngineFactoryService.Create(projectDirectory, _ => { }); - var imports = templateEngine.GetImportItems(tracker.FilePath); + var projectEngine = _projectEngineFactoryService.Create(projectDirectory, _ => { }); + var trackerItem = projectEngine.FileSystem.GetItem(tracker.FilePath); + var importFeature = projectEngine.ProjectFeatures.OfType().FirstOrDefault(); - return imports; + // There should always be an import feature unless someone has misconfigured their RazorProjectEngine. + // In that case once we attempt to parse the Razor file we'll explode and give the a user a decent + // error message; for now, lets just be extra protective and assume 0 imports to not give a bad error. + var imports = importFeature?.GetImports(trackerItem) ?? Enumerable.Empty(); + var physicalImports = imports.Where(import => import.FilePath != null); + + // Now that we have non-dynamic imports we need to get their RazorProjectItem equivalents so we have their + // physical file paths (according to the FileSystem). + var projectItems = new List(); + foreach (var physicalImport in physicalImports) + { + var projectItem = projectEngine.FileSystem.GetItem(physicalImport.FilePath); + projectItems.Add(projectItem); + } + + return projectItems; } private void OnChanged(ImportTracker importTracker, FileChangeKind changeKind) diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManagerFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManagerFactory.cs index 480374c4f8..47efa8b96c 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManagerFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManagerFactory.cs @@ -35,13 +35,13 @@ namespace Microsoft.VisualStudio.Editor.Razor var errorReporter = languageServices.WorkspaceServices.GetRequiredService(); var fileChangeTrackerFactory = languageServices.GetRequiredService(); - var templateEngineFactoryService = languageServices.GetRequiredService(); + var projectEngineFactoryService = languageServices.GetRequiredService(); return new DefaultImportDocumentManager( _foregroundDispatcher, errorReporter, fileChangeTrackerFactory, - templateEngineFactoryService); + projectEngineFactoryService); } } } diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs similarity index 77% rename from src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs index f4f7c8b608..5d1373729c 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs @@ -12,7 +12,7 @@ using MvcLatest = Microsoft.AspNetCore.Mvc.Razor.Extensions; namespace Microsoft.VisualStudio.Editor.Razor { - internal class DefaultTemplateEngineFactoryService : RazorTemplateEngineFactoryService + internal class DefaultProjectEngineFactoryService : RazorProjectEngineFactoryService { private readonly static MvcExtensibilityConfiguration DefaultConfiguration = new MvcExtensibilityConfiguration( RazorLanguageVersion.Version_2_0, @@ -22,7 +22,7 @@ namespace Microsoft.VisualStudio.Editor.Razor private readonly ProjectSnapshotManager _projectManager; - public DefaultTemplateEngineFactoryService(ProjectSnapshotManager projectManager) + public DefaultProjectEngineFactoryService(ProjectSnapshotManager projectManager) { if (projectManager == null) { @@ -32,7 +32,7 @@ namespace Microsoft.VisualStudio.Editor.Razor _projectManager = projectManager; } - public override RazorTemplateEngine Create(string projectPath, Action configure) + public override RazorProjectEngine Create(string projectPath, Action configure) { if (projectPath == null) { @@ -43,12 +43,14 @@ namespace Microsoft.VisualStudio.Editor.Razor var project = FindProject(projectPath); var configuration = (project?.Configuration as MvcExtensibilityConfiguration) ?? DefaultConfiguration; var razorLanguageVersion = configuration.LanguageVersion; - var razorConfiguration = new RazorConfiguration(razorLanguageVersion, "unnamed", Array.Empty()); - RazorEngine engine; + var razorConfiguration = new RazorConfiguration(razorLanguageVersion, "unnamed", Array.Empty()); + var fileSystem = RazorProjectFileSystem.Create(projectPath); + + RazorProjectEngine projectEngine; if (razorLanguageVersion.Major == 1) { - engine = RazorEngine.CreateCore(razorConfiguration, true, b => + projectEngine = RazorProjectEngine.Create(razorConfiguration, fileSystem, b => { configure?.Invoke(b); @@ -59,24 +61,18 @@ namespace Microsoft.VisualStudio.Editor.Razor Mvc1_X.RazorExtensions.RegisterViewComponentTagHelpers(b); } }); - - var templateEngine = new Mvc1_X.MvcRazorTemplateEngine(engine, RazorProjectFileSystem.Create(projectPath)); - templateEngine.Options.ImportsFileName = "_ViewImports.cshtml"; - return templateEngine; } else { - engine = RazorEngine.CreateCore(razorConfiguration, true, b => + projectEngine = RazorProjectEngine.Create(razorConfiguration, fileSystem, b => { configure?.Invoke(b); MvcLatest.RazorExtensions.Register(b); }); - - var templateEngine = new MvcLatest.MvcRazorTemplateEngine(engine, RazorProjectFileSystem.Create(projectPath)); - templateEngine.Options.ImportsFileName = "_ViewImports.cshtml"; - return templateEngine; } + + return projectEngine; } private ProjectSnapshot FindProject(string directory) diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs similarity index 60% rename from src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs index f95df76c08..babed97a5c 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs @@ -8,12 +8,12 @@ using Microsoft.CodeAnalysis.Razor.ProjectSystem; namespace Microsoft.VisualStudio.Editor.Razor { - [ExportLanguageServiceFactory(typeof(RazorTemplateEngineFactoryService), RazorLanguage.Name, ServiceLayer.Default)] - internal class DefaultTemplateEngineFactoryServiceFactory : ILanguageServiceFactory + [ExportLanguageServiceFactory(typeof(RazorProjectEngineFactoryService), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultProjectEngineFactoryServiceFactory : ILanguageServiceFactory { public ILanguageService CreateLanguageService(HostLanguageServices languageServices) { - return new DefaultTemplateEngineFactoryService(languageServices.GetRequiredService()); + return new DefaultProjectEngineFactoryService(languageServices.GetRequiredService()); } } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs index 053b980e86..7225f0dd8e 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs @@ -31,9 +31,9 @@ namespace Microsoft.VisualStudio.Editor.Razor private readonly VisualStudioCompletionBroker _completionBroker; private readonly VisualStudioDocumentTracker _documentTracker; private readonly ForegroundDispatcher _dispatcher; - private readonly RazorTemplateEngineFactoryService _templateEngineFactory; + private readonly RazorProjectEngineFactoryService _projectEngineFactory; private readonly ErrorReporter _errorReporter; - private RazorTemplateEngine _templateEngine; + private RazorProjectEngine _projectEngine; private RazorCodeDocument _codeDocument; private ITextSnapshot _snapshot; private bool _disposed; @@ -47,7 +47,7 @@ namespace Microsoft.VisualStudio.Editor.Razor public DefaultVisualStudioRazorParser( ForegroundDispatcher dispatcher, VisualStudioDocumentTracker documentTracker, - RazorTemplateEngineFactoryService templateEngineFactory, + RazorProjectEngineFactoryService projectEngineFactory, ErrorReporter errorReporter, VisualStudioCompletionBroker completionBroker) { @@ -61,9 +61,9 @@ namespace Microsoft.VisualStudio.Editor.Razor throw new ArgumentNullException(nameof(documentTracker)); } - if (templateEngineFactory == null) + if (projectEngineFactory == null) { - throw new ArgumentNullException(nameof(templateEngineFactory)); + throw new ArgumentNullException(nameof(projectEngineFactory)); } if (errorReporter == null) @@ -77,7 +77,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } _dispatcher = dispatcher; - _templateEngineFactory = templateEngineFactory; + _projectEngineFactory = projectEngineFactory; _errorReporter = errorReporter; _completionBroker = completionBroker; _documentTracker = documentTracker; @@ -85,7 +85,7 @@ namespace Microsoft.VisualStudio.Editor.Razor _documentTracker.ContextChanged += DocumentTracker_ContextChanged; } - public override RazorTemplateEngine TemplateEngine => _templateEngine; + public override RazorProjectEngine ProjectEngine => _projectEngine; public override string FilePath => _documentTracker.FilePath; @@ -170,8 +170,8 @@ namespace Microsoft.VisualStudio.Editor.Razor _dispatcher.AssertForegroundThread(); var projectDirectory = Path.GetDirectoryName(_documentTracker.ProjectPath); - _templateEngine = _templateEngineFactory.Create(projectDirectory, ConfigureTemplateEngine); - _parser = new BackgroundParser(TemplateEngine, FilePath); + _projectEngine = _projectEngineFactory.Create(projectDirectory, ConfigureProjectEngine); + _parser = new BackgroundParser(ProjectEngine, FilePath, projectDirectory); _parser.ResultsReady += OnResultsReady; _parser.Start(); @@ -383,7 +383,7 @@ namespace Microsoft.VisualStudio.Editor.Razor DocumentStructureChanged?.Invoke(this, args); } - private void ConfigureTemplateEngine(IRazorEngineBuilder builder) + private void ConfigureProjectEngine(RazorProjectEngineBuilder builder) { builder.Features.Add(new VisualStudioParserOptionsFeature(_documentTracker.EditorSettings)); builder.Features.Add(new VisualStudioTagHelperFeature(_documentTracker.TagHelpers)); diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs index 9e9ea12135..5318ede596 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.Editor.Razor internal class DefaultVisualStudioRazorParserFactory : VisualStudioRazorParserFactory { private readonly ForegroundDispatcher _dispatcher; - private readonly RazorTemplateEngineFactoryService _templateEngineFactoryService; + private readonly RazorProjectEngineFactoryService _projectEngineFactoryService; private readonly VisualStudioCompletionBroker _completionBroker; private readonly ErrorReporter _errorReporter; @@ -17,7 +17,7 @@ namespace Microsoft.VisualStudio.Editor.Razor ForegroundDispatcher dispatcher, ErrorReporter errorReporter, VisualStudioCompletionBroker completionBroker, - RazorTemplateEngineFactoryService templateEngineFactoryService) + RazorProjectEngineFactoryService projectEngineFactoryService) { if (dispatcher == null) { @@ -34,15 +34,15 @@ namespace Microsoft.VisualStudio.Editor.Razor throw new ArgumentNullException(nameof(completionBroker)); } - if (templateEngineFactoryService == null) + if (projectEngineFactoryService == null) { - throw new ArgumentNullException(nameof(templateEngineFactoryService)); + throw new ArgumentNullException(nameof(projectEngineFactoryService)); } _dispatcher = dispatcher; _errorReporter = errorReporter; _completionBroker = completionBroker; - _templateEngineFactoryService = templateEngineFactoryService; + _projectEngineFactoryService = projectEngineFactoryService; } public override VisualStudioRazorParser Create(VisualStudioDocumentTracker documentTracker) @@ -57,7 +57,7 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( _dispatcher, documentTracker, - _templateEngineFactoryService, + _projectEngineFactoryService, _errorReporter, _completionBroker); return parser; diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs index d1f2d94cdc..38cfe5f189 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs @@ -35,13 +35,13 @@ namespace Microsoft.VisualStudio.Editor.Razor var workspaceServices = languageServices.WorkspaceServices; var errorReporter = workspaceServices.GetRequiredService(); var completionBroker = languageServices.GetRequiredService(); - var templateEngineFactoryService = languageServices.GetRequiredService(); + var projectEngineFactoryService = languageServices.GetRequiredService(); return new DefaultVisualStudioRazorParserFactory( _foregroundDispatcher, errorReporter, completionBroker, - templateEngineFactoryService); + projectEngineFactoryService); } } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs b/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs new file mode 100644 index 0000000000..4a605fd4a4 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs @@ -0,0 +1,65 @@ +// 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.Text; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.VisualStudio.Text; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class TextSnapshotProjectItem : RazorProjectItem + { + private readonly ITextSnapshot _snapshot; + + public TextSnapshotProjectItem(ITextSnapshot snapshot, string projectDirectory, string relativeFilePath, string filePath) + { + if (snapshot == null) + { + throw new ArgumentNullException(nameof(snapshot)); + } + + if (string.IsNullOrEmpty(projectDirectory)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(projectDirectory)); + } + + if (string.IsNullOrEmpty(relativeFilePath)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(relativeFilePath)); + } + + if (string.IsNullOrEmpty(filePath)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); + } + + _snapshot = snapshot; + BasePath = projectDirectory; + FilePath = relativeFilePath; + PhysicalPath = filePath; + } + + public override string BasePath { get; } + + public override string FilePath { get; } + + public override string PhysicalPath { get; } + + public override bool Exists => true; + + public override Stream Read() + { + var charArray = _snapshot.ToCharArray(0, _snapshot.Length); + + // We can assume UTF8 because the call path that reads from RazorProjectItem => SourceDocument + // can't determine the encoding and always assumes Encoding.UTF8. This is something that we might + // want to revisit in the future. + var bytes = Encoding.UTF8.GetBytes(charArray); + var memoryStream = new MemoryStream(bytes); + return memoryStream; + } + } + +} diff --git a/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotSourceDocument.cs b/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotSourceDocument.cs deleted file mode 100644 index ffe6c2f212..0000000000 --- a/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotSourceDocument.cs +++ /dev/null @@ -1,79 +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.Text; -using Microsoft.AspNetCore.Razor.Language; -using Microsoft.VisualStudio.Text; - -namespace Microsoft.VisualStudio.Editor.Razor -{ - internal class TextSnapshotSourceDocument : RazorSourceDocument - { - private readonly ITextSnapshot _buffer; - private readonly RazorSourceLineCollection _lines; - - public TextSnapshotSourceDocument(ITextSnapshot snapshot, string filePath) - { - if (snapshot == null) - { - throw new ArgumentNullException(nameof(snapshot)); - } - - if (filePath == null) - { - throw new ArgumentNullException(nameof(filePath)); - } - - _buffer = snapshot; - FilePath = filePath; - - _lines = new DefaultRazorSourceLineCollection(this); - } - - public override char this[int position] => _buffer[position]; - - public override Encoding Encoding => Encoding.UTF8; - - public override int Length => _buffer.Length; - - public override RazorSourceLineCollection Lines => _lines; - - public override string FilePath { get; } - - public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) - { - if (destination == null) - { - throw new ArgumentNullException(nameof(destination)); - } - - if (sourceIndex < 0) - { - throw new ArgumentOutOfRangeException(nameof(sourceIndex)); - } - - if (destinationIndex < 0) - { - throw new ArgumentOutOfRangeException(nameof(destinationIndex)); - } - - if (count < 0 || count > Length - sourceIndex || count > destination.Length - destinationIndex) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - if (count == 0) - { - return; - } - - for (var i = 0; i < count; i++) - { - destination[destinationIndex + i] = this[sourceIndex + i]; - } - } - - public override byte[] GetChecksum() => throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParser.cs index e8dd96cf90..41810db7c9 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParser.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.Editor.Razor { public abstract event EventHandler DocumentStructureChanged; - public abstract RazorTemplateEngine TemplateEngine { get; } + public abstract RazorProjectEngine ProjectEngine { get; } public abstract string FilePath { get; } diff --git a/src/RazorPageGenerator/Program.cs b/src/RazorPageGenerator/Program.cs index aecb2344dc..4646463889 100644 --- a/src/RazorPageGenerator/Program.cs +++ b/src/RazorPageGenerator/Program.cs @@ -31,8 +31,8 @@ Examples: var rootNamespace = args[0]; var targetProjectDirectory = args.Length > 1 ? args[1] : Directory.GetCurrentDirectory(); - var razorEngine = CreateRazorEngine(rootNamespace); - var results = MainCore(razorEngine, targetProjectDirectory); + var projectEngine = CreateProjectEngine(rootNamespace, targetProjectDirectory); + var results = MainCore(projectEngine, targetProjectDirectory); foreach (var result in results) { @@ -45,9 +45,10 @@ Examples: return 0; } - public static RazorEngine CreateRazorEngine(string rootNamespace, Action configure = null) + public static RazorProjectEngine CreateProjectEngine(string rootNamespace, string targetProjectDirectory, Action configure = null) { - var razorEngine = RazorEngine.Create(builder => + var fileSystem = RazorProjectFileSystem.Create(targetProjectDirectory); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, builder => { builder .SetNamespace(rootNamespace) @@ -66,20 +67,18 @@ Examples: { configure(builder); } - }); - return razorEngine; - } - public static IList MainCore(RazorEngine razorEngine, string targetProjectDirectory) - { - var viewDirectories = Directory.EnumerateDirectories(targetProjectDirectory, "Views", SearchOption.AllDirectories); - var razorProject = RazorProjectFileSystem.Create(targetProjectDirectory); - var templateEngine = new RazorTemplateEngine(razorEngine, razorProject); - templateEngine.Options.DefaultImports = RazorSourceDocument.Create(@" + builder.AddDefaultImports(RazorSourceDocument.Create(@" @using System @using System.Threading.Tasks -", fileName: null); +", fileName: null)); + }); + return projectEngine; + } + public static IList MainCore(RazorProjectEngine projectEngine, string targetProjectDirectory) + { + var viewDirectories = Directory.EnumerateDirectories(targetProjectDirectory, "Views", SearchOption.AllDirectories); var fileCount = 0; var results = new List(); @@ -88,7 +87,7 @@ Examples: Console.WriteLine(); Console.WriteLine(" Generating code files for views in {0}", viewDir); var viewDirPath = viewDir.Substring(targetProjectDirectory.Length).Replace('\\', '/'); - var cshtmlFiles = razorProject.EnumerateItems(viewDirPath); + var cshtmlFiles = projectEngine.FileSystem.EnumerateItems(viewDirPath); if (!cshtmlFiles.Any()) { @@ -99,7 +98,7 @@ Examples: foreach (var item in cshtmlFiles) { Console.WriteLine(" Generating code file for view {0}...", item.FileName); - results.Add(GenerateCodeFile(templateEngine, item)); + results.Add(GenerateCodeFile(projectEngine, item)); Console.WriteLine(" Done!"); fileCount++; } @@ -108,10 +107,11 @@ Examples: return results; } - private static RazorPageGeneratorResult GenerateCodeFile(RazorTemplateEngine templateEngine, RazorProjectItem projectItem) + private static RazorPageGeneratorResult GenerateCodeFile(RazorProjectEngine projectEngine, RazorProjectItem projectItem) { var projectItemWrapper = new FileSystemRazorProjectItemWrapper(projectItem); - var cSharpDocument = templateEngine.GenerateCode(projectItemWrapper); + var codeDocument = projectEngine.Process(projectItemWrapper); + var cSharpDocument = codeDocument.GetCSharpDocument(); if (cSharpDocument.Diagnostics.Any()) { var diagnostics = string.Join(Environment.NewLine, cSharpDocument.Diagnostics); diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs new file mode 100644 index 0000000000..bcea84e918 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs @@ -0,0 +1,70 @@ +// 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.Tasks; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public static class RazorProjectEngineBuilderExtensions + { + public static RazorProjectEngineBuilder AddTagHelpers(this RazorProjectEngineBuilder builder, params TagHelperDescriptor[] tagHelpers) + { + return AddTagHelpers(builder, (IEnumerable)tagHelpers); + } + + public static RazorProjectEngineBuilder AddTagHelpers(this RazorProjectEngineBuilder builder, IEnumerable tagHelpers) + { + var feature = (TestTagHelperFeature)builder.Features.OfType().FirstOrDefault(); + if (feature == null) + { + feature = new TestTagHelperFeature(); + builder.Features.Add(feature); + } + + feature.TagHelpers.AddRange(tagHelpers); + return builder; + } + + public static RazorProjectEngineBuilder ConfigureDocumentClassifier(this RazorProjectEngineBuilder builder) + { + var feature = builder.Features.OfType().FirstOrDefault(); + if (feature == null) + { + feature = new DefaultDocumentClassifierPassFeature(); + builder.Features.Add(feature); + } + + feature.ConfigureNamespace.Clear(); + feature.ConfigureClass.Clear(); + feature.ConfigureMethod.Clear(); + + feature.ConfigureNamespace.Add((RazorCodeDocument codeDocument, NamespaceDeclarationIntermediateNode node) => + { + node.Content = "Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles"; + }); + + feature.ConfigureClass.Add((RazorCodeDocument codeDocument, ClassDeclarationIntermediateNode node) => + { + node.ClassName = IntegrationTestBase.FileName.Replace('/', '_'); + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + }); + + feature.ConfigureMethod.Add((RazorCodeDocument codeDocument, MethodDeclarationIntermediateNode node) => + { + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + node.Modifiers.Add("async"); + node.MethodName = "ExecuteAsync"; + node.ReturnType = typeof(Task).FullName; + }); + + return builder; + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs index 08528b1014..39ff443eb5 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs @@ -4,11 +4,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; namespace Microsoft.AspNetCore.Razor.Language { - public class TestRazorProjectFileSystem : RazorProjectFileSystem + internal class TestRazorProjectFileSystem : DefaultRazorProjectFileSystem { public static RazorProjectFileSystem Empty = new TestRazorProjectFileSystem(); @@ -19,7 +18,7 @@ namespace Microsoft.AspNetCore.Razor.Language { } - public TestRazorProjectFileSystem(IList items) + public TestRazorProjectFileSystem(IList items) : base("/") { _lookup = items.ToDictionary(item => item.FilePath); } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs index 3a2cadef34..576c4e4e44 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/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.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Language.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerIntegrationTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerIntegrationTest.cs index 18d890faac..5494ba8a4a 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerIntegrationTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerIntegrationTest.cs @@ -21,7 +21,7 @@ namespace Microsoft.VisualStudio.Editor.Razor var testImportsPath = "C:\\path\\to\\project\\_ViewImports.cshtml"; var tracker = Mock.Of(t => t.FilePath == filePath && t.ProjectPath == projectPath); var anotherTracker = Mock.Of(t => t.FilePath == anotherFilePath && t.ProjectPath == projectPath); - var templateEngineFactoryService = GetTemplateEngineFactoryService(); + var templateEngineFactoryService = GetProjectEngineFactoryService(); var fileChangeTracker = new Mock(); fileChangeTracker.Setup(f => f.FilePath).Returns(testImportsPath); var fileChangeTrackerFactory = new Mock(); @@ -58,12 +58,12 @@ namespace Microsoft.VisualStudio.Editor.Razor Assert.True(called); } - private RazorTemplateEngineFactoryService GetTemplateEngineFactoryService() + private RazorProjectEngineFactoryService GetProjectEngineFactoryService() { var projectManager = new Mock(); projectManager.Setup(p => p.Projects).Returns(Array.Empty()); - var service = new DefaultTemplateEngineFactoryService(projectManager.Object); + var service = new DefaultProjectEngineFactoryService(projectManager.Object); return service; } } diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerTest.cs index 856461052f..c32bbd0af3 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerTest.cs @@ -137,12 +137,12 @@ namespace Microsoft.VisualStudio.Editor.Razor manager.OnUnsubscribed(tracker); } - private RazorTemplateEngineFactoryService GetTemplateEngineFactoryService() + private RazorProjectEngineFactoryService GetTemplateEngineFactoryService() { var projectManager = new Mock(); projectManager.Setup(p => p.Projects).Returns(Array.Empty()); - var service = new DefaultTemplateEngineFactoryService(projectManager.Object); + var service = new DefaultProjectEngineFactoryService(projectManager.Object); return service; } } diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs similarity index 89% rename from test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs rename to test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs index 5e83b06042..a9ef8baba3 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs @@ -14,9 +14,9 @@ using MvcLatest = Microsoft.AspNetCore.Mvc.Razor.Extensions; namespace Microsoft.VisualStudio.Editor.Razor { - public class DefaultTemplateEngineFactoryServiceTest + public class DefaultProjectEngineFactoryServiceTest { - public DefaultTemplateEngineFactoryServiceTest() + public DefaultProjectEngineFactoryServiceTest() { Project project = null; @@ -35,7 +35,7 @@ namespace Microsoft.VisualStudio.Editor.Razor public Workspace Workspace { get; } [Fact] - public void Create_CreatesDesignTimeTemplateEngine_ForLatest() + public void Create_CreatesTemplateEngine_ForLatest() { // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); @@ -49,13 +49,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("2.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -65,7 +64,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } [Fact] - public void Create_CreatesDesignTimeTemplateEngine_ForVersion1_1() + public void Create_CreatesTemplateEngine_ForVersion1_1() { // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); @@ -79,13 +78,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("1.1.3.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -109,7 +107,7 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("1.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => @@ -138,13 +136,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("3.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -159,13 +156,12 @@ namespace Microsoft.VisualStudio.Editor.Razor // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/DifferentPath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -181,13 +177,12 @@ namespace Microsoft.VisualStudio.Editor.Razor var projectManager = new TestProjectSnapshotManager(Workspace); projectManager.ProjectAdded(Project); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/DifferentPath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs index 9b38140366..6f4c0086cd 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; using System.Threading; @@ -525,34 +524,27 @@ namespace Microsoft.VisualStudio.Editor.Razor return new TestParserManager(parser); } - private static RazorTemplateEngineFactoryService CreateTemplateEngineFactory( + private static RazorProjectEngineFactoryService CreateTemplateEngineFactory( string path = TestLinePragmaFileName, IEnumerable tagHelpers = null) { - var engine = RazorEngine.CreateDesignTime(builder => + var fileSystem = new TestRazorProjectFileSystem(); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, builder => { RazorExtensions.Register(builder); + builder.AddDefaultImports(RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml")); + if (tagHelpers != null) { builder.AddTagHelpers(tagHelpers); } }); - // GetImports on RazorTemplateEngine will at least check that the item exists, so we need to pretend - // that it does. - var items = new List(); - items.Add(new TestRazorProjectItem(path)); + var projectEngineFactoryService = Mock.Of( + service => service.Create(It.IsAny(), It.IsAny>()) == projectEngine); - var project = new TestRazorProjectFileSystem(items); - - var templateEngine = new RazorTemplateEngine(engine, project); - templateEngine.Options.DefaultImports = RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml"); - - var templateEngineFactory = Mock.Of( - service => service.Create(It.IsAny(), It.IsAny>()) == templateEngine); - - return templateEngineFactory; + return projectEngineFactoryService; } private async Task RunTypeKeywordTestAsync(string keyword) diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs index 38075b0460..8747324211 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs @@ -32,7 +32,7 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of()); parser.Dispose(); @@ -48,7 +48,7 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of()); parser.Dispose(); @@ -64,7 +64,7 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of()); parser.Dispose(); @@ -80,7 +80,7 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of())) { @@ -108,7 +108,7 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, documentTracker, - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of())) { @@ -139,7 +139,7 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of()) { @@ -169,7 +169,7 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of()) { @@ -198,7 +198,7 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of())) { @@ -222,7 +222,7 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, documentTracker, - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of())) { @@ -242,7 +242,7 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(isSupportedProject: true), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of())) { @@ -261,7 +261,7 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(isSupportedProject: false), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), Mock.Of())) { diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs index 074fa0e1be..529e0126e8 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs @@ -3,14 +3,12 @@ using System; using System.Collections.Generic; -using System.Linq; using Microsoft.AspNetCore.Mvc.Razor.Extensions; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Legacy; using Microsoft.VisualStudio.Test; using Microsoft.VisualStudio.Text; using Xunit; -using Span = Microsoft.AspNetCore.Razor.Language.Legacy.Span; namespace Microsoft.VisualStudio.Editor.Razor { @@ -44,12 +42,13 @@ namespace Microsoft.VisualStudio.Editor.Razor { builder.Build() }; - var templateEngine = CreateTemplateEngine(tagHelpers: descriptors); - var document = TestRazorCodeDocument.Create( - TestRazorSourceDocument.Create(edit.OldSnapshot.GetText()), - new[] { templateEngine.Options.DefaultImports }); - templateEngine.Engine.Process(document); - var syntaxTree = document.GetSyntaxTree(); + var projectEngine = CreateProjectEngine(tagHelpers: descriptors); + var projectItem = new TestRazorProjectItem("Index.cshtml") + { + Content = edit.OldSnapshot.GetText() + }; + var codeDocument = projectEngine.Process(projectItem); + var syntaxTree = codeDocument.GetSyntaxTree(); var parser = new RazorSyntaxTreePartialParser(syntaxTree); // Act @@ -115,12 +114,13 @@ namespace Microsoft.VisualStudio.Editor.Razor attribute.SetPropertyName("StringAttribute"); }); var descriptors = new[] { builder.Build() }; - var templateEngine = CreateTemplateEngine(tagHelpers: descriptors); - var document = TestRazorCodeDocument.Create( - TestRazorSourceDocument.Create(edit.OldSnapshot.GetText()), - new[] { templateEngine.Options.DefaultImports }); - templateEngine.Engine.Process(document); - var syntaxTree = document.GetSyntaxTree(); + var projectEngine = CreateProjectEngine(tagHelpers: descriptors); + var sourceDocument = new TestRazorProjectItem("Index.cshtml") + { + Content = edit.OldSnapshot.GetText() + }; + var codeDocument = projectEngine.Process(sourceDocument); + var syntaxTree = codeDocument.GetSyntaxTree(); var parser = new RazorSyntaxTreePartialParser(syntaxTree); // Act @@ -548,7 +548,7 @@ namespace Microsoft.VisualStudio.Editor.Razor private void RunPartialParseRejectionTest(TestEdit edit, PartialParseResultInternal additionalFlags = 0) { - var templateEngine = CreateTemplateEngine(); + var templateEngine = CreateProjectEngine(); var document = TestRazorCodeDocument.Create(edit.OldSnapshot.GetText()); templateEngine.Engine.Process(document); var syntaxTree = document.GetSyntaxTree(); @@ -560,7 +560,7 @@ namespace Microsoft.VisualStudio.Editor.Razor private static void RunPartialParseTest(TestEdit edit, Block expectedTree, PartialParseResultInternal additionalFlags = 0) { - var templateEngine = CreateTemplateEngine(); + var templateEngine = CreateProjectEngine(); var document = TestRazorCodeDocument.Create(edit.OldSnapshot.GetText()); templateEngine.Engine.Process(document); var syntaxTree = document.GetSyntaxTree(); @@ -580,30 +580,24 @@ namespace Microsoft.VisualStudio.Editor.Razor return new TestEdit(sourceChange, oldSnapshot, changedSnapshot); } - private static RazorTemplateEngine CreateTemplateEngine( + private static RazorProjectEngine CreateProjectEngine( string path = "C:\\This\\Path\\Is\\Just\\For\\Line\\Pragmas.cshtml", IEnumerable tagHelpers = null) { - var engine = RazorEngine.CreateDesignTime(builder => + var fileSystem = new TestRazorProjectFileSystem(); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, builder => { RazorExtensions.Register(builder); + builder.AddDefaultImports(RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml")); + if (tagHelpers != null) { builder.AddTagHelpers(tagHelpers); } }); - // GetImports on RazorTemplateEngine will at least check that the item exists, so we need to pretend - // that it does. - var items = new List(); - items.Add(new TestRazorProjectItem(path)); - - var project = new TestRazorProjectFileSystem(items); - - var templateEngine = new RazorTemplateEngine(engine, project); - templateEngine.Options.DefaultImports = RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml"); - return templateEngine; + return projectEngine; } } } diff --git a/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs b/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs index 81465d9541..613df16b0c 100644 --- a/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs +++ b/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs @@ -35,9 +35,10 @@ namespace RazorPageGenerator.Test { // Arrange var projectDirectory = TestProject.GetProjectDirectory(GetType()); - var razorEngine = Program.CreateRazorEngine("Microsoft.AspNetCore.TestGenerated"); + var projectEngine = Program.CreateProjectEngine("Microsoft.AspNetCore.TestGenerated", projectDirectory); + // Act - var results = Program.MainCore(razorEngine, projectDirectory); + var results = Program.MainCore(projectEngine, projectDirectory); // Assert Assert.Collection(results, From 3e449ec3dea8c4fdf3ab2cb0b057d5d67f324ac8 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 14 Feb 2018 10:25:21 -0800 Subject: [PATCH 06/56] Update KoreBuild and deps --- build/dependencies.props | 28 ++++++++++++++-------------- korebuild-lock.txt | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 32429c1cb7..314473ee57 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,21 +4,21 @@ 0.10.11 - 2.1.0-preview1-1012 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 15.3.409 - 15.3.409 + 2.1.0-preview1-1025 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 15.7.0-preview-000010-1365343 + 15.7.0-preview-000010-1365343 2.6.1 2.6.1 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview2-25711-01 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-26208-06 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 2.0.0 - 2.1.0-preview1-26122-01 + 2.1.0-preview1-26208-06 15.3.0 15.0.26606 15.6.161-preview @@ -38,8 +38,8 @@ 2.0.1 10.0.1 1.1.92 - 4.5.0-preview1-26119-06 - 4.5.0-preview1-26119-06 + 4.5.0-preview1-26208-08 + 4.5.0-preview1-26208-08 9.0.1 2.7.0-beta3-62512-06 2.7.0-beta3-62512-06 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index bc9c05011f..46abcdc657 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-1012 -commithash:692d90ec605e64b329e04480d81d3a551536973b +version:2.1.0-preview1-1025 +commithash:5111f89ef43885db3dcf81cefc84e2a1d6715b73 From 02200d4c11907b094dc5441ac8461acf0e94e538 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 29 Jan 2018 11:41:42 -0800 Subject: [PATCH 07/56] Integrate new WebSDK One of these tests had to be updated and split into two because the expectations of the test weren't totally right. I also logged https://github.com/aspnet/Razor/issues/1986 during this, we didn't consider the impact of putting this logic in the WebSDK on class library. --- .../IntegrationTests/PublishIntegrationTest.cs | 18 ++++++++++++++++-- .../AppWithP2PReference.csproj | 3 --- test/testapps/ClassLibrary/ClassLibrary.csproj | 4 ++-- test/testapps/SimpleMvc/SimpleMvc.csproj | 3 --- test/testapps/SimplePages/SimplePages.csproj | 3 --- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs index 6089d6f378..6b80b97be6 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs @@ -74,14 +74,28 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "Views"), "*.cshtml"); } - [Fact] + [Fact] // This will use the old precompilation tool, RazorSDK shouldn't get involved. [InitializeTestProject("SimpleMvc")] - public async Task Publish_WithMvcRazorCompileOnPublish_PublishesAssembly() + public async Task Publish_WithMvcRazorCompileOnPublish_Noops() { var result = await DotnetMSBuild("Publish", "/p:MvcRazorCompileOnPublish=true"); Assert.BuildPassed(result); + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); + Assert.FileDoesNotExist(result, PublishOutputPath, "SimpleMvc.PrecompiledViews.dll"); + Assert.FileDoesNotExist(result, PublishOutputPath, "SimpleMvc.PrecompiledViews.pdb"); + } + + [Fact] // This is an override to force the new toolset + [InitializeTestProject("SimpleMvc")] + public async Task Publish_WithMvcRazorCompileOnPublish_AndRazorSDK_PublishesAssembly() + { + var result = await DotnetMSBuild("Publish", "/p:MvcRazorCompileOnPublish=true /p:ResolvedRazorCompileToolset=RazorSDK"); + + Assert.BuildPassed(result); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.PrecompiledViews.dll"); Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.PrecompiledViews.pdb"); diff --git a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj index 82ba010fe7..ee3aa0f554 100644 --- a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj +++ b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj @@ -1,9 +1,6 @@ netcoreapp2.0 - - - RazorSDK diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj index 18338f29d2..13f82dd665 100644 --- a/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -2,8 +2,8 @@ netcoreapp2.0 - - RazorSDK + + RazorSDK diff --git a/test/testapps/SimpleMvc/SimpleMvc.csproj b/test/testapps/SimpleMvc/SimpleMvc.csproj index 11dac1b1da..91bf7e583a 100644 --- a/test/testapps/SimpleMvc/SimpleMvc.csproj +++ b/test/testapps/SimpleMvc/SimpleMvc.csproj @@ -1,9 +1,6 @@ netcoreapp2.0 - - - RazorSDK diff --git a/test/testapps/SimplePages/SimplePages.csproj b/test/testapps/SimplePages/SimplePages.csproj index 11dac1b1da..91bf7e583a 100644 --- a/test/testapps/SimplePages/SimplePages.csproj +++ b/test/testapps/SimplePages/SimplePages.csproj @@ -1,9 +1,6 @@ netcoreapp2.0 - - - RazorSDK From 501c180b5f7c865eef382710b2d7adaa90a443c7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 15 Feb 2018 08:26:26 -0800 Subject: [PATCH 08/56] Use properties in package props to redirect imports --- src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props | 6 +++++- src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets | 8 ++++---- .../netstandard2.0/Microsoft.NET.Sdk.Razor.props | 5 ++--- .../netstandard2.0/Microsoft.NET.Sdk.Razor.targets | 14 -------------- .../Microsoft.NET.Sdk.Razor.props | 3 ++- .../Microsoft.NET.Sdk.Razor.targets | 14 -------------- 6 files changed, 13 insertions(+), 37 deletions(-) delete mode 100644 src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.targets delete mode 100644 src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.targets diff --git a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props index c95725d653..b5fb8f7017 100644 --- a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props +++ b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props @@ -10,5 +10,9 @@ Copyright (c) .NET Foundation. All rights reserved. *********************************************************************************************** --> - + + $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.props + + + diff --git a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets index 441bba39f8..c096a5cbf4 100644 --- a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets +++ b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets @@ -11,11 +11,11 @@ Copyright (c) .NET Foundation. All rights reserved. --> - - <_RazorSdkTargetsPath Condition="'$(IsCrossTargetingBuild)' == 'true'">$(MSBuildThisFileDirectory)..\buildMultiTargeting\Sdk.Razor.CurrentVersion.MultiTargeting.targets - <_RazorSdkTargetsPath Condition="'$(IsCrossTargetingBuild)' != 'true'">$(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets + + $(MSBuildThisFileDirectory)..\buildMultiTargeting\Sdk.Razor.CurrentVersion.MultiTargeting.targets + $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets - + diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props index 413376f510..6fad4d5180 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props @@ -10,9 +10,8 @@ Copyright (c) .NET Foundation. All rights reserved. *********************************************************************************************** --> - - - <_RazorSdkPackageReferenced>true + $(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.props + $(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.targets diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.targets deleted file mode 100644 index 7a5540f394..0000000000 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.targets +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props b/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props index 5c775cd329..a04423a57a 100644 --- a/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props +++ b/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props @@ -11,6 +11,7 @@ Copyright (c) .NET Foundation. All rights reserved. --> - <_RazorSdkPackageReferenced>true + $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.props + $(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.MultiTargeting.targets diff --git a/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.targets b/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.targets deleted file mode 100644 index e1ef8742d3..0000000000 --- a/src/Microsoft.NET.Sdk.Razor/buildMultiTargeting/Microsoft.NET.Sdk.Razor.targets +++ /dev/null @@ -1,14 +0,0 @@ - - - - From e200b69511e10d3c3c367a7ea96a3d2465c8dd7c Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 14 Feb 2018 14:37:09 -0800 Subject: [PATCH 09/56] Change IImportProjectFeature to consume RazorProjectItems. - Updated all implementations of `IImportProjectFeature`; for MVC I went ahead and made a single project item that's always returned for MVC scenarios. That project item is smart about returning its content in a light-weight stream fashion. - Had to add a `RazorProjectItem` => `RazorSourceDocument` conversion mechanic into `DefaultRazorProjectEngine`. - Added tests for `DefaultRazorProjectItem.ConvertToSourceDocument`. - Removed the `ProjectEngine` API from `VisualStudioRazorParser`. This was unrelated but was missed feedback. #2068 --- .../MvcImportProjectFeature.cs | 85 +++++++++--------- .../MvcImportProjectFeature.cs | 89 ++++++++++--------- .../DefaultImportProjectFeature.cs | 2 +- .../DefaultRazorProjectEngine.cs | 25 +++++- .../IImportProjectFeature.cs | 2 +- .../RazorProjectEngineBuilderExtensions.cs | 11 +-- .../DefaultImportDocumentManager.cs | 15 +--- .../DefaultVisualStudioRazorParser.cs | 4 +- .../VisualStudioRazorParser.cs | 2 - src/RazorPageGenerator/Program.cs | 36 +++++++- ...Test.cs => MvcImportProjectFeatureTest.cs} | 8 +- ...Test.cs => MvcImportProjectFeatureTest.cs} | 8 +- ...efaultRazorProjectEngineIntegrationTest.cs | 5 +- .../DefaultRazorProjectEngineTest.cs | 37 ++++++++ .../DefaultRazorProjectFileSystemTest.cs | 2 +- ...tVisualStudioRazorParserIntegrationTest.cs | 2 +- .../RazorSyntaxTreePartialParserTest.cs | 2 +- 17 files changed, 208 insertions(+), 127 deletions(-) rename test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/{DefaultMvcImportFeatureTest.cs => MvcImportProjectFeatureTest.cs} (92%) rename test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/{DefaultMvcImportFeatureTest.cs => MvcImportProjectFeatureTest.cs} (92%) create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs index b7ef608871..254c57c1c4 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs @@ -14,14 +14,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { private const string ImportsFileName = "_ViewImports.cshtml"; - public IReadOnlyList GetImports(RazorProjectItem projectItem) + public IReadOnlyList GetImports(RazorProjectItem projectItem) { if (projectItem == null) { throw new ArgumentNullException(nameof(projectItem)); } - var imports = new List(); + var imports = new List(); AddDefaultDirectivesImport(imports); // We add hierarchical imports second so any default directive imports can be overridden. @@ -31,54 +31,59 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X } // Internal for testing - internal static void AddDefaultDirectivesImport(List imports) + internal static void AddDefaultDirectivesImport(List imports) { - using (var stream = new MemoryStream()) - using (var writer = new StreamWriter(stream, Encoding.UTF8)) - { - writer.WriteLine("@using System"); - writer.WriteLine("@using System.Collections.Generic"); - writer.WriteLine("@using System.Linq"); - writer.WriteLine("@using System.Threading.Tasks"); - writer.WriteLine("@using Microsoft.AspNetCore.Mvc"); - writer.WriteLine("@using Microsoft.AspNetCore.Mvc.Rendering"); - writer.WriteLine("@using Microsoft.AspNetCore.Mvc.ViewFeatures"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider"); - writer.WriteLine("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor"); - writer.Flush(); - - stream.Position = 0; - var defaultMvcImports = RazorSourceDocument.ReadFrom(stream, fileName: null, encoding: Encoding.UTF8); - imports.Add(defaultMvcImports); - } + imports.Add(DefaultDirectivesProjectItem.Instance); } // Internal for testing - internal void AddHierarchicalImports(RazorProjectItem projectItem, List imports) + internal void AddHierarchicalImports(RazorProjectItem projectItem, List imports) { // We want items in descending order. FindHierarchicalItems returns items in ascending order. var importProjectItems = ProjectEngine.FileSystem.FindHierarchicalItems(projectItem.FilePath, ImportsFileName).Reverse(); - foreach (var importProjectItem in importProjectItems) + imports.AddRange(importProjectItems); + } + + private class DefaultDirectivesProjectItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultDirectivesProjectItem() { - RazorSourceDocument importSourceDocument; + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Collections.Generic +@using System.Linq +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Mvc +@using Microsoft.AspNetCore.Mvc.Rendering +@using Microsoft.AspNetCore.Mvc.ViewFeatures +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json +@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component +@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url +@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor +"; + var contentBytes = Encoding.UTF8.GetBytes(content); - if (importProjectItem.Exists) - { - importSourceDocument = RazorSourceDocument.ReadFrom(importProjectItem); - } - else - { - // File doesn't exist on disk so just add a marker source document as an identifier for "there could be something here". - var sourceDocumentProperties = new RazorSourceDocumentProperties(importProjectItem.FilePath, importProjectItem.RelativePhysicalPath); - importSourceDocument = RazorSourceDocument.Create(string.Empty, sourceDocumentProperties); - } - - imports.Add(importSourceDocument); + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultDirectivesProjectItem Instance { get; } = new DefaultDirectivesProjectItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs index 999dd6fdbb..5c6ee7361d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs @@ -14,14 +14,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { private const string ImportsFileName = "_ViewImports.cshtml"; - public IReadOnlyList GetImports(RazorProjectItem projectItem) + public IReadOnlyList GetImports(RazorProjectItem projectItem) { if (projectItem == null) { throw new ArgumentNullException(nameof(projectItem)); } - var imports = new List(); + var imports = new List(); AddDefaultDirectivesImport(imports); // We add hierarchical imports second so any default directive imports can be overridden. @@ -31,56 +31,61 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } // Internal for testing - internal static void AddDefaultDirectivesImport(List imports) + internal static void AddDefaultDirectivesImport(List imports) { - using (var stream = new MemoryStream()) - using (var writer = new StreamWriter(stream, Encoding.UTF8)) - { - writer.WriteLine("@using System"); - writer.WriteLine("@using System.Collections.Generic"); - writer.WriteLine("@using System.Linq"); - writer.WriteLine("@using System.Threading.Tasks"); - writer.WriteLine("@using Microsoft.AspNetCore.Mvc"); - writer.WriteLine("@using Microsoft.AspNetCore.Mvc.Rendering"); - writer.WriteLine("@using Microsoft.AspNetCore.Mvc.ViewFeatures"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url"); - writer.WriteLine("@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider"); - writer.WriteLine("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor"); - writer.WriteLine("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor"); - writer.WriteLine("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor"); - writer.Flush(); - - stream.Position = 0; - var defaultMvcImports = RazorSourceDocument.ReadFrom(stream, fileName: null, encoding: Encoding.UTF8); - imports.Add(defaultMvcImports); - } + imports.Add(DefaultDirectivesProjectItem.Instance); } // Internal for testing - internal void AddHierarchicalImports(RazorProjectItem projectItem, List imports) + internal void AddHierarchicalImports(RazorProjectItem projectItem, List imports) { // We want items in descending order. FindHierarchicalItems returns items in ascending order. var importProjectItems = ProjectEngine.FileSystem.FindHierarchicalItems(projectItem.FilePath, ImportsFileName).Reverse(); - foreach (var importProjectItem in importProjectItems) + imports.AddRange(importProjectItems); + } + + private class DefaultDirectivesProjectItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultDirectivesProjectItem() { - RazorSourceDocument importSourceDocument; + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Collections.Generic +@using System.Linq +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Mvc +@using Microsoft.AspNetCore.Mvc.Rendering +@using Microsoft.AspNetCore.Mvc.ViewFeatures +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json +@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component +@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url +@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor +"; + var contentBytes = Encoding.UTF8.GetBytes(content); - if (importProjectItem.Exists) - { - importSourceDocument = RazorSourceDocument.ReadFrom(importProjectItem); - } - else - { - // File doesn't exist on disk so just add a marker source document as an identifier for "there could be something here". - var sourceDocumentProperties = new RazorSourceDocumentProperties(importProjectItem.FilePath, importProjectItem.RelativePhysicalPath); - importSourceDocument = RazorSourceDocument.Create(string.Empty, sourceDocumentProperties); - } - - imports.Add(importSourceDocument); + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultDirectivesProjectItem Instance { get; } = new DefaultDirectivesProjectItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs index 15fc2635cd..92778322d7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs @@ -8,6 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature { - public IReadOnlyList GetImports(RazorProjectItem projectItem) => Array.Empty(); + public IReadOnlyList GetImports(RazorProjectItem projectItem) => Array.Empty(); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs index b432fd2f9a..e7eaafec22 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs @@ -64,12 +64,13 @@ namespace Microsoft.AspNetCore.Razor.Language var sourceDocument = RazorSourceDocument.ReadFrom(projectItem); var importFeature = GetRequiredFeature(); - var imports = importFeature.GetImports(projectItem); + var importItems = importFeature.GetImports(projectItem); + var importSourceDocuments = importItems.Select(ConvertToSourceDocument); var parserOptions = GetRequiredFeature().Create(ConfigureParserOptions); var codeGenerationOptions = GetRequiredFeature().Create(ConfigureCodeGenerationOptions); - return RazorCodeDocument.Create(sourceDocument, imports, parserOptions, codeGenerationOptions); + return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); } protected override RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem) @@ -82,12 +83,14 @@ namespace Microsoft.AspNetCore.Razor.Language var sourceDocument = RazorSourceDocument.ReadFrom(projectItem); var importFeature = GetRequiredFeature(); - var imports = importFeature.GetImports(projectItem); + var importItems = importFeature.GetImports(projectItem); + var importSourceDocuments = importItems.Select(ConvertToSourceDocument); var parserOptions = GetRequiredFeature().Create(ConfigureDesignTimeParserOptions); var codeGenerationOptions = GetRequiredFeature().Create(ConfigureDesignTimeCodeGenerationOptions); - return RazorCodeDocument.Create(sourceDocument, imports, parserOptions, codeGenerationOptions); + + return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); } protected override void ProcessCore(RazorCodeDocument codeDocument) @@ -133,5 +136,19 @@ namespace Microsoft.AspNetCore.Razor.Language builder.SuppressChecksum = true; builder.SuppressMetadataAttributes = true; } + + // Internal for testing + internal static RazorSourceDocument ConvertToSourceDocument(RazorProjectItem importItem) + { + if (importItem.Exists) + { + // Normal import, has file paths, content etc. + return RazorSourceDocument.ReadFrom(importItem); + } + + // Marker import, doesn't exist, used as an identifier for "there could be something here". + var sourceDocumentProperties = new RazorSourceDocumentProperties(importItem.FilePath, importItem.RelativePhysicalPath); + return RazorSourceDocument.Create(string.Empty, sourceDocumentProperties); + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs index 90bd6638f4..98d8ffe558 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs @@ -7,6 +7,6 @@ namespace Microsoft.AspNetCore.Razor.Language { public interface IImportProjectFeature : IRazorProjectEngineFeature { - IReadOnlyList GetImports(RazorProjectItem projectItem); + IReadOnlyList GetImports(RazorProjectItem projectItem); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs index 4c3fe12cc7..48695a6f97 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -144,13 +145,13 @@ namespace Microsoft.AspNetCore.Razor.Language } /// - /// Adds the provided documents as imports to all documents processed + /// Adds the provided s as imports to all project items processed /// by the . /// /// The . /// The collection of imports. /// The . - public static RazorProjectEngineBuilder AddDefaultImports(this RazorProjectEngineBuilder builder, params RazorSourceDocument[] imports) + public static RazorProjectEngineBuilder AddDefaultImports(this RazorProjectEngineBuilder builder, params RazorProjectItem[] imports) { if (builder == null) { @@ -203,7 +204,7 @@ namespace Microsoft.AspNetCore.Razor.Language private class AdditionalImportsProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature { private readonly IImportProjectFeature _existingImportFeature; - private readonly RazorSourceDocument[] _imports; + private readonly RazorProjectItem[] _imports; public override RazorProjectEngine ProjectEngine { @@ -215,13 +216,13 @@ namespace Microsoft.AspNetCore.Razor.Language } } - public AdditionalImportsProjectFeature(IImportProjectFeature existingImportFeature, params RazorSourceDocument[] imports) + public AdditionalImportsProjectFeature(IImportProjectFeature existingImportFeature, params RazorProjectItem[] imports) { _existingImportFeature = existingImportFeature; _imports = imports; } - public IReadOnlyList GetImports(RazorProjectItem projectItem) + public IReadOnlyList GetImports(RazorProjectItem projectItem) { var imports = _existingImportFeature.GetImports(projectItem).ToList(); imports.AddRange(_imports); diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs index 0783713d7c..2e8c5a450a 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs @@ -123,19 +123,10 @@ namespace Microsoft.VisualStudio.Editor.Razor // There should always be an import feature unless someone has misconfigured their RazorProjectEngine. // In that case once we attempt to parse the Razor file we'll explode and give the a user a decent // error message; for now, lets just be extra protective and assume 0 imports to not give a bad error. - var imports = importFeature?.GetImports(trackerItem) ?? Enumerable.Empty(); - var physicalImports = imports.Where(import => import.FilePath != null); + var importItems = importFeature?.GetImports(trackerItem) ?? Enumerable.Empty(); + var physicalImports = importItems.Where(import => import.FilePath != null); - // Now that we have non-dynamic imports we need to get their RazorProjectItem equivalents so we have their - // physical file paths (according to the FileSystem). - var projectItems = new List(); - foreach (var physicalImport in physicalImports) - { - var projectItem = projectEngine.FileSystem.GetItem(physicalImport.FilePath); - projectItems.Add(projectItem); - } - - return projectItems; + return physicalImports; } private void OnChanged(ImportTracker importTracker, FileChangeKind changeKind) diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs index 7225f0dd8e..ddbd000f0b 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs @@ -85,8 +85,6 @@ namespace Microsoft.VisualStudio.Editor.Razor _documentTracker.ContextChanged += DocumentTracker_ContextChanged; } - public override RazorProjectEngine ProjectEngine => _projectEngine; - public override string FilePath => _documentTracker.FilePath; public override RazorCodeDocument CodeDocument => _codeDocument; @@ -171,7 +169,7 @@ namespace Microsoft.VisualStudio.Editor.Razor var projectDirectory = Path.GetDirectoryName(_documentTracker.ProjectPath); _projectEngine = _projectEngineFactory.Create(projectDirectory, ConfigureProjectEngine); - _parser = new BackgroundParser(ProjectEngine, FilePath, projectDirectory); + _parser = new BackgroundParser(_projectEngine, FilePath, projectDirectory); _parser.ResultsReady += OnResultsReady; _parser.Start(); diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParser.cs index 41810db7c9..c1d71a6111 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParser.cs @@ -11,8 +11,6 @@ namespace Microsoft.VisualStudio.Editor.Razor { public abstract event EventHandler DocumentStructureChanged; - public abstract RazorProjectEngine ProjectEngine { get; } - public abstract string FilePath { get; } public abstract RazorCodeDocument CodeDocument { get; } diff --git a/src/RazorPageGenerator/Program.cs b/src/RazorPageGenerator/Program.cs index 4646463889..1aae7c86ef 100644 --- a/src/RazorPageGenerator/Program.cs +++ b/src/RazorPageGenerator/Program.cs @@ -68,10 +68,7 @@ Examples: configure(builder); } - builder.AddDefaultImports(RazorSourceDocument.Create(@" -@using System -@using System.Threading.Tasks -", fileName: null)); + builder.AddDefaultImports(DefaultImportItem.Instance); }); return projectEngine; } @@ -156,6 +153,37 @@ Examples: } } + private class DefaultImportItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultImportItem() + { + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Threading.Tasks +"; + var contentBytes = Encoding.UTF8.GetBytes(content); + + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultImportItem Instance { get; } = new DefaultImportItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); + } + private class FileSystemRazorProjectItemWrapper : RazorProjectItem { private readonly RazorProjectItem _source; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/DefaultMvcImportFeatureTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs similarity index 92% rename from test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/DefaultMvcImportFeatureTest.cs rename to test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs index ccd59408f9..7e811ee261 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/DefaultMvcImportFeatureTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs @@ -8,13 +8,13 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { - public class DefaultMvcImportFeatureTest + public class MvcImportProjectFeatureTest { [Fact] public void AddDefaultDirectivesImport_AddsSingleDynamicImport() { // Arrange - var imports = new List(); + var imports = new List(); // Act MvcImportProjectFeature.AddDefaultDirectivesImport(imports); @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() { // Arrange - var imports = new List(); + var imports = new List(); var projectItem = new TestRazorProjectItem("/Contact/Index.cshtml"); var testFileSystem = new TestRazorProjectFileSystem(new[] { @@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void AddHierarchicalImports_AddsViewImportSourceDocumentsNotOnDisk() { // Arrange - var imports = new List(); + var imports = new List(); var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); var mvcImportFeature = new MvcImportProjectFeature() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/DefaultMvcImportFeatureTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs similarity index 92% rename from test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/DefaultMvcImportFeatureTest.cs rename to test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs index 680ab9ba1e..e53046ed5a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/DefaultMvcImportFeatureTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs @@ -8,13 +8,13 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { - public class DefaultMvcImportFeatureTest + public class MvcImportProjectFeatureTest { [Fact] public void AddDefaultDirectivesImport_AddsSingleDynamicImport() { // Arrange - var imports = new List(); + var imports = new List(); // Act MvcImportProjectFeature.AddDefaultDirectivesImport(imports); @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() { // Arrange - var imports = new List(); + var imports = new List(); var projectItem = new TestRazorProjectItem("/Contact/Index.cshtml"); var testFileSystem = new TestRazorProjectFileSystem(new[] { @@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void AddHierarchicalImports_AddsViewImportSourceDocumentsNotOnDisk() { // Arrange - var imports = new List(); + var imports = new List(); var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); var mvcImportFeature = new MvcImportProjectFeature() diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs index 0edbd89311..427b34c1b6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.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.IO; using Moq; using Xunit; @@ -56,7 +57,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var projectItem = new TestRazorProjectItem("Index.cshtml"); - var testImport = TestRazorSourceDocument.Create(); + var testImport = Mock.Of(i => i.Read() == new MemoryStream() && i.FilePath == "testvalue"); var importFeature = new Mock(); importFeature .Setup(feature => feature.GetImports(It.IsAny())) @@ -72,7 +73,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Assert var import = Assert.Single(codeDocument.Imports); - Assert.Same(testImport, import); + Assert.Equal("testvalue", import.FilePath); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs new file mode 100644 index 0000000000..171556ecf0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs @@ -0,0 +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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineTest + { + [Fact] + public void ConvertToSourceDocument_ConvertsNormalImports() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + // Act + var sourceDocument = DefaultRazorProjectEngine.ConvertToSourceDocument(projectItem); + + // Assert + Assert.NotNull(sourceDocument); + } + + [Fact] + public void ConvertToSourceDocument_ConvertsMarkerImports() + { + // Arrange + var projectItem = Mock.Of(item => item.FilePath == "Index.cshtml" && item.Exists == false); + + // Act + var sourceDocument = DefaultRazorProjectEngine.ConvertToSourceDocument(projectItem); + + // Assert + Assert.NotNull(sourceDocument); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs index addc55ebea..af48d1e900 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs @@ -143,7 +143,7 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal("/_ViewImports.cshtml", item.FilePath); Assert.Equal("/Views", item.BasePath); Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); - Assert.Equal(Path.Combine( "_ViewImports.cshtml"), item.RelativePhysicalPath); + Assert.Equal(Path.Combine("_ViewImports.cshtml"), item.RelativePhysicalPath); }, item => { diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs index 6f4c0086cd..2b07a09545 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs @@ -533,7 +533,7 @@ namespace Microsoft.VisualStudio.Editor.Razor { RazorExtensions.Register(builder); - builder.AddDefaultImports(RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml")); + builder.AddDefaultImports(new TestRazorProjectItem("_TestImports.cshtml") { Content = "@addTagHelper *, Test" }); if (tagHelpers != null) { diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs index 529e0126e8..a35ee3c13a 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs @@ -589,7 +589,7 @@ namespace Microsoft.VisualStudio.Editor.Razor { RazorExtensions.Register(builder); - builder.AddDefaultImports(RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml")); + builder.AddDefaultImports(new TestRazorProjectItem("_TestImports.cshtml") { Content = "@addTagHelper *, Test" }); if (tagHelpers != null) { From 16bcd8871e9855f4690fba70bca1354ace661313 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 15 Feb 2018 12:08:18 -0800 Subject: [PATCH 10/56] WebSdk transitions * Add a reference to Microsoft.Net.Sdk if it wasn't previously referenced * Move PreserveCompilationContext in to our target * Remove use of transition property --- korebuild-lock.txt | 4 ++-- src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props | 7 +++++++ src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets | 2 ++ .../netstandard2.0/Sdk.Razor.CurrentVersion.props | 2 +- .../netstandard2.0/Sdk.Razor.CurrentVersion.targets | 10 +++++++++- .../IntegrationTests/BuildIntegrationTest.cs | 12 ++++++++++++ test/testapps/Directory.Build.props | 3 +++ test/testapps/RazorTest.Introspection.targets | 4 ++++ 8 files changed, 40 insertions(+), 4 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index c6125ba391..565ec4224a 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15698 -commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 +version:2.1.0-preview2-15704 +commithash:21fdd9f5254226f407a2b4b3ef963693c2fd7998 diff --git a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props index b5fb8f7017..9102f6c805 100644 --- a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props +++ b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.props @@ -10,6 +10,13 @@ Copyright (c) .NET Foundation. All rights reserved. *********************************************************************************************** --> + + + <_RazorSdkImportsMicrosoftNetSdk Condition="'$(UsingMicrosoftNETSdk)' != 'true'">true + + + + $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.props diff --git a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets index c096a5cbf4..20b70fd9ab 100644 --- a/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets +++ b/src/Microsoft.NET.Sdk.Razor/Sdk/Sdk.targets @@ -11,6 +11,8 @@ Copyright (c) .NET Foundation. All rights reserved. --> + + $(MSBuildThisFileDirectory)..\buildMultiTargeting\Sdk.Razor.CurrentVersion.MultiTargeting.targets $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props index 8bd67bc624..0d9f2603ab 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props @@ -51,7 +51,7 @@ Copyright (c) .NET Foundation. All rights reserved. false - + diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 2ea795e89b..c101bf26d2 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -57,6 +57,14 @@ Copyright (c) .NET Foundation. All rights reserved. PrepareForRazorCompile; RazorCoreCompile + + + + + + true - + PrecompilationTool diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs index 30cbfd1b86..91655ff610 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs @@ -39,6 +39,11 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // end up in the MSBuild logs. Assert.BuildOutputContainsLine(result, $"SimpleMvc -> {Path.Combine(Path.GetFullPath(Project.DirectoryPath), OutputPath, "SimpleMvc.PrecompiledViews.dll")}"); } + + result = await DotnetMSBuild("_IntrospectPreserveCompilationContext"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "PreserveCompilationContext: true"); } [Fact] @@ -54,6 +59,13 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, OutputPath, "SimpleMvc.pdb"); Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.PrecompiledViews.dll"); Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.PrecompiledViews.pdb"); + + result = await DotnetMSBuild("_IntrospectPreserveCompilationContext"); + + Assert.BuildPassed(result); + // An app with no cshtml files should not have PreserveCompilationContext. + // This expectation should get resolved once we address https://github.com/aspnet/Razor/issues/2077 + Assert.BuildOutputContainsLine(result, "PreserveCompilationContext: true"); } [Fact] diff --git a/test/testapps/Directory.Build.props b/test/testapps/Directory.Build.props index 475a18a63f..134f59524c 100644 --- a/test/testapps/Directory.Build.props +++ b/test/testapps/Directory.Build.props @@ -4,6 +4,9 @@ $(MSBuildThisFileDirectory)..\..\ $([MSBuild]::EnsureTrailingSlash('$(SolutionRoot)')) + + + <_RazorSdkPackageReferenced>true diff --git a/test/testapps/RazorTest.Introspection.targets b/test/testapps/RazorTest.Introspection.targets index c950594f49..a909d0215b 100644 --- a/test/testapps/RazorTest.Introspection.targets +++ b/test/testapps/RazorTest.Introspection.targets @@ -6,4 +6,8 @@ + + + + From 56ead8118a9a5c72816a594652b0c3c8023d216b Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 5 Feb 2018 18:03:35 -0800 Subject: [PATCH 11/56] Decouple Razor tools from MVC Adds a loader (with shadow copying in server mode) based on the Roslyn Analyzer loader design. Adds some targets to the Razor SDK that we can use to compute the configuration and extensions. Passes all of the metadata through to the command line tools so they can deal with extensions. --- .../ExtensionInitializer.cs | 15 ++ .../Properties/AssemblyInfo.cs | 5 + .../RazorExtensions.cs | 2 + .../Microsoft.AspNetCore.Mvc.Razor.props | 5 +- ...etCore.Razor.Design.CodeGeneration.targets | 6 + .../AssemblyExtension.cs | 31 +++ .../EmptyProjectFileSystem.cs | 23 ++ ...ovideRazorExtensionInitializerAttribute.cs | 31 +++ .../RazorExtensionInitializer.cs | 10 + .../RazorProjectEngine.cs | 50 +++- .../RazorProjectFileSystem.cs | 2 + .../RazorGenerate.cs | 37 +++ .../RazorTagHelper.cs | 28 ++ .../Application.cs | 8 +- .../CompilerHost.cs | 46 ++-- .../DefaultExtensionAssemblyLoader.cs | 241 ++++++++++++++++++ .../DefaultExtensionDependencyChecker.cs | 155 +++++++++++ .../DiscoverCommand.cs | 73 +++++- .../ExtensionAssemblyLoader.cs | 16 ++ .../ExtensionDependencyChecker.cs | 12 + .../GenerateCommand.cs | 83 ++++-- .../MetadataReaderExtensions.cs | 93 +++++++ .../Microsoft.AspNetCore.Razor.Tools.csproj | 2 +- .../Program.cs | 6 +- .../ShadowCopyManager.cs | 169 ++++++++++++ .../BuildServerTestFixture.cs | 3 +- .../Language/TestRazorProjectFileSystem.cs | 2 +- .../DefaultExtensionAssemblyLoaderTest.cs | 128 ++++++++++ .../DefaultExtensionDependencyCheckerTest.cs | 111 ++++++++ .../Infrastructure/ServerUtilities.cs | 3 +- .../LoaderTestResources.cs | 146 +++++++++++ ...crosoft.AspNetCore.Razor.Tools.Test.csproj | 6 + .../Properties/AssemblyInfo.cs | 6 + .../TempDirectory.cs | 30 +++ .../TestDefaultExtensionAssemblyLoader.cs | 25 ++ .../AppWithP2PReference.csproj | 5 + .../testapps/ClassLibrary/ClassLibrary.csproj | 5 + test/testapps/SimpleMvc/SimpleMvc.csproj | 5 + test/testapps/SimplePages/SimplePages.csproj | 5 + 39 files changed, 1569 insertions(+), 60 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionAssemblyLoader.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/ExtensionAssemblyLoader.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/ExtensionDependencyChecker.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/MetadataReaderExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/ShadowCopyManager.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionAssemblyLoaderTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Tools.Test/LoaderTestResources.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Tools.Test/Properties/AssemblyInfo.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Tools.Test/TempDirectory.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Tools.Test/TestDefaultExtensionAssemblyLoader.cs diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs new file mode 100644 index 0000000000..eeb3246f74 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs @@ -0,0 +1,15 @@ +// 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 Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + internal class ExtensionInitializer : RazorExtensionInitializer + { + public override void Initialize(RazorProjectEngineBuilder builder) + { + RazorExtensions.Register(builder); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs index 6be3a1f170..b5caca17dd 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs @@ -2,6 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Mvc.Razor.Extensions; +using Microsoft.AspNetCore.Razor.Language; + +[assembly: ProvideRazorExtensionInitializer("MVC-2.0", typeof(ExtensionInitializer))] +[assembly: ProvideRazorExtensionInitializer("MVC-2.1", typeof(ExtensionInitializer))] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs index c22878bd09..abf1b447f0 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs @@ -25,6 +25,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions InheritsDirective.Register(builder); SectionDirective.Register(builder); + builder.Features.Add(new ViewComponentTagHelperDescriptorProvider()); + builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension()); builder.AddTargetExtension(new TemplateTargetExtension() { diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props index 8d2ac3b630..ef8766cdf2 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props @@ -10,6 +10,9 @@ Set the primary configuration supported by this pacakge as the default configuration for Razor. --> MVC-2.1 + + + <_MvcExtensionAssemblyPath Condition="'$(_MvcExtensionAssemblyPath)'==''">$(MSBuildThisFileDirectory)..\..\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll @@ -26,7 +29,7 @@ Microsoft.AspNetCore.Mvc.Razor.Extensions - $(MSBuildThisFileDirectory)..\..\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + $(_MvcExtensionAssemblyPath) \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets index 699b4608f3..8215f37eaf 100644 --- a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets +++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets @@ -73,6 +73,9 @@ UseServer="$(UseRazorBuildServer)" ForceServer="$(_RazorForceBuildServer)" PipeName="$(_RazorBuildServerPipeName)" + Version="$(RazorLangVersion)" + Configuration="@(ResolvedRazorConfiguration)" + Extensions="@(ResolvedRazorExtension)" Assemblies="@(RazorReferencePath)" ProjectRoot="$(MSBuildProjectDirectory)" TagHelperManifest="$(_RazorTagHelperOutputCache)"> @@ -121,6 +124,9 @@ UseServer="$(UseRazorBuildServer)" ForceServer="$(_RazorForceBuildServer)" PipeName="$(_RazorBuildServerPipeName)" + Version="$(RazorLangVersion)" + Configuration="@(ResolvedRazorConfiguration)" + Extensions="@(ResolvedRazorExtension)" Sources="@(RazorGenerateWithTargetPath)" ProjectRoot="$(MSBuildProjectDirectory)" TagHelperManifest="$(_RazorTagHelperOutputCache)" /> diff --git a/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs new file mode 100644 index 0000000000..b93323e018 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.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; +using System.Reflection; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class AssemblyExtension : RazorExtension + { + public AssemblyExtension(string extensionName, Assembly assembly) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + ExtensionName = extensionName; + Assembly = assembly; + } + + public override string ExtensionName { get; } + + public Assembly Assembly { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs new file mode 100644 index 0000000000..61ced1271b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.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.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class EmptyProjectFileSystem : RazorProjectFileSystem + { + public override IEnumerable EnumerateItems(string basePath) + { + NormalizeAndEnsureValidPath(basePath); + return Enumerable.Empty(); + } + + public override RazorProjectItem GetItem(string path) + { + NormalizeAndEnsureValidPath(path); + return new NotFoundProjectItem(string.Empty, path); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs b/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs new file mode 100644 index 0000000000..374419a676 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public class ProvideRazorExtensionInitializerAttribute : Attribute + { + public ProvideRazorExtensionInitializerAttribute(string extensionName, Type initializerType) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (initializerType == null) + { + throw new ArgumentNullException(nameof(initializerType)); + } + + ExtensionName = extensionName; + InitializerType = initializerType; + } + + public string ExtensionName { get; } + + public Type InitializerType { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs new file mode 100644 index 0000000000..5117115af6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs @@ -0,0 +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. + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorExtensionInitializer + { + public abstract void Initialize(RazorProjectEngineBuilder builder); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs index 09ae61dc1f..e76bdffc94 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language.Extensions; @@ -71,9 +72,17 @@ namespace Microsoft.AspNetCore.Razor.Language var builder = new DefaultRazorProjectEngineBuilder(configuration, fileSystem); + // The intialization order is somewhat important. + // + // Defaults -> Extensions -> Additional customization + // + // This allows extensions to rely on default features, and customizations to override choices made by + // extensions. RazorEngine.AddDefaultPhases(builder.Phases); AddDefaultsFeatures(builder.Features); + LoadExtensions(builder, configuration.Extensions); + configure?.Invoke(builder); return builder.Build(); @@ -142,19 +151,38 @@ namespace Microsoft.AspNetCore.Razor.Language }); } - internal static void AddDefaultRuntimeFeatures(RazorConfiguration configuration, ICollection features) + private static void LoadExtensions(RazorProjectEngineBuilder builder, IReadOnlyList extensions) { - // Configure options - features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: configuration.LanguageVersion)); - features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); - } + for (var i = 0; i < extensions.Count; i++) + { + // For now we only handle AssemblyExtension - which is not user-constructable. We're keeping a tight + // lid on how things work until we add official support for extensibility everywhere. So, this is + // intentionally inflexible for the time being. + var extension = extensions[i] as AssemblyExtension; + if (extension == null) + { + continue; + } - internal static void AddDefaultDesignTimeFeatures(RazorConfiguration configuration, ICollection features) - { - // Configure options - features.Add(new DefaultRazorParserOptionsFeature(designTime: true, version: configuration.LanguageVersion)); - features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: true)); - features.Add(new SuppressChecksumOptionsFeature()); + // It's not an error to have an assembly with no initializers. This is useful to specify a dependency + // that doesn't really provide any Razor configuration. + var attributes = extension.Assembly.GetCustomAttributes(); + foreach (var attribute in attributes) + { + // Using extension names and requiring them to line up allows a single assembly to ship multiple + // extensions/initializers for different configurations. + if (!string.Equals(attribute.ExtensionName, extension.ExtensionName, StringComparison.Ordinal)) + { + continue; + } + + // There's no real protection/exception handling here because this set isn't really user-extensible + // right now. This would be a great place to add some additional diagnostics and hardening in the + // future. + var initializer = (RazorExtensionInitializer)Activator.CreateInstance(attribute.InitializerType); + initializer.Initialize(builder); + } + } } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs index a95de255df..799c6bda65 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs @@ -7,6 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorProjectFileSystem : RazorProject { + internal static readonly RazorProjectFileSystem Empty = new EmptyProjectFileSystem(); + /// /// Create a Razor project file system based off of a root directory. /// diff --git a/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs b/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs index 7389725f94..03cef74692 100644 --- a/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs +++ b/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs @@ -12,6 +12,18 @@ namespace Microsoft.AspNetCore.Razor.Tasks private const string GeneratedOutput = "GeneratedOutput"; private const string TargetPath = "TargetPath"; private const string FullPath = "FullPath"; + private const string Identity = "Identity"; + private const string AssemblyName = "AssemblyName"; + private const string AssemblyFilePath = "AssemblyFilePath"; + + [Required] + public string Version { get; set; } + + [Required] + public ITaskItem[] Configuration { get; set; } + + [Required] + public ITaskItem[] Extensions { get; set; } [Required] public ITaskItem[] Sources { get; set; } @@ -36,6 +48,16 @@ namespace Microsoft.AspNetCore.Razor.Tasks } } + for (var i = 0; i < Extensions.Length; i++) + { + if (!EnsureRequiredMetadata(Extensions[i], Identity) || + !EnsureRequiredMetadata(Extensions[i], AssemblyName) || + !EnsureRequiredMetadata(Extensions[i], AssemblyFilePath)) + { + return false; + } + } + return base.ValidateParameters(); } @@ -65,6 +87,21 @@ namespace Microsoft.AspNetCore.Razor.Tasks builder.AppendLine("-t"); builder.AppendLine(TagHelperManifest); + builder.AppendLine("-v"); + builder.AppendLine(Version); + + builder.AppendLine("-c"); + builder.AppendLine(Configuration[0].GetMetadata(Identity)); + + for (var i = 0; i < Extensions.Length; i++) + { + builder.AppendLine("-n"); + builder.AppendLine(Extensions[i].GetMetadata(Identity)); + + builder.AppendLine("-e"); + builder.AppendLine(Path.GetFullPath(Extensions[i].GetMetadata(AssemblyFilePath))); + } + return builder.ToString(); } diff --git a/src/Microsoft.AspNetCore.Razor.Tasks/RazorTagHelper.cs b/src/Microsoft.AspNetCore.Razor.Tasks/RazorTagHelper.cs index 4064163c34..99d523a2b7 100644 --- a/src/Microsoft.AspNetCore.Razor.Tasks/RazorTagHelper.cs +++ b/src/Microsoft.AspNetCore.Razor.Tasks/RazorTagHelper.cs @@ -10,6 +10,19 @@ namespace Microsoft.AspNetCore.Razor.Tasks { public class RazorTagHelper : DotNetToolTask { + private const string Identity = "Identity"; + private const string AssemblyName = "AssemblyName"; + private const string AssemblyFilePath = "AssemblyFilePath"; + + [Required] + public string Version { get; set; } + + [Required] + public ITaskItem[] Configuration { get; set; } + + [Required] + public ITaskItem[] Extensions { get; set; } + [Required] public string[] Assemblies { get; set; } @@ -51,6 +64,21 @@ namespace Microsoft.AspNetCore.Razor.Tasks builder.AppendLine("-p"); builder.AppendLine(ProjectRoot); + builder.AppendLine("-v"); + builder.AppendLine(Version); + + builder.AppendLine("-c"); + builder.AppendLine(Configuration[0].GetMetadata(Identity)); + + for (var i = 0; i < Extensions.Length; i++) + { + builder.AppendLine("-n"); + builder.AppendLine(Extensions[i].GetMetadata(Identity)); + + builder.AppendLine("-e"); + builder.AppendLine(Path.GetFullPath(Extensions[i].GetMetadata(AssemblyFilePath))); + } + return builder.ToString(); } } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Application.cs b/src/Microsoft.AspNetCore.Razor.Tools/Application.cs index 483ab8c64c..06da6a9ec4 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Application.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Application.cs @@ -12,9 +12,11 @@ namespace Microsoft.AspNetCore.Razor.Tools { internal class Application : CommandLineApplication { - public Application(CancellationToken cancellationToken) + public Application(CancellationToken cancellationToken, ExtensionAssemblyLoader loader, ExtensionDependencyChecker checker) { CancellationToken = cancellationToken; + Checker = checker; + Loader = loader; Name = "rzc"; FullName = "Microsoft ASP.NET Core Razor CLI tool"; @@ -31,6 +33,10 @@ namespace Microsoft.AspNetCore.Razor.Tools public CancellationToken CancellationToken { get; } + public ExtensionAssemblyLoader Loader { get; } + + public ExtensionDependencyChecker Checker { get; } + public new int Execute(params string[] args) { try diff --git a/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs b/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs index c4b96df6b2..553e9f5a87 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs @@ -19,6 +19,21 @@ namespace Microsoft.AspNetCore.Razor.Tools private class DefaultCompilerHost : CompilerHost { + public DefaultCompilerHost() + { + // The loader needs to live for the lifetime of the server. + // + // This means that if a request tries to use a set of binaries that are inconsistent with what + // the server already has, then it will be rejected to try again on the client. + // + // We also check each set of extensions for missing depenencies individually, so that we can + // consistently reject a request that doesn't specify everything it needs. Otherwise the request + // could succeed sometimes if it relies on transient state. + Loader = new DefaultExtensionAssemblyLoader(Path.Combine(Path.GetTempPath(), "Razor-Server")); + } + + public ExtensionAssemblyLoader Loader { get; } + public override ServerResponse Execute(ServerRequest request, CancellationToken cancellationToken) { if (!TryParseArguments(request, out var parsed)) @@ -28,28 +43,23 @@ namespace Microsoft.AspNetCore.Razor.Tools var exitCode = 0; var output = string.Empty; - var app = new Application(cancellationToken); var commandArgs = parsed.args.ToArray(); + var writer = ServerLogger.IsLoggingEnabled ? new StringWriter() : TextWriter.Null; + + var checker = new DefaultExtensionDependencyChecker(Loader, writer); + var app = new Application(cancellationToken, Loader, checker) + { + Out = writer, + Error = writer, + }; + + exitCode = app.Execute(commandArgs); + if (ServerLogger.IsLoggingEnabled) { - using (var writer = new StringWriter()) - { - app.Out = writer; - app.Error = writer; - exitCode = app.Execute(commandArgs); - output = writer.ToString(); - ServerLogger.Log(output); - } - } - else - { - using (var writer = new StreamWriter(Stream.Null)) - { - app.Out = writer; - app.Error = writer; - exitCode = app.Execute(commandArgs); - } + output = writer.ToString(); + ServerLogger.Log(output); } return new CompletedServerResponse(exitCode, utf8output: false, output: string.Empty); diff --git a/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionAssemblyLoader.cs b/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionAssemblyLoader.cs new file mode 100644 index 0000000000..05dc4a09eb --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionAssemblyLoader.cs @@ -0,0 +1,241 @@ +// 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.Collections.Immutable; +using System.IO; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using System.Runtime.Loader; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class DefaultExtensionAssemblyLoader : ExtensionAssemblyLoader + { + private readonly string _baseDirectory; + + private readonly object _lock = new object(); + private readonly Dictionary _loadedByPath; + private readonly Dictionary _loadedByIdentity; + private readonly Dictionary _identityCache; + private readonly Dictionary> _wellKnownAssemblies; + + private ShadowCopyManager _shadowCopyManager; + + public DefaultExtensionAssemblyLoader(string baseDirectory) + { + _baseDirectory = baseDirectory; + + _loadedByPath = new Dictionary(StringComparer.OrdinalIgnoreCase); + _loadedByIdentity = new Dictionary(); + _identityCache = new Dictionary(StringComparer.OrdinalIgnoreCase); + _wellKnownAssemblies = new Dictionary>(StringComparer.OrdinalIgnoreCase); + + LoadContext = new ExtensionAssemblyLoadContext(AssemblyLoadContext.GetLoadContext(typeof(ExtensionAssemblyLoader).Assembly), this); + } + + protected AssemblyLoadContext LoadContext { get; } + + public override void AddAssemblyLocation(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + if (!Path.IsPathRooted(filePath)) + { + throw new ArgumentException(nameof(filePath)); + } + + var assemblyName = Path.GetFileNameWithoutExtension(filePath); + lock (_lock) + { + if (!_wellKnownAssemblies.TryGetValue(assemblyName, out var paths)) + { + paths = new List(); + _wellKnownAssemblies.Add(assemblyName, paths); + } + + if (!paths.Contains(filePath)) + { + paths.Add(filePath); + } + } + } + + public override Assembly Load(string assemblyName) + { + if (!AssemblyIdentity.TryParseDisplayName(assemblyName, out var identity)) + { + return null; + } + + lock (_lock) + { + // First, check if this loader already loaded the requested assembly: + if (_loadedByIdentity.TryGetValue(identity, out var assembly)) + { + return assembly; + } + + // Second, check if an assembly file of the same simple name was registered with the loader: + if (_wellKnownAssemblies.TryGetValue(identity.Name, out var paths)) + { + // Multiple assemblies of the same simple name but different identities might have been registered. + // Load the one that matches the requested identity (if any). + foreach (var path in paths) + { + var candidateIdentity = GetIdentity(path); + + if (identity.Equals(candidateIdentity)) + { + return LoadFromPathUnsafe(path, candidateIdentity); + } + } + } + + // We only support loading by name from 'well-known' paths. If you need to load something by + // name and you get here, then that means we don't know where to look. + return null; + } + } + + public override Assembly LoadFromPath(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + if (!Path.IsPathRooted(filePath)) + { + throw new ArgumentException(nameof(filePath)); + } + + lock (_lock) + { + return LoadFromPathUnsafe(filePath, identity: null); + } + } + + private Assembly LoadFromPathUnsafe(string filePath, AssemblyIdentity identity) + { + // If we've already loaded the assembly by path there should be nothing else to do, + // all of our data is up to date. + if (_loadedByPath.TryGetValue(filePath, out var entry)) + { + return entry.assembly; + } + + // If we've already loaded the assembly by identity, then we might has some updating + // to do. + identity = identity ?? GetIdentity(filePath); + if (identity != null && _loadedByIdentity.TryGetValue(identity, out var assembly)) + { + // An assembly file might be replaced by another file with a different identity. + // Last one wins. + _loadedByPath[filePath] = (assembly, identity); + return assembly; + } + + // Ok we don't have this cached. Let's actually try to load the assembly. + assembly = LoadFromPathUnsafeCore(CopyAssembly(filePath)); + + identity = identity ?? AssemblyIdentity.FromAssemblyDefinition(assembly); + + // It's possible an assembly was loaded by two different paths. Just use the original then. + if (_loadedByIdentity.TryGetValue(identity, out var duplicate)) + { + assembly = duplicate; + } + else + { + _loadedByIdentity.Add(identity, assembly); + } + + _loadedByPath[filePath] = (assembly, identity); + return assembly; + } + + private AssemblyIdentity GetIdentity(string filePath) + { + if (!_identityCache.TryGetValue(filePath, out var identity)) + { + identity = ReadAssemblyIdentity(filePath); + _identityCache.Add(filePath, identity); + } + + return identity; + } + + protected virtual string CopyAssembly(string filePath) + { + if (_baseDirectory == null) + { + // Don't shadow-copy when base directory is null. This means we're running as a CLI not + // a server. + return filePath; + } + + if (_shadowCopyManager == null) + { + _shadowCopyManager = new ShadowCopyManager(_baseDirectory); + } + + return _shadowCopyManager.AddAssembly(filePath); + } + + protected virtual Assembly LoadFromPathUnsafeCore(string filePath) + { + return LoadContext.LoadFromAssemblyPath(filePath); + } + + private static AssemblyIdentity ReadAssemblyIdentity(string filePath) + { + try + { + using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)) + using (var reader = new PEReader(stream)) + { + var metadataReader = reader.GetMetadataReader(); + return metadataReader.GetAssemblyIdentity(); + } + } + catch + { + } + + return null; + } + + private class ExtensionAssemblyLoadContext : AssemblyLoadContext + { + private readonly AssemblyLoadContext _parent; + private readonly DefaultExtensionAssemblyLoader _loader; + + public ExtensionAssemblyLoadContext(AssemblyLoadContext parent, DefaultExtensionAssemblyLoader loader) + { + _parent = parent; + _loader = loader; + } + + protected override Assembly Load(AssemblyName assemblyName) + { + // Try to load from well-known paths. This will be called when loading a dependency of an extension. + var assembly = _loader.Load(assemblyName.ToString()); + if (assembly != null) + { + return assembly; + } + + // If we don't have an entry, then fall back to the default load context. This allows extensions + // to resolve assemblies that are provided by the host. + return _parent.LoadFromAssemblyName(assemblyName); + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs b/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs new file mode 100644 index 0000000000..f5ce49abac --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs @@ -0,0 +1,155 @@ +// 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.Reflection; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class DefaultExtensionDependencyChecker : ExtensionDependencyChecker + { + // These are treated as prefixes. So `Microsoft.CodeAnalysis.Razor` would be assumed to work. + private static readonly string[] DefaultIgnoredAssemblies = new string[] + { + "mscorlib", + "netstandard", + "System", + "Microsoft.CodeAnalysis", + "Microsoft.AspNetCore.Razor.Language", + }; + + private readonly ExtensionAssemblyLoader _loader; + private readonly TextWriter _output; + private readonly string[] _ignoredAssemblies; + + public DefaultExtensionDependencyChecker( + ExtensionAssemblyLoader loader, + TextWriter output, + string[] ignoredAssemblies = null) + { + _loader = loader; + _output = output; + _ignoredAssemblies = ignoredAssemblies ?? DefaultIgnoredAssemblies; + } + + public override bool Check(IEnumerable assmblyFilePaths) + { + try + { + return CheckCore(assmblyFilePaths); + } + catch (Exception ex) + { + _output.WriteLine("Exception performing Extension dependency check:"); + _output.WriteLine(ex.ToString()); + return false; + } + } + + private bool CheckCore(IEnumerable assemblyFilePaths) + { + var items = assemblyFilePaths.Select(a => ExtensionVerificationItem.Create(a)).ToArray(); + var assemblies = new HashSet(items.Select(i => i.Identity)); + + for (var i = 0; i < items.Length; i++) + { + var item = items[i]; + _output.WriteLine($"Verifying assembly at {item.FilePath}"); + + if (!Path.IsPathRooted(item.FilePath)) + { + _output.WriteLine($"The file path '{item.FilePath}' is not a rooted path. File paths must be absolute and fully-qualified."); + return false; + } + + foreach (var reference in item.References) + { + if (_ignoredAssemblies.Any(n => reference.Name.StartsWith(n))) + { + // This is on the allow list, keep going. + continue; + } + + if (assemblies.Contains(reference)) + { + // This was also provided as a dependency, keep going. + continue; + } + + // If we get here we can't resolve this assembly. This is an error. + _output.WriteLine($"Extension assembly '{item.Identity.Name}' depends on '{reference.ToString()} which is missing."); + return false; + } + } + + // Assuming we get this far, the set of assemblies we have is at least a coherent set (barring + // version conflicts). Register all of the paths with the loader so they can find each other by + // name. + for (var i = 0; i < items.Length; i++) + { + _loader.AddAssemblyLocation(items[i].FilePath); + } + + // Now try to load everything. This has the side effect of resolving all of these items + // in the loader's caches. + for (var i = 0; i < items.Length; i++) + { + var item = items[i]; + item.Assembly = _loader.LoadFromPath(item.FilePath); + } + + // Third, check that the MVIDs of the files on disk match the MVIDs of the loaded assemblies. + for (var i = 0; i < items.Length; i++) + { + var item = items[i]; + if (item.Mvid != item.Assembly.ManifestModule.ModuleVersionId) + { + _output.WriteLine($"Extension assembly '{item.Identity.Name}' at '{item.FilePath}' has a different ModuleVersionId than loaded assembly '{item.Assembly.FullName}'"); + return false; + } + } + + return true; + } + + private class ExtensionVerificationItem + { + public static ExtensionVerificationItem Create(string filePath) + { + using (var peReader = new PEReader(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))) + { + var metadataReader = peReader.GetMetadataReader(); + var identity = metadataReader.GetAssemblyIdentity(); + var mvid = metadataReader.GetGuid(metadataReader.GetModuleDefinition().Mvid); + var references = metadataReader.GetReferencedAssembliesOrThrow(); + + return new ExtensionVerificationItem(filePath, identity, mvid, references.ToArray()); + } + } + + private ExtensionVerificationItem(string filePath, AssemblyIdentity identity, Guid mvid, AssemblyIdentity[] references) + { + FilePath = filePath; + Identity = identity; + Mvid = mvid; + References = references; + } + + public string FilePath { get; } + + public Assembly Assembly { get; set; } + + public AssemblyIdentity Identity { get; } + + public Guid Mvid { get; } + + public IReadOnlyList References { get; } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs index 2b3cee612e..9ca5b3d8bb 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Razor.Extensions; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; @@ -26,6 +25,10 @@ namespace Microsoft.AspNetCore.Razor.Tools Assemblies = Argument("assemblies", "assemblies to search for tag helpers", multipleValues: true); TagHelperManifest = Option("-o", "output file", CommandOptionType.SingleValue); ProjectDirectory = Option("-p", "project root directory", CommandOptionType.SingleValue); + Version = Option("-v|--version", "Razor language version", CommandOptionType.SingleValue); + Configuration = Option("-c", "Razor configuration name", CommandOptionType.SingleValue); + ExtensionNames = Option("-n", "extension name", CommandOptionType.MultipleValue); + ExtensionFilePaths = Option("-e", "extension file path", CommandOptionType.MultipleValue); } public CommandArgument Assemblies { get; } @@ -34,6 +37,14 @@ namespace Microsoft.AspNetCore.Razor.Tools public CommandOption ProjectDirectory { get; } + public CommandOption Version { get; } + + public CommandOption Configuration { get; } + + public CommandOption ExtensionNames { get; } + + public CommandOption ExtensionFilePaths { get; } + protected override bool ValidateArguments() { if (string.IsNullOrEmpty(TagHelperManifest.Value())) @@ -53,12 +64,61 @@ namespace Microsoft.AspNetCore.Razor.Tools ProjectDirectory.Values.Add(Environment.CurrentDirectory); } + if (string.IsNullOrEmpty(Version.Value())) + { + Error.WriteLine($"{Version.ValueName} must be specified."); + return false; + } + else if (!RazorLanguageVersion.TryParse(Version.Value(), out _)) + { + Error.WriteLine($"{Version.ValueName} is not a valid language version."); + return false; + } + + if (string.IsNullOrEmpty(Configuration.Value())) + { + Error.WriteLine($"{Configuration.ValueName} must be specified."); + return false; + } + + if (ExtensionNames.Values.Count != ExtensionFilePaths.Values.Count) + { + Error.WriteLine($"{ExtensionNames.ValueName} and {ExtensionFilePaths.ValueName} should have the same number of values."); + } + + foreach (var filePath in ExtensionFilePaths.Values) + { + if (!Path.IsPathRooted(filePath)) + { + Error.WriteLine($"Extension file paths must be fully-qualified, absolute paths."); + return false; + } + } + + if (!Parent.Checker.Check(ExtensionFilePaths.Values)) + { + Error.WriteLine($"Extenions could not be loaded. See output for details."); + return false; + } + return true; } protected override Task ExecuteCoreAsync() { + // Loading all of the extensions should succeed as the dependency checker will have already + // loaded them. + var extensions = new RazorExtension[ExtensionNames.Values.Count]; + for (var i = 0; i < ExtensionNames.Values.Count; i++) + { + extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); + } + + var version = RazorLanguageVersion.Parse(Version.Value()); + var configuration = new RazorConfiguration(version, Configuration.Value(), extensions); + var result = ExecuteCore( + configuration: configuration, projectDirectory: ProjectDirectory.Value(), outputFilePath: TagHelperManifest.Value(), assemblies: Assemblies.Values.ToArray()); @@ -66,7 +126,7 @@ namespace Microsoft.AspNetCore.Razor.Tools return Task.FromResult(result); } - private int ExecuteCore(string projectDirectory, string outputFilePath, string[] assemblies) + private int ExecuteCore(RazorConfiguration configuration, string projectDirectory, string outputFilePath, string[] assemblies) { outputFilePath = Path.Combine(projectDirectory, outputFilePath); @@ -76,19 +136,14 @@ namespace Microsoft.AspNetCore.Razor.Tools metadataReferences[i] = MetadataReference.CreateFromFile(assemblies[i]); } - var engine = RazorEngine.Create((b) => + var engine = RazorProjectEngine.Create(configuration, RazorProjectFileSystem.Empty, b => { - RazorExtensions.Register(b); - b.Features.Add(new DefaultMetadataReferenceFeature() { References = metadataReferences }); b.Features.Add(new CompilationTagHelperFeature()); - - // TagHelperDescriptorProviders (actually do tag helper discovery) b.Features.Add(new DefaultTagHelperDescriptorProvider()); - b.Features.Add(new ViewComponentTagHelperDescriptorProvider()); }); - var feature = engine.Features.OfType().Single(); + var feature = engine.Engine.Features.OfType().Single(); var tagHelpers = feature.GetDescriptors(); using (var stream = new MemoryStream()) diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ExtensionAssemblyLoader.cs b/src/Microsoft.AspNetCore.Razor.Tools/ExtensionAssemblyLoader.cs new file mode 100644 index 0000000000..071eec2f82 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/ExtensionAssemblyLoader.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.Reflection; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal abstract class ExtensionAssemblyLoader + { + public abstract void AddAssemblyLocation(string filePath); + + public abstract Assembly Load(string assemblyName); + + public abstract Assembly LoadFromPath(string filePath); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ExtensionDependencyChecker.cs b/src/Microsoft.AspNetCore.Razor.Tools/ExtensionDependencyChecker.cs new file mode 100644 index 0000000000..02fd86d9e8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/ExtensionDependencyChecker.cs @@ -0,0 +1,12 @@ +// 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.Tools +{ + internal abstract class ExtensionDependencyChecker + { + public abstract bool Check(IEnumerable extensionFilePaths); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/GenerateCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/GenerateCommand.cs index 0981cc1a03..d19c566b76 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/GenerateCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/GenerateCommand.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Razor.Extensions; using Microsoft.AspNetCore.Razor.Language; using Microsoft.Extensions.CommandLineUtils; using Microsoft.VisualStudio.LanguageServices.Razor; @@ -14,13 +13,6 @@ using Newtonsoft.Json; namespace Microsoft.AspNetCore.Razor.Tools { - internal class Builder - { - public static Builder Make(CommandBase result) => null; - - public static Builder Make(T result) => null; - } - internal class GenerateCommand : CommandBase { public GenerateCommand(Application parent) @@ -31,6 +23,10 @@ namespace Microsoft.AspNetCore.Razor.Tools RelativePaths = Option("-r", "Relative path", CommandOptionType.MultipleValue); ProjectDirectory = Option("-p", "project root directory", CommandOptionType.SingleValue); TagHelperManifest = Option("-t", "tag helper manifest file", CommandOptionType.SingleValue); + Version = Option("-v|--version", "Razor language version", CommandOptionType.SingleValue); + Configuration = Option("-c", "Razor configuration name", CommandOptionType.SingleValue); + ExtensionNames = Option("-n", "extension name", CommandOptionType.MultipleValue); + ExtensionFilePaths = Option("-e", "extension file path", CommandOptionType.MultipleValue); } public CommandOption Sources { get; } @@ -43,9 +39,29 @@ namespace Microsoft.AspNetCore.Razor.Tools public CommandOption TagHelperManifest { get; } + public CommandOption Version { get; } + + public CommandOption Configuration { get; } + + public CommandOption ExtensionNames { get; } + + public CommandOption ExtensionFilePaths { get; } + protected override Task ExecuteCoreAsync() { + // Loading all of the extensions should succeed as the dependency checker will have already + // loaded them. + var extensions = new RazorExtension[ExtensionNames.Values.Count]; + for (var i = 0; i < ExtensionNames.Values.Count; i++) + { + extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); + } + + var version = RazorLanguageVersion.Parse(Version.Value()); + var configuration = new RazorConfiguration(version, Configuration.Value(), extensions); + var result = ExecuteCore( + configuration: configuration, projectDirectory: ProjectDirectory.Value(), tagHelperManifest: TagHelperManifest.Value(), sources: Sources.Values, @@ -78,10 +94,48 @@ namespace Microsoft.AspNetCore.Razor.Tools ProjectDirectory.Values.Add(Environment.CurrentDirectory); } + if (string.IsNullOrEmpty(Version.Value())) + { + Error.WriteLine($"{Version.ValueName} must be specified."); + return false; + } + else if (!RazorLanguageVersion.TryParse(Version.Value(), out _)) + { + Error.WriteLine($"{Version.ValueName} is not a valid language version."); + return false; + } + + if (string.IsNullOrEmpty(Configuration.Value())) + { + Error.WriteLine($"{Configuration.ValueName} must be specified."); + return false; + } + + if (ExtensionNames.Values.Count != ExtensionFilePaths.Values.Count) + { + Error.WriteLine($"{ExtensionNames.ValueName} and {ExtensionFilePaths.ValueName} should have the same number of values."); + } + + foreach (var filePath in ExtensionFilePaths.Values) + { + if (!Path.IsPathRooted(filePath)) + { + Error.WriteLine($"Extension file paths must be fully-qualified, absolute paths."); + return false; + } + } + + if (!Parent.Checker.Check(ExtensionFilePaths.Values)) + { + Error.WriteLine($"Extensions could not be loaded. See output for details."); + return false; + } + return true; } private int ExecuteCore( + RazorConfiguration configuration, string projectDirectory, string tagHelperManifest, List sources, @@ -97,14 +151,13 @@ namespace Microsoft.AspNetCore.Razor.Tools GetVirtualRazorProjectSystem(inputItems), RazorProjectFileSystem.Create(projectDirectory), }); - var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, compositeFileSystem, b => + + var engine = RazorProjectEngine.Create(configuration, compositeFileSystem, b => { - RazorExtensions.Register(b); - b.Features.Add(new StaticTagHelperFeature() { TagHelpers = tagHelpers, }); }); - var results = GenerateCode(projectEngine, inputItems); + var results = GenerateCode(engine, inputItems); var success = true; @@ -175,14 +228,14 @@ namespace Microsoft.AspNetCore.Razor.Tools return items; } - private OutputItem[] GenerateCode(RazorProjectEngine projectEngine, SourceItem[] inputs) + private OutputItem[] GenerateCode(RazorProjectEngine engine, SourceItem[] inputs) { var outputs = new OutputItem[inputs.Length]; Parallel.For(0, outputs.Length, new ParallelOptions() { MaxDegreeOfParallelism = Debugger.IsAttached ? 1 : 4 }, i => { var inputItem = inputs[i]; - var projectItem = projectEngine.FileSystem.GetItem(inputItem.FilePath); - var codeDocument = projectEngine.Process(projectItem); + + var codeDocument = engine.Process(engine.FileSystem.GetItem(inputItem.FilePath)); var csharpDocument = codeDocument.GetCSharpDocument(); outputs[i] = new OutputItem(inputItem, csharpDocument); }); diff --git a/src/Microsoft.AspNetCore.Razor.Tools/MetadataReaderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Tools/MetadataReaderExtensions.cs new file mode 100644 index 0000000000..da1bddb865 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/MetadataReaderExtensions.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft. 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.Collections.Immutable; +using System.Reflection; +using System.Reflection.Metadata; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class MetadataReaderExtensions + { + internal static AssemblyIdentity GetAssemblyIdentity(this MetadataReader reader) + { + if (!reader.IsAssembly) + { + throw new BadImageFormatException(); + } + + var definition = reader.GetAssemblyDefinition(); + + return CreateAssemblyIdentity( + reader, + definition.Version, + definition.Flags, + definition.PublicKey, + definition.Name, + definition.Culture, + isReference: false); + } + + internal static AssemblyIdentity[] GetReferencedAssembliesOrThrow(this MetadataReader reader) + { + var references = new List(); + + foreach (var referenceHandle in reader.AssemblyReferences) + { + var reference = reader.GetAssemblyReference(referenceHandle); + references.Add(CreateAssemblyIdentity( + reader, + reference.Version, + reference.Flags, + reference.PublicKeyOrToken, + reference.Name, + reference.Culture, + isReference: true)); + } + + return references.ToArray(); + } + + private static AssemblyIdentity CreateAssemblyIdentity( + MetadataReader reader, + Version version, + AssemblyFlags flags, + BlobHandle publicKey, + StringHandle name, + StringHandle culture, + bool isReference) + { + var publicKeyOrToken = reader.GetBlobContent(publicKey); + bool hasPublicKey; + + if (isReference) + { + hasPublicKey = (flags & AssemblyFlags.PublicKey) != 0; + } + else + { + // Assembly definitions never contain a public key token, they only can have a full key or nothing, + // so the flag AssemblyFlags.PublicKey does not make sense for them and is ignored. + // See Ecma-335, Partition II Metadata, 22.2 "Assembly : 0x20". + // This also corresponds to the behavior of the native C# compiler and sn.exe tool. + hasPublicKey = !publicKeyOrToken.IsEmpty; + } + + if (publicKeyOrToken.IsEmpty) + { + publicKeyOrToken = default; + } + + return new AssemblyIdentity( + name: reader.GetString(name), + version: version, + cultureName: culture.IsNil ? null : reader.GetString(culture), + publicKeyOrToken: publicKeyOrToken, + hasPublicKey: hasPublicKey, + isRetargetable: (flags & AssemblyFlags.Retargetable) != 0, + contentType: (AssemblyContentType)((int)(flags & AssemblyFlags.ContentTypeMask) >> 9)); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Microsoft.AspNetCore.Razor.Tools.csproj b/src/Microsoft.AspNetCore.Razor.Tools/Microsoft.AspNetCore.Razor.Tools.csproj index fe2b7c52b9..6aae7e8d50 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Microsoft.AspNetCore.Razor.Tools.csproj +++ b/src/Microsoft.AspNetCore.Razor.Tools/Microsoft.AspNetCore.Razor.Tools.csproj @@ -27,7 +27,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs index 8a23dd91b9..0b3b980c3a 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs @@ -15,7 +15,11 @@ namespace Microsoft.AspNetCore.Razor.Tools var cancel = new CancellationTokenSource(); Console.CancelKeyPress += (sender, e) => { cancel.Cancel(); }; - var application = new Application(cancel.Token); + // Prevent shadow copying. + var loader = new DefaultExtensionAssemblyLoader(baseDirectory: null); + var checker = new DefaultExtensionDependencyChecker(loader, Console.Error); + + var application = new Application(cancel.Token, loader, checker); return application.Execute(args); } } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ShadowCopyManager.cs b/src/Microsoft.AspNetCore.Razor.Tools/ShadowCopyManager.cs new file mode 100644 index 0000000000..317dc5bd74 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/ShadowCopyManager.cs @@ -0,0 +1,169 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + // Note that this class has no thread-safety guarantees. The caller should use a lock + // if concurrency is required. + internal class ShadowCopyManager : IDisposable + { + // Note that this class uses the *existance* of the Mutex to lock a directory. + // + // Nothing in this code actually ever acquires the Mutex, we just try to see if it exists + // already. + private readonly Mutex _mutex; + + private int _counter; + + public ShadowCopyManager(string baseDirectory = null) + { + BaseDirectory = baseDirectory ?? Path.Combine(Path.GetTempPath(), "Razor", "ShadowCopy"); + + var guid = Guid.NewGuid().ToString("N").ToLowerInvariant(); + UniqueDirectory = Path.Combine(BaseDirectory, guid); + + _mutex = new Mutex(initiallyOwned: false, name: guid); + + Directory.CreateDirectory(UniqueDirectory); + } + + public string BaseDirectory { get; } + + public string UniqueDirectory { get; } + + public string AddAssembly(string filePath) + { + var assemblyDirectory = CreateUniqueDirectory(); + + var destination = Path.Combine(assemblyDirectory, Path.GetFileName(filePath)); + CopyFile(filePath, destination); + + var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath); + var resourcesNameWithoutExtension = fileNameWithoutExtension + ".resources"; + var resourcesNameWithExtension = resourcesNameWithoutExtension + ".dll"; + + foreach (var directory in Directory.EnumerateDirectories(Path.GetDirectoryName(filePath))) + { + var directoryName = Path.GetFileName(directory); + + var resourcesPath = Path.Combine(directory, resourcesNameWithExtension); + if (File.Exists(resourcesPath)) + { + var resourcesShadowCopyPath = Path.Combine(assemblyDirectory, directoryName, resourcesNameWithExtension); + CopyFile(resourcesPath, resourcesShadowCopyPath); + } + + resourcesPath = Path.Combine(directory, resourcesNameWithoutExtension, resourcesNameWithExtension); + if (File.Exists(resourcesPath)) + { + var resourcesShadowCopyPath = Path.Combine(assemblyDirectory, directoryName, resourcesNameWithoutExtension, resourcesNameWithExtension); + CopyFile(resourcesPath, resourcesShadowCopyPath); + } + } + + return destination; + } + + public void Dispose() + { + _mutex.ReleaseMutex(); + } + + public Task PurgeUnusedDirectoriesAsync() + { + return Task.Run((Action)PurgeUnusedDirectories); + } + + private string CreateUniqueDirectory() + { + var id = _counter++; + + var directory = Path.Combine(UniqueDirectory, id.ToString()); + Directory.CreateDirectory(directory); + return directory; + } + + private void CopyFile(string originalPath, string shadowCopyPath) + { + var directory = Path.GetDirectoryName(shadowCopyPath); + Directory.CreateDirectory(directory); + + File.Copy(originalPath, shadowCopyPath); + + MakeWritable(new FileInfo(shadowCopyPath)); + } + + private void MakeWritable(string directoryPath) + { + var directory = new DirectoryInfo(directoryPath); + + foreach (var file in directory.EnumerateFiles(searchPattern: "*", searchOption: SearchOption.AllDirectories)) + { + MakeWritable(file); + } + } + + private void MakeWritable(FileInfo file) + { + try + { + if (file.IsReadOnly) + { + file.IsReadOnly = false; + } + } + catch + { + // There are many reasons this could fail. Ignore it and keep going. + } + } + + private void PurgeUnusedDirectories() + { + IEnumerable directories; + try + { + directories = Directory.EnumerateDirectories(BaseDirectory); + } + catch (DirectoryNotFoundException) + { + return; + } + + foreach (var directory in directories) + { + Mutex mutex = null; + try + { + // We only want to try deleting the directory if no-one else is currently using it. + // + // Note that the mutex name is the name of the directory. This is OK because we're using + // GUIDs as directory/mutex names. + if (!Mutex.TryOpenExisting(Path.GetFileName(directory).ToLowerInvariant(), out mutex)) + { + MakeWritable(directory); + Directory.Delete(directory, recursive: true); + } + } + catch + { + // If something goes wrong we will leave it to the next run to clean up. + // Just swallow the exception and move on. + } + finally + { + if (mutex != null) + { + mutex.Dispose(); + } + } + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs index f63de011a4..d2d0aa98e5 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs @@ -5,6 +5,7 @@ using System; using System.IO; using System.Threading; using Microsoft.AspNetCore.Razor.Tools; +using Moq; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { @@ -34,7 +35,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected."); }); - var application = new Application(cts.Token); + var application = new Application(cts.Token, Mock.Of(), Mock.Of()); var exitCode = application.Execute("shutdown", "-w", "-p", PipeName); if (exitCode != 0) { diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs index 39ff443eb5..f16fff0274 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class TestRazorProjectFileSystem : DefaultRazorProjectFileSystem { - public static RazorProjectFileSystem Empty = new TestRazorProjectFileSystem(); + public new static RazorProjectFileSystem Empty = new TestRazorProjectFileSystem(); private readonly Dictionary _lookup; diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionAssemblyLoaderTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionAssemblyLoaderTest.cs new file mode 100644 index 0000000000..ad619e5570 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionAssemblyLoaderTest.cs @@ -0,0 +1,128 @@ +// 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.Text; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class DefaultExtensionAssemblyLoaderTest + { + [Fact] + public void LoadFromPath_CanLoadAssembly() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + + // Act + var assembly = loader.LoadFromPath(alphaFilePath); + + // Assert + Assert.NotNull(assembly); + } + } + + [Fact] + public void LoadFromPath_DoesNotAddDuplicates_AfterLoadingByName() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var alphaFilePath2 = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha2.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + loader.AddAssemblyLocation(alphaFilePath); + + var assembly1 = loader.Load("Alpha"); + + // Act + var assembly2 = loader.LoadFromPath(alphaFilePath2); + + // Assert + Assert.Same(assembly1, assembly2); + } + } + + [Fact] + public void LoadFromPath_DoesNotAddDuplicates_AfterLoadingByPath() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var alphaFilePath2 = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha2.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var assembly1 = loader.LoadFromPath(alphaFilePath); + + // Act + var assembly2 = loader.LoadFromPath(alphaFilePath2); + + // Assert + Assert.Same(assembly1, assembly2); + } + } + + [Fact] + public void Load_CanLoadAssemblyByName_AfterLoadingByPath() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var assembly1 = loader.LoadFromPath(alphaFilePath); + + // Act + var assembly2 = loader.Load(assembly1.FullName); + + // Assert + Assert.Same(assembly1, assembly2); + } + } + + [Fact] + public void LoadFromPath_WithDependencyPathsSpecified_CanLoadAssemblyDependencies() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var betaFilePath = LoaderTestResources.Beta.WriteToFile(directory.DirectoryPath, "Beta.dll"); + var gammaFilePath = LoaderTestResources.Gamma.WriteToFile(directory.DirectoryPath, "Gamma.dll"); + var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + loader.AddAssemblyLocation(gammaFilePath); + loader.AddAssemblyLocation(deltaFilePath); + + // Act + var alpha = loader.LoadFromPath(alphaFilePath); + var beta = loader.LoadFromPath(betaFilePath); + + // Assert + var builder = new StringBuilder(); + + var a = alpha.CreateInstance("Alpha.A"); + a.GetType().GetMethod("Write").Invoke(a, new object[] { builder, "Test A" }); + + var b = beta.CreateInstance("Beta.B"); + b.GetType().GetMethod("Write").Invoke(b, new object[] { builder, "Test B" }); + var expected = @"Delta: Gamma: Alpha: Test A +Delta: Gamma: Beta: Test B +"; + + var actual = builder.ToString(); + + Assert.Equal(expected, actual); + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs new file mode 100644 index 0000000000..72d719fdc8 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs @@ -0,0 +1,111 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class DefaultExtensionDependencyCheckerTest + { + [Fact] + public void Check_ReturnsFalse_WithMissingDependency() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var output = new StringWriter(); + + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var checker = new DefaultExtensionDependencyChecker(loader, output); + + // Act + var result = checker.Check(new[] { alphaFilePath, }); + + // Assert + Assert.False(result, "Check should not have passed: " + output.ToString()); + } + } + + [Fact] + public void Check_ReturnsTrue_WithAllDependenciesProvided() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var output = new StringWriter(); + + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var betaFilePath = LoaderTestResources.Beta.WriteToFile(directory.DirectoryPath, "Beta.dll"); + var gammaFilePath = LoaderTestResources.Gamma.WriteToFile(directory.DirectoryPath, "Gamma.dll"); + var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var checker = new DefaultExtensionDependencyChecker(loader, output); + + // Act + var result = checker.Check(new[] { alphaFilePath, betaFilePath, gammaFilePath, deltaFilePath, }); + + // Assert + Assert.True(result, "Check should have passed: " + output.ToString()); + } + } + + [Fact] + public void Check_ReturnsFalse_WhenAssemblyHasDifferentMVID() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var output = new StringWriter(); + + // Load Beta.dll from the future Alpha.dll path to prime the assembly loader + var alphaFilePath = LoaderTestResources.Beta.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var betaFilePath = LoaderTestResources.Beta.WriteToFile(directory.DirectoryPath, "Beta.dll"); + var gammaFilePath = LoaderTestResources.Gamma.WriteToFile(directory.DirectoryPath, "Gamma.dll"); + var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var checker = new DefaultExtensionDependencyChecker(loader, output); + + // This will cause the loader to cache some inconsistent information. + loader.LoadFromPath(alphaFilePath); + LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + + // Act + var result = checker.Check(new[] { alphaFilePath, gammaFilePath, deltaFilePath, }); + + // Assert + Assert.False(result, "Check should not have passed: " + output.ToString()); + } + } + + [Fact] + public void Check_ReturnsFalse_WhenLoaderThrows() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var output = new StringWriter(); + + var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + var loader = new Mock(); + loader + .Setup(l => l.LoadFromPath(It.IsAny())) + .Throws(new InvalidOperationException()); + var checker = new DefaultExtensionDependencyChecker(loader.Object, output); + + // Act + var result = checker.Check(new[] { deltaFilePath, }); + + // Assert + Assert.False(result, "Check should not have passed: " + output.ToString()); + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs index 473b608142..b91723c9d0 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; +using Moq; namespace Microsoft.AspNetCore.Razor.Tools { @@ -116,7 +117,7 @@ namespace Microsoft.AspNetCore.Razor.Tools CancellationToken ct, EventBus eventBus, TimeSpan? keepAlive) - : base(new Application(ct)) + : base(new Application(ct, Mock.Of(), Mock.Of())) { _host = host; _compilerHost = compilerHost; diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/LoaderTestResources.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/LoaderTestResources.cs new file mode 100644 index 0000000000..9478c46684 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/LoaderTestResources.cs @@ -0,0 +1,146 @@ +// 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 Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class LoaderTestResources + { + static LoaderTestResources() + { + Delta = CreateAssemblyBlob("Delta", Array.Empty(), @" +using System.Text; + +namespace Delta +{ + public class D + { + public void Write(StringBuilder sb, string s) + { + sb.AppendLine(""Delta: "" + s); + } + } +} +"); + + Gamma = CreateAssemblyBlob("Gamma", new[] { Delta, }, @" +using System.Text; +using Delta; + +namespace Gamma +{ + public class G + { + public void Write(StringBuilder sb, string s) + { + D d = new D(); + + d.Write(sb, ""Gamma: "" + s); + } + } +} +"); + + Alpha = CreateAssemblyBlob("Alpha", new[] { Gamma, }, @" +using System.Text; +using Gamma; + +namespace Alpha +{ + public class A + { + public void Write(StringBuilder sb, string s) + { + G g = new G(); + + g.Write(sb, ""Alpha: "" + s); + } + } +} +"); + + Beta = CreateAssemblyBlob("Beta", new[] { Gamma, }, @" +using System.Text; +using Gamma; + +namespace Beta +{ + public class B + { + public void Write(StringBuilder sb, string s) + { + G g = new G(); + + g.Write(sb, ""Beta: "" + s); + } + } +} +"); + } + + public static AssemblyBlob Alpha { get; } + + public static AssemblyBlob Beta { get; } + + public static AssemblyBlob Delta { get; } + + public static AssemblyBlob Gamma { get; } + + private static AssemblyBlob CreateAssemblyBlob(string assemblyName, AssemblyBlob[] references, string text) + { + var defaultReferences = new[] + { + MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + }; + + var compilation = CSharpCompilation.Create( + assemblyName, + new[] { CSharpSyntaxTree.ParseText(text) }, + references.Select(r => r.ToMetadataReference()).Concat(defaultReferences), + new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + + using (var assemblyStream = new MemoryStream()) + using (var symbolStream = new MemoryStream()) + { + var result = compilation.Emit(assemblyStream, symbolStream); + Assert.Empty(result.Diagnostics); + + return new AssemblyBlob(assemblyName, assemblyStream.GetBuffer(), symbolStream.GetBuffer()); + } + } + + public class AssemblyBlob + { + public AssemblyBlob(string assemblyName, byte[] assemblyBytes, byte[] symbolBytes) + { + AssemblyName = assemblyName; + AssemblyBytes = assemblyBytes; + SymbolBytes = symbolBytes; + } + + public string AssemblyName { get; } + + public byte[] AssemblyBytes { get; } + + public byte[] SymbolBytes { get; } + + public MetadataReference ToMetadataReference() + { + return MetadataReference.CreateFromImage(AssemblyBytes); + } + + internal string WriteToFile(string directoryPath, string fileName) + { + var filePath = Path.Combine(directoryPath, fileName); + File.WriteAllBytes(filePath, AssemblyBytes); + return filePath; + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/Microsoft.AspNetCore.Razor.Tools.Test.csproj b/test/Microsoft.AspNetCore.Razor.Tools.Test/Microsoft.AspNetCore.Razor.Tools.Test.csproj index 3778c1c8ca..df0bf3822a 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/Microsoft.AspNetCore.Razor.Tools.Test.csproj +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/Microsoft.AspNetCore.Razor.Tools.Test.csproj @@ -17,4 +17,10 @@ + + + System + + + diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f0aa552b16 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/Properties/AssemblyInfo.cs @@ -0,0 +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.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/TempDirectory.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/TempDirectory.cs new file mode 100644 index 0000000000..d491248465 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/TempDirectory.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; +using System.IO; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class TempDirectory : IDisposable + { + public static TempDirectory Create() + { + var directoryPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("n")); + Directory.CreateDirectory(directoryPath); + return new TempDirectory(directoryPath); + } + + private TempDirectory(string directoryPath) + { + DirectoryPath = directoryPath; + } + + public string DirectoryPath { get; } + + public void Dispose() + { + Directory.Delete(DirectoryPath, recursive: true); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/TestDefaultExtensionAssemblyLoader.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/TestDefaultExtensionAssemblyLoader.cs new file mode 100644 index 0000000000..d272e1c005 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/TestDefaultExtensionAssemblyLoader.cs @@ -0,0 +1,25 @@ +// 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.Reflection; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class TestDefaultExtensionAssemblyLoader : DefaultExtensionAssemblyLoader + { + public TestDefaultExtensionAssemblyLoader(string baseDirectory) + : base(baseDirectory) + { + } + + protected override Assembly LoadFromPathUnsafeCore(string filePath) + { + // Force a load from streams so we don't lock the files on disk. This way we can test + // shadow copying without leaving a mess behind. + var bytes = File.ReadAllBytes(filePath); + var stream = new MemoryStream(bytes); + return LoadContext.LoadFromStream(stream); + } + } +} diff --git a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj index fe9d5d2940..6688f30d79 100644 --- a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj +++ b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj @@ -7,6 +7,11 @@ + + + + <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj index 443d790efa..1aa8072b38 100644 --- a/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -8,6 +8,11 @@ + + + + <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + diff --git a/test/testapps/SimpleMvc/SimpleMvc.csproj b/test/testapps/SimpleMvc/SimpleMvc.csproj index 31c006b2f3..4e20c9b1c8 100644 --- a/test/testapps/SimpleMvc/SimpleMvc.csproj +++ b/test/testapps/SimpleMvc/SimpleMvc.csproj @@ -8,6 +8,11 @@ + + + + <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + diff --git a/test/testapps/SimplePages/SimplePages.csproj b/test/testapps/SimplePages/SimplePages.csproj index 340a6f14db..654b8f63dc 100644 --- a/test/testapps/SimplePages/SimplePages.csproj +++ b/test/testapps/SimplePages/SimplePages.csproj @@ -8,6 +8,11 @@ + + + + <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + From c2932674216e0dd72b60991fa303fbfd8867d3b1 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 14 Feb 2018 18:52:41 -0800 Subject: [PATCH 13/56] Fixed unnecessary invocation of TagHelper target --- ...etCore.Razor.Design.CodeGeneration.targets | 10 ++-- .../BuildIncrementalismTest.cs | 60 +++++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets index 8215f37eaf..1eb7d2baad 100644 --- a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets +++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets @@ -60,11 +60,11 @@ --> - - + AlwaysCreate="true" /> + + + + (); + + // Act 1 + var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + + var directoryPath = Path.Combine(result.Project.DirectoryPath, IntermediateOutputPath); + var filesToIgnore = new[] + { + // These files are generated on every build. + Path.Combine(directoryPath, "SimpleMvc.csproj.CopyComplete"), + Path.Combine(directoryPath, "SimpleMvc.csproj.FileListAbsolute.txt"), + }; + var files = Directory.GetFiles(directoryPath).Where(p => !filesToIgnore.Contains(p)); + foreach (var file in files) + { + var thumbprint = GetThumbPrint(file); + thumbprintLookup[file] = thumbprint; + } + + // Assert 1 + Assert.BuildPassed(result); + + // Act & Assert 2 + for (var i = 0; i < 2; i++) + { + // We want to make sure nothing changed between multiple incremental builds. + using (var razorGenDirectoryLock = LockDirectory(RazorIntermediateOutputPath)) + { + result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + } + + Assert.BuildPassed(result); + foreach (var file in files) + { + var thumbprint = GetThumbPrint(file); + Assert.Equal(thumbprintLookup[file], thumbprint); + } + } + } + } +} From 9ec207399d021de013352416b1f820d9604e08c6 Mon Sep 17 00:00:00 2001 From: Rustam Agametov Date: Fri, 9 Feb 2018 19:42:36 +0300 Subject: [PATCH 14/56] bug fix: unused parameter in the constructor --- .../CodeGeneration/CodeWriterExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CodeWriterExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CodeWriterExtensions.cs index 7d8c846ca2..e6a749b269 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CodeWriterExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CodeWriterExtensions.cs @@ -540,7 +540,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public CSharpCodeWritingScope(CodeWriter writer, int tabSize = 4, bool autoSpace = true) { _writer = writer; - _autoSpace = true; + _autoSpace = autoSpace; _tabSize = tabSize; _startIndent = -1; // Set in WriteStartScope From 45148142eacb591151a9e9fb814a17470f865a1e Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 16 Feb 2018 09:43:33 -0800 Subject: [PATCH 15/56] Fix broken build --- ...icrosoft.AspNetCore.Mvc.Razor.Extensions.props} | 0 ...rosoft.AspNetCore.Mvc.Razor.Extensions.targets} | 0 .../RazorGenerate.cs | 14 ++++++++++++++ .../AppWithP2PReference/AppWithP2PReference.csproj | 4 ++-- test/testapps/ClassLibrary/ClassLibrary.csproj | 4 ++-- test/testapps/SimpleMvc/SimpleMvc.csproj | 4 ++-- test/testapps/SimplePages/SimplePages.csproj | 4 ++-- 7 files changed, 22 insertions(+), 8 deletions(-) rename src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/{Microsoft.AspNetCore.Mvc.Razor.props => Microsoft.AspNetCore.Mvc.Razor.Extensions.props} (100%) rename src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/{Microsoft.AspNetCore.Mvc.Razor.targets => Microsoft.AspNetCore.Mvc.Razor.Extensions.targets} (100%) diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.props similarity index 100% rename from src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props rename to src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.props diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets similarity index 100% rename from src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets rename to src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets diff --git a/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs b/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs index 03cef74692..0eea45d546 100644 --- a/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs +++ b/src/Microsoft.AspNetCore.Razor.Tasks/RazorGenerate.cs @@ -9,6 +9,13 @@ namespace Microsoft.AspNetCore.Razor.Tasks { public class RazorGenerate : DotNetToolTask { + private static readonly string[] SourceRequiredMetadata = new string[] + { + FullPath, + GeneratedOutput, + TargetPath, + }; + private const string GeneratedOutput = "GeneratedOutput"; private const string TargetPath = "TargetPath"; private const string FullPath = "FullPath"; @@ -38,12 +45,19 @@ namespace Microsoft.AspNetCore.Razor.Tasks protected override bool ValidateParameters() { + if (Configuration.Length == 0) + { + Log.LogError("The project {0} must provide a value for {1}.", ProjectRoot, nameof(Configuration)); + return false; + } + for (var i = 0; i < Sources.Length; i++) { if (!EnsureRequiredMetadata(Sources[i], FullPath) || !EnsureRequiredMetadata(Sources[i], GeneratedOutput) || !EnsureRequiredMetadata(Sources[i], TargetPath)) { + Log.LogError("The Razor source item '{0}' is missing a required metadata entry. Required metadata are: '{1}'", Sources[i], SourceRequiredMetadata); return false; } } diff --git a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj index 6688f30d79..29fa0ee0be 100644 --- a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj +++ b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj @@ -12,7 +12,7 @@ <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll - + netcoreapp2.0 @@ -24,7 +24,7 @@ - + diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj index 1aa8072b38..d3a47e0743 100644 --- a/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -13,7 +13,7 @@ <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll - + netcoreapp2.0 @@ -30,7 +30,7 @@ - + diff --git a/test/testapps/SimpleMvc/SimpleMvc.csproj b/test/testapps/SimpleMvc/SimpleMvc.csproj index 4e20c9b1c8..115efbaa0b 100644 --- a/test/testapps/SimpleMvc/SimpleMvc.csproj +++ b/test/testapps/SimpleMvc/SimpleMvc.csproj @@ -13,7 +13,7 @@ <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll - + netcoreapp2.0 @@ -21,7 +21,7 @@ - + diff --git a/test/testapps/SimplePages/SimplePages.csproj b/test/testapps/SimplePages/SimplePages.csproj index 654b8f63dc..a8fba5b4b1 100644 --- a/test/testapps/SimplePages/SimplePages.csproj +++ b/test/testapps/SimplePages/SimplePages.csproj @@ -13,7 +13,7 @@ <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll - + netcoreapp2.0 @@ -21,7 +21,7 @@ - + From 02a5b1172512d7c1e86395d3e546b4b2962b48cd Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 18 Feb 2018 12:29:05 -0800 Subject: [PATCH 16/56] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 22 +++++++++++----------- korebuild-lock.txt | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 898bb3fff8..aa3027e138 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,20 +4,20 @@ 0.10.11 - 2.1.0-preview2-15698 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 15.3.409 - 15.3.409 - 15.3.409 + 2.1.0-preview2-15707 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 15.7.0-preview-000011-1378327 + 15.7.0-preview-000011-1378327 + 15.7.0-preview-000011-1378327 2.6.1 2.6.1 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 2.1.0-preview2-25711-01 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 565ec4224a..538f6228c3 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15704 -commithash:21fdd9f5254226f407a2b4b3ef963693c2fd7998 +version:2.1.0-preview2-15707 +commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 From c1b96eaabc18d14183ae53681970ea62dff3920c Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 6 Feb 2018 18:44:28 -0800 Subject: [PATCH 17/56] Update KoreBuild This branch roughly tracks our preview2 stuff for now --- korebuild-lock.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 35a596eb91..d7ea9c33bf 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,7 @@ +<<<<<<< HEAD version:2.1.0-preview2-15696 commithash:85ae1301d1a2ff19aab6837cc657699ccca719b5 +======= +version:2.1.0-preview2-15704 +commithash:21fdd9f5254226f407a2b4b3ef963693c2fd7998 +>>>>>>> Update KoreBuild From 13824c418e4a6b92caaaa0d41c0cfab66d0c4481 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 9 Feb 2018 10:08:09 -0800 Subject: [PATCH 18/56] Catch 15.7 up with dev This change integrates most of the non-breaking work that we did in 2.1 including the updates to make Razor less coupled to MVC. --- .appveyor.yml | 16 +- .gitignore | 2 + .travis.yml | 24 +- Directory.Build.props | 7 +- Razor.Slim.sln | 224 -- Razor.sln | 46 +- .../AssemblyInfo.cs | 1 + .../CodeGenerationBenchmark.cs | 33 +- .../MSN.cshtml | 0 ...rosoft.AspNetCore.Razor.Performance.csproj | 30 + .../TagHelperSerializationBenchmark.cs | 54 + .../readme.md | 0 .../taghelpers.json | 1 + build/VSIX.targets | 10 + build/dependencies.props | 20 +- build/repo.props | 6 +- korebuild-lock.txt | 5 - .../CaseSensitiveBoundAttributeComparer.cs | 7 +- src/Directory.Build.props | 2 +- .../CSharpIdentifier.cs | 8 + .../InjectDirective.cs | 22 +- ...ore.Mvc.Razor.Extensions.Version1_X.csproj | 4 - .../ModelDirective.cs | 32 +- .../MvcImportProjectFeature.cs | 89 + .../MvcRazorTemplateEngine.cs | 6 +- .../MvcViewDocumentClassifierPass.cs | 3 +- .../RazorCodeDocumentExtensions.cs | 34 - .../RazorExtensions.cs | 52 + .../RazorExtensionsDiagnosticFactory.cs | 10 +- .../AssemblyAttributeInjectionPass.cs | 35 +- .../CSharpIdentifier.cs | 8 + .../ExtensionInitializer.cs | 15 + .../InjectDirective.cs | 22 +- .../InstrumentationPass.cs | 5 + ...oft.AspNetCore.Mvc.Razor.Extensions.csproj | 3 +- .../ModelDirective.cs | 32 +- .../MvcImportProjectFeature.cs | 91 + .../MvcRazorTemplateEngine.cs | 6 +- .../MvcViewDocumentClassifierPass.cs | 3 +- .../NamespaceDirective.cs | 46 +- .../PageDirective.cs | 20 +- .../Properties/AssemblyInfo.cs | 6 + .../RazorCodeDocumentExtensions.cs | 34 - .../RazorExtensions.cs | 43 + .../RazorExtensionsDiagnosticFactory.cs | 12 +- .../RazorPageDocumentClassifierPass.cs | 4 +- .../Microsoft.AspNetCore.Mvc.Razor.props | 35 + .../Microsoft.AspNetCore.Mvc.Razor.targets | 9 + .../AllowedChildTagDescriptor.cs | 1 - .../AssemblyExtension.cs | 31 + .../Checksum.cs | 28 + .../CodeGeneration/DefaultDocumentWriter.cs | 51 +- .../DefaultDirectiveSyntaxTreePass.cs | 6 +- .../DefaultImportProjectFeature.cs | 13 + .../DefaultRazorCodeGenerationOptions.cs | 8 +- ...efaultRazorCodeGenerationOptionsBuilder.cs | 29 +- ...eGenerationOptionsFactoryProjectFeature.cs | 32 + ...efaultRazorCodeGenerationOptionsFeature.cs | 12 +- .../DefaultRazorDiagnostic.cs | 35 +- ...faultRazorIntermediateNodeLoweringPhase.cs | 4 +- .../DefaultRazorParserOptionsBuilder.cs | 32 +- ...RazorParserOptionsFactoryProjectFeature.cs | 32 + .../DefaultRazorParserOptionsFeature.cs | 2 + .../DefaultRazorParsingPhase.cs | 4 +- .../DefaultRazorProjectEngine.cs | 154 ++ .../DefaultRazorProjectEngineBuilder.cs | 56 + ...ct.cs => DefaultRazorProjectFileSystem.cs} | 20 +- ...jectItem.cs => DefaultRazorProjectItem.cs} | 16 +- .../DefaultRazorSourceLineCollection.cs | 6 +- .../DefaultRazorTagHelperBinderPhase.cs | 3 +- .../EmptyProjectFileSystem.cs | 23 + .../DefaultMetadataIdentifierFeature.cs | 41 + .../DefaultTagHelperTargetExtension.cs | 39 +- .../Extensions/DesignTimeDirectivePass.cs | 7 + .../Extensions/FunctionsDirective.cs | 21 +- .../IMetadataAttributeTargetExtension.cs | 14 + .../Extensions/IMetadataIdentifierFeature.cs | 10 + .../Extensions/InheritsDirective.cs | 21 +- .../Extensions/MetadataAttributePass.cs | 128 ++ .../MetadataAttributeTargetExtension.cs | 63 + ...catedTagHelperAttributeOptimizationPass.cs | 6 + ...orCompiledItemAttributeIntermediateNode.cs | 52 + ...SourceChecksumAttributeIntermediateNode.cs | 52 + .../Extensions/SectionDirective.cs | 22 +- .../IImportProjectFeature.cs | 12 + ...eGenerationOptionsFactoryProjectFeature.cs | 12 + .../IRazorCodeGenerationOptionsFeature.cs | 3 + .../IRazorEngineFeature.cs | 2 +- .../IRazorFeature.cs | 9 + ...RazorParserOptionsFactoryProjectFeature.cs | 12 + .../IRazorParserOptionsFeature.cs | 3 + .../IRazorProjectEngineFeature.cs | 10 + .../LargeTextSourceDocument.cs | 12 +- .../Legacy/Block.cs | 16 +- .../Legacy/CSharpCodeParser.cs | 248 +-- .../Legacy/CSharpLanguageCharacteristics.cs | 22 +- .../Legacy/CSharpSymbol.cs | 4 +- .../Legacy/CSharpTokenizer.cs | 21 +- .../Legacy/ErrorSink.cs | 26 +- .../Legacy/HtmlLanguageCharacteristics.cs | 12 +- .../Legacy/HtmlMarkupParser.cs | 61 +- .../Legacy/HtmlSymbol.cs | 4 +- .../Legacy/HtmlTokenizer.cs | 2 +- .../Legacy/LanguageCharacteristics.cs | 4 +- .../Legacy/RazorError.cs | 81 - .../Legacy/RazorParser.cs | 3 +- .../Legacy/Span.cs | 6 + .../Legacy/SymbolBase.cs | 4 +- .../Legacy/SyntaxTreeBuilder.cs | 8 +- .../Legacy/SyntaxTreeNode.cs | 2 + .../Legacy/TagHelperBlock.cs | 35 + .../Legacy/TagHelperBlockBuilder.cs | 5 +- .../Legacy/TagHelperBlockRewriter.cs | 55 +- .../Legacy/TagHelperParseTreeRewriter.cs | 50 +- .../Legacy/Tokenizer.cs | 8 +- .../Legacy/TokenizerBackedParser.cs | 66 +- .../LegacyRazorDiagnostic.cs | 40 - .../LegacyResources.resx | 410 ---- .../Properties/AssemblyInfo.cs | 5 + .../Properties/LegacyResources.Designer.cs | 1296 ------------ .../Properties/Resources.Designer.cs | 1826 +++++++++++++---- ...ovideRazorExtensionInitializerAttribute.cs | 31 + .../RazorCodeDocument.cs | 17 + .../RazorCodeDocumentExtensions.cs | 42 +- .../RazorCodeGenerationOptions.cs | 47 +- .../RazorCodeGenerationOptionsBuilder.cs | 33 + .../RazorConfiguration.cs | 17 +- .../RazorDiagnostic.cs | 12 +- .../RazorDiagnosticFactory.cs | 514 ++++- .../RazorEngine.cs | 114 +- .../RazorExtensionInitializer.cs | 10 + .../RazorParserOptionsBuilder.cs | 9 +- .../RazorProject.cs | 3 +- .../RazorProjectEngine.cs | 188 ++ .../RazorProjectEngineBuilder.cs | 20 + .../RazorProjectEngineBuilderExtensions.cs | 234 +++ .../RazorProjectEngineFeatureBase.cs | 31 + .../RazorProjectFileSystem.cs | 27 + .../RazorProjectItem.cs | 14 +- .../RazorSourceDocument.cs | 166 +- .../RazorSourceDocumentProperties.cs | 57 + .../RazorTemplateEngine.cs | 1 - .../Resources.resx | 426 +++- .../SourceLocation.cs | 5 +- .../SourceSpan.cs | 5 + .../StreamSourceDocument.cs | 18 +- .../StringSourceDocument.cs | 14 +- .../VirtualRazorProjectFileSystem.cs | 215 ++ .../Hosting/DefaultRazorCompiledItem.cs | 54 + .../Hosting/IRazorSourceChecksumMetadata.cs | 26 + .../Hosting/RazorCompiledItem.cs | 40 + .../Hosting/RazorCompiledItemAttribute.cs | 60 + .../Hosting/RazorCompiledItemExtensions.cs | 30 + .../Hosting/RazorCompiledItemLoader.cs | 83 + .../Hosting/RazorSourceChecksumAttribute.cs | 67 + .../Microsoft.AspNetCore.Razor.Runtime.csproj | 10 +- .../Properties/AssemblyInfo.cs | 19 + .../Microsoft.AspNetCore.Razor.csproj | 17 +- .../TagHelpers/DefaultTagHelperContent.cs | 0 .../TagHelpers/HtmlAttributeNameAttribute.cs | 0 .../HtmlAttributeNotBoundAttribute.cs | 0 .../TagHelpers/HtmlTargetElementAttribute.cs | 0 .../TagHelpers/ITagHelper.cs | 0 .../TagHelpers/ITagHelperComponent.cs | 0 .../TagHelpers/NullHtmlEncoder.cs | 0 .../TagHelpers/OutputElementHintAttribute.cs | 0 .../ReadOnlyTagHelperAttributeList.cs | 0 .../TagHelpers/RestrictChildrenAttribute.cs | 0 .../TagHelpers/TagHelper.cs | 0 .../TagHelpers/TagHelperAttribute.cs | 0 .../TagHelpers/TagHelperAttributeList.cs | 0 .../TagHelpers/TagHelperComponent.cs | 0 .../TagHelpers/TagHelperContent.cs | 0 .../TagHelpers/TagHelperContext.cs | 0 .../TagHelpers/TagHelperOutput.cs | 1 - .../DefaultErrorReporterFactory.cs | 2 +- .../DefaultTagHelperFactsServiceInternal.cs | 163 -- ...ultTagHelperFactsServiceInternalFactory.cs | 17 - .../DefaultEditorSettingsManagerInternal.cs | 54 - ...ultEditorSettingsManagerInternalFactory.cs | 25 - ...Internal.cs => WorkspaceEditorSettings.cs} | 4 +- .../ForegroundDispatcher.cs | 2 +- .../ProjectSystem/DefaultProjectSnapshot.cs | 5 +- .../DefaultProjectSnapshotManager.cs | 25 +- .../DefaultProjectSnapshotManagerFactory.cs | 15 +- .../DefaultProjectSnapshotWorker.cs | 2 +- .../DefaultProjectSnapshotWorkerFactory.cs | 15 +- .../ProjectSystem/ProjectSnapshot.cs | 3 +- .../ProjectSystem/ProjectSnapshotManager.cs | 1 - .../ProjectSnapshotManagerBase.cs | 2 + .../ProjectSnapshotUpdateContext.cs | 2 + .../Properties/AssemblyInfo.cs | 2 + ...cs => RazorProjectEngineFactoryService.cs} | 4 +- .../TagHelperFactsServiceInternal.cs | 20 - .../TagHelperResolver.cs | 12 +- .../DefaultTagHelperResolver.cs | 10 +- .../BackgroundParser.cs | 51 +- .../BraceSmartIndenterFactory.cs | 6 +- .../DefaultBraceSmartIndenterFactory.cs | 26 +- ...DefaultBraceSmartIndenterFactoryFactory.cs | 47 + .../DefaultEditorSettingsManager.cs | 53 +- ... => DefaultProjectEngineFactoryService.cs} | 28 +- ...aultProjectEngineFactoryServiceFactory.cs} | 6 +- .../DefaultTagHelperCompletionService.cs | 42 +- .../DefaultTagHelperFactsService.cs | 140 +- .../DefaultTagHelperResolver.cs | 60 + .../DefaultTagHelperResolverFactory.cs | 10 +- .../DefaultVisualStudioDocumentTracker.cs | 13 +- ...faultVisualStudioDocumentTrackerFactory.cs | 47 +- ...sualStudioDocumentTrackerFactoryFactory.cs | 75 + .../DefaultVisualStudioRazorParser.cs | 34 +- .../DefaultVisualStudioRazorParserFactory.cs | 66 + ...ltVisualStudioRazorParserFactoryFactory.cs | 47 + .../DelegatingTemplateEngine.cs | 40 + .../TextBufferProjectService.cs | 18 + .../TextSnapshotProjectItem.cs | 65 + .../VisualStudioCompletionBroker.cs | 13 + .../VisualStudioDocumentTrackerFactory.cs | 5 +- .../VisualStudioRazorParserFactory.cs | 4 +- .../VisualStudioWorkspaceAccessor.cs | 5 +- .../DefaultTagHelperResolver.cs | 123 -- .../DefaultVisualStudioWorkspaceAccessor.cs | 104 +- .../DefaultRazorEditorFactoryService.cs | 80 +- .../Editor/DefaultTextBufferProjectService.cs | 47 +- .../DefaultVisualStudioCompletionBroker.cs | 36 + ...aultVisualStudioCompletionBrokerFactory.cs | 41 + .../DefaultVisualStudioRazorParserFactory.cs | 64 - .../Editor/RazorTextViewConnectionListener.cs | 33 +- .../Editor/TextBufferProjectService.cs | 17 - .../Legacy/LegacyTagHelperResolver.cs | 16 +- .../OOPTagHelperResolver.cs | 91 + .../OOPTagHelperResolverFactory.cs | 21 + .../RazorDiagnosticJsonConverter.cs | 28 +- .../TextBufferProjectService.cs | 15 - .../VisualStudioForegroundDispatcher.cs | 7 +- src/RazorPageGenerator/Program.cs | 79 +- .../AssemblyAttributeInjectionPassTest.cs | 107 +- .../InstrumentationPassTest.cs | 80 +- .../ModelDirectiveTest.cs | 28 +- .../MvcImportProjectFeatureTest.cs | 76 + .../MvcRazorTemplateEngineTest.cs | 30 +- .../MvcViewDocumentClassifierPassTest.cs | 53 +- .../NamespaceDirectiveTest.cs | 38 +- .../RazorPageDocumentClassifierPassTest.cs | 56 +- .../Basic_DesignTime.codegen.cs | 2 +- .../Basic_DesignTime.ir.txt | 2 +- .../Basic_DesignTime.mappings.txt | 12 +- .../Basic_Runtime.codegen.cs | 6 +- .../Basic_Runtime.ir.txt | 6 +- ...IncompleteDirectives_DesignTime.codegen.cs | 8 +- ...pleteDirectives_DesignTime.diagnostics.txt | 24 +- .../IncompleteDirectives_DesignTime.ir.txt | 6 +- ...completeDirectives_DesignTime.mappings.txt | 16 +- .../IncompleteDirectives_Runtime.codegen.cs | 12 +- ...completeDirectives_Runtime.diagnostics.txt | 24 +- .../IncompleteDirectives_Runtime.ir.txt | 10 +- .../InheritsViewModel_DesignTime.codegen.cs | 2 +- .../InheritsViewModel_DesignTime.ir.txt | 2 +- .../InheritsViewModel_DesignTime.mappings.txt | 4 +- .../InheritsViewModel_Runtime.codegen.cs | 6 +- .../InheritsViewModel_Runtime.ir.txt | 6 +- ...eritsWithViewImports_DesignTime.codegen.cs | 2 +- .../InheritsWithViewImports_DesignTime.ir.txt | 2 +- ...itsWithViewImports_DesignTime.mappings.txt | 2 +- ...InheritsWithViewImports_Runtime.codegen.cs | 7 +- .../InheritsWithViewImports_Runtime.ir.txt | 7 +- .../InjectWithModel_DesignTime.codegen.cs | 2 +- .../InjectWithModel_DesignTime.ir.txt | 2 +- .../InjectWithModel_DesignTime.mappings.txt | 10 +- .../InjectWithModel_Runtime.codegen.cs | 6 +- .../InjectWithModel_Runtime.ir.txt | 6 +- .../InjectWithSemicolon_DesignTime.codegen.cs | 2 +- .../InjectWithSemicolon_DesignTime.ir.txt | 2 +- ...njectWithSemicolon_DesignTime.mappings.txt | 18 +- .../InjectWithSemicolon_Runtime.codegen.cs | 6 +- .../InjectWithSemicolon_Runtime.ir.txt | 6 +- .../Inject_DesignTime.codegen.cs | 2 +- .../Inject_DesignTime.ir.txt | 2 +- .../Inject_DesignTime.mappings.txt | 4 +- .../Inject_Runtime.codegen.cs | 6 +- .../Inject_Runtime.ir.txt | 6 +- ...nvalidNamespaceAtEOF_DesignTime.codegen.cs | 2 +- ...dNamespaceAtEOF_DesignTime.diagnostics.txt | 2 +- .../InvalidNamespaceAtEOF_DesignTime.ir.txt | 2 +- .../InvalidNamespaceAtEOF_Runtime.codegen.cs | 6 +- ...alidNamespaceAtEOF_Runtime.diagnostics.txt | 2 +- .../InvalidNamespaceAtEOF_Runtime.ir.txt | 6 +- ...lformedPageDirective_DesignTime.codegen.cs | 8 +- ...edPageDirective_DesignTime.diagnostics.txt | 2 +- .../MalformedPageDirective_DesignTime.ir.txt | 6 +- .../MalformedPageDirective_Runtime.codegen.cs | 12 +- ...ormedPageDirective_Runtime.diagnostics.txt | 2 +- .../MalformedPageDirective_Runtime.ir.txt | 10 +- ...lExpressionTagHelper_DesignTime.codegen.cs | 2 +- ...ModelExpressionTagHelper_DesignTime.ir.txt | 2 +- ...xpressionTagHelper_DesignTime.mappings.txt | 8 +- ...odelExpressionTagHelper_Runtime.codegen.cs | 6 +- .../ModelExpressionTagHelper_Runtime.ir.txt | 6 +- .../Model_DesignTime.codegen.cs | 2 +- .../Model_DesignTime.ir.txt | 2 +- .../Model_DesignTime.mappings.txt | 2 +- .../Model_Runtime.codegen.cs | 6 +- .../Model_Runtime.ir.txt | 6 +- .../MultipleModels_DesignTime.codegen.cs | 2 +- .../MultipleModels_DesignTime.diagnostics.txt | 2 +- .../MultipleModels_DesignTime.ir.txt | 2 +- .../MultipleModels_DesignTime.mappings.txt | 4 +- .../PageWithNamespace_DesignTime.codegen.cs | 8 +- .../PageWithNamespace_DesignTime.ir.txt | 6 +- .../PageWithNamespace_DesignTime.mappings.txt | 2 +- .../PageWithNamespace_Runtime.codegen.cs | 12 +- .../PageWithNamespace_Runtime.ir.txt | 10 +- ...zorPagesWithoutModel_DesignTime.codegen.cs | 8 +- .../RazorPagesWithoutModel_DesignTime.ir.txt | 6 +- ...rPagesWithoutModel_DesignTime.mappings.txt | 6 +- .../RazorPagesWithoutModel_Runtime.codegen.cs | 12 +- .../RazorPagesWithoutModel_Runtime.ir.txt | 10 +- .../RazorPages_DesignTime.codegen.cs | 2 +- .../RazorPages_DesignTime.ir.txt | 2 +- .../RazorPages_DesignTime.mappings.txt | 8 +- .../RazorPages_Runtime.codegen.cs | 6 +- .../RazorPages_Runtime.ir.txt | 6 +- .../Sections_DesignTime.codegen.cs | 2 +- .../Sections_DesignTime.ir.txt | 2 +- .../Sections_DesignTime.mappings.txt | 10 +- .../Sections_Runtime.codegen.cs | 6 +- .../Sections_Runtime.ir.txt | 6 +- ...ewComponentTagHelper_DesignTime.codegen.cs | 6 +- .../ViewComponentTagHelper_DesignTime.ir.txt | 6 +- ...ComponentTagHelper_DesignTime.mappings.txt | 6 +- .../ViewComponentTagHelper_Runtime.codegen.cs | 10 +- .../ViewComponentTagHelper_Runtime.ir.txt | 10 +- .../ViewWithNamespace_DesignTime.codegen.cs | 2 +- .../ViewWithNamespace_DesignTime.ir.txt | 2 +- .../ViewWithNamespace_DesignTime.mappings.txt | 2 +- .../ViewWithNamespace_Runtime.codegen.cs | 6 +- .../ViewWithNamespace_Runtime.ir.txt | 6 +- .../_ViewImports_DesignTime.codegen.cs | 2 +- .../_ViewImports_DesignTime.ir.txt | 2 +- .../_ViewImports_DesignTime.mappings.txt | 4 +- .../_ViewImports_Runtime.codegen.cs | 6 +- .../_ViewImports_Runtime.ir.txt | 6 +- .../BasicTest.codegen.cs | 2 + .../BasicTest.ir.txt | 2 + .../ViewComponentTagHelperPassTest.cs | 6 +- .../ModelDirectiveTest.cs | 28 +- .../MvcImportProjectFeatureTest.cs | 76 + .../MvcRazorTemplateEngineTest.cs | 30 +- .../MvcViewDocumentClassifierPassTest.cs | 53 +- .../Basic_DesignTime.codegen.cs | 2 +- .../Basic_DesignTime.ir.txt | 2 +- .../Basic_DesignTime.mappings.txt | 12 +- ...IncompleteDirectives_DesignTime.codegen.cs | 2 +- ...pleteDirectives_DesignTime.diagnostics.txt | 12 +- .../IncompleteDirectives_DesignTime.ir.txt | 2 +- ...completeDirectives_DesignTime.mappings.txt | 12 +- .../InheritsViewModel_DesignTime.codegen.cs | 2 +- .../InheritsViewModel_DesignTime.ir.txt | 2 +- .../InheritsViewModel_DesignTime.mappings.txt | 4 +- ...eritsWithViewImports_DesignTime.codegen.cs | 2 +- .../InheritsWithViewImports_DesignTime.ir.txt | 2 +- ...itsWithViewImports_DesignTime.mappings.txt | 2 +- .../InjectWithModel_DesignTime.codegen.cs | 2 +- .../InjectWithModel_DesignTime.ir.txt | 2 +- .../InjectWithModel_DesignTime.mappings.txt | 10 +- .../InjectWithSemicolon_DesignTime.codegen.cs | 2 +- .../InjectWithSemicolon_DesignTime.ir.txt | 2 +- ...njectWithSemicolon_DesignTime.mappings.txt | 18 +- .../Inject_DesignTime.codegen.cs | 2 +- .../Inject_DesignTime.ir.txt | 2 +- .../Inject_DesignTime.mappings.txt | 4 +- ...nvalidNamespaceAtEOF_DesignTime.codegen.cs | 2 +- ...dNamespaceAtEOF_DesignTime.diagnostics.txt | 2 +- .../InvalidNamespaceAtEOF_DesignTime.ir.txt | 2 +- ...lExpressionTagHelper_DesignTime.codegen.cs | 2 +- ...ModelExpressionTagHelper_DesignTime.ir.txt | 2 +- ...xpressionTagHelper_DesignTime.mappings.txt | 8 +- .../Model_DesignTime.codegen.cs | 2 +- .../Model_DesignTime.ir.txt | 2 +- .../Model_DesignTime.mappings.txt | 2 +- .../MultipleModels_DesignTime.codegen.cs | 2 +- .../MultipleModels_DesignTime.diagnostics.txt | 2 +- .../MultipleModels_DesignTime.ir.txt | 2 +- .../MultipleModels_DesignTime.mappings.txt | 4 +- .../Sections_DesignTime.codegen.cs | 2 +- .../Sections_DesignTime.ir.txt | 2 +- .../Sections_DesignTime.mappings.txt | 10 +- ...ewComponentTagHelper_DesignTime.codegen.cs | 6 +- .../ViewComponentTagHelper_DesignTime.ir.txt | 6 +- ...ComponentTagHelper_DesignTime.mappings.txt | 6 +- .../_ViewImports_DesignTime.codegen.cs | 2 +- .../_ViewImports_DesignTime.ir.txt | 2 +- .../_ViewImports_DesignTime.mappings.txt | 4 +- .../ViewComponentTagHelperPassTest.cs | 6 +- .../DefaultDocumentWriterTest.cs | 106 +- ...tRazorIntermediateNodeLoweringPhaseTest.cs | 14 +- .../DefaultRazorProjectEngineBuilderTest.cs | 65 + ...efaultRazorProjectEngineIntegrationTest.cs | 95 + .../DefaultRazorProjectEngineTest.cs | 37 + .../DefaultRazorProjectFileSystemTest.cs | 263 +++ ...Test.cs => DefaultRazorProjectItemTest.cs} | 19 +- .../DefaultRazorTagHelperBinderPhaseTest.cs | 69 +- .../DefaultMetadataIdentifierFeatureTest.cs | 72 + .../DefaultTagHelperTargetExtensionTest.cs | 92 +- .../Extensions/MetadataAttributePassTest.cs | 362 ++++ .../MetadataAttributeTargetExtensionTest.cs | 69 + .../FileSystemRazorProjectTest.cs | 171 -- .../IntegrationTests/BasicIntegrationTest.cs | 17 +- .../CodeGenerationIntegrationTest.cs | 8 +- .../ExtensibleDirectiveTest.cs | 2 +- .../RazorTemplateEngineIntegrationTest.cs | 62 +- .../LargeTextSourceDocumentTest.cs | 30 +- .../Legacy/BlockTest.cs | 20 + .../Legacy/CSharpAutoCompleteTest.cs | 42 +- .../Legacy/CSharpBlockTest.cs | 72 +- .../Legacy/CSharpDirectivesTest.cs | 408 ++-- .../Legacy/CSharpErrorTest.cs | 266 +-- .../Legacy/CSharpExplicitExpressionTest.cs | 10 +- .../Legacy/CSharpImplicitExpressionTest.cs | 43 +- .../Legacy/CSharpRazorCommentsTest.cs | 55 +- .../Legacy/CSharpReservedWordsTest.cs | 6 +- .../Legacy/CSharpSectionTest.cs | 91 +- .../Legacy/CSharpSpecialBlockTest.cs | 40 +- .../Legacy/CSharpStatementTest.cs | 26 +- .../Legacy/CSharpTemplateTest.cs | 8 +- .../Legacy/CSharpToMarkupSwitchTest.cs | 6 +- .../Legacy/CSharpVerbatimBlockTest.cs | 20 +- .../Legacy/CodeParserTestBase.cs | 20 +- .../Legacy/HtmlAttributeTest.cs | 6 +- .../Legacy/HtmlBlockTest.cs | 45 +- .../Legacy/HtmlDocumentTest.cs | 27 +- .../Legacy/HtmlErrorTest.cs | 42 +- .../Legacy/HtmlTagsTest.cs | 6 +- .../Legacy/RazorErrorTest.cs | 75 - .../Legacy/SpanTest.cs | 22 +- .../Legacy/TagHelperBlockRewriterTest.cs | 1074 +++++----- .../Legacy/TagHelperBlockTest.cs | 102 + .../Legacy/TagHelperParseTreeRewriterTest.cs | 737 +++---- .../Legacy/TagHelperRewritingTestBase.cs | 10 +- .../Legacy/TokenizerLookaheadTest.cs | 2 +- .../LegacyRazorDiagnosticTest.cs | 170 -- ...soft.AspNetCore.Razor.Language.Test.csproj | 1 + .../RazorCodeDocumentExtensionsTest.cs | 62 + .../RazorDiagnosticTest.cs | 17 - .../RazorEngineTest.cs | 10 +- ...RazorProjectEngineBuilderExtensionsTest.cs | 103 + .../RazorProjectEngineFeatureBaseTest.cs | 34 + .../RazorProjectEngineTest.cs | 85 + .../RazorSourceDocumentTest.cs | 108 +- .../RazorSyntaxTreeTest.cs | 2 +- .../RazorTemplateEngineTest.cs | 80 +- .../SourceLocationTest.cs | 4 +- .../StreamSourceDocumentTest.cs | 73 +- .../StringSourceDocumentTest.cs | 116 +- .../Home.cshtml | 0 .../Views/About/About.cshtml | 0 .../Views/Home/Index.cshtml | 0 .../Views/Home/Index.txt | 0 .../Views/Home/_ViewImports.cshtml | 1 + .../Views/_ViewImports.cshtml | 1 + .../_ViewImports.cshtml | 1 + .../CustomDirective.ir.txt | 2 + .../BasicIntegrationTest/Empty.ir.txt | 2 + .../BasicIntegrationTest/HelloWorld.ir.txt | 2 + ...buteTargetingTagHelpers_Runtime.codegen.cs | 2 + ...ttributeTargetingTagHelpers_Runtime.ir.txt | 2 + .../Await_Runtime.codegen.cs | 2 + .../Await_Runtime.ir.txt | 2 + .../BasicImports_Runtime.codegen.cs | 4 + .../BasicImports_Runtime.ir.txt | 4 + ...asicTagHelpers_Prefixed_Runtime.codegen.cs | 2 + .../BasicTagHelpers_Prefixed_Runtime.ir.txt | 2 + ...Helpers_RemoveTagHelper_Runtime.codegen.cs | 2 + ...cTagHelpers_RemoveTagHelper_Runtime.ir.txt | 2 + .../BasicTagHelpers_Runtime.codegen.cs | 2 + .../BasicTagHelpers_Runtime.ir.txt | 2 + .../Blocks_Runtime.codegen.cs | 2 + .../Blocks_Runtime.ir.txt | 2 + .../CSharp7_Runtime.codegen.cs | 2 + .../CSharp7_Runtime.ir.txt | 2 + .../CodeBlockAtEOF_DesignTime.diagnostics.txt | 2 +- .../CodeBlockAtEOF_Runtime.codegen.cs | 2 + .../CodeBlockAtEOF_Runtime.diagnostics.txt | 2 +- .../CodeBlockAtEOF_Runtime.ir.txt | 2 + ...odeBlockWithTextElement_Runtime.codegen.cs | 2 + .../CodeBlockWithTextElement_Runtime.ir.txt | 2 + .../CodeBlock_Runtime.codegen.cs | 2 + .../CodeBlock_Runtime.ir.txt | 2 + .../ComplexTagHelpers_Runtime.codegen.cs | 2 + .../ComplexTagHelpers_Runtime.ir.txt | 2 + .../ConditionalAttributes_Runtime.codegen.cs | 2 + .../ConditionalAttributes_Runtime.ir.txt | 2 + ...ctorTagHelperAttributes_Runtime.codegen.cs | 2 + ...SelectorTagHelperAttributes_Runtime.ir.txt | 2 + ...cateAttributeTagHelpers_Runtime.codegen.cs | 2 + ...uplicateAttributeTagHelpers_Runtime.ir.txt | 2 + ...uplicateTargetTagHelper_Runtime.codegen.cs | 2 + .../DuplicateTargetTagHelper_Runtime.ir.txt | 2 + ...amicAttributeTagHelpers_Runtime.codegen.cs | 2 + .../DynamicAttributeTagHelpers_Runtime.ir.txt | 2 + ...ibuteTagHelpers_DesignTime.diagnostics.txt | 6 +- ...mptyAttributeTagHelpers_Runtime.codegen.cs | 2 + ...ttributeTagHelpers_Runtime.diagnostics.txt | 6 +- .../EmptyAttributeTagHelpers_Runtime.ir.txt | 2 + .../EmptyCodeBlock_Runtime.codegen.cs | 2 + .../EmptyCodeBlock_Runtime.ir.txt | 2 + ...EmptyExplicitExpression_Runtime.codegen.cs | 2 + .../EmptyExplicitExpression_Runtime.ir.txt | 2 + ...xpressionInCode_DesignTime.diagnostics.txt | 2 +- ...mplicitExpressionInCode_Runtime.codegen.cs | 2 + ...itExpressionInCode_Runtime.diagnostics.txt | 2 +- ...ptyImplicitExpressionInCode_Runtime.ir.txt | 2 + ...licitExpression_DesignTime.diagnostics.txt | 2 +- ...EmptyImplicitExpression_Runtime.codegen.cs | 2 + ...ImplicitExpression_Runtime.diagnostics.txt | 2 +- .../EmptyImplicitExpression_Runtime.ir.txt | 2 + .../EnumTagHelpers_Runtime.codegen.cs | 2 + .../EnumTagHelpers_Runtime.ir.txt | 2 + .../EscapedTagHelpers_Runtime.codegen.cs | 2 + .../EscapedTagHelpers_Runtime.ir.txt | 2 + ...ExpressionAtEOF_DesignTime.diagnostics.txt | 2 +- ...ExplicitExpressionAtEOF_Runtime.codegen.cs | 2 + ...citExpressionAtEOF_Runtime.diagnostics.txt | 2 +- .../ExplicitExpressionAtEOF_Runtime.ir.txt | 2 + ...ssionWithMarkup_DesignTime.diagnostics.txt | 4 +- ...citExpressionWithMarkup_Runtime.codegen.cs | 2 + ...pressionWithMarkup_Runtime.diagnostics.txt | 4 +- ...xplicitExpressionWithMarkup_Runtime.ir.txt | 2 + .../ExplicitExpression_Runtime.codegen.cs | 2 + .../ExplicitExpression_Runtime.ir.txt | 2 + .../ExpressionsInCode_Runtime.codegen.cs | 2 + .../ExpressionsInCode_Runtime.ir.txt | 2 + .../FunctionsBlockMinimal_Runtime.codegen.cs | 2 + .../FunctionsBlockMinimal_Runtime.ir.txt | 2 + .../FunctionsBlock_Runtime.codegen.cs | 2 + .../FunctionsBlock_Runtime.ir.txt | 2 + .../HiddenSpansInCode_Runtime.codegen.cs | 2 + .../HiddenSpansInCode_Runtime.ir.txt | 2 + ...CommentWithQuote_Double_Runtime.codegen.cs | 2 + ...HtmlCommentWithQuote_Double_Runtime.ir.txt | 2 + ...CommentWithQuote_Single_Runtime.codegen.cs | 2 + ...HtmlCommentWithQuote_Single_Runtime.ir.txt | 2 + ...ExpressionAtEOF_DesignTime.diagnostics.txt | 2 +- ...ImplicitExpressionAtEOF_Runtime.codegen.cs | 2 + ...citExpressionAtEOF_Runtime.diagnostics.txt | 2 +- .../ImplicitExpressionAtEOF_Runtime.ir.txt | 2 + .../ImplicitExpression_Runtime.codegen.cs | 2 + .../ImplicitExpression_Runtime.ir.txt | 2 + ...pleteDirectives_DesignTime.diagnostics.txt | 50 +- .../IncompleteDirectives_Runtime.codegen.cs | 2 + ...completeDirectives_Runtime.diagnostics.txt | 50 +- .../IncompleteDirectives_Runtime.ir.txt | 2 + ...mpleteTagHelper_DesignTime.diagnostics.txt | 4 +- .../IncompleteTagHelper_Runtime.codegen.cs | 2 + ...ncompleteTagHelper_Runtime.diagnostics.txt | 4 +- .../IncompleteTagHelper_Runtime.ir.txt | 2 + .../Inherits_Runtime.codegen.cs | 2 + .../Inherits_Runtime.ir.txt | 2 + .../InlineBlocks_DesignTime.diagnostics.txt | 2 +- .../InlineBlocks_Runtime.codegen.cs | 2 + .../InlineBlocks_Runtime.diagnostics.txt | 2 +- .../InlineBlocks_Runtime.ir.txt | 2 + .../Instrumented_Runtime.codegen.cs | 2 + .../Instrumented_Runtime.ir.txt | 2 + .../MarkupInCodeBlock_Runtime.codegen.cs | 2 + .../MarkupInCodeBlock_Runtime.ir.txt | 2 + .../MinimizedTagHelpers_Runtime.codegen.cs | 2 + .../MinimizedTagHelpers_Runtime.ir.txt | 2 + .../NestedCSharp_Runtime.codegen.cs | 2 + .../NestedCSharp_Runtime.ir.txt | 2 + .../NestedCodeBlocks_Runtime.codegen.cs | 2 + .../NestedCodeBlocks_Runtime.ir.txt | 2 + ...stedScriptTagTagHelpers_Runtime.codegen.cs | 2 + .../NestedScriptTagTagHelpers_Runtime.ir.txt | 2 + .../NestedTagHelpers_Runtime.codegen.cs | 2 + .../NestedTagHelpers_Runtime.ir.txt | 2 + .../NoLinePragmas_Runtime.codegen.cs | 2 + .../NoLinePragmas_Runtime.ir.txt | 2 + ...lConditionalExpressions_Runtime.codegen.cs | 2 + .../NullConditionalExpressions_Runtime.ir.txt | 2 + .../OpenedIf_DesignTime.diagnostics.txt | 6 +- .../OpenedIf_Runtime.codegen.cs | 2 + .../OpenedIf_Runtime.diagnostics.txt | 6 +- .../OpenedIf_Runtime.ir.txt | 2 + .../ParserError_DesignTime.diagnostics.txt | 4 +- .../ParserError_Runtime.codegen.cs | 2 + .../ParserError_Runtime.diagnostics.txt | 4 +- .../ParserError_Runtime.ir.txt | 2 + ...ixedAttributeTagHelpers_Runtime.codegen.cs | 2 + ...PrefixedAttributeTagHelpers_Runtime.ir.txt | 2 + .../RazorComments_Runtime.codegen.cs | 2 + .../RazorComments_Runtime.ir.txt | 2 + .../Sections_Runtime.codegen.cs | 2 + .../Sections_Runtime.ir.txt | 2 + .../SimpleTagHelpers_Runtime.codegen.cs | 2 + .../SimpleTagHelpers_Runtime.ir.txt | 2 + .../SimpleUnspacedIf_Runtime.codegen.cs | 2 + .../SimpleUnspacedIf_Runtime.ir.txt | 2 + ...NewlineBeforeAttributes_Runtime.codegen.cs | 2 + ...WithNewlineBeforeAttributes_Runtime.ir.txt | 2 + .../SingleTagHelper_Runtime.codegen.cs | 2 + .../SingleTagHelper_Runtime.ir.txt | 2 + .../StringLiterals_Runtime.codegen.cs | 2 + .../StringLiterals_Runtime.ir.txt | 2 + .../SymbolBoundAttributes_Runtime.codegen.cs | 2 + .../SymbolBoundAttributes_Runtime.ir.txt | 2 + .../TagHelpersInSection_Runtime.codegen.cs | 2 + .../TagHelpersInSection_Runtime.ir.txt | 2 + ...persWithBoundAttributes_Runtime.codegen.cs | 2 + ...gHelpersWithBoundAttributes_Runtime.ir.txt | 2 + .../TagHelpersWithPrefix_Runtime.codegen.cs | 2 + .../TagHelpersWithPrefix_Runtime.ir.txt | 2 + .../TagHelpersWithTemplate_Runtime.codegen.cs | 2 + .../TagHelpersWithTemplate_Runtime.ir.txt | 2 + ...WeirdlySpacedAttributes_Runtime.codegen.cs | 2 + ...WithWeirdlySpacedAttributes_Runtime.ir.txt | 2 + .../Templates_Runtime.codegen.cs | 2 + .../Templates_Runtime.ir.txt | 2 + ...elperAttributes_DesignTime.diagnostics.txt | 2 +- ...nsInTagHelperAttributes_Runtime.codegen.cs | 2 + ...agHelperAttributes_Runtime.diagnostics.txt | 2 +- ...itionsInTagHelperAttributes_Runtime.ir.txt | 2 + ...inishedExpressionInCode_Runtime.codegen.cs | 2 + .../UnfinishedExpressionInCode_Runtime.ir.txt | 2 + .../Usings_Runtime.codegen.cs | 2 + .../Usings_Runtime.ir.txt | 2 + .../HtmlWithConditionalAttribute.ir.txt | 2 + .../HtmlWithDataDashAttribute.ir.txt | 2 + .../GenerateCodeWithBaseType.codegen.cs | 3 +- .../GenerateCodeWithConfigureClass.codegen.cs | 3 +- .../GenerateCodeWithDefaults.codegen.cs | 3 +- .../GenerateCodeWithSetNamespace.codegen.cs | 3 +- .../NestedTagHelpers.ir.txt | 2 + .../SimpleTagHelpers.ir.txt | 2 + .../TagHelpersWithBoundAttributes.ir.txt | 2 + .../TestRazorProject.cs | 0 .../VirtualRazorProjectFileSystemTest.cs | 400 ++++ .../Configs/CoreConfig.cs | 31 - ...rosoft.AspNetCore.Razor.Performance.csproj | 19 - .../Program.cs | 17 - .../IntegrationTests/IntegrationTestBase.cs | 42 +- .../Language/Legacy/ParserTestBase.cs | 52 +- .../Language/Legacy/TestSpanBuilder.cs | 12 +- .../Language/RazorEngineBuilderExtensions.cs | 40 + .../RazorProjectEngineBuilderExtensions.cs | 70 + .../Language/TestRazorProjectFileSystem.cs | 41 + .../Language/TestRazorProjectItem.cs | 10 +- .../Language/TestRazorSourceDocument.cs | 57 +- .../Properties/AssemblyInfo.cs | 2 + ...tCore.Razor.Test.MvcShim.Version1_X.csproj | 2 +- .../RazorPage.cs | 28 + ...osoft.AspNetCore.Razor.Test.MvcShim.csproj | 2 +- .../Microsoft.AspNetCore.Razor.Test.csproj | 29 + .../TagHelpers/DefaultTagHelperContentTest.cs | 0 .../TagHelpers/NullHtmlEncoderTest.cs | 0 .../ReadOnlyTagHelperAttributeListTest.cs | 0 .../TagHelpers/TagHelperAttributeListTest.cs | 0 .../TagHelpers/TagHelperContextTest.cs | 0 .../TagHelpers/TagHelperOutputTest.cs | 30 - .../xunit.runner.json | Bin 0 -> 116 bytes ...alysis.Razor.Workspaces.Test.Common.csproj | 16 + .../TestRazorLanguageServices.cs | 48 + .../TestServices.cs | 47 + .../TestWorkspace.cs | 26 + .../TestWorkspaceServices.cs | 85 + ....CodeAnalysis.Razor.Workspaces.Test.csproj | 2 +- .../DefaultProjectSnapshotManagerTest.cs | 34 +- .../DefaultProjectSnapshotTest.cs | 67 + ...rkspaceProjectSnapshotChangeTriggerTest.cs | 30 +- .../DefaultEditorSettingsManagerTest.cs} | 13 +- ...DefaultProjectEngineFactoryServiceTest.cs} | 38 +- .../DefaultTagHelperCompletionServiceTest.cs | 4 +- .../DefaultTagHelperFactsServiceTest.cs} | 32 +- .../DefaultTextBufferProviderTest.cs | 50 +- ...tVisualStudioRazorParserIntegrationTest.cs | 66 +- .../DefaultVisualStudioRazorParserTest.cs | 54 +- ...soft.VisualStudio.Editor.Razor.Test.csproj | 1 + .../RazorDirectiveCompletionProviderTest.cs | 30 +- .../RazorSyntaxTreePartialParserTest.cs | 2 +- ...efaultVisualStudioWorkspaceAccessorTest.cs | 150 ++ .../DefaultRazorEditorFactoryServiceTest.cs | 76 +- .../DefaultVisualStudioDocumentTrackerTest.cs | 7 +- .../RazorTextViewConnectionListenerTest.cs | 6 +- ...lStudio.LanguageServices.Razor.Test.csproj | 1 + .../DefaultProjectSnapshotWorkerTest.cs | 53 - .../ProjectSnapshotWorkerQueueTest.cs | 13 +- .../TagHelperDescriptorSerializationTest.cs | 5 +- .../RazorPageGeneratorTest.cs | 5 +- ...crosoft.VisualStudio.RazorExtension.csproj | 9 +- .../RazorInfo/RazorInfoViewModel.cs | 3 +- 690 files changed, 13155 insertions(+), 7708 deletions(-) delete mode 100644 Razor.Slim.sln create mode 100644 benchmarks/Microsoft.AspNetCore.Razor.Performance/AssemblyInfo.cs rename {test => benchmarks}/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs (54%) rename {test => benchmarks}/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml (100%) create mode 100644 benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj create mode 100644 benchmarks/Microsoft.AspNetCore.Razor.Performance/TagHelperSerializationBenchmark.cs rename {test => benchmarks}/Microsoft.AspNetCore.Razor.Performance/readme.md (100%) create mode 100644 benchmarks/Microsoft.AspNetCore.Razor.Performance/taghelpers.json create mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs delete mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorCodeDocumentExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs delete mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorCodeDocumentExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props create mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets create mode 100644 src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Checksum.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs rename src/Microsoft.AspNetCore.Razor.Language/{FileSystemRazorProject.cs => DefaultRazorProjectFileSystem.cs} (68%) rename src/Microsoft.AspNetCore.Razor.Language/{FileSystemRazorProjectItem.cs => DefaultRazorProjectItem.cs} (51%) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultMetadataIdentifierFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataAttributeTargetExtension.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataIdentifierFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributePass.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributeTargetExtension.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorSourceChecksumAttributeIntermediateNode.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/IRazorFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/IRazorProjectEngineFeature.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorError.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/LegacyRazorDiagnostic.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineFeatureBase.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocumentProperties.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/VirtualRazorProjectFileSystem.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Runtime/Hosting/DefaultRazorCompiledItem.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Runtime/Hosting/IRazorSourceChecksumMetadata.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItem.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemAttribute.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemLoader.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorSourceChecksumAttribute.cs rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/DefaultTagHelperContent.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/HtmlAttributeNameAttribute.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/HtmlAttributeNotBoundAttribute.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/HtmlTargetElementAttribute.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/ITagHelper.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/ITagHelperComponent.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/NullHtmlEncoder.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/OutputElementHintAttribute.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/ReadOnlyTagHelperAttributeList.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/RestrictChildrenAttribute.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/TagHelper.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/TagHelperAttribute.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/TagHelperAttributeList.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/TagHelperComponent.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/TagHelperContent.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/TagHelperContext.cs (100%) rename src/{Microsoft.AspNetCore.Razor.Runtime => Microsoft.AspNetCore.Razor}/TagHelpers/TagHelperOutput.cs (99%) delete mode 100644 src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternal.cs delete mode 100644 src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternalFactory.cs delete mode 100644 src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternal.cs delete mode 100644 src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternalFactory.cs rename src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/{EditorSettingsManagerInternal.cs => WorkspaceEditorSettings.cs} (74%) rename src/Microsoft.CodeAnalysis.Razor.Workspaces/{RazorTemplateEngineFactoryService.cs => RazorProjectEngineFactoryService.cs} (61%) delete mode 100644 src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperFactsServiceInternal.cs rename src/{Microsoft.VisualStudio.LanguageServices.Razor/Editor => Microsoft.VisualStudio.Editor.Razor}/DefaultBraceSmartIndenterFactory.cs (70%) create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactoryFactory.cs rename src/Microsoft.VisualStudio.Editor.Razor/{DefaultTemplateEngineFactoryService.cs => DefaultProjectEngineFactoryService.cs} (76%) rename src/Microsoft.VisualStudio.Editor.Razor/{DefaultTemplateEngineFactoryServiceFactory.cs => DefaultProjectEngineFactoryServiceFactory.cs} (60%) create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolver.cs rename src/{Microsoft.VisualStudio.LanguageServices.Razor => Microsoft.VisualStudio.Editor.Razor}/DefaultTagHelperResolverFactory.cs (66%) rename src/{Microsoft.VisualStudio.LanguageServices.Razor/Editor => Microsoft.VisualStudio.Editor.Razor}/DefaultVisualStudioDocumentTracker.cs (94%) rename src/{Microsoft.VisualStudio.LanguageServices.Razor/Editor => Microsoft.VisualStudio.Editor.Razor}/DefaultVisualStudioDocumentTrackerFactory.cs (66%) create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactoryFactory.cs create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/DelegatingTemplateEngine.cs create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/TextBufferProjectService.cs create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs delete mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs create mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs create mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs delete mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioRazorParserFactory.cs delete mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/TextBufferProjectService.cs create mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolver.cs create mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolverFactory.cs delete mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/TextBufferProjectService.cs create mode 100644 test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs create mode 100644 test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineBuilderTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs rename test/Microsoft.AspNetCore.Razor.Language.Test/{FileSystemRazorProjectItemTest.cs => DefaultRazorProjectItemTest.cs} (65%) create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultMetadataIdentifierFeatureTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributePassTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributeTargetExtensionTest.cs delete mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs delete mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorErrorTest.cs delete mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/LegacyRazorDiagnosticTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineFeatureBaseTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs rename test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/{FileSystemRazorProject => DefaultRazorProjectFileSystem}/Home.cshtml (100%) rename test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/{FileSystemRazorProject => DefaultRazorProjectFileSystem}/Views/About/About.cshtml (100%) rename test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/{FileSystemRazorProject => DefaultRazorProjectFileSystem}/Views/Home/Index.cshtml (100%) rename test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/{FileSystemRazorProject => DefaultRazorProjectFileSystem}/Views/Home/Index.txt (100%) create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml rename test/{Microsoft.AspNetCore.Razor.Test.Common/Language => Microsoft.AspNetCore.Razor.Language.Test}/TestRazorProject.cs (100%) create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/VirtualRazorProjectFileSystemTest.cs delete mode 100644 test/Microsoft.AspNetCore.Razor.Performance/Configs/CoreConfig.cs delete mode 100644 test/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj delete mode 100644 test/Microsoft.AspNetCore.Razor.Performance/Program.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Test/Microsoft.AspNetCore.Razor.Test.csproj rename test/{Microsoft.AspNetCore.Razor.Runtime.Test => Microsoft.AspNetCore.Razor.Test}/TagHelpers/DefaultTagHelperContentTest.cs (100%) rename test/{Microsoft.AspNetCore.Razor.Runtime.Test => Microsoft.AspNetCore.Razor.Test}/TagHelpers/NullHtmlEncoderTest.cs (100%) rename test/{Microsoft.AspNetCore.Razor.Runtime.Test => Microsoft.AspNetCore.Razor.Test}/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs (100%) rename test/{Microsoft.AspNetCore.Razor.Runtime.Test => Microsoft.AspNetCore.Razor.Test}/TagHelpers/TagHelperAttributeListTest.cs (100%) rename test/{Microsoft.AspNetCore.Razor.Runtime.Test => Microsoft.AspNetCore.Razor.Test}/TagHelpers/TagHelperContextTest.cs (100%) rename test/{Microsoft.AspNetCore.Razor.Runtime.Test => Microsoft.AspNetCore.Razor.Test}/TagHelpers/TagHelperOutputTest.cs (96%) create mode 100644 test/Microsoft.AspNetCore.Razor.Test/xunit.runner.json create mode 100644 test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common.csproj create mode 100644 test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestRazorLanguageServices.cs create mode 100644 test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestServices.cs create mode 100644 test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspace.cs create mode 100644 test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspaceServices.cs create mode 100644 test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs rename test/{Microsoft.CodeAnalysis.Razor.Workspaces.Test/Editor/DefaultEditorSettingsManagerInternalTest.cs => Microsoft.VisualStudio.Editor.Razor.Test/DefaultEditorSettingsManagerTest.cs} (78%) rename test/Microsoft.VisualStudio.Editor.Razor.Test/{DefaultTemplateEngineFactoryServiceTest.cs => DefaultProjectEngineFactoryServiceTest.cs} (85%) rename test/{Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceInternalTest.cs => Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperFactsServiceTest.cs} (94%) create mode 100644 test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultVisualStudioWorkspaceAccessorTest.cs delete mode 100644 test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultProjectSnapshotWorkerTest.cs diff --git a/.appveyor.yml b/.appveyor.yml index c2db660b52..fd85abb361 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,19 +1,17 @@ init: - - git config --global core.autocrlf true +- git config --global core.autocrlf true branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ build_script: - - ps: .\run.ps1 default-build +- ps: .\run.ps1 default-build clone_depth: 1 environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: off -deploy: off +test: 'off' +deploy: 'off' os: Visual Studio 2017 Preview diff --git a/.gitignore b/.gitignore index 15217d4a09..a0265568eb 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ global.json BenchmarkDotNet.Artifacts/ Microsoft.VisualStudio.RazorExtension.nuget.props Microsoft.VisualStudio.RazorExtension.nuget.targets +msbuild.binlog +msbuild.log diff --git a/.travis.yml b/.travis.yml index ceaae0b3b7..28507b93b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,25 +3,25 @@ sudo: required dist: trusty env: global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 addons: apt: packages: - - libunwind8 + - libunwind8 mono: none os: - - linux - - osx +- linux +- osx osx_image: xcode8.2 branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi +- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s + /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib + /usr/local/lib/; fi script: - - ./build.sh +- ./build.sh diff --git a/Directory.Build.props b/Directory.Build.props index 0e070d36a3..8260b6f326 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,8 @@  + + @@ -13,9 +17,6 @@ true true Microsoft - - - full diff --git a/Razor.Slim.sln b/Razor.Slim.sln deleted file mode 100644 index da9145a9d5..0000000000 --- a/Razor.Slim.sln +++ /dev/null @@ -1,224 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26820.0 -MinimumVisualStudioVersion = 15.0.26730.03 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B3-49D0-B4C3-176F0F1836ED}" - ProjectSection(SolutionItems) = preProject - src\Directory.Build.props = src\Directory.Build.props - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{92463391-81BE-462B-AC3C-78C6C760741F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor", "src\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj", "{EDA30434-C567-44DC-B8B6-2566A7F77163}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime", "src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj", "{D0196096-1B01-4133-AACE-1A10A0F7247C}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F8C12DD6-659D-405A-AA27-FB22AD92A010}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - Directory.Build.props = Directory.Build.props - Directory.Build.targets = Directory.Build.targets - NuGet.config = NuGet.config - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageGenerator", "src\RazorPageGenerator\RazorPageGenerator.csproj", "{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language", "src\Microsoft.AspNetCore.Razor.Language\Microsoft.AspNetCore.Razor.Language.csproj", "{932F3C9C-A6C0-40D3-BA50-9309886242FC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language.Test", "test\Microsoft.AspNetCore.Razor.Language.Test\Microsoft.AspNetCore.Razor.Language.Test.csproj", "{969357A4-CCF1-46D9-B002-9AA072AFC75C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime.Test", "test\Microsoft.AspNetCore.Razor.Runtime.Test\Microsoft.AspNetCore.Razor.Runtime.Test.csproj", "{277AB67E-9C8D-4799-A18C-C628E70A8664}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces", "src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj", "{0F265874-C592-448B-BC4F-3430AB03E0DC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.Razor", "src\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj", "{4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor", "src\Microsoft.CodeAnalysis.Razor\Microsoft.CodeAnalysis.Razor.csproj", "{42403DAF-F0BC-4F3A-B7F2-46D7013345D8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Test", "test\Microsoft.CodeAnalysis.Razor.Test\Microsoft.CodeAnalysis.Razor.Test.csproj", "{7A8A1664-37CE-4376-81CA-1862CF5F91D9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageGenerator.Test", "test\RazorPageGenerator.Test\RazorPageGenerator.Test.csproj", "{96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.Extensions", "src\Microsoft.AspNetCore.Mvc.Razor.Extensions\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj", "{995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Test", "test\Microsoft.AspNetCore.Mvc.Razor.Extensions.Test\Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj", "{7CFD5646-A757-4498-9E01-9C8528ED60AE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.Common", "test\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj", "{078AEF36-F319-4CE2-BAA2-5B58A6536B46}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "test\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.MvcShim", "test\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj", "{8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces.Test", "test\Microsoft.CodeAnalysis.Razor.Workspaces.Test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj", "{C61AAE12-5007-4205-A220-68F354A7F235}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - DebugNoVSIX|Any CPU = DebugNoVSIX|Any CPU - Release|Any CPU = Release|Any CPU - ReleaseNoVSIX|Any CPU = ReleaseNoVSIX|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.Build.0 = Release|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {EDA30434-C567-44DC-B8B6-2566A7F77163}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.Build.0 = Release|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {D0196096-1B01-4133-AACE-1A10A0F7247C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|Any CPU.Build.0 = Release|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|Any CPU.Build.0 = Release|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {932F3C9C-A6C0-40D3-BA50-9309886242FC}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.Build.0 = Release|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {969357A4-CCF1-46D9-B002-9AA072AFC75C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.Build.0 = Debug|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.ActiveCfg = Release|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.Build.0 = Release|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {277AB67E-9C8D-4799-A18C-C628E70A8664}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.Release|Any CPU.Build.0 = Release|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {0F265874-C592-448B-BC4F-3430AB03E0DC}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.Release|Any CPU.Build.0 = Release|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.Release|Any CPU.Build.0 = Release|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.Release|Any CPU.Build.0 = Release|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {7A8A1664-37CE-4376-81CA-1862CF5F91D9}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.Debug|Any CPU.Build.0 = Debug|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.Release|Any CPU.ActiveCfg = Release|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.Release|Any CPU.Build.0 = Release|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.Debug|Any CPU.Build.0 = Debug|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.Release|Any CPU.ActiveCfg = Release|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.Release|Any CPU.Build.0 = Release|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.Release|Any CPU.Build.0 = Release|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {7CFD5646-A757-4498-9E01-9C8528ED60AE}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Debug|Any CPU.Build.0 = Debug|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Release|Any CPU.ActiveCfg = Release|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Release|Any CPU.Build.0 = Release|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Release|Any CPU.Build.0 = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Release|Any CPU.Build.0 = Release|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.Release|Any CPU.Build.0 = Release|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {C61AAE12-5007-4205-A220-68F354A7F235}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {EDA30434-C567-44DC-B8B6-2566A7F77163} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {D0196096-1B01-4133-AACE-1A10A0F7247C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {7BE58880-36AD-4CD5-9E16-2A5AFEA790EF} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {932F3C9C-A6C0-40D3-BA50-9309886242FC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {969357A4-CCF1-46D9-B002-9AA072AFC75C} = {92463391-81BE-462B-AC3C-78C6C760741F} - {277AB67E-9C8D-4799-A18C-C628E70A8664} = {92463391-81BE-462B-AC3C-78C6C760741F} - {0F265874-C592-448B-BC4F-3430AB03E0DC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {42403DAF-F0BC-4F3A-B7F2-46D7013345D8} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {7A8A1664-37CE-4376-81CA-1862CF5F91D9} = {92463391-81BE-462B-AC3C-78C6C760741F} - {96EB1BD4-B8E0-4F52-A068-BBCACA7E3F63} = {92463391-81BE-462B-AC3C-78C6C760741F} - {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} - {7CFD5646-A757-4498-9E01-9C8528ED60AE} = {92463391-81BE-462B-AC3C-78C6C760741F} - {078AEF36-F319-4CE2-BAA2-5B58A6536B46} = {92463391-81BE-462B-AC3C-78C6C760741F} - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58} = {92463391-81BE-462B-AC3C-78C6C760741F} - {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90} = {92463391-81BE-462B-AC3C-78C6C760741F} - {C61AAE12-5007-4205-A220-68F354A7F235} = {92463391-81BE-462B-AC3C-78C6C760741F} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {057E86AD-8BD3-4E03-978C-42B8A5A3C024} - EndGlobalSection -EndGlobal diff --git a/Razor.sln b/Razor.sln index 9f65845f9c..0d8570750e 100644 --- a/Razor.sln +++ b/Razor.sln @@ -53,8 +53,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Ra EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.Common", "test\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj", "{078AEF36-F319-4CE2-BAA2-5B58A6536B46}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "test\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.MvcShim", "test\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj", "{8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces.Test", "test\Microsoft.CodeAnalysis.Razor.Workspaces.Test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj", "{C61AAE12-5007-4205-A220-68F354A7F235}" @@ -75,6 +73,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.LanguageServices.Razor", "src\Microsoft.VisualStudio.Mac.LanguageServices.Razor\Microsoft.VisualStudio.Mac.LanguageServices.Razor.csproj", "{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{4595A6F1-81C5-4A0A-A3DC-81F108523AEC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "benchmarks\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{BE1CE01F-5342-4075-BD46-DB4D857BC1FE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common", "test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common\Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common.csproj", "{E41C50E7-79D0-442C-832A-E6B1A2EF4B67}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test", "test\Microsoft.AspNetCore.Razor.Test\Microsoft.AspNetCore.Razor.Test.csproj", "{93F116E1-9421-4D55-BF3E-F8DDF8F2172C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -217,14 +223,6 @@ Global {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.Release|Any CPU.Build.0 = Release|Any CPU {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU {078AEF36-F319-4CE2-BAA2-5B58A6536B46}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.Release|Any CPU.Build.0 = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU @@ -305,6 +303,30 @@ Global {95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.Release|Any CPU.Build.0 = Release|Any CPU {95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU {95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.Release|Any CPU.Build.0 = Release|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.Release|Any CPU.Build.0 = Release|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.Release|Any CPU.Build.0 = Release|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -327,7 +349,6 @@ Global {995F2FEB-65FA-4399-B1C0-16E0B3FBDB15} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {7CFD5646-A757-4498-9E01-9C8528ED60AE} = {92463391-81BE-462B-AC3C-78C6C760741F} {078AEF36-F319-4CE2-BAA2-5B58A6536B46} = {92463391-81BE-462B-AC3C-78C6C760741F} - {82C23CF8-95FF-40F7-BF50-3AD9EE21ED58} = {92463391-81BE-462B-AC3C-78C6C760741F} {8F165A3F-A18C-4649-AA08-C0E1BA5F5C90} = {92463391-81BE-462B-AC3C-78C6C760741F} {C61AAE12-5007-4205-A220-68F354A7F235} = {92463391-81BE-462B-AC3C-78C6C760741F} {F1538809-7347-45D2-A7AC-C1D89CF0BBD4} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} @@ -338,6 +359,9 @@ Global {FC684D4F-D23C-407C-9C68-E10EF3B38560} = {92463391-81BE-462B-AC3C-78C6C760741F} {FAF9986F-E086-4513-9D52-F7BF5FFCF31D} = {C0CC1E1F-1559-44DE-93A8-63259CEA2AAB} {95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} + {BE1CE01F-5342-4075-BD46-DB4D857BC1FE} = {4595A6F1-81C5-4A0A-A3DC-81F108523AEC} + {E41C50E7-79D0-442C-832A-E6B1A2EF4B67} = {92463391-81BE-462B-AC3C-78C6C760741F} + {93F116E1-9421-4D55-BF3E-F8DDF8F2172C} = {92463391-81BE-462B-AC3C-78C6C760741F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0035341D-175A-4D05-95E6-F1C2785A1E26} diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/AssemblyInfo.cs b/benchmarks/Microsoft.AspNetCore.Razor.Performance/AssemblyInfo.cs new file mode 100644 index 0000000000..32248e0d1b --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/AssemblyInfo.cs @@ -0,0 +1 @@ +[assembly: BenchmarkDotNet.Attributes.AspNetCoreBenchmark] diff --git a/test/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs similarity index 54% rename from test/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs rename to benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs index e9e0349f43..c35e1db42f 100644 --- a/test/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.cs +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/CodeGenerationBenchmark.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 System.Collections.Generic; using System.IO; using BenchmarkDotNet.Attributes; using Microsoft.AspNetCore.Mvc.Razor.Extensions; @@ -10,7 +9,6 @@ using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.AspNetCore.Razor.Performance { - [Config(typeof(CoreConfig))] public class CodeGenerationBenchmark { public CodeGenerationBenchmark() @@ -22,33 +20,22 @@ namespace Microsoft.AspNetCore.Razor.Performance } var root = current; + var fileSystem = RazorProjectFileSystem.Create(root.FullName); + + ProjectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => RazorExtensions.Register(b)); ; - var engine = RazorEngine.Create(b => { RazorExtensions.Register(b); }); - - var project = RazorProject.Create(root.FullName); - - DesignTimeTemplateEngine = new MvcRazorTemplateEngine(RazorEngine.CreateDesignTime(b => { RazorExtensions.Register(b); }), project); - RuntimeTemplateEngine = new MvcRazorTemplateEngine(RazorEngine.Create(b => { RazorExtensions.Register(b); }), project); - - var codeDocument = RuntimeTemplateEngine.CreateCodeDocument(Path.Combine(root.FullName, "MSN.cshtml")); - - Imports = codeDocument.Imports; - MSN = codeDocument.Source; + MSN = fileSystem.GetItem(Path.Combine(root.FullName, "MSN.cshtml")); } - public RazorTemplateEngine DesignTimeTemplateEngine { get; } + public RazorProjectEngine ProjectEngine { get; } - public RazorTemplateEngine RuntimeTemplateEngine { get; } - - public IReadOnlyList Imports { get; } - - public RazorSourceDocument MSN { get; } + public RazorProjectItem MSN { get; } [Benchmark(Description = "Razor Design Time Code Generation of MSN.com")] public void CodeGeneration_DesignTime_LargeStaticFile() { - var codeDocument = RazorCodeDocument.Create(MSN, Imports); - var generated = DesignTimeTemplateEngine.GenerateCode(codeDocument); + var codeDocument = ProjectEngine.ProcessDesignTime(MSN); + var generated = codeDocument.GetCSharpDocument(); if (generated.Diagnostics.Count != 0) { @@ -59,8 +46,8 @@ namespace Microsoft.AspNetCore.Razor.Performance [Benchmark(Description = "Razor Runtime Code Generation of MSN.com")] public void CodeGeneration_Runtime_LargeStaticFile() { - var codeDocument = RazorCodeDocument.Create(MSN, Imports); - var generated = RuntimeTemplateEngine.GenerateCode(codeDocument); + var codeDocument = ProjectEngine.Process(MSN); + var generated = codeDocument.GetCSharpDocument(); if (generated.Diagnostics.Count != 0) { diff --git a/test/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml b/benchmarks/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml rename to benchmarks/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj b/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj new file mode 100644 index 0000000000..e63049a74f --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp2.0 + Exe + true + true + false + + + + + + + + + Shared\RazorDiagnosticJsonConverter.cs + + + Shared\TagHelperDescriptorJsonConverter.cs + + + + + + + + + + diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/TagHelperSerializationBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Razor.Performance/TagHelperSerializationBenchmark.cs new file mode 100644 index 0000000000..bfee04164f --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/TagHelperSerializationBenchmark.cs @@ -0,0 +1,54 @@ +// 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.Text; +using BenchmarkDotNet.Attributes; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.VisualStudio.LanguageServices.Razor; +using Newtonsoft.Json; + +namespace Microsoft.AspNetCore.Razor.Performance +{ + public class TagHelperSerializationBenchmark + { + private readonly byte[] _tagHelperBuffer; + + public TagHelperSerializationBenchmark() + { + var current = new DirectoryInfo(AppContext.BaseDirectory); + while (current != null && !File.Exists(Path.Combine(current.FullName, "taghelpers.json"))) + { + current = current.Parent; + } + + var tagHelperFilePath = Path.Combine(current.FullName, "taghelpers.json"); + _tagHelperBuffer = File.ReadAllBytes(tagHelperFilePath); + } + + [Benchmark(Description = "Razor TagHelper Serialization")] + public void TagHelper_Serialization_RoundTrip() + { + var serializer = new JsonSerializer(); + serializer.Converters.Add(new RazorDiagnosticJsonConverter()); + serializer.Converters.Add(new TagHelperDescriptorJsonConverter()); + + // Deserialize from json file. + IReadOnlyList tagHelpers; + using (var stream = new MemoryStream(_tagHelperBuffer)) + using (var reader = new JsonTextReader(new StreamReader(stream))) + { + tagHelpers = serializer.Deserialize>(reader); + } + + // Serialize back to json. + using (var stream = new MemoryStream()) + using (var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096)) + { + serializer.Serialize(writer, tagHelpers); + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Performance/readme.md b/benchmarks/Microsoft.AspNetCore.Razor.Performance/readme.md similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Performance/readme.md rename to benchmarks/Microsoft.AspNetCore.Razor.Performance/readme.md diff --git a/benchmarks/Microsoft.AspNetCore.Razor.Performance/taghelpers.json b/benchmarks/Microsoft.AspNetCore.Razor.Performance/taghelpers.json new file mode 100644 index 0000000000..27dcb16038 --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Razor.Performance/taghelpers.json @@ -0,0 +1 @@ +[{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper","TagMatchingRules":[{"TagName":"*","Attributes":[{"Name":"asp-prerender-module","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-prerender-module","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.SpaServices","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-prerender-module","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.ModuleName","Diagnostics":[],"Metadata":{"Common.PropertyName":"ModuleName"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-prerender-export","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.ExportName","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExportName"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-prerender-data","IndexerNamePrefix":null,"TypeName":"System.Object","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"object Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.CustomDataParameter","Diagnostics":[],"Metadata":{"Common.PropertyName":"CustomDataParameter"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-prerender-timeout","IndexerNamePrefix":null,"TypeName":"System.Int32","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"int Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.TimeoutMillisecondsParameter","Diagnostics":[],"Metadata":{"Common.PropertyName":"TimeoutMillisecondsParameter"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper","TagMatchingRules":[{"TagName":"a","Attributes":[{"Name":"asp-action","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-controller","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-controller","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-area","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-area","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-page","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-page-handler","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page-handler","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-fragment","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fragment","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-host","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-host","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-protocol","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-protocol","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-route","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-route","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-all-route-data","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-all-route-data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"asp-route-","NameComparison":1,"Value":null,"ValueComparison":0,"DisplayName":"asp-route-...","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-action","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Action","Diagnostics":[],"Metadata":{"Common.PropertyName":"Action"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-controller","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Controller","Diagnostics":[],"Metadata":{"Common.PropertyName":"Controller"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-area","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Area","Diagnostics":[],"Metadata":{"Common.PropertyName":"Area"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Page","Diagnostics":[],"Metadata":{"Common.PropertyName":"Page"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page-handler","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.PageHandler","Diagnostics":[],"Metadata":{"Common.PropertyName":"PageHandler"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-protocol","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Protocol","Diagnostics":[],"Metadata":{"Common.PropertyName":"Protocol"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-host","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Host","Diagnostics":[],"Metadata":{"Common.PropertyName":"Host"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fragment","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Fragment","Diagnostics":[],"Metadata":{"Common.PropertyName":"Fragment"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Route","Diagnostics":[],"Metadata":{"Common.PropertyName":"Route"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":true,"IsEnum":false,"IsStringProperty":false,"Name":"asp-all-route-data","IndexerNamePrefix":"asp-route-","TypeName":"System.Collections.Generic.IDictionary","IndexerTypeName":"System.String","HasIndexer":true,"Documentation":null,"DisplayName":"System.Collections.Generic.IDictionary Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.RouteValues","Diagnostics":[],"Metadata":{"Common.PropertyName":"RouteValues"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper","TagMatchingRules":[{"TagName":"cache","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"priority","IndexerNamePrefix":null,"TypeName":"Microsoft.Extensions.Caching.Memory.CacheItemPriority?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.Extensions.Caching.Memory.CacheItemPriority? Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.Priority","Diagnostics":[],"Metadata":{"Common.PropertyName":"Priority"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryBy","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryBy"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-header","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByHeader","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByHeader"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-query","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByQuery","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByQuery"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByRoute","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByRoute"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-cookie","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByCookie","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByCookie"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"vary-by-user","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.VaryByUser","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByUser"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-on","IndexerNamePrefix":null,"TypeName":"System.DateTimeOffset?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.DateTimeOffset? Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.ExpiresOn","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresOn"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-after","IndexerNamePrefix":null,"TypeName":"System.TimeSpan?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.TimeSpan? Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.ExpiresAfter","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresAfter"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-sliding","IndexerNamePrefix":null,"TypeName":"System.TimeSpan?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.TimeSpan? Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.ExpiresSliding","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresSliding"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"enabled","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper.Enabled","Diagnostics":[],"Metadata":{"Common.PropertyName":"Enabled"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper","TagMatchingRules":[{"TagName":"distributed-cache","Attributes":[{"Name":"name","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"name","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"name","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.Name","Diagnostics":[],"Metadata":{"Common.PropertyName":"Name"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryBy","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryBy"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-header","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByHeader","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByHeader"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-query","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByQuery","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByQuery"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByRoute","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByRoute"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"vary-by-cookie","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByCookie","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByCookie"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"vary-by-user","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.VaryByUser","Diagnostics":[],"Metadata":{"Common.PropertyName":"VaryByUser"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-on","IndexerNamePrefix":null,"TypeName":"System.DateTimeOffset?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.DateTimeOffset? Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.ExpiresOn","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresOn"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-after","IndexerNamePrefix":null,"TypeName":"System.TimeSpan?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.TimeSpan? Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.ExpiresAfter","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresAfter"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"expires-sliding","IndexerNamePrefix":null,"TypeName":"System.TimeSpan?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.TimeSpan? Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.ExpiresSliding","Diagnostics":[],"Metadata":{"Common.PropertyName":"ExpiresSliding"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"enabled","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper.Enabled","Diagnostics":[],"Metadata":{"Common.PropertyName":"Enabled"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.DistributedCacheTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper","TagMatchingRules":[{"TagName":"environment","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"names","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper.Names","Diagnostics":[],"Metadata":{"Common.PropertyName":"Names"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper.Include","Diagnostics":[],"Metadata":{"Common.PropertyName":"Include"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper.Exclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"Exclude"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper","TagMatchingRules":[{"TagName":"button","Attributes":[{"Name":"asp-action","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-controller","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-controller","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-area","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-area","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-page","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-page-handler","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page-handler","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-fragment","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fragment","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-route","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-route","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-all-route-data","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-all-route-data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"asp-route-","NameComparison":1,"Value":null,"ValueComparison":0,"DisplayName":"asp-route-...","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-action","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-controller","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-controller","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-area","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-area","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-page","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-page-handler","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page-handler","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-fragment","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fragment","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-route","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-route","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-all-route-data","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-all-route-data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"image","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-route-","NameComparison":1,"Value":null,"ValueComparison":0,"DisplayName":"asp-route-...","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-action","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-controller","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-controller","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-area","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-area","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-page","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-page-handler","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-page-handler","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-fragment","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fragment","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-route","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-route","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-all-route-data","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-all-route-data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"type","NameComparison":0,"Value":"submit","ValueComparison":1,"DisplayName":"type","Diagnostics":[],"HasErrors":false},{"Name":"asp-route-","NameComparison":1,"Value":null,"ValueComparison":0,"DisplayName":"asp-route-...","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-action","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Action","Diagnostics":[],"Metadata":{"Common.PropertyName":"Action"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-controller","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Controller","Diagnostics":[],"Metadata":{"Common.PropertyName":"Controller"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-area","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Area","Diagnostics":[],"Metadata":{"Common.PropertyName":"Area"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Page","Diagnostics":[],"Metadata":{"Common.PropertyName":"Page"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page-handler","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.PageHandler","Diagnostics":[],"Metadata":{"Common.PropertyName":"PageHandler"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fragment","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Fragment","Diagnostics":[],"Metadata":{"Common.PropertyName":"Fragment"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.Route","Diagnostics":[],"Metadata":{"Common.PropertyName":"Route"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":true,"IsEnum":false,"IsStringProperty":false,"Name":"asp-all-route-data","IndexerNamePrefix":"asp-route-","TypeName":"System.Collections.Generic.IDictionary","IndexerTypeName":"System.String","HasIndexer":true,"Documentation":null,"DisplayName":"System.Collections.Generic.IDictionary Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper.RouteValues","Diagnostics":[],"Metadata":{"Common.PropertyName":"RouteValues"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper","TagMatchingRules":[{"TagName":"form","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-action","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Action","Diagnostics":[],"Metadata":{"Common.PropertyName":"Action"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-controller","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Controller","Diagnostics":[],"Metadata":{"Common.PropertyName":"Controller"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-area","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Area","Diagnostics":[],"Metadata":{"Common.PropertyName":"Area"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Page","Diagnostics":[],"Metadata":{"Common.PropertyName":"Page"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-page-handler","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.PageHandler","Diagnostics":[],"Metadata":{"Common.PropertyName":"PageHandler"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-antiforgery","IndexerNamePrefix":null,"TypeName":"System.Boolean?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.Boolean? Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Antiforgery","Diagnostics":[],"Metadata":{"Common.PropertyName":"Antiforgery"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fragment","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Fragment","Diagnostics":[],"Metadata":{"Common.PropertyName":"Fragment"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-route","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Route","Diagnostics":[],"Metadata":{"Common.PropertyName":"Route"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"method","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Method","Diagnostics":[],"Metadata":{"Common.PropertyName":"Method"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":true,"IsEnum":false,"IsStringProperty":false,"Name":"asp-all-route-data","IndexerNamePrefix":"asp-route-","TypeName":"System.Collections.Generic.IDictionary","IndexerTypeName":"System.String","HasIndexer":true,"Documentation":null,"DisplayName":"System.Collections.Generic.IDictionary Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.RouteValues","Diagnostics":[],"Metadata":{"Common.PropertyName":"RouteValues"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper","TagMatchingRules":[{"TagName":"img","Attributes":[{"Name":"asp-append-version","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-append-version","Diagnostics":[],"HasErrors":false},{"Name":"src","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"src","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper.Src","Diagnostics":[],"Metadata":{"Common.PropertyName":"Src"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-append-version","IndexerNamePrefix":null,"TypeName":"System.Boolean","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"bool Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper.AppendVersion","Diagnostics":[],"Metadata":{"Common.PropertyName":"AppendVersion"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.ImageTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper","TagMatchingRules":[{"TagName":"input","Attributes":[{"Name":"asp-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-format","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.Format","Diagnostics":[],"Metadata":{"Common.PropertyName":"Format"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"type","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.InputTypeName","Diagnostics":[],"Metadata":{"Common.PropertyName":"InputTypeName"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"value","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.Value","Diagnostics":[],"Metadata":{"Common.PropertyName":"Value"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper","TagMatchingRules":[{"TagName":"label","Attributes":[{"Name":"asp-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper","TagMatchingRules":[{"TagName":"link","Attributes":[{"Name":"asp-href-include","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-href-include","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-href-exclude","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-href-exclude","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-href","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-href-include","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-href-include","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-href-exclude","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-href-exclude","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-test-class","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-test-class","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-test-property","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-test-property","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-fallback-test-value","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-test-value","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"asp-append-version","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-append-version","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"href","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.Href","Diagnostics":[],"Metadata":{"Common.PropertyName":"Href"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-href-include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.HrefInclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"HrefInclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-href-exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.HrefExclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"HrefExclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-href","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackHref","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackHref"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-append-version","IndexerNamePrefix":null,"TypeName":"System.Boolean?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.Boolean? Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.AppendVersion","Diagnostics":[],"Metadata":{"Common.PropertyName":"AppendVersion"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-href-include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackHrefInclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackHrefInclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-href-exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackHrefExclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackHrefExclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-test-class","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackTestClass","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackTestClass"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-test-property","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackTestProperty","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackTestProperty"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-test-value","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper.FallbackTestValue","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackTestValue"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.LinkTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.OptionTagHelper","TagMatchingRules":[{"TagName":"option","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"value","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.OptionTagHelper.Value","Diagnostics":[],"Metadata":{"Common.PropertyName":"Value"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.OptionTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.OptionTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper","TagMatchingRules":[{"TagName":"form","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper","TagMatchingRules":[{"TagName":"script","Attributes":[{"Name":"asp-src-include","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-src-include","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-src-exclude","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-src-exclude","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-fallback-src","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-fallback-src-include","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-src-include","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-fallback-src-exclude","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-src-exclude","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-fallback-test","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-fallback-test","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"asp-append-version","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-append-version","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"src","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.Src","Diagnostics":[],"Metadata":{"Common.PropertyName":"Src"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-src-include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.SrcInclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"SrcInclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-src-exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.SrcExclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"SrcExclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-src","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.FallbackSrc","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackSrc"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-append-version","IndexerNamePrefix":null,"TypeName":"System.Boolean?","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.Boolean? Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.AppendVersion","Diagnostics":[],"Metadata":{"Common.PropertyName":"AppendVersion"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-src-include","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.FallbackSrcInclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackSrcInclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-src-exclude","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.FallbackSrcExclude","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackSrcExclude"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":true,"Name":"asp-fallback-test","IndexerNamePrefix":null,"TypeName":"System.String","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"string Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper.FallbackTestExpression","Diagnostics":[],"Metadata":{"Common.PropertyName":"FallbackTestExpression"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.ScriptTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper","TagMatchingRules":[{"TagName":"select","Attributes":[{"Name":"asp-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"select","Attributes":[{"Name":"asp-items","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-items","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false},{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-items","IndexerNamePrefix":null,"TypeName":"System.Collections.Generic.IEnumerable","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"System.Collections.Generic.IEnumerable Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper.Items","Diagnostics":[],"Metadata":{"Common.PropertyName":"Items"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.TextAreaTagHelper","TagMatchingRules":[{"TagName":"textarea","Attributes":[{"Name":"asp-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.TextAreaTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.TextAreaTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.TextAreaTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper","TagMatchingRules":[{"TagName":"span","Attributes":[{"Name":"asp-validation-for","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-validation-for","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":false,"IsStringProperty":false,"Name":"asp-validation-for","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper.For","Diagnostics":[],"Metadata":{"Common.PropertyName":"For"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationMessageTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationSummaryTagHelper","TagMatchingRules":[{"TagName":"div","Attributes":[{"Name":"asp-validation-summary","NameComparison":0,"Value":null,"ValueComparison":0,"DisplayName":"asp-validation-summary","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.TagHelpers","BoundAttributes":[{"Kind":"ITagHelper","IsIndexerStringProperty":false,"IsEnum":true,"IsStringProperty":false,"Name":"asp-validation-summary","IndexerNamePrefix":null,"TypeName":"Microsoft.AspNetCore.Mvc.Rendering.ValidationSummary","IndexerTypeName":null,"HasIndexer":false,"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.Rendering.ValidationSummary Microsoft.AspNetCore.Mvc.TagHelpers.ValidationSummaryTagHelper.ValidationSummary","Diagnostics":[],"Metadata":{"Common.PropertyName":"ValidationSummary"},"HasErrors":false}],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationSummaryTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.TagHelpers.ValidationSummaryTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper","TagMatchingRules":[{"TagName":"body","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.Razor","BoundAttributes":[],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper","TagMatchingRules":[{"TagName":"head","Attributes":[],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.Razor","BoundAttributes":[],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper"},"HasErrors":false},{"Kind":"ITagHelper","Name":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper","TagMatchingRules":[{"TagName":"*","Attributes":[{"Name":"itemid","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"itemid","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"a","Attributes":[{"Name":"href","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"applet","Attributes":[{"Name":"archive","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"archive","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"area","Attributes":[{"Name":"href","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"audio","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"base","Attributes":[{"Name":"href","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"blockquote","Attributes":[{"Name":"cite","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"cite","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"button","Attributes":[{"Name":"formaction","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"formaction","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"del","Attributes":[{"Name":"cite","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"cite","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"embed","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"form","Attributes":[{"Name":"action","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"action","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"html","Attributes":[{"Name":"manifest","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"manifest","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"iframe","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"img","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"img","Attributes":[{"Name":"srcset","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"srcset","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"input","Attributes":[{"Name":"formaction","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"formaction","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"ins","Attributes":[{"Name":"cite","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"cite","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"link","Attributes":[{"Name":"href","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"href","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"menuitem","Attributes":[{"Name":"icon","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"icon","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"object","Attributes":[{"Name":"archive","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"archive","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"object","Attributes":[{"Name":"data","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"data","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"q","Attributes":[{"Name":"cite","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"cite","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"script","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"source","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"source","Attributes":[{"Name":"srcset","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"srcset","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"track","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":2,"Diagnostics":[],"HasErrors":false},{"TagName":"video","Attributes":[{"Name":"src","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"src","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false},{"TagName":"video","Attributes":[{"Name":"poster","NameComparison":0,"Value":"~/","ValueComparison":2,"DisplayName":"poster","Diagnostics":[],"HasErrors":false}],"ParentTag":null,"TagStructure":0,"Diagnostics":[],"HasErrors":false}],"AssemblyName":"Microsoft.AspNetCore.Mvc.Razor","BoundAttributes":[],"AllowedChildTags":[],"Documentation":null,"DisplayName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper","TagOutputHint":null,"Diagnostics":[],"Metadata":{"Runtime.Name":"ITagHelper","Common.TypeName":"Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper"},"HasErrors":false}] \ No newline at end of file diff --git a/build/VSIX.targets b/build/VSIX.targets index 7cd27381f2..e5114e4b03 100644 --- a/build/VSIX.targets +++ b/build/VSIX.targets @@ -8,6 +8,7 @@ $(BuildDir)$(VSIXName).vsix $(BuildDir)$(VSIXName).json $(RepositoryRoot)tooling\$(VSIXName)\$(VSIXName).csproj + $(BuildDir)$(VSIXName).pdb shipoob @@ -27,6 +28,13 @@ $(VSIXName) + + SymbolsFile + $(VSIXArtifactCategory) + $(VSIXName).vsix + full + + VsixPackageManifestFile $(VSIXArtifactCategory) @@ -36,6 +44,7 @@ + @@ -93,6 +102,7 @@ /flp:LogFile=$(VSIXLogFilePath); /p:DeployExtension=false; /p:TargetVSIXContainer=$(VSIXOutputPath); + /p:SymbolsPublishDir=$(BuildDir); /p:Configuration=$(Configuration);" /> diff --git a/build/dependencies.props b/build/dependencies.props index 1fd2f19bc2..bd52ff645b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,16 +1,17 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 0.10.11 - 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.3.1 - 2.3.1 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview2-15704 + 2.1.0-preview2-30077 + 2.1.0-preview2-30106 + 2.1.0-preview2-30106 + 2.4.0 + 2.4.0 + 2.1.0-preview2-30106 + 2.1.0-preview2-30106 2.1.0-preview2-25711-01 2.1.0-preview1-27965 2.1.0-preview1-27965 @@ -33,7 +34,7 @@ 7.10.6071 1.3.7 4.7.49 - 2.0.0 + 2.0.1 10.0.1 1.1.92 4.5.0-preview1-26016-05 @@ -52,5 +53,6 @@ 2.3.1 2.3.1 + diff --git a/build/repo.props b/build/repo.props index a3a5fbdbc0..091758faa3 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,12 +1,16 @@  + + true + + + - diff --git a/korebuild-lock.txt b/korebuild-lock.txt index d7ea9c33bf..02dc92cb26 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,7 +1,2 @@ -<<<<<<< HEAD -version:2.1.0-preview2-15696 -commithash:85ae1301d1a2ff19aab6837cc657699ccca719b5 -======= version:2.1.0-preview2-15704 commithash:21fdd9f5254226f407a2b4b3ef963693c2fd7998 ->>>>>>> Update KoreBuild diff --git a/shared/Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources/CaseSensitiveBoundAttributeComparer.cs b/shared/Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources/CaseSensitiveBoundAttributeComparer.cs index a385327fc8..4f7acca92b 100644 --- a/shared/Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources/CaseSensitiveBoundAttributeComparer.cs +++ b/shared/Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources/CaseSensitiveBoundAttributeComparer.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.IO; using Microsoft.AspNetCore.Html; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing { @@ -35,11 +34,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing public int GetHashCode(TagHelperAttribute attribute) { - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(attribute.GetHashCode()); - hashCodeCombiner.Add(attribute.Name, StringComparer.Ordinal); - - return hashCodeCombiner.CombinedHash; + return attribute.GetHashCode(); } private string GetString(object value) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 25771e8046..83534ef969 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,7 +8,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/CSharpIdentifier.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/CSharpIdentifier.cs index dc3183ba1d..4e34345903 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/CSharpIdentifier.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/CSharpIdentifier.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.Globalization; using System.Text; @@ -8,6 +9,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { internal static class CSharpIdentifier { + private const string CshtmlExtension = ".cshtml"; + public static string GetClassNameFromPath(string path) { if (string.IsNullOrEmpty(path)) @@ -15,6 +18,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return path; } + if (path.EndsWith(CshtmlExtension, StringComparison.OrdinalIgnoreCase)) + { + path = path.Substring(0, path.Length - CshtmlExtension.Length); + } + return SanitizeClassName(path); } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/InjectDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/InjectDirective.cs index c5e84d3ede..c1c348f8a9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/InjectDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/InjectDirective.cs @@ -24,8 +24,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X builder.Description = Resources.InjectDirective_Description; }); - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new Pass()); builder.AddTargetExtension(new InjectTargetExtension()); @@ -99,5 +104,20 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + builder.AddTargetExtension(new InjectTargetExtension()); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj index 2935e1b9ca..c6b3d3e212 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj @@ -13,10 +13,6 @@ - - - - diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs index 572d1b9ccb..0c5859ce22 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/ModelDirective.cs @@ -21,10 +21,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X builder.Description = Resources.ModelDirective_Description; }); - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); - builder.Features.Add(new Pass(builder.DesignTime)); + builder.Features.Add(new Pass()); return builder; } @@ -59,13 +64,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass { - private readonly bool _designTime; - - public Pass(bool designTime) - { - _designTime = designTime; - } - // Runs after the @inherits directive public override int Order => 5; @@ -74,7 +72,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var visitor = new Visitor(); var modelType = GetModelType(documentNode, visitor); - if (_designTime) + if (documentNode.Options.DesignTime) { // Alias the TModel token to a known type. // This allows design time compilation to succeed for Razor files where the token isn't replaced. @@ -128,5 +126,19 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs new file mode 100644 index 0000000000..254c57c1c4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcImportProjectFeature.cs @@ -0,0 +1,89 @@ +// 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.Text; +using Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X +{ + internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private const string ImportsFileName = "_ViewImports.cshtml"; + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var imports = new List(); + AddDefaultDirectivesImport(imports); + + // We add hierarchical imports second so any default directive imports can be overridden. + AddHierarchicalImports(projectItem, imports); + + return imports; + } + + // Internal for testing + internal static void AddDefaultDirectivesImport(List imports) + { + imports.Add(DefaultDirectivesProjectItem.Instance); + } + + // Internal for testing + internal void AddHierarchicalImports(RazorProjectItem projectItem, List imports) + { + // We want items in descending order. FindHierarchicalItems returns items in ascending order. + var importProjectItems = ProjectEngine.FileSystem.FindHierarchicalItems(projectItem.FilePath, ImportsFileName).Reverse(); + imports.AddRange(importProjectItems); + } + + private class DefaultDirectivesProjectItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultDirectivesProjectItem() + { + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Collections.Generic +@using System.Linq +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Mvc +@using Microsoft.AspNetCore.Mvc.Rendering +@using Microsoft.AspNetCore.Mvc.ViewFeatures +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json +@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component +@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url +@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor +"; + var contentBytes = Encoding.UTF8.GetBytes(content); + + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultDirectivesProjectItem Instance { get; } = new DefaultDirectivesProjectItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcRazorTemplateEngine.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcRazorTemplateEngine.cs index 442eddddbc..497d173e4e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcRazorTemplateEngine.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcRazorTemplateEngine.cs @@ -26,13 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X Options.DefaultImports = GetDefaultImports(); } - /// public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem) { - var codeDocument = base.CreateCodeDocument(projectItem); - codeDocument.SetRelativePath(projectItem.FilePath); - - return codeDocument; + return base.CreateCodeDocument(projectItem); } // Internal for testing. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcViewDocumentClassifierPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcViewDocumentClassifierPass.cs index 6fb18e2641..45cc3c1cb9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcViewDocumentClassifierPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/MvcViewDocumentClassifierPass.cs @@ -20,12 +20,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X ClassDeclarationIntermediateNode @class, MethodDeclarationIntermediateNode method) { - var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath; - base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); @namespace.Content = "AspNetCore"; + var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage"; @class.Modifiers.Clear(); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorCodeDocumentExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorCodeDocumentExtensions.cs deleted file mode 100644 index 487ad3d2dc..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorCodeDocumentExtensions.cs +++ /dev/null @@ -1,34 +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; - -namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X -{ - internal static class RazorCodeDocumentExtensions - { - private const string RelativePathKey = "relative-path"; - - public static string GetRelativePath(this RazorCodeDocument document) - { - if (document == null) - { - throw new ArgumentNullException(nameof(document)); - } - - return document.Items[RelativePathKey] as string; - } - - - public static void SetRelativePath(this RazorCodeDocument document, string relativePath) - { - if (document == null) - { - throw new ArgumentNullException(nameof(document)); - } - - document.Items[RelativePathKey] = relativePath; - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs index 341bb5d47a..e8b4f0018c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensions.cs @@ -9,8 +9,54 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { public static class RazorExtensions { + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + InjectDirective.Register(builder); + ModelDirective.Register(builder); + + FunctionsDirective.Register(builder); + InheritsDirective.Register(builder); + + // Register section directive with the 1.x compatible target extension. + builder.AddDirective(SectionDirective.Directive); + builder.Features.Add(new SectionDirectivePass()); + builder.AddTargetExtension(new LegacySectionTargetExtension()); + + builder.AddTargetExtension(new TemplateTargetExtension() + { + TemplateTypeName = "global::Microsoft.AspNetCore.Mvc.Razor.HelperResult", + }); + + builder.Features.Add(new ModelExpressionPass()); + builder.Features.Add(new MvcViewDocumentClassifierPass()); + + builder.SetImportFeature(new MvcImportProjectFeature()); + } + + public static void RegisterViewComponentTagHelpers(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.Features.Add(new ViewComponentTagHelperPass()); + builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension()); + } + + #region Obsolete public static void Register(IRazorEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + EnsureDesignTime(builder); InjectDirective.Register(builder); @@ -35,6 +81,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public static void RegisterViewComponentTagHelpers(IRazorEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + EnsureDesignTime(builder); builder.Features.Add(new ViewComponentTagHelperPass()); @@ -50,5 +101,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X throw new NotSupportedException(Resources.RuntimeCodeGenerationNotSupported); } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensionsDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensionsDiagnosticFactory.cs index 578de74478..af883af3d4 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensionsDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/RazorExtensionsDiagnosticFactory.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { private const string DiagnosticPrefix = "RZ"; - public static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod = + internal static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3900", () => ViewComponentResources.ViewComponent_CannotFindMethod, @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods = + internal static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3901", () => ViewComponentResources.ViewComponent_AmbiguousMethods, @@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask = + internal static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3902", () => ViewComponentResources.ViewComponent_AsyncMethod_ShouldReturnTask, @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue = + internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3903", () => ViewComponentResources.ViewComponent_SyncMethod_ShouldReturnValue, @@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask = + internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3904", () => ViewComponentResources.ViewComponent_SyncMethod_CannotReturnTask, diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs index ef02120f02..cf5549d0f5 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/AssemblyAttributeInjectionPass.cs @@ -14,6 +14,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + if (documentNode.Options.DesignTime) + { + return; + } + var @namespace = documentNode.FindPrimaryNamespace(); if (@namespace == null || string.IsNullOrEmpty(@namespace.Content)) { @@ -29,8 +34,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } var generatedTypeName = $"{@namespace.Content}.{@class.ClassName}"; - var path = codeDocument.GetRelativePath(); - var escapedPath = EscapeAsVerbatimLiteral(path); + + // The MVC attributes require a relative path to be specified so that we can make a view engine path. + // We can't use a rooted path because we don't know what the project root is. + // + // If we can't sanitize the path, we'll just set it to null and let is blow up at runtime - we don't + // want to create noise if this code has to run in some unanticipated scenario. + var escapedPath = MakeVerbatimStringLiteral(ConvertToViewEnginePath(codeDocument.Source.RelativePath)); string attribute; if (documentNode.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind) @@ -40,7 +50,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions else if (documentNode.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind && PageDirective.TryGetPageDirective(documentNode, out var pageDirective)) { - var escapedRoutePrefix = EscapeAsVerbatimLiteral(pageDirective.RouteTemplate); + var escapedRoutePrefix = MakeVerbatimStringLiteral(pageDirective.RouteTemplate); attribute = $"[assembly:{RazorPageAttribute}({escapedPath}, typeof({generatedTypeName}), {escapedRoutePrefix})]"; } else @@ -61,7 +71,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions documentNode.Children.Insert(index, pageAttribute); } - private static string EscapeAsVerbatimLiteral(string value) + private static string MakeVerbatimStringLiteral(string value) { if (value == null) { @@ -71,5 +81,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions value = value.Replace("\"", "\"\""); return $"@\"{value}\""; } + + private static string ConvertToViewEnginePath(string relativePath) + { + if (string.IsNullOrEmpty(relativePath)) + { + return null; + } + + // Checking for both / and \ because a \ will become a /. + if (!relativePath.StartsWith("/") && !relativePath.StartsWith("\\")) + { + relativePath = "/" + relativePath; + } + + relativePath = relativePath.Replace('\\', '/'); + return relativePath; + } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/CSharpIdentifier.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/CSharpIdentifier.cs index cd2661a70c..e1ca2e343e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/CSharpIdentifier.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/CSharpIdentifier.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.Globalization; using System.Text; @@ -8,6 +9,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { internal static class CSharpIdentifier { + private const string CshtmlExtension = ".cshtml"; + public static string GetClassNameFromPath(string path) { if (string.IsNullOrEmpty(path)) @@ -15,6 +18,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return path; } + if (path.EndsWith(CshtmlExtension, StringComparison.OrdinalIgnoreCase)) + { + path = path.Substring(0, path.Length - CshtmlExtension.Length); + } + return SanitizeClassName(path); } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs new file mode 100644 index 0000000000..eeb3246f74 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ExtensionInitializer.cs @@ -0,0 +1,15 @@ +// 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 Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + internal class ExtensionInitializer : RazorExtensionInitializer + { + public override void Initialize(RazorProjectEngineBuilder builder) + { + RazorExtensions.Register(builder); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectDirective.cs index 81f1d5b834..41bb56b57d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InjectDirective.cs @@ -24,8 +24,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Description = Resources.InjectDirective_Description; }); - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new Pass()); builder.AddTargetExtension(new InjectTargetExtension()); @@ -99,5 +104,20 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + builder.AddTargetExtension(new InjectTargetExtension()); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs index 9f271faf82..1ae0a72210 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs @@ -15,6 +15,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + if (documentNode.Options.DesignTime) + { + return; + } + var walker = new Visitor(); walker.VisitDocument(documentNode); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj index 497df54e0f..401d07c030 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj @@ -13,7 +13,8 @@ - + + diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs index 17d98d72b4..b6e2955f22 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/ModelDirective.cs @@ -21,10 +21,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Description = Resources.ModelDirective_Description; }); - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); - builder.Features.Add(new Pass(builder.DesignTime)); + builder.Features.Add(new Pass()); return builder; } @@ -66,13 +71,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass { - private readonly bool _designTime; - - public Pass(bool designTime) - { - _designTime = designTime; - } - // Runs after the @inherits directive public override int Order => 5; @@ -81,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var visitor = new Visitor(); var modelType = GetModelType(documentNode, visitor); - if (_designTime) + if (documentNode.Options.DesignTime) { // Alias the TModel token to a known type. // This allows design time compilation to succeed for Razor files where the token isn't replaced. @@ -135,5 +133,19 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs new file mode 100644 index 0000000000..5c6ee7361d --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcImportProjectFeature.cs @@ -0,0 +1,91 @@ +// 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.Text; +using Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private const string ImportsFileName = "_ViewImports.cshtml"; + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var imports = new List(); + AddDefaultDirectivesImport(imports); + + // We add hierarchical imports second so any default directive imports can be overridden. + AddHierarchicalImports(projectItem, imports); + + return imports; + } + + // Internal for testing + internal static void AddDefaultDirectivesImport(List imports) + { + imports.Add(DefaultDirectivesProjectItem.Instance); + } + + // Internal for testing + internal void AddHierarchicalImports(RazorProjectItem projectItem, List imports) + { + // We want items in descending order. FindHierarchicalItems returns items in ascending order. + var importProjectItems = ProjectEngine.FileSystem.FindHierarchicalItems(projectItem.FilePath, ImportsFileName).Reverse(); + imports.AddRange(importProjectItems); + } + + private class DefaultDirectivesProjectItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultDirectivesProjectItem() + { + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Collections.Generic +@using System.Linq +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Mvc +@using Microsoft.AspNetCore.Mvc.Rendering +@using Microsoft.AspNetCore.Mvc.ViewFeatures +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html +@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json +@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component +@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url +@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor +"; + var contentBytes = Encoding.UTF8.GetBytes(content); + + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultDirectivesProjectItem Instance { get; } = new DefaultDirectivesProjectItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcRazorTemplateEngine.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcRazorTemplateEngine.cs index c30ad4a037..f278b20a45 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcRazorTemplateEngine.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcRazorTemplateEngine.cs @@ -26,13 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions Options.DefaultImports = GetDefaultImports(); } - /// public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem) { - var codeDocument = base.CreateCodeDocument(projectItem); - codeDocument.SetRelativePath(projectItem.FilePath); - - return codeDocument; + return base.CreateCodeDocument(projectItem); } // Internal for testing. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs index ac524144d1..2378f23591 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs @@ -20,12 +20,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions ClassDeclarationIntermediateNode @class, MethodDeclarationIntermediateNode method) { - var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath; - base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); @namespace.Content = "AspNetCore"; + var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage"; @class.Modifiers.Clear(); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs index b235f2eabb..b0c197f42b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Description = Resources.NamespaceDirective_Description; }); - public static void Register(IRazorEngineBuilder builder) + public static void Register(RazorProjectEngineBuilder builder) { if (builder == null) { @@ -66,22 +66,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return; } - if (TryComputeNamespace(codeDocument.Source.FilePath, directive, out var computedNamespace)) - { - // Beautify the class name since we're using a hierarchy for namespaces. - var @class = visitor.FirstClass; - var prefix = CSharpIdentifier.SanitizeClassName(Path.GetFileNameWithoutExtension(codeDocument.Source.FilePath)); - if (@class != null && documentNode.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind) - { - @class.ClassName = prefix + "_Page"; - } - else if (@class != null && documentNode.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind) - { - @class.ClassName = prefix + "_View"; - } - } - - @namespace.Content = computedNamespace; + @namespace.Content = GetNamespace(codeDocument.Source.FilePath, directive); } } @@ -92,7 +77,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // // In the event that these two source either don't have FileNames set or don't follow a coherent hierarchy, // we will just use the namespace verbatim. - internal static bool TryComputeNamespace(string source, DirectiveIntermediateNode directive, out string @namespace) + internal static string GetNamespace(string source, DirectiveIntermediateNode directive) { var directiveSource = NormalizeDirectory(directive.Source?.FilePath); @@ -100,15 +85,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions if (string.IsNullOrEmpty(baseNamespace)) { // The namespace directive was incomplete. - @namespace = string.Empty; - return false; + return string.Empty; } if (string.IsNullOrEmpty(source) || directiveSource == null) { // No sources, can't compute a suffix. - @namespace = baseNamespace; - return false; + return baseNamespace; } // We're specifically using OrdinalIgnoreCase here because Razor treats all paths as case-insensitive. @@ -116,8 +99,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions source.Length <= directiveSource.Length) { // The imports are not from the directory hierarchy, can't compute a suffix. - @namespace = baseNamespace; - return false; + return baseNamespace; } // OK so that this point we know that the 'imports' file containing this directive is in the directory @@ -136,8 +118,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Append(CSharpIdentifier.SanitizeClassName(segments[i])); } - @namespace = builder.ToString(); - return true; + return builder.ToString(); } // We want to normalize the path of the file containing the '@namespace' directive to just the containing @@ -205,5 +186,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions base.VisitDirective(node); } } + + #region Obsolete + public static void Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/PageDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/PageDirective.cs index 5f617a1ebd..cd3624f435 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/PageDirective.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/PageDirective.cs @@ -32,8 +32,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public IntermediateNode DirectiveNode { get; } - public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); return builder; } @@ -98,5 +103,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions } } } + + #region Obsolete + public static IRazorEngineBuilder Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + return builder; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs index 6a4431ff38..b5caca17dd 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/Properties/AssemblyInfo.cs @@ -2,5 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Mvc.Razor.Extensions; +using Microsoft.AspNetCore.Razor.Language; + +[assembly: ProvideRazorExtensionInitializer("MVC-2.0", typeof(ExtensionInitializer))] +[assembly: ProvideRazorExtensionInitializer("MVC-2.1", typeof(ExtensionInitializer))] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorCodeDocumentExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorCodeDocumentExtensions.cs deleted file mode 100644 index 2e6c220bcc..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorCodeDocumentExtensions.cs +++ /dev/null @@ -1,34 +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; - -namespace Microsoft.AspNetCore.Mvc.Razor.Extensions -{ - internal static class RazorCodeDocumentExtensions - { - private const string RelativePathKey = "relative-path"; - - public static string GetRelativePath(this RazorCodeDocument document) - { - if (document == null) - { - throw new ArgumentNullException(nameof(document)); - } - - return document.Items[RelativePathKey] as string; - } - - - public static void SetRelativePath(this RazorCodeDocument document, string relativePath) - { - if (document == null) - { - throw new ArgumentNullException(nameof(document)); - } - - document.Items[RelativePathKey] = relativePath; - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs index fc1ad0c162..abf1b447f0 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.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 Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Extensions; @@ -8,8 +9,49 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { public static class RazorExtensions { + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + InjectDirective.Register(builder); + ModelDirective.Register(builder); + NamespaceDirective.Register(builder); + PageDirective.Register(builder); + + FunctionsDirective.Register(builder); + InheritsDirective.Register(builder); + SectionDirective.Register(builder); + + builder.Features.Add(new ViewComponentTagHelperDescriptorProvider()); + + builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension()); + builder.AddTargetExtension(new TemplateTargetExtension() + { + TemplateTypeName = "global::Microsoft.AspNetCore.Mvc.Razor.HelperResult", + }); + + builder.Features.Add(new ModelExpressionPass()); + builder.Features.Add(new PagesPropertyInjectionPass()); + builder.Features.Add(new ViewComponentTagHelperPass()); + builder.Features.Add(new RazorPageDocumentClassifierPass()); + builder.Features.Add(new MvcViewDocumentClassifierPass()); + builder.Features.Add(new AssemblyAttributeInjectionPass()); + builder.Features.Add(new InstrumentationPass()); + + builder.SetImportFeature(new MvcImportProjectFeature()); + } + + #region Obsolete public static void Register(IRazorEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + InjectDirective.Register(builder); ModelDirective.Register(builder); NamespaceDirective.Register(builder); @@ -37,5 +79,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions builder.Features.Add(new InstrumentationPass()); } } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensionsDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensionsDiagnosticFactory.cs index 565d4caa0b..1e2f6a1f7e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensionsDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensionsDiagnosticFactory.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { private const string DiagnosticPrefix = "RZ"; - public static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod = + internal static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3900", () => ViewComponentResources.ViewComponent_CannotFindMethod, @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods = + internal static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3901", () => ViewComponentResources.ViewComponent_AmbiguousMethods, @@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask = + internal static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3902", () => ViewComponentResources.ViewComponent_AsyncMethod_ShouldReturnTask, @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue = + internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3903", () => ViewComponentResources.ViewComponent_SyncMethod_ShouldReturnValue, @@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask = + internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3904", () => ViewComponentResources.ViewComponent_SyncMethod_CannotReturnTask, @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return diagnostic; } - public static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported = + internal static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}3905", () => Resources.PageDirectiveCannotBeImported, diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs index c69cd9ac16..a4959dded2 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs @@ -24,13 +24,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions ClassDeclarationIntermediateNode @class, MethodDeclarationIntermediateNode method) { - var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath; - base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); @namespace.Content = "AspNetCore"; @class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page"; + + var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.Modifiers.Clear(); diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props new file mode 100644 index 0000000000..ef8766cdf2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.props @@ -0,0 +1,35 @@ + + + + + MVC-2.1 + + + <_MvcExtensionAssemblyPath Condition="'$(_MvcExtensionAssemblyPath)'==''">$(MSBuildThisFileDirectory)..\..\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + + + + + + MVC-2.1;$(CustomRazorExtension) + + + + + + Microsoft.AspNetCore.Mvc.Razor.Extensions + $(_MvcExtensionAssemblyPath) + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets new file mode 100644 index 0000000000..61a0e7a8dc --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.targets @@ -0,0 +1,9 @@ + + + + + true + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs index 14ea34c493..84a83b3e8c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; namespace Microsoft.AspNetCore.Razor.Language diff --git a/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs new file mode 100644 index 0000000000..b93323e018 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.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; +using System.Reflection; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class AssemblyExtension : RazorExtension + { + public AssemblyExtension(string extensionName, Assembly assembly) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + ExtensionName = extensionName; + Assembly = assembly; + } + + public override string ExtensionName { get; } + + public Assembly Assembly { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Checksum.cs b/src/Microsoft.AspNetCore.Razor.Language/Checksum.cs new file mode 100644 index 0000000000..57834739e6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Checksum.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.Text; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal static class Checksum + { + public 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/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs index 1469ec377c..772c5a0fab 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Security.Cryptography; using System.Text; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -67,28 +68,52 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration if (!Context.Options.SuppressChecksum) { // See http://msdn.microsoft.com/en-us/library/system.codedom.codechecksumpragma.checksumalgorithmid.aspx - const string Sha1AlgorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}"; + // And https://github.com/dotnet/roslyn/blob/614299ff83da9959fa07131c6d0ffbc58873b6ae/src/Compilers/Core/Portable/PEWriter/DebugSourceDocument.cs#L67 + // + // We only support algorithms that the debugger understands, which is currently SHA1 and SHA256. + + string algorithmId; + var algorithm = Context.SourceDocument.GetChecksumAlgorithm(); + if (string.Equals(algorithm, HashAlgorithmName.SHA256.Name, StringComparison.Ordinal)) + { + algorithmId = "{8829d00f-11b8-4213-878b-770e8597ac16}"; + } + else if (string.Equals(algorithm, HashAlgorithmName.SHA1.Name, StringComparison.Ordinal) || + + // In 2.0, we didn't actually expose the name of the algorithm, so it's possible we could get null here. + // If that's the case, we just assume SHA1 since that's the only thing we supported in 2.0. + algorithm == null) + { + algorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}"; + } + else + { + var supportedAlgorithms = string.Join(" ", new string[] + { + HashAlgorithmName.SHA1.Name, + HashAlgorithmName.SHA256.Name + }); + + var message = Resources.FormatUnsupportedChecksumAlgorithm( + algorithm, + supportedAlgorithms, + nameof(RazorCodeGenerationOptions) + "." + nameof(RazorCodeGenerationOptions.SuppressChecksum), + bool.TrueString); + throw new InvalidOperationException(message); + } var sourceDocument = Context.SourceDocument; - var checksum = sourceDocument.GetChecksum(); - var fileHashBuilder = new StringBuilder(checksum.Length * 2); - foreach (var value in checksum) - { - fileHashBuilder.Append(value.ToString("x2")); - } - - var bytes = fileHashBuilder.ToString(); - - if (!string.IsNullOrEmpty(bytes)) + var checksum = Checksum.BytesToString(sourceDocument.GetChecksum()); + if (!string.IsNullOrEmpty(checksum)) { Context.CodeWriter .Write("#pragma checksum \"") .Write(sourceDocument.FilePath) .Write("\" \"") - .Write(Sha1AlgorithmId) + .Write(algorithmId) .Write("\" \"") - .Write(bytes) + .Write(checksum) .WriteLine("\""); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultDirectiveSyntaxTreePass.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultDirectiveSyntaxTreePass.cs index d41b998ca9..54c733e0f1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultDirectiveSyntaxTreePass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultDirectiveSyntaxTreePass.cs @@ -45,11 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Language { var directiveStart = block.Children.First(child => !child.IsBlock && ((Span)child).Kind == SpanKindInternal.Transition).Start; var errorLength = /* @ */ 1 + SectionDirective.Directive.Directive.Length; - var error = RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Sections_Cannot_Be_Nested(LegacyResources.SectionExample_CS), - directiveStart, - errorLength)); + var error = RazorDiagnosticFactory.CreateParsing_SectionsCannotBeNested(new SourceSpan(directiveStart, errorLength)); chunkGenerator.Diagnostics.Add(error); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs new file mode 100644 index 0000000000..92778322d7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultImportProjectFeature.cs @@ -0,0 +1,13 @@ +// 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 +{ + internal class DefaultImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + public IReadOnlyList GetImports(RazorProjectItem projectItem) => Array.Empty(); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptions.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptions.cs index c7a9fcf673..e521141628 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptions.cs @@ -5,12 +5,18 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRazorCodeGenerationOptions : RazorCodeGenerationOptions { - public DefaultRazorCodeGenerationOptions(bool indentWithTabs, int indentSize, bool designTime, bool suppressChecksum) + public DefaultRazorCodeGenerationOptions( + bool indentWithTabs, + int indentSize, + bool designTime, + bool suppressChecksum, + bool supressMetadataAttributes) { IndentWithTabs = indentWithTabs; IndentSize = indentSize; DesignTime = designTime; SuppressChecksum = suppressChecksum; + SuppressMetadataAttributes = supressMetadataAttributes; } public override bool DesignTime { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs index 79acdf8d44..8dd095a04e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsBuilder.cs @@ -1,26 +1,45 @@ // 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 { internal class DefaultRazorCodeGenerationOptionsBuilder : RazorCodeGenerationOptionsBuilder { - public DefaultRazorCodeGenerationOptionsBuilder(bool designTime) + private bool _designTime; + + public DefaultRazorCodeGenerationOptionsBuilder(RazorConfiguration configuration) { - DesignTime = designTime; + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } } - public override bool DesignTime { get; } + public DefaultRazorCodeGenerationOptionsBuilder(bool designTime) + { + _designTime = designTime; + } + + public override RazorConfiguration Configuration { get; } + + public override bool DesignTime => _designTime; public override int IndentSize { get; set; } = 4; public override bool IndentWithTabs { get; set; } public override bool SuppressChecksum { get; set; } - + public override RazorCodeGenerationOptions Build() { - return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, SuppressChecksum); + return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, SuppressChecksum, SuppressMetadataAttributes); + } + + public override void SetDesignTime(bool designTime) + { + _designTime = designTime; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..db2a25b81f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFactoryProjectFeature.cs @@ -0,0 +1,32 @@ +// 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.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorCodeGenerationOptionsFactoryProjectFeature : RazorProjectEngineFeatureBase, IRazorCodeGenerationOptionsFactoryProjectFeature + { + private IConfigureRazorCodeGenerationOptionsFeature[] _configureOptions; + + protected override void OnInitialized() + { + _configureOptions = ProjectEngine.EngineFeatures.OfType().ToArray(); + } + + public RazorCodeGenerationOptions Create(Action configure) + { + var builder = new DefaultRazorCodeGenerationOptionsBuilder(ProjectEngine.Configuration); + configure?.Invoke(builder); + + for (var i = 0; i < _configureOptions.Length; i++) + { + _configureOptions[i].Configure(builder); + } + + var options = builder.Build(); + return options; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs index 70ca502788..1c915364d7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCodeGenerationOptionsFeature.cs @@ -5,7 +5,9 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorCodeGenerationOptionsFeature : RazorEngineFeatureBase, IRazorCodeGenerationOptionsFeature +#pragma warning restore CS0618 // Type or member is obsolete { private readonly bool _designTime; private IConfigureRazorCodeGenerationOptionsFeature[] _configureOptions; @@ -22,15 +24,15 @@ namespace Microsoft.AspNetCore.Razor.Language public RazorCodeGenerationOptions GetOptions() { - var builder = new DefaultRazorCodeGenerationOptionsBuilder(_designTime); + return _designTime ? RazorCodeGenerationOptions.CreateDesignTime(ConfigureOptions) : RazorCodeGenerationOptions.Create(ConfigureOptions); + } + + private void ConfigureOptions(RazorCodeGenerationOptionsBuilder builder) + { for (var i = 0; i < _configureOptions.Length; i++) { _configureOptions[i].Configure(builder); } - - var options = builder.Build(); - - return options; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorDiagnostic.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorDiagnostic.cs index a8bc704e7a..40f558df26 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorDiagnostic.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorDiagnostic.cs @@ -8,26 +8,29 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRazorDiagnostic : RazorDiagnostic { - private readonly RazorDiagnosticDescriptor _descriptor; - private readonly object[] _args; - internal DefaultRazorDiagnostic(RazorDiagnosticDescriptor descriptor, SourceSpan span, object[] args) { - _descriptor = descriptor; + Descriptor = descriptor; Span = span; - _args = args; + Args = args; } - public override string Id => _descriptor.Id; + public override string Id => Descriptor.Id; - public override RazorDiagnosticSeverity Severity => _descriptor.Severity; + public override RazorDiagnosticSeverity Severity => Descriptor.Severity; public override SourceSpan Span { get; } + // Internal for testing + internal RazorDiagnosticDescriptor Descriptor { get; } + + // Internal for testing + internal object[] Args { get; } + public override string GetMessage(IFormatProvider formatProvider) { - var format = _descriptor.GetMessageFormat(); - return string.Format(formatProvider, format, _args); + var format = Descriptor.GetMessageFormat(); + return string.Format(formatProvider, format, Args); } public override bool Equals(RazorDiagnostic obj) @@ -38,7 +41,7 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - if (!_descriptor.Equals(other._descriptor)) + if (!Descriptor.Equals(other.Descriptor)) { return false; } @@ -48,14 +51,14 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - if (_args.Length != other._args.Length) + if (Args.Length != other.Args.Length) { return false; } - for (var i = 0; i < _args.Length; i++) + for (var i = 0; i < Args.Length; i++) { - if (!_args[i].Equals(other._args[i])) + if (!Args[i].Equals(other.Args[i])) { return false; } @@ -67,12 +70,12 @@ namespace Microsoft.AspNetCore.Razor.Language public override int GetHashCode() { var hash = new HashCodeCombiner(); - hash.Add(_descriptor.GetHashCode()); + hash.Add(Descriptor.GetHashCode()); hash.Add(Span.GetHashCode()); - for (var i = 0; i < _args.Length; i++) + for (var i = 0; i < Args.Length; i++) { - hash.Add(_args[i]); + hash.Add(Args[i]); } return hash; diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs index b7047bca1b..5e3ae8a258 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorIntermediateNodeLoweringPhase : RazorEnginePhaseBase, IRazorIntermediateNodeLoweringPhase { private IRazorCodeGenerationOptionsFeature _optionsFeature; @@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Language var document = new DocumentIntermediateNode(); var builder = IntermediateNodeBuilder.Create(document); - document.Options = _optionsFeature.GetOptions(); + document.Options = codeDocument.GetCodeGenerationOptions() ?? _optionsFeature.GetOptions(); var namespaces = new Dictionary(StringComparer.Ordinal); @@ -785,4 +786,5 @@ namespace Microsoft.AspNetCore.Razor.Language private static bool IsMalformed(List diagnostics) => diagnostics.Count > 0 && diagnostics.Any(diagnostic => diagnostic.Severity == RazorDiagnosticSeverity.Error); } +#pragma warning restore CS0618 // Type or member is obsolete } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs index eadc773439..2e4d3273d2 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsBuilder.cs @@ -9,23 +9,43 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRazorParserOptionsBuilder : RazorParserOptionsBuilder { - public DefaultRazorParserOptionsBuilder(bool designTime, RazorLanguageVersion version) + private bool _designTime; + + public DefaultRazorParserOptionsBuilder(RazorConfiguration configuration) { - DesignTime = designTime; - Version = version; + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + Configuration = configuration; + LanguageVersion = configuration.LanguageVersion; } - public override bool DesignTime { get; } + public DefaultRazorParserOptionsBuilder(bool designTime, RazorLanguageVersion version) + { + _designTime = designTime; + LanguageVersion = version; + } + + public override RazorConfiguration Configuration { get; } + + public override bool DesignTime => _designTime; public override ICollection Directives { get; } = new List(); public override bool ParseLeadingDirectives { get; set; } - public override RazorLanguageVersion Version { get; } + public override RazorLanguageVersion LanguageVersion { get; } public override RazorParserOptions Build() { - return new DefaultRazorParserOptions(Directives.ToArray(), DesignTime, ParseLeadingDirectives, Version); + return new DefaultRazorParserOptions(Directives.ToArray(), DesignTime, ParseLeadingDirectives, LanguageVersion); + } + + public override void SetDesignTime(bool designTime) + { + _designTime = designTime; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..32fb04af7f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFactoryProjectFeature.cs @@ -0,0 +1,32 @@ +// 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.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorParserOptionsFactoryProjectFeature : RazorProjectEngineFeatureBase, IRazorParserOptionsFactoryProjectFeature + { + private IConfigureRazorParserOptionsFeature[] _configureOptions; + + protected override void OnInitialized() + { + _configureOptions = ProjectEngine.EngineFeatures.OfType().ToArray(); + } + + public RazorParserOptions Create(Action configure) + { + var builder = new DefaultRazorParserOptionsBuilder(ProjectEngine.Configuration); + configure?.Invoke(builder); + + for (var i = 0; i < _configureOptions.Length; i++) + { + _configureOptions[i].Configure(builder); + } + + var options = builder.Build(); + return options; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs index 867e289ee7..eecb9bd9cc 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParserOptionsFeature.cs @@ -5,7 +5,9 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorParserOptionsFeature : RazorEngineFeatureBase, IRazorParserOptionsFeature +#pragma warning restore CS0618 // Type or member is obsolete { private readonly bool _designTime; private readonly RazorLanguageVersion _version; diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs index 5a13e68760..8264201271 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorParsingPhase.cs @@ -3,6 +3,7 @@ namespace Microsoft.AspNetCore.Razor.Language { +#pragma warning disable CS0618 // Type or member is obsolete internal class DefaultRazorParsingPhase : RazorEnginePhaseBase, IRazorParsingPhase { private IRazorParserOptionsFeature _optionsFeature; @@ -14,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language protected override void ExecuteCore(RazorCodeDocument codeDocument) { - var options = _optionsFeature.GetOptions(); + var options = codeDocument.GetParserOptions() ??_optionsFeature.GetOptions(); var syntaxTree = RazorSyntaxTree.Parse(codeDocument.Source, options); codeDocument.SetSyntaxTree(syntaxTree); @@ -26,4 +27,5 @@ namespace Microsoft.AspNetCore.Razor.Language codeDocument.SetImportSyntaxTrees(importSyntaxTrees); } } +#pragma warning restore CS0618 // Type or member is obsolete } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs new file mode 100644 index 0000000000..e7eaafec22 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.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.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class DefaultRazorProjectEngine : RazorProjectEngine + { + public DefaultRazorProjectEngine( + RazorConfiguration configuration, + RazorEngine engine, + RazorProjectFileSystem fileSystem, + IReadOnlyList projectFeatures) + { + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + if (engine == null) + { + throw new ArgumentNullException(nameof(engine)); + } + + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } + + if (projectFeatures == null) + { + throw new ArgumentNullException(nameof(projectFeatures)); + } + + Configuration = configuration; + Engine = engine; + FileSystem = fileSystem; + ProjectFeatures = projectFeatures; + + for (var i = 0; i < projectFeatures.Count; i++) + { + projectFeatures[i].ProjectEngine = this; + } + } + + public override RazorConfiguration Configuration { get; } + + public override RazorProjectFileSystem FileSystem { get; } + + public override RazorEngine Engine { get; } + + public override IReadOnlyList ProjectFeatures { get; } + + protected override RazorCodeDocument CreateCodeDocumentCore(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var sourceDocument = RazorSourceDocument.ReadFrom(projectItem); + + var importFeature = GetRequiredFeature(); + var importItems = importFeature.GetImports(projectItem); + var importSourceDocuments = importItems.Select(ConvertToSourceDocument); + + var parserOptions = GetRequiredFeature().Create(ConfigureParserOptions); + var codeGenerationOptions = GetRequiredFeature().Create(ConfigureCodeGenerationOptions); + + return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); + } + + protected override RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var sourceDocument = RazorSourceDocument.ReadFrom(projectItem); + + var importFeature = GetRequiredFeature(); + var importItems = importFeature.GetImports(projectItem); + var importSourceDocuments = importItems.Select(ConvertToSourceDocument); + + var parserOptions = GetRequiredFeature().Create(ConfigureDesignTimeParserOptions); + var codeGenerationOptions = GetRequiredFeature().Create(ConfigureDesignTimeCodeGenerationOptions); + + + return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); + } + + protected override void ProcessCore(RazorCodeDocument codeDocument) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + Engine.Process(codeDocument); + } + + private TFeature GetRequiredFeature() where TFeature : IRazorProjectEngineFeature + { + var feature = ProjectFeatures.OfType().FirstOrDefault(); + if (feature == null) + { + throw new InvalidOperationException( + Resources.FormatRazorProjectEngineMissingFeatureDependency( + typeof(RazorProjectEngine).FullName, + typeof(TFeature).FullName)); + } + + return feature; + } + + private void ConfigureParserOptions(RazorParserOptionsBuilder builder) + { + } + + private void ConfigureDesignTimeParserOptions(RazorParserOptionsBuilder builder) + { + builder.SetDesignTime(true); + } + + private void ConfigureCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) + { + } + + private void ConfigureDesignTimeCodeGenerationOptions(RazorCodeGenerationOptionsBuilder builder) + { + builder.SetDesignTime(true); + builder.SuppressChecksum = true; + builder.SuppressMetadataAttributes = true; + } + + // Internal for testing + internal static RazorSourceDocument ConvertToSourceDocument(RazorProjectItem importItem) + { + if (importItem.Exists) + { + // Normal import, has file paths, content etc. + return RazorSourceDocument.ReadFrom(importItem); + } + + // Marker import, doesn't exist, used as an identifier for "there could be something here". + var sourceDocumentProperties = new RazorSourceDocumentProperties(importItem.FilePath, importItem.RelativePhysicalPath); + return RazorSourceDocument.Create(string.Empty, sourceDocumentProperties); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs new file mode 100644 index 0000000000..a07f4581ff --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngineBuilder.cs @@ -0,0 +1,56 @@ +// 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 +{ + internal class DefaultRazorProjectEngineBuilder : RazorProjectEngineBuilder + { + public DefaultRazorProjectEngineBuilder(RazorConfiguration configuration, RazorProjectFileSystem fileSystem) + { + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } + + Configuration = configuration; + FileSystem = fileSystem; + Features = new List(); + Phases = new List(); + } + + public override RazorConfiguration Configuration { get; } + + public override RazorProjectFileSystem FileSystem { get; } + + public override ICollection Features { get; } + + public override IList Phases { get; } + + public override RazorProjectEngine Build() + { + var engine = RazorEngine.CreateEmpty(ConfigureRazorEngine); + var projectFeatures = Features.OfType().ToArray(); + var projectEngine = new DefaultRazorProjectEngine(Configuration, engine, FileSystem, projectFeatures); + + return projectEngine; + } + + private void ConfigureRazorEngine(IRazorEngineBuilder engineBuilder) + { + var engineFeatures = Features.OfType(); + foreach (var engineFeature in engineFeatures) + { + engineBuilder.Features.Add(engineFeature); + } + + for (var i = 0; i < Phases.Count; i++) + { + engineBuilder.Phases.Add(Phases[i]); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProject.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectFileSystem.cs similarity index 68% rename from src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProject.cs rename to src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectFileSystem.cs index 52ddafebe3..2600ce5efe 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProject.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectFileSystem.cs @@ -8,15 +8,15 @@ using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { - internal class FileSystemRazorProject : RazorProject + internal class DefaultRazorProjectFileSystem : RazorProjectFileSystem { - public FileSystemRazorProject(string root) + public DefaultRazorProjectFileSystem(string root) { if (string.IsNullOrEmpty(root)) { throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(root)); } - + Root = root.Replace('\\', '/').TrimEnd('/'); } @@ -36,16 +36,24 @@ namespace Microsoft.AspNetCore.Razor.Language .EnumerateFiles("*.cshtml", SearchOption.AllDirectories) .Select(file => { - var relativePath = file.FullName.Substring(absoluteBasePath.Length).Replace(Path.DirectorySeparatorChar, '/'); - return new FileSystemRazorProjectItem(basePath, relativePath, file); + var relativePhysicalPath = file.FullName.Substring(absoluteBasePath.Length + 1); // Include leading separator + var filePath = "/" + relativePhysicalPath.Replace(Path.DirectorySeparatorChar, '/'); + + return new DefaultRazorProjectItem(basePath, filePath, relativePhysicalPath, file); }); } public override RazorProjectItem GetItem(string path) { + var absoluteBasePath = NormalizeAndEnsureValidPath("/"); var absolutePath = NormalizeAndEnsureValidPath(path); - return new FileSystemRazorProjectItem("/", path, new FileInfo(absolutePath)); + var file = new FileInfo(absolutePath); + + var relativePhysicalPath = file.FullName.Substring(absoluteBasePath.Length + 1); // Include leading separator + var filePath = "/" + relativePhysicalPath.Replace(Path.DirectorySeparatorChar, '/'); + + return new DefaultRazorProjectItem("/", filePath, relativePhysicalPath, new FileInfo(absolutePath)); } protected override string NormalizeAndEnsureValidPath(string path) diff --git a/src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProjectItem.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectItem.cs similarity index 51% rename from src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProjectItem.cs rename to src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectItem.cs index 4138fbc3d8..5a3590a121 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/FileSystemRazorProjectItem.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectItem.cs @@ -5,18 +5,20 @@ using System.IO; namespace Microsoft.AspNetCore.Razor.Language { - internal class FileSystemRazorProjectItem : RazorProjectItem + internal class DefaultRazorProjectItem : RazorProjectItem { /// - /// Initializes a new instance of . + /// Initializes a new instance of . /// /// The base path. - /// The path. + /// The physical path of the base path. + /// The path. /// The . - public FileSystemRazorProjectItem(string basePath, string path, FileInfo file) + public DefaultRazorProjectItem(string basePath, string filePath, string relativePhysicalPath, FileInfo file) { BasePath = basePath; - FilePath = path; + FilePath = filePath; + RelativePhysicalPath = relativePhysicalPath; File = file; } @@ -30,6 +32,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override string PhysicalPath => File.FullName; - public override Stream Read() => File.OpenRead(); + public override string RelativePhysicalPath { get; } + + public override Stream Read() => new FileStream(PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs index 87749a73e6..37b5e156f1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Language // We have an exact match for the start of a line. Debug.Assert(_lineStarts[index] == position); - return new SourceLocation(_document.FilePath, position, index, characterIndex: 0); + return new SourceLocation(_document.GetFilePathForDisplay(), position, index, characterIndex: 0); } @@ -59,12 +59,12 @@ namespace Microsoft.AspNetCore.Razor.Language if (index == -1) { // There's no preceding line, so it's based on the start of the string - return new SourceLocation(_document.FilePath, position, 0, position); + return new SourceLocation(_document.GetFilePathForDisplay(), position, 0, position); } else { var characterIndex = position - _lineStarts[index]; - return new SourceLocation(_document.FilePath, position, index, characterIndex); + return new SourceLocation(_document.GetFilePathForDisplay(), position, index, characterIndex); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs index b75ab9335c..7d9dfb7c6e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorTagHelperBinderPhase.cs @@ -58,9 +58,8 @@ namespace Microsoft.AspNetCore.Razor.Language var root = syntaxTree.Root; root = rewriter.Rewrite(root, errorSink); - // Temporary code while we're still using legacy diagnostics in the SyntaxTree. var errorList = new List(); - errorList.AddRange(errorSink.Errors.Select(error => RazorDiagnostic.Create(error))); + errorList.AddRange(errorSink.Errors); errorList.AddRange(descriptors.SelectMany(d => d.GetAllDiagnostics())); diff --git a/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.cs new file mode 100644 index 0000000000..61ced1271b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/EmptyProjectFileSystem.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.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class EmptyProjectFileSystem : RazorProjectFileSystem + { + public override IEnumerable EnumerateItems(string basePath) + { + NormalizeAndEnsureValidPath(basePath); + return Enumerable.Empty(); + } + + public override RazorProjectItem GetItem(string path) + { + NormalizeAndEnsureValidPath(path); + return new NotFoundProjectItem(string.Empty, path); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultMetadataIdentifierFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultMetadataIdentifierFeature.cs new file mode 100644 index 0000000000..89dc56c469 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultMetadataIdentifierFeature.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; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + // The default scheme for identifiers matches MVC's view engine paths: + // 1. Normalize backslash to forward-slash + // 2. Always include leading slash + // 3. Always include file name and extensions + internal class DefaultMetadataIdentifierFeature : RazorEngineFeatureBase, IMetadataIdentifierFeature + { + public string GetIdentifier(RazorCodeDocument codeDocument, RazorSourceDocument sourceDocument) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (sourceDocument == null) + { + throw new ArgumentNullException(nameof(sourceDocument)); + } + + if (string.IsNullOrEmpty(sourceDocument.RelativePath)) + { + return null; + } + + var identifier = sourceDocument.RelativePath; + identifier = identifier.Replace("\\", "/"); + if (!identifier.StartsWith("/")) + { + identifier = "/" + identifier; + } + + return identifier; + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs index 3a6247a47e..ad85ebf807 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DefaultTagHelperTargetExtension.cs @@ -16,8 +16,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions { private static readonly string[] PrivateModifiers = new string[] { "private" }; - public bool DesignTime { get; set; } - public string RunnerVariableName { get; set; } = "__tagHelperRunner"; public string StringValueBufferVariableName { get; set; } = "__tagHelperStringValueBuffer"; @@ -82,7 +80,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); } @@ -136,7 +134,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions .Write(CreateTagHelperMethodName) .WriteLine("();"); - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter.WriteInstanceMethodInvocation( ExecutionContextVariableName, @@ -153,7 +151,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter .Write("await ") @@ -200,7 +198,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); } @@ -284,7 +282,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions throw new InvalidOperationException(message); } - if (!DesignTime) + if (!context.Options.DesignTime) { // Ensure that the property we're trying to set has initialized its dictionary bound properties. if (node.IsIndexerNameMatch && @@ -338,7 +336,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions // If we get there, this is the first time seeing this property so we need to evaluate the expression. if (node.BoundAttribute.ExpectsStringValue(node.AttributeName)) { - if (DesignTime) + if (context.Options.DesignTime) { context.RenderChildren(node); @@ -370,7 +368,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } else { - if (DesignTime) + if (context.Options.DesignTime) { var firstMappedChild = node.Children.FirstOrDefault(child => child.Source != null) as IntermediateNode; var valueStart = firstMappedChild?.Source; @@ -456,7 +454,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } } - if (!DesignTime) + if (!context.Options.DesignTime) { // We need to inform the context of the attribute value. context.CodeWriter @@ -474,7 +472,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperRuntime(CodeRenderingContext context, DefaultTagHelperRuntimeIntermediateNode node) { - if (!DesignTime) + if (!context.Options.DesignTime) { context.CodeWriter.WriteLine("#line hidden"); @@ -550,7 +548,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } } - private void RenderTagHelperAttributeInline( + // Internal for testing + internal void RenderTagHelperAttributeInline( CodeRenderingContext context, DefaultTagHelperPropertyIntermediateNode property, IntermediateNode node, @@ -565,7 +564,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } else if (node is IntermediateToken token) { - if (DesignTime && node.Source != null) + if (context.Options.DesignTime && node.Source != null) { context.AddSourceMappingFor(node); } @@ -574,20 +573,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } else if (node is CSharpCodeIntermediateNode) { - var error = new RazorError( - LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, - SourceLocation.FromSpan(span), - span == null ? -1 : span.Value.Length); - context.Diagnostics.Add(RazorDiagnostic.Create(error)); + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_CodeBlocksNotSupportedInAttributes(span ?? SourceSpan.Undefined); + context.Diagnostics.Add(diagnostic); } else if (node is TemplateIntermediateNode) { var expectedTypeName = property.IsIndexerNameMatch ? property.BoundAttribute.IndexerTypeName : property.BoundAttribute.TypeName; - var error = new RazorError( - LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(expectedTypeName), - SourceLocation.FromSpan(span), - span == null ? -1 : span.Value.Length); - context.Diagnostics.Add(RazorDiagnostic.Create(error)); + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(span ?? SourceSpan.Undefined, expectedTypeName); + context.Diagnostics.Add(diagnostic); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs index 31e9cbf361..6d6d7e261d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/DesignTimeDirectivePass.cs @@ -15,6 +15,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + // Only supports design time. This pass rewrites directives so they will have the right design time + // behavior and would break things if it ran for runtime. + if (!documentNode.Options.DesignTime) + { + return; + } + var walker = new DesignTimeHelperWalker(); walker.VisitDocument(documentNode); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirective.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirective.cs index f9033b8a83..0adb20aefb 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirective.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirective.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 Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Extensions @@ -15,10 +16,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions builder.Description = Resources.FunctionsDirective_Description; }); - public static void Register(IRazorEngineBuilder builder) + public static void Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new FunctionsDirectivePass()); } + + #region Obsolete + public static void Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new FunctionsDirectivePass()); + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataAttributeTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataAttributeTargetExtension.cs new file mode 100644 index 0000000000..646dcdd46f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataAttributeTargetExtension.cs @@ -0,0 +1,14 @@ +// 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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal interface IMetadataAttributeTargetExtension : ICodeTargetExtension + { + void WriteRazorCompiledItemAttribute(CodeRenderingContext context, RazorCompiledItemAttributeIntermediateNode node); + + void WriteRazorSourceChecksumAttribute(CodeRenderingContext context, RazorSourceChecksumAttributeIntermediateNode node); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataIdentifierFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataIdentifierFeature.cs new file mode 100644 index 0000000000..6948c33a67 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/IMetadataIdentifierFeature.cs @@ -0,0 +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. + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal interface IMetadataIdentifierFeature : IRazorEngineFeature + { + string GetIdentifier(RazorCodeDocument codeDocument, RazorSourceDocument sourceDocument); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/InheritsDirective.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/InheritsDirective.cs index 289b5d853c..6cef321c73 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/InheritsDirective.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/InheritsDirective.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 Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Extensions @@ -17,10 +18,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions builder.Description = Resources.InheritsDirective_Description; }); - public static void Register(IRazorEngineBuilder builder) + public static void Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new InheritsDirectivePass()); } + + #region Obsolete + public static void Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new InheritsDirectivePass()); + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributePass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributePass.cs new file mode 100644 index 0000000000..843b1fa48b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributePass.cs @@ -0,0 +1,128 @@ +// 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; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + // Optimization pass is the best choice for this class. It's not an optimization, but it also doesn't add semantically + // meaningful information. + internal class MetadataAttributePass : IntermediateNodePassBase, IRazorOptimizationPass + { + private IMetadataIdentifierFeature _identifierFeature; + + protected override void OnInitialized() + { + _identifierFeature = Engine.Features.OfType().FirstOrDefault(); + } + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (documentNode.Options == null || documentNode.Options.SuppressMetadataAttributes) + { + // Metadata attributes are turned off (or options not populated), nothing to do. + return; + } + + // We need to be able to compute the data we need for the [RazorCompiledItem] attribute - that includes + // a full type name, and a document kind, and optionally an identifier. + // + // If we can't use [RazorCompiledItem] then we don't care about the rest of the attributes. + var @namespace = documentNode.FindPrimaryNamespace(); + if (@namespace == null || string.IsNullOrEmpty(@namespace.Content)) + { + // No namespace node or it's incomplete. Skip. + return; + } + + var @class = documentNode.FindPrimaryClass(); + if (@class == null || string.IsNullOrEmpty(@class.ClassName)) + { + // No class node or it's incomplete. Skip. + return; + } + + if (documentNode.DocumentKind == null) + { + // No document kind. Skip. + return; + } + + var identifier = _identifierFeature?.GetIdentifier(codeDocument, codeDocument.Source); + if (identifier == null) + { + // No identifier. Skip + return; + } + + // [RazorCompiledItem] is an [assembly: ... ] attribute, so it needs to be applied at the global scope. + documentNode.Children.Insert(0, new RazorCompiledItemAttributeIntermediateNode() + { + TypeName = @namespace.Content + "." + @class.ClassName, + Kind = documentNode.DocumentKind, + Identifier = identifier, + }); + + // Now we need to add a [RazorSourceChecksum] for the source and for each import + // these are class attributes, so we need to find the insertion point to put them + // right before the class. + var insert = (int?)null; + for (var j = 0; j < @namespace.Children.Count; j++) + { + if (object.ReferenceEquals(@namespace.Children[j], @class)) + { + insert = j; + break; + } + } + + if (insert == null) + { + // Can't find a place to put the attributes, just bail. + return; + } + + // Checksum of the main source + var checksum = codeDocument.Source.GetChecksum(); + var checksumAlgorithm = codeDocument.Source.GetChecksumAlgorithm(); + if (checksum == null || checksum.Length == 0 || checksumAlgorithm == null || identifier == null) + { + // Don't generate anything unless we have all of the required information. + return; + } + + @namespace.Children.Insert((int)insert++, new RazorSourceChecksumAttributeIntermediateNode() + { + Checksum = checksum, + ChecksumAlgorithm = checksumAlgorithm, + Identifier = identifier, + }); + + // Now process the checksums of the imports + Debug.Assert(_identifierFeature != null); + for (var i = 0; i < codeDocument.Imports.Count; i++) + { + var import = codeDocument.Imports[i]; + + checksum = import.GetChecksum(); + checksumAlgorithm = import.GetChecksumAlgorithm(); + identifier = _identifierFeature.GetIdentifier(codeDocument, import); + + if (checksum == null || checksum.Length == 0 || checksumAlgorithm == null || identifier == null) + { + // It's ok to skip an import if we don't have all of the required information. + continue; + } + + @namespace.Children.Insert((int)insert++, new RazorSourceChecksumAttributeIntermediateNode() + { + Checksum = checksum, + ChecksumAlgorithm = checksumAlgorithm, + Identifier = identifier, + }); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributeTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributeTargetExtension.cs new file mode 100644 index 0000000000..c9723efc5b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/MetadataAttributeTargetExtension.cs @@ -0,0 +1,63 @@ +// 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.CodeGeneration; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal class MetadataAttributeTargetExtension : IMetadataAttributeTargetExtension + { + public string CompiledItemAttributeName { get; set; } = "global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute"; + + public string SourceChecksumAttributeName { get; set; } = "global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute"; + + public void WriteRazorCompiledItemAttribute(CodeRenderingContext context, RazorCompiledItemAttributeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // [assembly: global::...RazorCompiledItem(typeof({node.TypeName}), @"{node.Kind}", @"{node.Identifier}")] + context.CodeWriter.Write("[assembly: "); + context.CodeWriter.Write(CompiledItemAttributeName); + context.CodeWriter.Write("(typeof("); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write("), @\""); + context.CodeWriter.Write(node.Kind); + context.CodeWriter.Write("\", @\""); + context.CodeWriter.Write(node.Identifier); + context.CodeWriter.WriteLine("\")]"); + } + + public void WriteRazorSourceChecksumAttribute(CodeRenderingContext context, RazorSourceChecksumAttributeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // [global::...RazorSourceChecksum(@"{node.ChecksumAlgorithm}", @"{node.Checksum}", @"{node.Identifier}")] + context.CodeWriter.Write("["); + context.CodeWriter.Write(SourceChecksumAttributeName); + context.CodeWriter.Write("(@\""); + context.CodeWriter.Write(node.ChecksumAlgorithm); + context.CodeWriter.Write("\", @\""); + context.CodeWriter.Write(Checksum.BytesToString(node.Checksum)); + context.CodeWriter.Write("\", @\""); + context.CodeWriter.Write(node.Identifier); + context.CodeWriter.WriteLine("\")]"); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs index ed9488da20..f6d0f40a3b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperAttributeOptimizationPass.cs @@ -15,6 +15,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { + // There's no value in executing this pass at design time, it just prevents some allocations. + if (documentNode.Options.DesignTime) + { + return; + } + var walker = new PreallocatedTagHelperWalker(); walker.VisitDocument(documentNode); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs new file mode 100644 index 0000000000..792fb4ecc1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorCompiledItemAttributeIntermediateNode.cs @@ -0,0 +1,52 @@ +// 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.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal sealed class RazorCompiledItemAttributeIntermediateNode : ExtensionIntermediateNode + { + public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly; + + public string TypeName { get; set; } + + public string Kind { get; set; } + + public string Identifier { get; set; } + + public override void Accept(IntermediateNodeVisitor visitor) + { + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(CodeTarget target, CodeRenderingContext context) + { + if (target == null) + { + throw new ArgumentNullException(nameof(target)); + } + + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var extension = target.GetExtension(); + if (extension == null) + { + ReportMissingCodeTargetExtension(context); + return; + } + + extension.WriteRazorCompiledItemAttribute(context, this); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorSourceChecksumAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorSourceChecksumAttributeIntermediateNode.cs new file mode 100644 index 0000000000..4aa8d3f978 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/RazorSourceChecksumAttributeIntermediateNode.cs @@ -0,0 +1,52 @@ +// 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.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + internal sealed class RazorSourceChecksumAttributeIntermediateNode : ExtensionIntermediateNode + { + public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly; + + public byte[] Checksum { get; set; } + + public string ChecksumAlgorithm { get; set; } + + public string Identifier { get; set; } + + public override void Accept(IntermediateNodeVisitor visitor) + { + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(CodeTarget target, CodeRenderingContext context) + { + if (target == null) + { + throw new ArgumentNullException(nameof(target)); + } + + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var extension = target.GetExtension(); + if (extension == null) + { + ReportMissingCodeTargetExtension(context); + return; + } + + extension.WriteRazorSourceChecksumAttribute(context, this); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirective.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirective.cs index 1542525a70..14c461d08f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirective.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirective.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 Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Extensions @@ -16,11 +17,30 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions builder.Description = Resources.SectionDirective_Description; }); - public static void Register(IRazorEngineBuilder builder) + public static void Register(RazorProjectEngineBuilder builder) { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + builder.AddDirective(Directive); builder.Features.Add(new SectionDirectivePass()); builder.AddTargetExtension(new SectionTargetExtension()); } + + #region Obsolete + public static void Register(IRazorEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + builder.Features.Add(new SectionDirectivePass()); + builder.AddTargetExtension(new SectionTargetExtension()); + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs new file mode 100644 index 0000000000..98d8ffe558 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IImportProjectFeature.cs @@ -0,0 +1,12 @@ +// 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 +{ + public interface IImportProjectFeature : IRazorProjectEngineFeature + { + IReadOnlyList GetImports(RazorProjectItem projectItem); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..6d3ed5156c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFactoryProjectFeature.cs @@ -0,0 +1,12 @@ +// 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 +{ + internal interface IRazorCodeGenerationOptionsFactoryProjectFeature : IRazorProjectEngineFeature + { + RazorCodeGenerationOptions Create(Action configure); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs index dc97b6326c..b74bcc3d8d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorCodeGenerationOptionsFeature.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; + namespace Microsoft.AspNetCore.Razor.Language { + [Obsolete("In Razor 2.1 and newer, use RazorCodeDocument.GetCodeGenerationOptions().")] public interface IRazorCodeGenerationOptionsFeature : IRazorEngineFeature { RazorCodeGenerationOptions GetOptions(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorEngineFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorEngineFeature.cs index dcf3efdf8a..e06f3a65ce 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorEngineFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorEngineFeature.cs @@ -3,7 +3,7 @@ namespace Microsoft.AspNetCore.Razor.Language { - public interface IRazorEngineFeature + public interface IRazorEngineFeature : IRazorFeature { RazorEngine Engine { get; set; } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorFeature.cs new file mode 100644 index 0000000000..4b8d602601 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorFeature.cs @@ -0,0 +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. + +namespace Microsoft.AspNetCore.Razor.Language +{ + public interface IRazorFeature + { + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs new file mode 100644 index 0000000000..e73bf8babc --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFactoryProjectFeature.cs @@ -0,0 +1,12 @@ +// 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 +{ + internal interface IRazorParserOptionsFactoryProjectFeature : IRazorProjectEngineFeature + { + RazorParserOptions Create(Action configure); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs index ec4b3f1ab1..b2c1e9ec3e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorParserOptionsFeature.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; + namespace Microsoft.AspNetCore.Razor.Language { + [Obsolete("In Razor 2.1 and newer, use RazorCodeDocument.GetParserOptions().")] public interface IRazorParserOptionsFeature : IRazorEngineFeature { RazorParserOptions GetOptions(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/IRazorProjectEngineFeature.cs b/src/Microsoft.AspNetCore.Razor.Language/IRazorProjectEngineFeature.cs new file mode 100644 index 0000000000..3b97dbefd2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/IRazorProjectEngineFeature.cs @@ -0,0 +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. + +namespace Microsoft.AspNetCore.Razor.Language +{ + public interface IRazorProjectEngineFeature : IRazorFeature + { + RazorProjectEngine ProjectEngine { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs index 20498f66b4..34e72ad984 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language private readonly int _length; private byte[] _checksum; - public LargeTextSourceDocument(StreamReader reader, int chunkMaxLength, Encoding encoding, string fileName) + public LargeTextSourceDocument(StreamReader reader, int chunkMaxLength, Encoding encoding, RazorSourceDocumentProperties properties) { if (reader == null) { @@ -32,9 +32,15 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(encoding)); } + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + _chunkMaxLength = chunkMaxLength; Encoding = encoding; - FilePath = fileName; + FilePath = properties.FilePath; + RelativePath = properties.RelativePath; ReadChunks(reader, _chunkMaxLength, out _length, out _chunks); _lines = new DefaultRazorSourceLineCollection(this); @@ -59,6 +65,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override RazorSourceLineCollection Lines => _lines; + public override string RelativePath { get; } + public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) { if (destination == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/Block.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/Block.cs index 9084f43a4e..ee7cc135f1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/Block.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/Block.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (type == null) { - throw new InvalidOperationException(LegacyResources.Block_Type_Not_Specified); + throw new InvalidOperationException(Resources.Block_Type_Not_Specified); } Type = type.Value; @@ -234,6 +234,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy visitor.VisitBlock(this); } + public override SyntaxTreeNode Clone() + { + var blockBuilder = new BlockBuilder(this); + + blockBuilder.Children.Clear(); + for (var i = 0; i < Children.Count; i++) + { + var clonedChild = Children[i].Clone(); + blockBuilder.Children.Add(clonedChild); + } + + return blockBuilder.Build(); + } + internal void ChildChanged() { // A node in our graph has changed. We'll need to recompute our length the next time we're asked for it. diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs index 6390d1ffc4..9cdbb1389e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs @@ -196,7 +196,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (Context == null) { - throw new InvalidOperationException(LegacyResources.Parser_Context_Not_Set); + throw new InvalidOperationException(Resources.Parser_Context_Not_Set); } Span.Start = CurrentLocation; @@ -296,10 +296,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy StringComparison.Ordinal)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_HelperDirectiveNotAvailable( - SyntaxConstants.CSharp.HelperKeyword), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); } Context.Builder.CurrentBlock.Type = BlockKindInternal.Expression; @@ -344,24 +342,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (At(CSharpSymbolType.WhiteSpace) || At(CSharpSymbolType.NewLine)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); } else if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - length: 1 /* end of file */); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS( - CurrentSymbol.Content), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), + CurrentSymbol.Content)); } } finally @@ -375,7 +370,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void VerbatimBlock() { Assert(CSharpSymbolType.LeftBrace); - var block = new Block(LegacyResources.BlockName_Code, CurrentStart); + var block = new Block(Resources.BlockName_Code, CurrentStart); AcceptAndMoveNext(); // Set up the "{" span and output @@ -614,7 +609,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private void ExplicitExpression() { - var block = new Block(LegacyResources.BlockName_ExplicitExpression, CurrentStart); + var block = new Block(Resources.BlockName_ExplicitExpression, CurrentStart); Assert(CSharpSymbolType.LeftParenthesis); AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; @@ -634,9 +629,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { AcceptUntil(CSharpSymbolType.LessThan); Context.ErrorSink.OnError( - block.Start, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(block.Name, ")", "("), - length: 1 /* ( */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(block.Start, contentLength: 1 /* ( */), block.Name, ")", "(")); } // If necessary, put an empty-content marker symbol here @@ -664,9 +658,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (Context.Builder.ActiveBlocks.Any(block => block.Type == BlockKindInternal.Template)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, - length: 1 /* @ */); + RazorDiagnosticFactory.CreateParsing_InlineMarkupBlocksCannotBeNested( + new SourceSpan(CurrentStart, contentLength: 1 /* @ */))); } Output(SpanKindInternal.Code); using (Context.Builder.StartBlock(BlockKindInternal.Template)) @@ -767,9 +760,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected virtual void ReservedDirective(bool topLevel) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_ReservedWord(CurrentSymbol.Content), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_ReservedWord( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), CurrentSymbol.Content)); + AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -850,9 +843,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!topLevel) { Context.ErrorSink.OnError( - block.Start, - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - block.Name.Length); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(block.Start, block.Name.Length))); StandardStatement(); } else @@ -1170,11 +1162,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed( + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), Language.GetSample(CSharpSymbolType.LeftBrace), - CurrentSymbol.Content), - CurrentSymbol.Content.Length); + CurrentSymbol.Content)); } // Parse the statement and then we're done @@ -1333,9 +1324,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (type == CSharpSymbolType.Transition && !isSingleLineMarkup) { Context.ErrorSink.OnError( - loc, - LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, - length: 1 /* @ */); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(loc, contentLength: 1 /* @ */))); } // Markup block @@ -1365,7 +1355,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy break; case CSharpSymbolType.LeftBrace: // Verbatim Block - block = block ?? new Block(LegacyResources.BlockName_Code, CurrentStart); + block = block ?? new Block(Resources.BlockName_Code, CurrentStart); AcceptAndMoveNext(); CodeBlock(block); break; @@ -1417,9 +1407,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_Nested_CodeBlock, - length: 1 /* { */); + RazorDiagnosticFactory.CreateParsing_UnexpectedNestedCodeBlock( + new SourceSpan(CurrentStart, contentLength: 1 /* { */))); } // @( or @foo - Nested expression, parse a child block @@ -1513,9 +1502,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile) { Context.ErrorSink.OnError( - block.Start, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(block.Name, '}', '{'), - length: 1 /* { OR } */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(block.Start, contentLength: 1 /* { OR } */), block.Name, "}", "{")); } else if (acceptTerminatingBrace) { @@ -1624,9 +1612,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var currentDirective = CurrentSymbol.Content; Context.ErrorSink.OnError( - CurrentStart, - Resources.FormatDirectiveMustAppearAtStartOfLine(currentDirective), - length: currentDirective.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(CurrentStart, currentDirective.Length), currentDirective)); break; } } @@ -1662,9 +1649,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy !EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - Resources.FormatDirectiveTokensMustBeSeparatedByWhitespace(descriptor.Directive), - length: CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } @@ -1700,9 +1686,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedEOFAfterDirective(descriptor.Directive, tokenDescriptor.Kind.ToString().ToLowerInvariant()), - length: 1); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(CurrentStart, contentLength: 1), + descriptor.Directive, + tokenDescriptor.Kind.ToString().ToLowerInvariant())); return; } @@ -1712,9 +1699,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!NamespaceOrTypeName()) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsTypeName(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsTypeName( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } @@ -1724,9 +1710,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!QualifiedIdentifier(out var identifierLength)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsNamespace(descriptor.Directive), - identifierLength); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(CurrentStart, identifierLength), descriptor.Directive)); return; } @@ -1740,9 +1725,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsIdentifier(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } break; @@ -1755,9 +1739,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } break; @@ -1789,9 +1772,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (!EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedDirectiveLiteral(descriptor.Directive, LegacyResources.ErrorComponent_Newline), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), + descriptor.Directive, + Resources.ErrorComponent_Newline)); } Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -1840,8 +1824,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (directiveErrorSink.Errors.Count > 0) { - var directiveDiagnostics = directiveErrorSink.Errors.Select(error => RazorDiagnostic.Create(error)); - directiveChunkGenerator.Diagnostics.AddRange(directiveDiagnostics); + directiveChunkGenerator.Diagnostics.AddRange(directiveErrorSink.Errors); } Context.ErrorSink = savedErrorSink; @@ -1855,18 +1838,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (Context.SeenDirectives.Contains(descriptor.Directive)) { - UsageError(Resources.FormatDuplicateDirective(descriptor.Directive)); + // There will always be at least 1 child because of the `@` transition. + var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; + var errorLength = /* @ */ 1 + descriptor.Directive.Length; + Context.ErrorSink.OnError( + RazorDiagnosticFactory.CreateParsing_DuplicateDirective( + new SourceSpan(directiveStart, errorLength), descriptor.Directive)); + return; } } - - void UsageError(string message) - { - // There wil always be at least 1 child because of the `@` transition. - var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; - var errorLength = /* @ */ 1 + descriptor.Directive.Length; - Context.ErrorSink.OnError(directiveStart, message, errorLength); - } } private void ParseDirectiveBlock(DirectiveDescriptor descriptor, Action parseChildren) @@ -1874,16 +1855,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedEOFAfterDirective(descriptor.Directive, "{"), - length: 1 /* { */); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(CurrentStart, contentLength: 1 /* { */), descriptor.Directive, "{")); } else if (!At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedDirectiveLiteral(descriptor.Directive, "{"), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive, "{")); } else { @@ -1901,9 +1880,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { editHandler.AutoCompleteString = "}"; Context.ErrorSink.OnError( - startingBraceLocation, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(descriptor.Directive, "}", "{"), - length: 1 /* } */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(startingBraceLocation, contentLength: 1 /* } */), descriptor.Directive, "}", "{")); } else { @@ -1924,8 +1902,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; var errorLength = /* @ */ 1 + SyntaxConstants.CSharp.TagHelperPrefixKeyword.Length; duplicateDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - new SourceSpan(directiveStart, errorLength)); + new SourceSpan(directiveStart, errorLength), + SyntaxConstants.CSharp.TagHelperPrefixKeyword); } TagHelperDirective( @@ -1958,11 +1936,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (char.IsWhiteSpace(character) || InvalidNonWhitespaceNameCharacters.Contains(character)) { diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix), - directiveLocation, - prefix.Length))); + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(directiveLocation, prefix.Length), + SyntaxConstants.CSharp.TagHelperPrefixKeyword, + character, + prefix)); return; } @@ -2037,11 +2015,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy text.EndsWith("'")) { errors.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText(text), - directiveLocation, - Math.Max(text.Length, 1)))); + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(directiveLocation, Math.Max(text.Length, 1)), text)); return directive; } @@ -2100,59 +2075,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Debug.Assert(string.Equals(CurrentSymbol.Content, directive, StringComparison.Ordinal)); } - protected void BaseTypeDirective(string noTypeNameError, Func createChunkGenerator) - { - var keywordStartLocation = Span.Start; - - // Set the block type - Context.Builder.CurrentBlock.Type = BlockKindInternal.Directive; - - var keywordLength = Span.End.AbsoluteIndex - Span.Start.AbsoluteIndex; - - // Accept whitespace - var remainingWhitespace = AcceptSingleWhiteSpaceCharacter(); - - if (Span.Symbols.Count > 1) - { - Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; - } - - Output(SpanKindInternal.MetaCode); - - if (remainingWhitespace != null) - { - Accept(remainingWhitespace); - } - - AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true)); - - if (EndOfFile || At(CSharpSymbolType.WhiteSpace) || At(CSharpSymbolType.NewLine)) - { - Context.ErrorSink.OnError( - keywordStartLocation, - noTypeNameError, - keywordLength); - } - - // Parse to the end of the line - AcceptUntil(CSharpSymbolType.NewLine); - if (!Context.DesignTimeMode) - { - // We want the newline to be treated as code, but it causes issues at design-time. - Optional(CSharpSymbolType.NewLine); - } - - // Pull out the type name - var baseType = string.Concat(Span.Symbols.Select(s => s.Content)); - - // Set up chunk generation - Span.ChunkGenerator = createChunkGenerator(baseType.Trim()); - - // Output the span and finish the block - CompleteBlock(); - Output(SpanKindInternal.Code, AcceptedCharactersInternal.AnyExceptNewline); - } - private void TagHelperDirective(string keyword, Func, ISpanChunkGenerator> chunkGeneratorFactory) { AssertDirective(keyword); @@ -2190,9 +2112,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile || At(CSharpSymbolType.NewLine)) { Context.ErrorSink.OnError( - keywordStartLocation, - LegacyResources.FormatParseError_DirectiveMustHaveValue(keyword), - keywordLength); + RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(keywordStartLocation, keywordLength), keyword)); directiveValue = string.Empty; } @@ -2213,9 +2134,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (startsWithQuote != endsWithQuote) { Context.ErrorSink.OnError( - startLocation, - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(keyword), - rawValue.Length); + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(startLocation, rawValue.Length), keyword)); } directiveValue = rawValue; @@ -2223,17 +2143,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } finally { - List directiveErrors; - if (directiveErrorSink.Errors.Count > 0) - { - directiveErrors = directiveErrorSink.Errors.Select(RazorDiagnostic.Create).ToList(); - } - else - { - directiveErrors = new List(); - } - - Span.ChunkGenerator = chunkGeneratorFactory(directiveValue, directiveErrors); + Span.ChunkGenerator = chunkGeneratorFactory(directiveValue, directiveErrorSink.Errors.ToList()); Context.ErrorSink = savedErrorSink; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs index 7a251cc7e9..44ce3a89ce 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpLanguageCharacteristics.cs @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return new CSharpTokenizer(source); } - protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) + protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) { return new CSharpSymbol(content, type, errors); } @@ -87,25 +87,25 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy switch (type) { case CSharpSymbolType.Identifier: - return LegacyResources.CSharpSymbol_Identifier; + return Resources.CSharpSymbol_Identifier; case CSharpSymbolType.Keyword: - return LegacyResources.CSharpSymbol_Keyword; + return Resources.CSharpSymbol_Keyword; case CSharpSymbolType.IntegerLiteral: - return LegacyResources.CSharpSymbol_IntegerLiteral; + return Resources.CSharpSymbol_IntegerLiteral; case CSharpSymbolType.NewLine: - return LegacyResources.CSharpSymbol_Newline; + return Resources.CSharpSymbol_Newline; case CSharpSymbolType.WhiteSpace: - return LegacyResources.CSharpSymbol_Whitespace; + return Resources.CSharpSymbol_Whitespace; case CSharpSymbolType.Comment: - return LegacyResources.CSharpSymbol_Comment; + return Resources.CSharpSymbol_Comment; case CSharpSymbolType.RealLiteral: - return LegacyResources.CSharpSymbol_RealLiteral; + return Resources.CSharpSymbol_RealLiteral; case CSharpSymbolType.CharacterLiteral: - return LegacyResources.CSharpSymbol_CharacterLiteral; + return Resources.CSharpSymbol_CharacterLiteral; case CSharpSymbolType.StringLiteral: - return LegacyResources.CSharpSymbol_StringLiteral; + return Resources.CSharpSymbol_StringLiteral; default: - return LegacyResources.Symbol_Unknown; + return Resources.Symbol_Unknown; } } return sample; diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs index cbb8cc9a21..21cd94915d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpSymbol.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public CSharpSymbol( string content, CSharpSymbolType type) - : base(content, type, RazorError.EmptyArray) + : base(content, type, RazorDiagnostic.EmptyArray) { if (content == null) { @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public CSharpSymbol( string content, CSharpSymbolType type, - IReadOnlyList errors) + IReadOnlyList errors) : base(content, type, errors) { if (content == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs index eb08ba8e2e..a1943070f3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpTokenizer.cs @@ -343,7 +343,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return base.GetSymbolContent(type); } - protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) + protected override CSharpSymbol CreateSymbol(string content, CSharpSymbolType type, IReadOnlyList errors) { return new CSharpSymbol(content, type, errors); } @@ -547,10 +547,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (EndOfFile) { CurrentErrors.Add( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - CurrentStart, - length: 1 /* end of file */)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } return Transition(CSharpTokenizerState.Data, EndSymbol(CSharpSymbolType.StringLiteral)); } @@ -576,10 +574,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (EndOfFile || ParserHelpers.IsNewLine(CurrentCharacter)) { CurrentErrors.Add( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - CurrentStart, - length: 1 /* " */)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(CurrentStart, contentLength: 1 /* " */))); } else { @@ -595,10 +591,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile) { CurrentErrors.Add( - new RazorError( - LegacyResources.ParseError_BlockComment_Not_Terminated, - CurrentStart, - length: 1 /* end of file */)); + RazorDiagnosticFactory.CreateParsing_BlockCommentNotTerminated( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); + return Transition(CSharpTokenizerState.Data, EndSymbol(CSharpSymbolType.Comment)); } if (CurrentCharacter == '*') diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/ErrorSink.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/ErrorSink.cs index c8219dda5a..3b4c057cd7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/ErrorSink.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/ErrorSink.cs @@ -6,41 +6,29 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language.Legacy { /// - /// Used to manage s encountered during the Razor parsing phase. + /// Used to manage s encountered during the Razor parsing phase. /// internal class ErrorSink { - private readonly List _errors; + private readonly List _errors; /// /// Instantiates a new instance of . /// public ErrorSink() { - _errors = new List(); + _errors = new List(); } /// - /// s collected. + /// s collected. /// - public IReadOnlyList Errors => _errors; + public IReadOnlyList Errors => _errors; /// /// Tracks the given . /// - /// The to track. - public void OnError(RazorError error) =>_errors.Add(error); - - /// - /// Creates and tracks a new . - /// - /// of the error. - /// A message describing the error. - /// The length of the error. - public void OnError(SourceLocation location, string message, int length) - { - var error = new RazorError(message, location, length); - _errors.Add(error); - } + /// The to track. + public void OnError(RazorDiagnostic error) =>_errors.Add(error); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs index 70d7929736..cc44a34368 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlLanguageCharacteristics.cs @@ -24,11 +24,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy switch (type) { case HtmlSymbolType.Text: - return LegacyResources.HtmlSymbol_Text; + return Resources.HtmlSymbol_Text; case HtmlSymbolType.WhiteSpace: - return LegacyResources.HtmlSymbol_WhiteSpace; + return Resources.HtmlSymbol_WhiteSpace; case HtmlSymbolType.NewLine: - return LegacyResources.HtmlSymbol_NewLine; + return Resources.HtmlSymbol_NewLine; case HtmlSymbolType.OpenAngle: return "<"; case HtmlSymbolType.Bang: @@ -56,13 +56,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy case HtmlSymbolType.Colon: return ":"; case HtmlSymbolType.RazorComment: - return LegacyResources.HtmlSymbol_RazorComment; + return Resources.HtmlSymbol_RazorComment; case HtmlSymbolType.RazorCommentStar: return "*"; case HtmlSymbolType.RazorCommentTransition: return "@"; default: - return LegacyResources.Symbol_Unknown; + return Resources.Symbol_Unknown; } } @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy } } - protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) + protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) { return new HtmlSymbol(content, type, errors); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs index 0a7d84efd3..4fdee1322f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlMarkupParser.cs @@ -267,7 +267,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (Context == null) { - throw new InvalidOperationException(LegacyResources.Parser_Context_Not_Set); + throw new InvalidOperationException(Resources.Parser_Context_Not_Set); } using (PushSpanConfig(DefaultMarkupSpan)) @@ -310,9 +310,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag, - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_MarkupBlockMustStartWithTag( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); } Output(SpanKindInternal.Markup); } @@ -472,9 +471,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (tags.Count == 0) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_OuterTagMissingName, - length: 1 /* end of file */); + RazorDiagnosticFactory.CreateParsing_OuterTagMissingName( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } return false; } @@ -634,9 +632,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!seenCloseAngle) { Context.ErrorSink.OnError( - textLocation, - LegacyResources.ParseError_TextTagCannotContainAttributes, - length: 4 /* text */); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(textLocation, contentLength: 4 /* text */))); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Any; RecoverTextTag(); @@ -1089,9 +1086,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Context.Source.Position = bookmark; NextToken(); Context.ErrorSink.OnError( - textLocation, - LegacyResources.ParseError_TextTagCannotContainAttributes, - length: 4 /* text */); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(textLocation, contentLength: 4 /* text */))); RecoverTextTag(); } @@ -1142,9 +1138,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!seenClose) { Context.ErrorSink.OnError( - SourceLocationTracker.Advance(tag.Item2, "<"), - LegacyResources.FormatParseError_UnfinishedTag(tag.Item1.Content), - Math.Max(tag.Item1.Content.Length, 1)); + RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan( + SourceLocationTracker.Advance(tag.Item2, "<"), + Math.Max(tag.Item1.Content.Length, 1)), + tag.Item1.Content)); } else { @@ -1277,9 +1275,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!Optional(HtmlSymbolType.CloseAngle)) { Context.ErrorSink.OnError( - SourceLocationTracker.Advance(tagStart, " { public HtmlSymbol(string content, HtmlSymbolType type) - : base(content, type, RazorError.EmptyArray) + : base(content, type, RazorDiagnostic.EmptyArray) { if (content == null) { @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public HtmlSymbol( string content, HtmlSymbolType type, - IReadOnlyList errors) + IReadOnlyList errors) : base(content, type, errors) { if (content == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs index 0b3af2d407..df9671d1b7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/HtmlTokenizer.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { return HtmlSymbolType.RazorCommentStar; } } - protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) + protected override HtmlSymbol CreateSymbol(string content, HtmlSymbolType type, IReadOnlyList errors) { return new HtmlSymbol(content, type, errors); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs index 02b5864458..23d5f037d0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/LanguageCharacteristics.cs @@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public virtual Tuple SplitSymbol(TSymbol symbol, int splitAt, TSymbolType leftType) { - var left = CreateSymbol(symbol.Content.Substring(0, splitAt), leftType, RazorError.EmptyArray); + var left = CreateSymbol(symbol.Content.Substring(0, splitAt), leftType, RazorDiagnostic.EmptyArray); TSymbol right = null; if (splitAt < symbol.Content.Length) @@ -104,6 +104,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return type == KnownSymbolType.Unknown || !Equals(GetKnownSymbolType(type), GetKnownSymbolType(KnownSymbolType.Unknown)); } - protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); + protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorError.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorError.cs deleted file mode 100644 index 7c93867a8c..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorError.cs +++ /dev/null @@ -1,81 +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.Globalization; -using Microsoft.Extensions.Internal; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - internal class RazorError : IEquatable - { - internal static readonly RazorError[] EmptyArray = new RazorError[0]; - - /// - /// Used only for deserialization. - /// - public RazorError() - : this(message: string.Empty, location: SourceLocation.Undefined, length: -1) - { - } - - public RazorError(string message, int absoluteIndex, int lineIndex, int columnIndex, int length) - : this(message, new SourceLocation(absoluteIndex, lineIndex, columnIndex), length) - { - } - - public RazorError(string message, SourceLocation location, int length) - { - Message = message; - Location = location; - Length = length; - } - - /// - /// Gets (or sets) the message describing the error. - /// - /// Set property is only accessible for deserialization purposes. - public string Message { get; set; } - - /// - /// Gets (or sets) the start position of the erroneous text. - /// - /// Set property is only accessible for deserialization purposes. - public SourceLocation Location { get; set; } - - /// - /// Gets or sets the length of the erroneous text. - /// - /// Set property is only accessible for deserialization purposes. - public int Length { get; set; } - - public override string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "Error @ {0}({2}) - [{1}]", Location, Message, Length); - } - - public override bool Equals(object obj) - { - var error = obj as RazorError; - return Equals(error); - } - - public override int GetHashCode() - { - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(Message, StringComparer.Ordinal); - hashCodeCombiner.Add(Location); - hashCodeCombiner.Add(Length); - - return hashCodeCombiner; - } - - public bool Equals(RazorError other) - { - return other != null && - string.Equals(other.Message, Message, StringComparison.Ordinal) && - Location.Equals(other.Location) && - Length.Equals(other.Length); - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs index 2823ffd69d..8e79907b8c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/RazorParser.cs @@ -43,8 +43,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var root = context.Builder.Build(); - // Temporary code while we're still using legacy diagnostics in the SyntaxTree. - var diagnostics = context.ErrorSink.Errors.Select(error => RazorDiagnostic.Create(error)); + var diagnostics = context.ErrorSink.Errors; return RazorSyntaxTree.Create(root, source, diagnostics, Options); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs index 880e8ee6f6..9b7366fc5e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/Span.cs @@ -179,5 +179,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { visitor.VisitSpan(this); } + + public override SyntaxTreeNode Clone() + { + var spanBuilder = new SpanBuilder(this); + return spanBuilder.Build(); + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs index b0a772e85d..c1caebb988 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SymbolBase.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected SymbolBase( string content, TType type, - IReadOnlyList errors) + IReadOnlyList errors) { if (content == null) { @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public Span Parent { get; set; } - public IReadOnlyList Errors { get; } + public IReadOnlyList Errors { get; } public string Content { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeBuilder.cs index 625a33fba4..6a48614ad7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeBuilder.cs @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (_blockStack.Count == 0) { - throw new InvalidOperationException(LegacyResources.ParserContext_NoCurrentBlock); + throw new InvalidOperationException(Resources.ParserContext_NoCurrentBlock); } CurrentBlock.Children.Add(span); LastSpan = span; @@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (_blockStack.Count == 0) { - throw new InvalidOperationException(LegacyResources.EndBlock_Called_Without_Matching_StartBlock); + throw new InvalidOperationException(Resources.EndBlock_Called_Without_Matching_StartBlock); } if (_blockStack.Count > 1) @@ -78,11 +78,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (_blockStack.Count == 0) { - throw new InvalidOperationException(LegacyResources.ParserContext_CannotCompleteTree_NoRootBlock); + throw new InvalidOperationException(Resources.ParserContext_CannotCompleteTree_NoRootBlock); } if (_blockStack.Count != 1) { - throw new InvalidOperationException(LegacyResources.ParserContext_CannotCompleteTree_OutstandingBlocks); + throw new InvalidOperationException(Resources.ParserContext_CannotCompleteTree_OutstandingBlocks); } var rootBuilder = _blockStack.Pop(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs index ed5ef74181..a20c7c318b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/SyntaxTreeNode.cs @@ -43,5 +43,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public abstract int GetEquivalenceHash(); public abstract void Accept(ParserVisitor visitor); + + public abstract SyntaxTreeNode Clone(); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlock.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlock.cs index 9d3f7167be..b8863247bd 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlock.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlock.cs @@ -159,6 +159,41 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return null; } + public override SyntaxTreeNode Clone() + { + var tagHelperBlockBuilder = new TagHelperBlockBuilder(this); + + tagHelperBlockBuilder.Children.Clear(); + for (var i = 0; i < Children.Count; i++) + { + var clonedChild = Children[i].Clone(); + tagHelperBlockBuilder.Children.Add(clonedChild); + } + + tagHelperBlockBuilder.Attributes.Clear(); + for (var i = 0; i < Attributes.Count; i++) + { + var existingAttribute = Attributes[i]; + var clonedValue = existingAttribute.Value != null ? existingAttribute.Value.Clone() : null; + tagHelperBlockBuilder.Attributes.Add( + new TagHelperAttributeNode(existingAttribute.Name, clonedValue, existingAttribute.AttributeStructure)); + } + + if (SourceStartTag != null) + { + var clonedStartTag = (Block)SourceStartTag.Clone(); + tagHelperBlockBuilder.SourceStartTag = clonedStartTag; + } + + if (SourceEndTag != null) + { + var clonedEndTag = (Block)SourceEndTag.Clone(); + tagHelperBlockBuilder.SourceEndTag = clonedEndTag; + } + + return tagHelperBlockBuilder.Build(); + } + /// public override string ToString() { diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockBuilder.cs index b05edd8941..29e39bb3ae 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockBuilder.cs @@ -18,9 +18,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public TagHelperBlockBuilder(TagHelperBlock original) : base(original) { - TagName = original.TagName; + SourceStartTag = original.SourceStartTag; + SourceEndTag = original.SourceEndTag; + TagMode = original.TagMode; BindingResult = original.Binding; Attributes = new List(original.Attributes); + TagName = original.TagName; } /// diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs index af8b1a9c36..bfb31bce05 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperBlockRewriter.cs @@ -61,8 +61,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Only want to track the attribute if we succeeded in parsing its corresponding Block/Span. if (result != null) { - SourceLocation? errorLocation = null; - // Check if it's a non-boolean bound attribute that is minimized or if it's a bound // non-string attribute that has null or whitespace content. var isMinimized = result.AttributeValueNode == null; @@ -74,32 +72,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy result.IsBoundNonStringAttribute && IsNullOrWhitespaceAttributeValue(result.AttributeValueNode))) { - errorLocation = GetAttributeNameStartLocation(child); - - errorSink.OnError( - errorLocation.Value, - LegacyResources.FormatRewriterError_EmptyTagHelperBoundAttribute( - result.AttributeName, - tagName, - GetPropertyType(result.AttributeName, bindingResult.Descriptors)), - result.AttributeName.Length); + var errorLocation = GetAttributeNameLocation(child, result.AttributeName); + var propertyTypeName = GetPropertyType(result.AttributeName, bindingResult.Descriptors); + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(errorLocation, result.AttributeName, tagName, propertyTypeName); + errorSink.OnError(diagnostic); } // Check if the attribute was a prefix match for a tag helper dictionary property but the // dictionary key would be the empty string. if (result.IsMissingDictionaryKey) { - if (!errorLocation.HasValue) - { - errorLocation = GetAttributeNameStartLocation(child); - } - - errorSink.OnError( - errorLocation.Value, - LegacyResources.FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey( - result.AttributeName, - tagName), - result.AttributeName.Length); + var errorLocation = GetAttributeNameLocation(child, result.AttributeName); + var diagnostic = RazorDiagnosticFactory.CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey(errorLocation, result.AttributeName, tagName); + errorSink.OnError(diagnostic); } var attributeNode = new TagHelperAttributeNode( @@ -299,10 +284,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // ex: () .First(sym => sym.Type != HtmlSymbolType.WhiteSpace && sym.Type != HtmlSymbolType.NewLine); - return firstNonWhitespaceSymbol.Start; + var location = new SourceSpan(firstNonWhitespaceSymbol.Start, attributeName.Length); + return location; } private static Span CreateMarkupAttribute(SpanBuilder builder, TryParseResult result) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperParseTreeRewriter.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperParseTreeRewriter.cs index 00d48921aa..2059522263 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperParseTreeRewriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TagHelperParseTreeRewriter.cs @@ -291,12 +291,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // End tag TagHelper that states it shouldn't have an end tag. errorSink.OnError( - SourceLocationTracker.Advance(tagBlock.Start, "(); + CurrentErrors = new List(); StartSymbol(); } - protected List CurrentErrors { get; } + protected List CurrentErrors { get; } protected abstract int StartState { get; } @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public SourceLocation CurrentStart { get; private set; } - protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); + protected abstract TSymbol CreateSymbol(string content, TSymbolType type, IReadOnlyList errors); protected abstract StateResult Dispatch(); @@ -205,7 +205,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (HaveContent) { // Perf: Don't allocate a new errors array unless necessary. - var errors = CurrentErrors.Count == 0 ? RazorError.EmptyArray : new RazorError[CurrentErrors.Count]; + var errors = CurrentErrors.Count == 0 ? RazorDiagnostic.EmptyArray : new RazorDiagnostic[CurrentErrors.Count]; for (var i = 0; i < CurrentErrors.Count; i++) { errors[i] = CurrentErrors[i]; diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs index 3017e96fa6..6f564eb442 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/TokenizerBackedParser.cs @@ -168,11 +168,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile && ((mode & BalancingModes.NoErrorOnFailure) != BalancingModes.NoErrorOnFailure)) { Context.ErrorSink.OnError( - start, - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF( + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(start, contentLength: 1 /* { OR } */), Language.GetSample(left), - Language.GetSample(right)), - length: 1 /* { OR } */); + Language.GetSample(right))); } return Balance(mode, left, right, start); @@ -218,11 +217,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if ((mode & BalancingModes.NoErrorOnFailure) != BalancingModes.NoErrorOnFailure) { Context.ErrorSink.OnError( - start, - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF( + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(start, contentLength: 1 /* { OR } */), Language.GetSample(left), - Language.GetSample(right)), - length: 1 /* { OR } */); + Language.GetSample(right))); } if ((mode & BalancingModes.BacktrackOnFailure) == BalancingModes.BacktrackOnFailure) { @@ -435,44 +433,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return false; } - protected internal bool Required(TSymbolType expected, bool errorIfNotFound, Func errorBase) - { - var found = At(expected); - if (!found && errorIfNotFound) - { - string error; - if (Language.IsNewLine(CurrentSymbol)) - { - error = LegacyResources.ErrorComponent_Newline; - } - else if (Language.IsWhiteSpace(CurrentSymbol)) - { - error = LegacyResources.ErrorComponent_Whitespace; - } - else if (EndOfFile) - { - error = LegacyResources.ErrorComponent_EndOfFile; - } - else - { - error = LegacyResources.FormatErrorComponent_Character(CurrentSymbol.Content); - } - - int errorLength; - if (CurrentSymbol == null || CurrentSymbol.Content == null) - { - errorLength = 1; - } - else - { - errorLength = Math.Max(CurrentSymbol.Content.Length, 1); - } - - Context.ErrorSink.OnError(CurrentStart, errorBase(error), errorLength); - } - return found; - } - protected bool EnsureCurrent() { if (CurrentSymbol == null) @@ -594,7 +554,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected virtual void OutputSpanBeforeRazorComment() { - throw new InvalidOperationException(LegacyResources.Language_Does_Not_Support_RazorComment); + throw new InvalidOperationException(Resources.Language_Does_Not_Support_RazorComment); } private void CommentSpanConfig(SpanBuilder span) @@ -609,7 +569,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy !Language.KnowsSymbolType(KnownSymbolType.CommentStar) || !Language.KnowsSymbolType(KnownSymbolType.CommentBody)) { - throw new InvalidOperationException(LegacyResources.Language_Does_Not_Support_RazorComment); + throw new InvalidOperationException(Resources.Language_Does_Not_Support_RazorComment); } OutputSpanBeforeRazorComment(); using (PushSpanConfig(CommentSpanConfig)) @@ -634,9 +594,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { errorReported = true; Context.ErrorSink.OnError( - start, - LegacyResources.ParseError_RazorComment_Not_Terminated, - length: 2 /* @* */); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(start, contentLength: 2 /* @* */))); } else { @@ -649,9 +608,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { errorReported = true; Context.ErrorSink.OnError( - start, - LegacyResources.ParseError_RazorComment_Not_Terminated, - length: 2 /* @* */); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(start, contentLength: 2 /* @* */))); } } else diff --git a/src/Microsoft.AspNetCore.Razor.Language/LegacyRazorDiagnostic.cs b/src/Microsoft.AspNetCore.Razor.Language/LegacyRazorDiagnostic.cs deleted file mode 100644 index 17ab6a5c2b..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/LegacyRazorDiagnostic.cs +++ /dev/null @@ -1,40 +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.Legacy; - -namespace Microsoft.AspNetCore.Razor.Language -{ - internal class LegacyRazorDiagnostic : RazorDiagnostic - { - private readonly RazorError _error; - - public LegacyRazorDiagnostic(RazorError error) - { - _error = error; - } - - public override string Id => "RZ9999"; - - public override RazorDiagnosticSeverity Severity => RazorDiagnosticSeverity.Error; - - public override SourceSpan Span => new SourceSpan(_error.Location, _error.Length); - - public override string GetMessage(IFormatProvider formatProvider) - { - return _error.Message; - } - - public override bool Equals(RazorDiagnostic obj) - { - var other = obj as LegacyRazorDiagnostic; - return other == null ? false : _error.Equals(other._error); - } - - public override int GetHashCode() - { - return _error.GetHashCode(); - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx b/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx deleted file mode 100644 index af753ed15b..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx +++ /dev/null @@ -1,410 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Value cannot be null or an empty string. - - - Value must be between {0} and {1}. - - - Value must be a value from the "{0}" enumeration. - - - Value must be greater than {0}. - - - Value must be greater than or equal to {0}. - - - Value must be less than {0}. - - - Value must be less than or equal to {0}. - - - Value cannot be an empty string. It must either be null or a non-empty string. - - - code - This is a literal used when composing ParserError_* messages. Most blocks are named by the keyword that starts them, for example "if". However, for those without keywords, a (localizable) name must be used. This literal is ALWAYS used mid-sentence, thus should not be capitalized. - - - explicit expression - This is a literal used when composing ParserError_* messages. Most blocks are named by the keyword that starts them, for example "if". However, for those without keywords, a (localizable) name must be used. This literal is ALWAYS used mid-sentence, thus should not be capitalized. - - - Block cannot be built because a Type has not been specified in the BlockBuilder - - - <<character literal>> - - - <<comment>> - - - <<identifier>> - - - <<integer literal>> - - - <<keyword>> - - - <<newline sequence>> - - - <<real literal>> - - - <<string literal>> - - - <<white space>> - - - The '{0}' directive expects an identifier. - - - The '{0}' directive expects a namespace name. - - - The '{0}' directive expects a string surrounded by double quotes. - - - The '{0}' directive expects a type name. - - - "EndBlock" was called without a matching call to "StartBlock". - - - "{0}" character - - - end of file - - - line break - - - space or line break - - - <<newline sequence>> - - - <<razor comment>> - - - <<text>> - - - <<white space>> - - - 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 - - - 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) { - <p>Hello, @user!</p> -} - - - End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. - - - Directive '{0}' must have a value. - - - An opening "{0}" is missing the corresponding closing "{1}". - - - The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. - - - Expected "{0}". - - - The {0} directive is not supported. - - - Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. - - - The 'inherits' keyword must be followed by a type name on the same line. - - - Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. - - - Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". - - - The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. - - - Sections cannot be empty. The "@section" keyword must be followed by a block of markup surrounded by "{}". For example: - -@section Sidebar { - <!-- Markup and text goes here --> -} - - - 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. -} - - - Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. - - - 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. - - - "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. - - - Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. - - - Expected a "{0}" but found a "{1}". 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) - <p>Hello, @user</p> - -Instead, wrap the contents of the block in "{{}}": - -@if(isLoggedIn) {{ - <p>Hello, @user</p> -}} - {0} is only ever a single character - - - "<text>" and "</text>" tags cannot contain attributes. - - - Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? - - - Unexpected {0} after section keyword. Section names must start with an "_" or alphabetic character, and the remaining characters must be either "_" or alphanumeric. - - - "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. - "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" - - - 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: "@@" - - - 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: "@@" - - - Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. - - - 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. - - - End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. - - - 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. - - - Cannot complete the tree, StartBlock must be called at least once. - - - Cannot complete the tree, there are still open blocks. - - - Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span - - - Cannot complete action, the parser has finished. Only CompleteParse can be called to extract the final parser results after the parser has finished - - - Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. - - - Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. - - - @section Header { ... } - In CSHTML, the @section keyword is case-sensitive and lowercase (as with all C# keywords) - - - Cannot perform '{1}' operations on '{0}' instances with different file paths. - - - <<unknown>> - - - The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. - - - TagHelper attributes must be well-formed. - - - The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. - - - Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). - - - Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. - - - The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. - - - Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. - - - Missing close angle for tag helper '{0}'. - - - Tag Helper '{0}'s attributes must have names. - - - The tag helper '{0}' must not have C# in the element's attribute declaration area. - - - Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. - Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. - - - Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. - Expected a '{0}' attribute value, not a string. - - - In order to put a symbol back, it must have been the symbol which ended at the current position. The specified symbol ends at {0}, but the current position is {1} - - - Unexpected literal following the '{0}' directive. Expected '{1}'. - - - Unexpected end of file following the '{0}' directive. Expected '{1}'. - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs index 2e1dafb7a8..7214d8baca 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Properties/AssemblyInfo.cs @@ -2,10 +2,15 @@ // 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.AspNetCore.Razor.Performance, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.GenerateTool, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Language.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.TagHelperTool, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("rzc, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs b/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs deleted file mode 100644 index 73042a77d8..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs +++ /dev/null @@ -1,1296 +0,0 @@ -// -namespace Microsoft.AspNetCore.Razor.Language -{ - using System.Globalization; - using System.Reflection; - using System.Resources; - - internal static class LegacyResources - { - private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNetCore.Razor.Language.LegacyResources", typeof(LegacyResources).GetTypeInfo().Assembly); - - /// - /// Value cannot be null or an empty string. - /// - internal static string Argument_Cannot_Be_Null_Or_Empty - { - get => GetString("Argument_Cannot_Be_Null_Or_Empty"); - } - - /// - /// Value cannot be null or an empty string. - /// - internal static string FormatArgument_Cannot_Be_Null_Or_Empty() - => GetString("Argument_Cannot_Be_Null_Or_Empty"); - - /// - /// Value must be between {0} and {1}. - /// - internal static string Argument_Must_Be_Between - { - get => GetString("Argument_Must_Be_Between"); - } - - /// - /// Value must be between {0} and {1}. - /// - internal static string FormatArgument_Must_Be_Between(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_Between"), p0, p1); - - /// - /// Value must be a value from the "{0}" enumeration. - /// - internal static string Argument_Must_Be_Enum_Member - { - get => GetString("Argument_Must_Be_Enum_Member"); - } - - /// - /// Value must be a value from the "{0}" enumeration. - /// - internal static string FormatArgument_Must_Be_Enum_Member(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_Enum_Member"), p0); - - /// - /// Value must be greater than {0}. - /// - internal static string Argument_Must_Be_GreaterThan - { - get => GetString("Argument_Must_Be_GreaterThan"); - } - - /// - /// Value must be greater than {0}. - /// - internal static string FormatArgument_Must_Be_GreaterThan(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_GreaterThan"), p0); - - /// - /// Value must be greater than or equal to {0}. - /// - internal static string Argument_Must_Be_GreaterThanOrEqualTo - { - get => GetString("Argument_Must_Be_GreaterThanOrEqualTo"); - } - - /// - /// Value must be greater than or equal to {0}. - /// - internal static string FormatArgument_Must_Be_GreaterThanOrEqualTo(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_GreaterThanOrEqualTo"), p0); - - /// - /// Value must be less than {0}. - /// - internal static string Argument_Must_Be_LessThan - { - get => GetString("Argument_Must_Be_LessThan"); - } - - /// - /// Value must be less than {0}. - /// - internal static string FormatArgument_Must_Be_LessThan(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_LessThan"), p0); - - /// - /// Value must be less than or equal to {0}. - /// - internal static string Argument_Must_Be_LessThanOrEqualTo - { - get => GetString("Argument_Must_Be_LessThanOrEqualTo"); - } - - /// - /// Value must be less than or equal to {0}. - /// - internal static string FormatArgument_Must_Be_LessThanOrEqualTo(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("Argument_Must_Be_LessThanOrEqualTo"), p0); - - /// - /// Value cannot be an empty string. It must either be null or a non-empty string. - /// - internal static string Argument_Must_Be_Null_Or_Non_Empty - { - get => GetString("Argument_Must_Be_Null_Or_Non_Empty"); - } - - /// - /// Value cannot be an empty string. It must either be null or a non-empty string. - /// - internal static string FormatArgument_Must_Be_Null_Or_Non_Empty() - => GetString("Argument_Must_Be_Null_Or_Non_Empty"); - - /// - /// code - /// - internal static string BlockName_Code - { - get => GetString("BlockName_Code"); - } - - /// - /// code - /// - internal static string FormatBlockName_Code() - => GetString("BlockName_Code"); - - /// - /// explicit expression - /// - internal static string BlockName_ExplicitExpression - { - get => GetString("BlockName_ExplicitExpression"); - } - - /// - /// explicit expression - /// - internal static string FormatBlockName_ExplicitExpression() - => GetString("BlockName_ExplicitExpression"); - - /// - /// Block cannot be built because a Type has not been specified in the BlockBuilder - /// - internal static string Block_Type_Not_Specified - { - get => GetString("Block_Type_Not_Specified"); - } - - /// - /// Block cannot be built because a Type has not been specified in the BlockBuilder - /// - internal static string FormatBlock_Type_Not_Specified() - => GetString("Block_Type_Not_Specified"); - - /// - /// <<character literal>> - /// - internal static string CSharpSymbol_CharacterLiteral - { - get => GetString("CSharpSymbol_CharacterLiteral"); - } - - /// - /// <<character literal>> - /// - internal static string FormatCSharpSymbol_CharacterLiteral() - => GetString("CSharpSymbol_CharacterLiteral"); - - /// - /// <<comment>> - /// - internal static string CSharpSymbol_Comment - { - get => GetString("CSharpSymbol_Comment"); - } - - /// - /// <<comment>> - /// - internal static string FormatCSharpSymbol_Comment() - => GetString("CSharpSymbol_Comment"); - - /// - /// <<identifier>> - /// - internal static string CSharpSymbol_Identifier - { - get => GetString("CSharpSymbol_Identifier"); - } - - /// - /// <<identifier>> - /// - internal static string FormatCSharpSymbol_Identifier() - => GetString("CSharpSymbol_Identifier"); - - /// - /// <<integer literal>> - /// - internal static string CSharpSymbol_IntegerLiteral - { - get => GetString("CSharpSymbol_IntegerLiteral"); - } - - /// - /// <<integer literal>> - /// - internal static string FormatCSharpSymbol_IntegerLiteral() - => GetString("CSharpSymbol_IntegerLiteral"); - - /// - /// <<keyword>> - /// - internal static string CSharpSymbol_Keyword - { - get => GetString("CSharpSymbol_Keyword"); - } - - /// - /// <<keyword>> - /// - internal static string FormatCSharpSymbol_Keyword() - => GetString("CSharpSymbol_Keyword"); - - /// - /// <<newline sequence>> - /// - internal static string CSharpSymbol_Newline - { - get => GetString("CSharpSymbol_Newline"); - } - - /// - /// <<newline sequence>> - /// - internal static string FormatCSharpSymbol_Newline() - => GetString("CSharpSymbol_Newline"); - - /// - /// <<real literal>> - /// - internal static string CSharpSymbol_RealLiteral - { - get => GetString("CSharpSymbol_RealLiteral"); - } - - /// - /// <<real literal>> - /// - internal static string FormatCSharpSymbol_RealLiteral() - => GetString("CSharpSymbol_RealLiteral"); - - /// - /// <<string literal>> - /// - internal static string CSharpSymbol_StringLiteral - { - get => GetString("CSharpSymbol_StringLiteral"); - } - - /// - /// <<string literal>> - /// - internal static string FormatCSharpSymbol_StringLiteral() - => GetString("CSharpSymbol_StringLiteral"); - - /// - /// <<white space>> - /// - internal static string CSharpSymbol_Whitespace - { - get => GetString("CSharpSymbol_Whitespace"); - } - - /// - /// <<white space>> - /// - internal static string FormatCSharpSymbol_Whitespace() - => GetString("CSharpSymbol_Whitespace"); - - /// - /// The '{0}' directive expects an identifier. - /// - internal static string DirectiveExpectsIdentifier - { - get => GetString("DirectiveExpectsIdentifier"); - } - - /// - /// The '{0}' directive expects an identifier. - /// - internal static string FormatDirectiveExpectsIdentifier(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsIdentifier"), p0); - - /// - /// The '{0}' directive expects a namespace name. - /// - internal static string DirectiveExpectsNamespace - { - get => GetString("DirectiveExpectsNamespace"); - } - - /// - /// The '{0}' directive expects a namespace name. - /// - internal static string FormatDirectiveExpectsNamespace(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsNamespace"), p0); - - /// - /// The '{0}' directive expects a string surrounded by double quotes. - /// - internal static string DirectiveExpectsQuotedStringLiteral - { - get => GetString("DirectiveExpectsQuotedStringLiteral"); - } - - /// - /// The '{0}' directive expects a string surrounded by double quotes. - /// - internal static string FormatDirectiveExpectsQuotedStringLiteral(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsQuotedStringLiteral"), p0); - - /// - /// The '{0}' directive expects a type name. - /// - internal static string DirectiveExpectsTypeName - { - get => GetString("DirectiveExpectsTypeName"); - } - - /// - /// The '{0}' directive expects a type name. - /// - internal static string FormatDirectiveExpectsTypeName(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsTypeName"), p0); - - /// - /// "EndBlock" was called without a matching call to "StartBlock". - /// - internal static string EndBlock_Called_Without_Matching_StartBlock - { - get => GetString("EndBlock_Called_Without_Matching_StartBlock"); - } - - /// - /// "EndBlock" was called without a matching call to "StartBlock". - /// - internal static string FormatEndBlock_Called_Without_Matching_StartBlock() - => GetString("EndBlock_Called_Without_Matching_StartBlock"); - - /// - /// "{0}" character - /// - internal static string ErrorComponent_Character - { - get => GetString("ErrorComponent_Character"); - } - - /// - /// "{0}" character - /// - internal static string FormatErrorComponent_Character(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ErrorComponent_Character"), p0); - - /// - /// end of file - /// - internal static string ErrorComponent_EndOfFile - { - get => GetString("ErrorComponent_EndOfFile"); - } - - /// - /// end of file - /// - internal static string FormatErrorComponent_EndOfFile() - => GetString("ErrorComponent_EndOfFile"); - - /// - /// line break - /// - internal static string ErrorComponent_Newline - { - get => GetString("ErrorComponent_Newline"); - } - - /// - /// line break - /// - internal static string FormatErrorComponent_Newline() - => GetString("ErrorComponent_Newline"); - - /// - /// space or line break - /// - internal static string ErrorComponent_Whitespace - { - get => GetString("ErrorComponent_Whitespace"); - } - - /// - /// space or line break - /// - internal static string FormatErrorComponent_Whitespace() - => GetString("ErrorComponent_Whitespace"); - - /// - /// <<newline sequence>> - /// - internal static string HtmlSymbol_NewLine - { - get => GetString("HtmlSymbol_NewLine"); - } - - /// - /// <<newline sequence>> - /// - internal static string FormatHtmlSymbol_NewLine() - => GetString("HtmlSymbol_NewLine"); - - /// - /// <<razor comment>> - /// - internal static string HtmlSymbol_RazorComment - { - get => GetString("HtmlSymbol_RazorComment"); - } - - /// - /// <<razor comment>> - /// - internal static string FormatHtmlSymbol_RazorComment() - => GetString("HtmlSymbol_RazorComment"); - - /// - /// <<text>> - /// - internal static string HtmlSymbol_Text - { - get => GetString("HtmlSymbol_Text"); - } - - /// - /// <<text>> - /// - internal static string FormatHtmlSymbol_Text() - => GetString("HtmlSymbol_Text"); - - /// - /// <<white space>> - /// - internal static string HtmlSymbol_WhiteSpace - { - get => GetString("HtmlSymbol_WhiteSpace"); - } - - /// - /// <<white space>> - /// - internal static string FormatHtmlSymbol_WhiteSpace() - => GetString("HtmlSymbol_WhiteSpace"); - - /// - /// 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 - /// - internal static string Language_Does_Not_Support_RazorComment - { - get => GetString("Language_Does_Not_Support_RazorComment"); - } - - /// - /// 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 - /// - internal static string FormatLanguage_Does_Not_Support_RazorComment() - => GetString("Language_Does_Not_Support_RazorComment"); - - /// - /// 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) { - /// <p>Hello, @user!</p> - /// } - /// - internal static string ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start - { - get => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); - } - - /// - /// 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) { - /// <p>Hello, @user!</p> - /// } - /// - internal static string FormatParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start() - => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); - - /// - /// End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. - /// - internal static string ParseError_BlockComment_Not_Terminated - { - get => GetString("ParseError_BlockComment_Not_Terminated"); - } - - /// - /// End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. - /// - internal static string FormatParseError_BlockComment_Not_Terminated() - => GetString("ParseError_BlockComment_Not_Terminated"); - - /// - /// Directive '{0}' must have a value. - /// - internal static string ParseError_DirectiveMustHaveValue - { - get => GetString("ParseError_DirectiveMustHaveValue"); - } - - /// - /// Directive '{0}' must have a value. - /// - internal static string FormatParseError_DirectiveMustHaveValue(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_DirectiveMustHaveValue"), p0); - - /// - /// An opening "{0}" is missing the corresponding closing "{1}". - /// - internal static string ParseError_Expected_CloseBracket_Before_EOF - { - get => GetString("ParseError_Expected_CloseBracket_Before_EOF"); - } - - /// - /// An opening "{0}" is missing the corresponding closing "{1}". - /// - internal static string FormatParseError_Expected_CloseBracket_Before_EOF(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_CloseBracket_Before_EOF"), p0, p1); - - /// - /// The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. - /// - internal static string ParseError_Expected_EndOfBlock_Before_EOF - { - get => GetString("ParseError_Expected_EndOfBlock_Before_EOF"); - } - - /// - /// The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. - /// - internal static string FormatParseError_Expected_EndOfBlock_Before_EOF(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_EndOfBlock_Before_EOF"), p0, p1, p2); - - /// - /// Expected "{0}". - /// - internal static string ParseError_Expected_X - { - get => GetString("ParseError_Expected_X"); - } - - /// - /// Expected "{0}". - /// - internal static string FormatParseError_Expected_X(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_X"), p0); - - /// - /// The {0} directive is not supported. - /// - internal static string ParseError_HelperDirectiveNotAvailable - { - get => GetString("ParseError_HelperDirectiveNotAvailable"); - } - - /// - /// The {0} directive is not supported. - /// - internal static string FormatParseError_HelperDirectiveNotAvailable(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_HelperDirectiveNotAvailable"), p0); - - /// - /// Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. - /// - internal static string ParseError_IncompleteQuotesAroundDirective - { - get => GetString("ParseError_IncompleteQuotesAroundDirective"); - } - - /// - /// Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. - /// - internal static string FormatParseError_IncompleteQuotesAroundDirective(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_IncompleteQuotesAroundDirective"), p0); - - /// - /// The 'inherits' keyword must be followed by a type name on the same line. - /// - internal static string ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName - { - get => GetString("ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName"); - } - - /// - /// The 'inherits' keyword must be followed by a type name on the same line. - /// - internal static string FormatParseError_InheritsKeyword_Must_Be_Followed_By_TypeName() - => GetString("ParseError_InheritsKeyword_Must_Be_Followed_By_TypeName"); - - /// - /// Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. - /// - internal static string ParseError_InlineMarkup_Blocks_Cannot_Be_Nested - { - get => GetString("ParseError_InlineMarkup_Blocks_Cannot_Be_Nested"); - } - - /// - /// Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. - /// - internal static string FormatParseError_InlineMarkup_Blocks_Cannot_Be_Nested() - => GetString("ParseError_InlineMarkup_Blocks_Cannot_Be_Nested"); - - /// - /// Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". - /// - internal static string ParseError_MarkupBlock_Must_Start_With_Tag - { - get => GetString("ParseError_MarkupBlock_Must_Start_With_Tag"); - } - - /// - /// Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". - /// - internal static string FormatParseError_MarkupBlock_Must_Start_With_Tag() - => GetString("ParseError_MarkupBlock_Must_Start_With_Tag"); - - /// - /// The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. - /// - internal static string ParseError_MissingEndTag - { - get => GetString("ParseError_MissingEndTag"); - } - - /// - /// The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. - /// - internal static string FormatParseError_MissingEndTag(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_MissingEndTag"), p0); - - /// - /// Sections cannot be empty. The "@section" keyword must be followed by a block of markup surrounded by "{}". For example: - /// - /// @section Sidebar { - /// <!-- Markup and text goes here --> - /// } - /// - internal static string ParseError_MissingOpenBraceAfterSection - { - get => GetString("ParseError_MissingOpenBraceAfterSection"); - } - - /// - /// Sections cannot be empty. The "@section" keyword must be followed by a block of markup surrounded by "{}". For example: - /// - /// @section Sidebar { - /// <!-- Markup and text goes here --> - /// } - /// - internal static string FormatParseError_MissingOpenBraceAfterSection() - => GetString("ParseError_MissingOpenBraceAfterSection"); - - /// - /// 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. - /// } - /// - internal static string ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock - { - get => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); - } - - /// - /// 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. - /// } - /// - internal static string FormatParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock() - => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); - - /// - /// Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. - /// - internal static string ParseError_OuterTagMissingName - { - get => GetString("ParseError_OuterTagMissingName"); - } - - /// - /// Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. - /// - internal static string FormatParseError_OuterTagMissingName() - => GetString("ParseError_OuterTagMissingName"); - - /// - /// 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. - /// - internal static string ParseError_RazorComment_Not_Terminated - { - get => GetString("ParseError_RazorComment_Not_Terminated"); - } - - /// - /// 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. - /// - internal static string FormatParseError_RazorComment_Not_Terminated() - => GetString("ParseError_RazorComment_Not_Terminated"); - - /// - /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. - /// - internal static string ParseError_ReservedWord - { - get => GetString("ParseError_ReservedWord"); - } - - /// - /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. - /// - internal static string FormatParseError_ReservedWord(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_ReservedWord"), p0); - - /// - /// Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. - /// - internal static string ParseError_Sections_Cannot_Be_Nested - { - get => GetString("ParseError_Sections_Cannot_Be_Nested"); - } - - /// - /// Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. - /// - internal static string FormatParseError_Sections_Cannot_Be_Nested(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Sections_Cannot_Be_Nested"), p0); - - /// - /// Expected a "{0}" but found a "{1}". 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) - /// <p>Hello, @user</p> - /// - /// Instead, wrap the contents of the block in "{{}}": - /// - /// @if(isLoggedIn) {{ - /// <p>Hello, @user</p> - /// }} - /// - internal static string ParseError_SingleLine_ControlFlowStatements_Not_Allowed - { - get => GetString("ParseError_SingleLine_ControlFlowStatements_Not_Allowed"); - } - - /// - /// Expected a "{0}" but found a "{1}". 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) - /// <p>Hello, @user</p> - /// - /// Instead, wrap the contents of the block in "{{}}": - /// - /// @if(isLoggedIn) {{ - /// <p>Hello, @user</p> - /// }} - /// - internal static string FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_SingleLine_ControlFlowStatements_Not_Allowed"), p0, p1); - - /// - /// "<text>" and "</text>" tags cannot contain attributes. - /// - internal static string ParseError_TextTagCannotContainAttributes - { - get => GetString("ParseError_TextTagCannotContainAttributes"); - } - - /// - /// "<text>" and "</text>" tags cannot contain attributes. - /// - internal static string FormatParseError_TextTagCannotContainAttributes() - => GetString("ParseError_TextTagCannotContainAttributes"); - - /// - /// Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? - /// - internal static string ParseError_UnexpectedEndTag - { - get => GetString("ParseError_UnexpectedEndTag"); - } - - /// - /// Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? - /// - internal static string FormatParseError_UnexpectedEndTag(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_UnexpectedEndTag"), p0); - - /// - /// Unexpected {0} after section keyword. Section names must start with an "_" or alphabetic character, and the remaining characters must be either "_" or alphanumeric. - /// - internal static string ParseError_Unexpected_Character_At_Section_Name_Start - { - get => GetString("ParseError_Unexpected_Character_At_Section_Name_Start"); - } - - /// - /// Unexpected {0} after section keyword. Section names must start with an "_" or alphabetic character, and the remaining characters must be either "_" or alphanumeric. - /// - internal static string FormatParseError_Unexpected_Character_At_Section_Name_Start(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Unexpected_Character_At_Section_Name_Start"), p0); - - /// - /// "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. - /// - internal static string ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS - { - get => GetString("ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS"); - } - - /// - /// "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. - /// - internal static string FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS"), p0); - - /// - /// 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: "@@" - /// - internal static string ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock - { - get => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock"); - } - - /// - /// 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: "@@" - /// - internal static string FormatParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock() - => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock"); - - /// - /// 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: "@@" - /// - internal static string ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1 - { - get => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1"); - } - - /// - /// 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: "@@" - /// - internal static string FormatParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1() - => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1"); - - /// - /// Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. - /// - internal static string ParseError_Unexpected_Nested_CodeBlock - { - get => GetString("ParseError_Unexpected_Nested_CodeBlock"); - } - - /// - /// Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. - /// - internal static string FormatParseError_Unexpected_Nested_CodeBlock() - => GetString("ParseError_Unexpected_Nested_CodeBlock"); - - /// - /// 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. - /// - internal static string ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS - { - get => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS"); - } - - /// - /// 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. - /// - internal static string FormatParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS() - => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS"); - - /// - /// End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. - /// - internal static string ParseError_UnfinishedTag - { - get => GetString("ParseError_UnfinishedTag"); - } - - /// - /// End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. - /// - internal static string FormatParseError_UnfinishedTag(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_UnfinishedTag"), p0); - - /// - /// 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. - /// - internal static string ParseError_Unterminated_String_Literal - { - get => GetString("ParseError_Unterminated_String_Literal"); - } - - /// - /// 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. - /// - internal static string FormatParseError_Unterminated_String_Literal() - => GetString("ParseError_Unterminated_String_Literal"); - - /// - /// Cannot complete the tree, StartBlock must be called at least once. - /// - internal static string ParserContext_CannotCompleteTree_NoRootBlock - { - get => GetString("ParserContext_CannotCompleteTree_NoRootBlock"); - } - - /// - /// Cannot complete the tree, StartBlock must be called at least once. - /// - internal static string FormatParserContext_CannotCompleteTree_NoRootBlock() - => GetString("ParserContext_CannotCompleteTree_NoRootBlock"); - - /// - /// Cannot complete the tree, there are still open blocks. - /// - internal static string ParserContext_CannotCompleteTree_OutstandingBlocks - { - get => GetString("ParserContext_CannotCompleteTree_OutstandingBlocks"); - } - - /// - /// Cannot complete the tree, there are still open blocks. - /// - internal static string FormatParserContext_CannotCompleteTree_OutstandingBlocks() - => GetString("ParserContext_CannotCompleteTree_OutstandingBlocks"); - - /// - /// Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span - /// - internal static string ParserContext_NoCurrentBlock - { - get => GetString("ParserContext_NoCurrentBlock"); - } - - /// - /// Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span - /// - internal static string FormatParserContext_NoCurrentBlock() - => GetString("ParserContext_NoCurrentBlock"); - - /// - /// Cannot complete action, the parser has finished. Only CompleteParse can be called to extract the final parser results after the parser has finished - /// - internal static string ParserContext_ParseComplete - { - get => GetString("ParserContext_ParseComplete"); - } - - /// - /// Cannot complete action, the parser has finished. Only CompleteParse can be called to extract the final parser results after the parser has finished - /// - internal static string FormatParserContext_ParseComplete() - => GetString("ParserContext_ParseComplete"); - - /// - /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. - /// - internal static string Parser_Context_Not_Set - { - get => GetString("Parser_Context_Not_Set"); - } - - /// - /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. - /// - internal static string FormatParser_Context_Not_Set() - => GetString("Parser_Context_Not_Set"); - - /// - /// Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. - /// - internal static string RewriterError_EmptyTagHelperBoundAttribute - { - get => GetString("RewriterError_EmptyTagHelperBoundAttribute"); - } - - /// - /// Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. - /// - internal static string FormatRewriterError_EmptyTagHelperBoundAttribute(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("RewriterError_EmptyTagHelperBoundAttribute"), p0, p1, p2); - - /// - /// @section Header { ... } - /// - internal static string SectionExample_CS - { - get => GetString("SectionExample_CS"); - } - - /// - /// @section Header { ... } - /// - internal static string FormatSectionExample_CS() - => GetString("SectionExample_CS"); - - /// - /// Cannot perform '{1}' operations on '{0}' instances with different file paths. - /// - internal static string SourceLocationFilePathDoesNotMatch - { - get => GetString("SourceLocationFilePathDoesNotMatch"); - } - - /// - /// Cannot perform '{1}' operations on '{0}' instances with different file paths. - /// - internal static string FormatSourceLocationFilePathDoesNotMatch(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("SourceLocationFilePathDoesNotMatch"), p0, p1); - - /// - /// <<unknown>> - /// - internal static string Symbol_Unknown - { - get => GetString("Symbol_Unknown"); - } - - /// - /// <<unknown>> - /// - internal static string FormatSymbol_Unknown() - => GetString("Symbol_Unknown"); - - /// - /// The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. - /// - internal static string TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey - { - get => GetString("TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey"); - } - - /// - /// The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. - /// - internal static string FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey"), p0, p1); - - /// - /// TagHelper attributes must be well-formed. - /// - internal static string TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed - { - get => GetString("TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed"); - } - - /// - /// TagHelper attributes must be well-formed. - /// - internal static string FormatTagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed() - => GetString("TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed"); - - /// - /// The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. - /// - internal static string TagHelperParseTreeRewriter_CannotHaveNonTagContent - { - get => GetString("TagHelperParseTreeRewriter_CannotHaveNonTagContent"); - } - - /// - /// The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. - /// - internal static string FormatTagHelperParseTreeRewriter_CannotHaveNonTagContent(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_CannotHaveNonTagContent"), p0, p1); - - /// - /// Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). - /// - internal static string TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag - { - get => GetString("TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag"); - } - - /// - /// Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). - /// - internal static string FormatTagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag"), p0, p1, p2); - - /// - /// Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. - /// - internal static string TagHelperParseTreeRewriter_InconsistentTagStructure - { - get => GetString("TagHelperParseTreeRewriter_InconsistentTagStructure"); - } - - /// - /// Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. - /// - internal static string FormatTagHelperParseTreeRewriter_InconsistentTagStructure(object p0, object p1, object p2, object p3) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_InconsistentTagStructure"), p0, p1, p2, p3); - - /// - /// The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. - /// - internal static string TagHelperParseTreeRewriter_InvalidNestedTag - { - get => GetString("TagHelperParseTreeRewriter_InvalidNestedTag"); - } - - /// - /// The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. - /// - internal static string FormatTagHelperParseTreeRewriter_InvalidNestedTag(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_InvalidNestedTag"), p0, p1, p2); - - /// - /// Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. - /// - internal static string TagHelpersParseTreeRewriter_FoundMalformedTagHelper - { - get => GetString("TagHelpersParseTreeRewriter_FoundMalformedTagHelper"); - } - - /// - /// Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. - /// - internal static string FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpersParseTreeRewriter_FoundMalformedTagHelper"), p0); - - /// - /// Missing close angle for tag helper '{0}'. - /// - internal static string TagHelpersParseTreeRewriter_MissingCloseAngle - { - get => GetString("TagHelpersParseTreeRewriter_MissingCloseAngle"); - } - - /// - /// Missing close angle for tag helper '{0}'. - /// - internal static string FormatTagHelpersParseTreeRewriter_MissingCloseAngle(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpersParseTreeRewriter_MissingCloseAngle"), p0); - - /// - /// Tag Helper '{0}'s attributes must have names. - /// - internal static string TagHelpers_AttributesMustHaveAName - { - get => GetString("TagHelpers_AttributesMustHaveAName"); - } - - /// - /// Tag Helper '{0}'s attributes must have names. - /// - internal static string FormatTagHelpers_AttributesMustHaveAName(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_AttributesMustHaveAName"), p0); - - /// - /// The tag helper '{0}' must not have C# in the element's attribute declaration area. - /// - internal static string TagHelpers_CannotHaveCSharpInTagDeclaration - { - get => GetString("TagHelpers_CannotHaveCSharpInTagDeclaration"); - } - - /// - /// The tag helper '{0}' must not have C# in the element's attribute declaration area. - /// - internal static string FormatTagHelpers_CannotHaveCSharpInTagDeclaration(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_CannotHaveCSharpInTagDeclaration"), p0); - - /// - /// Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. - /// Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. - /// - internal static string TagHelpers_CodeBlocks_NotSupported_InAttributes - { - get => GetString("TagHelpers_CodeBlocks_NotSupported_InAttributes"); - } - - /// - /// Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. - /// Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. - /// - internal static string FormatTagHelpers_CodeBlocks_NotSupported_InAttributes() - => GetString("TagHelpers_CodeBlocks_NotSupported_InAttributes"); - - /// - /// Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. - /// Expected a '{0}' attribute value, not a string. - /// - internal static string TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes - { - get => GetString("TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes"); - } - - /// - /// Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. - /// Expected a '{0}' attribute value, not a string. - /// - internal static string FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes"), p0); - - /// - /// In order to put a symbol back, it must have been the symbol which ended at the current position. The specified symbol ends at {0}, but the current position is {1} - /// - internal static string TokenizerView_CannotPutBack - { - get => GetString("TokenizerView_CannotPutBack"); - } - - /// - /// In order to put a symbol back, it must have been the symbol which ended at the current position. The specified symbol ends at {0}, but the current position is {1} - /// - internal static string FormatTokenizerView_CannotPutBack(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("TokenizerView_CannotPutBack"), p0, p1); - - /// - /// Unexpected literal following the '{0}' directive. Expected '{1}'. - /// - internal static string UnexpectedDirectiveLiteral - { - get => GetString("UnexpectedDirectiveLiteral"); - } - - /// - /// Unexpected literal following the '{0}' directive. Expected '{1}'. - /// - internal static string FormatUnexpectedDirectiveLiteral(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedDirectiveLiteral"), p0, p1); - - /// - /// Unexpected end of file following the '{0}' directive. Expected '{1}'. - /// - internal static string UnexpectedEOFAfterDirective - { - get => GetString("UnexpectedEOFAfterDirective"); - } - - /// - /// Unexpected end of file following the '{0}' directive. Expected '{1}'. - /// - internal static string FormatUnexpectedEOFAfterDirective(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedEOFAfterDirective"), p0, p1); - - private static string GetString(string name, params string[] formatterNames) - { - var value = _resourceManager.GetString(name); - - System.Diagnostics.Debug.Assert(value != null); - - if (formatterNames != null) - { - for (var i = 0; i < formatterNames.Length; i++) - { - value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); - } - } - - return value; - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs index 1f95e0176c..a785a39bca 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Properties/Resources.Designer.cs @@ -10,6 +10,48 @@ namespace Microsoft.AspNetCore.Razor.Language private static readonly ResourceManager _resourceManager = new ResourceManager("Microsoft.AspNetCore.Razor.Language.Resources", typeof(Resources).GetTypeInfo().Assembly); + /// + /// Register Tag Helpers for use in the current document. + /// + internal static string AddTagHelperDirective_Description + { + get => GetString("AddTagHelperDirective_Description"); + } + + /// + /// Register Tag Helpers for use in the current document. + /// + internal static string FormatAddTagHelperDirective_Description() + => GetString("AddTagHelperDirective_Description"); + + /// + /// Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. + /// + internal static string AddTagHelperDirective_StringToken_Description + { + get => GetString("AddTagHelperDirective_StringToken_Description"); + } + + /// + /// Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. + /// + internal static string FormatAddTagHelperDirective_StringToken_Description() + => GetString("AddTagHelperDirective_StringToken_Description"); + + /// + /// TypeName, AssemblyName + /// + internal static string AddTagHelperDirective_StringToken_Name + { + get => GetString("AddTagHelperDirective_StringToken_Name"); + } + + /// + /// TypeName, AssemblyName + /// + internal static string FormatAddTagHelperDirective_StringToken_Name() + => GetString("AddTagHelperDirective_StringToken_Name"); + /// /// Value cannot be null or an empty string. /// @@ -24,6 +66,384 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatArgumentCannotBeNullOrEmpty() => GetString("ArgumentCannotBeNullOrEmpty"); + /// + /// Block cannot be built because a Type has not been specified in the BlockBuilder + /// + internal static string Block_Type_Not_Specified + { + get => GetString("Block_Type_Not_Specified"); + } + + /// + /// Block cannot be built because a Type has not been specified in the BlockBuilder + /// + internal static string FormatBlock_Type_Not_Specified() + => GetString("Block_Type_Not_Specified"); + + /// + /// Block directive '{0}' cannot be imported. + /// + internal static string BlockDirectiveCannotBeImported + { + get => GetString("BlockDirectiveCannotBeImported"); + } + + /// + /// Block directive '{0}' cannot be imported. + /// + internal static string FormatBlockDirectiveCannotBeImported(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("BlockDirectiveCannotBeImported"), p0); + + /// + /// code + /// + internal static string BlockName_Code + { + get => GetString("BlockName_Code"); + } + + /// + /// code + /// + internal static string FormatBlockName_Code() + => GetString("BlockName_Code"); + + /// + /// explicit expression + /// + internal static string BlockName_ExplicitExpression + { + get => GetString("BlockName_ExplicitExpression"); + } + + /// + /// explicit expression + /// + internal static string FormatBlockName_ExplicitExpression() + => GetString("BlockName_ExplicitExpression"); + + /// + /// Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. + /// + internal static string CodeWriter_InvalidNewLine + { + get => GetString("CodeWriter_InvalidNewLine"); + } + + /// + /// Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. + /// + internal static string FormatCodeWriter_InvalidNewLine(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("CodeWriter_InvalidNewLine"), p0); + + /// + /// <<character literal>> + /// + internal static string CSharpSymbol_CharacterLiteral + { + get => GetString("CSharpSymbol_CharacterLiteral"); + } + + /// + /// <<character literal>> + /// + internal static string FormatCSharpSymbol_CharacterLiteral() + => GetString("CSharpSymbol_CharacterLiteral"); + + /// + /// <<comment>> + /// + internal static string CSharpSymbol_Comment + { + get => GetString("CSharpSymbol_Comment"); + } + + /// + /// <<comment>> + /// + internal static string FormatCSharpSymbol_Comment() + => GetString("CSharpSymbol_Comment"); + + /// + /// <<identifier>> + /// + internal static string CSharpSymbol_Identifier + { + get => GetString("CSharpSymbol_Identifier"); + } + + /// + /// <<identifier>> + /// + internal static string FormatCSharpSymbol_Identifier() + => GetString("CSharpSymbol_Identifier"); + + /// + /// <<integer literal>> + /// + internal static string CSharpSymbol_IntegerLiteral + { + get => GetString("CSharpSymbol_IntegerLiteral"); + } + + /// + /// <<integer literal>> + /// + internal static string FormatCSharpSymbol_IntegerLiteral() + => GetString("CSharpSymbol_IntegerLiteral"); + + /// + /// <<keyword>> + /// + internal static string CSharpSymbol_Keyword + { + get => GetString("CSharpSymbol_Keyword"); + } + + /// + /// <<keyword>> + /// + internal static string FormatCSharpSymbol_Keyword() + => GetString("CSharpSymbol_Keyword"); + + /// + /// <<newline sequence>> + /// + internal static string CSharpSymbol_Newline + { + get => GetString("CSharpSymbol_Newline"); + } + + /// + /// <<newline sequence>> + /// + internal static string FormatCSharpSymbol_Newline() + => GetString("CSharpSymbol_Newline"); + + /// + /// <<real literal>> + /// + internal static string CSharpSymbol_RealLiteral + { + get => GetString("CSharpSymbol_RealLiteral"); + } + + /// + /// <<real literal>> + /// + internal static string FormatCSharpSymbol_RealLiteral() + => GetString("CSharpSymbol_RealLiteral"); + + /// + /// <<string literal>> + /// + internal static string CSharpSymbol_StringLiteral + { + get => GetString("CSharpSymbol_StringLiteral"); + } + + /// + /// <<string literal>> + /// + internal static string FormatCSharpSymbol_StringLiteral() + => GetString("CSharpSymbol_StringLiteral"); + + /// + /// <<white space>> + /// + internal static string CSharpSymbol_Whitespace + { + get => GetString("CSharpSymbol_Whitespace"); + } + + /// + /// <<white space>> + /// + internal static string FormatCSharpSymbol_Whitespace() + => GetString("CSharpSymbol_Whitespace"); + + /// + /// The document type '{0}' does not support the extension '{1}'. + /// + internal static string Diagnostic_CodeTarget_UnsupportedExtension + { + get => GetString("Diagnostic_CodeTarget_UnsupportedExtension"); + } + + /// + /// The document type '{0}' does not support the extension '{1}'. + /// + internal static string FormatDiagnostic_CodeTarget_UnsupportedExtension(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("Diagnostic_CodeTarget_UnsupportedExtension"), p0, p1); + + /// + /// Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + /// + internal static string DirectiveDescriptor_InvalidDirectiveKeyword + { + get => GetString("DirectiveDescriptor_InvalidDirectiveKeyword"); + } + + /// + /// Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + /// + internal static string FormatDirectiveDescriptor_InvalidDirectiveKeyword(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveDescriptor_InvalidDirectiveKeyword"), p0); + + /// + /// A non-optional directive token cannot follow an optional directive token. + /// + internal static string DirectiveDescriptor_InvalidNonOptionalToken + { + get => GetString("DirectiveDescriptor_InvalidNonOptionalToken"); + } + + /// + /// A non-optional directive token cannot follow an optional directive token. + /// + internal static string FormatDirectiveDescriptor_InvalidNonOptionalToken() + => GetString("DirectiveDescriptor_InvalidNonOptionalToken"); + + /// + /// The '{0}' directive expects an identifier. + /// + internal static string DirectiveExpectsIdentifier + { + get => GetString("DirectiveExpectsIdentifier"); + } + + /// + /// The '{0}' directive expects an identifier. + /// + internal static string FormatDirectiveExpectsIdentifier(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsIdentifier"), p0); + + /// + /// The '{0}' directive expects a namespace name. + /// + internal static string DirectiveExpectsNamespace + { + get => GetString("DirectiveExpectsNamespace"); + } + + /// + /// The '{0}' directive expects a namespace name. + /// + internal static string FormatDirectiveExpectsNamespace(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsNamespace"), p0); + + /// + /// The '{0}' directive expects a string surrounded by double quotes. + /// + internal static string DirectiveExpectsQuotedStringLiteral + { + get => GetString("DirectiveExpectsQuotedStringLiteral"); + } + + /// + /// The '{0}' directive expects a string surrounded by double quotes. + /// + internal static string FormatDirectiveExpectsQuotedStringLiteral(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsQuotedStringLiteral"), p0); + + /// + /// The '{0}' directive expects a type name. + /// + internal static string DirectiveExpectsTypeName + { + get => GetString("DirectiveExpectsTypeName"); + } + + /// + /// The '{0}' directive expects a type name. + /// + internal static string FormatDirectiveExpectsTypeName(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveExpectsTypeName"), p0); + + /// + /// The '{0}` directive must appear at the start of the line. + /// + internal static string DirectiveMustAppearAtStartOfLine + { + get => GetString("DirectiveMustAppearAtStartOfLine"); + } + + /// + /// The '{0}` directive must appear at the start of the line. + /// + internal static string FormatDirectiveMustAppearAtStartOfLine(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveMustAppearAtStartOfLine"), p0); + + /// + /// The '{0}' directives value(s) must be separated by whitespace. + /// + internal static string DirectiveTokensMustBeSeparatedByWhitespace + { + get => GetString("DirectiveTokensMustBeSeparatedByWhitespace"); + } + + /// + /// The '{0}' directives value(s) must be separated by whitespace. + /// + internal static string FormatDirectiveTokensMustBeSeparatedByWhitespace(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveTokensMustBeSeparatedByWhitespace"), p0); + + /// + /// The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. + /// + internal static string DocumentMissingTarget + { + get => GetString("DocumentMissingTarget"); + } + + /// + /// The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. + /// + internal static string FormatDocumentMissingTarget(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("DocumentMissingTarget"), p0, p1, p2); + + /// + /// The '{0}' directive may only occur once per document. + /// + internal static string DuplicateDirective + { + get => GetString("DuplicateDirective"); + } + + /// + /// The '{0}' directive may only occur once per document. + /// + internal static string FormatDuplicateDirective(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("DuplicateDirective"), p0); + + /// + /// "EndBlock" was called without a matching call to "StartBlock". + /// + internal static string EndBlock_Called_Without_Matching_StartBlock + { + get => GetString("EndBlock_Called_Without_Matching_StartBlock"); + } + + /// + /// "EndBlock" was called without a matching call to "StartBlock". + /// + internal static string FormatEndBlock_Called_Without_Matching_StartBlock() + => GetString("EndBlock_Called_Without_Matching_StartBlock"); + + /// + /// line break + /// + internal static string ErrorComponent_Newline + { + get => GetString("ErrorComponent_Newline"); + } + + /// + /// line break + /// + internal static string FormatErrorComponent_Newline() + => GetString("ErrorComponent_Newline"); + /// /// The '{0}' feature requires a '{1}' provided by the '{2}'. /// @@ -38,6 +458,216 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatFeatureDependencyMissing(object p0, object p1, object p2) => string.Format(CultureInfo.CurrentCulture, GetString("FeatureDependencyMissing"), p0, p1, p2); + /// + /// The feature must be initialized by setting the '{0}' property. + /// + internal static string FeatureMustBeInitialized + { + get => GetString("FeatureMustBeInitialized"); + } + + /// + /// The feature must be initialized by setting the '{0}' property. + /// + internal static string FormatFeatureMustBeInitialized(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("FeatureMustBeInitialized"), p0); + + /// + /// Specify a C# code block. + /// + internal static string FunctionsDirective_Description + { + get => GetString("FunctionsDirective_Description"); + } + + /// + /// Specify a C# code block. + /// + internal static string FormatFunctionsDirective_Description() + => GetString("FunctionsDirective_Description"); + + /// + /// <<newline sequence>> + /// + internal static string HtmlSymbol_NewLine + { + get => GetString("HtmlSymbol_NewLine"); + } + + /// + /// <<newline sequence>> + /// + internal static string FormatHtmlSymbol_NewLine() + => GetString("HtmlSymbol_NewLine"); + + /// + /// <<razor comment>> + /// + internal static string HtmlSymbol_RazorComment + { + get => GetString("HtmlSymbol_RazorComment"); + } + + /// + /// <<razor comment>> + /// + internal static string FormatHtmlSymbol_RazorComment() + => GetString("HtmlSymbol_RazorComment"); + + /// + /// <<text>> + /// + internal static string HtmlSymbol_Text + { + get => GetString("HtmlSymbol_Text"); + } + + /// + /// <<text>> + /// + internal static string FormatHtmlSymbol_Text() + => GetString("HtmlSymbol_Text"); + + /// + /// <<white space>> + /// + internal static string HtmlSymbol_WhiteSpace + { + get => GetString("HtmlSymbol_WhiteSpace"); + } + + /// + /// <<white space>> + /// + internal static string FormatHtmlSymbol_WhiteSpace() + => GetString("HtmlSymbol_WhiteSpace"); + + /// + /// Specify the base class for the current document. + /// + internal static string InheritsDirective_Description + { + get => GetString("InheritsDirective_Description"); + } + + /// + /// Specify the base class for the current document. + /// + internal static string FormatInheritsDirective_Description() + => GetString("InheritsDirective_Description"); + + /// + /// The base type that the current page inherits. + /// + internal static string InheritsDirective_TypeToken_Description + { + get => GetString("InheritsDirective_TypeToken_Description"); + } + + /// + /// The base type that the current page inherits. + /// + internal static string FormatInheritsDirective_TypeToken_Description() + => GetString("InheritsDirective_TypeToken_Description"); + + /// + /// TypeName + /// + internal static string InheritsDirective_TypeToken_Name + { + get => GetString("InheritsDirective_TypeToken_Name"); + } + + /// + /// TypeName + /// + internal static string FormatInheritsDirective_TypeToken_Name() + => GetString("InheritsDirective_TypeToken_Name"); + + /// + /// The '{0}' operation is not valid when the builder is empty. + /// + internal static string IntermediateNodeBuilder_PopInvalid + { + get => GetString("IntermediateNodeBuilder_PopInvalid"); + } + + /// + /// The '{0}' operation is not valid when the builder is empty. + /// + internal static string FormatIntermediateNodeBuilder_PopInvalid(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeBuilder_PopInvalid"), p0); + + /// + /// The node '{0}' has a read-only child collection and cannot be modified. + /// + internal static string IntermediateNodeReference_CollectionIsReadOnly + { + get => GetString("IntermediateNodeReference_CollectionIsReadOnly"); + } + + /// + /// The node '{0}' has a read-only child collection and cannot be modified. + /// + internal static string FormatIntermediateNodeReference_CollectionIsReadOnly(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeReference_CollectionIsReadOnly"), p0); + + /// + /// The reference is invalid. The node '{0}' could not be found as a child of '{1}'. + /// + internal static string IntermediateNodeReference_NodeNotFound + { + get => GetString("IntermediateNodeReference_NodeNotFound"); + } + + /// + /// The reference is invalid. The node '{0}' could not be found as a child of '{1}'. + /// + internal static string FormatIntermediateNodeReference_NodeNotFound(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeReference_NodeNotFound"), p0, p1); + + /// + /// The reference is invalid. References initialized with the default constructor cannot modify nodes. + /// + internal static string IntermediateNodeReference_NotInitialized + { + get => GetString("IntermediateNodeReference_NotInitialized"); + } + + /// + /// The reference is invalid. References initialized with the default constructor cannot modify nodes. + /// + internal static string FormatIntermediateNodeReference_NotInitialized() + => GetString("IntermediateNodeReference_NotInitialized"); + + /// + /// The '{0}' node type can only be used as a direct child of a '{1}' node. + /// + internal static string IntermediateNodes_InvalidParentNode + { + get => GetString("IntermediateNodes_InvalidParentNode"); + } + + /// + /// The '{0}' node type can only be used as a direct child of a '{1}' node. + /// + internal static string FormatIntermediateNodes_InvalidParentNode(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodes_InvalidParentNode"), p0, p1); + + /// + /// The node '{0}' is not the owner of change '{1}'. + /// + internal static string InvalidOperation_SpanIsNotChangeOwner + { + get => GetString("InvalidOperation_SpanIsNotChangeOwner"); + } + + /// + /// The node '{0}' is not the owner of change '{1}'. + /// + internal static string FormatInvalidOperation_SpanIsNotChangeOwner(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("InvalidOperation_SpanIsNotChangeOwner"), p0, p1); + /// /// Invalid tag helper directive look up text '{0}'. The correct look up text format is: "name, assemblyName". /// @@ -67,18 +697,32 @@ namespace Microsoft.AspNetCore.Razor.Language => string.Format(CultureInfo.CurrentCulture, GetString("InvalidTagHelperPrefixValue"), p0, p1, p2); /// - /// The '{0}' operation is not valid when the builder is empty. + /// The key must not be null. /// - internal static string IntermediateNodeBuilder_PopInvalid + internal static string KeyMustNotBeNull { - get => GetString("IntermediateNodeBuilder_PopInvalid"); + get => GetString("KeyMustNotBeNull"); } /// - /// The '{0}' operation is not valid when the builder is empty. + /// The key must not be null. /// - internal static string FormatIntermediateNodeBuilder_PopInvalid(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeBuilder_PopInvalid"), p0); + internal static string FormatKeyMustNotBeNull() + => 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 + /// + internal static string Language_Does_Not_Support_RazorComment + { + get => GetString("Language_Does_Not_Support_RazorComment"); + } + + /// + /// 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 + /// + internal static string FormatLanguage_Does_Not_Support_RazorComment() + => GetString("Language_Does_Not_Support_RazorComment"); /// /// The specified encoding '{0}' does not match the content's encoding '{1}'. @@ -94,6 +738,434 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatMismatchedContentEncoding(object p0, object p1) => string.Format(CultureInfo.CurrentCulture, GetString("MismatchedContentEncoding"), p0, p1); + /// + /// 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) {{ + /// <p>Hello, @user!</p> + /// }} + /// + internal static string ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start + { + get => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); + } + + /// + /// 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) {{ + /// <p>Hello, @user!</p> + /// }} + /// + internal static string FormatParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start() + => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); + + /// + /// End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. + /// + internal static string ParseError_BlockComment_Not_Terminated + { + get => GetString("ParseError_BlockComment_Not_Terminated"); + } + + /// + /// End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. + /// + internal static string FormatParseError_BlockComment_Not_Terminated() + => GetString("ParseError_BlockComment_Not_Terminated"); + + /// + /// Directive '{0}' must have a value. + /// + internal static string ParseError_DirectiveMustHaveValue + { + get => GetString("ParseError_DirectiveMustHaveValue"); + } + + /// + /// Directive '{0}' must have a value. + /// + internal static string FormatParseError_DirectiveMustHaveValue(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_DirectiveMustHaveValue"), p0); + + /// + /// An opening "{0}" is missing the corresponding closing "{1}". + /// + internal static string ParseError_Expected_CloseBracket_Before_EOF + { + get => GetString("ParseError_Expected_CloseBracket_Before_EOF"); + } + + /// + /// An opening "{0}" is missing the corresponding closing "{1}". + /// + internal static string FormatParseError_Expected_CloseBracket_Before_EOF(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_CloseBracket_Before_EOF"), p0, p1); + + /// + /// The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. + /// + internal static string ParseError_Expected_EndOfBlock_Before_EOF + { + get => GetString("ParseError_Expected_EndOfBlock_Before_EOF"); + } + + /// + /// The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. + /// + internal static string FormatParseError_Expected_EndOfBlock_Before_EOF(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Expected_EndOfBlock_Before_EOF"), p0, p1, p2); + + /// + /// The {0} directive is not supported. + /// + internal static string ParseError_HelperDirectiveNotAvailable + { + get => GetString("ParseError_HelperDirectiveNotAvailable"); + } + + /// + /// The {0} directive is not supported. + /// + internal static string FormatParseError_HelperDirectiveNotAvailable(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_HelperDirectiveNotAvailable"), p0); + + /// + /// Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. + /// + internal static string ParseError_IncompleteQuotesAroundDirective + { + get => GetString("ParseError_IncompleteQuotesAroundDirective"); + } + + /// + /// Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. + /// + internal static string FormatParseError_IncompleteQuotesAroundDirective(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_IncompleteQuotesAroundDirective"), p0); + + /// + /// Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. + /// + internal static string ParseError_InlineMarkup_Blocks_Cannot_Be_Nested + { + get => GetString("ParseError_InlineMarkup_Blocks_Cannot_Be_Nested"); + } + + /// + /// Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. + /// + internal static string FormatParseError_InlineMarkup_Blocks_Cannot_Be_Nested() + => GetString("ParseError_InlineMarkup_Blocks_Cannot_Be_Nested"); + + /// + /// Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". + /// + internal static string ParseError_MarkupBlock_Must_Start_With_Tag + { + get => GetString("ParseError_MarkupBlock_Must_Start_With_Tag"); + } + + /// + /// Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". + /// + internal static string FormatParseError_MarkupBlock_Must_Start_With_Tag() + => GetString("ParseError_MarkupBlock_Must_Start_With_Tag"); + + /// + /// The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. + /// + internal static string ParseError_MissingEndTag + { + get => GetString("ParseError_MissingEndTag"); + } + + /// + /// The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. + /// + internal static string FormatParseError_MissingEndTag(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_MissingEndTag"), p0); + + /// + /// 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. + /// }} + /// + internal static string ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock + { + get => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); + } + + /// + /// 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. + /// }} + /// + internal static string FormatParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock() + => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); + + /// + /// Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. + /// + internal static string ParseError_OuterTagMissingName + { + get => GetString("ParseError_OuterTagMissingName"); + } + + /// + /// Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. + /// + internal static string FormatParseError_OuterTagMissingName() + => GetString("ParseError_OuterTagMissingName"); + + /// + /// 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. + /// + internal static string ParseError_RazorComment_Not_Terminated + { + get => GetString("ParseError_RazorComment_Not_Terminated"); + } + + /// + /// 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. + /// + internal static string FormatParseError_RazorComment_Not_Terminated() + => GetString("ParseError_RazorComment_Not_Terminated"); + + /// + /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. + /// + internal static string ParseError_ReservedWord + { + get => GetString("ParseError_ReservedWord"); + } + + /// + /// "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. + /// + internal static string FormatParseError_ReservedWord(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_ReservedWord"), p0); + + /// + /// Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. + /// + internal static string ParseError_Sections_Cannot_Be_Nested + { + get => GetString("ParseError_Sections_Cannot_Be_Nested"); + } + + /// + /// Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. + /// + internal static string FormatParseError_Sections_Cannot_Be_Nested(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Sections_Cannot_Be_Nested"), p0); + + /// + /// Expected a "{0}" but found a "{1}". 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) + /// <p>Hello, @user</p> + /// + /// Instead, wrap the contents of the block in "{{}}": + /// + /// @if(isLoggedIn) {{ + /// <p>Hello, @user</p> + /// }} + /// + internal static string ParseError_SingleLine_ControlFlowStatements_Not_Allowed + { + get => GetString("ParseError_SingleLine_ControlFlowStatements_Not_Allowed"); + } + + /// + /// Expected a "{0}" but found a "{1}". 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) + /// <p>Hello, @user</p> + /// + /// Instead, wrap the contents of the block in "{{}}": + /// + /// @if(isLoggedIn) {{ + /// <p>Hello, @user</p> + /// }} + /// + internal static string FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_SingleLine_ControlFlowStatements_Not_Allowed"), p0, p1); + + /// + /// "<text>" and "</text>" tags cannot contain attributes. + /// + internal static string ParseError_TextTagCannotContainAttributes + { + get => GetString("ParseError_TextTagCannotContainAttributes"); + } + + /// + /// "<text>" and "</text>" tags cannot contain attributes. + /// + internal static string FormatParseError_TextTagCannotContainAttributes() + => GetString("ParseError_TextTagCannotContainAttributes"); + + /// + /// "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. + /// + internal static string ParseError_Unexpected_Character_At_Start_Of_CodeBlock + { + get => GetString("ParseError_Unexpected_Character_At_Start_Of_CodeBlock"); + } + + /// + /// "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. + /// + internal static string FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Unexpected_Character_At_Start_Of_CodeBlock"), p0); + + /// + /// 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: "@@" + /// + internal static string ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock + { + get => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock"); + } + + /// + /// 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: "@@" + /// + internal static string FormatParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock() + => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock"); + + /// + /// Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. + /// + internal static string ParseError_Unexpected_Nested_CodeBlock + { + get => GetString("ParseError_Unexpected_Nested_CodeBlock"); + } + + /// + /// Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. + /// + internal static string FormatParseError_Unexpected_Nested_CodeBlock() + => GetString("ParseError_Unexpected_Nested_CodeBlock"); + + /// + /// 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. + /// + internal static string ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock + { + get => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock"); + } + + /// + /// 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. + /// + internal static string FormatParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock() + => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock"); + + /// + /// Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? + /// + internal static string ParseError_UnexpectedEndTag + { + get => GetString("ParseError_UnexpectedEndTag"); + } + + /// + /// Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? + /// + internal static string FormatParseError_UnexpectedEndTag(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_UnexpectedEndTag"), p0); + + /// + /// End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. + /// + internal static string ParseError_UnfinishedTag + { + get => GetString("ParseError_UnfinishedTag"); + } + + /// + /// End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. + /// + internal static string FormatParseError_UnfinishedTag(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("ParseError_UnfinishedTag"), p0); + + /// + /// 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. + /// + internal static string ParseError_Unterminated_String_Literal + { + get => GetString("ParseError_Unterminated_String_Literal"); + } + + /// + /// 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. + /// + internal static string FormatParseError_Unterminated_String_Literal() + => GetString("ParseError_Unterminated_String_Literal"); + + /// + /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. + /// + internal static string Parser_Context_Not_Set + { + get => GetString("Parser_Context_Not_Set"); + } + + /// + /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. + /// + internal static string FormatParser_Context_Not_Set() + => GetString("Parser_Context_Not_Set"); + + /// + /// Cannot complete the tree, StartBlock must be called at least once. + /// + internal static string ParserContext_CannotCompleteTree_NoRootBlock + { + get => GetString("ParserContext_CannotCompleteTree_NoRootBlock"); + } + + /// + /// Cannot complete the tree, StartBlock must be called at least once. + /// + internal static string FormatParserContext_CannotCompleteTree_NoRootBlock() + => GetString("ParserContext_CannotCompleteTree_NoRootBlock"); + + /// + /// Cannot complete the tree, there are still open blocks. + /// + internal static string ParserContext_CannotCompleteTree_OutstandingBlocks + { + get => GetString("ParserContext_CannotCompleteTree_OutstandingBlocks"); + } + + /// + /// Cannot complete the tree, there are still open blocks. + /// + internal static string FormatParserContext_CannotCompleteTree_OutstandingBlocks() + => GetString("ParserContext_CannotCompleteTree_OutstandingBlocks"); + + /// + /// Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span + /// + internal static string ParserContext_NoCurrentBlock + { + get => GetString("ParserContext_NoCurrentBlock"); + } + + /// + /// Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span + /// + internal static string FormatParserContext_NoCurrentBlock() + => GetString("ParserContext_NoCurrentBlock"); + /// /// The '{0}' phase requires a '{1}' provided by the '{2}'. /// @@ -122,20 +1194,6 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatPhaseMustBeInitialized(object p0) => string.Format(CultureInfo.CurrentCulture, GetString("PhaseMustBeInitialized"), p0); - /// - /// Tag helper directive assembly name cannot be null or empty. - /// - internal static string TagHelperAssemblyNameCannotBeEmptyOrNull - { - get => GetString("TagHelperAssemblyNameCannotBeEmptyOrNull"); - } - - /// - /// Tag helper directive assembly name cannot be null or empty. - /// - internal static string FormatTagHelperAssemblyNameCannotBeEmptyOrNull() - => GetString("TagHelperAssemblyNameCannotBeEmptyOrNull"); - /// /// Path must begin with a forward slash '/'. /// @@ -150,34 +1208,6 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatRazorProject_PathMustStartWithForwardSlash() => GetString("RazorProject_PathMustStartWithForwardSlash"); - /// - /// A non-optional directive token cannot follow an optional directive token. - /// - internal static string DirectiveDescriptor_InvalidNonOptionalToken - { - get => GetString("DirectiveDescriptor_InvalidNonOptionalToken"); - } - - /// - /// A non-optional directive token cannot follow an optional directive token. - /// - internal static string FormatDirectiveDescriptor_InvalidNonOptionalToken() - => GetString("DirectiveDescriptor_InvalidNonOptionalToken"); - - /// - /// The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. - /// - internal static string DocumentMissingTarget - { - get => GetString("DocumentMissingTarget"); - } - - /// - /// The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. - /// - internal static string FormatDocumentMissingTarget(object p0, object p1, object p2) - => string.Format(CultureInfo.CurrentCulture, GetString("DocumentMissingTarget"), p0, p1, p2); - /// /// The item '{0}' could not be found. /// @@ -192,6 +1222,146 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatRazorTemplateEngine_ItemCouldNotBeFound(object p0) => string.Format(CultureInfo.CurrentCulture, GetString("RazorTemplateEngine_ItemCouldNotBeFound"), p0); + /// + /// Remove Tag Helpers for use in the current document. + /// + internal static string RemoveTagHelperDirective_Description + { + get => GetString("RemoveTagHelperDirective_Description"); + } + + /// + /// Remove Tag Helpers for use in the current document. + /// + internal static string FormatRemoveTagHelperDirective_Description() + => GetString("RemoveTagHelperDirective_Description"); + + /// + /// Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. + /// + internal static string RemoveTagHelperDirective_StringToken_Description + { + get => GetString("RemoveTagHelperDirective_StringToken_Description"); + } + + /// + /// Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. + /// + internal static string FormatRemoveTagHelperDirective_StringToken_Description() + => GetString("RemoveTagHelperDirective_StringToken_Description"); + + /// + /// TypeName, AssemblyName + /// + internal static string RemoveTagHelperDirective_StringToken_Name + { + get => GetString("RemoveTagHelperDirective_StringToken_Name"); + } + + /// + /// TypeName, AssemblyName + /// + internal static string FormatRemoveTagHelperDirective_StringToken_Name() + => GetString("RemoveTagHelperDirective_StringToken_Name"); + + /// + /// The '{0}' requires a '{1}' delegate to be set. + /// + internal static string RenderingContextRequiresDelegate + { + get => GetString("RenderingContextRequiresDelegate"); + } + + /// + /// The '{0}' requires a '{1}' delegate to be set. + /// + internal static string FormatRenderingContextRequiresDelegate(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("RenderingContextRequiresDelegate"), p0, p1); + + /// + /// Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. + /// + internal static string RewriterError_EmptyTagHelperBoundAttribute + { + get => GetString("RewriterError_EmptyTagHelperBoundAttribute"); + } + + /// + /// Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. + /// + internal static string FormatRewriterError_EmptyTagHelperBoundAttribute(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("RewriterError_EmptyTagHelperBoundAttribute"), p0, p1, p2); + + /// + /// Define a section to be rendered in the configured layout page. + /// + internal static string SectionDirective_Description + { + get => GetString("SectionDirective_Description"); + } + + /// + /// Define a section to be rendered in the configured layout page. + /// + internal static string FormatSectionDirective_Description() + => GetString("SectionDirective_Description"); + + /// + /// The name of the section. + /// + internal static string SectionDirective_NameToken_Description + { + get => GetString("SectionDirective_NameToken_Description"); + } + + /// + /// The name of the section. + /// + internal static string FormatSectionDirective_NameToken_Description() + => GetString("SectionDirective_NameToken_Description"); + + /// + /// SectionName + /// + internal static string SectionDirective_NameToken_Name + { + get => GetString("SectionDirective_NameToken_Name"); + } + + /// + /// SectionName + /// + internal static string FormatSectionDirective_NameToken_Name() + => GetString("SectionDirective_NameToken_Name"); + + /// + /// @section Header { ... } + /// + internal static string SectionExample + { + get => GetString("SectionExample"); + } + + /// + /// @section Header { ... } + /// + internal static string FormatSectionExample() + => GetString("SectionExample"); + + /// + /// <<unknown>> + /// + internal static string Symbol_Unknown + { + get => GetString("Symbol_Unknown"); + } + + /// + /// <<unknown>> + /// + internal static string FormatSymbol_Unknown() + => GetString("Symbol_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. /// @@ -375,298 +1545,102 @@ namespace Microsoft.AspNetCore.Razor.Language => GetString("TagHelper_InvalidTargetedTagNameNullOrWhitespace"); /// - /// The node '{0}' is not the owner of change '{1}'. + /// Tag helper directive assembly name cannot be null or empty. /// - internal static string InvalidOperation_SpanIsNotChangeOwner + internal static string TagHelperAssemblyNameCannotBeEmptyOrNull { - get => GetString("InvalidOperation_SpanIsNotChangeOwner"); + get => GetString("TagHelperAssemblyNameCannotBeEmptyOrNull"); } /// - /// The node '{0}' is not the owner of change '{1}'. + /// Tag helper directive assembly name cannot be null or empty. /// - internal static string FormatInvalidOperation_SpanIsNotChangeOwner(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("InvalidOperation_SpanIsNotChangeOwner"), p0, p1); + internal static string FormatTagHelperAssemblyNameCannotBeEmptyOrNull() + => GetString("TagHelperAssemblyNameCannotBeEmptyOrNull"); /// - /// Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + /// The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. /// - internal static string DirectiveDescriptor_InvalidDirectiveKeyword + internal static string TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey { - get => GetString("DirectiveDescriptor_InvalidDirectiveKeyword"); + get => GetString("TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey"); } /// - /// Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + /// The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. /// - internal static string FormatDirectiveDescriptor_InvalidDirectiveKeyword(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveDescriptor_InvalidDirectiveKeyword"), p0); + internal static string FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey"), p0, p1); /// - /// The feature must be initialized by setting the '{0}' property. + /// TagHelper attributes must be well-formed. /// - internal static string FeatureMustBeInitialized + internal static string TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed { - get => GetString("FeatureMustBeInitialized"); + get => GetString("TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed"); } /// - /// The feature must be initialized by setting the '{0}' property. + /// TagHelper attributes must be well-formed. /// - internal static string FormatFeatureMustBeInitialized(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("FeatureMustBeInitialized"), p0); + internal static string FormatTagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed() + => GetString("TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed"); /// - /// The document type '{0}' does not support the extension '{1}'. + /// The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. /// - internal static string Diagnostic_CodeTarget_UnsupportedExtension + internal static string TagHelperParseTreeRewriter_CannotHaveNonTagContent { - get => GetString("Diagnostic_CodeTarget_UnsupportedExtension"); + get => GetString("TagHelperParseTreeRewriter_CannotHaveNonTagContent"); } /// - /// The document type '{0}' does not support the extension '{1}'. + /// The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. /// - internal static string FormatDiagnostic_CodeTarget_UnsupportedExtension(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("Diagnostic_CodeTarget_UnsupportedExtension"), p0, p1); + internal static string FormatTagHelperParseTreeRewriter_CannotHaveNonTagContent(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_CannotHaveNonTagContent"), p0, p1); /// - /// The '{0}` directive must appear at the start of the line. + /// Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). /// - internal static string DirectiveMustAppearAtStartOfLine + internal static string TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag { - get => GetString("DirectiveMustAppearAtStartOfLine"); + get => GetString("TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag"); } /// - /// The '{0}` directive must appear at the start of the line. + /// Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). /// - internal static string FormatDirectiveMustAppearAtStartOfLine(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveMustAppearAtStartOfLine"), p0); + internal static string FormatTagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag"), p0, p1, p2); /// - /// The '{0}' directives value(s) must be separated by whitespace. + /// Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. /// - internal static string DirectiveTokensMustBeSeparatedByWhitespace + internal static string TagHelperParseTreeRewriter_InconsistentTagStructure { - get => GetString("DirectiveTokensMustBeSeparatedByWhitespace"); + get => GetString("TagHelperParseTreeRewriter_InconsistentTagStructure"); } /// - /// The '{0}' directives value(s) must be separated by whitespace. + /// Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. /// - internal static string FormatDirectiveTokensMustBeSeparatedByWhitespace(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DirectiveTokensMustBeSeparatedByWhitespace"), p0); + internal static string FormatTagHelperParseTreeRewriter_InconsistentTagStructure(object p0, object p1, object p2, object p3) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_InconsistentTagStructure"), p0, p1, p2, p3); /// - /// The key must not be null. + /// The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. /// - internal static string KeyMustNotBeNull + internal static string TagHelperParseTreeRewriter_InvalidNestedTag { - get => GetString("KeyMustNotBeNull"); + get => GetString("TagHelperParseTreeRewriter_InvalidNestedTag"); } /// - /// The key must not be null. + /// The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. /// - internal static string FormatKeyMustNotBeNull() - => GetString("KeyMustNotBeNull"); - - /// - /// The reference is invalid. The node '{0}' could not be found as a child of '{1}'. - /// - internal static string IntermediateNodeReference_NodeNotFound - { - get => GetString("IntermediateNodeReference_NodeNotFound"); - } - - /// - /// The reference is invalid. The node '{0}' could not be found as a child of '{1}'. - /// - internal static string FormatIntermediateNodeReference_NodeNotFound(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeReference_NodeNotFound"), p0, p1); - - /// - /// The reference is invalid. References initialized with the default constructor cannot modify nodes. - /// - internal static string IntermediateNodeReference_NotInitialized - { - get => GetString("IntermediateNodeReference_NotInitialized"); - } - - /// - /// The reference is invalid. References initialized with the default constructor cannot modify nodes. - /// - internal static string FormatIntermediateNodeReference_NotInitialized() - => GetString("IntermediateNodeReference_NotInitialized"); - - /// - /// The node '{0}' has a read-only child collection and cannot be modified. - /// - internal static string IntermediateNodeReference_CollectionIsReadOnly - { - get => GetString("IntermediateNodeReference_CollectionIsReadOnly"); - } - - /// - /// The node '{0}' has a read-only child collection and cannot be modified. - /// - internal static string FormatIntermediateNodeReference_CollectionIsReadOnly(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodeReference_CollectionIsReadOnly"), p0); - - /// - /// The '{0}' directive may only occur once per document. - /// - internal static string DuplicateDirective - { - get => GetString("DuplicateDirective"); - } - - /// - /// The '{0}' directive may only occur once per document. - /// - internal static string FormatDuplicateDirective(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("DuplicateDirective"), p0); - - /// - /// Block directive '{0}' cannot be imported. - /// - internal static string BlockDirectiveCannotBeImported - { - get => GetString("BlockDirectiveCannotBeImported"); - } - - /// - /// Block directive '{0}' cannot be imported. - /// - internal static string FormatBlockDirectiveCannotBeImported(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("BlockDirectiveCannotBeImported"), p0); - - /// - /// Unreachable code. This can happen when a new {0} is introduced. - /// - internal static string UnexpectedDirectiveKind - { - get => GetString("UnexpectedDirectiveKind"); - } - - /// - /// Unreachable code. This can happen when a new {0} is introduced. - /// - internal static string FormatUnexpectedDirectiveKind(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedDirectiveKind"), p0); - - /// - /// The '{0}' requires a '{1}' delegate to be set. - /// - internal static string RenderingContextRequiresDelegate - { - get => GetString("RenderingContextRequiresDelegate"); - } - - /// - /// The '{0}' requires a '{1}' delegate to be set. - /// - internal static string FormatRenderingContextRequiresDelegate(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("RenderingContextRequiresDelegate"), p0, p1); - - /// - /// The '{0}' node type can only be used as a direct child of a '{1}' node. - /// - internal static string IntermediateNodes_InvalidParentNode - { - get => GetString("IntermediateNodes_InvalidParentNode"); - } - - /// - /// The '{0}' node type can only be used as a direct child of a '{1}' node. - /// - internal static string FormatIntermediateNodes_InvalidParentNode(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("IntermediateNodes_InvalidParentNode"), p0, p1); - - /// - /// Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. - /// - internal static string CodeWriter_InvalidNewLine - { - get => GetString("CodeWriter_InvalidNewLine"); - } - - /// - /// Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. - /// - internal static string FormatCodeWriter_InvalidNewLine(object p0) - => string.Format(CultureInfo.CurrentCulture, GetString("CodeWriter_InvalidNewLine"), p0); - - /// - /// Register Tag Helpers for use in the current document. - /// - internal static string AddTagHelperDirective_Description - { - get => GetString("AddTagHelperDirective_Description"); - } - - /// - /// Register Tag Helpers for use in the current document. - /// - internal static string FormatAddTagHelperDirective_Description() - => GetString("AddTagHelperDirective_Description"); - - /// - /// Specify a C# code block. - /// - internal static string FunctionsDirective_Description - { - get => GetString("FunctionsDirective_Description"); - } - - /// - /// Specify a C# code block. - /// - internal static string FormatFunctionsDirective_Description() - => GetString("FunctionsDirective_Description"); - - /// - /// Specify the base class for the current document. - /// - internal static string InheritsDirective_Description - { - get => GetString("InheritsDirective_Description"); - } - - /// - /// Specify the base class for the current document. - /// - internal static string FormatInheritsDirective_Description() - => GetString("InheritsDirective_Description"); - - /// - /// Remove Tag Helpers for use in the current document. - /// - internal static string RemoveTagHelperDirective_Description - { - get => GetString("RemoveTagHelperDirective_Description"); - } - - /// - /// Remove Tag Helpers for use in the current document. - /// - internal static string FormatRemoveTagHelperDirective_Description() - => GetString("RemoveTagHelperDirective_Description"); - - /// - /// Define a section to be rendered in the configured layout page. - /// - internal static string SectionDirective_Description - { - get => GetString("SectionDirective_Description"); - } - - /// - /// Define a section to be rendered in the configured layout page. - /// - internal static string FormatSectionDirective_Description() - => GetString("SectionDirective_Description"); + internal static string FormatTagHelperParseTreeRewriter_InvalidNestedTag(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelperParseTreeRewriter_InvalidNestedTag"), p0, p1, p2); /// /// Specify a prefix that is required in an element name for it to be included in Tag Helper processing. @@ -682,90 +1656,6 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatTagHelperPrefixDirective_Description() => GetString("TagHelperPrefixDirective_Description"); - /// - /// Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. - /// - internal static string AddTagHelperDirective_StringToken_Description - { - get => GetString("AddTagHelperDirective_StringToken_Description"); - } - - /// - /// Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. - /// - internal static string FormatAddTagHelperDirective_StringToken_Description() - => GetString("AddTagHelperDirective_StringToken_Description"); - - /// - /// TypeName, AssemblyName - /// - internal static string AddTagHelperDirective_StringToken_Name - { - get => GetString("AddTagHelperDirective_StringToken_Name"); - } - - /// - /// TypeName, AssemblyName - /// - internal static string FormatAddTagHelperDirective_StringToken_Name() - => GetString("AddTagHelperDirective_StringToken_Name"); - - /// - /// The base type that the current page inherits. - /// - internal static string InheritsDirective_TypeToken_Description - { - get => GetString("InheritsDirective_TypeToken_Description"); - } - - /// - /// The base type that the current page inherits. - /// - internal static string FormatInheritsDirective_TypeToken_Description() - => GetString("InheritsDirective_TypeToken_Description"); - - /// - /// TypeName - /// - internal static string InheritsDirective_TypeToken_Name - { - get => GetString("InheritsDirective_TypeToken_Name"); - } - - /// - /// TypeName - /// - internal static string FormatInheritsDirective_TypeToken_Name() - => GetString("InheritsDirective_TypeToken_Name"); - - /// - /// Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. - /// - internal static string RemoveTagHelperDirective_StringToken_Description - { - get => GetString("RemoveTagHelperDirective_StringToken_Description"); - } - - /// - /// Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. - /// - internal static string FormatRemoveTagHelperDirective_StringToken_Description() - => GetString("RemoveTagHelperDirective_StringToken_Description"); - - /// - /// TypeName, AssemblyName - /// - internal static string RemoveTagHelperDirective_StringToken_Name - { - get => GetString("RemoveTagHelperDirective_StringToken_Name"); - } - - /// - /// TypeName, AssemblyName - /// - internal static string FormatRemoveTagHelperDirective_StringToken_Name() - => GetString("RemoveTagHelperDirective_StringToken_Name"); - /// /// The tag prefix to apply to tag helpers. /// @@ -795,32 +1685,176 @@ namespace Microsoft.AspNetCore.Razor.Language => GetString("TagHelperPrefixDirective_PrefixToken_Name"); /// - /// The name of the section. + /// Tag Helper '{0}'s attributes must have names. /// - internal static string SectionDirective_NameToken_Description + internal static string TagHelpers_AttributesMustHaveAName { - get => GetString("SectionDirective_NameToken_Description"); + get => GetString("TagHelpers_AttributesMustHaveAName"); } /// - /// The name of the section. + /// Tag Helper '{0}'s attributes must have names. /// - internal static string FormatSectionDirective_NameToken_Description() - => GetString("SectionDirective_NameToken_Description"); + internal static string FormatTagHelpers_AttributesMustHaveAName(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_AttributesMustHaveAName"), p0); /// - /// SectionName + /// The tag helper '{0}' must not have C# in the element's attribute declaration area. /// - internal static string SectionDirective_NameToken_Name + internal static string TagHelpers_CannotHaveCSharpInTagDeclaration { - get => GetString("SectionDirective_NameToken_Name"); + get => GetString("TagHelpers_CannotHaveCSharpInTagDeclaration"); } /// - /// SectionName + /// The tag helper '{0}' must not have C# in the element's attribute declaration area. /// - internal static string FormatSectionDirective_NameToken_Name() - => GetString("SectionDirective_NameToken_Name"); + internal static string FormatTagHelpers_CannotHaveCSharpInTagDeclaration(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_CannotHaveCSharpInTagDeclaration"), p0); + + /// + /// Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. + /// Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. + /// + internal static string TagHelpers_CodeBlocks_NotSupported_InAttributes + { + get => GetString("TagHelpers_CodeBlocks_NotSupported_InAttributes"); + } + + /// + /// Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. + /// Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. + /// + internal static string FormatTagHelpers_CodeBlocks_NotSupported_InAttributes() + => GetString("TagHelpers_CodeBlocks_NotSupported_InAttributes"); + + /// + /// Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. + /// Expected a '{0}' attribute value, not a string. + /// + internal static string TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes + { + get => GetString("TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes"); + } + + /// + /// Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. + /// Expected a '{0}' attribute value, not a string. + /// + internal static string FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes"), p0); + + /// + /// Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. + /// + internal static string TagHelpersParseTreeRewriter_FoundMalformedTagHelper + { + get => GetString("TagHelpersParseTreeRewriter_FoundMalformedTagHelper"); + } + + /// + /// Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. + /// + internal static string FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpersParseTreeRewriter_FoundMalformedTagHelper"), p0); + + /// + /// Missing close angle for tag helper '{0}'. + /// + internal static string TagHelpersParseTreeRewriter_MissingCloseAngle + { + get => GetString("TagHelpersParseTreeRewriter_MissingCloseAngle"); + } + + /// + /// Missing close angle for tag helper '{0}'. + /// + internal static string FormatTagHelpersParseTreeRewriter_MissingCloseAngle(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("TagHelpersParseTreeRewriter_MissingCloseAngle"), p0); + + /// + /// Unreachable code. This can happen when a new {0} is introduced. + /// + internal static string UnexpectedDirectiveKind + { + get => GetString("UnexpectedDirectiveKind"); + } + + /// + /// Unreachable code. This can happen when a new {0} is introduced. + /// + internal static string FormatUnexpectedDirectiveKind(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedDirectiveKind"), p0); + + /// + /// Unexpected literal following the '{0}' directive. Expected '{1}'. + /// + internal static string UnexpectedDirectiveLiteral + { + get => GetString("UnexpectedDirectiveLiteral"); + } + + /// + /// Unexpected literal following the '{0}' directive. Expected '{1}'. + /// + internal static string FormatUnexpectedDirectiveLiteral(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedDirectiveLiteral"), p0, p1); + + /// + /// Unexpected end of file following the '{0}' directive. Expected '{1}'. + /// + internal static string UnexpectedEOFAfterDirective + { + get => GetString("UnexpectedEOFAfterDirective"); + } + + /// + /// Unexpected end of file following the '{0}' directive. Expected '{1}'. + /// + internal static string FormatUnexpectedEOFAfterDirective(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedEOFAfterDirective"), p0, p1); + + /// + /// The hash algorithm '{0}' is not supported for checksum generation. Supported algorithms are: '{1}'. Set '{2}' to '{3}' to suppress automatic checksum generation. + /// + internal static string UnsupportedChecksumAlgorithm + { + get => GetString("UnsupportedChecksumAlgorithm"); + } + + /// + /// The hash algorithm '{0}' is not supported for checksum generation. Supported algorithms are: '{1}'. Set '{2}' to '{3}' to suppress automatic checksum generation. + /// + internal static string FormatUnsupportedChecksumAlgorithm(object p0, object p1, object p2, object p3) + => string.Format(CultureInfo.CurrentCulture, GetString("UnsupportedChecksumAlgorithm"), p0, p1, p2, p3); + + /// + /// The '{0}.{1}' property must not be null. + /// + internal static string PropertyMustNotBeNull + { + get => GetString("PropertyMustNotBeNull"); + } + + /// + /// The '{0}.{1}' property must not be null. + /// + internal static string FormatPropertyMustNotBeNull(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("PropertyMustNotBeNull"), p0, p1); + + /// + /// The '{0}' is missing feature '{1}'. + /// + internal static string RazorProjectEngineMissingFeatureDependency + { + get => GetString("RazorProjectEngineMissingFeatureDependency"); + } + + /// + /// The '{0}' is missing feature '{1}'. + /// + internal static string FormatRazorProjectEngineMissingFeatureDependency(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("RazorProjectEngineMissingFeatureDependency"), p0, p1); /// /// The Razor language version '{0}' is unrecognized or not supported by this version of Razor. @@ -836,6 +1870,34 @@ namespace Microsoft.AspNetCore.Razor.Language internal static string FormatRazorLanguageVersion_InvalidVersion(object p0) => string.Format(CultureInfo.CurrentCulture, GetString("RazorLanguageVersion_InvalidVersion"), p0); + /// + /// File path '{0}' does not belong to the directory '{1}'. + /// + internal static string VirtualFileSystem_FileDoesNotBelongToDirectory + { + get => GetString("VirtualFileSystem_FileDoesNotBelongToDirectory"); + } + + /// + /// File path '{0}' does not belong to the directory '{1}'. + /// + internal static string FormatVirtualFileSystem_FileDoesNotBelongToDirectory(object p0, object p1) + => string.Format(CultureInfo.CurrentCulture, GetString("VirtualFileSystem_FileDoesNotBelongToDirectory"), p0, p1); + + /// + /// The file path '{0}' is invalid. File path is the root relative path of the file starting with '/' and should not contain any '\' characters. + /// + internal static string VirtualFileSystem_InvalidRelativePath + { + get => GetString("VirtualFileSystem_InvalidRelativePath"); + } + + /// + /// The file path '{0}' is invalid. File path is the root relative path of the file starting with '/' and should not contain any '\' characters. + /// + internal static string FormatVirtualFileSystem_InvalidRelativePath(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("VirtualFileSystem_InvalidRelativePath"), p0); + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs b/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.cs new file mode 100644 index 0000000000..374419a676 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/ProvideRazorExtensionInitializerAttribute.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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public class ProvideRazorExtensionInitializerAttribute : Attribute + { + public ProvideRazorExtensionInitializerAttribute(string extensionName, Type initializerType) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (initializerType == null) + { + throw new ArgumentNullException(nameof(initializerType)); + } + + ExtensionName = extensionName; + InitializerType = initializerType; + } + + public string ExtensionName { get; } + + public Type InitializerType { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs index 6ee41d0be5..0d57df2815 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocument.cs @@ -30,6 +30,23 @@ namespace Microsoft.AspNetCore.Razor.Language return new DefaultRazorCodeDocument(source, imports); } + public static RazorCodeDocument Create( + RazorSourceDocument source, + IEnumerable imports, + RazorParserOptions parserOptions, + RazorCodeGenerationOptions codeGenerationOptions) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + + var codeDocument = new DefaultRazorCodeDocument(source, imports); + codeDocument.SetParserOptions(parserOptions); + codeDocument.SetCodeGenerationOptions(codeGenerationOptions); + return codeDocument; + } + public abstract IReadOnlyList Imports { get; } public abstract ItemCollection Items { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs index 6cee701d3e..85df33837a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeDocumentExtensions.cs @@ -9,8 +9,6 @@ namespace Microsoft.AspNetCore.Razor.Language { public static class RazorCodeDocumentExtensions { - private static object TagHelperPrefixKey = new object(); - public static TagHelperDocumentContext GetTagHelperContext(this RazorCodeDocument document) { if (document == null) @@ -111,6 +109,46 @@ namespace Microsoft.AspNetCore.Razor.Language document.Items[typeof(RazorCSharpDocument)] = csharp; } + public static RazorParserOptions GetParserOptions(this RazorCodeDocument document) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + return (RazorParserOptions)document.Items[typeof(RazorParserOptions)]; + } + + public static void SetParserOptions(this RazorCodeDocument document, RazorParserOptions parserOptions) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + document.Items[typeof(RazorParserOptions)] = parserOptions; + } + + public static RazorCodeGenerationOptions GetCodeGenerationOptions(this RazorCodeDocument document) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + return (RazorCodeGenerationOptions)document.Items[typeof(RazorCodeGenerationOptions)]; + } + + public static void SetCodeGenerationOptions(this RazorCodeDocument document, RazorCodeGenerationOptions codeGenerationOptions) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + document.Items[typeof(RazorCodeGenerationOptions)] = codeGenerationOptions; + } + private class ImportSyntaxTreesHolder { public ImportSyntaxTreesHolder(IReadOnlyList syntaxTrees) diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptions.cs index 6e73d6a004..60da959c2d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptions.cs @@ -9,12 +9,22 @@ namespace Microsoft.AspNetCore.Razor.Language { public static RazorCodeGenerationOptions CreateDefault() { - return new DefaultRazorCodeGenerationOptions(indentWithTabs: false, indentSize: 4, designTime: false, suppressChecksum: false); + return new DefaultRazorCodeGenerationOptions( + indentWithTabs: false, + indentSize: 4, + designTime: false, + suppressChecksum: false, + supressMetadataAttributes: false); } public static RazorCodeGenerationOptions CreateDesignTimeDefault() { - return new DefaultRazorCodeGenerationOptions(indentWithTabs: false, indentSize: 4, designTime: true, suppressChecksum: false); + return new DefaultRazorCodeGenerationOptions( + indentWithTabs: false, + indentSize: 4, + designTime: true, + suppressChecksum: false, + supressMetadataAttributes: true); } public static RazorCodeGenerationOptions Create(Action configure) @@ -38,7 +48,11 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(configure)); } - var builder = new DefaultRazorCodeGenerationOptionsBuilder(designTime: true); + var builder = new DefaultRazorCodeGenerationOptionsBuilder(designTime: true) + { + SuppressMetadataAttributes = true, + }; + configure(builder); var options = builder.Build(); @@ -51,6 +65,33 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract int IndentSize { get; } + /// + /// Gets a value that indicates whether to suppress the default #pragma checksum directive in the + /// generated C# code. If false the checkum directive will be included, otherwise it will not be + /// generated. Defaults to false, meaning that the checksum will be included. + /// + /// + /// The #pragma checksum is required to enable debugging and should only be supressed for testing + /// purposes. + /// public abstract bool SuppressChecksum { get; } + + /// + /// Gets a value that indicates whether to suppress the default metadata attributes in the generated + /// C# code. If false the default attributes will be included, otherwise they will not be generated. + /// Defaults to false at run time, meaning that the attributes will be included. Defaults to + /// true at design time, meaning that the attributes will not be included. + /// + /// + /// + /// The Microsoft.AspNetCore.Razor.Runtime package includes a default set of attributes intended + /// for runtimes to discover metadata about the compiled code. + /// + /// + /// The default metadata attributes should be suppressed if code generation targets a runtime without + /// a reference to Microsoft.AspNetCore.Razor.Runtime, or for testing purposes. + /// + /// + public virtual bool SuppressMetadataAttributes { get; protected set; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs index 3b24c23bfe..be4c9dff3d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorCodeGenerationOptionsBuilder.cs @@ -5,14 +5,47 @@ namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorCodeGenerationOptionsBuilder { + public virtual RazorConfiguration Configuration => null; + public abstract bool DesignTime { get; } public abstract int IndentSize { get; set; } public abstract bool IndentWithTabs { get; set; } + /// + /// Gets or sets a value that indicates whether to suppress the default #pragma checksum directive in the + /// generated C# code. If false the checkum directive will be included, otherwise it will not be + /// generated. Defaults to false, meaning that the checksum will be included. + /// + /// + /// The #pragma checksum is required to enable debugging and should only be supressed for testing + /// purposes. + /// public abstract bool SuppressChecksum { get; set; } + /// + /// Gets or setsa value that indicates whether to suppress the default metadata attributes in the generated + /// C# code. If false the default attributes will be included, otherwise they will not be generated. + /// Defaults to false at run time, meaning that the attributes will be included. Defaults to + /// true at design time, meaning that the attributes will not be included. + /// + /// + /// + /// The Microsoft.AspNetCore.Razor.Runtime package includes a default set of attributes intended + /// for runtimes to discover metadata about the compiled code. + /// + /// + /// The default metadata attributes should be suppressed if code generation targets a runtime without + /// a reference to Microsoft.AspNetCore.Razor.Runtime, or for testing purposes. + /// + /// + public virtual bool SuppressMetadataAttributes { get; set; } + public abstract RazorCodeGenerationOptions Build(); + + public virtual void SetDesignTime(bool designTime) + { + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs index 0f00751497..f68db61f22 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorConfiguration.cs @@ -12,22 +12,12 @@ namespace Microsoft.AspNetCore.Razor.Language public static readonly RazorConfiguration Default = new RazorConfiguration( RazorLanguageVersion.Latest, "unnamed", - Array.Empty(), - designTime: false); - - // This is used only in some back-compat scenarios. We don't expose it because there's no - // use case for anyone else to use it. - internal static readonly RazorConfiguration DefaultDesignTime = new RazorConfiguration( - RazorLanguageVersion.Latest, - "unnamed", - Array.Empty(), - designTime: true); + Array.Empty()); public RazorConfiguration( RazorLanguageVersion languageVersion, string configurationName, - IEnumerable extensions, - bool designTime) + IEnumerable extensions) { if (languageVersion == null) { @@ -47,7 +37,6 @@ namespace Microsoft.AspNetCore.Razor.Language LanguageVersion = languageVersion; ConfigurationName = configurationName; Extensions = extensions.ToArray(); - DesignTime = designTime; } public string ConfigurationName { get; } @@ -55,7 +44,5 @@ namespace Microsoft.AspNetCore.Razor.Language public IReadOnlyList Extensions { get; } public RazorLanguageVersion LanguageVersion { get; } - - public bool DesignTime { get; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnostic.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnostic.cs index 0edb2fdf93..a4bd3c2b5e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnostic.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnostic.cs @@ -2,12 +2,12 @@ // 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.Legacy; namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorDiagnostic : IEquatable, IFormattable { + internal static readonly RazorDiagnostic[] EmptyArray = new RazorDiagnostic[0]; internal static readonly object[] EmptyArgs = new object[0]; public abstract string Id { get; } @@ -44,16 +44,6 @@ namespace Microsoft.AspNetCore.Razor.Language return new DefaultRazorDiagnostic(descriptor, span, args); } - internal static RazorDiagnostic Create(RazorError error) - { - if (error == null) - { - throw new ArgumentNullException(nameof(error)); - } - - return new LegacyRazorDiagnostic(error); - } - public override string ToString() { return ((IFormattable)this).ToString(null, null); diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs index bf19f615b3..cf1ad34dd6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.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.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language { @@ -13,11 +14,11 @@ namespace Microsoft.AspNetCore.Razor.Language // General Errors ID Offset = 0 - public static readonly RazorDiagnosticDescriptor Directive_BlockDirectiveCannotBeImported = - new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}0000", - () => Resources.BlockDirectiveCannotBeImported, - RazorDiagnosticSeverity.Error); + internal static readonly RazorDiagnosticDescriptor Directive_BlockDirectiveCannotBeImported = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}0000", + () => Resources.BlockDirectiveCannotBeImported, + RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateDirective_BlockDirectiveCannotBeImported(string directive) { return RazorDiagnostic.Create(Directive_BlockDirectiveCannotBeImported, SourceSpan.Undefined, directive); @@ -29,13 +30,400 @@ namespace Microsoft.AspNetCore.Razor.Language // Language Errors ID Offset = 1000 + internal static readonly RazorDiagnosticDescriptor Parsing_UnterminatedStringLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1000", + () => Resources.ParseError_Unterminated_String_Literal, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnterminatedStringLiteral(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnterminatedStringLiteral, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_BlockCommentNotTerminated = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1001", + () => Resources.ParseError_BlockComment_Not_Terminated, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_BlockCommentNotTerminated(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_BlockCommentNotTerminated, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_HelperDirectiveNotAvailable = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1002", + () => Resources.ParseError_HelperDirectiveNotAvailable, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_HelperDirectiveNotAvailable(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_HelperDirectiveNotAvailable, location, SyntaxConstants.CSharp.HelperKeyword); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedWhiteSpaceAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1003", + () => Resources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedWhiteSpaceAtStartOfCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEndOfFileAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1004", + () => Resources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedEndOfFileAtStartOfCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedCharacterAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1005", + () => Resources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedCharacterAtStartOfCodeBlock(SourceSpan location, string content) + { + return RazorDiagnostic.Create(Parsing_UnexpectedCharacterAtStartOfCodeBlock, location, content); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_ExpectedEndOfBlockBeforeEOF = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1006", + () => Resources.ParseError_Expected_EndOfBlock_Before_EOF, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_ExpectedEndOfBlockBeforeEOF(SourceSpan location, string blockName, string closeBlock, string openBlock) + { + return RazorDiagnostic.Create(Parsing_ExpectedEndOfBlockBeforeEOF, location, blockName, closeBlock, openBlock); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_ReservedWord = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1007", + () => Resources.ParseError_ReservedWord, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_ReservedWord(SourceSpan location, string content) + { + return RazorDiagnostic.Create(Parsing_ReservedWord, location, content); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_SingleLineControlFlowStatementsNotAllowed = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1008", + () => Resources.ParseError_SingleLine_ControlFlowStatements_Not_Allowed, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_SingleLineControlFlowStatementsNotAllowed(SourceSpan location, string expected, string actual) + { + return RazorDiagnostic.Create(Parsing_SingleLineControlFlowStatementsNotAllowed, location, expected, actual); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1009", + () => Resources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedNestedCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1010", + () => Resources.ParseError_Unexpected_Nested_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedNestedCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedNestedCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveTokensMustBeSeparatedByWhitespace = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1011", + () => Resources.DirectiveTokensMustBeSeparatedByWhitespace, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveTokensMustBeSeparatedByWhitespace, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEOFAfterDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1012", + () => Resources.UnexpectedEOFAfterDirective, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedEOFAfterDirective(SourceSpan location, string directiveName, string expectedToken) + { + return RazorDiagnostic.Create(Parsing_UnexpectedEOFAfterDirective, location, directiveName, expectedToken); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsTypeName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1013", + () => Resources.DirectiveExpectsTypeName, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsTypeName(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsTypeName, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsNamespace = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1014", + () => Resources.DirectiveExpectsNamespace, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsNamespace(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsNamespace, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsIdentifier = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1015", + () => Resources.DirectiveExpectsIdentifier, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsIdentifier(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsIdentifier, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsQuotedStringLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1016", + () => Resources.DirectiveExpectsQuotedStringLiteral, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsQuotedStringLiteral(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsQuotedStringLiteral, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedDirectiveLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1017", + () => Resources.UnexpectedDirectiveLiteral, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedDirectiveLiteral(SourceSpan location, string directiveName, string expected) + { + return RazorDiagnostic.Create(Parsing_UnexpectedDirectiveLiteral, location, directiveName, expected); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveMustHaveValue = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1018", + () => Resources.ParseError_DirectiveMustHaveValue, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveMustHaveValue(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveMustHaveValue, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_IncompleteQuotesAroundDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1019", + () => Resources.ParseError_IncompleteQuotesAroundDirective, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_IncompleteQuotesAroundDirective(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_IncompleteQuotesAroundDirective, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_InvalidTagHelperPrefixValue = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1020", + () => Resources.InvalidTagHelperPrefixValue, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InvalidTagHelperPrefixValue(SourceSpan location, string directiveName, char character, string prefix) + { + 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", + () => Resources.ParseError_MarkupBlock_Must_Start_With_Tag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_MarkupBlockMustStartWithTag(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_MarkupBlockMustStartWithTag, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_OuterTagMissingName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1022", + () => Resources.ParseError_OuterTagMissingName, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_OuterTagMissingName(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_OuterTagMissingName, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TextTagCannotContainAttributes = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1023", + () => Resources.ParseError_TextTagCannotContainAttributes, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TextTagCannotContainAttributes(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_TextTagCannotContainAttributes, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnfinishedTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1024", + () => Resources.ParseError_UnfinishedTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnfinishedTag(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_UnfinishedTag, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_MissingEndTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1025", + () => Resources.ParseError_MissingEndTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_MissingEndTag(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_MissingEndTag, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEndTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1026", + () => Resources.ParseError_UnexpectedEndTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedEndTag(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_UnexpectedEndTag, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_ExpectedCloseBracketBeforeEOF = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1027", + () => Resources.ParseError_Expected_CloseBracket_Before_EOF, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_ExpectedCloseBracketBeforeEOF(SourceSpan location, string openBrace, string closeBrace) + { + return RazorDiagnostic.Create(Parsing_ExpectedCloseBracketBeforeEOF, location, openBrace, closeBrace); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_RazorCommentNotTerminated = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1028", + () => Resources.ParseError_RazorComment_Not_Terminated, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_RazorCommentNotTerminated(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_RazorCommentNotTerminated, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperIndexerAttributeNameMustIncludeKey = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1029", + () => Resources.TagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey(SourceSpan location, string attributeName, string tagName) + { + return RazorDiagnostic.Create(Parsing_TagHelperIndexerAttributeNameMustIncludeKey, location, attributeName, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperAttributeListMustBeWellFormed = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1030", + () => Resources.TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperAttributeListMustBeWellFormed(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_TagHelperAttributeListMustBeWellFormed, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelpersCannotHaveCSharpInTagDeclaration = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1031", + () => Resources.TagHelpers_CannotHaveCSharpInTagDeclaration, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_TagHelpersCannotHaveCSharpInTagDeclaration, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperAttributesMustHaveAName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1032", + () => Resources.TagHelpers_AttributesMustHaveAName, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperAttributesMustHaveAName(SourceSpan location, string tagName) + { + return RazorDiagnostic.Create(Parsing_TagHelperAttributesMustHaveAName, location, tagName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperMustNotHaveAnEndTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1033", + () => Resources.TagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperMustNotHaveAnEndTag(SourceSpan location, string tagName, string displayName, TagStructure tagStructure) + { + var diagnostic = RazorDiagnostic.Create( + Parsing_TagHelperMustNotHaveAnEndTag, + location, + tagName, + displayName, + tagStructure); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperFoundMalformedTagHelper = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1034", + () => Resources.TagHelpersParseTreeRewriter_FoundMalformedTagHelper, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperFoundMalformedTagHelper(SourceSpan location, string tagName) + { + var diagnostic = RazorDiagnostic.Create( + Parsing_TagHelperFoundMalformedTagHelper, + location, + tagName); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor Parsing_TagHelperMissingCloseAngle = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1035", + () => Resources.TagHelpersParseTreeRewriter_MissingCloseAngle, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_TagHelperMissingCloseAngle(SourceSpan location, string tagName) + { + var diagnostic = RazorDiagnostic.Create( + Parsing_TagHelperMissingCloseAngle, + location, + tagName); + + return diagnostic; + } + #endregion #region Semantic Errors // Semantic Errors ID Offset = 2000 - public static readonly RazorDiagnosticDescriptor CodeTarget_UnsupportedExtension = + internal static readonly RazorDiagnosticDescriptor CodeTarget_UnsupportedExtension = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}2000", () => Resources.Diagnostic_CodeTarget_UnsupportedExtension, @@ -50,11 +438,117 @@ namespace Microsoft.AspNetCore.Razor.Language $"{DiagnosticPrefix}2001", () => Resources.DuplicateDirective, RazorDiagnosticSeverity.Error); - public static RazorDiagnostic CreateParsing_DuplicateDirective(string directive, SourceSpan location) + public static RazorDiagnostic CreateParsing_DuplicateDirective(SourceSpan location, string directive) { return RazorDiagnostic.Create(Parsing_DuplicateDirective, location, directive); } + internal static readonly RazorDiagnosticDescriptor Parsing_SectionsCannotBeNested = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2002", + () => Resources.ParseError_Sections_Cannot_Be_Nested, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_SectionsCannotBeNested(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_SectionsCannotBeNested, location, Resources.SectionExample); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_InlineMarkupBlocksCannotBeNested = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2003", + () => Resources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InlineMarkupBlocksCannotBeNested(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_InlineMarkupBlocksCannotBeNested, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2004", + () => Resources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveMustAppearAtStartOfLine = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2005", + () => Resources.DirectiveMustAppearAtStartOfLine, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveMustAppearAtStartOfLine(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveMustAppearAtStartOfLine, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_CodeBlocksNotSupportedInAttributes = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2006", + () => Resources.TagHelpers_CodeBlocks_NotSupported_InAttributes, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_CodeBlocksNotSupportedInAttributes(SourceSpan location) + { + var diagnostic = RazorDiagnostic.Create(TagHelper_CodeBlocksNotSupportedInAttributes, location); + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InlineMarkupBlocksNotSupportedInAttributes = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2007", + () => Resources.TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(SourceSpan location, string expectedTypeName) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_InlineMarkupBlocksNotSupportedInAttributes, + location, + expectedTypeName); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_EmptyBoundAttribute = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2008", + () => Resources.RewriterError_EmptyTagHelperBoundAttribute, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_EmptyBoundAttribute(SourceSpan location, string attributeName, string tagName, string propertyTypeName) + { + return RazorDiagnostic.Create(TagHelper_EmptyBoundAttribute, location, attributeName, tagName, propertyTypeName); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_CannotHaveNonTagContent = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2009", + () => Resources.TagHelperParseTreeRewriter_CannotHaveNonTagContent, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_CannotHaveNonTagContent(SourceSpan location, string tagName, string allowedChildren) + { + return RazorDiagnostic.Create(TagHelper_CannotHaveNonTagContent, location, tagName, allowedChildren); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidNestedTag = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2010", + () => Resources.TagHelperParseTreeRewriter_InvalidNestedTag, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InvalidNestedTag(SourceSpan location, string tagName, string parent, string allowedChildren) + { + return RazorDiagnostic.Create(TagHelper_InvalidNestedTag, location, tagName, parent, allowedChildren); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InconsistentTagStructure = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2011", + () => Resources.TagHelperParseTreeRewriter_InconsistentTagStructure, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InconsistentTagStructure(SourceSpan location, string firstDescriptor, string secondDescriptor, string tagName) + { + return RazorDiagnostic.Create(TagHelper_InconsistentTagStructure, location, firstDescriptor, secondDescriptor, tagName, nameof(TagMatchingRuleDescriptor.TagStructure)); + } + #endregion #region TagHelper Errors @@ -116,7 +610,7 @@ namespace Microsoft.AspNetCore.Razor.Language () => Resources.TagHelper_InvalidBoundAttributeName, RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateTagHelper_InvalidBoundAttributeName( - string tagHelperDisplayName, + string tagHelperDisplayName, string propertyDisplayName, string invalidName, char invalidCharacter) @@ -258,7 +752,7 @@ namespace Microsoft.AspNetCore.Razor.Language internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidTargetedAttributeNameNullOrWhitespace = new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}3009", + $"{DiagnosticPrefix}3011", () => Resources.TagHelper_InvalidTargetedAttributeNameNullOrWhitespace, RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateTagHelper_InvalidTargetedAttributeNameNullOrWhitespace() @@ -272,7 +766,7 @@ namespace Microsoft.AspNetCore.Razor.Language internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidTargetedAttributeName = new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}3010", + $"{DiagnosticPrefix}3012", () => Resources.TagHelper_InvalidTargetedAttributeName, RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateTagHelper_InvalidTargetedAttributeName(string invalidAttributeName, char invalidCharacter) diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs index aa06b9f9ab..13f2f6be73 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs @@ -3,6 +3,8 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language.Extensions; @@ -15,33 +17,33 @@ namespace Microsoft.AspNetCore.Razor.Language return Create(configure: null); } - public static RazorEngine Create(Action configure) => CreateCore(RazorConfiguration.Default, configure); + public static RazorEngine Create(Action configure) => CreateCore(RazorConfiguration.Default, false, configure); public static RazorEngine CreateDesignTime() { return CreateDesignTime(configure: null); } - public static RazorEngine CreateDesignTime(Action configure) => CreateCore(RazorConfiguration.DefaultDesignTime, configure); + public static RazorEngine CreateDesignTime(Action configure) => CreateCore(RazorConfiguration.Default, true, configure); // Internal since RazorEngine APIs are going to be obsolete. - internal static RazorEngine CreateCore(RazorConfiguration configuration, Action configure) + internal static RazorEngine CreateCore(RazorConfiguration configuration, bool designTime, Action configure) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } - var builder = new DefaultRazorEngineBuilder(configuration.DesignTime); + var builder = new DefaultRazorEngineBuilder(designTime); AddDefaults(builder); - if (configuration.DesignTime) + if (designTime) { - AddDesignTimeDefaults(configuration, builder); + AddDefaultDesignTimeFeatures(configuration, builder.Features); } else { - AddRuntimeDefaults(configuration, builder); + AddDefaultRuntimeFeatures(configuration, builder.Features); } configure?.Invoke(builder); @@ -50,37 +52,66 @@ namespace Microsoft.AspNetCore.Razor.Language public static RazorEngine CreateEmpty(Action configure) { + if (configure == null) + { + throw new ArgumentNullException(nameof(configure)); + } + var builder = new DefaultRazorEngineBuilder(designTime: false); - configure?.Invoke(builder); + configure(builder); + return builder.Build(); + } + + public static RazorEngine CreateDesignTimeEmpty(Action configure) + { + if (configure == null) + { + throw new ArgumentNullException(nameof(configure)); + } + + var builder = new DefaultRazorEngineBuilder(designTime: true); + configure(builder); return builder.Build(); } internal static void AddDefaults(IRazorEngineBuilder builder) { - builder.Phases.Add(new DefaultRazorParsingPhase()); - builder.Phases.Add(new DefaultRazorSyntaxTreePhase()); - builder.Phases.Add(new DefaultRazorTagHelperBinderPhase()); - builder.Phases.Add(new DefaultRazorIntermediateNodeLoweringPhase()); - builder.Phases.Add(new DefaultRazorDocumentClassifierPhase()); - builder.Phases.Add(new DefaultRazorDirectiveClassifierPhase()); - builder.Phases.Add(new DefaultRazorOptimizationPhase()); - builder.Phases.Add(new DefaultRazorCSharpLoweringPhase()); + AddDefaultPhases(builder.Phases); + AddDefaultFeatures(builder.Features); + } + internal static void AddDefaultPhases(IList phases) + { + phases.Add(new DefaultRazorParsingPhase()); + phases.Add(new DefaultRazorSyntaxTreePhase()); + phases.Add(new DefaultRazorTagHelperBinderPhase()); + phases.Add(new DefaultRazorIntermediateNodeLoweringPhase()); + phases.Add(new DefaultRazorDocumentClassifierPhase()); + phases.Add(new DefaultRazorDirectiveClassifierPhase()); + phases.Add(new DefaultRazorOptimizationPhase()); + phases.Add(new DefaultRazorCSharpLoweringPhase()); + } + + internal static void AddDefaultFeatures(ICollection features) + { // General extensibility - builder.Features.Add(new DefaultRazorDirectiveFeature()); - builder.Features.Add(new DefaultRazorTargetExtensionFeature()); + features.Add(new DefaultRazorDirectiveFeature()); + var targetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + features.Add(targetExtensionFeature); + features.Add(new DefaultMetadataIdentifierFeature()); // Syntax Tree passes - builder.Features.Add(new DefaultDirectiveSyntaxTreePass()); - builder.Features.Add(new HtmlNodeOptimizationPass()); + features.Add(new DefaultDirectiveSyntaxTreePass()); + features.Add(new HtmlNodeOptimizationPass()); // Intermediate Node Passes - builder.Features.Add(new DefaultDocumentClassifierPass()); - builder.Features.Add(new DirectiveRemovalOptimizationPass()); - builder.Features.Add(new DefaultTagHelperOptimizationPass()); + features.Add(new DefaultDocumentClassifierPass()); + features.Add(new MetadataAttributePass()); + features.Add(new DirectiveRemovalOptimizationPass()); + features.Add(new DefaultTagHelperOptimizationPass()); // Default Code Target Extensions - // (currently none) + targetExtensionFeature.TargetExtensions.Add(new MetadataAttributeTargetExtension()); // Default configuration var configurationFeature = new DefaultDocumentClassifierPassFeature(); @@ -105,36 +136,42 @@ namespace Microsoft.AspNetCore.Razor.Language method.Modifiers.Add("override"); }); - builder.Features.Add(configurationFeature); + features.Add(configurationFeature); } - internal static void AddRuntimeDefaults(RazorConfiguration configuration, IRazorEngineBuilder builder) + internal static void AddDefaultRuntimeFeatures(RazorConfiguration configuration, ICollection features) { // Configure options - builder.Features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: configuration.LanguageVersion)); - builder.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: configuration.LanguageVersion)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); // Intermediate Node Passes - builder.Features.Add(new PreallocatedTagHelperAttributeOptimizationPass()); + features.Add(new PreallocatedTagHelperAttributeOptimizationPass()); // Code Target Extensions - builder.AddTargetExtension(new DefaultTagHelperTargetExtension() { DesignTime = false }); - builder.AddTargetExtension(new PreallocatedAttributeTargetExtension()); + var targetExtension = features.OfType().FirstOrDefault(); + Debug.Assert(targetExtension != null); + + targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); + targetExtension.TargetExtensions.Add(new PreallocatedAttributeTargetExtension()); } - internal static void AddDesignTimeDefaults(RazorConfiguration configuration, IRazorEngineBuilder builder) + internal static void AddDefaultDesignTimeFeatures(RazorConfiguration configuration, ICollection features) { // Configure options - builder.Features.Add(new DefaultRazorParserOptionsFeature(designTime: true, version: configuration.LanguageVersion)); - builder.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: true)); - builder.Features.Add(new SuppressChecksumOptionsFeature()); + features.Add(new DefaultRazorParserOptionsFeature(designTime: true, version: configuration.LanguageVersion)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: true)); + features.Add(new SuppressChecksumOptionsFeature()); // Intermediate Node Passes - builder.Features.Add(new DesignTimeDirectivePass()); + features.Add(new DesignTimeDirectivePass()); // Code Target Extensions - builder.AddTargetExtension(new DefaultTagHelperTargetExtension() { DesignTime = true }); - builder.AddTargetExtension(new DesignTimeDirectiveTargetExtension()); + var targetExtension = features.OfType().FirstOrDefault(); + Debug.Assert(targetExtension != null); + + targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); + targetExtension.TargetExtensions.Add(new DesignTimeDirectiveTargetExtension()); } public abstract IReadOnlyList Features { get; } @@ -144,3 +181,4 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract void Process(RazorCodeDocument document); } } + diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs new file mode 100644 index 0000000000..5117115af6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorExtensionInitializer.cs @@ -0,0 +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. + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorExtensionInitializer + { + public abstract void Initialize(RazorProjectEngineBuilder builder); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs index 74b11fcc26..b036e3d58d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorParserOptionsBuilder.cs @@ -1,21 +1,26 @@ // 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 { public abstract class RazorParserOptionsBuilder { + public virtual RazorConfiguration Configuration => null; + public abstract bool DesignTime { get; } public abstract ICollection Directives { get; } public abstract bool ParseLeadingDirectives { get; set; } - public virtual RazorLanguageVersion Version { get; } + public virtual RazorLanguageVersion LanguageVersion { get; } public abstract RazorParserOptions Build(); + + public virtual void SetDesignTime(bool designTime) + { + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProject.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProject.cs index 473e6382e1..74b772e142 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProject.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProject.cs @@ -129,9 +129,10 @@ namespace Microsoft.AspNetCore.Razor.Language /// /// The directory to root the file system at. /// A + [Obsolete("This method is obsolete and will be removed in a future version. Please use " + nameof(RazorProjectFileSystem) + "." + nameof(RazorProjectFileSystem.Create) + " instead.")] public static RazorProject Create(string rootDirectoryPath) { - return new FileSystemRazorProject(rootDirectoryPath); + return new DefaultRazorProjectFileSystem(rootDirectoryPath); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs new file mode 100644 index 0000000000..e76bdffc94 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngine.cs @@ -0,0 +1,188 @@ +// 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.Reflection; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language.Extensions; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorProjectEngine + { + public abstract RazorConfiguration Configuration { get; } + + public abstract RazorProjectFileSystem FileSystem { get; } + + public abstract RazorEngine Engine { get; } + + public IReadOnlyList EngineFeatures => Engine.Features; + + public IReadOnlyList Phases => Engine.Phases; + + public abstract IReadOnlyList ProjectFeatures { get; } + + public virtual RazorCodeDocument Process(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var codeDocument = CreateCodeDocumentCore(projectItem); + ProcessCore(codeDocument); + return codeDocument; + } + + public virtual RazorCodeDocument ProcessDesignTime(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var codeDocument = CreateCodeDocumentDesignTimeCore(projectItem); + ProcessCore(codeDocument); + return codeDocument; + } + + protected abstract RazorCodeDocument CreateCodeDocumentCore(RazorProjectItem projectItem); + + protected abstract RazorCodeDocument CreateCodeDocumentDesignTimeCore(RazorProjectItem projectItem); + + protected abstract void ProcessCore(RazorCodeDocument codeDocument); + + public static RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem) => Create(configuration, fileSystem, configure: null); + + public static RazorProjectEngine Create( + RazorConfiguration configuration, + RazorProjectFileSystem fileSystem, + Action configure) + { + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } + + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + var builder = new DefaultRazorProjectEngineBuilder(configuration, fileSystem); + + // The intialization order is somewhat important. + // + // Defaults -> Extensions -> Additional customization + // + // This allows extensions to rely on default features, and customizations to override choices made by + // extensions. + RazorEngine.AddDefaultPhases(builder.Phases); + AddDefaultsFeatures(builder.Features); + + LoadExtensions(builder, configuration.Extensions); + + configure?.Invoke(builder); + + return builder.Build(); + } + + private static void AddDefaultsFeatures(ICollection features) + { + features.Add(new DefaultImportProjectFeature()); + + // General extensibility + features.Add(new DefaultRazorDirectiveFeature()); + features.Add(new DefaultMetadataIdentifierFeature()); + + // Options features + features.Add(new DefaultRazorParserOptionsFactoryProjectFeature()); + features.Add(new DefaultRazorCodeGenerationOptionsFactoryProjectFeature()); + + // Legacy options features + // + // These features are obsolete as of 2.1. Our code will resolve this but not invoke them. + features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: RazorLanguageVersion.Version_2_0)); + features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + + // Syntax Tree passes + features.Add(new DefaultDirectiveSyntaxTreePass()); + features.Add(new HtmlNodeOptimizationPass()); + features.Add(new PreallocatedTagHelperAttributeOptimizationPass()); + + // Intermediate Node Passes + features.Add(new DefaultDocumentClassifierPass()); + features.Add(new MetadataAttributePass()); + features.Add(new DesignTimeDirectivePass()); + features.Add(new DirectiveRemovalOptimizationPass()); + features.Add(new DefaultTagHelperOptimizationPass()); + + // Default Code Target Extensions + var targetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + features.Add(targetExtensionFeature); + targetExtensionFeature.TargetExtensions.Add(new MetadataAttributeTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new PreallocatedAttributeTargetExtension()); + targetExtensionFeature.TargetExtensions.Add(new DesignTimeDirectiveTargetExtension()); + + // Default configuration + var configurationFeature = new DefaultDocumentClassifierPassFeature(); + features.Add(configurationFeature); + configurationFeature.ConfigureClass.Add((document, @class) => + { + @class.ClassName = "Template"; + @class.Modifiers.Add("public"); + }); + + configurationFeature.ConfigureNamespace.Add((document, @namespace) => + { + @namespace.Content = "Razor"; + }); + + configurationFeature.ConfigureMethod.Add((document, method) => + { + method.MethodName = "ExecuteAsync"; + method.ReturnType = $"global::{typeof(Task).FullName}"; + + method.Modifiers.Add("public"); + method.Modifiers.Add("async"); + method.Modifiers.Add("override"); + }); + } + + private static void LoadExtensions(RazorProjectEngineBuilder builder, IReadOnlyList extensions) + { + for (var i = 0; i < extensions.Count; i++) + { + // For now we only handle AssemblyExtension - which is not user-constructable. We're keeping a tight + // lid on how things work until we add official support for extensibility everywhere. So, this is + // intentionally inflexible for the time being. + var extension = extensions[i] as AssemblyExtension; + if (extension == null) + { + continue; + } + + // It's not an error to have an assembly with no initializers. This is useful to specify a dependency + // that doesn't really provide any Razor configuration. + var attributes = extension.Assembly.GetCustomAttributes(); + foreach (var attribute in attributes) + { + // Using extension names and requiring them to line up allows a single assembly to ship multiple + // extensions/initializers for different configurations. + if (!string.Equals(attribute.ExtensionName, extension.ExtensionName, StringComparison.Ordinal)) + { + continue; + } + + // There's no real protection/exception handling here because this set isn't really user-extensible + // right now. This would be a great place to add some additional diagnostics and hardening in the + // future. + var initializer = (RazorExtensionInitializer)Activator.CreateInstance(attribute.InitializerType); + initializer.Initialize(builder); + } + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.cs new file mode 100644 index 0000000000..9fe4356fa9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilder.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.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorProjectEngineBuilder + { + public abstract RazorConfiguration Configuration { get; } + + public abstract RazorProjectFileSystem FileSystem { get; } + + public abstract ICollection Features { get; } + + public abstract IList Phases { get; } + + public abstract RazorProjectEngine Build(); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs new file mode 100644 index 0000000000..48695a6f97 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs @@ -0,0 +1,234 @@ +// 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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public static class RazorProjectEngineBuilderExtensions + { + /// + /// Registers a class configuration delegate that gets invoked during code generation. + /// + /// The . + /// invoked to configure + /// during code generation. + /// The . + public static RazorProjectEngineBuilder ConfigureClass( + this RazorProjectEngineBuilder builder, + Action configureClass) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (configureClass == null) + { + throw new ArgumentNullException(nameof(configureClass)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureClass.Add(configureClass); + return builder; + } + + /// + /// Sets the base type for generated types. + /// + /// The . + /// The name of the base type. + /// The . + public static RazorProjectEngineBuilder SetBaseType(this RazorProjectEngineBuilder builder, string baseType) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureClass.Add((document, @class) => @class.BaseType = baseType); + return builder; + } + + /// + /// Sets the namespace for generated types. + /// + /// The . + /// The name of the namespace. + /// The . + public static RazorProjectEngineBuilder SetNamespace(this RazorProjectEngineBuilder builder, string namespaceName) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var configurationFeature = GetDefaultDocumentClassifierPassFeature(builder); + configurationFeature.ConfigureNamespace.Add((document, @namespace) => @namespace.Content = namespaceName); + return builder; + } + + public static void SetImportFeature(this RazorProjectEngineBuilder builder, IImportProjectFeature feature) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (feature == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + // Remove any existing import features in favor of the new one we're given. + var existingFeatures = builder.Features.OfType().ToArray(); + foreach (var existingFeature in existingFeatures) + { + builder.Features.Remove(existingFeature); + } + + builder.Features.Add(feature); + } + + /// + /// Adds the specified . + /// + /// The . + /// The to add. + /// The . + public static RazorProjectEngineBuilder AddTargetExtension(this RazorProjectEngineBuilder builder, ICodeTargetExtension extension) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (extension == null) + { + throw new ArgumentNullException(nameof(extension)); + } + + var targetExtensionFeature = GetTargetExtensionFeature(builder); + targetExtensionFeature.TargetExtensions.Add(extension); + + return builder; + } + + /// + /// Adds the specified . + /// + /// The . + /// The to add. + /// The . + public static RazorProjectEngineBuilder AddDirective(this RazorProjectEngineBuilder builder, DirectiveDescriptor directive) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (directive == null) + { + throw new ArgumentNullException(nameof(directive)); + } + + var directiveFeature = GetDirectiveFeature(builder); + directiveFeature.Directives.Add(directive); + + return builder; + } + + /// + /// Adds the provided s as imports to all project items processed + /// by the . + /// + /// The . + /// The collection of imports. + /// The . + public static RazorProjectEngineBuilder AddDefaultImports(this RazorProjectEngineBuilder builder, params RazorProjectItem[] imports) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var existingImportFeature = builder.Features.OfType().First(); + var testImportFeature = new AdditionalImportsProjectFeature(existingImportFeature, imports); + builder.SetImportFeature(testImportFeature); + + return builder; + } + + private static IRazorDirectiveFeature GetDirectiveFeature(RazorProjectEngineBuilder builder) + { + var directiveFeature = builder.Features.OfType().FirstOrDefault(); + if (directiveFeature == null) + { + directiveFeature = new DefaultRazorDirectiveFeature(); + builder.Features.Add(directiveFeature); + } + + return directiveFeature; + } + + private static IRazorTargetExtensionFeature GetTargetExtensionFeature(RazorProjectEngineBuilder builder) + { + var targetExtensionFeature = builder.Features.OfType().FirstOrDefault(); + if (targetExtensionFeature == null) + { + targetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + builder.Features.Add(targetExtensionFeature); + } + + return targetExtensionFeature; + } + + private static DefaultDocumentClassifierPassFeature GetDefaultDocumentClassifierPassFeature(RazorProjectEngineBuilder builder) + { + var configurationFeature = builder.Features.OfType().FirstOrDefault(); + if (configurationFeature == null) + { + configurationFeature = new DefaultDocumentClassifierPassFeature(); + builder.Features.Add(configurationFeature); + } + + return configurationFeature; + } + + private class AdditionalImportsProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private readonly IImportProjectFeature _existingImportFeature; + private readonly RazorProjectItem[] _imports; + + public override RazorProjectEngine ProjectEngine + { + get => base.ProjectEngine; + set + { + _existingImportFeature.ProjectEngine = value; + base.ProjectEngine = value; + } + } + + public AdditionalImportsProjectFeature(IImportProjectFeature existingImportFeature, params RazorProjectItem[] imports) + { + _existingImportFeature = existingImportFeature; + _imports = imports; + } + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + var imports = _existingImportFeature.GetImports(projectItem).ToList(); + imports.AddRange(_imports); + + return imports; + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineFeatureBase.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineFeatureBase.cs new file mode 100644 index 0000000000..ec170659e4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineFeatureBase.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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorProjectEngineFeatureBase : IRazorProjectEngineFeature + { + private RazorProjectEngine _projectEngine; + + public virtual RazorProjectEngine ProjectEngine + { + get => _projectEngine; + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + _projectEngine = value; + OnInitialized(); + } + } + + protected virtual void OnInitialized() + { + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.cs new file mode 100644 index 0000000000..799c6bda65 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectFileSystem.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. + +using System; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class RazorProjectFileSystem : RazorProject + { + internal static readonly RazorProjectFileSystem Empty = new EmptyProjectFileSystem(); + + /// + /// Create a Razor project file system based off of a root directory. + /// + /// The directory to root the file system at. + /// A + public new static RazorProjectFileSystem Create(string rootDirectoryPath) + { + if (string.IsNullOrEmpty(rootDirectoryPath)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(rootDirectoryPath)); + } + + return new DefaultRazorProjectFileSystem(rootDirectoryPath); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs index 67b0e04dfd..6aecb94daa 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectItem.cs @@ -7,7 +7,7 @@ using System.IO; namespace Microsoft.AspNetCore.Razor.Language { /// - /// An item in . + /// An item in a . /// [DebuggerDisplay("{" + nameof(DebuggerToString) + "()}")] public abstract class RazorProjectItem @@ -18,15 +18,23 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract string BasePath { get; } /// - /// File path relative to . + /// File path relative to . This property uses the project path syntax, + /// using / as a path separator and does not follow the operating system's file system + /// conventions. /// public abstract string FilePath { get; } /// - /// The absolute path to the file, including the file name. + /// The absolute physical (file system) path to the file, including the file name. /// public abstract string PhysicalPath { get; } + /// + /// The relative physical (file system) path to the file, including the file name. Relative to the + /// physical path of the . + /// + public virtual string RelativePhysicalPath => null; + /// /// Gets the file contents as readonly . /// diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs index 868e25db88..31acb7dfd6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Security.Cryptography; using System.Text; namespace Microsoft.AspNetCore.Razor.Language @@ -17,15 +18,33 @@ namespace Microsoft.AspNetCore.Razor.Language internal static readonly RazorSourceDocument[] EmptyArray = new RazorSourceDocument[0]; /// - /// Encoding of the file that the text was read from. + /// Gets the encoding of the text in the original source document. /// + /// + /// Depending on the method used to create a the encoding may be used to + /// read the file contents, or it may be solely informational. Refer to the documentation on the method + /// used to create the for details. + /// public abstract Encoding Encoding { get; } /// - /// Path of the file the content was read from. + /// Gets the file path of the orginal source document. /// + /// + /// The file path may be either an absolute path or project-relative path. An absolute path is required + /// to generate debuggable assemblies. + /// public abstract string FilePath { get; } + /// + /// Gets the project-relative path to the source file. May be null. + /// + /// + /// The relative path (if provided) is used for display (error messages). The project-relative path may also + /// be used to embed checksums of the original source documents to support runtime recompilation of Razor code. + /// + public virtual string RelativePath => null; + /// /// Gets a character at given position. /// @@ -57,6 +76,29 @@ namespace Microsoft.AspNetCore.Razor.Language /// The checksum. public abstract byte[] GetChecksum(); + /// + /// Gets the name of the algorithm used to compute the checksum returned by . + /// + /// + /// This member did not exist in the 2.0 release, so it is possible for an implementation to return + /// the wrong value (or null). Implementations of should + /// override this member and specify their choice of hash algorithm even if it is the same as the + /// default (SHA1). + /// + public virtual string GetChecksumAlgorithm() + { + return HashAlgorithmName.SHA1.Name; + } + + /// + /// Gets the file path in a format that should be used for display. + /// + /// The if set, or the . + public virtual string GetFilePathForDisplay() + { + return RelativePath ?? FilePath; + } + /// /// Reads the from the specified . /// @@ -70,7 +112,8 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(stream)); } - return new StreamSourceDocument(stream, encoding: null, fileName: fileName); + var properties = new RazorSourceDocumentProperties(fileName, relativePath: null); + return new StreamSourceDocument(stream, null, properties); } /// @@ -92,7 +135,35 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(encoding)); } - return new StreamSourceDocument(stream, encoding, fileName); + var properties = new RazorSourceDocumentProperties(fileName, relativePath: null); + return new StreamSourceDocument(stream, encoding, properties); + } + + /// + /// Reads the from the specified . + /// + /// The to read from. + /// The to use to read the . + /// Properties to configure the . + /// The . + public static RazorSourceDocument ReadFrom(Stream stream, Encoding encoding, RazorSourceDocumentProperties properties) + { + if (stream == null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (encoding == null) + { + throw new ArgumentNullException(nameof(encoding)); + } + + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + return new StreamSourceDocument(stream, encoding, properties); } /// @@ -107,32 +178,73 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(projectItem)); } - var path = projectItem.PhysicalPath; - if (string.IsNullOrEmpty(path)) + // ProjectItem.PhysicalPath is usually an absolute (rooted) path. + var filePath = projectItem.PhysicalPath; + if (string.IsNullOrEmpty(filePath)) { - path = projectItem.FilePath; + // Fall back to the relative path only if necessary. + filePath = projectItem.RelativePhysicalPath; } - using (var inputStream = projectItem.Read()) + if (string.IsNullOrEmpty(filePath)) { - return ReadFrom(inputStream, path); + // Then fall back to the FilePath (yeah it's a bad name) which is like an MVC view engine path + // It's much better to have something than nothing. + filePath = projectItem.FilePath; + } + + using (var stream = projectItem.Read()) + { + // Autodetect the encoding. + var relativePath = projectItem.RelativePhysicalPath ?? projectItem.FilePath; + return new StreamSourceDocument(stream, null, new RazorSourceDocumentProperties(filePath, relativePath)); } } /// /// Creates a from the specified . /// - /// The template content. + /// The source document content. /// The file name of the . /// The . /// Uses public static RazorSourceDocument Create(string content, string fileName) - => Create(content, fileName, Encoding.UTF8); + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + return Create(content, fileName, Encoding.UTF8); + } + /// /// Creates a from the specified . /// - /// The template content. + /// The source document content. + /// Properties to configure the . + /// The . + /// Uses + public static RazorSourceDocument Create(string content, RazorSourceDocumentProperties properties) + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + return Create(content, Encoding.UTF8, properties); + } + + /// + /// Creates a from the specified . + /// + /// The source document content. /// The file name of the . /// The of the file was read from. /// The . @@ -148,7 +260,35 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(encoding)); } - return new StringSourceDocument(content, encoding, fileName); + var properties = new RazorSourceDocumentProperties(fileName, relativePath: null); + return new StringSourceDocument(content, encoding, properties); + } + + /// + /// Creates a from the specified . + /// + /// The source document content. + /// The encoding of the source document. + /// Properties to configure the . + /// The . + public static RazorSourceDocument Create(string content, Encoding encoding, RazorSourceDocumentProperties properties) + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + if (encoding == null) + { + throw new ArgumentNullException(nameof(encoding)); + } + + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + return new StringSourceDocument(content, encoding, properties); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocumentProperties.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocumentProperties.cs new file mode 100644 index 0000000000..ed48c00181 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocumentProperties.cs @@ -0,0 +1,57 @@ +// 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 +{ + /// + /// Use to configure optional properties for creating a . + /// + public sealed class RazorSourceDocumentProperties + { + /// + /// A with default values. + /// + internal static readonly RazorSourceDocumentProperties Default = new RazorSourceDocumentProperties(); + + /// + /// Creates a new . + /// + public RazorSourceDocumentProperties() + { + } + + /// + /// Creates a new . + /// + /// + /// The path to the source file. Provide an rooted path if possible. May be null. + /// + /// + /// The project-relative path to the source file. May be null. Must be a non-rooted path. + /// + public RazorSourceDocumentProperties(string filePath, string relativePath) + { + // We don't do any magic or validation here since we don't need to do any I/O or interation + // with the file system. We didn't validate anything in 2.0 so we don't want any compat risk. + FilePath = filePath; + RelativePath = relativePath; + } + + /// + /// Gets the path to the source file. May be an absolute or project-relative path. May be null. + /// + /// + /// An absolute path must be provided to generate debuggable assemblies. + /// + public string FilePath { get; } + + /// + /// Gets the project-relative path to the source file. May be null. + /// + /// + /// The relative path (if provided) is used for display (error messages). The project-relative path may also + /// be used to embed checksums of the original source documents to support runtime recompilation of Razor code. + /// + public string RelativePath { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorTemplateEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorTemplateEngine.cs index 73bbb4d9cf..298666b56f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorTemplateEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorTemplateEngine.cs @@ -184,7 +184,6 @@ namespace Microsoft.AspNetCore.Razor.Language } var result = new List(); - var importProjectItems = GetImportItems(projectItem); foreach (var importItem in importProjectItems) { diff --git a/src/Microsoft.AspNetCore.Razor.Language/Resources.resx b/src/Microsoft.AspNetCore.Razor.Language/Resources.resx index 35b511066d..195a9d791b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Resources.resx +++ b/src/Microsoft.AspNetCore.Razor.Language/Resources.resx @@ -117,45 +117,315 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Register Tag Helpers for use in the current document. + + + Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. + + + TypeName, AssemblyName + Value cannot be null or an empty string. + + Block cannot be built because a Type has not been specified in the BlockBuilder + + + Block directive '{0}' cannot be imported. + + + code + This is a literal used when composing ParserError_* messages. Most blocks are named by the keyword that starts them, for example "if". However, for those without keywords, a (localizable) name must be used. This literal is ALWAYS used mid-sentence, thus should not be capitalized. + + + explicit expression + This is a literal used when composing ParserError_* messages. Most blocks are named by the keyword that starts them, for example "if". However, for those without keywords, a (localizable) name must be used. This literal is ALWAYS used mid-sentence, thus should not be capitalized. + + + 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>> + + + The document type '{0}' does not support the extension '{1}'. + + + Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + + + A non-optional directive token cannot follow an optional directive token. + + + The '{0}' directive expects an identifier. + + + The '{0}' directive expects a namespace name. + + + The '{0}' directive expects a string surrounded by double quotes. + + + The '{0}' directive expects a type name. + + + The '{0}` directive must appear at the start of the line. + + + The '{0}' directives value(s) must be separated by whitespace. + + + The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. + + + The '{0}' directive may only occur once per document. + + + "EndBlock" was called without a matching call to "StartBlock". + + + line break + The '{0}' feature requires a '{1}' provided by the '{2}'. + + The feature must be initialized by setting the '{0}' property. + + + Specify a C# code block. + + + <<newline sequence>> + + + <<razor comment>> + + + <<text>> + + + <<white space>> + + + Specify the base class for the current document. + + + The base type that the current page inherits. + + + TypeName + + + The '{0}' operation is not valid when the builder is empty. + + + The node '{0}' has a read-only child collection and cannot be modified. + + + The reference is invalid. The node '{0}' could not be found as a child of '{1}'. + + + The reference is invalid. References initialized with the default constructor cannot modify nodes. + + + The '{0}' node type can only be used as a direct child of a '{1}' node. + + + The node '{0}' is not the owner of change '{1}'. + Invalid tag helper directive look up text '{0}'. The correct look up text format is: "name, assemblyName". Invalid tag helper directive '{0}' value. '{1}' is not allowed in prefix '{2}'. - - The '{0}' operation is not valid when the builder is empty. + + 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 The specified encoding '{0}' does not match the content's encoding '{1}'. + + 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) {{ + <p>Hello, @user!</p> +}} + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. + + + Directive '{0}' must have a value. + + + An opening "{0}" is missing the corresponding closing "{1}". + + + The {0} block is missing a closing "{1}" character. Make sure you have a matching "{1}" character for all the "{2}" characters within this block, and that none of the "{1}" characters are being interpreted as markup. + + + The {0} directive is not supported. + + + Optional quote around the directive '{0}' is missing the corresponding opening or closing quote. + + + Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed. + + + Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "<br>". Instead use self-closing tags like "<br/>". + + + The "{0}" element was not closed. All elements must be either self-closing or have a matching end tag. + + + 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. +}} + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. + + + 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. + + + "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. + + + Section blocks ("{0}") cannot be nested. Only one level of section blocks are allowed. + + + Expected a "{0}" but found a "{1}". 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) + <p>Hello, @user</p> + +Instead, wrap the contents of the block in "{{}}": + +@if(isLoggedIn) {{ + <p>Hello, @user</p> +}} + {0} is only ever a single character + + + "<text>" and "</text>" tags cannot contain attributes. + + + "{0}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{{" are valid. + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + 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: "@@" + + + Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + 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. + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" + + + Encountered end tag "{0}" with no matching start tag. Are your start/end tags properly balanced? + + + End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. + + + 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. + + + Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. + + + Cannot complete the tree, StartBlock must be called at least once. + + + Cannot complete the tree, there are still open blocks. + + + Cannot finish span, there is no current block. Call StartBlock at least once before finishing a span + The '{0}' phase requires a '{1}' provided by the '{2}'. The phase must be initialized by setting the '{0}' property. - - Tag helper directive assembly name cannot be null or empty. - Path must begin with a forward slash '/'. - - A non-optional directive token cannot follow an optional directive token. - - - The document of kind '{0}' does not have a '{1}'. The document classifier must set a value for '{2}'. - The item '{0}' could not be found. + + Remove Tag Helpers for use in the current document. + + + Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. + + + TypeName, AssemblyName + + + The '{0}' requires a '{1}' delegate to be set. + + + Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of type '{2}' cannot be empty or contain only whitespace. + + + Define a section to be rendered in the configured layout page. + + + The name of the section. + + + SectionName + + + @section Header { ... } + In CSHTML, the @section keyword is case-sensitive and lowercase (as with all C# keywords) + + + <<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. @@ -195,103 +465,81 @@ Targeted tag name cannot be null or whitespace. - - The node '{0}' is not the owner of change '{1}'. + + Tag helper directive assembly name cannot be null or empty. - - Invalid directive keyword '{0}'. Directives must have a non-empty keyword that consists only of letters. + + The tag helper attribute '{0}' in element '{1}' is missing a key. The syntax is '<{1} {0}{{ key }}="value">'. - - The feature must be initialized by setting the '{0}' property. + + TagHelper attributes must be well-formed. - - The document type '{0}' does not support the extension '{1}'. + + The parent <{0}> tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) '{1}' are allowed. - - The '{0}` directive must appear at the start of the line. + + Found an end tag (</{0}>) for tag helper '{1}' with tag structure that disallows an end tag ('{2}'). - - The '{0}' directives value(s) must be separated by whitespace. + + Tag helpers '{0}' and '{1}' targeting element '{2}' must not expect different {3} values. - - The key must not be null. - - - The reference is invalid. The node '{0}' could not be found as a child of '{1}'. - - - The reference is invalid. References initialized with the default constructor cannot modify nodes. - - - The node '{0}' has a read-only child collection and cannot be modified. - - - The '{0}' directive may only occur once per document. - - - Block directive '{0}' cannot be imported. - - - Unreachable code. This can happen when a new {0} is introduced. - - - The '{0}' requires a '{1}' delegate to be set. - - - The '{0}' node type can only be used as a direct child of a '{1}' node. - - - Invalid newline sequence '{0}'. Support newline sequences are '\r\n' and '\n'. - - - Register Tag Helpers for use in the current document. - - - Specify a C# code block. - - - Specify the base class for the current document. - - - Remove Tag Helpers for use in the current document. - - - Define a section to be rendered in the configured layout page. + + The <{0}> tag is not allowed by parent <{1}> tag helper. Only child tags with name(s) '{2}' are allowed. Specify a prefix that is required in an element name for it to be included in Tag Helper processing. - - Add tag helpers from the specified type name and assembly name. Specify '*' for the type name to include all tag helper types from the specified assembly. - - - TypeName, AssemblyName - - - The base type that the current page inherits. - - - TypeName - - - Remove tag helpers from the specified type name and assembly name. Specify '*' for the type name to remove all tag helper types from the specified assembly. - - - TypeName, AssemblyName - The tag prefix to apply to tag helpers. Prefix - - The name of the section. + + Tag Helper '{0}'s attributes must have names. - - SectionName + + The tag helper '{0}' must not have C# in the element's attribute declaration area. + + + Code blocks (e.g. @{{var variable = 23;}}) must not appear in non-string tag helper attribute values. + Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. + + + Inline markup blocks (e.g. @<p>content</p>) must not appear in non-string tag helper attribute values. + Expected a '{0}' attribute value, not a string. + + + Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self closing. + + + Missing close angle for tag helper '{0}'. + + + Unreachable code. This can happen when a new {0} is introduced. + + + Unexpected literal following the '{0}' directive. Expected '{1}'. + + + Unexpected end of file following the '{0}' directive. Expected '{1}'. + + + The hash algorithm '{0}' is not supported for checksum generation. Supported algorithms are: '{1}'. Set '{2}' to '{3}' to suppress automatic checksum generation. + + + The '{0}.{1}' property must not be null. + + + The '{0}' is missing feature '{1}'. The Razor language version '{0}' is unrecognized or not supported by this version of Razor. + + File path '{0}' does not belong to the directory '{1}'. + + + The file path '{0}' is invalid. File path is the root relative path of the file starting with '/' and should not contain any '\' characters. + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs b/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs index bb5ac8b973..de58f7c2aa 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs @@ -116,9 +116,10 @@ namespace Microsoft.AspNetCore.Razor.Language /// public bool Equals(SourceLocation other) { - // LineIndex and CharacterIndex can be calculated from AbsoluteIndex and the document content. return string.Equals(FilePath, other.FilePath, StringComparison.Ordinal) && - AbsoluteIndex == other.AbsoluteIndex; + AbsoluteIndex == other.AbsoluteIndex && + LineIndex == other.LineIndex && + CharacterIndex == other.CharacterIndex; } public static bool operator==(SourceLocation left, SourceLocation right) diff --git a/src/Microsoft.AspNetCore.Razor.Language/SourceSpan.cs b/src/Microsoft.AspNetCore.Razor.Language/SourceSpan.cs index 970aab07b4..5da785c911 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/SourceSpan.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/SourceSpan.cs @@ -30,6 +30,11 @@ namespace Microsoft.AspNetCore.Razor.Language FilePath = filePath; } + public SourceSpan(int absoluteIndex, int lineIndex, int characterIndex, int length) + : this(filePath: null, absoluteIndex: absoluteIndex, lineIndex: lineIndex, characterIndex: characterIndex, length: length) + { + } + public int Length { get; } public int AbsoluteIndex { get; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs index 2c0fab062c..1b9d239e7b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs @@ -15,15 +15,21 @@ namespace Microsoft.AspNetCore.Razor.Language private readonly byte[] _checksum; - public StreamSourceDocument(Stream stream, Encoding encoding, string fileName) + public StreamSourceDocument(Stream stream, Encoding encoding, RazorSourceDocumentProperties properties) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + // Notice we don't validate the encoding here. StreamSourceDocument can compute it. _checksum = ComputeChecksum(stream); - _innerSourceDocument = CreateInnerSourceDocument(stream, encoding, fileName); + _innerSourceDocument = CreateInnerSourceDocument(stream, encoding, properties); } public override char this[int position] => _innerSourceDocument[position]; @@ -36,6 +42,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override RazorSourceLineCollection Lines => _innerSourceDocument.Lines; + public override string RelativePath => _innerSourceDocument.RelativePath; + public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) => _innerSourceDocument.CopyTo(sourceIndex, destination, destinationIndex, count); @@ -58,7 +66,7 @@ namespace Microsoft.AspNetCore.Razor.Language } } - private static RazorSourceDocument CreateInnerSourceDocument(Stream stream, Encoding encoding, string fileName) + private static RazorSourceDocument CreateInnerSourceDocument(Stream stream, Encoding encoding, RazorSourceDocumentProperties properties) { var streamLength = (int)stream.Length; var content = string.Empty; @@ -98,14 +106,14 @@ namespace Microsoft.AspNetCore.Razor.Language reader, LargeObjectHeapLimitInChars, contentEncoding, - fileName); + properties); } content = reader.ReadToEnd(); } } - return new StringSourceDocument(content, contentEncoding, fileName); + return new StringSourceDocument(content, contentEncoding, properties); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs index 5f528024c2..a89ac1b25a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language private readonly RazorSourceLineCollection _lines; private byte[] _checksum; - public StringSourceDocument(string content, Encoding encoding, string filePath) + public StringSourceDocument(string content, Encoding encoding, RazorSourceDocumentProperties properties) { if (content == null) { @@ -25,9 +25,15 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(encoding)); } + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + _content = content; Encoding = encoding; - FilePath = filePath; + FilePath = properties.FilePath; + RelativePath = properties.RelativePath; _lines = new DefaultRazorSourceLineCollection(this); } @@ -37,11 +43,13 @@ namespace Microsoft.AspNetCore.Razor.Language public override Encoding Encoding { get; } public override string FilePath { get; } - + public override int Length => _content.Length; public override RazorSourceLineCollection Lines => _lines; + public override string RelativePath { get; } + public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) { if (destination == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/VirtualRazorProjectFileSystem.cs b/src/Microsoft.AspNetCore.Razor.Language/VirtualRazorProjectFileSystem.cs new file mode 100644 index 0000000000..6b3737fb73 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/VirtualRazorProjectFileSystem.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.Diagnostics; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class VirtualRazorProjectFileSystem : RazorProjectFileSystem + { + private readonly DirectoryNode _root = new DirectoryNode("/"); + + public override IEnumerable EnumerateItems(string basePath) + { + basePath = NormalizeAndEnsureValidPath(basePath); + var directory = _root.GetDirectory(basePath); + return directory?.EnumerateItems() ?? Enumerable.Empty(); + } + + public override RazorProjectItem GetItem(string path) + { + path = NormalizeAndEnsureValidPath(path); + return _root.GetItem(path) ?? new NotFoundProjectItem(string.Empty, path); + } + + public void Add(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + var filePath = NormalizeAndEnsureValidPath(projectItem.FilePath); + _root.AddFile(new FileNode(filePath, projectItem)); + } + + // Internal for testing + [DebuggerDisplay("{Path}")] + internal class DirectoryNode + { + public DirectoryNode(string path) + { + Path = path; + } + + public string Path { get; } + + public List Directories { get; } = new List(); + + public List Files { get; } = new List(); + + public void AddFile(FileNode fileNode) + { + var filePath = fileNode.Path; + if (!filePath.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) + { + var message = Resources.FormatVirtualFileSystem_FileDoesNotBelongToDirectory(fileNode.Path, Path); + throw new InvalidOperationException(message); + } + + // Look for the first / that appears in the path after the current directory path. + var directoryPath = GetDirectoryPath(filePath); + var directory = GetOrAddDirectory(this, directoryPath, createIfNotExists: true); + Debug.Assert(directory != null); + directory.Files.Add(fileNode); + } + + public DirectoryNode GetDirectory(string path) + { + if (!path.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) + { + var message = Resources.FormatVirtualFileSystem_FileDoesNotBelongToDirectory(path, Path); + throw new InvalidOperationException(message); + } + + return GetOrAddDirectory(this, path); + } + + public IEnumerable EnumerateItems() + { + foreach (var file in Files) + { + yield return file.ProjectItem; + } + + foreach (var directory in Directories) + { + foreach (var file in directory.EnumerateItems()) + { + yield return file; + } + } + } + + public RazorProjectItem GetItem(string path) + { + if (!path.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException(Resources.FormatVirtualFileSystem_FileDoesNotBelongToDirectory(path, Path)); + } + + var directoryPath = GetDirectoryPath(path); + var directory = GetOrAddDirectory(this, directoryPath); + if (directory == null) + { + return null; + } + + foreach (var file in directory.Files) + { + var filePath = file.Path; + var directoryLength = directory.Path.Length; + + // path, filePath -> /Views/Home/Index.cshtml + // directory.Path -> /Views/Home/ + // We only need to match the file name portion since we've already matched the directory segment. + if (string.Compare(path, directoryLength, filePath, directoryLength, path.Length - directoryLength, StringComparison.OrdinalIgnoreCase) == 0) + { + return file.ProjectItem; + } + } + + return null; + } + + private static string GetDirectoryPath(string path) + { + // /dir1/dir2/file.cshtml -> /dir1/dir2/ + var fileNameIndex = path.LastIndexOf('/'); + if (fileNameIndex == -1) + { + return path; + } + + return path.Substring(0, fileNameIndex + 1); + } + + private static DirectoryNode GetOrAddDirectory( + DirectoryNode directory, + string path, + bool createIfNotExists = false) + { + Debug.Assert(!string.IsNullOrEmpty(path)); + if (path[path.Length - 1] != '/') + { + path += '/'; + } + + int index; + while ((index = path.IndexOf('/', directory.Path.Length)) != -1 && index != path.Length) + { + var subDirectory = FindSubDirectory(directory, path); + + if (subDirectory == null) + { + if (createIfNotExists) + { + var directoryPath = path.Substring(0, index + 1); // + 1 to include trailing slash + subDirectory = new DirectoryNode(directoryPath); + directory.Directories.Add(subDirectory); + } + else + { + return null; + } + } + + directory = subDirectory; + } + + return directory; + } + + private static DirectoryNode FindSubDirectory(DirectoryNode parentDirectory, string path) + { + for (var i = 0; i < parentDirectory.Directories.Count; i++) + { + // ParentDirectory.Path -> /Views/Home/ + // CurrentDirectory.Path -> /Views/Home/SubDir/ + // Path -> /Views/Home/SubDir/MorePath/File.cshtml + // Each invocation of FindSubDirectory returns the immediate subdirectory along the path to the file. + + var currentDirectory = parentDirectory.Directories[i]; + var directoryPath = currentDirectory.Path; + var startIndex = parentDirectory.Path.Length; + var directoryNameLength = directoryPath.Length - startIndex; + + if (string.Compare(path, startIndex, directoryPath, startIndex, directoryPath.Length - startIndex, StringComparison.OrdinalIgnoreCase) == 0) + { + return currentDirectory; + } + } + + return null; + } + } + + // Internal for testing + [DebuggerDisplay("{Path}")] + internal struct FileNode + { + public FileNode(string path, RazorProjectItem projectItem) + { + Path = path; + ProjectItem = projectItem; + } + + public string Path { get; } + + public RazorProjectItem ProjectItem { get; } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/DefaultRazorCompiledItem.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/DefaultRazorCompiledItem.cs new file mode 100644 index 0000000000..b5390b7c87 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/DefaultRazorCompiledItem.cs @@ -0,0 +1,54 @@ +// 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.Hosting +{ + internal class DefaultRazorCompiledItem : RazorCompiledItem + { + private object[] _metadata; + + public DefaultRazorCompiledItem(Type type, string kind, string identifier) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + if (kind == null) + { + throw new ArgumentNullException(nameof(kind)); + } + + if (identifier == null) + { + throw new ArgumentNullException(nameof(identifier)); + } + + Type = type; + Kind = kind; + Identifier = identifier; + } + + public override string Identifier { get; } + + public override string Kind { get; } + + public override IReadOnlyList Metadata + { + get + { + if (_metadata == null) + { + _metadata = Type.GetCustomAttributes(inherit: true); + } + + return _metadata; + } + } + + public override Type Type { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/IRazorSourceChecksumMetadata.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/IRazorSourceChecksumMetadata.cs new file mode 100644 index 0000000000..dccdb2f871 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/IRazorSourceChecksumMetadata.cs @@ -0,0 +1,26 @@ +// 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.Hosting +{ + /// + /// A metadata object containing the checksum of a source file that contributed to a compiled item. + /// + public interface IRazorSourceChecksumMetadata + { + /// + /// Gets the checksum as string of hex-encoded bytes. + /// + string Checksum { get; } + + /// + /// Gets the name of the algorithm used to create this checksum. + /// + string ChecksumAlgorithm { get; } + + /// + /// Gets the identifier of the source file associated with this checksum. + /// + string Identifier { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItem.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItem.cs new file mode 100644 index 0000000000..8eff0f4ea2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItem.cs @@ -0,0 +1,40 @@ +// 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.Hosting +{ + /// + /// Identifies a compiled item that can be identified and loaded. + /// + public abstract class RazorCompiledItem + { + /// + /// Gets the identifier associated with the compiled item. The identifier is used programmatically to locate + /// a specific item of a specific kind and should be uniqure within the assembly. + /// + public abstract string Identifier { get; } + + /// + /// Gets the kind of compiled item. The kind is used programmatically to associate behaviors and semantics + /// with the item. + /// + public abstract string Kind { get; } + + /// + /// Gets a collection of arbitrary metadata associated with the item. + /// + /// + /// For items loaded with the default implementation of , the + /// metadata collection will return all attributes defined on the . + /// + public abstract IReadOnlyList Metadata { get; } + + /// + /// Gets the of the compiled item. + /// + public abstract Type Type { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemAttribute.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemAttribute.cs new file mode 100644 index 0000000000..8e4c003f87 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemAttribute.cs @@ -0,0 +1,60 @@ +// 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.Hosting +{ + /// + /// Specifies that an assembly contains a compiled Razor asset. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public sealed class RazorCompiledItemAttribute : Attribute + { + /// + /// Creates a new . + /// + /// The of the compiled item. + /// + /// The kind of the compiled item. The kind is used programmatically to associate behaviors with the item. + /// + /// + /// The identifier associated with the item. The identifier is used programmatically to locate + /// a specific item of a specific kind, and should be unique within the assembly. + /// + public RazorCompiledItemAttribute(Type type, string kind, string identifier) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + if (kind == null) + { + throw new ArgumentNullException(nameof(kind)); + } + + Type = type; + Kind = kind; + Identifier = identifier; + } + + /// + /// Gets the kind of compiled item. The kind is used programmatically to associate behaviors and semantics + /// with the item. + /// + public string Kind { get; } + + /// + /// Gets the identifier associated with the compiled item. The identifier is used programmatically to locate + /// a specific item of a specific kind and should be uniqure within the assembly. + /// + public string Identifier { get; } + + /// + /// Gets the of the compiled item. The type should be contained in the assembly associated + /// with this instance of . + /// + public Type Type { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemExtensions.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemExtensions.cs new file mode 100644 index 0000000000..d6287e3253 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemExtensions.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; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Hosting +{ + /// + /// Extension methods for . + /// + public static class RazorCompiledItemExtensions + { + /// + /// Gets the list of associated with . + /// + /// The . + /// A list of . + public static IReadOnlyList GetChecksumMetadata(this RazorCompiledItem item) + { + if (item == null) + { + throw new ArgumentNullException(nameof(item)); + } + + return item.Metadata.OfType().ToArray(); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemLoader.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemLoader.cs new file mode 100644 index 0000000000..9b3db2dbb3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorCompiledItemLoader.cs @@ -0,0 +1,83 @@ +// 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.Reflection; + +namespace Microsoft.AspNetCore.Razor.Hosting +{ + /// + /// A loader implementation that can load objects from an + /// using reflection. + /// + /// + /// + /// Inherit from to customize the behavior when loading + /// objects from an . The default implementations of methods + /// defined by this class use reflection in a trivial way to load attributes from the assembly. + /// + /// + /// Inheriting from is useful when an implementation needs to consider + /// additional configuration or data outside of the being loaded. + /// + /// + /// Subclasses of can return subclasses of + /// with additional data members by overriding . + /// + /// + public class RazorCompiledItemLoader + { + /// + /// Loads a list of objects from the provided . + /// + /// The assembly to search. + /// A list of objects. + public virtual IReadOnlyList LoadItems(Assembly assembly) + { + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + var items = new List(); + foreach (var attribute in LoadAttributes(assembly)) + { + items.Add(CreateItem(attribute)); + } + + return items; + } + + /// + /// Creates a from a . + /// + /// The . + /// A created from . + protected virtual RazorCompiledItem CreateItem(RazorCompiledItemAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return new DefaultRazorCompiledItem(attribute.Type, attribute.Kind, attribute.Identifier); + } + + /// + /// Retrieves the list of attributes defined for the provided + /// . + /// + /// The to search. + /// A list of attributes. + protected IEnumerable LoadAttributes(Assembly assembly) + { + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + return assembly.GetCustomAttributes(); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorSourceChecksumAttribute.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorSourceChecksumAttribute.cs new file mode 100644 index 0000000000..d1da25b300 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Hosting/RazorSourceChecksumAttribute.cs @@ -0,0 +1,67 @@ +// 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.Hosting +{ + /// + /// Specifies the checksum of a source file that contributed to a compiled item. + /// + /// + /// + /// These attributes are added by the Razor infrastructure when generating code to assist runtime + /// implementations to determine the integrity of compiled items. + /// + /// + /// Runtime implementations should access the checksum metadata for an item using + /// . + /// + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] + public sealed class RazorSourceChecksumAttribute : Attribute, IRazorSourceChecksumMetadata + { + /// + /// Creates a new . + /// + /// The algorithm used to create this checksum. + /// The checksum as a string of hex-encoded bytes. + /// The identifier associated with this thumbprint. + public RazorSourceChecksumAttribute(string checksumAlgorithm, string checksum, string identifier) + { + if (checksumAlgorithm == null) + { + throw new ArgumentNullException(nameof(checksumAlgorithm)); + } + + if (checksum == null) + { + throw new ArgumentNullException(nameof(checksum)); + } + + if (identifier == null) + { + throw new ArgumentNullException(nameof(identifier)); + } + + ChecksumAlgorithm = checksumAlgorithm; + Checksum = checksum; + Identifier = identifier; + } + + /// + /// Gets the checksum as string of hex-encoded bytes. + /// + public string Checksum { get; } + + /// + /// Gets the name of the algorithm used to create this checksum. + /// + public string ChecksumAlgorithm { get; } + + /// + /// Gets the identifier of the source file associated with this checksum. + /// + public string Identifier { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Microsoft.AspNetCore.Razor.Runtime.csproj b/src/Microsoft.AspNetCore.Razor.Runtime/Microsoft.AspNetCore.Razor.Runtime.csproj index 962c97a367..b58a7f9c3f 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/Microsoft.AspNetCore.Razor.Runtime.csproj +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Microsoft.AspNetCore.Razor.Runtime.csproj @@ -1,15 +1,8 @@  - Runtime components for rendering Razor pages and implementing tag helpers. - $(Summary) - -Commonly used types: -Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute -Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute -Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper + Runtime infrastructure for rendering Razor pages and tag helpers. netstandard2.0 - true $(PackageTags);taghelper;taghelpers @@ -20,7 +13,6 @@ Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper - diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Properties/AssemblyInfo.cs index fe4a34e5e5..ea941b3e5a 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Properties/AssemblyInfo.cs @@ -2,5 +2,24 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Razor.TagHelpers; [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Runtime.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] + +[assembly: TypeForwardedTo(typeof(DefaultTagHelperContent))] +[assembly: TypeForwardedTo(typeof(HtmlAttributeNameAttribute))] +[assembly: TypeForwardedTo(typeof(HtmlAttributeNotBoundAttribute))] +[assembly: TypeForwardedTo(typeof(HtmlTargetElementAttribute))] +[assembly: TypeForwardedTo(typeof(ITagHelper))] +[assembly: TypeForwardedTo(typeof(ITagHelperComponent))] +[assembly: TypeForwardedTo(typeof(NullHtmlEncoder))] +[assembly: TypeForwardedTo(typeof(OutputElementHintAttribute))] +[assembly: TypeForwardedTo(typeof(ReadOnlyTagHelperAttributeList))] +[assembly: TypeForwardedTo(typeof(RestrictChildrenAttribute))] +[assembly: TypeForwardedTo(typeof(TagHelper))] +[assembly: TypeForwardedTo(typeof(TagHelperAttribute))] +[assembly: TypeForwardedTo(typeof(TagHelperAttributeList))] +[assembly: TypeForwardedTo(typeof(TagHelperComponent))] +[assembly: TypeForwardedTo(typeof(TagHelperContent))] +[assembly: TypeForwardedTo(typeof(TagHelperContext))] +[assembly: TypeForwardedTo(typeof(TagHelperOutput))] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor/Microsoft.AspNetCore.Razor.csproj b/src/Microsoft.AspNetCore.Razor/Microsoft.AspNetCore.Razor.csproj index f6dee80752..29dfb82a7b 100644 --- a/src/Microsoft.AspNetCore.Razor/Microsoft.AspNetCore.Razor.csproj +++ b/src/Microsoft.AspNetCore.Razor/Microsoft.AspNetCore.Razor.csproj @@ -1,8 +1,23 @@  - Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor parser and code generation infrastructure. + Razor is a markup syntax for adding server-side logic to web pages. This package contains runtime components for rendering Razor pages and implementing tag helpers. + $(Summary) + +Commonly used types: +Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute +Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute +Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper netstandard2.0 + $(PackageTags);taghelper;taghelpers + + + true + + + + + diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/DefaultTagHelperContent.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/DefaultTagHelperContent.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlAttributeNameAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlAttributeNameAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlAttributeNameAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlAttributeNameAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlAttributeNotBoundAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlAttributeNotBoundAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlAttributeNotBoundAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlAttributeNotBoundAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlTargetElementAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlTargetElementAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/HtmlTargetElementAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/HtmlTargetElementAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelper.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/ITagHelper.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelper.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/ITagHelper.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelperComponent.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/ITagHelperComponent.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelperComponent.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/ITagHelperComponent.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/NullHtmlEncoder.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/NullHtmlEncoder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/NullHtmlEncoder.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/NullHtmlEncoder.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/OutputElementHintAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/OutputElementHintAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/OutputElementHintAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/OutputElementHintAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ReadOnlyTagHelperAttributeList.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/ReadOnlyTagHelperAttributeList.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ReadOnlyTagHelperAttributeList.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/ReadOnlyTagHelperAttributeList.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/RestrictChildrenAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/RestrictChildrenAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/RestrictChildrenAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/RestrictChildrenAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelper.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelper.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelper.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelper.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperAttribute.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperAttribute.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperAttribute.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperAttributeList.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperAttributeList.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperAttributeList.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperAttributeList.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperComponent.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperComponent.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperComponent.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperComponent.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperContent.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperContent.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperContent.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperContent.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperContext.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperContext.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperContext.cs diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperOutput.cs b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperOutput.cs similarity index 99% rename from src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperOutput.cs rename to src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperOutput.cs index 14de474670..51a7f8392b 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperOutput.cs +++ b/src/Microsoft.AspNetCore.Razor/TagHelpers/TagHelperOutput.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 System.Diagnostics; using System.IO; using System.Text.Encodings.Web; using System.Threading.Tasks; diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultErrorReporterFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultErrorReporterFactory.cs index 102ef6551b..e9c987d108 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultErrorReporterFactory.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultErrorReporterFactory.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.Razor { [Shared] - [ExportWorkspaceServiceFactory(typeof(ErrorReporter))] + [ExportWorkspaceServiceFactory(typeof(ErrorReporter), ServiceLayer.Default)] internal class DefaultErrorReporterFactory : IWorkspaceServiceFactory { public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternal.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternal.cs deleted file mode 100644 index 99cf4f6d12..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternal.cs +++ /dev/null @@ -1,163 +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 Microsoft.AspNetCore.Razor.Language; - -namespace Microsoft.CodeAnalysis.Razor -{ - internal class DefaultTagHelperFactsServiceInternal : TagHelperFactsServiceInternal - { - public override TagHelperBinding GetTagHelperBinding( - TagHelperDocumentContext documentContext, - string tagName, - IEnumerable> attributes, - string parentTag, - bool parentIsTagHelper) - { - if (documentContext == null) - { - throw new ArgumentNullException(nameof(documentContext)); - } - - if (tagName == null) - { - throw new ArgumentNullException(nameof(tagName)); - } - - if (attributes == null) - { - throw new ArgumentNullException(nameof(attributes)); - } - - var descriptors = documentContext.TagHelpers; - if (descriptors == null || descriptors.Count == 0) - { - return null; - } - - var prefix = documentContext.Prefix; - var tagHelperBinder = new TagHelperBinder(prefix, descriptors); - var binding = tagHelperBinder.GetBinding(tagName, attributes.ToList(), parentTag, parentIsTagHelper); - - return binding; - } - - public override IEnumerable GetBoundTagHelperAttributes( - TagHelperDocumentContext documentContext, - string attributeName, - TagHelperBinding binding) - { - if (documentContext == null) - { - throw new ArgumentNullException(nameof(documentContext)); - } - - if (attributeName == null) - { - throw new ArgumentNullException(nameof(attributeName)); - } - - if (binding == null) - { - throw new ArgumentNullException(nameof(binding)); - } - - var matchingBoundAttributes = new List(); - foreach (var descriptor in binding.Descriptors) - { - foreach (var boundAttributeDescriptor in descriptor.BoundAttributes) - { - if (TagHelperMatchingConventions.CanSatisfyBoundAttribute(attributeName, boundAttributeDescriptor)) - { - matchingBoundAttributes.Add(boundAttributeDescriptor); - - // Only one bound attribute can match an attribute - break; - } - } - } - - return matchingBoundAttributes; - } - - public override IReadOnlyList GetTagHelpersGivenTag( - TagHelperDocumentContext documentContext, - string tagName, - string parentTag) - { - if (documentContext == null) - { - throw new ArgumentNullException(nameof(documentContext)); - } - - if (tagName == null) - { - throw new ArgumentNullException(nameof(tagName)); - } - - var matchingDescriptors = new List(); - var descriptors = documentContext?.TagHelpers; - if (descriptors?.Count == 0) - { - return matchingDescriptors; - } - - var prefix = documentContext.Prefix ?? string.Empty; - if (!tagName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) - { - // Can't possibly match TagHelpers, it doesn't start with the TagHelperPrefix. - return matchingDescriptors; - } - - var tagNameWithoutPrefix = tagName.Substring(prefix.Length); - for (var i = 0; i < descriptors.Count; i++) - { - var descriptor = descriptors[i]; - foreach (var rule in descriptor.TagMatchingRules) - { - if (TagHelperMatchingConventions.SatisfiesTagName(tagNameWithoutPrefix, rule) && - TagHelperMatchingConventions.SatisfiesParentTag(parentTag, rule)) - { - matchingDescriptors.Add(descriptor); - break; - } - } - } - - return matchingDescriptors; - } - - public override IReadOnlyList GetTagHelpersGivenParent(TagHelperDocumentContext documentContext, string parentTag) - { - if (documentContext == null) - { - throw new ArgumentNullException(nameof(documentContext)); - } - - var matchingDescriptors = new List(); - var descriptors = documentContext?.TagHelpers; - if (descriptors?.Count == 0) - { - return matchingDescriptors; - } - - for (var i = 0; i < descriptors.Count; i++) - { - var descriptor = descriptors[i]; - foreach (var rule in descriptor.TagMatchingRules) - { - if (TagHelperMatchingConventions.SatisfiesParentTag(parentTag, rule)) - { - matchingDescriptors.Add(descriptor); - break; - } - } - } - - return matchingDescriptors; - } - } -} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternalFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternalFactory.cs deleted file mode 100644 index 4e89fcdff1..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperFactsServiceInternalFactory.cs +++ /dev/null @@ -1,17 +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 Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Host.Mef; - -namespace Microsoft.CodeAnalysis.Razor -{ - [ExportLanguageServiceFactory(typeof(TagHelperFactsServiceInternal), RazorLanguage.Name, ServiceLayer.Default)] - internal class DefaultTagHelperFactsServiceInternalFactory : ILanguageServiceFactory - { - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) - { - return new DefaultTagHelperFactsServiceInternal(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternal.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternal.cs deleted file mode 100644 index 092da5f62c..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternal.cs +++ /dev/null @@ -1,54 +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.Editor -{ - internal class DefaultEditorSettingsManagerInternal : EditorSettingsManagerInternal - { - public override event EventHandler Changed; - - private readonly object SettingsAccessorLock = new object(); - private EditorSettings _settings; - - public DefaultEditorSettingsManagerInternal() - { - _settings = EditorSettings.Default; - } - - public override EditorSettings Current - { - get - { - lock (SettingsAccessorLock) - { - return _settings; - } - } - } - - public override void Update(EditorSettings updatedSettings) - { - if (updatedSettings == null) - { - throw new ArgumentNullException(nameof(updatedSettings)); - } - - lock (SettingsAccessorLock) - { - if (!_settings.Equals(updatedSettings)) - { - _settings = updatedSettings; - OnChanged(); - } - } - } - - private void OnChanged() - { - var args = new EditorSettingsChangedEventArgs(Current); - Changed?.Invoke(this, args); - } - } -} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternalFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternalFactory.cs deleted file mode 100644 index 84f49a95c8..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/DefaultEditorSettingsManagerInternalFactory.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; -using System.Composition; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Host.Mef; - -namespace Microsoft.CodeAnalysis.Razor.Editor -{ - [Shared] - [ExportLanguageServiceFactory(typeof(EditorSettingsManagerInternal), RazorLanguage.Name)] - internal class DefaultEditorSettingsManagerInternalFactory : ILanguageServiceFactory - { - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) - { - if (languageServices == null) - { - throw new ArgumentNullException(nameof(languageServices)); - } - - return new DefaultEditorSettingsManagerInternal(); - } - } -} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/EditorSettingsManagerInternal.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/WorkspaceEditorSettings.cs similarity index 74% rename from src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/EditorSettingsManagerInternal.cs rename to src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/WorkspaceEditorSettings.cs index 9dd5a4f5aa..6736dfc39d 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/EditorSettingsManagerInternal.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Editor/WorkspaceEditorSettings.cs @@ -6,12 +6,10 @@ using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.Razor.Editor { - internal abstract class EditorSettingsManagerInternal : ILanguageService + internal abstract class WorkspaceEditorSettings : ILanguageService { public abstract event EventHandler Changed; public abstract EditorSettings Current { get; } - - public abstract void Update(EditorSettings updateSettings); } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ForegroundDispatcher.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ForegroundDispatcher.cs index 7f7dac2130..bf9b0f59a4 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ForegroundDispatcher.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ForegroundDispatcher.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.Razor { - internal abstract class ForegroundDispatcher : IWorkspaceService + internal abstract class ForegroundDispatcher { public abstract bool IsForegroundThread { get; } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs index ad43248fab..afbd0028f3 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs @@ -2,6 +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.Linq; +using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { @@ -92,7 +95,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return new DefaultProjectSnapshot(update, this); } - public bool HasChangesComparedTo(ProjectSnapshot original) + public bool HasConfigurationChanged(ProjectSnapshot original) { if (original == null) { diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs index e8f9ff1de3..32c3ae4681 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs @@ -149,7 +149,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // Now we need to know if the changes that we applied are significant. If that's the case then // we need to notify listeners. - if (snapshot.HasChangesComparedTo(original)) + if (snapshot.HasConfigurationChanged(original)) { NotifyListeners(new ProjectChangeEventArgs(snapshot, ProjectChangeKind.Changed)); } @@ -172,6 +172,25 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem } } + public override void ProjectBuildComplete(Project underlyingProject) + { + if (underlyingProject == null) + { + throw new ArgumentNullException(nameof(underlyingProject)); + } + + if (_projects.TryGetValue(underlyingProject.Id, out var original)) + { + // 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.WithProjectChange(underlyingProject); + _projects[underlyingProject.Id] = snapshot; + + // Notify the background worker so it can trigger tag helper discovery. + NotifyBackgroundWorker(underlyingProject); + } + } + public override void ProjectsCleared() { foreach (var kvp in _projects.ToArray()) @@ -186,12 +205,16 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // virtual so it can be overridden in tests protected virtual void NotifyBackgroundWorker(Project project) { + _foregroundDispatcher.AssertForegroundThread(); + _workerQueue.Enqueue(project); } // virtual so it can be overridden in tests protected virtual void NotifyListeners(ProjectChangeEventArgs e) { + _foregroundDispatcher.AssertForegroundThread(); + var handler = Changed; if (handler != null) { diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs index 82d0bcdb53..d82d82cd7c 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManagerFactory.cs @@ -14,11 +14,24 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem internal class DefaultProjectSnapshotManagerFactory : ILanguageServiceFactory { private readonly IEnumerable _triggers; + private readonly ForegroundDispatcher _foregroundDispatcher; [ImportingConstructor] public DefaultProjectSnapshotManagerFactory( + ForegroundDispatcher foregroundDispatcher, [ImportMany] IEnumerable triggers) { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + if (triggers == null) + { + throw new ArgumentNullException(nameof(triggers)); + } + + _foregroundDispatcher = foregroundDispatcher; _triggers = triggers; } @@ -30,7 +43,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem } return new DefaultProjectSnapshotManager( - languageServices.WorkspaceServices.GetRequiredService(), + _foregroundDispatcher, languageServices.WorkspaceServices.GetRequiredService(), languageServices.GetRequiredService(), _triggers, diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs index 78efdfbf04..8a40c50f40 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorker.cs @@ -40,7 +40,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem // Don't block the main thread if (_foregroundDispatcher.IsForegroundThread) { - return Task.Factory.StartNew(ProjectUpdatesCoreAsync, update, CancellationToken.None, TaskCreationOptions.None, _foregroundDispatcher.BackgroundScheduler); + return Task.Factory.StartNew(ProjectUpdatesCoreAsync, update, cancellationToken, TaskCreationOptions.None, _foregroundDispatcher.BackgroundScheduler); } return ProjectUpdatesCoreAsync(update); diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs index 40a5b3f5f4..321d7dfa7a 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotWorkerFactory.cs @@ -11,10 +11,23 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem [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( - languageServices.WorkspaceServices.GetRequiredService(), + _foregroundDispatcher, languageServices.GetRequiredService()); } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs index 0a54f9b4f4..f28e477d5d 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs @@ -1,7 +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 Microsoft.AspNetCore.Razor.Language; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs index d5a4c7a9ea..b9e39e00b1 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs @@ -12,6 +12,5 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem public abstract event EventHandler Changed; public abstract IReadOnlyList Projects { get; } - } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs index 1e036b76f6..4dd392076b 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerBase.cs @@ -17,6 +17,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem public abstract void ProjectRemoved(Project underlyingProject); + public abstract void ProjectBuildComplete(Project underlyingProject); + public abstract void ProjectsCleared(); public abstract void ReportError(Exception exception); diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs index bce7e39b3a..83357e9968 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotUpdateContext.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; +using System.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs index ea60d51dec..a73900fa42 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Properties/AssemblyInfo.cs @@ -8,6 +8,8 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs similarity index 61% rename from src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs rename to src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs index 26ff5b803a..0388de4671 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorTemplateEngineFactoryService.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorProjectEngineFactoryService.cs @@ -7,8 +7,8 @@ using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.Razor { - internal abstract class RazorTemplateEngineFactoryService : ILanguageService + internal abstract class RazorProjectEngineFactoryService : ILanguageService { - public abstract RazorTemplateEngine Create(string projectPath, Action configure); + public abstract RazorProjectEngine Create(string projectPath, Action configure); } } \ No newline at end of file diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperFactsServiceInternal.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperFactsServiceInternal.cs deleted file mode 100644 index 78d26cfdbb..0000000000 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperFactsServiceInternal.cs +++ /dev/null @@ -1,20 +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.Collections.Generic; -using Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis.Host; - -namespace Microsoft.CodeAnalysis.Razor -{ - internal abstract class TagHelperFactsServiceInternal : ILanguageService - { - public abstract TagHelperBinding GetTagHelperBinding(TagHelperDocumentContext documentContext, string tagName, IEnumerable> attributes, string parentTag, bool parentIsTagHelper); - - public abstract IEnumerable GetBoundTagHelperAttributes(TagHelperDocumentContext documentContext, string attributeName, TagHelperBinding binding); - - public abstract IReadOnlyList GetTagHelpersGivenTag(TagHelperDocumentContext documentContext, string tagName, string parentTag); - - public abstract IReadOnlyList GetTagHelpersGivenParent(TagHelperDocumentContext documentContext, string parentTag); - } -} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs index a16f46400b..182273abfd 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs @@ -9,14 +9,6 @@ namespace Microsoft.CodeAnalysis.Razor { internal abstract class TagHelperResolver : ILanguageService { - public abstract TagHelperResolutionResult GetTagHelpers(Compilation compilation); - - public virtual async Task GetTagHelpersAsync( - Project project, - CancellationToken cancellationToken = default(CancellationToken)) - { - var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - return GetTagHelpers(compilation); - } + public abstract Task GetTagHelpersAsync(Project project, CancellationToken cancellationToken); } -} +} \ No newline at end of file diff --git a/src/Microsoft.CodeAnalysis.Remote.Razor/DefaultTagHelperResolver.cs b/src/Microsoft.CodeAnalysis.Remote.Razor/DefaultTagHelperResolver.cs index 43b55a5b50..4aca5c8f7e 100644 --- a/src/Microsoft.CodeAnalysis.Remote.Razor/DefaultTagHelperResolver.cs +++ b/src/Microsoft.CodeAnalysis.Remote.Razor/DefaultTagHelperResolver.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.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Razor.Extensions; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; @@ -17,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor public bool DesignTime { get; } - public override TagHelperResolutionResult GetTagHelpers(Compilation compilation) + private TagHelperResolutionResult GetTagHelpers(Compilation compilation) { var descriptors = new List(); @@ -42,5 +44,11 @@ namespace Microsoft.CodeAnalysis.Remote.Razor return resolutionResult; } + + public override async Task GetTagHelpersAsync(Project project, CancellationToken cancellationToken) + { + var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + return GetTagHelpers(compilation); + } } } diff --git a/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs index 887a98dab0..a81681c872 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/BackgroundParser.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Text; using System.Threading; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Legacy; @@ -18,10 +19,10 @@ namespace Microsoft.VisualStudio.Editor.Razor private MainThreadState _main; private BackgroundThread _bg; - public BackgroundParser(RazorTemplateEngine templateEngine, string filePath) + public BackgroundParser(RazorProjectEngine projectEngine, string filePath, string projectDirectory) { _main = new MainThreadState(filePath); - _bg = new BackgroundThread(_main, templateEngine, filePath); + _bg = new BackgroundThread(_main, projectEngine, filePath, projectDirectory); _main.ResultsReady += (sender, args) => OnResultsReady(args); } @@ -233,22 +234,25 @@ namespace Microsoft.VisualStudio.Editor.Razor private class BackgroundThread : ThreadStateBase { + private readonly string _filePath; + private readonly string _relativeFilePath; + private readonly string _projectDirectory; private MainThreadState _main; private Thread _backgroundThread; private CancellationToken _shutdownToken; - private RazorTemplateEngine _templateEngine; - private string _filePath; + private RazorProjectEngine _projectEngine; private RazorSyntaxTree _currentSyntaxTree; private IList _previouslyDiscarded = new List(); - public BackgroundThread(MainThreadState main, RazorTemplateEngine templateEngine, string fileName) + public BackgroundThread(MainThreadState main, RazorProjectEngine projectEngine, string filePath, string projectDirectory) { // Run on MAIN thread! _main = main; _shutdownToken = _main.CancelToken; - _templateEngine = templateEngine; - _filePath = fileName; - + _projectEngine = projectEngine; + _filePath = filePath; + _relativeFilePath = GetNormalizedRelativeFilePath(filePath, projectDirectory); + _projectDirectory = projectDirectory; _backgroundThread = new Thread(WorkerLoop); SetThreadId(_backgroundThread.ManagedThreadId); } @@ -262,8 +266,6 @@ namespace Microsoft.VisualStudio.Editor.Razor // **** BACKGROUND THREAD **** private void WorkerLoop() { - var fileNameOnly = Path.GetFileName(_filePath); - try { EnsureOnThread(); @@ -347,14 +349,31 @@ namespace Microsoft.VisualStudio.Editor.Razor { EnsureOnThread(); - var sourceDocument = new TextSnapshotSourceDocument(snapshot, _filePath); - var imports = _templateEngine.GetImports(_filePath); + var projectItem = new TextSnapshotProjectItem(snapshot, _projectDirectory, _relativeFilePath, _filePath); + var codeDocument = _projectEngine.ProcessDesignTime(projectItem); - var codeDocument = RazorCodeDocument.Create(sourceDocument, imports); - - _templateEngine.GenerateCode(codeDocument); return codeDocument; } + + private string GetNormalizedRelativeFilePath(string filePath, string projectDirectory) + { + if (filePath.StartsWith(projectDirectory, StringComparison.OrdinalIgnoreCase)) + { + filePath = filePath.Substring(projectDirectory.Length); + } + + if (filePath.Length > 1) + { + filePath = filePath.Replace('\\', '/'); + + if (filePath[0] != '/') + { + filePath = "/" + filePath; + } + } + + return filePath; + } } private class WorkParcel @@ -383,4 +402,4 @@ namespace Microsoft.VisualStudio.Editor.Razor public ITextSnapshot Snapshot { get; set; } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/BraceSmartIndenterFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/BraceSmartIndenterFactory.cs index 750c061b7b..bc477b4f28 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/BraceSmartIndenterFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/BraceSmartIndenterFactory.cs @@ -1,10 +1,12 @@ // 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 Microsoft.CodeAnalysis.Host; + namespace Microsoft.VisualStudio.Editor.Razor { - internal abstract class BraceSmartIndenterFactory + internal abstract class BraceSmartIndenterFactory : ILanguageService { public abstract BraceSmartIndenter Create(VisualStudioDocumentTracker documentTracker); } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultBraceSmartIndenterFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactory.cs similarity index 70% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultBraceSmartIndenterFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactory.cs index 9b2bcf0ad0..53f093412b 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultBraceSmartIndenterFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactory.cs @@ -2,38 +2,32 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.ComponentModel.Composition; -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Text.Operations; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { - [System.Composition.Shared] - [Export(typeof(BraceSmartIndenterFactory))] internal class DefaultBraceSmartIndenterFactory : BraceSmartIndenterFactory { private readonly IEditorOperationsFactoryService _editorOperationsFactory; private readonly ForegroundDispatcher _dispatcher; - [ImportingConstructor] public DefaultBraceSmartIndenterFactory( - IEditorOperationsFactoryService editorOperationsFactory, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) + ForegroundDispatcher dispatcher, + IEditorOperationsFactoryService editorOperationsFactory) { + if (dispatcher == null) + { + throw new ArgumentNullException(nameof(dispatcher)); + } + if (editorOperationsFactory == null) { throw new ArgumentNullException(nameof(editorOperationsFactory)); } - if (workspace == null) - { - throw new ArgumentNullException(nameof(workspace)); - } - + _dispatcher = dispatcher; _editorOperationsFactory = editorOperationsFactory; - _dispatcher = workspace.Services.GetRequiredService(); } public override BraceSmartIndenter Create(VisualStudioDocumentTracker documentTracker) @@ -50,4 +44,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return braceSmartIndenter; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactoryFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactoryFactory.cs new file mode 100644 index 0000000000..0f96a5189b --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultBraceSmartIndenterFactoryFactory.cs @@ -0,0 +1,47 @@ +// 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; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Text.Operations; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(BraceSmartIndenterFactory), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultBraceSmartIndenterFactoryFactory : ILanguageServiceFactory + { + private readonly ForegroundDispatcher _foregroundDispatcher; + private readonly IEditorOperationsFactoryService _editorOperationsFactory; + + [ImportingConstructor] + public DefaultBraceSmartIndenterFactoryFactory(ForegroundDispatcher foregroundDispatcher, IEditorOperationsFactoryService editorOperationsFactory) + { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + if (editorOperationsFactory == null) + { + throw new ArgumentNullException(nameof(editorOperationsFactory)); + } + + _foregroundDispatcher = foregroundDispatcher; + _editorOperationsFactory = editorOperationsFactory; + } + + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + return new DefaultBraceSmartIndenterFactory(_foregroundDispatcher, _editorOperationsFactory); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultEditorSettingsManager.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultEditorSettingsManager.cs index 389aff0b77..952bc3be91 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultEditorSettingsManager.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultEditorSettingsManager.cs @@ -12,26 +12,55 @@ namespace Microsoft.VisualStudio.Editor.Razor [Export(typeof(EditorSettingsManager))] internal class DefaultEditorSettingsManager : EditorSettingsManager { - private readonly EditorSettingsManagerInternal _editorSettingsManager; + public override event EventHandler Changed; + + private readonly object SettingsAccessorLock = new object(); + private readonly ForegroundDispatcher _foregroundDispatcher; + private EditorSettings _settings; [ImportingConstructor] - public DefaultEditorSettingsManager(VisualStudioWorkspaceAccessor workspaceAccessor) + public DefaultEditorSettingsManager(ForegroundDispatcher foregroundDispatcher) { - var razorLanguageServices = workspaceAccessor.Workspace.Services.GetLanguageServices(RazorLanguage.Name); - _editorSettingsManager = razorLanguageServices.GetRequiredService(); + _foregroundDispatcher = foregroundDispatcher; + _settings = EditorSettings.Default; } - public override event EventHandler Changed + public override EditorSettings Current { - add => _editorSettingsManager.Changed += value; - remove => _editorSettingsManager.Changed -= value; + get + { + lock (SettingsAccessorLock) + { + return _settings; + } + } } - public override EditorSettings Current => _editorSettingsManager.Current; - - public override void Update(EditorSettings updateSettings) + public override void Update(EditorSettings updatedSettings) { - _editorSettingsManager.Update(updateSettings); + if (updatedSettings == null) + { + throw new ArgumentNullException(nameof(updatedSettings)); + } + + _foregroundDispatcher.AssertForegroundThread(); + + lock (SettingsAccessorLock) + { + if (!_settings.Equals(updatedSettings)) + { + _settings = updatedSettings; + OnChanged(); + } + } + } + + private void OnChanged() + { + _foregroundDispatcher.AssertForegroundThread(); + + var args = new EditorSettingsChangedEventArgs(Current); + Changed?.Invoke(this, args); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs similarity index 76% rename from src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs index ab5518bb46..f97abf0a3b 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryService.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryService.cs @@ -12,7 +12,7 @@ using MvcLatest = Microsoft.AspNetCore.Mvc.Razor.Extensions; namespace Microsoft.VisualStudio.Editor.Razor { - internal class DefaultTemplateEngineFactoryService : RazorTemplateEngineFactoryService + internal class DefaultProjectEngineFactoryService : RazorProjectEngineFactoryService { private readonly static MvcExtensibilityConfiguration DefaultConfiguration = new MvcExtensibilityConfiguration( RazorLanguageVersion.Version_2_0, @@ -22,7 +22,7 @@ namespace Microsoft.VisualStudio.Editor.Razor private readonly ProjectSnapshotManager _projectManager; - public DefaultTemplateEngineFactoryService(ProjectSnapshotManager projectManager) + public DefaultProjectEngineFactoryService(ProjectSnapshotManager projectManager) { if (projectManager == null) { @@ -32,7 +32,7 @@ namespace Microsoft.VisualStudio.Editor.Razor _projectManager = projectManager; } - public override RazorTemplateEngine Create(string projectPath, Action configure) + public override RazorProjectEngine Create(string projectPath, Action configure) { if (projectPath == null) { @@ -43,12 +43,14 @@ namespace Microsoft.VisualStudio.Editor.Razor var project = FindProject(projectPath); var configuration = (project?.Configuration as MvcExtensibilityConfiguration) ?? DefaultConfiguration; var razorLanguageVersion = configuration.LanguageVersion; - var razorConfiguration = new RazorConfiguration(razorLanguageVersion, "unnamed", Array.Empty(), designTime: true); - RazorEngine engine; + var razorConfiguration = new RazorConfiguration(razorLanguageVersion, "unnamed", Array.Empty()); + var fileSystem = RazorProjectFileSystem.Create(projectPath); + + RazorProjectEngine projectEngine; if (razorLanguageVersion.Major == 1) { - engine = RazorEngine.CreateCore(razorConfiguration, b => + projectEngine = RazorProjectEngine.Create(razorConfiguration, fileSystem, b => { configure?.Invoke(b); @@ -59,24 +61,18 @@ namespace Microsoft.VisualStudio.Editor.Razor Mvc1_X.RazorExtensions.RegisterViewComponentTagHelpers(b); } }); - - var templateEngine = new Mvc1_X.MvcRazorTemplateEngine(engine, RazorProject.Create(projectPath)); - templateEngine.Options.ImportsFileName = "_ViewImports.cshtml"; - return templateEngine; } else { - engine = RazorEngine.CreateCore(razorConfiguration, b => + projectEngine = RazorProjectEngine.Create(razorConfiguration, fileSystem, b => { configure?.Invoke(b); MvcLatest.RazorExtensions.Register(b); }); - - var templateEngine = new MvcLatest.MvcRazorTemplateEngine(engine, RazorProject.Create(projectPath)); - templateEngine.Options.ImportsFileName = "_ViewImports.cshtml"; - return templateEngine; } + + return projectEngine; } private ProjectSnapshot FindProject(string directory) @@ -104,4 +100,4 @@ namespace Microsoft.VisualStudio.Editor.Razor return path.Replace('\\', '/').TrimEnd('/'); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs similarity index 60% rename from src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs index f95df76c08..babed97a5c 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTemplateEngineFactoryServiceFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectEngineFactoryServiceFactory.cs @@ -8,12 +8,12 @@ using Microsoft.CodeAnalysis.Razor.ProjectSystem; namespace Microsoft.VisualStudio.Editor.Razor { - [ExportLanguageServiceFactory(typeof(RazorTemplateEngineFactoryService), RazorLanguage.Name, ServiceLayer.Default)] - internal class DefaultTemplateEngineFactoryServiceFactory : ILanguageServiceFactory + [ExportLanguageServiceFactory(typeof(RazorProjectEngineFactoryService), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultProjectEngineFactoryServiceFactory : ILanguageServiceFactory { public ILanguageService CreateLanguageService(HostLanguageServices languageServices) { - return new DefaultTemplateEngineFactoryService(languageServices.GetRequiredService()); + return new DefaultProjectEngineFactoryService(languageServices.GetRequiredService()); } } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperCompletionService.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperCompletionService.cs index 0bb688e1b3..f365c47698 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperCompletionService.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperCompletionService.cs @@ -7,7 +7,6 @@ using System.ComponentModel.Composition; using System.Diagnostics; using System.Linq; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis.Razor; namespace Microsoft.VisualStudio.Editor.Razor { @@ -15,34 +14,31 @@ namespace Microsoft.VisualStudio.Editor.Razor [Export(typeof(TagHelperCompletionService))] internal class DefaultTagHelperCompletionService : TagHelperCompletionService { - private readonly TagHelperFactsServiceInternal _tagHelperFactsService; + private readonly TagHelperFactsService _tagHelperFactsService; private static readonly HashSet _emptyHashSet = new HashSet(); [ImportingConstructor] - public DefaultTagHelperCompletionService(VisualStudioWorkspaceAccessor workspaceAccessor) + public DefaultTagHelperCompletionService(TagHelperFactsService tagHelperFactsService) { - var razorLanguageServices = workspaceAccessor.Workspace.Services.GetLanguageServices(RazorLanguage.Name); - _tagHelperFactsService = razorLanguageServices.GetRequiredService(); - } + if (tagHelperFactsService == null) + { + throw new ArgumentNullException(nameof(tagHelperFactsService)); + } - // Internal for testing - internal DefaultTagHelperCompletionService(TagHelperFactsServiceInternal tagHelperFactsService) - { _tagHelperFactsService = tagHelperFactsService; } - /* - * This API attempts to understand a users context as they're typing in a Razor file to provide TagHelper based attribute IntelliSense. - * - * Scenarios for TagHelper attribute IntelliSense follows: - * 1. TagHelperDescriptor's have matching required attribute names - * -> Provide IntelliSense for the required attributes of those descriptors to lead users towards a TagHelperified element. - * 2. TagHelperDescriptor entirely applies to current element. Tag name, attributes, everything is fulfilled. - * -> Provide IntelliSense for the bound attributes for the applied descriptors. - * - * Within each of the above scenarios if an attribute completion has a corresponding bound attribute we associate it with the corresponding - * BoundAttributeDescriptor. By doing this a user can see what C# type a TagHelper expects for the attribute. - */ + // This API attempts to understand a users context as they're typing in a Razor file to provide TagHelper based attribute IntelliSense. + // + // Scenarios for TagHelper attribute IntelliSense follows: + // 1. TagHelperDescriptor's have matching required attribute names + // -> Provide IntelliSense for the required attributes of those descriptors to lead users towards a TagHelperified element. + // 2. TagHelperDescriptor entirely applies to current element. Tag name, attributes, everything is fulfilled. + // -> Provide IntelliSense for the bound attributes for the applied descriptors. + // + // Within each of the above scenarios if an attribute completion has a corresponding bound attribute we associate it with the corresponding + // BoundAttributeDescriptor. By doing this a user can see what C# type a TagHelper expects for the attribute. + // public override AttributeCompletionResult GetAttributeCompletions(AttributeCompletionContext completionContext) { if (completionContext == null) @@ -212,7 +208,7 @@ namespace Microsoft.VisualStudio.Editor.Razor { foreach (var completionTagName in elementCompletions.Keys) { - if (elementCompletions[completionTagName].Count > 0 || + if (elementCompletions[completionTagName].Count > 0 || !string.IsNullOrEmpty(prefix) && completionTagName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) { // The current completion either has other TagHelper's associated with it or is prefixed with a non-empty @@ -293,4 +289,4 @@ namespace Microsoft.VisualStudio.Editor.Razor } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperFactsService.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperFactsService.cs index 2769d59657..8424353951 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperFactsService.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperFactsService.cs @@ -4,8 +4,8 @@ using System; using System.Collections.Generic; using System.ComponentModel.Composition; +using System.Linq; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis.Razor; namespace Microsoft.VisualStudio.Editor.Razor { @@ -13,15 +13,6 @@ namespace Microsoft.VisualStudio.Editor.Razor [Export(typeof(TagHelperFactsService))] internal class DefaultTagHelperFactsService : TagHelperFactsService { - private readonly TagHelperFactsServiceInternal _tagHelperFactsService; - - [ImportingConstructor] - public DefaultTagHelperFactsService(VisualStudioWorkspaceAccessor workspaceAccessor) - { - var razorLanguageServices = workspaceAccessor.Workspace.Services.GetLanguageServices(RazorLanguage.Name); - _tagHelperFactsService = razorLanguageServices.GetRequiredService(); - } - public override TagHelperBinding GetTagHelperBinding( TagHelperDocumentContext documentContext, string tagName, @@ -29,7 +20,32 @@ namespace Microsoft.VisualStudio.Editor.Razor string parentTag, bool parentIsTagHelper) { - return _tagHelperFactsService.GetTagHelperBinding(documentContext, tagName, attributes, parentTag, parentIsTagHelper); + if (documentContext == null) + { + throw new ArgumentNullException(nameof(documentContext)); + } + + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + if (attributes == null) + { + throw new ArgumentNullException(nameof(attributes)); + } + + var descriptors = documentContext.TagHelpers; + if (descriptors == null || descriptors.Count == 0) + { + return null; + } + + var prefix = documentContext.Prefix; + var tagHelperBinder = new TagHelperBinder(prefix, descriptors); + var binding = tagHelperBinder.GetBinding(tagName, attributes.ToList(), parentTag, parentIsTagHelper); + + return binding; } public override IEnumerable GetBoundTagHelperAttributes( @@ -37,7 +53,37 @@ namespace Microsoft.VisualStudio.Editor.Razor string attributeName, TagHelperBinding binding) { - return _tagHelperFactsService.GetBoundTagHelperAttributes(documentContext, attributeName, binding); + if (documentContext == null) + { + throw new ArgumentNullException(nameof(documentContext)); + } + + if (attributeName == null) + { + throw new ArgumentNullException(nameof(attributeName)); + } + + if (binding == null) + { + throw new ArgumentNullException(nameof(binding)); + } + + var matchingBoundAttributes = new List(); + foreach (var descriptor in binding.Descriptors) + { + foreach (var boundAttributeDescriptor in descriptor.BoundAttributes) + { + if (TagHelperMatchingConventions.CanSatisfyBoundAttribute(attributeName, boundAttributeDescriptor)) + { + matchingBoundAttributes.Add(boundAttributeDescriptor); + + // Only one bound attribute can match an attribute + break; + } + } + } + + return matchingBoundAttributes; } public override IReadOnlyList GetTagHelpersGivenTag( @@ -45,12 +91,76 @@ namespace Microsoft.VisualStudio.Editor.Razor string tagName, string parentTag) { - return _tagHelperFactsService.GetTagHelpersGivenTag(documentContext, tagName, parentTag); + if (documentContext == null) + { + throw new ArgumentNullException(nameof(documentContext)); + } + + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + var matchingDescriptors = new List(); + var descriptors = documentContext?.TagHelpers; + if (descriptors?.Count == 0) + { + return matchingDescriptors; + } + + var prefix = documentContext.Prefix ?? string.Empty; + if (!tagName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + { + // Can't possibly match TagHelpers, it doesn't start with the TagHelperPrefix. + return matchingDescriptors; + } + + var tagNameWithoutPrefix = tagName.Substring(prefix.Length); + for (var i = 0; i < descriptors.Count; i++) + { + var descriptor = descriptors[i]; + foreach (var rule in descriptor.TagMatchingRules) + { + if (TagHelperMatchingConventions.SatisfiesTagName(tagNameWithoutPrefix, rule) && + TagHelperMatchingConventions.SatisfiesParentTag(parentTag, rule)) + { + matchingDescriptors.Add(descriptor); + break; + } + } + } + + return matchingDescriptors; } public override IReadOnlyList GetTagHelpersGivenParent(TagHelperDocumentContext documentContext, string parentTag) { - return _tagHelperFactsService.GetTagHelpersGivenParent(documentContext, parentTag); + if (documentContext == null) + { + throw new ArgumentNullException(nameof(documentContext)); + } + + var matchingDescriptors = new List(); + var descriptors = documentContext?.TagHelpers; + if (descriptors?.Count == 0) + { + return matchingDescriptors; + } + + for (var i = 0; i < descriptors.Count; i++) + { + var descriptor = descriptors[i]; + foreach (var rule in descriptor.TagMatchingRules) + { + if (TagHelperMatchingConventions.SatisfiesParentTag(parentTag, rule)) + { + matchingDescriptors.Add(descriptor); + break; + } + } + } + + return matchingDescriptors; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolver.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolver.cs new file mode 100644 index 0000000000..7547bde441 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolver.cs @@ -0,0 +1,60 @@ +// 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; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Razor.Extensions; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class DefaultTagHelperResolver : TagHelperResolver + { + // Hack for testability. The view component visitor will normally just no op if we're not referencing + // an appropriate version of MVC. + internal bool ForceEnableViewComponentDiscovery { get; set; } + + public override async Task GetTagHelpersAsync(Project project, CancellationToken cancellationToken) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + var result = GetTagHelpers(compilation); + return result; + } + + // Internal for testing + internal TagHelperResolutionResult GetTagHelpers(Compilation compilation) + { + var descriptors = new List(); + + var providers = new ITagHelperDescriptorProvider[] + { + new DefaultTagHelperDescriptorProvider() { DesignTime = true, }, + new ViewComponentTagHelperDescriptorProvider() { ForceEnabled = ForceEnableViewComponentDiscovery }, + }; + + var results = new List(); + var context = TagHelperDescriptorProviderContext.Create(results); + context.SetCompilation(compilation); + + for (var i = 0; i < providers.Length; i++) + { + var provider = providers[i]; + provider.Execute(context); + } + + var diagnostics = new List(); + var resolutionResult = new TagHelperResolutionResult(results, diagnostics); + + return resolutionResult; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolverFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolverFactory.cs similarity index 66% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolverFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolverFactory.cs index f59d049bfa..50e2e96179 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolverFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultTagHelperResolverFactory.cs @@ -1,22 +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.ComponentModel.Composition; +using System.Composition; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Razor; -namespace Microsoft.VisualStudio.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor { + [Shared] [ExportLanguageServiceFactory(typeof(TagHelperResolver), RazorLanguage.Name, ServiceLayer.Default)] internal class DefaultTagHelperResolverFactory : ILanguageServiceFactory { - [Import] - public VisualStudioWorkspace Workspace { get; set; } - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) { - return new DefaultTagHelperResolver(Workspace.Services.GetRequiredService(), Workspace); + return new DefaultTagHelperResolver(); } } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTracker.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTracker.cs similarity index 94% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTracker.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTracker.cs index 1cc76169aa..eb771205d1 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTracker.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTracker.cs @@ -9,7 +9,6 @@ using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Editor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.VisualStudio.Editor.Razor; -using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; @@ -19,7 +18,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor { private readonly string _filePath; private readonly ProjectSnapshotManager _projectManager; - private readonly EditorSettingsManagerInternal _editorSettingsManager; + private readonly EditorSettingsManager _editorSettingsManager; private readonly TextBufferProjectService _projectService; private readonly ITextBuffer _textBuffer; private readonly List _textViews; @@ -34,13 +33,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor string filePath, ProjectSnapshotManager projectManager, TextBufferProjectService projectService, - EditorSettingsManagerInternal editorSettingsManager, + EditorSettingsManager editorSettingsManager, Workspace workspace, ITextBuffer textBuffer) { if (string.IsNullOrEmpty(filePath)) { - throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); + throw new ArgumentException(Microsoft.VisualStudio.Editor.Razor.Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); } if (projectManager == null) @@ -154,7 +153,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor // unexpected /impossible states. // // We also want to successfully shut down if the buffer is something other than .cshtml. - IVsHierarchy hierarchy = null; + object hierarchy = null; string projectPath = null; var isSupportedProject = false; @@ -162,7 +161,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor // We expect the document to have a hierarchy even if it's not a real 'project'. // However the hierarchy can be null when the document is in the process of closing. - (hierarchy = _projectService.GetHierarchy(_textBuffer)) != null) + (hierarchy = _projectService.GetHostProject(_textBuffer)) != null) { projectPath = _projectService.GetProjectPath(hierarchy); isSupportedProject = _projectService.IsSupportedProject(hierarchy); @@ -226,4 +225,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor OnContextChanged(_project, ContextChangeKind.EditorSettingsChanged); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTrackerFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactory.cs similarity index 66% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTrackerFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactory.cs index 53c2c074a2..b6e847192b 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioDocumentTrackerFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactory.cs @@ -2,19 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.ComponentModel.Composition; using System.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Editor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; -using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.LanguageServices.Razor.Editor; using Microsoft.VisualStudio.Text; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { - [System.Composition.Shared] - [Export(typeof(VisualStudioDocumentTrackerFactory))] internal class DefaultVisualStudioDocumentTrackerFactory : VisualStudioDocumentTrackerFactory { private readonly TextBufferProjectService _projectService; @@ -22,14 +19,31 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor private readonly Workspace _workspace; private readonly ForegroundDispatcher _foregroundDispatcher; private readonly ProjectSnapshotManager _projectManager; - private readonly EditorSettingsManagerInternal _editorSettingsManager; + private readonly EditorSettingsManager _editorSettingsManager; - [ImportingConstructor] public DefaultVisualStudioDocumentTrackerFactory( + ForegroundDispatcher foregroundDispatcher, + ProjectSnapshotManager projectManager, + EditorSettingsManager editorSettingsManager, TextBufferProjectService projectService, ITextDocumentFactoryService textDocumentFactory, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) + Workspace workspace) { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + if (projectManager == null) + { + throw new ArgumentNullException(nameof(projectManager)); + } + + if (editorSettingsManager == null) + { + throw new ArgumentNullException(nameof(editorSettingsManager)); + } + if (projectService == null) { throw new ArgumentNullException(nameof(projectService)); @@ -45,14 +59,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor throw new ArgumentNullException(nameof(workspace)); } + _foregroundDispatcher = foregroundDispatcher; + _projectManager = projectManager; + _editorSettingsManager = editorSettingsManager; _projectService = projectService; _textDocumentFactory = textDocumentFactory; _workspace = workspace; - - _foregroundDispatcher = workspace.Services.GetRequiredService(); - var razorLanguageServices = workspace.Services.GetLanguageServices(RazorLanguage.Name); - _projectManager = razorLanguageServices.GetRequiredService(); - _editorSettingsManager = razorLanguageServices.GetRequiredService(); } public override VisualStudioDocumentTracker Create(ITextBuffer textBuffer) @@ -69,9 +81,16 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } var filePath = textDocument.FilePath; + var project = _projectService.GetHostProject(textBuffer); + if (project == null) + { + Debug.Fail("Text buffer should belong to a project."); + return null; + } + var tracker = new DefaultVisualStudioDocumentTracker(filePath, _projectManager, _projectService, _editorSettingsManager, _workspace, textBuffer); return tracker; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactoryFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactoryFactory.cs new file mode 100644 index 0000000000..92adb1db84 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioDocumentTrackerFactoryFactory.cs @@ -0,0 +1,75 @@ +// 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; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.CodeAnalysis.Razor.Editor; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.VisualStudio.Text; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(VisualStudioDocumentTrackerFactory), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultVisualStudioDocumentTrackerFactoryFactory : ILanguageServiceFactory + { + private readonly ForegroundDispatcher _foregroundDispatcher; + private readonly TextBufferProjectService _projectService; + private readonly EditorSettingsManager _editorSettingsManager; + private readonly ITextDocumentFactoryService _textDocumentFactory; + + [ImportingConstructor] + public DefaultVisualStudioDocumentTrackerFactoryFactory( + ForegroundDispatcher foregroundDispatcher, + TextBufferProjectService projectService, + EditorSettingsManager editorSettingsManager, + ITextDocumentFactoryService textDocumentFactory) + { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + if (projectService == null) + { + throw new ArgumentNullException(nameof(projectService)); + } + + if (editorSettingsManager == null) + { + throw new ArgumentNullException(nameof(editorSettingsManager)); + } + + if (textDocumentFactory == null) + { + throw new ArgumentNullException(nameof(textDocumentFactory)); + } + + _foregroundDispatcher = foregroundDispatcher; + _projectService = projectService; + _editorSettingsManager = editorSettingsManager; + _textDocumentFactory = textDocumentFactory; + } + + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + var projectManager = languageServices.GetRequiredService(); + + return new DefaultVisualStudioDocumentTrackerFactory( + _foregroundDispatcher, + projectManager, + _editorSettingsManager, + _projectService, + _textDocumentFactory, + languageServices.WorkspaceServices.Workspace); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs index 99a7163ba8..7ace362811 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParser.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -28,13 +29,14 @@ namespace Microsoft.VisualStudio.Editor.Razor internal ChangeReference _latestChangeReference; private readonly object IdleLock = new object(); - private readonly ICompletionBroker _completionBroker; + private readonly VisualStudioCompletionBroker _completionBroker; private readonly VisualStudioDocumentTracker _documentTracker; private readonly ForegroundDispatcher _dispatcher; - private readonly RazorTemplateEngineFactoryService _templateEngineFactory; + private readonly RazorProjectEngineFactoryService _projectEngineFactory; private readonly ErrorReporter _errorReporter; private RazorSyntaxTreePartialParser _partialParser; - private RazorTemplateEngine _templateEngine; + private RazorProjectEngine _projectEngine; + private DelegatingTemplateEngine _templateEngine; private RazorCodeDocument _codeDocument; private ITextSnapshot _snapshot; private bool _disposed; @@ -48,9 +50,9 @@ namespace Microsoft.VisualStudio.Editor.Razor public DefaultVisualStudioRazorParser( ForegroundDispatcher dispatcher, VisualStudioDocumentTracker documentTracker, - RazorTemplateEngineFactoryService templateEngineFactory, + RazorProjectEngineFactoryService projectEngineFactory, ErrorReporter errorReporter, - ICompletionBroker completionBroker) + VisualStudioCompletionBroker completionBroker) { if (dispatcher == null) { @@ -62,9 +64,9 @@ namespace Microsoft.VisualStudio.Editor.Razor throw new ArgumentNullException(nameof(documentTracker)); } - if (templateEngineFactory == null) + if (projectEngineFactory == null) { - throw new ArgumentNullException(nameof(templateEngineFactory)); + throw new ArgumentNullException(nameof(projectEngineFactory)); } if (errorReporter == null) @@ -78,7 +80,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } _dispatcher = dispatcher; - _templateEngineFactory = templateEngineFactory; + _projectEngineFactory = projectEngineFactory; _errorReporter = errorReporter; _completionBroker = completionBroker; _documentTracker = documentTracker; @@ -171,8 +173,18 @@ namespace Microsoft.VisualStudio.Editor.Razor _dispatcher.AssertForegroundThread(); var projectDirectory = Path.GetDirectoryName(_documentTracker.ProjectPath); - _templateEngine = _templateEngineFactory.Create(projectDirectory, ConfigureTemplateEngine); - _parser = new BackgroundParser(TemplateEngine, FilePath); + _projectEngine = _projectEngineFactory.Create(projectDirectory, ConfigureProjectEngine); + + // Make sure any tests use the real thing or a good mock. These tests can cause failures + // that are hard to understand when this throws. + Debug.Assert(_projectEngine != null); + Debug.Assert(_projectEngine.Engine != null); + Debug.Assert(_projectEngine.FileSystem != null); + + // This is still exposed and used by WTE in 15.7 + _templateEngine = new DelegatingTemplateEngine(_projectEngine); + + _parser = new BackgroundParser(_projectEngine, FilePath, projectDirectory); _parser.ResultsReady += OnResultsReady; _parser.Start(); @@ -384,7 +396,7 @@ namespace Microsoft.VisualStudio.Editor.Razor DocumentStructureChanged?.Invoke(this, args); } - private void ConfigureTemplateEngine(IRazorEngineBuilder builder) + private void ConfigureProjectEngine(RazorProjectEngineBuilder builder) { builder.Features.Add(new VisualStudioParserOptionsFeature(_documentTracker.EditorSettings)); builder.Features.Add(new VisualStudioTagHelperFeature(TextBuffer)); diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.cs new file mode 100644 index 0000000000..5318ede596 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactory.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.CodeAnalysis.Razor; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class DefaultVisualStudioRazorParserFactory : VisualStudioRazorParserFactory + { + private readonly ForegroundDispatcher _dispatcher; + private readonly RazorProjectEngineFactoryService _projectEngineFactoryService; + private readonly VisualStudioCompletionBroker _completionBroker; + private readonly ErrorReporter _errorReporter; + + public DefaultVisualStudioRazorParserFactory( + ForegroundDispatcher dispatcher, + ErrorReporter errorReporter, + VisualStudioCompletionBroker completionBroker, + RazorProjectEngineFactoryService projectEngineFactoryService) + { + if (dispatcher == null) + { + throw new ArgumentNullException(nameof(dispatcher)); + } + + if (errorReporter == null) + { + throw new ArgumentNullException(nameof(errorReporter)); + } + + if (completionBroker == null) + { + throw new ArgumentNullException(nameof(completionBroker)); + } + + if (projectEngineFactoryService == null) + { + throw new ArgumentNullException(nameof(projectEngineFactoryService)); + } + + _dispatcher = dispatcher; + _errorReporter = errorReporter; + _completionBroker = completionBroker; + _projectEngineFactoryService = projectEngineFactoryService; + } + + public override VisualStudioRazorParser Create(VisualStudioDocumentTracker documentTracker) + { + if (documentTracker == null) + { + throw new ArgumentNullException(nameof(documentTracker)); + } + + _dispatcher.AssertForegroundThread(); + + var parser = new DefaultVisualStudioRazorParser( + _dispatcher, + documentTracker, + _projectEngineFactoryService, + _errorReporter, + _completionBroker); + return parser; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs new file mode 100644 index 0000000000..38cfe5f189 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultVisualStudioRazorParserFactoryFactory.cs @@ -0,0 +1,47 @@ +// 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; +using Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(VisualStudioRazorParserFactory), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultVisualStudioRazorParserFactoryFactory : ILanguageServiceFactory + { + private readonly ForegroundDispatcher _foregroundDispatcher; + + [ImportingConstructor] + public DefaultVisualStudioRazorParserFactoryFactory(ForegroundDispatcher foregroundDispatcher) + { + if (foregroundDispatcher == null) + { + throw new ArgumentNullException(nameof(foregroundDispatcher)); + } + + _foregroundDispatcher = foregroundDispatcher; + } + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + var workspaceServices = languageServices.WorkspaceServices; + var errorReporter = workspaceServices.GetRequiredService(); + var completionBroker = languageServices.GetRequiredService(); + var projectEngineFactoryService = languageServices.GetRequiredService(); + + return new DefaultVisualStudioRazorParserFactory( + _foregroundDispatcher, + errorReporter, + completionBroker, + projectEngineFactoryService); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DelegatingTemplateEngine.cs b/src/Microsoft.VisualStudio.Editor.Razor/DelegatingTemplateEngine.cs new file mode 100644 index 0000000000..912afc2502 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/DelegatingTemplateEngine.cs @@ -0,0 +1,40 @@ +// 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; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class DelegatingTemplateEngine : RazorTemplateEngine + { + private readonly RazorProjectEngine _inner; + + public DelegatingTemplateEngine(RazorProjectEngine inner) + : base(inner.Engine, inner.FileSystem) + { + if (inner == null) + { + throw new ArgumentNullException(nameof(inner)); + } + + _inner = inner; + } + + public override IEnumerable GetImportItems(RazorProjectItem projectItem) + { + var feature = _inner.ProjectFeatures.OfType().FirstOrDefault(); + if (feature == null) + { + return Array.Empty(); + } + + var imports = feature.GetImports(projectItem); + var physicalImports = imports.Where(import => import.FilePath != null); + + return physicalImports; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/TextBufferProjectService.cs b/src/Microsoft.VisualStudio.Editor.Razor/TextBufferProjectService.cs new file mode 100644 index 0000000000..b6add8abd2 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/TextBufferProjectService.cs @@ -0,0 +1,18 @@ +// 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 Microsoft.VisualStudio.Text; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal abstract class TextBufferProjectService + { + public abstract object GetHostProject(ITextBuffer textBuffer); + + public abstract bool IsSupportedProject(object project); + + public abstract string GetProjectPath(object project); + + public abstract string GetProjectName(object project); + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs b/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs new file mode 100644 index 0000000000..7d120d5640 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/TextSnapshotProjectItem.cs @@ -0,0 +1,65 @@ +// 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.Text; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.VisualStudio.Text; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal class TextSnapshotProjectItem : RazorProjectItem + { + private readonly ITextSnapshot _snapshot; + + public TextSnapshotProjectItem(ITextSnapshot snapshot, string projectDirectory, string relativeFilePath, string filePath) + { + if (snapshot == null) + { + throw new ArgumentNullException(nameof(snapshot)); + } + + if (string.IsNullOrEmpty(projectDirectory)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(projectDirectory)); + } + + if (string.IsNullOrEmpty(relativeFilePath)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(relativeFilePath)); + } + + if (string.IsNullOrEmpty(filePath)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); + } + + _snapshot = snapshot; + BasePath = projectDirectory; + FilePath = relativeFilePath; + PhysicalPath = filePath; + } + + public override string BasePath { get; } + + public override string FilePath { get; } + + public override string PhysicalPath { get; } + + public override bool Exists => true; + + public override Stream Read() + { + var charArray = _snapshot.ToCharArray(0, _snapshot.Length); + + // We can assume UTF8 because the call path that reads from RazorProjectItem => SourceDocument + // can't determine the encoding and always assumes Encoding.UTF8. This is something that we might + // want to revisit in the future. + var bytes = Encoding.UTF8.GetBytes(charArray); + var memoryStream = new MemoryStream(bytes); + return memoryStream; + } + } + +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs new file mode 100644 index 0000000000..f9946bb528 --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs @@ -0,0 +1,13 @@ +// 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 Microsoft.CodeAnalysis.Host; +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.Editor.Razor +{ + internal abstract class VisualStudioCompletionBroker : ILanguageService + { + public abstract bool IsCompletionActive(ITextView textView); + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioDocumentTrackerFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioDocumentTrackerFactory.cs index 1576ac9074..39f89aafd1 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioDocumentTrackerFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioDocumentTrackerFactory.cs @@ -1,12 +1,13 @@ // 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 Microsoft.CodeAnalysis.Host; using Microsoft.VisualStudio.Text; namespace Microsoft.VisualStudio.Editor.Razor { - internal abstract class VisualStudioDocumentTrackerFactory + internal abstract class VisualStudioDocumentTrackerFactory : ILanguageService { public abstract VisualStudioDocumentTracker Create(ITextBuffer textBuffer); } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParserFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParserFactory.cs index 580b33cc62..7d30a46027 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParserFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioRazorParserFactory.cs @@ -1,9 +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 Microsoft.CodeAnalysis.Host; + namespace Microsoft.VisualStudio.Editor.Razor { - internal abstract class VisualStudioRazorParserFactory + internal abstract class VisualStudioRazorParserFactory : ILanguageService { public abstract VisualStudioRazorParser Create(VisualStudioDocumentTracker documentTracker); } diff --git a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs index 2e84e16ec8..a3394804a6 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs @@ -2,11 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.CodeAnalysis; +using Microsoft.VisualStudio.Text; namespace Microsoft.VisualStudio.Editor.Razor { internal abstract class VisualStudioWorkspaceAccessor { - public abstract Workspace Workspace { get; } + public abstract bool TryGetWorkspace(ITextBuffer textBuffer, out Workspace workspace); } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs deleted file mode 100644 index 31713fb3b2..0000000000 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs +++ /dev/null @@ -1,123 +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.Composition; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Razor.Extensions; -using Microsoft.AspNetCore.Razor.Language; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Microsoft.VisualStudio.LanguageServices.Razor -{ - internal class DefaultTagHelperResolver : TagHelperResolver - { - private readonly ErrorReporter _errorReporter; - private readonly Workspace _workspace; - - public DefaultTagHelperResolver(ErrorReporter errorReporter, Workspace workspace) - { - _errorReporter = errorReporter; - _workspace = workspace; - } - - public async Task GetTagHelpersAsync(Project project) - { - if (project == null) - { - throw new ArgumentNullException(nameof(project)); - } - - try - { - TagHelperResolutionResult result; - - // We're being overly defensive here because the OOP host can return null for the client/session/operation - // when it's disconnected (user stops the process). - // - // This will change in the future to an easier to consume API but for VS RTM this is what we have. - var client = await RazorLanguageServiceClientFactory.CreateAsync(_workspace, CancellationToken.None); - if (client != null) - { - using (var session = await client.CreateSessionAsync(project.Solution)) - { - if (session != null) - { - var jsonObject = await session.InvokeAsync( - "GetTagHelpersAsync", - new object[] { project.Id.Id, "Foo", }, - CancellationToken.None).ConfigureAwait(false); - - result = GetTagHelperResolutionResult(jsonObject); - - if (result != null) - { - return result; - } - } - } - } - - // The OOP host is turned off, so let's do this in process. - var compilation = await project.GetCompilationAsync(CancellationToken.None).ConfigureAwait(false); - result = GetTagHelpers(compilation); - return result; - } - catch (Exception exception) - { - _errorReporter.ReportError(exception, project); - - throw new InvalidOperationException( - Resources.FormatUnexpectedException( - typeof(DefaultTagHelperResolver).FullName, - nameof(GetTagHelpersAsync)), - exception); - } - } - - public override TagHelperResolutionResult GetTagHelpers(Compilation compilation) - { - var descriptors = new List(); - - var providers = new ITagHelperDescriptorProvider[] - { - new DefaultTagHelperDescriptorProvider() { DesignTime = true, }, - new ViewComponentTagHelperDescriptorProvider(), - }; - - var results = new List(); - var context = TagHelperDescriptorProviderContext.Create(results); - context.SetCompilation(compilation); - - for (var i = 0; i < providers.Length; i++) - { - var provider = providers[i]; - provider.Execute(context); - } - - var diagnostics = new List(); - var resolutionResult = new TagHelperResolutionResult(results, diagnostics); - - return resolutionResult; - } - - private TagHelperResolutionResult GetTagHelperResolutionResult(JObject jsonObject) - { - var serializer = new JsonSerializer(); - serializer.Converters.Add(TagHelperDescriptorJsonConverter.Instance); - serializer.Converters.Add(RazorDiagnosticJsonConverter.Instance); - - using (var reader = jsonObject.CreateReader()) - { - return serializer.Deserialize(reader); - } - } - } -} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs index 4749c44f5b..d3ef76b676 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs @@ -1,9 +1,14 @@ // 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.ComponentModel.Composition; +using System.Linq; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.Projection; namespace Microsoft.VisualStudio.LanguageServices.Razor { @@ -11,12 +16,103 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor [Export(typeof(VisualStudioWorkspaceAccessor))] internal class DefaultVisualStudioWorkspaceAccessor : VisualStudioWorkspaceAccessor { + private readonly IBufferGraphFactoryService _bufferGraphService; + private readonly TextBufferProjectService _projectService; + private readonly Workspace _defaultWorkspace; + [ImportingConstructor] - public DefaultVisualStudioWorkspaceAccessor([Import(typeof(VisualStudioWorkspace))] Workspace workspace) + public DefaultVisualStudioWorkspaceAccessor( + IBufferGraphFactoryService bufferGraphService, + TextBufferProjectService projectService, + [Import(typeof(VisualStudioWorkspace))] Workspace defaultWorkspace) { - Workspace = workspace; + if (bufferGraphService == null) + { + throw new ArgumentNullException(nameof(bufferGraphService)); + } + + if (projectService == null) + { + throw new ArgumentNullException(nameof(projectService)); + } + + if (defaultWorkspace == null) + { + throw new ArgumentNullException(nameof(defaultWorkspace)); + } + + _bufferGraphService = bufferGraphService; + _projectService = projectService; + _defaultWorkspace = defaultWorkspace; } - public override Workspace Workspace { get; } + public override bool TryGetWorkspace(ITextBuffer textBuffer, out Workspace workspace) + { + if (textBuffer == null) + { + throw new ArgumentNullException(nameof(textBuffer)); + } + + // We do a best effort approach in this method to get the workspace that belongs to the TextBuffer. + // The approaches we take to find the workspace are: + // + // 1. Look for a C# projection buffer associated with the Razor buffer. If we can find one we let + // Roslyn take control of finding the Workspace (projectionBuffer.GetWorkspace()). If not, + // fall back to determining if we can use the default workspace. + // 2. Look to see if this ITextBuffer is associated with a host project. If we find that our Razor + // buffer has a host project, we make the assumption that we should use the default VisualStudioWorkspace. + + if (TryGetWorkspaceFromProjectionBuffer(textBuffer, out workspace)) + { + return true; + } + + if (TryGetWorkspaceFromHostProject(textBuffer, out workspace)) + { + return true; + } + + workspace = null; + return false; + } + + // Internal virtual for testing + internal virtual bool TryGetWorkspaceFromProjectionBuffer(ITextBuffer textBuffer, out Workspace workspace) + { + var graph = _bufferGraphService.CreateBufferGraph(textBuffer); + var projectedCSharpBuffer = graph.GetTextBuffers(buffer => buffer.ContentType.IsOfType("CSharp")).FirstOrDefault(); + + if (projectedCSharpBuffer == null) + { + workspace = null; + return false; + } + + workspace = projectedCSharpBuffer.GetWorkspace(); + if (workspace == null) + { + // Couldn't resolve a workspace for the projected csharp buffer. + return false; + } + + return true; + } + + // Internal virtual for testing + internal virtual bool TryGetWorkspaceFromHostProject(ITextBuffer textBuffer, out Workspace workspace) + { + var project = _projectService.GetHostProject(textBuffer); + + if (project == null) + { + // Could not locate a project for the given text buffer. + workspace = null; + return false; + } + + // We have a host project, assume default workspace. + workspace = _defaultWorkspace; + return true; + } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultRazorEditorFactoryService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultRazorEditorFactoryService.cs index 226f0af2da..5b868ee3ad 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultRazorEditorFactoryService.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultRazorEditorFactoryService.cs @@ -4,45 +4,27 @@ using System; using System.ComponentModel.Composition; using System.Diagnostics; -using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.CodeAnalysis.Razor; using Microsoft.VisualStudio.Text; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { [System.Composition.Shared] [Export(typeof(RazorEditorFactoryService))] internal class DefaultRazorEditorFactoryService : RazorEditorFactoryService { private static readonly object RazorTextBufferInitializationKey = new object(); - - private readonly VisualStudioDocumentTrackerFactory _documentTrackerFactory; - private readonly VisualStudioRazorParserFactory _parserFactory; - private readonly BraceSmartIndenterFactory _braceSmartIndenterFactory; + private readonly VisualStudioWorkspaceAccessor _workspaceAccessor; [ImportingConstructor] - public DefaultRazorEditorFactoryService( - VisualStudioDocumentTrackerFactory documentTrackerFactory, - VisualStudioRazorParserFactory parserFactory, - BraceSmartIndenterFactory braceSmartIndenterFactory) + public DefaultRazorEditorFactoryService(VisualStudioWorkspaceAccessor workspaceAccessor) { - if (documentTrackerFactory == null) + if (workspaceAccessor == null) { - throw new ArgumentNullException(nameof(documentTrackerFactory)); + throw new ArgumentNullException(nameof(workspaceAccessor)); } - if (parserFactory == null) - { - throw new ArgumentNullException(nameof(parserFactory)); - } - - if (braceSmartIndenterFactory == null) - { - throw new ArgumentNullException(nameof(braceSmartIndenterFactory)); - } - - _documentTrackerFactory = documentTrackerFactory; - _parserFactory = parserFactory; - _braceSmartIndenterFactory = braceSmartIndenterFactory; + _workspaceAccessor = workspaceAccessor; } public override bool TryGetDocumentTracker(ITextBuffer textBuffer, out VisualStudioDocumentTracker documentTracker) @@ -58,8 +40,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return false; } - EnsureTextBufferInitialized(textBuffer); - + var textBufferInitialized = TryInitializeTextBuffer(textBuffer); + if (!textBufferInitialized) + { + documentTracker = null; + return false; + } + if (!textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out documentTracker)) { Debug.Fail("Document tracker should have been stored on the text buffer during initialization."); @@ -82,7 +69,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return false; } - EnsureTextBufferInitialized(textBuffer); + var textBufferInitialized = TryInitializeTextBuffer(textBuffer); + if (!textBufferInitialized) + { + parser = null; + return false; + } if (!textBuffer.Properties.TryGetProperty(typeof(VisualStudioRazorParser), out parser)) { @@ -106,7 +98,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return false; } - EnsureTextBufferInitialized(textBuffer); + var textBufferInitialized = TryInitializeTextBuffer(textBuffer); + if (!textBufferInitialized) + { + braceSmartIndenter = null; + return false; + } if (!textBuffer.Properties.TryGetProperty(typeof(BraceSmartIndenter), out braceSmartIndenter)) { @@ -118,24 +115,37 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } // Internal for testing - internal void EnsureTextBufferInitialized(ITextBuffer textBuffer) + internal bool TryInitializeTextBuffer(ITextBuffer textBuffer) { if (textBuffer.Properties.ContainsProperty(RazorTextBufferInitializationKey)) { // Buffer already initialized. - return; + return true; } - var tracker = _documentTrackerFactory.Create(textBuffer); + if (!_workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace)) + { + // Could not locate workspace for given text buffer. + return false; + } + + var razorLanguageServices = workspace.Services.GetLanguageServices(RazorLanguage.Name); + var documentTrackerFactory = razorLanguageServices.GetRequiredService(); + var parserFactory = razorLanguageServices.GetRequiredService(); + var braceSmartIndenterFactory = razorLanguageServices.GetRequiredService(); + + var tracker = documentTrackerFactory.Create(textBuffer); textBuffer.Properties[typeof(VisualStudioDocumentTracker)] = tracker; - var parser = _parserFactory.Create(tracker); + var parser = parserFactory.Create(tracker); textBuffer.Properties[typeof(VisualStudioRazorParser)] = parser; - var braceSmartIndenter = _braceSmartIndenterFactory.Create(tracker); + var braceSmartIndenter = braceSmartIndenterFactory.Create(tracker); textBuffer.Properties[typeof(BraceSmartIndenter)] = braceSmartIndenter; textBuffer.Properties.AddProperty(RazorTextBufferInitializationKey, RazorTextBufferInitializationKey); + + return true; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs index f81d6fa4d5..2b6e5a2aa6 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs @@ -3,7 +3,8 @@ using System; using System.ComponentModel.Composition; -using Microsoft.CodeAnalysis; +using System.Diagnostics; +using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Text; @@ -13,6 +14,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor /// /// Infrastructure methods to find project information from an . /// + [System.Composition.Shared] [Export(typeof(TextBufferProjectService))] internal class DefaultTextBufferProjectService : TextBufferProjectService { @@ -24,8 +26,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor [ImportingConstructor] public DefaultTextBufferProjectService( [Import(typeof(SVsServiceProvider))] IServiceProvider services, - ITextDocumentFactoryService documentFactory, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) + ITextDocumentFactoryService documentFactory) { if (services == null) { @@ -41,7 +42,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor _documentTable = new RunningDocumentTable(services); } - public override IVsHierarchy GetHierarchy(ITextBuffer textBuffer) + public override object GetHostProject(ITextBuffer textBuffer) { if (textBuffer == null) { @@ -63,24 +64,30 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return hierarchy; } - public override string GetProjectPath(IVsHierarchy hierarchy) + public override string GetProjectPath(object project) { - if (hierarchy == null) + if (project == null) { - throw new ArgumentNullException(nameof(hierarchy)); + throw new ArgumentNullException(nameof(project)); } + var hierarchy = project as IVsHierarchy; + Debug.Assert(hierarchy != null); + ErrorHandler.ThrowOnFailure(((IVsProject)hierarchy).GetMkDocument((uint)VSConstants.VSITEMID.Root, out var path), VSConstants.E_NOTIMPL); return path; } - public override bool IsSupportedProject(IVsHierarchy hierarchy) + public override bool IsSupportedProject(object project) { - if (hierarchy == null) + if (project == null) { - throw new ArgumentNullException(nameof(hierarchy)); + throw new ArgumentNullException(nameof(project)); } + var hierarchy = project as IVsHierarchy; + Debug.Assert(hierarchy != null); + try { return hierarchy.IsCapabilityMatch(DotNetCoreCapability); @@ -96,5 +103,23 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor return false; } + + public override string GetProjectName(object project) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + var hierarchy = project as IVsHierarchy; + Debug.Assert(hierarchy != null); + + if (ErrorHandler.Failed(hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_Name, out var name))) + { + return null; + } + + return (string)name; + } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs new file mode 100644 index 0000000000..52521d27c8 --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.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 Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.Language.Intellisense; +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +{ + internal class DefaultVisualStudioCompletionBroker : VisualStudioCompletionBroker + { + private readonly ICompletionBroker _completionBroker; + + public DefaultVisualStudioCompletionBroker(ICompletionBroker completionBroker) + { + if (completionBroker == null) + { + throw new ArgumentNullException(nameof(completionBroker)); + } + + _completionBroker = completionBroker; + } + + public override bool IsCompletionActive(ITextView textView) + { + if (textView == null) + { + throw new ArgumentNullException(nameof(textView)); + } + + var completionIsActive = _completionBroker.IsCompletionActive(textView); + return completionIsActive; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs new file mode 100644 index 0000000000..5312946e7f --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.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 System.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.Language.Intellisense; + +namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(VisualStudioCompletionBroker), RazorLanguage.Name, ServiceLayer.Default)] + internal class DefaultVisualStudioCompletionBrokerFactory : ILanguageServiceFactory + { + private readonly ICompletionBroker _completionBroker; + + [ImportingConstructor] + public DefaultVisualStudioCompletionBrokerFactory(ICompletionBroker completionBroker) + { + if (completionBroker == null) + { + throw new ArgumentNullException(nameof(completionBroker)); + } + + _completionBroker = completionBroker; + } + + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + return new DefaultVisualStudioCompletionBroker(_completionBroker); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioRazorParserFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioRazorParserFactory.cs deleted file mode 100644 index 3e881f05ad..0000000000 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioRazorParserFactory.cs +++ /dev/null @@ -1,64 +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.ComponentModel.Composition; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; -using Microsoft.VisualStudio.Language.Intellisense; -using TemplateEngineFactoryService = Microsoft.CodeAnalysis.Razor.RazorTemplateEngineFactoryService; - -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor -{ - [System.Composition.Shared] - [Export(typeof(VisualStudioRazorParserFactory))] - internal class DefaultVisualStudioRazorParserFactory : VisualStudioRazorParserFactory - { - private readonly ForegroundDispatcher _dispatcher; - private readonly TemplateEngineFactoryService _templateEngineFactoryService; - private readonly ICompletionBroker _completionBroker; - private readonly ErrorReporter _errorReporter; - - [ImportingConstructor] - public DefaultVisualStudioRazorParserFactory( - ICompletionBroker completionBroker, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) - { - if (completionBroker == null) - { - throw new ArgumentNullException(nameof(completionBroker)); - } - - if (workspace == null) - { - throw new ArgumentNullException(nameof(workspace)); - } - - _completionBroker = completionBroker; - _dispatcher = workspace.Services.GetRequiredService(); - _errorReporter = workspace.Services.GetRequiredService(); - var razorLanguageServices = workspace.Services.GetLanguageServices(RazorLanguage.Name); - _templateEngineFactoryService = razorLanguageServices.GetRequiredService(); - } - - public override VisualStudioRazorParser Create(VisualStudioDocumentTracker documentTracker) - { - if (documentTracker == null) - { - throw new ArgumentNullException(nameof(documentTracker)); - } - - _dispatcher.AssertForegroundThread(); - - var parser = new DefaultVisualStudioRazorParser( - _dispatcher, - documentTracker, - _templateEngineFactoryService, - _errorReporter, - _completionBroker); - return parser; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs index 860a8680e1..ae63cc5dfc 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs @@ -28,34 +28,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor [ImportingConstructor] public RazorTextViewConnectionListener( - TextBufferProjectService projectService, - RazorEditorFactoryService editorFactoryService, - [Import(typeof(VisualStudioWorkspace))] Workspace workspace) - { - if (projectService == null) - { - throw new ArgumentNullException(nameof(projectService)); - } - - if (editorFactoryService == null) - { - throw new ArgumentNullException(nameof(editorFactoryService)); - } - - if (workspace == null) - { - throw new ArgumentNullException(nameof(workspace)); - } - - _projectService = projectService; - _editorFactoryService = editorFactoryService; - _workspace = workspace; - - _foregroundDispatcher = workspace.Services.GetRequiredService(); - } - - // This is only for testing. We want to avoid using the actual Roslyn GetService methods in unit tests. - internal RazorTextViewConnectionListener( ForegroundDispatcher foregroundDispatcher, TextBufferProjectService projectService, RazorEditorFactoryService editorFactoryService, @@ -85,6 +57,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor _projectService = projectService; _editorFactoryService = editorFactoryService; _workspace = workspace; + } public Workspace Workspace => _workspace; @@ -111,8 +84,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor continue; } - var hierarchy = _projectService.GetHierarchy(textBuffer); - if (!_projectService.IsSupportedProject(hierarchy)) + var hostProject = _projectService.GetHostProject(textBuffer); + if (!_projectService.IsSupportedProject(hostProject)) { return; } diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/TextBufferProjectService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/TextBufferProjectService.cs deleted file mode 100644 index 89a5eb49cd..0000000000 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/TextBufferProjectService.cs +++ /dev/null @@ -1,17 +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 Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Text; - -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor -{ - internal abstract class TextBufferProjectService - { - public abstract IVsHierarchy GetHierarchy(ITextBuffer textBuffer); - - public abstract bool IsSupportedProject(IVsHierarchy hierarchy); - - public abstract string GetProjectPath(IVsHierarchy hierarchy); - } -} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs index ed6cc73313..54b67052e2 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Legacy/LegacyTagHelperResolver.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.ComponentModel.Composition; +using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; @@ -12,13 +14,23 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor // use TagHelperResolver. // ---------------------------------------------------------------------------------------------------- [Export(typeof(ITagHelperResolver))] - internal class LegacyTagHelperResolver : DefaultTagHelperResolver, ITagHelperResolver + internal class LegacyTagHelperResolver : OOPTagHelperResolver, ITagHelperResolver { [ImportingConstructor] public LegacyTagHelperResolver( [Import(typeof(VisualStudioWorkspace))] Workspace workspace) - : base(workspace.Services.GetRequiredService(), workspace) + : base(workspace) { } + + public Task GetTagHelpersAsync(Project project) + { + if (project == null) + { + throw new System.ArgumentNullException(nameof(project)); + } + + return base.GetTagHelpersAsync(project, CancellationToken.None); + } } } \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolver.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolver.cs new file mode 100644 index 0000000000..f0e81aeece --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolver.cs @@ -0,0 +1,91 @@ +// 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; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Editor.Razor; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Microsoft.VisualStudio.LanguageServices.Razor +{ + internal class OOPTagHelperResolver : TagHelperResolver + { + private readonly DefaultTagHelperResolver _defaultResolver; + private readonly Workspace _workspace; + + public OOPTagHelperResolver(Workspace workspace) + { + if (workspace == null) + { + throw new ArgumentNullException(nameof(workspace)); + } + + _workspace = workspace; + _defaultResolver = new DefaultTagHelperResolver(); + } + + public override async Task GetTagHelpersAsync(Project project, CancellationToken cancellationToken) + { + if (project == null) + { + throw new ArgumentNullException(nameof(project)); + } + + try + { + TagHelperResolutionResult result = null; + + // We're being defensive here because the OOP host can return null for the client/session/operation + // when it's disconnected (user stops the process). + var client = await RazorLanguageServiceClientFactory.CreateAsync(_workspace, cancellationToken); + if (client != null) + { + using (var session = await client.CreateSessionAsync(project.Solution)) + { + if (session != null) + { + var jsonObject = await session.InvokeAsync( + "GetTagHelpersAsync", + new object[] { project.Id.Id, "Foo", }, + cancellationToken).ConfigureAwait(false); + + result = GetTagHelperResolutionResult(jsonObject); + } + } + } + + if (result == null) + { + // Was unable to get tag helpers OOP, fallback to default behavior. + result = await _defaultResolver.GetTagHelpersAsync(project, cancellationToken); + } + + return result; + } + catch (Exception exception) + { + throw new InvalidOperationException( + Resources.FormatUnexpectedException( + typeof(DefaultTagHelperResolver).FullName, + nameof(GetTagHelpersAsync)), + exception); + } + } + + private TagHelperResolutionResult GetTagHelperResolutionResult(JObject jsonObject) + { + var serializer = new JsonSerializer(); + serializer.Converters.Add(TagHelperDescriptorJsonConverter.Instance); + serializer.Converters.Add(RazorDiagnosticJsonConverter.Instance); + + using (var reader = jsonObject.CreateReader()) + { + return serializer.Deserialize(reader); + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolverFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolverFactory.cs new file mode 100644 index 0000000000..d3265f7778 --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/OOPTagHelperResolverFactory.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.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Razor; + +namespace Microsoft.VisualStudio.LanguageServices.Razor +{ + [Shared] + [ExportLanguageServiceFactory(typeof(TagHelperResolver), RazorLanguage.Name, ServiceLayer.Host)] + internal class OOPTagHelperResolverFactory : ILanguageServiceFactory + { + public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + { + var workspace = languageServices.WorkspaceServices.Workspace; + return new OOPTagHelperResolver(workspace); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDiagnosticJsonConverter.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDiagnosticJsonConverter.cs index d9d4d966e1..85d0a4096b 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDiagnosticJsonConverter.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDiagnosticJsonConverter.cs @@ -3,7 +3,6 @@ using System; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.Language.Legacy; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -13,7 +12,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor { public static readonly RazorDiagnosticJsonConverter Instance = new RazorDiagnosticJsonConverter(); private const string RazorDiagnosticMessageKey = "Message"; - private const string RazorDiagnosticTypeNameKey = "TypeName"; public override bool CanConvert(Type objectType) { @@ -35,26 +33,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor var length = span[nameof(SourceSpan.Length)].Value(); var filePath = span[nameof(SourceSpan.FilePath)].Value(); var message = diagnostic[RazorDiagnosticMessageKey].Value(); - var typeName = diagnostic[RazorDiagnosticTypeNameKey].Value(); + var id = diagnostic[nameof(RazorDiagnostic.Id)].Value(); + var severity = diagnostic[nameof(RazorDiagnostic.Severity)].Value(); - if (string.Equals(typeName, typeof(DefaultRazorDiagnostic).FullName, StringComparison.Ordinal)) - { - var id = diagnostic[nameof(RazorDiagnostic.Id)].Value(); - var severity = diagnostic[nameof(RazorDiagnostic.Severity)].Value(); + var descriptor = new RazorDiagnosticDescriptor(id, () => message, (RazorDiagnosticSeverity)severity); + var sourceSpan = new SourceSpan(filePath, absoluteIndex, lineIndex, characterIndex, length); - var descriptor = new RazorDiagnosticDescriptor(id, () => message, (RazorDiagnosticSeverity)severity); - var sourceSpan = new SourceSpan(filePath, absoluteIndex, lineIndex, characterIndex, length); - - return RazorDiagnostic.Create(descriptor, sourceSpan); - } - else if (string.Equals(typeName, typeof(LegacyRazorDiagnostic).FullName, StringComparison.Ordinal)) - { - var error = new RazorError(message, absoluteIndex, lineIndex, characterIndex, length); - - return RazorDiagnostic.Create(error); - } - - return null; + return RazorDiagnostic.Create(descriptor, sourceSpan); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) @@ -65,7 +50,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor WriteProperty(writer, nameof(RazorDiagnostic.Id), diagnostic.Id); WriteProperty(writer, nameof(RazorDiagnostic.Severity), (int)diagnostic.Severity); WriteProperty(writer, RazorDiagnosticMessageKey, diagnostic.GetMessage()); - WriteProperty(writer, RazorDiagnosticTypeNameKey, diagnostic.GetType().FullName); writer.WritePropertyName(nameof(RazorDiagnostic.Span)); serializer.Serialize(writer, diagnostic.Span); @@ -79,4 +63,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor writer.WriteValue(value); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/TextBufferProjectService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/TextBufferProjectService.cs deleted file mode 100644 index 902b8b4a68..0000000000 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/TextBufferProjectService.cs +++ /dev/null @@ -1,15 +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 Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Text; - -namespace Microsoft.VisualStudio.LanguageServices.Razor -{ - internal abstract class TextBufferProjectService - { - public abstract IVsHierarchy GetHierarchy(ITextBuffer textBuffer); - - public abstract bool IsSupportedProject(IVsHierarchy hierarchy); - } -} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioForegroundDispatcher.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioForegroundDispatcher.cs index e0f8400e27..6b80023b68 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioForegroundDispatcher.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioForegroundDispatcher.cs @@ -1,16 +1,15 @@ // 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 System.ComponentModel.Composition; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Razor; using Microsoft.VisualStudio.Shell; namespace Microsoft.VisualStudio.LanguageServices.Razor { - [Shared] - [ExportWorkspaceService(typeof(ForegroundDispatcher), ServiceLayer.Host)] + [System.Composition.Shared] + [Export(typeof(ForegroundDispatcher))] internal class VisualStudioForegroundDispatcher : ForegroundDispatcher { public override TaskScheduler BackgroundScheduler { get; } = TaskScheduler.Default; diff --git a/src/RazorPageGenerator/Program.cs b/src/RazorPageGenerator/Program.cs index dd41d007c5..1aae7c86ef 100644 --- a/src/RazorPageGenerator/Program.cs +++ b/src/RazorPageGenerator/Program.cs @@ -31,8 +31,8 @@ Examples: var rootNamespace = args[0]; var targetProjectDirectory = args.Length > 1 ? args[1] : Directory.GetCurrentDirectory(); - var razorEngine = CreateRazorEngine(rootNamespace); - var results = MainCore(razorEngine, targetProjectDirectory); + var projectEngine = CreateProjectEngine(rootNamespace, targetProjectDirectory); + var results = MainCore(projectEngine, targetProjectDirectory); foreach (var result in results) { @@ -45,9 +45,10 @@ Examples: return 0; } - public static RazorEngine CreateRazorEngine(string rootNamespace, Action configure = null) + public static RazorProjectEngine CreateProjectEngine(string rootNamespace, string targetProjectDirectory, Action configure = null) { - var razorEngine = RazorEngine.Create(builder => + var fileSystem = RazorProjectFileSystem.Create(targetProjectDirectory); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, builder => { builder .SetNamespace(rootNamespace) @@ -60,24 +61,21 @@ Examples: }); builder.Features.Add(new SuppressChecksumOptionsFeature()); + builder.Features.Add(new SuppressMetadataAttributesFeature()); + if (configure != null) { configure(builder); } + + builder.AddDefaultImports(DefaultImportItem.Instance); }); - return razorEngine; + return projectEngine; } - public static IList MainCore(RazorEngine razorEngine, string targetProjectDirectory) + public static IList MainCore(RazorProjectEngine projectEngine, string targetProjectDirectory) { var viewDirectories = Directory.EnumerateDirectories(targetProjectDirectory, "Views", SearchOption.AllDirectories); - var razorProject = RazorProject.Create(targetProjectDirectory); - var templateEngine = new RazorTemplateEngine(razorEngine, razorProject); - templateEngine.Options.DefaultImports = RazorSourceDocument.Create(@" -@using System -@using System.Threading.Tasks -", fileName: null); - var fileCount = 0; var results = new List(); @@ -86,7 +84,7 @@ Examples: Console.WriteLine(); Console.WriteLine(" Generating code files for views in {0}", viewDir); var viewDirPath = viewDir.Substring(targetProjectDirectory.Length).Replace('\\', '/'); - var cshtmlFiles = razorProject.EnumerateItems(viewDirPath); + var cshtmlFiles = projectEngine.FileSystem.EnumerateItems(viewDirPath); if (!cshtmlFiles.Any()) { @@ -97,7 +95,7 @@ Examples: foreach (var item in cshtmlFiles) { Console.WriteLine(" Generating code file for view {0}...", item.FileName); - results.Add(GenerateCodeFile(templateEngine, item)); + results.Add(GenerateCodeFile(projectEngine, item)); Console.WriteLine(" Done!"); fileCount++; } @@ -106,10 +104,11 @@ Examples: return results; } - private static RazorPageGeneratorResult GenerateCodeFile(RazorTemplateEngine templateEngine, RazorProjectItem projectItem) + private static RazorPageGeneratorResult GenerateCodeFile(RazorProjectEngine projectEngine, RazorProjectItem projectItem) { var projectItemWrapper = new FileSystemRazorProjectItemWrapper(projectItem); - var cSharpDocument = templateEngine.GenerateCode(projectItemWrapper); + var codeDocument = projectEngine.Process(projectItemWrapper); + var cSharpDocument = codeDocument.GetCSharpDocument(); if (cSharpDocument.Diagnostics.Any()) { var diagnostics = string.Join(Environment.NewLine, cSharpDocument.Diagnostics); @@ -139,6 +138,52 @@ Examples: } } + private class SuppressMetadataAttributesFeature : RazorEngineFeatureBase, IConfigureRazorCodeGenerationOptionsFeature + { + public int Order { get; set; } + + public void Configure(RazorCodeGenerationOptionsBuilder options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + options.SuppressMetadataAttributes = true; + } + } + + private class DefaultImportItem : RazorProjectItem + { + private readonly byte[] _defaultImportBytes; + + private DefaultImportItem() + { + var preamble = Encoding.UTF8.GetPreamble(); + var content = @" +@using System +@using System.Threading.Tasks +"; + var contentBytes = Encoding.UTF8.GetBytes(content); + + _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_defaultImportBytes, 0); + contentBytes.CopyTo(_defaultImportBytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public static DefaultImportItem Instance { get; } = new DefaultImportItem(); + + public override Stream Read() => new MemoryStream(_defaultImportBytes); + } + private class FileSystemRazorProjectItemWrapper : RazorProjectItem { private readonly RazorProjectItem _source; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs index 36e9adae36..a507103fb7 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/AssemblyAttributeInjectionPassTest.cs @@ -13,7 +13,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfNamespaceNodeIsMissing() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var pass = new AssemblyAttributeInjectionPass { Engine = RazorEngine.Create(), @@ -30,7 +34,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfNamespaceNodeHasEmptyContent() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = string.Empty }; @namespace.Annotations[CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace; @@ -53,7 +60,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfClassNameNodeIsMissing() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "SomeNamespace" }; builder.Push(@namespace); @@ -67,7 +78,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); // Assert - Assert.Collection(irDocument.Children, + Assert.Collection( + irDocument.Children, node => Assert.Same(@namespace, node)); } @@ -75,7 +87,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_NoOps_IfClassNameIsEmpty() { // Arrange - var irDocument = new DocumentIntermediateNode(); + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode { @@ -115,6 +130,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = "Default", + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "SomeNamespace" }; @@ -138,18 +154,19 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); // Assert - Assert.Collection(irDocument.Children, + Assert.Collection( + irDocument.Children, node => Assert.Same(@namespace, node)); } [Fact] - public void Execute_AddsRazorViewAttribute_ToViews() + public void Execute_NoOps_ForDesignTime() { // Arrange - var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/Views/Index.cshtml\", typeof(SomeNamespace.SomeName))]"; var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDesignTimeDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode @@ -175,8 +192,56 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { Engine = RazorEngine.Create(), }; - var document = TestRazorCodeDocument.CreateEmpty(); - document.SetRelativePath("/Views/Index.cshtml"); + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); + + // Act + pass.Execute(document, irDocument); + + // Assert + Assert.Collection( + irDocument.Children, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_AddsRazorViewAttribute_ToViews() + { + // Arrange + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/Views/Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var irDocument = new DocumentIntermediateNode + { + DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = RazorEngine.Create(), + }; + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); // Act pass.Execute(document, irDocument); @@ -197,10 +262,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_EscapesViewPathWhenAddingAttributeToViews() { // Arrange - var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"\\test\\\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/test/\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode @@ -226,8 +292,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { Engine = RazorEngine.Create(), }; - var document = TestRazorCodeDocument.CreateEmpty(); - document.SetRelativePath("\\test\\\"Index.cshtml"); + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "\\test\\\"Index.cshtml")); + var document = RazorCodeDocument.Create(source); // Act pass.Execute(document, irDocument); @@ -252,6 +319,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = new DocumentIntermediateNode { DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var pageDirective = new DirectiveIntermediateNode @@ -283,8 +351,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { Engine = RazorEngine.Create(), }; - var document = TestRazorCodeDocument.CreateEmpty(); - document.SetRelativePath("/Views/Index.cshtml"); + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); // Act pass.Execute(document, irDocument); @@ -306,10 +375,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void Execute_EscapesViewPathAndRouteWhenAddingAttributeToPage() { // Arrange - var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"\\test\\\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/test/\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; var irDocument = new DocumentIntermediateNode { DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), }; var builder = IntermediateNodeBuilder.Create(irDocument); var @namespace = new NamespaceDeclarationIntermediateNode @@ -336,8 +406,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { Engine = RazorEngine.Create(), }; - var document = TestRazorCodeDocument.CreateEmpty(); - document.SetRelativePath("\\test\\\"Index.cshtml"); + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "test\\\"Index.cshtml")); + var document = RazorCodeDocument.Create(source); // Act pass.Execute(document, irDocument); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs index 0827042ac4..d59d1ad06b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs @@ -10,11 +10,47 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { public class InstrumentationPassTest { + [Fact] + public void InstrumentationPass_NoOps_ForDesignTime() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDesignTimeDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new HtmlContentIntermediateNode()); + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.Html, + }); + builder.Pop(); + + var pass = new InstrumentationPass() + { + Engine = RazorEngine.CreateEmpty(b => { }), + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => IntermediateNodeAssert.Html("Hi", n)); + } + [Fact] public void InstrumentationPass_InstrumentsHtml() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new HtmlContentIntermediateNode() @@ -49,7 +85,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsHtml_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new HtmlContentIntermediateNode()); builder.Add(new IntermediateToken() @@ -77,7 +117,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_InstrumentsCSharpExpression() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new CSharpExpressionIntermediateNode() { @@ -109,7 +153,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new CSharpExpressionIntermediateNode()); builder.Add(new IntermediateToken() @@ -136,7 +184,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_InsideTagHelperAttribute() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); @@ -183,7 +235,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsCSharpExpression_InsideTagHelperProperty() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); @@ -230,7 +286,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_InstrumentsTagHelper() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Add(new TagHelperIntermediateNode() { @@ -257,7 +317,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void InstrumentationPass_SkipsTagHelper_WithoutLocation() { // Arrange - var document = new DocumentIntermediateNode(); + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(document); builder.Push(new TagHelperIntermediateNode()); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs index fcf8bc2422..f6466520af 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ModelDirectiveTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -163,8 +163,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @inherits BaseType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -193,8 +193,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @model SomeType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -246,6 +246,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }); } + private RazorEngine CreateDesignTimeEngine() + { + return RazorEngine.CreateDesignTime(b => + { + // Notice we're not registering the ModelDirective.Pass here so we can run it on demand. + b.AddDirective(ModelDirective.Directive); + + // There's some special interaction with the inherits directive + InheritsDirective.Register(b); + }); + } + private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) { for (var i = 0; i < engine.Phases.Count; i++) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs new file mode 100644 index 0000000000..7e811ee261 --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcImportProjectFeatureTest.cs @@ -0,0 +1,76 @@ +// 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 Microsoft.AspNetCore.Razor.Language; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class MvcImportProjectFeatureTest + { + [Fact] + public void AddDefaultDirectivesImport_AddsSingleDynamicImport() + { + // Arrange + var imports = new List(); + + // Act + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); + + // Assert + var import = Assert.Single(imports); + Assert.Null(import.FilePath); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() + { + // Arrange + var imports = new List(); + var projectItem = new TestRazorProjectItem("/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] + { + new TestRazorProjectItem("/Index.cshtml"), + new TestRazorProjectItem("/_ViewImports.cshtml"), + new TestRazorProjectItem("/Contact/_ViewImports.cshtml"), + projectItem, + }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) + }; + + // Act + mvcImportFeature.AddHierarchicalImports(projectItem, imports); + + // Assert + Assert.Collection(imports, + import => Assert.Equal("/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Contact/_ViewImports.cshtml", import.FilePath)); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsNotOnDisk() + { + // Arrange + var imports = new List(); + var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) + }; + + // Act + mvcImportFeature.AddHierarchicalImports(projectItem, imports); + + // Assert + Assert.Collection(imports, + import => Assert.Equal("/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Pages/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Pages/Contact/_ViewImports.cshtml", import.FilePath)); + } + } +} diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcRazorTemplateEngineTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcRazorTemplateEngineTest.cs index 753ed80f00..58e440547e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcRazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcRazorTemplateEngineTest.cs @@ -2,10 +2,8 @@ // 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; -using Moq; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @@ -28,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }; var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -54,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }; var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -72,7 +70,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Arrange var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -86,28 +84,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions Assert.Contains("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor", importContent); } - [Fact] - public void CreateCodeDocument_SetsRelativePathOnOutput() - { - // Arrange - var path = "/Views/Home/Index.cshtml"; - var item = new TestRazorProjectItem(path) - { - Content = "Hello world", - }; - var project = new TestRazorProject(new List() { item, }); - - var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( - RazorEngine.Create(), - project); - - // Act - var codeDocument = mvcRazorTemplateEngine.CreateCodeDocument(path); - - // Assert - Assert.Equal(path, codeDocument.GetRelativePath()); - } - private string GetContent(RazorSourceDocument imports) { var contentChars = new char[imports.Length]; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcViewDocumentClassifierPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcViewDocumentClassifierPassTest.cs index fbedc6f67f..f5d775f677 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcViewDocumentClassifierPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/MvcViewDocumentClassifierPassTest.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 Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; @@ -14,7 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_SetsDocumentKind() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -33,7 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); irDocument.DocumentKind = "some-value"; @@ -53,7 +54,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_SetsNamespace() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -74,14 +76,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_SetsClass() { // Arrange - var codeDocument = CreateDocument("some-content"); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass { Engine = engine }; - codeDocument.SetRelativePath("Test.cshtml"); // Act pass.Execute(codeDocument, irDocument); @@ -91,17 +94,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("global::Microsoft.AspNetCore.Mvc.Razor.RazorPage", visitor.Class.BaseType); Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); - Assert.Equal("Test_cshtml", visitor.Class.ClassName); + Assert.Equal("Test", visitor.Class.ClassName); } [Theory] - [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index_cshtml")] - [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About_cshtml")] + [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index")] + [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About")] public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) { // Arrange - var codeDocument = CreateDocument("some-content"); - codeDocument.SetRelativePath(relativePath); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -122,9 +126,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() { // Arrange - var expected = "x___application_Views_Home_Index_cshtml"; - var path = @"x::\application\Views\Home\Index.cshtml"; - var codeDocument = CreateDocument("some-content", path); + var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -138,16 +142,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName); } [Fact] public void MvcViewDocumentClassifierPass_SanitizesClassName() { // Arrange - var expected = "path_with_invalid_chars"; - var codeDocument = CreateDocument("some-content"); - codeDocument.SetRelativePath("path.with+invalid-chars"); + var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -161,14 +165,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName); } [Fact] public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -187,14 +192,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); } - private static RazorCodeDocument CreateDocument(string content, string filePath = null) - { - filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml"); - - var source = RazorSourceDocument.Create(content, filePath); - return RazorCodeDocument.Create(source); - } - private static RazorEngine CreateEngine() => RazorEngine.Create(); private static DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/NamespaceDirectiveTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/NamespaceDirectiveTest.cs index fa806d0dc0..54f0feef51 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/NamespaceDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/NamespaceDirectiveTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public class NamespaceDirectiveTest { [Fact] - public void TryComputeNamespace_IncompleteDirective_UsesEmptyNamespace() + public void GetNamespace_IncompleteDirective_UsesEmptyNamespace() { // Arrange var source = "c:\\foo\\bar\\bleh.cshtml"; @@ -22,15 +22,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions }; // Act - var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace); + var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert - Assert.False(computed); Assert.Equal(string.Empty, @namespace); } [Fact] - public void TryComputeNamespace_EmptyDirective_UsesEmptyNamespace() + public void GetNamespace_EmptyDirective_UsesEmptyNamespace() { // Arrange var source = "c:\\foo\\bar\\bleh.cshtml"; @@ -43,10 +42,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions node.Children.Add(new DirectiveTokenIntermediateNode() { Content = string.Empty }); // Act - var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace); + var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert - Assert.False(computed); Assert.Equal(string.Empty, @namespace); } @@ -60,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions [InlineData("/foo.cshtml", "/foo/bar.cshtml")] [InlineData("c:\\foo.cshtml", "d:\\foo\\bar.cshtml")] [InlineData("c:\\foo\\bar\\bleh.cshtml", "c:\\foo\\baz\\bleh.cshtml")] - public void TryComputeNamespace_ForNonRelatedFiles_UsesNamespaceVerbatim(string source, string imports) + public void GetNamespace_ForNonRelatedFiles_UsesNamespaceVerbatim(string source, string imports) { // Arrange var node = new DirectiveIntermediateNode() @@ -72,10 +70,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions node.Children.Add(new DirectiveTokenIntermediateNode() { Content = "Base" }); // Act - var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace); + var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert - Assert.False(computed); Assert.Equal("Base", @namespace); } @@ -90,7 +87,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions [InlineData("c:\\foo\\bar\\baz.cshtml", "c:\\_ViewImports.cshtml", "Base.foo.bar")] [InlineData("c:\\foo\\bar\\baz.cshtml", "c:\\foo\\_ViewImports.cshtml", "Base.bar")] [InlineData("c:\\Foo\\bar\\baz.cshtml", "c:\\foo\\_ViewImports.cshtml", "Base.bar")] - public void TryComputeNamespace_ForRelatedFiles_ComputesNamespaceWithSuffix(string source, string imports, string expected) + public void GetNamespace_ForRelatedFiles_ComputesNamespaceWithSuffix(string source, string imports, string expected) { // Arrange var node = new DirectiveIntermediateNode() @@ -102,16 +99,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions node.Children.Add(new DirectiveTokenIntermediateNode() { Content = "Base" }); // Act - var computed = NamespaceDirective.TryComputeNamespace(source, node, out var @namespace); + var @namespace = NamespaceDirective.GetNamespace(source, node); // Assert - Assert.True(computed); Assert.Equal(expected, @namespace); } // This is the case where a _ViewImports sets the namespace. [Fact] - public void Pass_SetsNamespaceAndClassName_ComputedFromImports() + public void Pass_SetsNamespace_ComputedFromImports() { // Arrange var document = new DocumentIntermediateNode(); @@ -143,12 +139,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Content); - Assert.Equal("AddUser_Page", @class.ClassName); + Assert.Equal("default", @class.ClassName); } // This is the case where the source file sets the namespace. [Fact] - public void Pass_SetsNamespaceAndClassName_ComputedFromSource() + public void Pass_SetsNamespace_ComputedFromSource() { // Arrange var document = new DocumentIntermediateNode(); @@ -190,13 +186,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Content); - Assert.Equal("AddUser_Page", @class.ClassName); + Assert.Equal("default", @class.ClassName); } // Handles cases where invalid characters appears in FileNames. Note that we don't sanitize the part of // the namespace that you put in an import, just the file-based-suffix. Garbage in, garbage out. [Fact] - public void Pass_SetsNamespaceAndClassName_SanitizesClassAndNamespace() + public void Pass_SetsNamespace_SanitizesClassAndNamespace() { // Arrange var document = new DocumentIntermediateNode(); @@ -228,12 +224,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("WebApplication.Account.Manage_Info", @namespace.Content); - Assert.Equal("Add_User_Page", @class.ClassName); + Assert.Equal("default", @class.ClassName); } // This is the case where the source file sets the namespace. [Fact] - public void Pass_SetsNamespaceAndClassName_ComputedFromSource_ForView() + public void Pass_SetsNamespace_ComputedFromSource_ForView() { // Arrange var document = new DocumentIntermediateNode(); @@ -275,13 +271,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("WebApplication.Account.Manage", @namespace.Content); - Assert.Equal("AddUser_View", @class.ClassName); + Assert.Equal("default", @class.ClassName); } // This handles an error case where we can't determine the relationship between the // imports and the source. [Fact] - public void Pass_SetsNamespaceButNotClassName_VerbatimFromImports() + public void Pass_SetsNamespace_VerbatimFromImports() { // Arrange var document = new DocumentIntermediateNode(); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/RazorPageDocumentClassifierPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/RazorPageDocumentClassifierPassTest.cs index bd7ecb95dd..6a21674f2e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/RazorPageDocumentClassifierPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/RazorPageDocumentClassifierPassTest.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 Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; @@ -40,7 +39,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_SetsDocumentKind() { // Arrange - var codeDocument = CreateDocument("@page"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -59,7 +59,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() { // Arrange - var codeDocument = CreateDocument("@page"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); irDocument.DocumentKind = "some-value"; @@ -79,7 +80,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_NoOpsIfPageDirectiveIsMalformed() { // Arrange - var codeDocument = CreateDocument("@page+1"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page+1", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); irDocument.DocumentKind = "some-value"; @@ -99,7 +101,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_SetsNamespace() { // Arrange - var codeDocument = CreateDocument("@page"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -120,14 +123,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_SetsClass() { // Arrange - var codeDocument = CreateDocument("@page"); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass { Engine = engine }; - codeDocument.SetRelativePath("Test.cshtml"); // Act pass.Execute(codeDocument, irDocument); @@ -137,17 +141,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions // Assert Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", visitor.Class.BaseType); Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); - Assert.Equal("Test_cshtml", visitor.Class.ClassName); + Assert.Equal("Test", visitor.Class.ClassName); } [Theory] - [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index_cshtml")] - [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About_cshtml")] + [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index")] + [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About")] public void RazorPageDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) { // Arrange - var codeDocument = CreateDocument("@page"); - codeDocument.SetRelativePath(relativePath); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -168,9 +173,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions public void RazorPageDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() { // Arrange - var expected = "x___application_Views_Home_Index_cshtml"; - var path = @"x::\application\Views\Home\Index.cshtml"; - var codeDocument = CreateDocument("@page", path); + var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -184,16 +189,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName); } [Fact] public void RazorPageDocumentClassifierPass_SanitizesClassName() { // Arrange - var expected = "path_with_invalid_chars"; - var codeDocument = CreateDocument("@page"); - codeDocument.SetRelativePath("path.with+invalid-chars"); + var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -207,14 +212,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName); } [Fact] public void RazorPageDocumentClassifierPass_SetsUpExecuteAsyncMethod() { // Arrange - var codeDocument = CreateDocument("@page"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new RazorPageDocumentClassifierPass @@ -233,14 +239,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); } - private static RazorCodeDocument CreateDocument(string content, string filePath = null) - { - filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml"); - - var source = RazorSourceDocument.Create(content, filePath); - return RazorCodeDocument.Create(source); - } - private static RazorEngine CreateEngine() { return RazorEngine.Create(b => diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs index 3edf343f5e..d39b64c26d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt index b29d7ed8cd..4074239b9f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt index e25ebcea7e..372b49cb6f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt @@ -1,34 +1,34 @@ Source Location: (13:0,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |this.ToString()| -Generated Location: (1037:26,13 [15] ) +Generated Location: (1030:26,13 [15] ) |this.ToString()| Source Location: (54:2,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |string.Format("{0}", "Hello")| -Generated Location: (1173:31,6 [29] ) +Generated Location: (1166:31,6 [29] ) |string.Format("{0}", "Hello")| Source Location: (95:4,2 [25] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) | var cls = "foo"; | -Generated Location: (1319:36,2 [25] ) +Generated Location: (1312:36,2 [25] ) | var cls = "foo"; | Source Location: (134:7,11 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |if(cls != null) { | -Generated Location: (1467:42,11 [18] ) +Generated Location: (1460:42,11 [18] ) |if(cls != null) { | Source Location: (153:7,30 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |cls| -Generated Location: (1629:47,30 [3] ) +Generated Location: (1622:47,30 [3] ) |cls| Source Location: (156:7,33 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) | }| -Generated Location: (1780:52,33 [2] ) +Generated Location: (1773:52,33 [2] ) | }| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs index 5a329752ee..bda5a6244e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4120ddad9d4353ed260e0585fe71080d78ff8ab3" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4120ddad9d4353ed260e0585fe71080d78ff8ab3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.ir.txt index c4bcd68fcd..9173f6251b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync CSharpCode - IntermediateToken - - CSharp - BeginContext(0, 4, true); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs index 3e79145caf..93b05b4ddd 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { @@ -59,9 +59,9 @@ MyService __typeHelper = default(MyService); [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index 2f95c8c58a..1cfef392ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,12 +1,12 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ9999: The 'inject' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ9999: The 'namespace' directive expects a namespace name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ9999: The 'namespace' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt index e6cca7f462..2aeddc2fa2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -79,6 +79,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt index 77fa549e07..c13c9c3006 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -1,40 +1,40 @@ Source Location: (119:6,6 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (678:18,0 [0] ) +Generated Location: (671:18,0 [0] ) || Source Location: (128:7,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (731:21,0 [0] ) +Generated Location: (724:21,0 [0] ) || Source Location: (139:9,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (784:24,0 [0] ) +Generated Location: (777:24,0 [0] ) || Source Location: (149:10,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (837:27,0 [0] ) +Generated Location: (830:27,0 [0] ) || Source Location: (159:11,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) |MyService| -Generated Location: (890:30,0 [17] ) +Generated Location: (883:30,0 [17] ) |MyService| Source Location: (176:11,25 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (1012:34,0 [0] ) +Generated Location: (1005:34,0 [0] ) || Source Location: (190:13,10 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (1065:37,0 [0] ) +Generated Location: (1058:37,0 [0] ) || Source Location: (203:14,11 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (1118:40,0 [0] ) +Generated Location: (1111:40,0 [0] ) || diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs index 7e8dc0ce87..908ae63c42 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "fec5cf763044f842fa2114e997bb07e0bf280cd6" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"fec5cf763044f842fa2114e997bb07e0bf280cd6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() @@ -55,9 +57,9 @@ namespace AspNetCore [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt index 2f95c8c58a..1cfef392ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -1,12 +1,12 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ9999: The 'inject' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ9999: The 'namespace' directive expects a namespace name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ9999: The 'namespace' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt index cea68367fe..bd3bdd87e2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync CSharpCode - IntermediateToken - - CSharp - BeginContext(83, 4, true); @@ -88,6 +90,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs index 0c96a6c7e0..6a16b10feb 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml : MyBasePageForViews + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt index 73169535b3..3310acfa76 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml - MyBasePageForViews - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt index 4f38bd7343..9b7a5db61d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) |MyBasePageForViews| -Generated Location: (654:18,0 [26] ) +Generated Location: (647:18,0 [26] ) |MyBasePageForViews| Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) |MyModel| -Generated Location: (794:22,0 [7] ) +Generated Location: (787:22,0 [7] ) |MyModel| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs index d8f59b684a..28a881a8ac 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "91cf923452a86b2906083cb0236d6d5b3bc528ef" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml : MyBasePageForViews + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"91cf923452a86b2906083cb0236d6d5b3bc528ef", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt index 4b994c2d50..2468ef4662 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml - MyBasePageForViews - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs index e3748d4f91..8d27d45236 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml : MyPageModel + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyPageModel { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt index e6a7b3f4c0..a183f64bc5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml - MyPageModel - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyPageModel - DesignTimeDirective - DirectiveToken - (10:0,10 [19] InheritsWithViewImports_Imports0.cshtml) - MyPageModel DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt index 4ae600111e..c120ec9937 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (14:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml) |MyModel| -Generated Location: (653:18,0 [7] ) +Generated Location: (646:18,0 [7] ) |MyModel| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs index 3684c48b5d..e9220f8dd9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "052fe5ad02d36ebdf943dddd543cb26aaff62411" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)] namespace AspNetCore { #line hidden @@ -12,7 +13,9 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml : MyPageModel + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"052fe5ad02d36ebdf943dddd543cb26aaff62411", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"28770296d18b0505bb216c6143cc1ec6514adb7b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Imports0.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyPageModel { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt index 548bb823f5..2704223a57 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,9 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml - MyPageModel - + RazorSourceChecksumAttribute - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyPageModel - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs index 10050cba80..e198bf38b2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt index 132fe4ed61..c1d70d5d89 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt index 64bb4804b3..0d58ddea20 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt @@ -1,25 +1,25 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyModel| -Generated Location: (682:18,0 [7] ) +Generated Location: (675:18,0 [7] ) |MyModel| Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyApp| -Generated Location: (784:22,0 [5] ) +Generated Location: (777:22,0 [5] ) |MyApp| Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyPropertyName| -Generated Location: (904:26,22 [14] ) +Generated Location: (897:26,22 [14] ) |MyPropertyName| Source Location: (54:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyService| -Generated Location: (988:30,0 [17] ) +Generated Location: (981:30,0 [17] ) |MyService| Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |Html| -Generated Location: (1132:34,22 [4] ) +Generated Location: (1125:34,22 [4] ) |Html| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs index 3201f448fd..94406cdd68 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a039b7091118c718dc3023b6ac58d9645cb58e59" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a039b7091118c718dc3023b6ac58d9645cb58e59", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt index edd53414fb..d018107ae2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs index 2c3776aedd..7d588d5d12 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt index f9bf4e3c8c..5c4540f366 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt index fb80df37b7..8e98145f2d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt @@ -1,45 +1,45 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyModel| -Generated Location: (686:18,0 [7] ) +Generated Location: (679:18,0 [7] ) |MyModel| Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyApp| -Generated Location: (788:22,0 [5] ) +Generated Location: (781:22,0 [5] ) |MyApp| Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyPropertyName| -Generated Location: (908:26,22 [14] ) +Generated Location: (901:26,22 [14] ) |MyPropertyName| Source Location: (58:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyService| -Generated Location: (992:30,0 [17] ) +Generated Location: (985:30,0 [17] ) |MyService| Source Location: (76:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |Html| -Generated Location: (1136:34,22 [4] ) +Generated Location: (1129:34,22 [4] ) |Html| Source Location: (93:3,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyApp| -Generated Location: (1210:38,0 [5] ) +Generated Location: (1203:38,0 [5] ) |MyApp| Source Location: (99:3,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyPropertyName2| -Generated Location: (1330:42,22 [15] ) +Generated Location: (1323:42,22 [15] ) |MyPropertyName2| Source Location: (129:4,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyService| -Generated Location: (1415:46,0 [17] ) +Generated Location: (1408:46,0 [17] ) |MyService| Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |Html2| -Generated Location: (1559:50,22 [5] ) +Generated Location: (1552:50,22 [5] ) |Html2| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs index fd547570a8..816bd59508 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5010aab35d235175dab517f8018e41aee9a2ac7f" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5010aab35d235175dab517f8018e41aee9a2ac7f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt index 6f1f2b25c2..898557c170 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs index b8e43e2f76..b6a4d2a93f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt index 73671c0430..0b8beeae9b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt index ec01d63774..8bd4399f3f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (8:0,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) |MyApp| -Generated Location: (673:18,0 [5] ) +Generated Location: (666:18,0 [5] ) |MyApp| Source Location: (14:0,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) |MyPropertyName| -Generated Location: (793:22,22 [14] ) +Generated Location: (786:22,22 [14] ) |MyPropertyName| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs index da4378a7d8..04f3cce3ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c711078454f5b0e8d2cb77d9cb7fa88cca32b884" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c711078454f5b0e8d2cb77d9cb7fa88cca32b884", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt index e51dcacfeb..e05f9d2df9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs index d4bee96fbd..d99c176c52 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt index d076071130..90446dc58b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt index 5d1c4a4884..6f9220aab4 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs index b4c2cab291..c576cc0875 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "de132bd3e2a46a0d2ec953a168427c01e5829cde" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"de132bd3e2a46a0d2ec953a168427c01e5829cde", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt index d076071130..90446dc58b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt index 33f1f5b60a..e99ab2d9c2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync MalformedDirective - (0:0,0 [11] InvalidNamespaceAtEOF.cshtml) - namespace CSharpCode - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs index 44ef10a7fb..15befce0d0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { @@ -34,9 +34,9 @@ namespace AspNetCore [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt index 664a950710..637d1e902b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt index 71a96d869b..c3fbc6082e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -46,6 +46,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs index 1ce4676fc9..c90d98ec8f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5a9ff8440150c6746e4a8ba63bc633ea84930405" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5a9ff8440150c6746e4a8ba63bc633ea84930405", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() @@ -31,9 +33,9 @@ namespace AspNetCore [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt index 664a950710..637d1e902b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt index 8acaa03a0d..0692442d42 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page CSharpCode - @@ -31,6 +33,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs index 8dc9887854..e669a23be0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt index 529d7a140b..37627e94ea 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt index 0a0cb62f30..ced10bc85e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt @@ -1,20 +1,20 @@ Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |DateTime| -Generated Location: (758:19,0 [8] ) +Generated Location: (751:19,0 [8] ) |DateTime| Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |"InputTestTagHelper, AppCode"| -Generated Location: (899:23,37 [29] ) +Generated Location: (892:23,37 [29] ) |"InputTestTagHelper, AppCode"| Source Location: (83:4,17 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |Date| -Generated Location: (1547:36,102 [4] ) +Generated Location: (1540:36,102 [4] ) |Date| Source Location: (111:5,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |Model| -Generated Location: (1863:42,94 [5] ) +Generated Location: (1856:42,94 [5] ) |Model| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs index 2db976ac8c..238210a6a3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0906a816db301fe624bbe5a96c4b3013071ea492" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"0906a816db301fe624bbe5a96c4b3013071ea492", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #line hidden #pragma warning disable 0169 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt index c7a6817e41..1fb7820a75 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs index b12ca26651..923b853936 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt index b346a02ef5..1ebdc00df2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt index 226138531b..14e9047943 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (7:0,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml) |System.Collections.IEnumerable| -Generated Location: (695:18,0 [30] ) +Generated Location: (688:18,0 [30] ) |System.Collections.IEnumerable| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs index 511ba16f5e..3c58601f0f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "31c5b047a450ac9f6dc4116626667d26bfb657ba" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"31c5b047a450ac9f6dc4116626667d26bfb657ba", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt index 30bcc7afe1..2b7dcff085 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs index a766ae3900..dc5fcee8a2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt index b051568470..2fe8233c66 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ9999: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt index 7c125bef61..f63a69601b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt index 65348abd7b..ff5971643c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (7:0,7 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) |ThisShouldBeGenerated| -Generated Location: (695:18,0 [21] ) +Generated Location: (688:18,0 [21] ) |ThisShouldBeGenerated| Source Location: (37:1,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) |System.Collections.IEnumerable| -Generated Location: (825:22,0 [30] ) +Generated Location: (818:22,0 [30] ) |System.Collections.IEnumerable| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs index b584c46a88..cb05019c29 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace Test.Namespace using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class PageWithNamespace_Page : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { @@ -38,9 +38,9 @@ global::System.Object __typeHelper = nameof(Test.Namespace); [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public PageWithNamespace_Page Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt index 0dc65607e5..9238a0a419 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - PageWithNamespace_Page - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -42,6 +42,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public PageWithNamespace_Page Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt index 341492ab00..23b745fa44 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (18:1,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml) |Test.Namespace| -Generated Location: (664:18,44 [14] ) +Generated Location: (716:18,44 [14] ) |Test.Namespace| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs index ed1a98a723..5c256902b6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b205857d3dad47cb3f0c1d7775ae251b306ab830" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(Test.Namespace.PageWithNamespace_Page), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)] namespace Test.Namespace { #line hidden @@ -12,7 +13,8 @@ namespace Test.Namespace using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class PageWithNamespace_Page : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"b205857d3dad47cb3f0c1d7775ae251b306ab830", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() @@ -31,9 +33,9 @@ namespace Test.Namespace [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public PageWithNamespace_Page Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt index 841a9e1040..53b89427ee 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(Test.Namespace.PageWithNamespace_Page), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)] NamespaceDeclaration - - Test.Namespace UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - PageWithNamespace_Page - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync CSharpCode - IntermediateToken - - CSharp - BeginContext(34, 20, true); @@ -26,6 +28,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public PageWithNamespace_Page Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs index 6cccda46f2..af9ff10e76 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs @@ -16,7 +16,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; #line default #line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { private global::DivTagHelper __DivTagHelper; #pragma warning disable 219 @@ -71,9 +71,9 @@ global::System.Object __typeHelper = "*, AppCode"; [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt index 8662b30f1e..913b80d2aa 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt @@ -9,7 +9,7 @@ Document - UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingDirective - (38:3,1 [41] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DefaultTagHelperRuntime - FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper DesignTimeDirective - @@ -138,6 +138,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt index 0f57e118d6..a4abcf411d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt @@ -5,12 +5,12 @@ Generated Location: (487:14,0 [41] ) Source Location: (23:2,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) |"*, AppCode"| -Generated Location: (944:24,37 [12] ) +Generated Location: (937:24,37 [12] ) |"*, AppCode"| Source Location: (566:24,47 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) |Name| -Generated Location: (1507:37,47 [4] ) +Generated Location: (1500:37,47 [4] ) |Name| Source Location: (95:5,12 [283] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) @@ -28,7 +28,7 @@ Source Location: (95:5,12 [283] TestFiles/IntegrationTests/CodeGenerationIntegra public string Name { get; set; } } | -Generated Location: (1988:48,12 [283] ) +Generated Location: (1981:48,12 [283] ) | public IActionResult OnPost(Customer customer) { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs index 565653d24d..aadcde70fd 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c0587249e6e0b7ba4e1efc463f58577d5d0b6ae2" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)] namespace AspNetCore { #line hidden @@ -17,7 +18,8 @@ using Microsoft.AspNetCore.Mvc.RazorPages; #line default #line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c0587249e6e0b7ba4e1efc463f58577d5d0b6ae2", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); @@ -194,9 +196,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages; [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml Model => ViewData.Model; + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt index 9b45194f6c..519006aec3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -10,7 +11,8 @@ Document - UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingDirective - (38:3,1 [43] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - text-danger - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - col-md-10 - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - form-group - HtmlAttributeValueStyle.DoubleQuotes @@ -186,6 +188,6 @@ Document - Inject - Inject - CSharpCode - - IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; CSharpCode - - IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml Model => ViewData.Model; + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs index 3fc1ec92eb..8731920f14 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs @@ -16,7 +16,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; #line default #line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { private global::DivTagHelper __DivTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt index f1df7922a5..2266b746f6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt @@ -9,7 +9,7 @@ Document - UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingDirective - (55:4,1 [41] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - DefaultTagHelperRuntime - FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt index 88bdded9c2..02d6726a3a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt @@ -5,17 +5,17 @@ Generated Location: (475:14,0 [41] ) Source Location: (16:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) |NewModel| -Generated Location: (883:24,0 [8] ) +Generated Location: (876:24,0 [8] ) |NewModel| Source Location: (40:3,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) |"*, AppCode"| -Generated Location: (1024:28,37 [12] ) +Generated Location: (1017:28,37 [12] ) |"*, AppCode"| Source Location: (661:28,47 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) |Model.Name| -Generated Location: (1575:41,47 [10] ) +Generated Location: (1568:41,47 [10] ) |Model.Name| Source Location: (112:6,12 [360] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) @@ -36,7 +36,7 @@ Source Location: (112:6,12 [360] TestFiles/IntegrationTests/CodeGenerationIntegr public string Name { get; set; } } | -Generated Location: (2050:52,12 [360] ) +Generated Location: (2043:52,12 [360] ) | public class NewModel : PageModel { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs index d43bdad547..bda200e2ef 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "608b3f7b9b29c66ee25bde2d20324b4bef1aa070" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml), null)] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)] namespace AspNetCore { #line hidden @@ -17,7 +18,8 @@ using Microsoft.AspNetCore.Mvc.RazorPages; #line default #line hidden - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"608b3f7b9b29c66ee25bde2d20324b4bef1aa070", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages : global::Microsoft.AspNetCore.Mvc.RazorPages.Page { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt index fd1dc08a9a..cc1bc6f718 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml), null)] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -10,7 +11,8 @@ Document - UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingDirective - (55:4,1 [43] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - text-danger - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - col-md-10 - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - form-group - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs index fd3c971a71..604b3f412a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt index 061c04e613..312d7bb7ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt index 5e120c830d..4eb221e12b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -1,29 +1,29 @@ Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |DateTime| -Generated Location: (742:19,0 [8] ) +Generated Location: (735:19,0 [8] ) |DateTime| Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |"InputTestTagHelper, AppCode"| -Generated Location: (883:23,37 [29] ) +Generated Location: (876:23,37 [29] ) |"InputTestTagHelper, AppCode"| Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Section1| -Generated Location: (997:27,22 [8] ) +Generated Location: (990:27,22 [8] ) |Section1| Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) | Layout = "_SectionTestLayout.cshtml"; | -Generated Location: (1432:39,2 [46] ) +Generated Location: (1425:39,2 [46] ) | Layout = "_SectionTestLayout.cshtml"; | Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Date| -Generated Location: (1857:47,102 [4] ) +Generated Location: (1850:47,102 [4] ) |Date| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs index ba56f04308..1bf54c1495 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "dbec91fd88a09c6a2e35b5adedb3f8ab8e3ae486" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"dbec91fd88a09c6a2e35b5adedb3f8ab8e3ae486", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #line hidden #pragma warning disable 0169 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt index 4a4f3ce128..8a5b810749 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs index 3e793c429e..1cd38d3029 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs @@ -11,10 +11,10 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::AllTagHelper __AllTagHelper; - private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { @@ -36,7 +36,7 @@ global::System.Object __typeHelper = "*, AppCode"; #line default #line hidden __AllTagHelper = CreateTagHelper(); - __TestViewComponentTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); #line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" __o = foo; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt index a4644b8052..8e7497e7d6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt @@ -8,10 +8,10 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper - FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -43,7 +43,7 @@ Document - TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag DefaultTagHelperBody - DefaultTagHelperCreate - - AllTagHelper - DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt index 9344e08ed2..dcc0a00913 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt @@ -1,19 +1,19 @@ Source Location: (14:0,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) |"*, AppCode"| -Generated Location: (973:20,37 [12] ) +Generated Location: (959:20,37 [12] ) |"*, AppCode"| Source Location: (30:1,2 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) | var foo = "Hello"; | -Generated Location: (1419:32,2 [26] ) +Generated Location: (1405:32,2 [26] ) | var foo = "Hello"; | Source Location: (83:5,22 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) |foo| -Generated Location: (1877:40,22 [3] ) +Generated Location: (1856:40,22 [3] ) |foo| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs index fae9d8f97e..912ddae15c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6a0ad3c59f3a87877c36928472f0508bd40cdd8c" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))] namespace AspNetCore { #line hidden @@ -12,9 +13,10 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6a0ad3c59f3a87877c36928472f0508bd40cdd8c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { - private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("bar", " World", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); #line hidden #pragma warning disable 0169 @@ -53,7 +55,7 @@ namespace AspNetCore ); __AllTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__AllTagHelper); - __TestViewComponentTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__TestViewComponentTagHelper); BeginWriteTagHelperAttribute(); #line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt index 1afbf3ebfd..4c215a09d3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,8 +10,9 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - bar - World - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper @@ -28,7 +30,7 @@ Document - TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag DefaultTagHelperBody - DefaultTagHelperCreate - - AllTagHelper - DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs index 360ee6de22..208184dc25 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace Test.Namespace using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class ViewWithNamespace_View : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt index 817da953cc..42d53bcd1b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - ViewWithNamespace_View - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt index 18b68f476b..caae65f18f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (11:0,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml) |Test.Namespace| -Generated Location: (673:18,44 [14] ) +Generated Location: (725:18,44 [14] ) |Test.Namespace| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs index b1ffde19d1..aab5b52963 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2893acf42354a0bc8b6a2698f5d2e4fab0e59dbe" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(Test.Namespace.ViewWithNamespace_View))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))] namespace Test.Namespace { #line hidden @@ -12,7 +13,8 @@ namespace Test.Namespace using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class ViewWithNamespace_View : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2893acf42354a0bc8b6a2698f5d2e4fab0e59dbe", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt index fe9408759b..471464c580 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(Test.Namespace.ViewWithNamespace_View))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))] NamespaceDeclaration - - Test.Namespace UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - ViewWithNamespace_View - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync CSharpCode - IntermediateToken - - CSharp - BeginContext(27, 20, true); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs index 2e09a42013..6bc3c83d01 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt index af728a2813..b677049ce1 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt index 287d4e0c05..a418264123 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (8:0,8 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) |IHtmlHelper| -Generated Location: (679:18,0 [19] ) +Generated Location: (672:18,0 [19] ) |IHtmlHelper| Source Location: (28:0,28 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) |Helper| -Generated Location: (827:22,22 [6] ) +Generated Location: (820:22,22 [6] ) |Helper| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs index 748d2c4dc3..f60ea39dac 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs @@ -1,7 +1,8 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e57bbc3e746e8b13b4c33d8df0e022bd397d8caa" // #pragma warning disable 1591 -[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml))] +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))] namespace AspNetCore { #line hidden @@ -12,7 +13,8 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e57bbc3e746e8b13b4c33d8df0e022bd397d8caa", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt index 700715b3e4..addc2754ec 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt @@ -1,6 +1,7 @@ Document - + RazorCompiledItemAttribute - CSharpCode - - IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml))] + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))] NamespaceDeclaration - - AspNetCore UsingDirective - (1:0,1 [14] ) - System UsingDirective - (16:1,1 [34] ) - System.Collections.Generic @@ -9,7 +10,8 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs index 632e83d73c..42761df919 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "723b7da149db577d0c49cff7c00f2d831e8916e7" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.Template), @"default", @"/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml")] namespace Razor { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"723b7da149db577d0c49cff7c00f2d831e8916e7", @"/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml")] public class Template { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt index 69d1ee0c72..c4ba72abd9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ViewComponentTagHelperPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ViewComponentTagHelperPassTest.cs index ab70db8306..d6b2b398e5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ViewComponentTagHelperPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/ViewComponentTagHelperPassTest.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); @@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); @@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs index c366918999..c0319a9a0a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ModelDirectiveTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X "); var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: false) + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -163,8 +163,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X @inherits BaseType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -193,8 +193,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X @model SomeType "); - var engine = CreateEngine(); - var pass = new ModelDirective.Pass(designTime: true) + var engine = CreateDesignTimeEngine(); + var pass = new ModelDirective.Pass() { Engine = engine, }; @@ -246,6 +246,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X }); } + private RazorEngine CreateDesignTimeEngine() + { + return RazorEngine.CreateDesignTime(b => + { + // Notice we're not registering the ModelDirective.Pass here so we can run it on demand. + b.AddDirective(ModelDirective.Directive); + + // There's some special interaction with the inherits directive + InheritsDirective.Register(b); + }); + } + private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) { for (var i = 0; i < engine.Phases.Count; i++) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs new file mode 100644 index 0000000000..e53046ed5a --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcImportProjectFeatureTest.cs @@ -0,0 +1,76 @@ +// 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 Microsoft.AspNetCore.Razor.Language; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X +{ + public class MvcImportProjectFeatureTest + { + [Fact] + public void AddDefaultDirectivesImport_AddsSingleDynamicImport() + { + // Arrange + var imports = new List(); + + // Act + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); + + // Assert + var import = Assert.Single(imports); + Assert.Null(import.FilePath); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() + { + // Arrange + var imports = new List(); + var projectItem = new TestRazorProjectItem("/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] + { + new TestRazorProjectItem("/Index.cshtml"), + new TestRazorProjectItem("/_ViewImports.cshtml"), + new TestRazorProjectItem("/Contact/_ViewImports.cshtml"), + projectItem, + }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) + }; + + // Act + mvcImportFeature.AddHierarchicalImports(projectItem, imports); + + // Assert + Assert.Collection(imports, + import => Assert.Equal("/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Contact/_ViewImports.cshtml", import.FilePath)); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsNotOnDisk() + { + // Arrange + var imports = new List(); + var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(projectEngine => projectEngine.FileSystem == testFileSystem) + }; + + // Act + mvcImportFeature.AddHierarchicalImports(projectItem, imports); + + // Assert + Assert.Collection(imports, + import => Assert.Equal("/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Pages/_ViewImports.cshtml", import.FilePath), + import => Assert.Equal("/Pages/Contact/_ViewImports.cshtml", import.FilePath)); + } + } +} diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcRazorTemplateEngineTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcRazorTemplateEngineTest.cs index b4954469bc..c2378397a6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcRazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcRazorTemplateEngineTest.cs @@ -2,10 +2,8 @@ // 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; -using Moq; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X @@ -28,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X }; var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -54,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X }; var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -72,7 +70,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X // Arrange var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( RazorEngine.Create(), - new TestRazorProject()); + new TestRazorProjectFileSystem()); // Act var imports = mvcRazorTemplateEngine.Options.DefaultImports; @@ -84,28 +82,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X Assert.Contains("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor", importContent); } - [Fact] - public void CreateCodeDocument_SetsRelativePathOnOutput() - { - // Arrange - var path = "/Views/Home/Index.cshtml"; - var item = new TestRazorProjectItem(path) - { - Content = "Hello world", - }; - var project = new TestRazorProject(new List() { item, }); - - var mvcRazorTemplateEngine = new MvcRazorTemplateEngine( - RazorEngine.Create(), - project); - - // Act - var codeDocument = mvcRazorTemplateEngine.CreateCodeDocument(path); - - // Assert - Assert.Equal(path, codeDocument.GetRelativePath()); - } - private string GetContent(RazorSourceDocument imports) { var contentChars = new char[imports.Length]; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcViewDocumentClassifierPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcViewDocumentClassifierPassTest.cs index d0b8361965..2000f66a53 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcViewDocumentClassifierPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/MvcViewDocumentClassifierPassTest.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 Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; @@ -14,7 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_SetsDocumentKind() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -33,7 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); irDocument.DocumentKind = "some-value"; @@ -53,7 +54,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_SetsNamespace() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -74,14 +76,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_SetsClass() { // Arrange - var codeDocument = CreateDocument("some-content"); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass { Engine = engine }; - codeDocument.SetRelativePath("Test.cshtml"); // Act pass.Execute(codeDocument, irDocument); @@ -91,17 +94,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X // Assert Assert.Equal("global::Microsoft.AspNetCore.Mvc.Razor.RazorPage", visitor.Class.BaseType); Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); - Assert.Equal("Test_cshtml", visitor.Class.ClassName); + Assert.Equal("Test", visitor.Class.ClassName); } [Theory] - [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index_cshtml")] - [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About_cshtml")] + [InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index")] + [InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About")] public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) { // Arrange - var codeDocument = CreateDocument("some-content"); - codeDocument.SetRelativePath(relativePath); + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -122,9 +126,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() { // Arrange - var expected = "x___application_Views_Home_Index_cshtml"; - var path = @"x::\application\Views\Home\Index.cshtml"; - var codeDocument = CreateDocument("some-content", path); + var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -138,16 +142,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName); } [Fact] public void MvcViewDocumentClassifierPass_SanitizesClassName() { // Arrange - var expected = "path_with_invalid_chars"; - var codeDocument = CreateDocument("some-content"); - codeDocument.SetRelativePath("path.with+invalid-chars"); + var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -161,14 +165,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X visitor.Visit(irDocument); // Assert - Assert.Equal(expected, visitor.Class.ClassName); + Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName); } [Fact] public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod() { // Arrange - var codeDocument = CreateDocument("some-content"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml")); + var engine = CreateEngine(); var irDocument = CreateIRDocument(engine, codeDocument); var pass = new MvcViewDocumentClassifierPass @@ -187,14 +192,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); } - private static RazorCodeDocument CreateDocument(string content, string filePath = null) - { - filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml"); - - var source = RazorSourceDocument.Create(content, filePath); - return RazorCodeDocument.Create(source); - } - private static RazorEngine CreateEngine() => RazorEngine.Create(); private static DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs index 3edf343f5e..d39b64c26d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt index ba42b7a0f4..24d84bf975 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt index e25ebcea7e..372b49cb6f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt @@ -1,34 +1,34 @@ Source Location: (13:0,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |this.ToString()| -Generated Location: (1037:26,13 [15] ) +Generated Location: (1030:26,13 [15] ) |this.ToString()| Source Location: (54:2,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |string.Format("{0}", "Hello")| -Generated Location: (1173:31,6 [29] ) +Generated Location: (1166:31,6 [29] ) |string.Format("{0}", "Hello")| Source Location: (95:4,2 [25] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) | var cls = "foo"; | -Generated Location: (1319:36,2 [25] ) +Generated Location: (1312:36,2 [25] ) | var cls = "foo"; | Source Location: (134:7,11 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |if(cls != null) { | -Generated Location: (1467:42,11 [18] ) +Generated Location: (1460:42,11 [18] ) |if(cls != null) { | Source Location: (153:7,30 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) |cls| -Generated Location: (1629:47,30 [3] ) +Generated Location: (1622:47,30 [3] ) |cls| Source Location: (156:7,33 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) | }| -Generated Location: (1780:52,33 [2] ) +Generated Location: (1773:52,33 [2] ) | }| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs index e213442d23..5975633478 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index 72a8fa589b..3542c13c86 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,6 +1,6 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ9999: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ1015: The 'inject' directive expects an identifier. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt index ef934781a0..3a6d24fc1e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt index 27676d9e12..3b5068e43c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -1,30 +1,30 @@ Source Location: (93:2,6 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (687:18,0 [0] ) +Generated Location: (680:18,0 [0] ) || Source Location: (102:3,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (740:21,0 [0] ) +Generated Location: (733:21,0 [0] ) || Source Location: (113:5,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (793:24,0 [0] ) +Generated Location: (786:24,0 [0] ) || Source Location: (123:6,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (846:27,0 [0] ) +Generated Location: (839:27,0 [0] ) || Source Location: (133:7,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) |MyService| -Generated Location: (899:30,0 [17] ) +Generated Location: (892:30,0 [17] ) |MyService| Source Location: (150:7,25 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) || -Generated Location: (1021:34,0 [0] ) +Generated Location: (1014:34,0 [0] ) || diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs index 0c96a6c7e0..6a16b10feb 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml : MyBasePageForViews + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt index 1fba17672d..cc189604db 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml - MyBasePageForViews - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt index 4f38bd7343..9b7a5db61d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) |MyBasePageForViews| -Generated Location: (654:18,0 [26] ) +Generated Location: (647:18,0 [26] ) |MyBasePageForViews| Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) |MyModel| -Generated Location: (794:22,0 [7] ) +Generated Location: (787:22,0 [7] ) |MyModel| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs index a4a69f2b7f..b77fc2e72c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml : MyBasePageForViews + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyBasePageForViews { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt index 2da50d158b..eb605730f1 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml - MyBasePageForViews - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyBasePageForViews - DesignTimeDirective - DirectiveToken - (10:0,10 [26] InheritsWithViewImports_Imports0.cshtml) - MyBasePageForViews DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt index bd614d72eb..8ae3008a95 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml) |MyModel| -Generated Location: (660:18,0 [7] ) +Generated Location: (653:18,0 [7] ) |MyModel| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs index 10050cba80..e198bf38b2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt index e1d660ce8d..8ff03ba4e9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt index 64bb4804b3..0d58ddea20 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt @@ -1,25 +1,25 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyModel| -Generated Location: (682:18,0 [7] ) +Generated Location: (675:18,0 [7] ) |MyModel| Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyApp| -Generated Location: (784:22,0 [5] ) +Generated Location: (777:22,0 [5] ) |MyApp| Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyPropertyName| -Generated Location: (904:26,22 [14] ) +Generated Location: (897:26,22 [14] ) |MyPropertyName| Source Location: (54:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |MyService| -Generated Location: (988:30,0 [17] ) +Generated Location: (981:30,0 [17] ) |MyService| Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) |Html| -Generated Location: (1132:34,22 [4] ) +Generated Location: (1125:34,22 [4] ) |Html| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs index 2c3776aedd..7d588d5d12 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt index 4c0240ef2d..2b470e7180 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt index fb80df37b7..8e98145f2d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt @@ -1,45 +1,45 @@ Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyModel| -Generated Location: (686:18,0 [7] ) +Generated Location: (679:18,0 [7] ) |MyModel| Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyApp| -Generated Location: (788:22,0 [5] ) +Generated Location: (781:22,0 [5] ) |MyApp| Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyPropertyName| -Generated Location: (908:26,22 [14] ) +Generated Location: (901:26,22 [14] ) |MyPropertyName| Source Location: (58:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyService| -Generated Location: (992:30,0 [17] ) +Generated Location: (985:30,0 [17] ) |MyService| Source Location: (76:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |Html| -Generated Location: (1136:34,22 [4] ) +Generated Location: (1129:34,22 [4] ) |Html| Source Location: (93:3,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyApp| -Generated Location: (1210:38,0 [5] ) +Generated Location: (1203:38,0 [5] ) |MyApp| Source Location: (99:3,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyPropertyName2| -Generated Location: (1330:42,22 [15] ) +Generated Location: (1323:42,22 [15] ) |MyPropertyName2| Source Location: (129:4,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |MyService| -Generated Location: (1415:46,0 [17] ) +Generated Location: (1408:46,0 [17] ) |MyService| Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) |Html2| -Generated Location: (1559:50,22 [5] ) +Generated Location: (1552:50,22 [5] ) |Html2| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs index b8e43e2f76..b6a4d2a93f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt index e00df79298..2fed4fbe5a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt index ec01d63774..8bd4399f3f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (8:0,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) |MyApp| -Generated Location: (673:18,0 [5] ) +Generated Location: (666:18,0 [5] ) |MyApp| Source Location: (14:0,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) |MyPropertyName| -Generated Location: (793:22,22 [14] ) +Generated Location: (786:22,22 [14] ) |MyPropertyName| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs index d4bee96fbd..d99c176c52 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt index cfbf688e18..c3add1daa9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,2): Error RZ9999: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,2): Error RZ1007: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt index 59f3e7b070..f34fe8f4a0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs index 8dc9887854..e669a23be0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt index c4bbcf7a73..1ecd121c63 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt index 0a0cb62f30..ced10bc85e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt @@ -1,20 +1,20 @@ Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |DateTime| -Generated Location: (758:19,0 [8] ) +Generated Location: (751:19,0 [8] ) |DateTime| Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |"InputTestTagHelper, AppCode"| -Generated Location: (899:23,37 [29] ) +Generated Location: (892:23,37 [29] ) |"InputTestTagHelper, AppCode"| Source Location: (83:4,17 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |Date| -Generated Location: (1547:36,102 [4] ) +Generated Location: (1540:36,102 [4] ) |Date| Source Location: (111:5,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) |Model| -Generated Location: (1863:42,94 [5] ) +Generated Location: (1856:42,94 [5] ) |Model| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs index b12ca26651..923b853936 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt index 75faeeb1ca..c18b0cd554 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt index 226138531b..14e9047943 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt @@ -1,5 +1,5 @@ Source Location: (7:0,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml) |System.Collections.IEnumerable| -Generated Location: (695:18,0 [30] ) +Generated Location: (688:18,0 [30] ) |System.Collections.IEnumerable| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs index a766ae3900..dc5fcee8a2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt index b051568470..2fe8233c66 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ9999: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt index d8bb1d6d9d..a1ef9941e3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt index 65348abd7b..ff5971643c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (7:0,7 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) |ThisShouldBeGenerated| -Generated Location: (695:18,0 [21] ) +Generated Location: (688:18,0 [21] ) |ThisShouldBeGenerated| Source Location: (37:1,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) |System.Collections.IEnumerable| -Generated Location: (825:22,0 [30] ) +Generated Location: (818:22,0 [30] ) |System.Collections.IEnumerable| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs index fd3c971a71..604b3f412a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt index 7ab3c05edd..515e48bee6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt index 5e120c830d..4eb221e12b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -1,29 +1,29 @@ Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |DateTime| -Generated Location: (742:19,0 [8] ) +Generated Location: (735:19,0 [8] ) |DateTime| Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |"InputTestTagHelper, AppCode"| -Generated Location: (883:23,37 [29] ) +Generated Location: (876:23,37 [29] ) |"InputTestTagHelper, AppCode"| Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Section1| -Generated Location: (997:27,22 [8] ) +Generated Location: (990:27,22 [8] ) |Section1| Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) | Layout = "_SectionTestLayout.cshtml"; | -Generated Location: (1432:39,2 [46] ) +Generated Location: (1425:39,2 [46] ) | Layout = "_SectionTestLayout.cshtml"; | Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Date| -Generated Location: (1857:47,102 [4] ) +Generated Location: (1850:47,102 [4] ) |Date| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs index 3e793c429e..1cd38d3029 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs @@ -11,10 +11,10 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { private global::AllTagHelper __AllTagHelper; - private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { @@ -36,7 +36,7 @@ global::System.Object __typeHelper = "*, AppCode"; #line default #line hidden __AllTagHelper = CreateTagHelper(); - __TestViewComponentTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); #line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" __o = foo; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt index c3f1fcf05d..328b11876d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt @@ -8,10 +8,10 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DefaultTagHelperRuntime - FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper - FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -41,7 +41,7 @@ Document - TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag DefaultTagHelperBody - DefaultTagHelperCreate - - AllTagHelper - DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt index 9344e08ed2..dcc0a00913 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt @@ -1,19 +1,19 @@ Source Location: (14:0,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) |"*, AppCode"| -Generated Location: (973:20,37 [12] ) +Generated Location: (959:20,37 [12] ) |"*, AppCode"| Source Location: (30:1,2 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) | var foo = "Hello"; | -Generated Location: (1419:32,2 [26] ) +Generated Location: (1405:32,2 [26] ) | var foo = "Hello"; | Source Location: (83:5,22 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) |foo| -Generated Location: (1877:40,22 [3] ) +Generated Location: (1856:40,22 [3] ) |foo| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs index 2e09a42013..6bc3c83d01 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs @@ -11,7 +11,7 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt index d2def8694a..f75113d4b6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt @@ -8,7 +8,7 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt index 287d4e0c05..a418264123 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt @@ -1,10 +1,10 @@ Source Location: (8:0,8 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) |IHtmlHelper| -Generated Location: (679:18,0 [19] ) +Generated Location: (672:18,0 [19] ) |IHtmlHelper| Source Location: (28:0,28 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) |Helper| -Generated Location: (827:22,22 [6] ) +Generated Location: (820:22,22 [6] ) |Helper| diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ViewComponentTagHelperPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ViewComponentTagHelperPassTest.cs index 8200131bbf..8374009cc5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ViewComponentTagHelperPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/ViewComponentTagHelperPassTest.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); @@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); @@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var irDocument = CreateIRDocument(engine, codeDocument); - var vcthFullName = "AspNetCore.test_cshtml.__Generated__TagCloudViewComponentTagHelper"; + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; // Act pass.Execute(codeDocument, irDocument); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs index 74d48a1f8d..99678f74b6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs @@ -1,16 +1,18 @@ // 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.Intermediate; +using Moq; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public class DefaultDocumentWriterTest { - [Fact] - public void WriteDocument_Empty_WritesChecksumAndMarksAutoGenerated() + [Fact] // This test covers the whole process including actual hashing. + public void WriteDocument_EndToEnd_WritesChecksumAndMarksAutoGenerated() { // Arrange var document = new DocumentIntermediateNode(); @@ -36,6 +38,106 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration ignoreLineEndingDifferences: true); } + [Fact] + public void WriteDocument_SHA1_WritesChecksumAndMarksAutoGenerated() + { + // Arrange + var checksumBytes = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }; + + var sourceDocument = Mock.Of(d => + d.FilePath == "test.cshtml" && + d.GetChecksum() == checksumBytes && + d.GetChecksumAlgorithm() == "SHA1"); + + var document = new DocumentIntermediateNode(); + + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var options = RazorCodeGenerationOptions.CreateDefault(); + + var target = CodeTarget.CreateDefault(codeDocument, options); + var writer = new DefaultDocumentWriter(target, options); + + // Act + var result = writer.WriteDocument(codeDocument, document); + + // Assert + var csharp = result.GeneratedCode; + Assert.Equal( +@"#pragma checksum ""test.cshtml"" ""{ff1816ec-aa5e-4d10-87f7-6f4963833460}"" ""74657374"" +// +#pragma warning disable 1591 +#pragma warning restore 1591 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDocument_SHA256_WritesChecksumAndMarksAutoGenerated() + { + // Arrange + var checksumBytes = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }; + + var sourceDocument = Mock.Of(d => + d.FilePath == "test.cshtml" && + d.GetChecksum() == checksumBytes && + d.GetChecksumAlgorithm() == "SHA256"); + + var document = new DocumentIntermediateNode(); + + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var options = RazorCodeGenerationOptions.CreateDefault(); + + var target = CodeTarget.CreateDefault(codeDocument, options); + var writer = new DefaultDocumentWriter(target, options); + + // Act + var result = writer.WriteDocument(codeDocument, document); + + // Assert + var csharp = result.GeneratedCode; + Assert.Equal( +@"#pragma checksum ""test.cshtml"" ""{8829d00f-11b8-4213-878b-770e8597ac16}"" ""74657374"" +// +#pragma warning disable 1591 +#pragma warning restore 1591 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDocument_UnsupportedChecksumAlgorithm_Throws() + { + // Arrange + var checksumBytes = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }; + + var sourceDocument = Mock.Of(d => + d.FilePath == "test.cshtml" && + d.GetChecksum() == checksumBytes && + d.GetChecksumAlgorithm() == "SHA3"); + + var document = new DocumentIntermediateNode(); + + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var options = RazorCodeGenerationOptions.CreateDefault(); + + var target = CodeTarget.CreateDefault(codeDocument, options); + var writer = new DefaultDocumentWriter(target, options); + + // Act & Assert + var exception = Assert.Throws(() => + { + var result = writer.WriteDocument(codeDocument, document); + }); + Assert.Equal( + "The hash algorithm 'SHA3' is not supported for checksum generation. Supported algorithms are: 'SHA1 SHA256'. " + + "Set 'RazorCodeGenerationOptions.SuppressChecksum' to 'True' to suppress automatic checksum generation.", + exception.Message); + } + + + [Fact] public void WriteDocument_Empty_SuppressChecksumTrue_DoesnotWriteChecksum() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs index 1288b1b127..bb53e69947 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", fileName: "import.cshtml"); + var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", fileName: "import.cshtml"); + var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import.cshtml"); var codeDocument = TestRazorCodeDocument.Create("@custom \"world\""); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); @@ -100,8 +100,8 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource1 = TestRazorSourceDocument.Create("@custom \"hello\"", fileName: "import1.cshtml"); - var importSource2 = TestRazorSourceDocument.Create("@custom \"world\"", fileName: "import2.cshtml"); + var importSource1 = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import1.cshtml"); + var importSource2 = TestRazorSourceDocument.Create("@custom \"world\"", filePath: "import2.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource1, options), RazorSyntaxTree.Parse(importSource2, options) }); @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Razor.Language var importSource = TestRazorSourceDocument.Create( @"@code ""code block"" { } @razor ""razor block"" { }", - fileName: "testImports.cshtml"); + filePath: "testImports.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); @@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource = TestRazorSourceDocument.Create("@custom { }", fileName: "import.cshtml"); + var importSource = TestRazorSourceDocument.Create("@custom { }", filePath: "import.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); @@ -196,7 +196,7 @@ namespace Microsoft.AspNetCore.Razor.Language b.AddDirective(directive); }); var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); - var importSource = TestRazorSourceDocument.Create("@custom { }", fileName: "import.cshtml"); + var importSource = TestRazorSourceDocument.Create("@custom { }", filePath: "import.cshtml"); var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineBuilderTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineBuilderTest.cs new file mode 100644 index 0000000000..5323ba3ffa --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineBuilderTest.cs @@ -0,0 +1,65 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineBuilderTest + { + [Fact] + public void Build_AddsFeaturesToRazorEngine() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + + var features = builder.Features.ToArray(); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Collection(projectEngine.Engine.Features, + feature => Assert.Same(features[0], feature), + feature => Assert.Same(features[1], feature)); + } + + [Fact] + public void Build_AddsPhasesToRazorEngine() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + builder.Phases.Add(Mock.Of()); + builder.Phases.Add(Mock.Of()); + + var phases = builder.Phases.ToArray(); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Collection(projectEngine.Engine.Phases, + phase => Assert.Same(phases[0], phase), + phase => Assert.Same(phases[1], phase)); + } + + [Fact] + public void Build_CreatesProjectEngineWithFileSystem() + { + // Arrange + var fileSystem = Mock.Of(); + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, fileSystem); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Same(fileSystem, projectEngine.FileSystem); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs new file mode 100644 index 0000000000..427b34c1b6 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs @@ -0,0 +1,95 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineIntegrationTest + { + [Fact] + public void Process_SetsOptions_Runtime() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var parserOptions = codeDocument.GetParserOptions(); + Assert.False(parserOptions.DesignTime); + + var codeGenerationOptions = codeDocument.GetCodeGenerationOptions(); + Assert.False(codeGenerationOptions.DesignTime); + Assert.False(codeGenerationOptions.SuppressChecksum); + Assert.False(codeGenerationOptions.SuppressMetadataAttributes); + } + + [Fact] + public void ProcessDesignTime_SetsOptions_DesignTime() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + var parserOptions = codeDocument.GetParserOptions(); + Assert.True(parserOptions.DesignTime); + + var codeGenerationOptions = codeDocument.GetCodeGenerationOptions(); + Assert.True(codeGenerationOptions.DesignTime); + Assert.True(codeGenerationOptions.SuppressChecksum); + Assert.True(codeGenerationOptions.SuppressMetadataAttributes); + } + + [Fact] + public void Process_GetsImportsFromFeature() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var testImport = Mock.Of(i => i.Read() == new MemoryStream() && i.FilePath == "testvalue"); + var importFeature = new Mock(); + importFeature + .Setup(feature => feature.GetImports(It.IsAny())) + .Returns(new[] { testImport }); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty, builder => + { + builder.SetImportFeature(importFeature.Object); + }); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var import = Assert.Single(codeDocument.Imports); + Assert.Equal("testvalue", import.FilePath); + } + + [Fact] + public void Process_GeneratesCodeDocumentWithValidCSharpDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var csharpDocument = codeDocument.GetCSharpDocument(); + Assert.NotNull(csharpDocument); + Assert.Empty(csharpDocument.Diagnostics); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs new file mode 100644 index 0000000000..171556ecf0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs @@ -0,0 +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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineTest + { + [Fact] + public void ConvertToSourceDocument_ConvertsNormalImports() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + // Act + var sourceDocument = DefaultRazorProjectEngine.ConvertToSourceDocument(projectItem); + + // Assert + Assert.NotNull(sourceDocument); + } + + [Fact] + public void ConvertToSourceDocument_ConvertsMarkerImports() + { + // Arrange + var projectItem = Mock.Of(item => item.FilePath == "Index.cshtml" && item.Exists == false); + + // Act + var sourceDocument = DefaultRazorProjectEngine.ConvertToSourceDocument(projectItem); + + // Assert + Assert.NotNull(sourceDocument); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs new file mode 100644 index 0000000000..af48d1e900 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectFileSystemTest.cs @@ -0,0 +1,263 @@ +// 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 Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectFileSystemTest + { + private static string TestFolder { get; } = Path.Combine( + TestProject.GetProjectDirectory(typeof(DefaultRazorProjectFileSystemTest)), + "TestFiles", + "DefaultRazorProjectFileSystem"); + + [Theory] + [InlineData(null)] + [InlineData("")] + public void NormalizeAndEnsureValidPath_ThrowsIfPathIsNullOrEmpty(string path) + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act and Assert + ExceptionAssert.ThrowsArgumentNullOrEmptyString(() => fileSystem.NormalizeAndEnsureValidPath(path), "path"); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePath() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath("file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePathWithoutForwardSlash() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath("/file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToForwardSlashes() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem(@"C:\some\test\path\root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath(@"something\file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/something/file.cshtml", absolutePath); + } + + [Fact] + public void EnumerateItems_DiscoversAllCshtmlFiles() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/"); + + // Assert + Assert.Collection( + items.OrderBy(f => f.FilePath), + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal("_ViewImports.cshtml", item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Home.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Home.cshtml"), item.PhysicalPath); + Assert.Equal("Home.cshtml", item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/About/About.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Views/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/Home/Index.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "Index.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "Index.cshtml"), item.RelativePhysicalPath); + }); + } + + [Fact] + public void EnumerateItems_DiscoversAllCshtmlFiles_UnderSpecifiedBasePath() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/Views"); + + // Assert + Assert.Collection( + items.OrderBy(f => f.FilePath), + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/About/About.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("About", "About.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Home/Index.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "Index.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Home", "Index.cshtml"), item.RelativePhysicalPath); + }); + } + + [Fact] + public void EnumerateItems_ReturnsEmptySequence_WhenBasePathDoesNotExist() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/Does-Not-Exist"); + + // Assert + Assert.Empty(items); + } + + [Fact] + public void FindHierarchicalItems_FindsItemsWithMatchingNames() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.FindHierarchicalItems("/Views/Home/Index.cshtml", "_ViewImports.cshtml"); + + // Assert + Assert.Collection( + items, + item => + { + Assert.Equal("/Views/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal("_ViewImports.cshtml", item.RelativePhysicalPath); + + }); + } + + [Fact] + public void GetItem_ReturnsFileFromDisk() + { + // Arrange + var filePath = "/Views/About/About.cshtml"; + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var item = fileSystem.GetItem(filePath); + + // Assert + Assert.True(item.Exists); + Assert.Equal(filePath, item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath); + } + + [Fact] + public void GetItem_ReturnsNotFoundResult() + { + // Arrange + var path = "/NotFound.cshtml"; + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var item = fileSystem.GetItem(path); + + // Assert + Assert.False(item.Exists); + } + + private class TestRazorProjectFileSystem : DefaultRazorProjectFileSystem + { + public TestRazorProjectFileSystem(string root) : base(root) + { + } + + public new string NormalizeAndEnsureValidPath(string path) => base.NormalizeAndEnsureValidPath(path); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectItemTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectItemTest.cs similarity index 65% rename from test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectItemTest.cs rename to test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectItemTest.cs index 638d898e0d..1fa4453bd3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectItemTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectItemTest.cs @@ -6,28 +6,29 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Language { - public class FileSystemRazorProjectItemTest + public class DefaultRazorProjectItemTest { private static string TestFolder { get; } = Path.Combine( - TestProject.GetProjectDirectory(typeof(FileSystemRazorProjectItemTest)), - "TestFiles", - "FileSystemRazorProject"); + TestProject.GetProjectDirectory(typeof(DefaultRazorProjectItemTest)), + "TestFiles", + "DefaultRazorProjectFileSystem"); [Fact] - public void FileSystemRazorProjectItem_SetsProperties() + public void DefaultRazorProjectItem_SetsProperties() { // Arrange var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); // Act - var projectItem = new FileSystemRazorProjectItem("/Views", "/Home.cshtml", fileInfo); + var projectItem = new DefaultRazorProjectItem("/", "/Home.cshtml", "Home.cshtml", fileInfo); // Assert Assert.Equal("/Home.cshtml", projectItem.FilePath); - Assert.Equal("/Views", projectItem.BasePath); + Assert.Equal("/", projectItem.BasePath); Assert.True(projectItem.Exists); Assert.Equal("Home.cshtml", projectItem.FileName); Assert.Equal(fileInfo.FullName, projectItem.PhysicalPath); + Assert.Equal("Home.cshtml", projectItem.RelativePhysicalPath); } [Fact] @@ -37,7 +38,7 @@ namespace Microsoft.AspNetCore.Razor.Language var fileInfo = new FileInfo(Path.Combine(TestFolder, "Views", "FileDoesNotExist.cshtml")); // Act - var projectItem = new FileSystemRazorProjectItem("/Views", "/FileDoesNotExist.cshtml", fileInfo); + var projectItem = new DefaultRazorProjectItem("/Views", "/FileDoesNotExist.cshtml", Path.Combine("Views", "FileDoesNotExist.cshtml"), fileInfo); // Assert Assert.False(projectItem.Exists); @@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); - var projectItem = new FileSystemRazorProjectItem("/", "/Home.cshtml", fileInfo); + var projectItem = new DefaultRazorProjectItem("/", "/Home.cshtml", "Home.cshtml", fileInfo); // Act var stream = projectItem.Read(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs index 968c12bde7..d4fd3c1910 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs @@ -27,22 +27,16 @@ namespace Microsoft.AspNetCore.Razor.Language }; var expectedDiagnostics = new[] { - RazorDiagnostic.Create( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(14 + Environment.NewLine.Length, 1, 14), - length: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\""), - new SourceLocation(14 + Environment.NewLine.Length, 1, 14), - length: 1)) + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(14 + Environment.NewLine.Length, 1, 14), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14 + Environment.NewLine.Length, 1, 14), contentLength: 1), "\"") }; var content = @" @addTagHelper """; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); codeDocument.SetSyntaxTree(originalTree); @@ -72,22 +66,16 @@ namespace Microsoft.AspNetCore.Razor.Language }; var expectedDiagnostics = new[] { - RazorDiagnostic.Create( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\""), - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)) + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1), "\"") }; var content = @" @removeTagHelper """; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); codeDocument.SetSyntaxTree(originalTree); @@ -117,22 +105,16 @@ namespace Microsoft.AspNetCore.Razor.Language }; var expectedDiagnostics = new[] { - RazorDiagnostic.Create( - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue("tagHelperPrefix", "\"", "\""), - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)) + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1), "tagHelperPrefix", '\"', "\""), }; var content = @" @tagHelperPrefix """; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); codeDocument.SetSyntaxTree(originalTree); @@ -431,17 +413,16 @@ namespace Microsoft.AspNetCore.Razor.Language @addTagHelper *, TestAssembly
"; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); var codeDocument = RazorCodeDocument.Create(sourceDocument); var originalTree = RazorSyntaxTree.Parse(sourceDocument); - var initialError = RazorDiagnostic.Create(new RazorError("Initial test error", SourceLocation.Zero, length: 1)); - var expectedRewritingError = RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper("form"), - new SourceLocation(Environment.NewLine.Length * 2 + 30, 2, 1), - length: 4)); + var initialError = RazorDiagnostic.Create( + new RazorDiagnosticDescriptor("RZ9999", () => "Initial test error", RazorDiagnosticSeverity.Error), + new SourceSpan(SourceLocation.Zero, contentLength: 1)); + var expectedRewritingError = RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(Environment.NewLine.Length * 2 + 30, 2, 1), contentLength: 4), "form"); var erroredOriginalTree = RazorSyntaxTree.Create(originalTree.Root, originalTree.Source, new[] { initialError }, originalTree.Options); codeDocument.SetSyntaxTree(erroredOriginalTree); @@ -559,7 +540,7 @@ namespace Microsoft.AspNetCore.Razor.Language string expectedPrefix) { // Arrange - var sourceDocument = TestRazorSourceDocument.Create(source, fileName: "TestFile"); + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); var parser = new RazorParser(); var syntaxTree = parser.Parse(sourceDocument); var visitor = new DefaultRazorTagHelperBinderPhase.DirectiveVisitor(tagHelpers: new List()); @@ -725,7 +706,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var expected = (TagHelperDescriptor[])expectedDescriptors; - var sourceDocument = TestRazorSourceDocument.Create(source, fileName: "TestFile"); + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); var parser = new RazorParser(); var syntaxTree = parser.Parse(sourceDocument); var visitor = new DefaultRazorTagHelperBinderPhase.DirectiveVisitor((TagHelperDescriptor[])tagHelpers); @@ -869,7 +850,7 @@ namespace Microsoft.AspNetCore.Razor.Language object tagHelpers) { // Arrange - var sourceDocument = TestRazorSourceDocument.Create(source, fileName: "TestFile"); + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); var parser = new RazorParser(); var syntaxTree = parser.Parse(sourceDocument); var visitor = new DefaultRazorTagHelperBinderPhase.DirectiveVisitor((TagHelperDescriptor[])tagHelpers); @@ -904,7 +885,7 @@ namespace Microsoft.AspNetCore.Razor.Language "; - var sourceDocument = TestRazorSourceDocument.Create(content, fileName: null); + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); return sourceDocument; } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultMetadataIdentifierFeatureTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultMetadataIdentifierFeatureTest.cs new file mode 100644 index 0000000000..38ea7f32c3 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultMetadataIdentifierFeatureTest.cs @@ -0,0 +1,72 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class DefaultMetadataIdentifierFeatureTest + { + [Fact] + public void GetIdentifier_ReturnsNull_ForNullRelativePath() + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", null)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = RazorEngine.Create(), + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Null(result); + } + + [Fact] + public void GetIdentifier_ReturnsNull_ForEmptyRelativePath() + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", string.Empty)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = RazorEngine.Create(), + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Null(result); + } + + [Theory] + [InlineData("Test.cshtml", "/Test.cshtml")] + [InlineData("/Test.cshtml", "/Test.cshtml")] + [InlineData("\\Test.cshtml", "/Test.cshtml")] + [InlineData("\\About\\Test.cshtml", "/About/Test.cshtml")] + [InlineData("\\About\\Test\\cshtml", "/About/Test/cshtml")] + public void GetIdentifier_SanitizesRelativePath(string relativePath, string expected) + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", relativePath)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = RazorEngine.Create(), + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Equal(expected, result); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs index 79aba5837c..dcb8d6d6ff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/DefaultTagHelperTargetExtensionTest.cs @@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperBody_DesignTime_WritesChildren() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions public void WriteTagHelperCreate_DesignTime_RendersCorrectly_UsesSpecifiedTagHelperType() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -190,7 +190,7 @@ __tagHelperExecutionContext.Add(__TestNamespace_MyTagHelper); public void WriteTagHelperExecute_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -243,7 +243,7 @@ __tagHelperExecutionContext = __tagHelperScopeManager.End(); public void WriteTagHelperHtmlAttribute_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -359,11 +359,79 @@ EndAddHtmlAttributeValues(__tagHelperExecutionContext); ignoreLineEndingDifferences: true); } + [Fact] + public void RenderTagHelperAttributeInline_NonString_StatementInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = false, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_CodeBlocksNotSupportedInAttributes(expectedLocation); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new CSharpCodeIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RenderTagHelperAttributeInline_NonStringIndexerMatch_TemplateInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = true, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(expectedLocation, "System.Int32"); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new TemplateIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RenderTagHelperAttributeInline_NonString_TemplateInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = false, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes( + expectedLocation, + "System.Collections.Generic.Dictionary"); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new TemplateIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + [Fact] public void WriteTagHelperProperty_DesignTime_StringProperty_HtmlContent_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -404,7 +472,7 @@ __InputTagHelper.StringProp = ""value""; public void WriteTagHelperProperty_DesignTime_StringProperty_NonHtmlContent_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -445,7 +513,7 @@ __InputTagHelper.StringProp = string.Empty; public void WriteTagHelperProperty_DesignTime_NonStringProperty_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -492,7 +560,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringProperty_SecondUseOfAttribute() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -534,7 +602,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringProperty_RendersCorrectly_WithoutLocation() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -574,7 +642,7 @@ __InputTagHelper.IntProp = 32; public void WriteTagHelperProperty_DesignTime_NonStringIndexer_RendersCorrectly() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -619,7 +687,7 @@ __InputTagHelper.IntIndexer[""bound""] = 32; public void WriteTagHelperProperty_DesignTime_NonStringIndexer_RendersCorrectly_WithoutLocation() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var tagHelperNode = new TagHelperIntermediateNode(); @@ -996,7 +1064,7 @@ __tagHelperExecutionContext.AddTagHelperAttribute(""foo-bound"", __InputTagHelpe public void WriteTagHelperRuntime_DesignTime_WritesNothing() { // Arrange - var extension = new DefaultTagHelperTargetExtension() { DesignTime = true }; + var extension = new DefaultTagHelperTargetExtension(); var context = TestCodeRenderingContext.CreateDesignTime(); var node = new DefaultTagHelperRuntimeIntermediateNode(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributePassTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributePassTest.cs new file mode 100644 index 0000000000..05e54da54d --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributePassTest.cs @@ -0,0 +1,362 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class MetadataAttributePassTest + { + [Fact] + public void Execute_NullCodeGenerationOptions_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + NoChildren(irDocument); + } + + [Fact] + public void Execute_SuppressMetadataAttributes_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(o => + { + o.SuppressMetadataAttributes = true; + }), + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + NoChildren(irDocument); + } + + [Fact] + public void Execute_NoNamespaceSet_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoClassNameSet_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoDocumentKind_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoIdentifier_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, null)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_HasRequiredInfo_AddsItemAndSourceChecksum() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, "Foo\\Bar.cshtml")); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal(2, irDocument.Children.Count); + + var item = Assert.IsType(irDocument.Children[0]); + Assert.Equal("/Foo/Bar.cshtml", item.Identifier); + Assert.Equal("test", item.Kind); + Assert.Equal("Some.Namespace.Test", item.TypeName); + + Assert.Equal(2, @namespace.Children.Count); + var checksum = Assert.IsType(@namespace.Children[0]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Bar.cshtml", checksum.Identifier); + } + + [Fact] + public void Execute_HasRequiredInfo_AndImport_AddsItemAndSourceChecksum() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, "Foo\\Bar.cshtml")); + var import = TestRazorSourceDocument.Create("@using System", new RazorSourceDocumentProperties(null, "Foo\\Import.cshtml")); + var codeDocument = RazorCodeDocument.Create(sourceDocument, new[] { import, }); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal(2, irDocument.Children.Count); + + var item = Assert.IsType(irDocument.Children[0]); + Assert.Equal("/Foo/Bar.cshtml", item.Identifier); + Assert.Equal("test", item.Kind); + Assert.Equal("Some.Namespace.Test", item.TypeName); + + Assert.Equal(3, @namespace.Children.Count); + var checksum = Assert.IsType(@namespace.Children[0]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Bar.cshtml", checksum.Identifier); + + checksum = Assert.IsType(@namespace.Children[1]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Import.cshtml", checksum.Identifier); + } + + private static RazorEngine CreateEngine() + { + return RazorEngine.Create(b => + { + b.Features.Add(new DefaultMetadataIdentifierFeature()); + }); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributeTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributeTargetExtensionTest.cs new file mode 100644 index 0000000000..9f8a280f73 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/MetadataAttributeTargetExtensionTest.cs @@ -0,0 +1,69 @@ +// 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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class MetadataAttributeTargetExtensionTest + { + [Fact] + public void WriteRazorCompiledItemAttribute_RendersCorrectly() + { + // Arrange + var extension = new MetadataAttributeTargetExtension() + { + CompiledItemAttributeName = "global::TestItem", + }; + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new RazorCompiledItemAttributeIntermediateNode() + { + TypeName = "Foo.Bar", + Kind = "test", + Identifier = "Foo/Bar", + }; + + // Act + extension.WriteRazorCompiledItemAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"[assembly: global::TestItem(typeof(Foo.Bar), @""test"", @""Foo/Bar"")] +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteRazorSourceChecksumAttribute_RendersCorrectly() + { + // Arrange + var extension = new MetadataAttributeTargetExtension() + { + SourceChecksumAttributeName = "global::TestChecksum", + }; + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new RazorSourceChecksumAttributeIntermediateNode() + { + ChecksumAlgorithm = "SHA1", + Checksum = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }, + Identifier = "Foo/Bar", + }; + + // Act + extension.WriteRazorSourceChecksumAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"[global::TestChecksum(@""SHA1"", @""74657374"", @""Foo/Bar"")] +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs deleted file mode 100644 index 98a22f4fc5..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs +++ /dev/null @@ -1,171 +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.IO; -using System.Linq; -using Microsoft.AspNetCore.Testing; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language -{ - public class FileSystemRazorProjectTest - { - private static string TestFolder { get; } = Path.Combine( - TestProject.GetProjectDirectory(typeof(FileSystemRazorProjectTest)), - "TestFiles", - "FileSystemRazorProject"); - - [Theory] - [InlineData(null)] - [InlineData("")] - public void NormalizeAndEnsureValidPath_ThrowsIfPathIsNullOrEmpty(string path) - { - // Arrange - var project = new TestFileSystemRazorProject("C:/some/test/path/root"); - - // Act and Assert - ExceptionAssert.ThrowsArgumentNullOrEmptyString(() => project.NormalizeAndEnsureValidPath(path), "path"); - } - - [Fact] - public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePath() - { - // Arrange - var project = new TestFileSystemRazorProject("C:/some/test/path/root"); - - // Act - var absolutePath = project.NormalizeAndEnsureValidPath("file.cshtml"); - - // Assert - Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); - } - - [Fact] - public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePathWithoutForwardSlash() - { - // Arrange - var project = new TestFileSystemRazorProject("C:/some/test/path/root"); - - // Act - var absolutePath = project.NormalizeAndEnsureValidPath("/file.cshtml"); - - // Assert - Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); - } - - [Fact] - public void NormalizeAndEnsureValidPath_NormalizesToForwardSlashes() - { - // Arrange - var project = new TestFileSystemRazorProject(@"C:\some\test\path\root"); - - // Act - var absolutePath = project.NormalizeAndEnsureValidPath(@"something\file.cshtml"); - - // Assert - Assert.Equal("C:/some/test/path/root/something/file.cshtml", absolutePath); - } - - [Fact] - public void EnumerateItems_DiscoversAllCshtmlFiles() - { - // Arrange - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var files = fileSystemProject.EnumerateItems("/"); - - // Assert - Assert.Collection(files.OrderBy(f => f.FilePath), - file => - { - Assert.Equal("/Home.cshtml", file.FilePath); - Assert.Equal("/", file.BasePath); - }, - file => - { - Assert.Equal("/Views/About/About.cshtml", file.FilePath); - Assert.Equal("/", file.BasePath); - }, - file => - { - Assert.Equal("/Views/Home/Index.cshtml", file.FilePath); - Assert.Equal("/", file.BasePath); - }); - } - - [Fact] - public void EnumerateItems_DiscoversAllCshtmlFiles_UnderSpecifiedBasePath() - { - // Arrange - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var files = fileSystemProject.EnumerateItems("/Views"); - - // Assert - Assert.Collection(files.OrderBy(f => f.FilePath), - file => - { - Assert.Equal("/About/About.cshtml", file.FilePath); - Assert.Equal("/Views", file.BasePath); - }, - file => - { - Assert.Equal("/Home/Index.cshtml", file.FilePath); - Assert.Equal("/Views", file.BasePath); - }); - } - - [Fact] - public void EnumerateItems_ReturnsEmptySequence_WhenBasePathDoesNotExist() - { - // Arrange - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var files = fileSystemProject.EnumerateItems("/Does-Not-Exist"); - - // Assert - Assert.Empty(files); - } - - [Fact] - public void GetItem_ReturnsFileFromDisk() - { - // Arrange - var path = "/Views/About/About.cshtml"; - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var file = fileSystemProject.GetItem(path); - - // Assert - Assert.True(file.Exists); - Assert.Equal(path, file.FilePath); - } - - [Fact] - public void GetItem_ReturnsNotFoundResult() - { - // Arrange - var path = "/NotFound.cshtml"; - var fileSystemProject = new FileSystemRazorProject(TestFolder); - - // Act - var file = fileSystemProject.GetItem(path); - - // Assert - Assert.False(file.Exists); - } - - private class TestFileSystemRazorProject : FileSystemRazorProject - { - public TestFileSystemRazorProject(string root) : base(root) - { - } - - public new string NormalizeAndEnsureValidPath(string path) => base.NormalizeAndEnsureValidPath(path); - } - } -} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs index cac3abd762..56c22c8105 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs @@ -78,12 +78,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.Create(); - var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@!!!", fileName: "test.cshtml")); + var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@!!!", filePath: "test.cshtml")); - var expected = RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"), - new SourceLocation("test.cshtml", 1, 0, 1), - length: 1)); + var expected = RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation("test.cshtml", 1, 0, 1), contentLength: 1), + "!"); // Act engine.Process(document); @@ -100,12 +99,10 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.CreateDesignTime(); - var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@{", fileName: "test.cshtml")); + var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@{", filePath: "test.cshtml")); - var expected = RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation("test.cshtml", 1, 0, 1), - length: 1)); + var expected = RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation("test.cshtml", 1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"); // Act engine.Process(document); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs index f8de2ce59c..673f6ac7fa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -885,7 +885,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.CreateDesignTime(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); // Some of these tests use templates builder.AddTargetExtension(new TemplateTargetExtension()); @@ -911,7 +911,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.Create(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); // Some of these tests use templates builder.AddTargetExtension(new TemplateTargetExtension()); @@ -936,7 +936,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.Create(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); builder.AddTagHelpers(descriptors); // Some of these tests use templates @@ -962,7 +962,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.CreateDesignTime(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); builder.AddTagHelpers(descriptors); // Some of these tests use templates diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs index 3428fadde8..1074b1052a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ExtensibleDirectiveTest.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange var engine = RazorEngine.CreateDesignTime(builder => { - builder.Features.Add(new ApiSetsIRTestAdapter()); + builder.ConfigureDocumentClassifier(); builder.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken())); }); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs index b5cd18e7ff..ad26823b85 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs @@ -12,39 +12,35 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithDefaults() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") + var fileSystem = new DefaultRazorProjectFileSystem(TestProjectRoot); + var razorEngine = RazorEngine.Create(engine => { - Content = content, - }; - var project = new TestRazorProject(new[]{ projectItem }); - var razorEngine = RazorEngine.Create(); - var templateEngine = new RazorTemplateEngine(razorEngine, project); + engine.Features.Add(new SuppressChecksumOptionsFeature()); + }); + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem); // Act - var resultcSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert - AssertCSharpDocumentMatchesBaseline(resultcSharpDocument); + AssertCSharpDocumentMatchesBaseline(cSharpDocument); } [Fact] public void GenerateCodeWithBaseType() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") + var fileSystem = new DefaultRazorProjectFileSystem(TestProjectRoot); + var razorEngine = RazorEngine.Create(engine => { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); - var razorEngine = RazorEngine.Create(engine => engine.SetBaseType("MyBaseType")); - var templateEngine = new RazorTemplateEngine(razorEngine, project); + engine.Features.Add(new SuppressChecksumOptionsFeature()); + + engine.SetBaseType("MyBaseType"); + }); + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); @@ -54,15 +50,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithConfigureClass() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") - { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); + var fileSystem = new DefaultRazorProjectFileSystem(TestProjectRoot); var razorEngine = RazorEngine.Create(engine => { + engine.Features.Add(new SuppressChecksumOptionsFeature()); + engine.ConfigureClass((document, @class) => { @class.ClassName = "MyClass"; @@ -78,10 +70,10 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests @class.BaseType = "CustomBaseType"; }); }); - var templateEngine = new RazorTemplateEngine(razorEngine, project); + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); @@ -91,21 +83,17 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithSetNamespace() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") - { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); + var fileSystem = new DefaultRazorProjectFileSystem(TestProjectRoot); var razorEngine = RazorEngine.Create(engine => { + engine.Features.Add(new SuppressChecksumOptionsFeature()); + engine.SetNamespace("MyApp.Razor.Views"); }); - var templateEngine = new RazorTemplateEngine(razorEngine, project); + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs index bf61974524..fb47799b23 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var contentString = "Hello World"; var stream = TestRazorSourceDocument.CreateStreamContent(contentString); var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); - var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var firstChecksum = document.GetChecksum(); @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var contentString = "Hello World"; var stream = TestRazorSourceDocument.CreateStreamContent(contentString); var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); - var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 10, 77, 85, 168, 215, 120, 229, 2, 47, 171, 112, 25, 119, 197, 216, 64, 187, 196, 134, 208 }; // Act @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var contentString = "Hello World"; var stream = TestRazorSourceDocument.CreateStreamContent(contentString, Encoding.UTF32); var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); - var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF32, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF32, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 108, 172, 130, 171, 42, 19, 155, 176, 211, 80, 224, 121, 169, 133, 25, 134, 48, 228, 199, 141 }; // Act @@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var stream = TestRazorSourceDocument.CreateStreamContent(new string(content)); var reader = new StreamReader(stream, true); - var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var output = new char[contentLength]; @@ -106,12 +106,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var reader = new StreamReader(stream, true); // Act - var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, filePath); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: filePath, relativePath: null)); // Assert Assert.Equal(filePath, document.FilePath); } + [Theory] + [InlineData("test.cshtml")] + [InlineData(null)] + public void RelativePath(string relativePath) + { + // Arrange + var stream = TestRazorSourceDocument.CreateStreamContent("abc"); + var reader = new StreamReader(stream, true); + + // Act + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: relativePath)); + + // Assert + Assert.Equal(relativePath, document.RelativePath); + } + [Fact] public void Lines() { @@ -120,7 +136,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var reader = new StreamReader(stream, true); // Act - var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Assert Assert.Equal(3, document.Lines.Count); @@ -142,7 +158,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test var stream = TestRazorSourceDocument.CreateStreamContent("abcdefghijklmnopqrstuvwxyz"); var reader = new StreamReader(stream, true); - var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, "file.cshtml"); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var destination = new char[1000]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs index dc57fb1147..4b4f984ce6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/BlockTest.cs @@ -44,6 +44,26 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Assert.Equal(2, parentBlock.Length); } + [Fact] + public void Clone_ClonesBlock() + { + // Arrange + var blockBuilder = new BlockBuilder() + { + ChunkGenerator = new DynamicAttributeBlockChunkGenerator(new LocationTagged("class=\"", SourceLocation.Zero), 0, 0, 0), + Type = BlockKindInternal.Expression, + }; + blockBuilder.Children.Add(new SpanBuilder(new SourceLocation(1, 2, 3)).Build()); + var block = blockBuilder.Build(); + + // Act + var copy = (Block)block.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, block); + Assert.NotSame(block, copy); + } + [Fact] public void ConstructorWithBlockBuilderSetsParent() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs index 9f0e9f1fba..13633efdd1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs @@ -16,11 +16,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(FunctionsDirective.Directive.Directive, "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), FunctionsDirective.Directive.Directive, "}", "{")); // Act & Assert ParseBlockTest( @@ -38,11 +35,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "section", "}", "{")); // Act & Assert ParseBlockTest( @@ -71,11 +65,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsStatement() .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -84,11 +75,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -107,11 +95,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "section", "}", "{")); // Act & Assert ParseBlockTest( @@ -152,11 +137,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Span(SpanKindInternal.Code, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown)) .With(new StatementChunkGenerator()) ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs index 5972dabb25..fa22393a46 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs @@ -148,10 +148,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ImplicitExpressionTest( "Html.En(code()", "Html.En(code()", AcceptedCharactersInternal.Any, - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(8, 0, 8), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "(", ")")); } [Fact] @@ -499,10 +497,8 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara document, BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -514,14 +510,10 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara document, BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.ParseError_BlockComment_Not_Terminated, - new SourceLocation(24, 0, 24), - length: 1), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_BlockCommentNotTerminated( + new SourceSpan(new SourceLocation(24, 0, 24), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -533,10 +525,8 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara document, BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -1151,16 +1141,12 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); 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 RazorError[] + var expectedErrors = new RazorDiagnostic[] { - new RazorError( - @"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.", - new SourceLocation(2, 0, 2), - length: 4), - new RazorError( - @"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.", - SourceLocation.Zero, - length: 1), + 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 @@ -1194,16 +1180,13 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None))), Factory.EmptyCSharp().AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)); - var expectedErrors = new RazorError[] + var expectedErrors = new RazorDiagnostic[] { - new RazorError( - @"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.", - new SourceLocation(13, 0, 13), - length: 1), - new RazorError( - @"""' />}"" is not valid at the start of a code block. Only identifiers, keywords, comments, ""("" and ""{"" are valid.", - new SourceLocation(15, 0, 15), - length: 5), + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 5), + "' />}"), }; // Act & Assert @@ -1251,22 +1234,13 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); ParseBlockTest(prefix + markup + suffix, expected); } - private void NamespaceImportTest(string content, string expectedNS, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.None, string errorMessage = null, SourceLocation? location = null) + private void NamespaceImportTest(string content, string expectedNS, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.None, SourceLocation? location = null) { - var errors = new RazorError[0]; - if (!string.IsNullOrEmpty(errorMessage) && location.HasValue) - { - errors = new RazorError[] - { - new RazorError(errorMessage, location.Value, length: 1) - }; - } ParseBlockTest(content, new DirectiveBlock( Factory.Code(content) .AsNamespaceImport(expectedNS) - .Accepts(acceptedCharacters)), - errors); + .Accepts(acceptedCharacters))); } private static StatementBlock CreateStatementBlock(MarkupBlock block) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs index 29cdff255b..98cda93282 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs @@ -60,10 +60,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDuplicateDirective("custom"), - 42 + Environment.NewLine.Length, 1, 0, 7))); + RazorDiagnosticFactory.CreateParsing_DuplicateDirective( + new SourceSpan(new SourceLocation(42 + Environment.NewLine.Length, 1, 0), 7), "custom")); // Act & Assert ParseDocumentTest( @@ -202,10 +200,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken().AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveTokensMustBeSeparatedByWhitespace("custom"), - 17, 0, 17, 9))); + RazorDiagnosticFactory.CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace( + new SourceSpan(new SourceLocation(17, 0, 17), 9), "custom")); // Act & Assert ParseCodeBlockTest( @@ -228,10 +224,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -253,10 +247,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -277,10 +269,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -302,10 +292,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -386,7 +374,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "*, Foo", "*", "Foo", - new RazorError(Resources.FormatDirectiveMustAppearAtStartOfLine("addTagHelper"), new SourceLocation(4, 0, 4), 12))), + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(4, 0, 4), 12), "addTagHelper"))), Factory.Code(Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); } @@ -401,11 +390,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddTypeToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveMustAppearAtStartOfLine("custom"), - new SourceLocation(4, 0, 4), - 6))); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 6), "custom")); // Act & Assert ParseCodeBlockTest( @@ -541,11 +527,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -567,11 +550,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "custom")); // Act & Assert ParseCodeBlockTest( @@ -593,11 +573,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 9))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 9), "custom")); // Act & Assert ParseCodeBlockTest( @@ -619,11 +596,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -761,11 +735,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddMemberToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier("custom"), - new SourceLocation(8, 0, 8), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "custom")); // Act & Assert ParseCodeBlockTest( @@ -887,11 +858,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral("custom", "line break"), - new SourceLocation(16, 0, 16), - length: 7))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 7), "custom", "line break")); // Act & Assert ParseCodeBlockTest( @@ -916,11 +884,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral("custom", "{"), - new SourceLocation(16, 0, 16), - length: 5))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 5), "custom", "{")); // Act & Assert ParseCodeBlockTest( @@ -945,11 +910,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective("custom", "{"), - new SourceLocation(15, 0, 15), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "custom", "{")); // Act & Assert ParseCodeBlockTest( @@ -972,11 +934,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("custom", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "custom", "}", "{")); // Act & Assert ParseCodeBlockTest( @@ -998,8 +957,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Arrange var expectedDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( - "tagHelperPrefix", - new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16)); + new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16), "tagHelperPrefix"); // Act var document = ParseDocument( @@ -1068,9 +1026,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public void TagHelperPrefixDirective_RequiresValue() { // Arrange - var expectedError = new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15); + var expectedError = RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 15), SyntaxConstants.CSharp.TagHelperPrefixKeyword); // Act & Assert ParseBlockTest("@tagHelperPrefix ", @@ -1093,15 +1050,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, '"', "\"Foo"), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4) + 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 @@ -1124,15 +1078,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 23, lineIndex: 0, columnIndex: 23, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 7), - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, ' ', "Foo \""), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 7) + 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 @@ -1154,10 +1105,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(18, 0, 18), - length: 1) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(18, 0, 18), contentLength: 1), string.Empty) }; ParseBlockTest("@removeTagHelper \"\"", @@ -1173,7 +1122,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsRemoveTagHelper( "\"\"", string.Empty, - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1181,10 +1130,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(17, 0, 17), - length: 3) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 3), "Foo") }; ParseBlockTest("@removeTagHelper Foo", @@ -1200,7 +1147,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsRemoveTagHelper( "Foo", "Foo", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1208,10 +1155,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("'*, Foo'"), - new SourceLocation(17, 0, 17), - length: 8) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 8), "'*, Foo'") }; ParseBlockTest("@removeTagHelper '*, Foo'", @@ -1225,7 +1170,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsRemoveTagHelper( "'*, Foo'", "'*, Foo'", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1233,10 +1178,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(18, 0, 18), - length: 3) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(18, 0, 18), contentLength: 3), "Foo") }; ParseBlockTest("@removeTagHelper \"Foo\"", @@ -1252,7 +1195,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsRemoveTagHelper( "\"Foo\"", "Foo", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1280,13 +1223,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15), - new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(17, 0, 17), - length: 1), + 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 @@ -1298,7 +1238,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.EmptyCSharp() - .AsRemoveTagHelper(string.Empty, string.Empty, legacyErrors: expectedErrors) + .AsRemoveTagHelper(string.Empty, string.Empty, errors: expectedErrors) .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); } @@ -1308,16 +1248,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\"Foo"), - new SourceLocation(17, 0, 17), - length: 4), + 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 @@ -1331,7 +1267,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.Code("\"Foo") - .AsRemoveTagHelper("\"Foo", "\"Foo", legacyErrors: expectedErrors))); + .AsRemoveTagHelper("\"Foo", "\"Foo", errors: expectedErrors))); } [Fact] @@ -1340,16 +1276,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 20, lineIndex: 0, columnIndex: 20, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo\""), - new SourceLocation(17, 0, 17), - length: 4), + 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 @@ -1363,7 +1295,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.Code("Foo\"") - .AsRemoveTagHelper("Foo\"", "Foo\"", legacyErrors: expectedErrors) + .AsRemoveTagHelper("Foo\"", "Foo\"", errors: expectedErrors) .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); } @@ -1372,10 +1304,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(15, 0, 15), - length: 1) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), string.Empty), }; ParseBlockTest("@addTagHelper \"\"", @@ -1391,7 +1321,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsAddTagHelper( "\"\"", string.Empty, - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1399,10 +1329,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(14, 0, 14), - length: 3) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 3), "Foo"), }; ParseBlockTest("@addTagHelper Foo", @@ -1416,7 +1344,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsAddTagHelper( "Foo", "Foo", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1424,10 +1352,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(15, 0, 15), - length: 3) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 3), "Foo") }; ParseBlockTest("@addTagHelper \"Foo\"", @@ -1443,7 +1369,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsAddTagHelper( "\"Foo\"", "Foo", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1451,10 +1377,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - new RazorError( - Resources.FormatInvalidTagHelperLookupText("'*, Foo'"), - new SourceLocation(14, 0, 14), - length: 8) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 8), "'*, Foo'") }; ParseBlockTest("@addTagHelper '*, Foo'", @@ -1468,7 +1392,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsAddTagHelper( "'*, Foo'", "'*, Foo'", - legacyErrors: expectedErrors))); + errors: expectedErrors))); } [Fact] @@ -1498,13 +1422,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 12), - new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(14, 0, 14), - length: 1), + 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 @@ -1518,7 +1439,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.EmptyCSharp() - .AsAddTagHelper(string.Empty, string.Empty, legacyErrors: expectedErrors) + .AsAddTagHelper(string.Empty, string.Empty, errors: expectedErrors) .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); } @@ -1528,16 +1449,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\"Foo"), - new SourceLocation(14, 0, 14), - length: 4), + 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 @@ -1551,7 +1468,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.Code("\"Foo") - .AsAddTagHelper("\"Foo", "\"Foo", legacyErrors: expectedErrors))); + .AsAddTagHelper("\"Foo", "\"Foo", errors: expectedErrors))); } [Fact] @@ -1560,16 +1477,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1), - new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4), - new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo\""), - new SourceLocation(14, 0, 14), - length: 4), + 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 @@ -1583,7 +1496,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Span(SpanKindInternal.Markup, " ", markup: false) .Accepts(AcceptedCharactersInternal.None), Factory.Code("Foo\"") - .AsAddTagHelper("Foo\"", "Foo\"", legacyErrors: expectedErrors) + .AsAddTagHelper("Foo\"", "Foo\"", errors: expectedErrors) .Accepts(AcceptedCharactersInternal.AnyExceptNewline))); } @@ -1865,24 +1778,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var directiveLocation = new SourceLocation(1, 2, 3); - var invalidTagHelperPrefixValueError = - "Invalid tag helper directive '{0}' value. '{1}' is not allowed in prefix '{2}'."; + RazorDiagnostic InvalidPrefixError(int length, char character, string prefix) + { + return RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(directiveLocation, length), SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix); + } - return new TheoryData> + return new TheoryData> { { "th ", directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - ' ', - "th "), - directiveLocation, - length: 3) + InvalidPrefixError(3, ' ', "th "), } }, { @@ -1890,14 +1799,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '\t', - "th\t"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '\t', "th\t"), } }, { @@ -1905,14 +1807,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - Environment.NewLine[0], - "th" + Environment.NewLine), - directiveLocation, - length: 2 + Environment.NewLine.Length) + InvalidPrefixError(2 + Environment.NewLine.Length, Environment.NewLine[0], "th" + Environment.NewLine), } }, { @@ -1920,14 +1815,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - ' ', - " th "), - directiveLocation, - length: 4) + InvalidPrefixError(4, ' ', " th "), } }, { @@ -1935,14 +1823,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '@', - "@"), - directiveLocation, - length: 1) + InvalidPrefixError(1, '@', "@"), } }, { @@ -1950,14 +1831,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '@', - "t@h"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '@', "t@h"), } }, { @@ -1965,14 +1839,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '!', - "!"), - directiveLocation, - length: 1) + InvalidPrefixError(1, '!', "!"), } }, { @@ -1980,14 +1847,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '!', - "!th"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '!', "!th"), } }, }; @@ -2002,7 +1862,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedErrors) { // Arrange - var expectedDiagnostics = ((IEnumerable)expectedErrors).Select(RazorDiagnostic.Create); + var expectedDiagnostics = (IEnumerable)expectedErrors; var source = TestRazorSourceDocument.Create(); var options = RazorParserOptions.CreateDefault(); var context = new ParserContext(source, options); @@ -2072,22 +1932,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var parser = new CSharpCodeParser(context); - var expectedErrorMessage = string.Format( - "Invalid tag helper directive look up text '{0}'. The correct look up text " + - "format is: \"name, assemblyName\".", - directiveText); - var directive = new CSharpCodeParser.ParsedDirective() { DirectiveText = directiveText }; var diagnostics = new List(); - var expectedError = RazorDiagnostic.Create( - new RazorError( - expectedErrorMessage, - new SourceLocation(1, 2, 3), - errorLength)); + 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); @@ -2103,11 +1955,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string document, IEnumerable descriptors, Block expected, - params RazorError[] expectedErrors) + params RazorDiagnostic[] expectedErrors) { var result = ParseCodeBlock(document, descriptors, designTime: false); - EvaluateResults(result, expected, expectedErrors.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateResults(result, expected, expectedErrors); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs index d9be2f5e7b..4d792c1a31 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs @@ -19,10 +19,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace) ), - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS('"'), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "\"")); } [Fact] @@ -34,10 +33,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code("helper") .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.FormatParseError_HelperDirectiveNotAvailable(SyntaxConstants.CSharp.HelperKeyword), - new SourceLocation(1, 0, 1), - length: 6)); + RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 6))); + } + + [Fact] + public void ParseBlockWithNestedCodeBlockProducesError() + { + 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))); } [Fact] @@ -60,10 +80,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsStatement() .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -88,10 +106,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(1, 0, 1), - Environment.NewLine.Length)); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), Environment.NewLine.Length))); } [Fact] @@ -113,10 +129,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" {}" + Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(6 + Environment.NewLine.Length, 1, 5), - length: 3)); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 3))); } [Fact] @@ -136,13 +150,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), Factory.EmptyCSharp().AsStatement() ), - new RazorError( - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - 6 + Environment.NewLine.Length, 1, 5, length: 1), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - SourceLocation.Zero, - length: 1)); + 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] @@ -154,10 +165,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "!")); } [Fact] @@ -169,10 +179,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), Factory.Code($"foo bar{Environment.NewLine}baz").AsExpression() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_ExplicitExpression, ")", "(")); } [Fact] @@ -186,10 +194,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), Factory.Code($"foo bar{Environment.NewLine}").AsExpression() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_ExplicitExpression, ")", "(")); } [Fact] @@ -201,10 +207,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code("Href(" + Environment.NewLine) .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(4, 0, 4), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); } [Fact] @@ -218,10 +222,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}Boz") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(3, 0, 3), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "(", ")")); } [Fact] @@ -237,10 +239,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(3, 0, 3), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "(", ")")); } [Fact] @@ -254,10 +254,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}Boz") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"), - new SourceLocation(3, 0, 3), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "[", "]")); } [Fact] @@ -273,10 +271,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}") .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"), - new SourceLocation(3, 0, 3), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "[", "]")); } // Simple EOF handling errors: @@ -289,11 +285,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" var foo = bar; if(foo != null) { bar(); } ") .AsStatement() .AutoCompleteWith("}")), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -302,11 +295,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", '}', '{'), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -332,10 +322,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else", '}', '{'), - new SourceLocation(19, 0, 19), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else", "}", "{")); } [Fact] @@ -345,10 +333,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else if", '}', '{'), - new SourceLocation(19, 0, 19), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else if", "}", "{")); } [Fact] @@ -358,10 +344,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "do", "}", "{")); } [Fact] @@ -371,10 +355,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("try", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "try", "}", "{")); } [Fact] @@ -384,10 +366,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("catch", '}', '{'), - new SourceLocation(15, 0, 15), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "catch", "}", "{")); } [Fact] @@ -397,10 +377,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("finally", '}', '{'), - new SourceLocation(15, 0, 15), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "finally", "}", "{")); } [Fact] @@ -442,7 +420,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void ParseBlockRequiresControlFlowStatementsToHaveBraces() { - var expectedMessage = LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", "<"); + 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(), @@ -464,9 +442,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None)), Factory.EmptyCSharp().AsStatement() ), - new RazorError(expectedMessage, 8, 0, 8, 1), - new RazorError(expectedMessage, 32, 0, 32, 1), - new RazorError(expectedMessage, 48, 0, 48, 1)); + 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), "{", "<")); } [Fact] @@ -476,10 +457,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo)) { var bar = foo; }").AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", ")"), - new SourceLocation(7, 0, 7), - length: 1)); + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "{", ")")); } [Fact] @@ -497,10 +476,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), Factory.Code("}").AsStatement() ), - new RazorError( - LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, - new SourceLocation(10, 0, 10), - length: 1)); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1))); } [Fact] @@ -511,10 +488,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo bar" + Environment.NewLine).AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(2, 0, 2), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), "(", ")")); } [Fact] @@ -525,10 +500,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("foreach(foo bar" + Environment.NewLine).AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(7, 0, 7), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "(", ")")); } [Fact] @@ -539,10 +512,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("do { } while(foo bar" + Environment.NewLine).AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(12, 0, 12), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1), "(", ")")); } [Fact] @@ -553,10 +524,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("using(foo bar" + Environment.NewLine).AsStatement() ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(5, 0, 5), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 1), "(", ")")); } [Fact] @@ -574,10 +543,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(2, 0, 2), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), "(", ")")); } [Fact] @@ -588,24 +555,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + ";" + Environment.NewLine + "}", BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(21 + Environment.NewLine.Length, 1, 12), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(21 + Environment.NewLine.Length, 1, 12), contentLength: 1))); } [Fact] public void ParseBlockTerminatesNormalStringAtEndOfFile() { SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(20, 0, 20), - length: 1), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); } [Fact] @@ -617,14 +578,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "blah " + Environment.NewLine + "blah", BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(20, 0, 20), - length: 1), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); } [Fact] @@ -648,10 +605,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), Factory.Code("}").AsStatement() ), - new RazorError( - LegacyResources.ParseError_Unterminated_String_Literal, - new SourceLocation(23 + Environment.NewLine.Length, 1, 14), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(23 + Environment.NewLine.Length, 1, 14), contentLength: 1))); } [Fact] @@ -681,12 +636,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), expectedErrors: new[] { - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(14, 0, 14), - length: 1) + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "(", ")"), }); - } private void RunUnterminatedSimpleKeywordBlock(string keyword) @@ -695,10 +647,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ", BlockKindInternal.Statement, SpanKindInternal.Code, - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'), - SourceLocation.Zero, - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), keyword, "}", "{")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs index 83e0b9f2c1..afc2afa90a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs @@ -29,11 +29,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), Factory.EmptyCSharp().AsExpression() ), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_ExplicitExpression, ")", "("), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + Resources.BlockName_ExplicitExpression, + ")", + "(")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs index ce82632a59..3a013a6ec8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs @@ -14,26 +14,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { get { - var noErrors = new RazorError[0]; - Func missingEndParenError = (index) => - new RazorError[1] + var noErrors = new RazorDiagnostic[0]; + Func missingEndBracketError = (index) => + new RazorDiagnostic[1] { - new RazorError( - "An opening \"(\" is missing the corresponding closing \")\".", - new SourceLocation(index, 0, index), - length: 1) - }; - Func missingEndBracketError = (index) => - new RazorError[1] - { - new RazorError( - "An opening \"[\" is missing the corresponding closing \"]\".", - new SourceLocation(index, 0, index), - length: 1) + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(index, 0, index), contentLength: 1), "[", "]"), }; // implicitExpression, expectedImplicitExpression, acceptedCharacters, expectedErrors - return new TheoryData + return new TheoryData { { "val??[", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, { "val??[0", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors }, @@ -68,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy implicitExpresison, expectedImplicitExpression, (AcceptedCharactersInternal)acceptedCharacters, - (RazorError[])expectedErrors); + (RazorDiagnostic[])expectedErrors); } public static TheoryData NullConditionalOperatorData_Dot @@ -135,10 +125,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "/")); } [Fact] @@ -150,10 +139,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1))); } [Fact] @@ -253,10 +240,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ImplicitExpressionTest( "foo(()", "foo(()", acceptedCharacters: AcceptedCharactersInternal.Any, - errors: new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(4, 0, 4), - length: 1)); + errors: RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs index c4ec18b465..eb626f3abe 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs @@ -25,10 +25,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string.Empty, HtmlSymbolType.Unknown)) .Accepts(AcceptedCharactersInternal.Any))), - new RazorError( - LegacyResources.ParseError_RazorComment_Not_Terminated, - SourceLocation.Zero, - length: 2)); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(SourceLocation.Zero, contentLength: 2))); } [Fact] @@ -79,10 +77,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.None)), Factory.Code(Environment.NewLine) .AsImplicitExpression(CSharpCodeParser.DefaultKeywords))), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(4, 0, 4), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); } [Fact] @@ -104,14 +100,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string.Empty, CSharpSymbolType.Unknown)) .Accepts(AcceptedCharactersInternal.Any)))), - new RazorError( - LegacyResources.ParseError_RazorComment_Not_Terminated, - new SourceLocation(5, 0, 5), - length: 2), - new RazorError( - LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), - new SourceLocation(4, 0, 4), - length: 1)); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 2)), + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); } [Fact] @@ -149,18 +141,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.None)), Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null), Factory.Markup("}")))), - new RazorError( - LegacyResources.ParseError_TextTagCannotContainAttributes, - new SourceLocation(7 + Environment.NewLine.Length, 1, 5), - length: 4), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("text"), - new SourceLocation(7 + Environment.NewLine.Length, 1, 5), - length: 4), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(new SourceLocation(7 + Environment.NewLine.Length, 1, 5), contentLength: 4)), + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(7 + Environment.NewLine.Length, 1, 5), contentLength: 4), "text"), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -182,15 +168,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.None), Factory.Span(SpanKindInternal.Comment, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown)) .Accepts(AcceptedCharactersInternal.Any)))), - new RazorError( - LegacyResources.ParseError_RazorComment_Not_Terminated, - new SourceLocation(2, 0, 2), - length: 2), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_RazorCommentNotTerminated( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 2)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs index ce0382e7c6..21a2dacf19 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs @@ -16,10 +16,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new DirectiveBlock( Factory.MetaCode(word).Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.FormatParseError_ReservedWord(word), - SourceLocation.Zero, - word.Length)); + RazorDiagnosticFactory.CreateParsing_ReservedWord( + new SourceSpan(SourceLocation.Zero, word.Length), word)); } [Theory] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs index 2966814826..3ae95b1994 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.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 System.Linq; using Microsoft.AspNetCore.Razor.Language.Extensions; using Xunit; @@ -16,11 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(8, 0, 8), - length: Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: Environment.NewLine.Length), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -42,11 +38,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(SectionDirective.Directive.Directive, "{"), - new SourceLocation(25 + Environment.NewLine.Length, 0, 25 + Environment.NewLine.Length), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(25 + Environment.NewLine.Length, 1, 4), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( @@ -69,11 +64,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(17, 0, 17), - length: Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: Environment.NewLine.Length), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -113,11 +105,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(9, 0, 9), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 1), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -144,11 +133,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral(SectionDirective.Directive.Directive, "{"), - new SourceLocation(12, 0, 12), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( @@ -176,17 +164,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var erroredChunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); erroredChunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveMustAppearAtStartOfLine("section"), - new SourceLocation(16, 0, 16), - 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 7), "section")); erroredChunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Sections_Cannot_Be_Nested(LegacyResources.SectionExample_CS), - new SourceLocation(15, 0, 15), - 8))); + RazorDiagnosticFactory.CreateParsing_SectionsCannotBeNested( + new SourceSpan(new SourceLocation(15, 0, 15), 8))); // Act & Assert ParseDocumentTest( @@ -230,11 +212,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(SectionDirective.Directive.Directive, "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), SectionDirective.Directive.Directive, "}", "{")); // Act & Assert ParseDocumentTest( @@ -263,11 +242,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), "section", "}", "{")); // Act & Assert ParseDocumentTest( @@ -292,11 +268,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), "section", "}", "{")); // Act & Assert ParseDocumentTest( @@ -328,11 +301,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var newLine = Environment.NewLine; var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13 + newLine.Length, 1, 0), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13 + newLine.Length, 1, 0), contentLength: 1), "section", "}", "{")); var spaces = " "; // Act & Assert @@ -372,11 +342,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(SectionDirective.Directive.Directive, "{"), - new SourceLocation(18 + Environment.NewLine.Length, 0, 18 + Environment.NewLine.Length), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(18 + Environment.NewLine.Length, 1, 0), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs index 69e78889f9..ca472f33f5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.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 System.Linq; using Microsoft.AspNetCore.Razor.Language.Extensions; using Xunit; @@ -16,10 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(InheritsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(InheritsDirective.Directive.Directive, "type"), - new SourceLocation(9, 0, 9), 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(9, 0, 9), 1), InheritsDirective.Directive.Directive, "type")); // Act & Assert ParseDocumentTest( @@ -57,10 +54,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(InheritsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsTypeName(InheritsDirective.Directive.Directive), - 25, 0, 25, Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsTypeName( + new SourceSpan(new SourceLocation(25, 0, 25), Environment.NewLine.Length), + InheritsDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -88,10 +84,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AutoCompleteWith(autoCompleteString: null), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - new SourceLocation(2, 0, 2), - length: 5)); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 5))); } [Fact] @@ -105,10 +99,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AutoCompleteWith(autoCompleteString: null), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - new RazorError( - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - new SourceLocation(2, 0, 2), - length: 5)); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 5))); } [Fact] @@ -192,11 +184,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -228,10 +217,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "/")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs index 490d252688..0d3a485441 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs @@ -248,13 +248,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var unbalancedParenErrorString = "An opening \"(\" is missing the corresponding closing \")\"."; - var unbalancedBracketCatchErrorString = "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."; // document, expectedStatement, expectedErrors - return new TheoryData + return new TheoryData { { "@try { someMethod(); } catch(Exception) when (", @@ -263,7 +259,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory .Code("try { someMethod(); } catch(Exception) when (") .AsStatement()), - new[] { new RazorError(unbalancedParenErrorString, 45, 0, 45, 1) } + new[] + { + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(45, 0, 45), contentLength: 1), "(", ")"), + } }, { "@try { someMethod(); } catch(Exception) when (someMethod(", @@ -272,7 +272,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory .Code("try { someMethod(); } catch(Exception) when (someMethod(") .AsStatement()), - new[] { new RazorError(unbalancedParenErrorString, 45, 0, 45, 1) } + new[] + { + RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( + new SourceSpan(new SourceLocation(45, 0, 45), contentLength: 1), "(", ")"), + } }, { "@try { someMethod(); } catch(Exception) when (true) {", @@ -281,7 +285,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory .Code("try { someMethod(); } catch(Exception) when (true) {") .AsStatement()), - new[] { new RazorError(unbalancedBracketCatchErrorString, 23, 0, 23, 1) } + new[] + { + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(23, 0, 23), contentLength: 1), "catch", "}", "{"), + } }, }; } @@ -297,7 +305,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy FixupSpans = true; // Act & Assert - ParseBlockTest(document, (StatementBlock)expectedStatement, (RazorError[])expectedErrors); + ParseBlockTest(document, (StatementBlock)expectedStatement, (RazorDiagnostic[])expectedErrors); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs index 775f2a3c4f..0631ff1c7f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs @@ -312,12 +312,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo," + testTemplateWithDoubleTransitionCode + "); }", expected); } - private static RazorError GetNestedTemplateError(int characterIndex) + private static RazorDiagnostic GetNestedTemplateError(int characterIndex) { - return new RazorError( - LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, - new SourceLocation(characterIndex, 0, characterIndex), - length: 1); + return RazorDiagnosticFactory.CreateParsing_InlineMarkupBlocksCannotBeNested( + new SourceSpan(new SourceLocation(characterIndex, 0, characterIndex), contentLength: 1)); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs index fa51eb681f..1d96a65590 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs @@ -111,10 +111,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" " + Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), true, - new RazorError( - LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, - new SourceLocation(5 + Environment.NewLine.Length, 1, 4), - length: 1)); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(new SourceLocation(5 + Environment.NewLine.Length, 1, 4), contentLength: 1))); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs index dde4e6e58c..903e68f313 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs @@ -44,10 +44,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy designTime: true, expectedErrors: new[] { - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("}"), - new SourceLocation(2, 0, 2), - length: 1) + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), + "}") }); } @@ -69,10 +68,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy designTime: true, expectedErrors: new[] { - new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("."), - new SourceLocation(2, 0, 2), - length: 1) + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), + ".") }); } @@ -94,10 +92,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), /* designTimeParser */ true, - new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(6 + Environment.NewLine.Length, 1, 5), - Environment.NewLine.Length)); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), Environment.NewLine.Length))); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs index f67b159189..f0af2d1530 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs @@ -14,17 +14,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return ParseCodeBlock(document, directives, designTime); } - internal void ImplicitExpressionTest(string input, params RazorError[] errors) + internal void ImplicitExpressionTest(string input, params RazorDiagnostic[] errors) { ImplicitExpressionTest(input, AcceptedCharactersInternal.NonWhiteSpace, errors); } - internal void ImplicitExpressionTest(string input, AcceptedCharactersInternal acceptedCharacters, params RazorError[] errors) + internal void ImplicitExpressionTest(string input, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] errors) { ImplicitExpressionTest(input, input, acceptedCharacters, errors); } - internal void ImplicitExpressionTest(string input, string expected, params RazorError[] errors) + internal void ImplicitExpressionTest(string input, string expected, params RazorDiagnostic[] errors) { ImplicitExpressionTest(input, expected, AcceptedCharactersInternal.NonWhiteSpace, errors); } @@ -39,28 +39,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null); } - internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedError) + internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedError) { SingleSpanBlockTest(document, document, blockKind, spanType, expectedError); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedErrors) + internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedErrors) { - SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorError[0]); + SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorDiagnostic[0]); } - internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedError) + internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedError) { SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError); } - internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedErrors) + 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 RazorError[0]); + ParseBlockTest(document, b, expectedErrors ?? new RazorDiagnostic[0]); } - internal void ImplicitExpressionTest(string input, string expected, AcceptedCharactersInternal acceptedCharacters, params RazorError[] errors) + internal void ImplicitExpressionTest(string input, string expected, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] errors) { var factory = CreateSpanFactory(); ParseBlockTest(SyntaxConstants.TransitionString + input, diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs index e074835fd1..8687be85d3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs @@ -40,11 +40,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var suffixLocation1 = new SourceLocation( absoluteIndex: 8 + newlineLength + attributeNameLength, lineIndex: 1, - characterIndex: 5 + attributeNameLength); + characterIndex: 5); var valueLocation1 = new SourceLocation( absoluteIndex: 5 + attributeNameLength + newlineLength, lineIndex: 1, - characterIndex: 2 + attributeNameLength); + characterIndex: 2); var prefixLocation2 = SourceLocationTracker.Advance(suffixLocation1, "'"); var suffixLocation2 = new SourceLocation( absoluteIndex: 15 + attributeNameLength * 2 + newlineLength * 2, @@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var suffixLocation1 = new SourceLocation( absoluteIndex: 10 + newlineLength + attributeNameLength, lineIndex: 1, - characterIndex: 5 + attributeNameLength + newlineLength); + characterIndex: 7 + attributeNameLength); var valueLocation1 = new SourceLocation( absoluteIndex: 7 + attributeNameLength + newlineLength, lineIndex: 1, diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs index f0cf332e1f..f54ba50d37 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp().AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), Factory.EmptyHtml()), - new RazorError[0]); + new RazorDiagnostic[0]); } [Fact] @@ -47,11 +47,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagBlock( Factory.Markup("<"))))), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{")); } [Fact] @@ -82,14 +79,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy designTime: true, expectedErrors: new[] { - new RazorError( - LegacyResources.FormatParseError_UnexpectedEndTag("html"), - new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2), - length: 4), - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("code", "}", "{"), - new SourceLocation(1, 0, 1), - length: 1) + 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, "}", "{"), }); } @@ -102,10 +95,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagBlock( Factory.Markup($"< {Environment.NewLine} "))), designTime: true, - expectedErrors: new RazorError( - LegacyResources.FormatParseError_UnfinishedTag(string.Empty), - new SourceLocation(1, 0, 1), - length: 1)); + expectedErrors: RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), string.Empty)); } [Fact] @@ -335,10 +326,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagBlock( Factory.Markup("").Accepts(AcceptedCharactersInternal.None))), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("foo"), - new SourceLocation(1, 0, 1), - length: 3)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); } [Fact] @@ -458,10 +447,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), new MarkupTagBlock( Factory.Markup("").Accepts(AcceptedCharactersInternal.None))), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("foo"), - new SourceLocation(1, 0, 1), - length: 3)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); } @@ -620,10 +607,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagBlock( Factory.Markup("
"))); - var expectedErrors = new RazorError[] + var expectedErrors = new RazorDiagnostic[] { - new RazorError( - @"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.", - new SourceLocation(12, 0, 12), - length: 1), - new RazorError( - @"""' />"" is not valid at the start of a code block. Only identifiers, keywords, comments, ""("" and ""{"" are valid.", - new SourceLocation(14, 0, 14), - length: 4), + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), + "' />"), }; // Act & Assert diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs index 0856a18c43..497fceedaa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs @@ -28,10 +28,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.Any)), new MarkupTagBlock( Factory.MarkupTransition(""))), - new RazorError( - LegacyResources.ParseError_TextTagCannotContainAttributes, - new SourceLocation(1, 0, 1), - length: 4)); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 4))); } [Fact] @@ -43,10 +41,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MarkupTransition("")), new MarkupTagBlock( Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.Any))), - new RazorError( - LegacyResources.ParseError_TextTagCannotContainAttributes, - new SourceLocation(8, 0, 8), - length: 4)); + RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 4))); } [Fact] @@ -54,10 +50,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseBlockTest("foo bar ", new MarkupBlock(), - new RazorError( - LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag, - SourceLocation.Zero, - length: 3)); + RazorDiagnosticFactory.CreateParsing_MarkupBlockMustStartWithTag( + new SourceSpan(SourceLocation.Zero, contentLength: 3))); } [Fact] @@ -68,10 +62,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagBlock( Factory.Markup("
").Accepts(AcceptedCharactersInternal.None)), Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - new RazorError( - LegacyResources.FormatParseError_UnexpectedEndTag("foo"), - new SourceLocation(2, 0, 2), - length: 3)); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 3), "foo")); } [Fact] @@ -85,10 +77,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), new MarkupTagBlock( Factory.Markup("").Accepts(AcceptedCharactersInternal.None))), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("p"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p")); } [Fact] @@ -99,10 +89,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagBlock( Factory.Markup("").Accepts(AcceptedCharactersInternal.None)), Factory.Markup("blah blah blah blah blah")), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("foo"), - new SourceLocation(1, 0, 1), - length: 3)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); } [Fact] @@ -115,10 +103,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(new AttributeBlockChunkGenerator("bar", new LocationTagged(" bar=", 4, 0, 4), new LocationTagged(string.Empty, 12, 0, 12)), Factory.Markup(" bar=").With(SpanChunkGenerator.Null), Factory.Markup("baz").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), new LocationTagged("baz", 9, 0, 9)))))), - new RazorError( - LegacyResources.FormatParseError_UnfinishedTag("foo"), - new SourceLocation(1, 0, 1), - length: 3)); + RazorDiagnosticFactory.CreateParsing_UnfinishedTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs index c1b3b1a688..0a86c7a06b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs @@ -39,10 +39,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None), Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - new RazorError( - LegacyResources.FormatParseError_MissingEndTag("p"), - new SourceLocation(1, 0, 1), - length: 1)); + RazorDiagnosticFactory.CreateParsing_MissingEndTag( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorErrorTest.cs deleted file mode 100644 index 698add61b6..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/RazorErrorTest.cs +++ /dev/null @@ -1,75 +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 Newtonsoft.Json; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language.Legacy -{ - public class RazorErrorTest - { - [Fact] - public void RazorError_CanBeSerialized() - { - // Arrange - var error = new RazorError( - message: "Testing", - location: new SourceLocation(absoluteIndex: 1, lineIndex: 2, characterIndex: 3), - length: 456); - var expectedSerializedError = - $"{{\"{nameof(RazorError.Message)}\":\"Testing\",\"{nameof(RazorError.Location)}\":{{\"" + - $"{nameof(SourceLocation.FilePath)}\":null,\"" + - $"{nameof(SourceLocation.AbsoluteIndex)}\":1,\"{nameof(SourceLocation.LineIndex)}\":2,\"" + - $"{nameof(SourceLocation.CharacterIndex)}\":3}},\"{nameof(RazorError.Length)}\":456}}"; - - // Act - var serializedError = JsonConvert.SerializeObject(error); - - // Assert - Assert.Equal(expectedSerializedError, serializedError, StringComparer.Ordinal); - } - - [Fact] - public void RazorError_WithFilePath_CanBeSerialized() - { - // Arrange - var error = new RazorError( - message: "Testing", - location: new SourceLocation("some-path", absoluteIndex: 1, lineIndex: 2, characterIndex: 56), - length: 3); - var expectedSerializedError = - $"{{\"{nameof(RazorError.Message)}\":\"Testing\",\"{nameof(RazorError.Location)}\":{{\"" + - $"{nameof(SourceLocation.FilePath)}\":\"some-path\",\"" + - $"{nameof(SourceLocation.AbsoluteIndex)}\":1,\"{nameof(SourceLocation.LineIndex)}\":2,\"" + - $"{nameof(SourceLocation.CharacterIndex)}\":56}},\"{nameof(RazorError.Length)}\":3}}"; - - // Act - var serializedError = JsonConvert.SerializeObject(error); - - // Assert - Assert.Equal(expectedSerializedError, serializedError, StringComparer.Ordinal); - } - - [Fact] - public void RazorError_CanBeDeserialized() - { - // Arrange - var error = new RazorError( - message: "Testing", - location: new SourceLocation("somepath", absoluteIndex: 1, lineIndex: 2, characterIndex: 3), - length: 456); - var serializedError = JsonConvert.SerializeObject(error); - - // Act - var deserializedError = JsonConvert.DeserializeObject(serializedError); - - // Assert - Assert.Equal("Testing", deserializedError.Message, StringComparer.Ordinal); - Assert.Equal(1, deserializedError.Location.AbsoluteIndex); - Assert.Equal(2, deserializedError.Location.LineIndex); - Assert.Equal(3, deserializedError.Location.CharacterIndex); - Assert.Equal(456, deserializedError.Length); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs index 4c2ee94e41..5c52dd7967 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/SpanTest.cs @@ -26,7 +26,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Assert.Equal(2, span.Length); } - // Note: This is more of an integration-like test. However, it's valuable to determine // that the Span's ReplaceWith code is properly propogating change notifications to parents. [Fact] @@ -54,5 +53,26 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Assert.Equal(5, originalBlockLength); Assert.Equal(2, block.Length); } + + [Fact] + public void Clone_ClonesSpan() + { + // Arrange + var spanBuilder = new SpanBuilder(new SourceLocation(1, 2, 3)) + { + EditHandler = new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString), + Kind = SpanKindInternal.Transition, + ChunkGenerator = new ExpressionChunkGenerator(), + }; + spanBuilder.Accept(new CSharpSymbol("@", CSharpSymbolType.Transition)); + var span = spanBuilder.Build(); + + // Act + var copy = (Span)span.Clone(); + + // Assert + Assert.Equal(span, copy); + Assert.NotSame(span, copy); + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs index cc6b408e3d..9b2adc4d07 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs @@ -156,7 +156,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData WithoutEndTagElementData @@ -230,7 +230,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData TagStructureCompatibilityData @@ -334,7 +334,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData MalformedTagHelperAttributeBlockData @@ -343,11 +343,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; - var errorFormatNoCloseAngle = "Missing close angle for tag helper '{0}'."; - var errorFormatNoCSharp = "The tag helper '{0}' must not have C# in the element's attribute " + - "declaration area."; Func createInvalidDoBlock = extraCode => { return new MarkupBlock( @@ -362,7 +357,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Code("do {" + extraCode).AsStatement()))); }; - return new TheoryData + return new TheoryData { { "

+ return new TheoryData { { ""))), new [] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "strong"), - new SourceLocation(3, 0, 3), - length: 6) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 6), "strong") } }, { @@ -925,10 +818,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

"))), new [] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), - new SourceLocation(14, 0, 14), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "p") } } }; @@ -942,7 +833,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData CodeTagHelperAttributesData @@ -1219,7 +1110,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, (MarkupBlock)expectedOutput, - expectedErrors: Enumerable.Empty()); + expectedErrors: Enumerable.Empty()); } public static IEnumerable IncompleteHelperBlockData @@ -1228,8 +1119,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var malformedErrorFormat = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; yield return new object[] { @@ -1258,14 +1147,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }, new MarkupTagHelperBlock("strong")), blockFactory.MarkupTagBlock("")), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 53, lineIndex: 0, columnIndex: 53, length: 6), - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 66, lineIndex: 0, columnIndex: 66, length: 6) + 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[] @@ -1278,11 +1165,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong", factory.Markup("World")), blockFactory.MarkupTagBlock(""))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 1), "p") } }; yield return new object[] @@ -1295,14 +1181,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong", factory.Markup("World"), blockFactory.MarkupTagBlock("")))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 15, lineIndex: 0, columnIndex: 15, length: 6) + 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[] @@ -1321,12 +1205,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new TagHelperAttributeNode("style", factory.Markup("color:red;")) }, factory.Markup("World")))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") } }; } @@ -1339,7 +1221,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } @@ -1917,7 +1799,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [MemberData(nameof(EmptyAttributeTagHelperData))] public void Rewrite_UnderstandsEmptyAttributeTagHelpers(string documentContent, object expectedOutput) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorError[0], "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorDiagnostic[0], "p"); } public static TheoryData EmptyTagHelperBoundAttributeData @@ -1925,13 +1807,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var emptyAttributeError = - "Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound attributes of " + - "type '{2}' cannot be empty or contain only whitespace."; var boolTypeName = typeof(bool).FullName; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -1945,9 +1824,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName) } }, { @@ -1963,7 +1844,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.CodeMarkup(" true").With(new ExpressionChunkGenerator()), AttributeStructure.SingleQuotes) })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -1980,9 +1861,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -1998,12 +1881,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 16, lineIndex: 0, columnIndex: 16, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(16, 0, 16, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2024,12 +1911,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(17, 0, 17, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2051,9 +1942,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(19, 0, 19, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2072,9 +1965,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2093,9 +1988,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2122,9 +2019,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 31, lineIndex: 0, columnIndex: 31, length: 5), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(31, 0, 31, 5), + "bound", + "myth", + boolTypeName), } }, { @@ -2139,9 +2038,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "BouND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "BouND", + "myth", + boolTypeName), } }, { @@ -2157,12 +2058,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "BOUND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( - string.Format(emptyAttributeError, "bOUnd", "myth", boolTypeName), - absoluteIndex: 18, lineIndex: 0, columnIndex: 18, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "BOUND", + "myth", + boolTypeName), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(18, 0, 18, 5), + "bOUnd", + "myth", + boolTypeName), } }, { @@ -2180,9 +2085,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(emptyAttributeError, "BOUND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(6, 0, 6, 5), + "BOUND", + "myth", + boolTypeName), } }, { @@ -2207,7 +2114,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AttributeStructure.SingleQuotes) } })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -2233,7 +2140,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AttributeStructure.SingleQuotes) } })), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -2265,7 +2172,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static IEnumerable ScriptBlockData @@ -2861,7 +2768,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput) { // Act & Assert - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, Enumerable.Empty(), "input"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, Enumerable.Empty(), "input"); } public static TheoryData MinimizedAttributeData_Document @@ -2869,11 +2776,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var noErrors = new RazorError[0]; - var errorFormat = "Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound " + - "attributes of type '{2}' cannot be empty or contain only whitespace."; - var emptyKeyFormat = "The tag helper attribute '{0}' in element '{1}' is missing a key. The " + - "syntax is '<{1} {0}{{ key }}=\"value\">'."; + var noErrors = new RazorDiagnostic[0]; var stringType = typeof(string).FullName; var intType = typeof(int).FullName; var expressionString = "@DateTime.Now + 1"; @@ -2900,7 +2803,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("1", index + 16, 0, index + 16))))); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -2926,8 +2829,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-string", "p", stringType), 3, 0, 3, 12) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 12), + "bound-string", + "p", + stringType), } }, { @@ -2942,8 +2848,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), 7, 0, 7, 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -2958,8 +2867,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 18), + "bound-required-int", + "input", + intType), } }, { @@ -2972,7 +2884,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), })), - new[] { new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9) } + new[] + { + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 9), + "bound-int", + "p", + intType), + } }, { "", @@ -2986,12 +2905,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "int-dictionary", "input", typeof(IDictionary).Namespace + ".IDictionary"), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 14), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 14), + "int-dictionary", + "input", + typeof(IDictionary).Namespace + ".IDictionary"), } }, { @@ -3006,12 +2924,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "string-dictionary", "input", typeof(IDictionary).Namespace + ".IDictionary"), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 17), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 17), + "string-dictionary", + "input", + typeof(IDictionary).Namespace + ".IDictionary"), } }, { @@ -3026,18 +2943,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "int-prefix-", "input", typeof(int).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 11), - new RazorError( - string.Format(emptyKeyFormat, "int-prefix-", "input"), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 11), + 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"), } }, { @@ -3052,18 +2966,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "string-prefix-", "input", typeof(string).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 14), - new RazorError( - string.Format(emptyKeyFormat, "string-prefix-", "input"), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 14), + 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"), } }, { @@ -3078,12 +2989,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "int-prefix-value", "input", typeof(int).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 16), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 16), + "int-prefix-value", + "input", + intType), } }, { @@ -3098,12 +3008,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "string-prefix-value", "input", typeof(string).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 19), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 19), + "string-prefix-value", + "input", + stringType), } }, { @@ -3118,12 +3027,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "int-prefix-value", "input", typeof(int).FullName), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 16), + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 16), + "int-prefix-value", + "input", + intType), } }, { @@ -3136,7 +3044,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { new TagHelperAttributeNode("string-prefix-value", new MarkupBlock(), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3151,7 +3059,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.CodeMarkup("3").With(new ExpressionChunkGenerator()), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3168,7 +3076,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(" string")), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3183,12 +3091,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 24, - lineIndex: 0, - columnIndex: 24, - length: 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(24, 0, 24, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -3204,8 +3111,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 13, 0, 13, 12), + 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), } }, { @@ -3222,14 +3137,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18), - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 43, - lineIndex: 0, - columnIndex: 43, - length: 21) + 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), } }, { @@ -3246,9 +3163,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 13, 0, 13, 12), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 26, 0, 26, 12), + 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), } }, { @@ -3277,12 +3206,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-string", "p", stringType), - absoluteIndex: 3, - lineIndex: 0, - columnIndex: 3, - length: 12) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 12), + "bound-string", + "p", + stringType), } }, { @@ -3311,12 +3239,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-string", "p", stringType), - absoluteIndex: 15, - lineIndex: 0, - columnIndex: 15, - length: 12) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(15, 0, 15, 12), + "bound-string", + "p", + stringType), } }, { @@ -3332,12 +3259,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 7, - lineIndex: 0, - columnIndex: 7, - length: 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -3353,12 +3279,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 19, - lineIndex: 0, - columnIndex: 19, - length: 21) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(19, 0, 19, 21), + "bound-required-string", + "input", + stringType), } }, { @@ -3374,8 +3299,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(7, 0, 7, 18), + "bound-required-int", + "input", + intType), } }, { @@ -3391,7 +3319,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(3, 0, 3, 9), + "bound-int", + "p", + intType), } }, { @@ -3407,7 +3339,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-required-int", "input", intType), 19, 0, 19, 18) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(19, 0, 19, 18), + "bound-required-int", + "input", + intType), } }, { @@ -3423,7 +3359,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 15, 0, 15, 9) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(15, 0, 15, 9), + "bound-int", + "p", + intType), } }, { @@ -3439,8 +3379,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 33, 0, 33, 18) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(33, 0, 33, 18), + "bound-required-int", + "input", + intType), } }, { @@ -3456,7 +3399,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 29, 0, 29, 9) + RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute( + new SourceSpan(29, 0, 29, 9), + "bound-int", + "p", + intType), } }, { @@ -3476,14 +3423,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 10, 0, 10, 18), - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), - absoluteIndex: 57, - lineIndex: 0, - columnIndex: 57, - length: 21), + 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), } }, { @@ -3503,9 +3452,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 6, 0, 6, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 44, 0, 44, 12), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 84, 0, 84, 12), + 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), } }, }; @@ -3612,12 +3573,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy data[1] = buildStatementBlock(() => data[1] as MarkupBlock); - var errors = data[2] as RazorError[]; + var errors = data[2] as RazorDiagnostic[]; for (var i = 0; i < errors.Length; i++) { - var error = errors[i]; - error.Location = SourceLocationTracker.Advance(error.Location, "@{"); + 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; } } @@ -3630,17 +3594,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var noErrors = new RazorError[0]; - var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; - var errorFormatNoCloseAngle = "Missing close angle for tag helper '{0}'."; - var errorFormatNoValue = "Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound " + - "attributes of type '{2}' cannot be empty or contain only whitespace."; + var noErrors = new RazorDiagnostic[0]; var stringType = typeof(string).FullName; var intType = typeof(int).FullName; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "(), + children: new[] + { + new SpanBuilder(SourceLocation.Zero).Build(), + new SpanBuilder(new SourceLocation(0, 1, 2)).Build(), + }).Build(); + + // Act + var copy = (TagHelperBlock)tagHelper.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, tagHelper); + Assert.Collection( + copy.Children, + child => Assert.NotSame(tagHelper.Children[0], child), + child => Assert.NotSame(tagHelper.Children[1], child)); + } + + [Fact] + public void Clone_ClonesTagHelperAttributes() + { + // Arrange + var tagHelper = (TagHelperBlock)new TagHelperBlockBuilder( + "p", + TagMode.StartTagAndEndTag, + attributes: new List() + { + new TagHelperAttributeNode("class", new SpanBuilder(SourceLocation.Zero).Build(), AttributeStructure.NoQuotes), + new TagHelperAttributeNode("checked", new SpanBuilder(SourceLocation.Undefined).Build(), AttributeStructure.NoQuotes) + }, + children: Enumerable.Empty()).Build(); + + // Act + var copy = (TagHelperBlock)tagHelper.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, tagHelper); + Assert.Collection( + copy.Attributes, + attribute => Assert.NotSame(tagHelper.Attributes[0], attribute), + attribute => Assert.NotSame(tagHelper.Attributes[1], attribute)); + } + + [Fact] + public void Clone_ClonesTagHelperSourceStartTag() + { + // Arrange + var tagHelper = (TagHelperBlock)new TagHelperBlockBuilder( + "p", + TagMode.StartTagAndEndTag, + attributes: new List(), + children: Enumerable.Empty()) + { + SourceStartTag = new BlockBuilder() + { + Type = BlockKindInternal.Comment, + ChunkGenerator = new RazorCommentChunkGenerator() + }.Build() + }.Build(); + + // Act + var copy = (TagHelperBlock)tagHelper.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, tagHelper); + Assert.NotSame(tagHelper.SourceStartTag, copy.SourceStartTag); + } + + [Fact] + public void Clone_ClonesTagHelperSourceEndTag() + { + // Arrange + var tagHelper = (TagHelperBlock)new TagHelperBlockBuilder( + "p", + TagMode.StartTagAndEndTag, + attributes: new List(), + children: Enumerable.Empty()) + { + SourceEndTag = new BlockBuilder() + { + Type = BlockKindInternal.Comment, + ChunkGenerator = new RazorCommentChunkGenerator() + }.Build() + }.Build(); + + // Act + var copy = (TagHelperBlock)tagHelper.Clone(); + + // Assert + ParserTestBase.EvaluateParseTree(copy, tagHelper); + Assert.NotSame(tagHelper.SourceEndTag, copy.SourceEndTag); + } + [Fact] public void FlattenFlattensSelfClosingTagHelpers() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs index 5c75651f43..2feccbe1a4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs @@ -74,20 +74,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - Func errorFormatUnclosed = (location, tagName) => - new RazorError( - $"Found a malformed '{tagName}' tag helper. Tag helpers must have a start and end tag or be " + - "self closing.", - new SourceLocation(location, 0, location), - tagName.Length); - Func errorFormatNoCloseAngle = (location, tagName) => - new RazorError( - $"Missing close angle for tag helper '{tagName}'.", - new SourceLocation(location, 0, location), - tagName.Length); + Func errorFormatUnclosed = (location, tagName) => + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(location, 0, location), tagName.Length), tagName); + + Func errorFormatNoCloseAngle = (location, tagName) => + RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle( + new SourceSpan(new SourceLocation(location, 0, location), tagName.Length), tagName); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "

", @@ -173,7 +169,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static TheoryData NestedVoidSelfClosingRequiredParentData @@ -279,7 +275,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData NestedRequiredParentData @@ -354,7 +350,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } [Fact] @@ -381,7 +377,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -409,7 +405,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -433,12 +429,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Build(), }; var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper("th:strong"), - absoluteIndex: 8, - lineIndex: 0, - columnIndex: 8, - length: 9), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(filePath: null, absoluteIndex: 8, lineIndex: 0, characterIndex: 8, length: 9), + "th:strong"), }; // Act & Assert @@ -474,7 +467,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -755,12 +748,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy $"{Environment.NewLine} {Environment.NewLine}

"; var newLineLength = Environment.NewLine.Length; var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag("strong", "p", "br"), - absoluteIndex: 8 + newLineLength, - lineIndex: 1, - columnIndex: 5, - length: 6), + RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( + new SourceSpan(absoluteIndex: 8 + newLineLength, lineIndex: 1, characterIndex: 5, length: 6), "strong", "p", "br"), }; var expectedOutput = new MarkupBlock( new MarkupTagHelperBlock("p", @@ -790,12 +779,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var documentContent = ""; var expectedErrors = new[] { - new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag("strong", "strong", "br"), - absoluteIndex: 18, - lineIndex: 0, - columnIndex: 18, - length: 6) + RazorDiagnosticFactory.CreateTagHelper_InvalidNestedTag( + new SourceSpan(absoluteIndex: 18, lineIndex: 0, characterIndex: 18, length: 6), "strong", "strong", "br") }; var expectedOutput = new MarkupBlock( new MarkupTagHelperBlock("strong", @@ -853,7 +838,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); } [Fact] @@ -889,7 +874,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData AllowedChildrenData @@ -898,25 +883,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - Func nestedTagError = - (childName, parentName, allowed, location, length) => new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag( - childName, - parentName, - allowed), - absoluteIndex: location, - lineIndex: 0, - columnIndex: location, - length: length); - Func nestedContentError = - (parentName, allowed, location, length) => new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_CannotHaveNonTagContent(parentName, allowed), - absoluteIndex: location, - lineIndex: 0, - columnIndex: location, - length: length); + 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, RazorError[]> + return new TheoryData, MarkupBlock, RazorDiagnostic[]> { { "


", @@ -924,7 +900,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagHelperBlock("p", new MarkupTagHelperBlock("br", TagMode.SelfClosing))), - new RazorError[0] + new RazorDiagnostic[0] }, { $"

{Environment.NewLine}
{Environment.NewLine}

", @@ -934,7 +910,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(Environment.NewLine), new MarkupTagHelperBlock("br", TagMode.SelfClosing), factory.Markup(Environment.NewLine))), - new RazorError[0] + new RazorDiagnostic[0] }, { "


", @@ -1129,7 +1105,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } [Fact] @@ -1152,12 +1128,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock(""; var expectedOutput = new MarkupBlock(blockFactory.MarkupTagBlock("")); var descriptors = new TagHelperDescriptor[] @@ -1253,16 +1217,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var expectedError = new RazorError( - LegacyResources.FormatTagHelperParseTreeRewriter_InconsistentTagStructure( - "InputTagHelper1", - "InputTagHelper2", - "input", - nameof(TagMatchingRuleDescriptor.TagStructure)), - absoluteIndex: 0, - lineIndex: 0, - columnIndex: 0, - length: 7); + 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[] @@ -1711,7 +1667,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData NestedRequiredAttributeData @@ -1964,7 +1920,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData MalformedRequiredAttributeData @@ -1973,17 +1929,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; - var errorFormatNoCloseAngle = "Missing close angle for tag helper '{0}'."; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { ""), blockFactory.MarkupTagBlock(""))), new[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(1, 0, 1), - length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), - new SourceLocation(1, 0, 1), - length: 1), + 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"), } }, { @@ -2103,14 +2040,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy children: blockFactory.MarkupTagBlock("

"))), new[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(1, 0, 1), - length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), - new SourceLocation(1, 0, 1), - length: 1), + 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"), } }, { @@ -2124,14 +2057,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(1, 0, 1), - length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(17, 0, 17), - length: 1) + 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") } }, { @@ -2146,14 +2075,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(1, 0, 1), - length: 1), - new RazorError( - string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), - new SourceLocation(34, 0, 34), - length: 1) + 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") } }, }; @@ -2179,7 +2104,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static TheoryData PrefixedTagHelperBoundData @@ -2333,7 +2258,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy (IEnumerable)availableDescriptors, documentContent, (MarkupBlock)expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -2343,13 +2268,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatNormalUnclosed = - "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + - "matching end tag."; - var errorMatchingBrace = - "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."; Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -2365,7 +2283,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -2394,12 +2312,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + 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"), } }, { @@ -2423,7 +2339,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words with spaces}", @@ -2447,7 +2363,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), factory.Markup("words with spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2484,7 +2400,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 34, 0, 34)))), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2520,7 +2436,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -2532,19 +2448,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatMalformed = - "Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self " + - "closing."; - var errorFormatNormalUnclosed = - "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + - "matching end tag."; - var errorFormatNormalNotStarted = - "Encountered end tag \"{0}\" with no matching start tag. Are your start/end tags properly " + - "balanced?"; - var errorMatchingBrace = - "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."; + + 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) => { @@ -2560,7 +2469,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -2574,12 +2483,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + MissingEndTagError("!text"), } }, { @@ -2589,9 +2495,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( - string.Format(errorFormatNormalNotStarted, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 5), + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(filePath: null, absoluteIndex: 4, lineIndex: 0, characterIndex: 4, length: 5), "!text"), } }, { @@ -2600,7 +2505,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words and spaces}", @@ -2609,7 +2514,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2619,12 +2524,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5), - new RazorError( - string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 11, lineIndex: 0, columnIndex: 11, length: 4) + MissingEndTagError("!text"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 11, lineIndex: 0, characterIndex: 11, length: 4), "text") } }, { @@ -2638,9 +2540,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("text>").Accepts(AcceptedCharactersInternal.None)))), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4) + MissingEndTagError("text"), } }, { @@ -2650,7 +2550,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), new MarkupTagHelperBlock("text"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2669,12 +2569,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + MissingEndTagError("text"), } }, { @@ -2694,12 +2591,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( - string.Format(errorFormatNormalNotStarted, "text", CultureInfo.InvariantCulture), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4), - new RazorError( - string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4) + 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") } }, }; @@ -2714,7 +2609,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "p", "text"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "p", "text"); } public static TheoryData OptOut_WithPartialTextTagData @@ -2723,15 +2618,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorMatchingBrace = - "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."; - var errorEOFMatchingBrace = - "End of file or an unexpected character was reached before the \"{0}\" 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."; + + 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) => { @@ -2744,7 +2637,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "text}"))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text}", 6), } }, { @@ -2770,12 +2660,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } }, { @@ -2798,12 +2685,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 15, 0, 15))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } }, { @@ -2826,12 +2710,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn}", 16, 0, 16))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } }, { @@ -2857,12 +2738,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } }, { @@ -2889,12 +2767,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!text", 5), } } }; @@ -2908,7 +2783,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "text"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "text"); } public static TheoryData OptOut_WithPartialData_CSharp @@ -2917,15 +2792,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorMatchingBrace = - "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."; - var errorEOFMatchingBrace = - "End of file or an unexpected character was reached before the \"{0}\" 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."; + + 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) => { @@ -2938,7 +2811,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "}"))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!}"), } }, { @@ -2960,12 +2830,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "p}"))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 3) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p}"), } }, { @@ -2975,12 +2842,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p /", new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3003,12 +2867,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 12, 0, 12))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3031,12 +2892,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn}", 13, 0, 13))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3066,12 +2924,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 18, 0, 18))))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3097,12 +2952,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } }, { @@ -3130,12 +2982,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + UnfinishedTagError("!p"), } } }; @@ -3149,7 +2998,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData OptOut_WithPartialData_HTML @@ -3256,7 +3105,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string documentContent, object expectedOutput) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorError[0], "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorDiagnostic[0], "strong", "p"); } public static TheoryData OptOut_WithBlockData_CSharp @@ -3265,19 +3114,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatMalformed = - "Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self " + - "closing."; - var errorFormatNormalUnclosed = - "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + - "matching end tag."; - var errorFormatNormalNotStarted = - "Encountered end tag \"{0}\" with no matching start tag. Are your start/end tags properly " + - "balanced?"; - var errorMatchingBrace = - "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."; + + 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) => { @@ -3293,7 +3135,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -3307,12 +3149,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), Resources.BlockName_Code, "}", "{"), + MissingEndTagError("!p"), } }, { @@ -3322,9 +3161,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( - string.Format(errorFormatNormalNotStarted, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 2), + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(filePath: null, absoluteIndex: 4, lineIndex: 0, characterIndex: 4, length: 2), "!p"), } }, { @@ -3333,7 +3171,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words and spaces}", @@ -3342,7 +3180,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3352,12 +3190,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None))), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 8, lineIndex: 0, columnIndex: 8, length: 1) + MissingEndTagError("!p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 8, lineIndex: 0, characterIndex: 8, length: 1), "p") } }, { @@ -3368,12 +3203,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1) + MissingEndTagError("p"), + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 1), "p") } }, { @@ -3383,7 +3215,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3399,15 +3231,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}"))))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1) + 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") } }, { @@ -3427,12 +3255,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( - string.Format(errorFormatNormalNotStarted, "p", CultureInfo.InvariantCulture), - absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1) + 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") } }, { @@ -3452,18 +3278,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6), - new RazorError( - string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6), - new RazorError( - string.Format(errorFormatNormalNotStarted, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6), - new RazorError( - string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6) + 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") } }, { @@ -3481,7 +3302,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyCSharp().AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), factory.EmptyHtml()), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3504,24 +3325,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( - string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( - string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 6), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 24, lineIndex: 0, columnIndex: 24, length: 2), - new RazorError( - string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 29, lineIndex: 0, columnIndex: 29, length: 6), - new RazorError( - string.Format(errorFormatNormalNotStarted, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 38, lineIndex: 0, columnIndex: 38, length: 2), + 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"), } }, }; @@ -3534,13 +3347,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatNormalUnclosed = - "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + - "matching end tag."; - var errorMatchingBrace = - "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."; Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -3556,7 +3362,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -3585,12 +3391,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( - string.Format(errorFormatNormalUnclosed, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + 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"), } }, { @@ -3614,7 +3418,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words with spaces}", @@ -3638,7 +3442,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), factory.Markup("words with spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -3675,7 +3479,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 31, 0, 31)))), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -3711,7 +3515,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -3725,7 +3529,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData OptOut_WithBlockData_HTML @@ -3734,30 +3538,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + - "end tag or be self closing."; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "words and spaces", @@ -3765,7 +3567,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p>"), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3774,9 +3576,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

")), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(absoluteIndex: 6, lineIndex: 0, characterIndex: 6, length: 1), "p") } }, { @@ -3785,10 +3586,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") } }, { @@ -3797,7 +3596,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock(""))), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3807,10 +3606,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") } }, { @@ -3821,10 +3618,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

")), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - new SourceLocation(11, 0, 11), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(11, 0, 11), contentLength: 1), "p") } }, { @@ -3832,7 +3627,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagHelperBlock("strong", blockFactory.EscapedMarkupTagBlock(""))), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3840,7 +3635,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong"), blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3852,10 +3647,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( - string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - new SourceLocation(1, 0, 1), - length: 1) + RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p") } }, }; @@ -3870,7 +3663,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var blockFactory = new BlockFactory(factory); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -3891,7 +3684,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 11, 0, 11))), factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">"))), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3913,7 +3706,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "words and spaces", @@ -3936,7 +3729,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">")), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3972,7 +3765,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 29, 0, 29)))), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -4007,7 +3800,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -4021,7 +3814,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static IEnumerable TextTagsBlockData @@ -4305,10 +4098,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyHtml()); var expectedErrors = new[] { - new RazorError( - "Encountered end tag \"div\" with no matching start tag. Are your start/end tags properly balanced?", - new SourceLocation(9, 0, 9), - 3), + RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag( + new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 3), "div"), }; RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs index 8471aaf23a..8271cee1a9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs @@ -16,14 +16,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy RunParseTreeRewriterTest( documentContent, expectedOutput, - errors: Enumerable.Empty(), + errors: Enumerable.Empty(), tagNames: tagNames); } internal void RunParseTreeRewriterTest( string documentContent, MarkupBlock expectedOutput, - IEnumerable errors, + IEnumerable errors, params string[] tagNames) { var descriptors = BuildDescriptors(tagNames); @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy IEnumerable descriptors, string documentContent, MarkupBlock expectedOutput, - IEnumerable expectedErrors, + IEnumerable expectedErrors, string tagHelperPrefix = null, RazorParserFeatureFlags featureFlags = null) { @@ -63,12 +63,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var actualTree = parseTreeRewriter.Rewrite(syntaxTree.Root, errorSink); - var allErrors = syntaxTree.Diagnostics.Concat(errorSink.Errors.Select(error => RazorDiagnostic.Create(error))); + var allErrors = syntaxTree.Diagnostics.Concat(errorSink.Errors); var actualErrors = allErrors .OrderBy(error => error.Span.AbsoluteIndex) .ToList(); - EvaluateRazorErrors(actualErrors, expectedErrors.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateRazorErrors(actualErrors, expectedErrors.ToList()); EvaluateParseTree(actualTree, expectedOutput); } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs index d8b98becfd..6abd70ad3e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TokenizerLookaheadTest.cs @@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected override CSharpSymbol CreateSymbol( string content, CSharpSymbolType type, - IReadOnlyList errors) + IReadOnlyList errors) { throw new NotImplementedException(); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/LegacyRazorDiagnosticTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/LegacyRazorDiagnosticTest.cs deleted file mode 100644 index bc67e730c7..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/LegacyRazorDiagnosticTest.cs +++ /dev/null @@ -1,170 +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.Globalization; -using Microsoft.AspNetCore.Razor.Language.Legacy; -using Xunit; - -namespace Microsoft.AspNetCore.Razor.Language -{ - public class LegacyRazorDiagnosticTest - { - [Fact] - public void LegacyRazorDiagnostic_Ctor() - { - // Arrange - var span = new SourceSpan("test.cs", 15, 1, 8, 5); - var error = new RazorError("This is an error", new SourceLocation("test.cs", 15, 1, 8), 5); - - // Act - var diagnostic = new LegacyRazorDiagnostic(error); - - // Assert - Assert.Equal("RZ9999", diagnostic.Id); - Assert.Equal(RazorDiagnosticSeverity.Error, diagnostic.Severity); - Assert.Equal(span, diagnostic.Span); - } - - [Fact] - public void LegacyRazorDiagnostic_GetMessage() - { - // Arrange - var error = new RazorError("This is an error", SourceLocation.Zero, 5); - var diagnostic = new LegacyRazorDiagnostic(error); - - // Act - var result = diagnostic.GetMessage(); - - // Assert - Assert.Equal("This is an error", result); - } - - // RazorError doesn't support format strings. - [Fact] - public void LegacyRazorDiagnostic_GetMessage_FormatProvider() - { - // Arrange - var error = new RazorError("This is an error", SourceLocation.Zero, 5); - var diagnostic = new LegacyRazorDiagnostic(error); - - // Act - var result = diagnostic.GetMessage(CultureInfo.InvariantCulture); - - // Assert - Assert.Equal("This is an error", result); - } - - [Fact] - public void LegacyRazorDiagnostic_ToString() - { - // Arrange - var error = new RazorError("This is an error", SourceLocation.Zero, 5); - var diagnostic = new LegacyRazorDiagnostic(error); - - // Act - var result = diagnostic.ToString(); - - // Assert - Assert.Equal("(1,1): Error RZ9999: This is an error", result); - } - - [Fact] - public void LegacyRazorDiagnostic_ToString_FormatProvider() - { - // Arrange - var error = new RazorError("This is an error", SourceLocation.Zero, 5); - var diagnostic = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - - // Act - var result = ((IFormattable)diagnostic).ToString("ignored", CultureInfo.InvariantCulture); - - // Assert - Assert.Equal("(1,1): Error RZ9999: This is an error", result); - } - - [Fact] - public void LegacyRazorDiagnostic_Equals() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - - // Act - var result = diagnostic1.Equals(diagnostic2); - - // Assert - Assert.True(result); - } - - [Fact] - public void LegacyRazorDiagnostic_NotEquals_DifferentLocation() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 1)); - - // Act - var result = diagnostic1.Equals(diagnostic2); - - // Assert - Assert.False(result); - } - - [Fact] - public void LegacyRazorDiagnostic_NotEquals_DifferentMessage() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is maybe an error", SourceLocation.Zero, 5)); - - // Act - var result = diagnostic1.Equals(diagnostic2); - - // Assert - Assert.False(result); - } - - [Fact] - public void LegacyRazorDiagnostic_HashCodesEqual() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - - // Act - var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); - - // Assert - Assert.True(result); - } - - [Fact] - public void LegacyRazorDiagnostic_HashCodesNotEqual_DifferentLocation() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 2)); - - // Act - var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); - - // Assert - Assert.False(result); - } - - [Fact] - public void LegacyRazorDiagnostic_HashCodesNotEqual_DifferentMessage() - { - // Arrange - var diagnostic1 = new LegacyRazorDiagnostic(new RazorError("This is an error", SourceLocation.Zero, 5)); - var diagnostic2 = new LegacyRazorDiagnostic(new RazorError("This is maybe an error", SourceLocation.Zero, 5)); - - // Act - var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); - - // Assert - Assert.False(result); - } - } -} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj b/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj index 0481f4e948..8f15748273 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj @@ -5,6 +5,7 @@ $(TargetFrameworks);netcoreapp2.0 $(TargetFrameworks);net46 $(DefaultItemExcludes);TestFiles\**\* + $(DefineConstants);GENERATE_BASELINES diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs index 14c6aa4453..41f899512b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorCodeDocumentExtensionsTest.cs @@ -148,5 +148,67 @@ namespace Microsoft.AspNetCore.Razor.Language // Assert Assert.Same(expected, codeDocument.Items[typeof(TagHelperDocumentContext)]); } + + [Fact] + public void GetParserOptions_ReturnsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorParserOptions.CreateDefault(); + codeDocument.Items[typeof(RazorParserOptions)] = expected; + + // Act + var actual = codeDocument.GetParserOptions(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetParserOptions_SetsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorParserOptions.CreateDefault(); + + // Act + codeDocument.SetParserOptions(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorParserOptions)]); + } + + [Fact] + public void GetCodeGenerationOptions_ReturnsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCodeGenerationOptions.CreateDefault(); + codeDocument.Items[typeof(RazorCodeGenerationOptions)] = expected; + + // Act + var actual = codeDocument.GetCodeGenerationOptions(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetCodeGenerationOptions_SetsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCodeGenerationOptions.CreateDefault(); + + // Act + codeDocument.SetCodeGenerationOptions(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorCodeGenerationOptions)]); + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorDiagnosticTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorDiagnosticTest.cs index 795a7e1340..0ad45e8ed5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorDiagnosticTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorDiagnosticTest.cs @@ -41,22 +41,5 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(RazorDiagnosticSeverity.Error, defaultDiagnostic.Severity); Assert.Equal(span, diagnostic.Span); } - - [Fact] - public void Create_WithRazorError_CreatesLegacyRazorDiagnostic() - { - // Arrange - var span = new SourceSpan("test.cs", 15, 1, 8, 5); - var error = new RazorError("This is an error", new SourceLocation("test.cs", 15, 1, 8), 5); - - // Act - var diagnostic = RazorDiagnostic.Create(error); - - // Assert - var legacyDiagnostic = Assert.IsType(diagnostic); - Assert.Equal("RZ9999", legacyDiagnostic.Id); - Assert.Equal(RazorDiagnosticSeverity.Error, legacyDiagnostic.Severity); - Assert.Equal(span, diagnostic.Span); - } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs index 57639292ea..424b5fddd4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorEngineTest.cs @@ -144,7 +144,8 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Collection( feature.TargetExtensions, - extension => Assert.False(Assert.IsType(extension).DesignTime), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), extension => Assert.IsType(extension)); } @@ -154,9 +155,11 @@ namespace Microsoft.AspNetCore.Razor.Language features, feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), @@ -186,7 +189,8 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Collection( feature.TargetExtensions, - extension => Assert.True(Assert.IsType(extension).DesignTime), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), extension => Assert.IsType(extension)); } @@ -196,9 +200,11 @@ namespace Microsoft.AspNetCore.Razor.Language features, feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs new file mode 100644 index 0000000000..f0a57128c3 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineBuilderExtensionsTest.cs @@ -0,0 +1,103 @@ +// 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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectEngineBuilderExtensionsTest + { + [Fact] + public void SetImportFeature_SetsTheImportFeature() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var testFeature1 = Mock.Of(); + var testFeature2 = Mock.Of(); + builder.Features.Add(testFeature1); + builder.Features.Add(testFeature2); + var newFeature = Mock.Of(); + + // Act + builder.SetImportFeature(newFeature); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(newFeature, feature); + } + + [Fact] + public void AddTargetExtension_CreatesAndAddsToTargetExtensionFeatureIfItDoesNotExist() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var expectedExtension = Mock.Of(); + + // Act + builder.AddTargetExtension(expectedExtension); + + // Assert + var feature = Assert.Single(builder.Features); + var codeTargetExtensionFeature = Assert.IsAssignableFrom(feature); + var extensions = Assert.Single(codeTargetExtensionFeature.TargetExtensions); + Assert.Same(expectedExtension, extensions); + } + + [Fact] + public void AddTargetExtension_UsesExistingFeatureIfExistsAndAddsTo() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var codeTargetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + builder.Features.Add(codeTargetExtensionFeature); + var expectedExtension = Mock.Of(); + + // Act + builder.AddTargetExtension(expectedExtension); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(codeTargetExtensionFeature, feature); + var extensions = Assert.Single(codeTargetExtensionFeature.TargetExtensions); + Assert.Same(expectedExtension, extensions); + } + + [Fact] + public void AddDirective_CreatesAndAddsToDirectiveFeatureIfItDoesNotExist() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var expectedDirective = Mock.Of(); + + // Act + builder.AddDirective(expectedDirective); + + // Assert + var feature = Assert.Single(builder.Features); + var directiveFeature = Assert.IsAssignableFrom(feature); + var directive = Assert.Single(directiveFeature.Directives); + Assert.Same(expectedDirective, directive); + } + + [Fact] + public void AddDirective_UsesExistingFeatureIfExistsAndAddsTo() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var directiveFeature = new DefaultRazorDirectiveFeature(); + builder.Features.Add(directiveFeature); + var expecteDirective = Mock.Of(); + + // Act + builder.AddDirective(expecteDirective); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(directiveFeature, feature); + var directive = Assert.Single(directiveFeature.Directives); + Assert.Same(expecteDirective, directive); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineFeatureBaseTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineFeatureBaseTest.cs new file mode 100644 index 0000000000..8344e787c7 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineFeatureBaseTest.cs @@ -0,0 +1,34 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectEngineFeatureBaseTest + { + [Fact] + public void ProjectEngineSetter_CallsOnInitialized() + { + // Arrange + var testFeature = new TestFeature(); + + // Act + testFeature.ProjectEngine = Mock.Of(); + + // Assert + Assert.Equal(1, testFeature.InitializationCount); + } + + private class TestFeature : RazorProjectEngineFeatureBase + { + public int InitializationCount { get; private set; } + + protected override void OnInitialized() + { + InitializationCount++; + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs new file mode 100644 index 0000000000..d901c16199 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorProjectEngineTest.cs @@ -0,0 +1,85 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Extensions; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test +{ + public class RazorProjectEngineTest + { + [Fact] + public void CreateDesignTime_Lambda_AddsFeaturesAndPhases() + { + // Arrange + + // Act + var engine = RazorProjectEngine.Create(RazorConfiguration.Default, Mock.Of()); + + // Assert + AssertDefaultPhases(engine); + AssertDefaultFeatures(engine); + AssertDefaultDirectives(engine); + AssertDefaultTargetExtensions(engine); + } + + private static void AssertDefaultPhases(RazorProjectEngine engine) + { + Assert.Collection( + engine.Phases, + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase)); + } + + private static void AssertDefaultFeatures(RazorProjectEngine engine) + { + var features = engine.EngineFeatures.OrderBy(f => f.GetType().Name).ToArray(); + Assert.Collection( + features, + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature)); + } + + private static void AssertDefaultDirectives(RazorProjectEngine engine) + { + var feature = engine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + Assert.Empty(feature.Directives); + } + + private static void AssertDefaultTargetExtensions(RazorProjectEngine engine) + { + var feature = engine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + + var extensions = feature.TargetExtensions.OrderBy(f => f.GetType().Name).ToArray(); + Assert.Collection( + extensions, + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension)); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs index 7288f8a43c..9c05f2851c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs @@ -37,6 +37,22 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); } + [Fact] + public void ReadFrom_WithProperties() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(encoding: Encoding.UTF32); + var properties = new RazorSourceDocumentProperties("c:\\myapp\\filePath.cshtml", "filePath.cshtml"); + + // Act + var document = RazorSourceDocument.ReadFrom(content, Encoding.UTF32, properties); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); + } + [Fact] public void ReadFrom_EmptyStream_WithEncoding() { @@ -52,30 +68,62 @@ namespace Microsoft.AspNetCore.Razor.Language } [Fact] - public void ReadFrom_UsesProjectItemPhysicalPath() + public void ReadFrom_ProjectItem() { // Arrange - var projectItem = new TestRazorProjectItem("/test-path", "some-physical-path"); + var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", "filePath.cshtml", "c:\\myapp\\"); // Act var document = RazorSourceDocument.ReadFrom(projectItem); // Assert - Assert.Equal(projectItem.PhysicalPath, document.FilePath); + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); Assert.Equal(projectItem.Content, ReadContent(document)); } [Fact] - public void ReadFrom_ProjectItem() + public void ReadFrom_ProjectItem_NoRelativePath() { // Arrange - var projectItem = new TestRazorProjectItem("/test-path"); + var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", basePath: "c:\\myapp\\"); // Act var document = RazorSourceDocument.ReadFrom(projectItem); // Assert - Assert.Equal(projectItem.FilePath, document.FilePath); + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_FallbackToRelativePath() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", relativePhysicalPath: "filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_FallbackToFileName() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); Assert.Equal(projectItem.Content, ReadContent(document)); } @@ -112,6 +160,54 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Same(encoding, document.Encoding); } + [Fact] + public void Create_WithProperties() + { + // Arrange + var content = "Hello world"; + var properties = new RazorSourceDocumentProperties("c:\\myapp\\filePath.cshtml", "filePath.cshtml"); + + // Act + var document = RazorSourceDocument.Create(content, Encoding.UTF32, properties); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(content, ReadContent(document)); + Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); + } + + [Fact] + public void ReadFrom_WithProjectItem_FallbackToFilePath_WhenRelativePhysicalPathIsNull() + { + // Arrange + var filePath = "filePath.cshtml"; + var projectItem = new TestRazorProjectItem(filePath, relativePhysicalPath: null); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal(filePath, document.FilePath); + Assert.Equal(filePath, document.RelativePath); + } + + [Fact] + public void ReadFrom_WithProjectItem_UsesRelativePhysicalPath() + { + // Arrange + var filePath = "filePath.cshtml"; + var relativePhysicalPath = "relative-path.cshtml"; + var projectItem = new TestRazorProjectItem(filePath, relativePhysicalPath: relativePhysicalPath); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal(relativePhysicalPath, document.FilePath); + Assert.Equal(relativePhysicalPath, document.RelativePath); + } + private static string ReadContent(RazorSourceDocument razorSourceDocument) { var buffer = new char[razorSourceDocument.Length]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSyntaxTreeTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSyntaxTreeTest.cs index 54466376cd..09b36651ce 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSyntaxTreeTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSyntaxTreeTest.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test { // Arrange var filePath = "test.cshtml"; - var source = TestRazorSourceDocument.Create("@if (true) { @if(false) {

@something.
} }", fileName: filePath); + var source = TestRazorSourceDocument.Create("@if (true) { @if(false) {
@something.
} }", filePath: filePath); // Act var syntaxTree = RazorSyntaxTree.Parse(source); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs index 453788d36c..e77c5a05fa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs @@ -15,16 +15,16 @@ namespace Microsoft.AspNetCore.Razor.Language public void GetImports_CanQueryInformationOnNonExistentFileWithoutImports() { // Arrange - var project = new TestRazorProject(); + var fileSystem = new TestRazorProjectFileSystem(); var razorEngine = RazorEngine.Create(); - var templateEngine = new RazorTemplateEngine(razorEngine, project) + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem) { Options = { ImportsFileName = "MyImport.cshtml" } }; - var projectItemToQuery = project.GetItem("/Views/Home/Index.cshtml"); + var projectItemToQuery = fileSystem.GetItem("/Views/Home/Index.cshtml"); // Act var imports = templateEngine.GetImports(projectItemToQuery); @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var path = "/Views/Home/MyImport.cshtml"; var projectItem = new TestRazorProjectItem(path); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project) { @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Razor.Language public void GenerateCode_ThrowsIfItemCannotBeFound() { // Arrange - var project = new TestRazorProject(new RazorProjectItem[] { }); + var project = new TestRazorProjectFileSystem(new RazorProjectItem[] { }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Language public void SettingOptions_ThrowsIfValueIsNull() { // Arrange - var project = new TestRazorProject(new RazorProjectItem[] { }); + var project = new TestRazorProjectFileSystem(new RazorProjectItem[] { }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var path = "/Views/Home/Index.cshtml"; var projectItem = new TestRazorProjectItem(path); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var path = "/Views/Home/Index.cshtml"; - var project = new TestRazorProject(new RazorProjectItem[] { }); + var project = new TestRazorProjectFileSystem(new RazorProjectItem[] { }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -125,7 +125,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var path = "/Views/Home/Index.cshtml"; var projectItem = new TestRazorProjectItem(path); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -144,7 +144,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var path = "/Views/Home/Index.cshtml"; var projectItem = new TestRazorProjectItem(path); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); @@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project) { @@ -192,7 +192,7 @@ namespace Microsoft.AspNetCore.Razor.Language var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); var import1 = new TestRazorProjectItem("/MyImport.cshtml"); var import2 = new TestRazorProjectItem("/Views/Home/MyImport.cshtml"); - var project = new TestRazorProject(new[] { import1, import2, projectItem }); + var project = new TestRazorProjectFileSystem(new[] { import1, import2, projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project) { @@ -218,7 +218,7 @@ namespace Microsoft.AspNetCore.Razor.Language var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); var import1 = new TestRazorProjectItem("/MyImport.cshtml"); var import2 = new TestRazorProjectItem("/Views/Home/MyImport.cshtml"); - var project = new TestRazorProject(new[] { import1, import2, projectItem }); + var project = new TestRazorProjectFileSystem(new[] { import1, import2, projectItem }); var razorEngine = RazorEngine.Create(); var defaultImport = RazorSourceDocument.ReadFrom(new MemoryStream(), "Default.cshtml"); var templateEngine = new RazorTemplateEngine(razorEngine, project) @@ -245,7 +245,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); - var project = new TestRazorProject(new[] { projectItem }); + var project = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var defaultImport = RazorSourceDocument.ReadFrom(new MemoryStream(), "Default.cshtml"); var templateEngine = new RazorTemplateEngine(razorEngine, project) @@ -269,7 +269,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var expected = new[] { "/Views/Home/MyImport.cshtml", "/Views/MyImport.cshtml", "/MyImport.cshtml" }; - var project = new TestRazorProject(); + var project = new TestRazorProjectFileSystem(); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project) { @@ -293,9 +293,9 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var expected = new[] { "/Views/Home/MyImport.cshtml", "/Views/MyImport.cshtml", "/MyImport.cshtml" }; var projectItem = new TestRazorProjectItem("/Views/Home/Index.cshtml"); - var project = new TestRazorProject(new[] { projectItem }); + var fileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); var razorEngine = RazorEngine.Create(); - var templateEngine = new RazorTemplateEngine(razorEngine, project) + var templateEngine = new RazorTemplateEngine(razorEngine, fileSystem) { Options = { @@ -310,5 +310,51 @@ namespace Microsoft.AspNetCore.Razor.Language var paths = imports.Select(i => i.FilePath); Assert.Equal(expected, paths); } + + [Fact] + public void CreateCodeDocument_WithFileSystemProject_ReturnsCorrectItems() + { + // Arrange + var testFolder = Path.Combine( + TestProject.GetProjectDirectory(typeof(DefaultRazorProjectFileSystemTest)), + "TestFiles", + "DefaultRazorProjectFileSystem"); + + var project = new DefaultRazorProjectFileSystem(testFolder); + var razorEngine = RazorEngine.Create(); + var templateEngine = new RazorTemplateEngine(razorEngine, project) + { + Options = + { + ImportsFileName = "_ViewImports.cshtml" + } + }; + + // Act + var codeDocument = templateEngine.CreateCodeDocument("/Views/Home/Index.cshtml"); + + // Assert + Assert.Collection( + codeDocument.Imports, + item => + { + Assert.Equal(Path.Combine(testFolder, "_ViewImports.cshtml"), item.FilePath); + Assert.Equal("_ViewImports.cshtml", item.RelativePath); + + }, + item => + { + Assert.Equal(Path.Combine(testFolder, "Views", "_ViewImports.cshtml"), item.FilePath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePath); + + }, + item => + { + Assert.Equal(Path.Combine(testFolder, "Views", "Home", "_ViewImports.cshtml"), item.FilePath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePath); + + }); + } + } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs index ec7fd726ca..c2401c56b7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Language } [Fact] - public void Equals_ReturnsTrue_FilePathsNullAndAbsoluteIndicesMatch() + public void Equals_ReturnsFalse_FilePathsNullAndAbsoluteIndicesMatch() { // Arrange var sourceLocationA = new SourceLocation(10, 3, 4); @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Razor.Language var result = sourceLocationA.Equals(sourceLocationB); // Assert - Assert.True(result); + Assert.False(result); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs index 84163a1c57..f377450320 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs @@ -10,13 +10,69 @@ namespace Microsoft.AspNetCore.Razor.Language { public class StreamSourceDocumentTest { + [Fact] + public void FilePath() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "file.cshtml", relativePath: null)); + + // Assert + Assert.Equal("file.cshtml", document.FilePath); + } + + [Fact] + public void FilePath_Null() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.FilePath); + } + + [Fact] + public void RelativePath() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: "file.cshtml")); + + // Assert + Assert.Equal("file.cshtml", document.RelativePath); + } + + [Fact] + public void RelativePath_Null() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.RelativePath); + } + [Fact] public void GetChecksum_ReturnsCopiedChecksum() { // Arrange var content = "Hello World!"; var stream = CreateBOMStream(content, Encoding.UTF8); - var document = new StreamSourceDocument(stream, Encoding.UTF8, "file.cshtml"); + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); // Act var firstChecksum = document.GetChecksum(); @@ -33,7 +89,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello World!"; var stream = CreateBOMStream(content, Encoding.UTF8); - var document = new StreamSourceDocument(stream, Encoding.UTF8, "file.cshtml"); + var document = new StreamSourceDocument(stream, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 70, 180, 84, 105, 70, 79, 152, 31, 71, 157, 46, 159, 50, 83, 1, 243, 222, 48, 90, 18 }; // Act @@ -49,7 +105,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello World!"; var stream = CreateBOMStream(content, Encoding.UTF32); - var document = new StreamSourceDocument(stream, encoding: null, fileName: "file.cshtml"); + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 159, 154, 109, 89, 250, 163, 165, 108, 2, 112, 34, 4, 247, 161, 82, 168, 77, 213, 107, 71 }; // Act @@ -66,11 +122,10 @@ namespace Microsoft.AspNetCore.Razor.Language var content = TestRazorSourceDocument.CreateStreamContent(encoding: Encoding.UTF32); // Act - var document = new StreamSourceDocument(content, encoding: null, fileName: "file.cshtml"); + var document = new StreamSourceDocument(content, null, RazorSourceDocumentProperties.Default); // Assert Assert.IsType(document); - Assert.Equal("file.cshtml", document.FilePath); Assert.Equal(Encoding.UTF32, document.Encoding); } @@ -81,11 +136,10 @@ namespace Microsoft.AspNetCore.Razor.Language var content = TestRazorSourceDocument.CreateStreamContent(content: string.Empty, encoding: Encoding.UTF32); // Act - var document = new StreamSourceDocument(content, encoding: null, fileName: "file.cshtml"); + var document = new StreamSourceDocument(content, null, RazorSourceDocumentProperties.Default); // Assert Assert.IsType(document); - Assert.Equal("file.cshtml", document.FilePath); Assert.Equal(Encoding.UTF32, document.Encoding); } @@ -98,7 +152,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Act & Assert var exception = Assert.Throws( - () => new StreamSourceDocument(content, Encoding.UTF8, "file.cshtml")); + () => new StreamSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default)); Assert.Equal(expectedMessage, exception.Message); } @@ -115,12 +169,11 @@ namespace Microsoft.AspNetCore.Razor.Language var stream = TestRazorSourceDocument.CreateStreamContent(content); // Act - var document = new StreamSourceDocument(stream, encoding: null, fileName: "file.cshtml"); + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); // Assert var streamDocument = Assert.IsType(document); Assert.IsType(streamDocument._innerSourceDocument); - Assert.Equal("file.cshtml", document.FilePath); Assert.Same(Encoding.UTF8, document.Encoding); Assert.Equal(content, ReadContent(document)); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs index 16acfc8be9..8306d2bf80 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, "file.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var firstChecksum = document.GetChecksum(); @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, "file.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 46, 247, 189, 230, 8, 206, 84, 4, 233, 125, 95, 4, 47, 149, 248, 159, 28, 35, 40, 113 }; // Act @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello World!"; - var document = new StringSourceDocument(content, Encoding.UTF32, "file.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF32, RazorSourceDocumentProperties.Default); var expectedChecksum = new byte[] { 8, 149, 159, 15, 242, 255, 115, 227, 219, 78, 61, 53, 127, 239, 77, 239, 215, 140, 248, 44 }; // Act @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var expectedContent = "Hello, World!"; var indexerBuffer = new char[expectedContent.Length]; - var document = new StringSourceDocument(expectedContent, Encoding.UTF8, filePath: "file.cshtml"); + var document = new StringSourceDocument(expectedContent, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act for (var i = 0; i < document.Length; i++) @@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var expectedContent = "Hello, World!"; - var document = new StringSourceDocument(expectedContent, Encoding.UTF8, filePath: "file.cshtml"); + var document = new StringSourceDocument(expectedContent, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act & Assert Assert.Equal(expectedContent.Length, document.Length); @@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.Razor.Language var content = "Hello, World!"; // Act - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: "file.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "file.cshtml", relativePath: null)); // Assert Assert.Equal("file.cshtml", document.FilePath); @@ -104,18 +104,44 @@ namespace Microsoft.AspNetCore.Razor.Language var content = "Hello, World!"; // Act - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); // Assert Assert.Null(document.FilePath); } + [Fact] + public void RelativePath() + { + // Arrange + var content = "Hello, World!"; + + // Act + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: "file.cshtml")); + + // Assert + Assert.Equal("file.cshtml", document.RelativePath); + } + + [Fact] + public void RelativePath_Null() + { + // Arrange + var content = "Hello, World!"; + + // Act + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.RelativePath); + } + [Fact] public void CopyTo_PartialCopyFromStart() { // Arrange var content = "Hello, World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedContent = "Hello"; var charBuffer = new char[expectedContent.Length]; @@ -132,7 +158,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello, World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedContent = "$Hello"; var charBuffer = new char[expectedContent.Length]; charBuffer[0] = '$'; @@ -150,7 +176,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "Hello, World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); var expectedContent = "World"; var charBuffer = new char[expectedContent.Length]; @@ -162,28 +188,12 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(expectedContent, copiedContent); } - [Fact] - public void CopyTo_WithEncoding() - { - // Arrange - var content = "Hi"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); - var charBuffer = new char[2]; - - // Act - document.CopyTo(0, charBuffer, 0, 2); - - // Assert - var copiedContent = new string(charBuffer); - Assert.Equal("Hi", copiedContent); - } - [Fact] public void CopyTo_CanCopyMultipleTimes() { // Arrange var content = "Hi"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act & Assert // @@ -202,7 +212,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = string.Empty; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.Count; @@ -216,7 +226,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = string.Empty; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLineLength(0); @@ -230,7 +240,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "hello\n"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLineLength(0); @@ -244,7 +254,7 @@ namespace Microsoft.AspNetCore.Razor.Language { // Arrange var content = "hello\r\n"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLineLength(0); @@ -263,7 +273,7 @@ namespace Microsoft.AspNetCore.Razor.Language .Append("jumps over the lazy dog.") .ToString(); - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -278,7 +288,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -293,7 +303,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\rWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -309,7 +319,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\rBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -324,7 +334,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -339,7 +349,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\u0085World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -354,7 +364,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\u2028World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -369,7 +379,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\u2029World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = GetAllSourceMappings(document); @@ -384,7 +394,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello, World!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: "Hi.cshtml"); + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "Hi.cshtml", relativePath: null)); // Act var actual = document.Lines.GetLocation(1); @@ -394,6 +404,22 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(1, actual.AbsoluteIndex); } + [Fact] + public void Lines_GetLocation_PrefersRelativePath() + { + // Arrange + var content = "Hello, World!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "Hi.cshtml", relativePath: "Bye.cshtml")); + + // Act + var actual = document.Lines.GetLocation(1); + + // Assert + Assert.Equal("Bye.cshtml", actual.FilePath); + Assert.Equal(1, actual.AbsoluteIndex); + } + // Beginnings of lines are special because the BinarySearch in the implementation // will succeed. It's a different code path. [Fact] @@ -402,7 +428,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(0); @@ -418,7 +444,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(5); @@ -434,7 +460,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(7); @@ -450,7 +476,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(11); @@ -466,7 +492,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var content = "Hello\nBig\r\nWorld!"; - var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null); + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); // Act var actual = document.Lines.GetLocation(16); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Home.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Home.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Home.cshtml rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Home.cshtml diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/About/About.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/About/About.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/About/About.cshtml rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/About/About.cshtml diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/Index.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/Index.cshtml rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.cshtml diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/Index.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.txt similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/Index.txt rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.txt diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt index 2e159a5cba..6142bc2eb1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt @@ -1,4 +1,6 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt index 2e159a5cba..6142bc2eb1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt @@ -1,4 +1,6 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt index 98b909d3f4..83409ed68c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [13] HelloWorld.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs index 4436f2c17b..32dba3fdc3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ea06819774d4f892a37cc84688446440dee29bd6" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ea06819774d4f892a37cc84688446440dee29bd6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("catchAll", new global::Microsoft.AspNetCore.Html.HtmlString("hi"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt index 25aafc533b..1fbf6fd6c7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - catchAll - hi - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs index d5996bfd6b..5b92f3a416 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "00b5e01b7a405dcfde7e4d512ee930daaa1778b5" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"00b5e01b7a405dcfde7e4d512ee930daaa1778b5", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt index 1f2ab0b7c2..1890add00a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (91:6,0 [100] Await.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs index 171a43089d..bec15180ea 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.codegen.cs @@ -1,6 +1,7 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d351c0c4dc0afdbf46547fcd87692951d2e4871f" // #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 @@ -19,6 +20,9 @@ using System.Text; #line default #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d351c0c4dc0afdbf46547fcd87692951d2e4871f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8aa538f3517d6d8922adaf817015cf8a61a57046", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports0.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ad27b5360a3a2ab427f824e417620a745c0f45de", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Imports1.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_Runtime : Hello { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt index a50f1190ac..014ca50451 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_Runtime.ir.txt @@ -1,8 +1,12 @@ 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) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs index 979b35b5b0..5b647f3ed5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e05d346bc9435e651c4c8f34515c1b5f2cff294a" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e05d346bc9435e651c4c8f34515c1b5f2cff294a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt index c9d169d3af..f78f3256b9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs index 001fa0894b..116a67d3f1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8479a280916bffac36ca773a941b3f9155fe4ace" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8479a280916bffac36ca773a941b3f9155fe4ace", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt index d6c82f8c3c..ef78c52e75 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs index fd36bca122..716d143e8b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "56c40717284b82fcb2ee9f60f09e8c6c0bda8959" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"56c40717284b82fcb2ee9f60f09e8c6c0bda8959", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data", new global::Microsoft.AspNetCore.Html.HtmlString("-delay1000"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt index a5acd5c506..ce7caef785 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - data - -delay1000 - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs index 1dae6c06c2..f491305fbf 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ba7d8f5f5159a2389c780aa606885ef6c917a45a" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ba7d8f5f5159a2389c780aa606885ef6c917a45a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt index ad45f51432..9fa7984a1d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [18] Blocks.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs index 3821c22d4d..4764d6208a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d287720a0df9d4595ed4f009c44479d9c7b0a800" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d287720a0df9d4595ed4f009c44479d9c7b0a800", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt index e7d0eb4998..ff3f1b48ff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [8] CSharp7.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt index 9fb02062cb..c3072c6248 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs index 9cfca93cb8..546075b30f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5f82673b13daf5e28291f3bfb58df5e3a94e13cc" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5f82673b13daf5e28291f3bfb58df5e3a94e13cc", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt index 9fb02062cb..c3072c6248 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt index c905d540e8..daf2692204 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [0] CodeBlockAtEOF.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs index dba89ef37d..669b4af337 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "13e48ff59aab8106ceb68dd4a10b0bdf10c322fc" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"13e48ff59aab8106ceb68dd4a10b0bdf10c322fc", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt index 1dccf74278..0c163f3a41 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [17] CodeBlockWithTextElement.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs index 328c5c3e99..20f8423105 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "019ce8023d064d08ca88c597b764aea895ec5841" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"019ce8023d064d08ca88c597b764aea895ec5841", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt index 962866d7d7..f700c27032 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [115] CodeBlock.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs index f35abe18ef..49b9f25807 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6c8cd00002dfc24a4fd1b1c3f079728b7697257f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6c8cd00002dfc24a4fd1b1c3f079728b7697257f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt index ca0a9a40fe..92bc67f8c6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - value - - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs index f990427ccb..d0a163333f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "088be4e50958bcab0f1d1ac04d2c28dcd8049bf5" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"088be4e50958bcab0f1d1ac04d2c28dcd8049bf5", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.ir.txt index 120563b3f3..3b1e6f21df 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [44] ConditionalAttributes.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs index 9db2df6588..98e21a7edc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1ba28534da506a7c741c3d82251fd700658ff7c8" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"1ba28534da506a7c741c3d82251fd700658ff7c8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("href", new global::Microsoft.AspNetCore.Html.HtmlString("~/"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt index 7f6deff99d..ef34c24d71 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - href - ~/ - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - href - ~/hello - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs index 1253a67096..88d12d14f5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f64041250fa76433a1542ae43458ed7ba286a01c" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f64041250fa76433a1542ae43458ed7ba286a01c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "button", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt index 5280049d8c..f2e84ead91 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - button - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - TYPE - checkbox - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs index 7fdf724432..4e0cb04880 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cce7d92553451468e4599af8a8329633dbad75a3" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"cce7d92553451468e4599af8a8329633dbad75a3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt index 276a121283..d86a4d2b8c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs index 1a008757c0..ad9774545c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e044ca9442dd9f93d8ce7f93a79c46a542221f1e" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e044ca9442dd9f93d8ce7f93a79c46a542221f1e", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime { #line hidden diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt index 7695ef4f6c..72a0832670 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime - - DefaultTagHelperRuntime - FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt index f4d4633005..0b20997aff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt @@ -1,3 +1,3 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ9999: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ9999: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ9999: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ2008: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs index d62ca0372c..bdcfeab925 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ebd7c5a5d3edbcd879a6437ec728fafa9c84d312" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ebd7c5a5d3edbcd879a6437ec728fafa9c84d312", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt index f4d4633005..0b20997aff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt @@ -1,3 +1,3 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ9999: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ9999: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ9999: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ2008: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt index cc0af5d4a2..f8c39dee99 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs index bc4425b55b..4d127cd32d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a81f9de6dc302ab6600f3808428e5247ed389511" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a81f9de6dc302ab6600f3808428e5247ed389511", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt index 8c313f73c7..75e7307e0f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] EmptyCodeBlock.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs index 6ff66e6a8c..45b4ed17d0 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e6467906896d16277c5a0cf962ac6d863c58852f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e6467906896d16277c5a0cf962ac6d863c58852f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt index 23c889ee0f..c3daa8feb5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] EmptyExplicitExpression.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt index c0a89d2ef4..84ac278f6d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs index 993c4303fb..6a7443dbc7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b21853e37dde51b305bde9602624934d4d6affd3" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"b21853e37dde51b305bde9602624934d4d6affd3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt index c0a89d2ef4..84ac278f6d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt index 952bf2bcb0..b910f3841c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt index 862260264e..5524460d0c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ9999: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs index 46eeadae27..599ecb7a1e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8ed47ba5d7cac644fdbb2c4f816d49bdeed1ac45" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8ed47ba5d7cac644fdbb2c4f816d49bdeed1ac45", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt index 862260264e..5524460d0c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ9999: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt index e404569687..e4187049bb 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] EmptyImplicitExpression.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs index e665652ed6..58378b6745 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c55ebb3869f93768c36d432f769272b9f8feeb0b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c55ebb3869f93768c36d432f769272b9f8feeb0b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime { #line hidden diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt index d7dced8096..e38db1bbaa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime - - DefaultTagHelperRuntime - FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs index 349f6fdcbe..a35cbde3b6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e082322a2f2c103fcc2779608d1ef7fe4b915d75" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e082322a2f2c103fcc2779608d1ef7fe4b915d75", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime { #line hidden diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt index 272ff7b035..18242c571b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime - - DefaultTagHelperRuntime - FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt index 2050eeea35..4e0bfb131d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs index 636c407d05..584fb48088 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "bf53afff8ab65f1af9b9a82f9a571f1cd023dfc0" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"bf53afff8ab65f1af9b9a82f9a571f1cd023dfc0", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt index 2050eeea35..4e0bfb131d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt index a435fb6858..5f459014c8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] ExplicitExpressionAtEOF.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt index ee9b4f9d6f..16ad2a09d5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ9999: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs index 110345b36b..af26048758 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1252c799cdeb86a71e4304f01ebaae540fa26894" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"1252c799cdeb86a71e4304f01ebaae540fa26894", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt index ee9b4f9d6f..16ad2a09d5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ9999: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt index b112ccd9bd..dde86a08b2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [5] ExplicitExpressionWithMarkup.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs index 09073c2d96..ed1147c800 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a897a227b26c531d644bdff988df46d3c8178346" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a897a227b26c531d644bdff988df46d3c8178346", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt index 1d4d7afbba..c1867efbb6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [8] ExplicitExpression.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs index b603e0f752..7668b46128 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8c7ae67489dbddec9f2dbef3c2b65def1149e507" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8c7ae67489dbddec9f2dbef3c2b65def1149e507", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt index aa1cb230d8..d87e4b1d61 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [51] ExpressionsInCode.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs index afbbbb4419..1a9e0dd74c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "366e1cb1c026413435ec398a7d47c8c1acc373d8" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"366e1cb1c026413435ec398a7d47c8c1acc373d8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt index be99b1fcf0..2d4242e8c4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [4] FunctionsBlockMinimal.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs index cbfb302cb7..1ad1a373f5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "94813053694a285515d791c48d703f1131881d0c" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"94813053694a285515d791c48d703f1131881d0c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt index 5e1a08efbf..4b05dbcc3d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (19:3,0 [2] FunctionsBlock.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs index bb860eeb2c..21bbadd378 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5bd51d8947ca920e594be8d214b4ebee2888c90c" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5bd51d8947ca920e594be8d214b4ebee2888c90c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt index 7b24771c9f..92fc13fef7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [6] HiddenSpansInCode.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs index 3fd49516ac..7bd80ff77f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a07711bc1fd0478b3b8329a68ab2028ef93429df" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a07711bc1fd0478b3b8329a68ab2028ef93429df", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt index 2514947c95..343985c189 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Double.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs index 6fe7a287ab..9c3354b3c1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2d9bb4407e7aac9563aaeac9f0534a48f54e3d44" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2d9bb4407e7aac9563aaeac9f0534a48f54e3d44", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt index c63e151ad0..65aafb6fe7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Single.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt index 1fd198f0e7..e2a8c29095 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: 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: "@@" +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs index 98187d4e98..12759ba9cc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ecf286733e30e006a630f3a5fe87c21f45e4c807" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ecf286733e30e006a630f3a5fe87c21f45e4c807", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt index 1fd198f0e7..e2a8c29095 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: 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: "@@" +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt index acad1cd788..b2ac3e3520 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [18] ImplicitExpressionAtEOF.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs index 0fd158c731..e202aca56f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "77befd9645f3c2d9ab48b935faebf9f731f42abc" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"77befd9645f3c2d9ab48b935faebf9f731f42abc", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt index 8d54e46136..c3d0aaab02 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (1:0,1 [32] ImplicitExpression.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index b9c22ace19..b01ced2ed2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,27 +1,27 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ9999: 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 RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ9999: 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 RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. +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(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(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(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(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(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(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. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: 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(13,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(13,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ9999: The 'inherits' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ9999: The functions 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1020: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ2001: The 'inherits' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ1006: The functions 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs index 2aca243fd5..317dfab9e5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "df5d66431db818236f9c26c6dd920838c22ddb82" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"df5d66431db818236f9c26c6dd920838c22ddb82", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt index b9c22ace19..b01ced2ed2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -1,27 +1,27 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ9999: 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 RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ9999: 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 RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. +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(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(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(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(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(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(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. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: 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(13,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(13,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ9999: The 'inherits' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ9999: The functions 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1020: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ2001: The 'inherits' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ1006: The functions 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt index aad13cff1a..ecffead8c5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (83:0,83 [4] IncompleteDirectives.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.diagnostics.txt index 96431ecdd6..10a2d590e2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ9999: Missing close angle for tag helper 'p'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ9999: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ1035: Missing close angle for tag helper 'p'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.codegen.cs index 9ff13d0996..a83e98b757 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2b8b22f00f74af242e046b0dd3ab40dc54d6bfd8" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2b8b22f00f74af242e046b0dd3ab40dc54d6bfd8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteTagHelper_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString(""), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.diagnostics.txt index 96431ecdd6..10a2d590e2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ9999: Missing close angle for tag helper 'p'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ9999: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ1035: Missing close angle for tag helper 'p'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml(3,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.ir.txt index b90f2c3d58..dfc5fa13b1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteTagHelper_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.codegen.cs index b148ac5fc5..1598a627ce 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d5c565b0bb468550fca15010c0addc84e79c5297" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inherits_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d5c565b0bb468550fca15010c0addc84e79c5297", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inherits_Runtime : foo.bar>.boz { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.ir.txt index 37b754242a..e901fffac8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inherits_Runtime - foo.bar>.boz - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (33:1,0 [2] Inherits.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt index 78599522c6..66af9b7600 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ9999: Unexpected literal following the 'section' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ1017: Unexpected literal following the 'section' directive. Expected '{'. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.codegen.cs index c2a28a3ec1..379ffda090 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e827e93343a95c7254a19287b095dfba9390d29f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InlineBlocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e827e93343a95c7254a19287b095dfba9390d29f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InlineBlocks_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt index 78599522c6..66af9b7600 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ9999: Unexpected literal following the 'section' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ1017: Unexpected literal following the 'section' directive. Expected '{'. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.ir.txt index 30f475ca18..eb8fd5d9f6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InlineBlocks_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync MalformedDirective - (0:0,0 [13] InlineBlocks.cshtml) - section diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs index 3b11d9997a..29d4fd3dcc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "9b521264e3e64710635c0f0490a368845d90da66" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"9b521264e3e64710635c0f0490a368845d90da66", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt index 5259662cfa..2fb8fdbe9b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [32] Instrumented.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs index a93678cbb6..834f466573 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cf059b36d7e93e260c1d5b852f7a59e6c99ae33d" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"cf059b36d7e93e260c1d5b852f7a59e6c99ae33d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt index 9f46cfe6c7..a543cca51d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [38] MarkupInCodeBlock.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs index ce9b852bf4..ee273d41e8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ab8c9a5af38d07138a55ae82942b4a97fe3c9025" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ab8c9a5af38d07138a55ae82942b4a97fe3c9025", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("btn"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt index e27c841eb8..20205a9756 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - btn - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - input-bound-required-string - hello - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs index c6a8e7f124..06a3a3c037 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2b9e8dcf7c08153c15ac84973938a7c0254f2369" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2b9e8dcf7c08153c15ac84973938a7c0254f2369", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt index b814b88e6f..1c240ea1bd 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [6] NestedCSharp.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs index c6862dcdc9..64f2c350ee 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a4eb7397719094ea9da5b7d6674d317314fa26b4" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a4eb7397719094ea9da5b7d6674d317314fa26b4", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt index 354dcf1292..2c0030ec65 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (1:0,1 [15] NestedCodeBlocks.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs index 31f4c1d8d3..f5a9f556c1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "880f98e8cc874c7736b089ea69af2461a11eacb2" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"880f98e8cc874c7736b089ea69af2461a11eacb2", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt index 8202635abb..7041d3c6fc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs index 273ceb63fa..4d6202ca35 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "fc99ab53936074d66d80552f780e58d4edb223d6" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"fc99ab53936074d66d80552f780e58d4edb223d6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt index c4d6a65257..f4c6001b80 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs index 78a2256f26..9ba267ed22 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "682929a2038f56f4737f1b7aa3c9eaa5488cc001" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"682929a2038f56f4737f1b7aa3c9eaa5488cc001", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt index 7c45b1a26c..133177b5c4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [18] NoLinePragmas.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs index 270cc5abfb..03296645f6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c8c4f34e0768aea12ef6ce8e3fe0e384ad023faf" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c8c4f34e0768aea12ef6ce8e3fe0e384ad023faf", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt index 0cc5a8ac6e..8fd7d3dc26 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [6] NullConditionalExpressions.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt index 3d3db9befd..49f293ec33 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt @@ -1,3 +1,3 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ9999: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ9999: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ1026: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs index 3c5f300875..d121325445 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "608d7aa10b6df6798d8259379837fa7ffb088ed6" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"608d7aa10b6df6798d8259379837fa7ffb088ed6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt index 3d3db9befd..49f293ec33 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt @@ -1,3 +1,3 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ9999: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ9999: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ1026: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt index 47bbd0deea..24ee8b0ec7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [16] OpenedIf.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt index 2d6f4fb000..1a25d90e26 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ9999: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs index c7d7962e05..55f7c0863f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "99e6be6b384d3f247935d3cb15564542b7a82e43" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"99e6be6b384d3f247935d3cb15564542b7a82e43", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt index 2d6f4fb000..1a25d90e26 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt @@ -1,2 +1,2 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ9999: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt index 219de0c125..8f60e461b4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [31] ParserError.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs index 9b37c7dd64..b8304fbc65 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6e6edd0cad896f8dbf05be369b813477046ccd40" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6e6edd0cad896f8dbf05be369b813477046ccd40", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("checkbox"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt index b6df7d0360..892245a292 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - password - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs index 6a28ece18f..beef9c9cf4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "45c16f152aef80d7de27c7df32dc522af5842197" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"45c16f152aef80d7de27c7df32dc522af5842197", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt index 74944e4a55..e05218677f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (36:0,36 [17] RazorComments.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs index 128b60701f..d5276e436e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ec9a74381c339244a887565526c11056ece494a3" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ec9a74381c339244a887565526c11056ece494a3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt index bfe56628c3..be452577fe 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [44] Sections.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs index dc69621e9e..afb4239f5b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "248dc9c0c1ef35d3636cfb2fa7f5ac0f8a0b553a" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"248dc9c0c1ef35d3636cfb2fa7f5ac0f8a0b553a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt index bd8c027f6d..818e754db8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.SingleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs index c9637b930c..3f3c71b734 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8501407d5716c727ebc0ba157b04442cd2c302ff" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8501407d5716c727ebc0ba157b04442cd2c302ff", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt index e985b716c0..d12d18e89b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (1:0,1 [14] SimpleUnspacedIf.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs index f0a295667d..a9a6b7dcf6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1fcd2e2ee0b7146c8c0ec8a1721b4ffdc71e9f1e" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"1fcd2e2ee0b7146c8c0ec8a1721b4ffdc71e9f1e", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt index fd4b3da51b..fb67e469d9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs index 2f35981c40..3c867bb000 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a46ef1b45affd451aae23202a87f93feb5c454f4" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a46ef1b45affd451aae23202a87f93feb5c454f4", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt index 669a0da2c8..89ef050a2c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs index ba174de703..2f31e6d4bc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3c21118a6113e76e4f71d17e3ae081f13d451427" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"3c21118a6113e76e4f71d17e3ae081f13d451427", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt index ff5b980f15..33d3408bbe 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [2013] StringLiterals.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs index b58999afa1..544de2e533 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "10f840b503550891681c6569925ce1a183d07e75" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"10f840b503550891681c6569925ce1a183d07e75", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("[item]", new global::Microsoft.AspNetCore.Html.HtmlString("items"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt index eb9578becc..ee4dc7af83 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - [item] - items - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - [(item)] - items - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs index 1d3fbf2f83..c616234186 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "97d0dc6305d8a47fd3d81a127119f47417862f1a" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"97d0dc6305d8a47fd3d81a127119f47417862f1a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime { #line hidden diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt index ce67807512..0b89183f3e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime - - DefaultTagHelperRuntime - FieldDeclaration - - private - global::TestNamespace.MyTagHelper - __TestNamespace_MyTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs index aea09e502d..3f948f363e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f7ed8b06f7ede1d7928dc05f2b2f081a3fda13aa" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f7ed8b06f7ede1d7928dc05f2b2f081a3fda13aa", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt index 3080abaccb..c3d5ddf52e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.SingleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs index 9da2d505d3..9cd583768b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "984b7fd00fa0286dd56ceda786fa7cf893520df6" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"984b7fd00fa0286dd56ceda786fa7cf893520df6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt index be6d6f5006..6d6437abfc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.SingleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs index f19b98782a..e32ab23204 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f1ffadb1ad9c279ac40218b45a1688ac2f3ea857" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f1ffadb1ad9c279ac40218b45a1688ac2f3ea857", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("checkbox"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt index 9f0f34cf62..d53344f511 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - checked - true - HtmlAttributeValueStyle.DoubleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs index 7688fb821a..a992eb99bd 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d02c1a0d63df91a5ffded6b9a62cfda3584cbd5f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d02c1a0d63df91a5ffded6b9a62cfda3584cbd5f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt index 8bdd5747a6..e6920b3067 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs index 6f8c421068..b807c1364e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8a16b856f52a2ed469347984184b8ac48080234f" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8a16b856f52a2ed469347984184b8ac48080234f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.ir.txt index 23fafbfe40..4416a51d48 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (280:9,0 [2] Templates.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt index e966770db2..cc0379e358 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ9999: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ1007: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.codegen.cs index 725a855e7f..190b9da31f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f3bafd9eaf3c9718228a830b5c71dc8536f1f7f2" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TransitionsInTagHelperAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f3bafd9eaf3c9718228a830b5c71dc8536f1f7f2", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TransitionsInTagHelperAttributes_Runtime { private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("test"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt index e966770db2..cc0379e358 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ9999: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ1007: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.ir.txt index 78aaa1d48f..6a6678ed86 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TransitionsInTagHelperAttributes_Runtime - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - test - HtmlAttributeValueStyle.DoubleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.codegen.cs index 42832a4d16..977030b04d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.codegen.cs @@ -1,9 +1,11 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "80cd1011b7b46797f36c184b68c352568ccc5060" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UnfinishedExpressionInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"80cd1011b7b46797f36c184b68c352568ccc5060", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UnfinishedExpressionInCode_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.ir.txt index af1bffd6c9..a9958a1a62 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UnfinishedExpressionInCode_Runtime.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UnfinishedExpressionInCode_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync CSharpCode - (2:0,2 [2] UnfinishedExpressionInCode.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.codegen.cs index 3bf81585f8..a1d0456d97 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.codegen.cs @@ -1,6 +1,7 @@ #pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f452adb7c255f6d9d6d2573c6add7cb28022b151" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Usings_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings.cshtml")] namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden @@ -34,6 +35,7 @@ using static global::System.Text.Encoding; #line default #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f452adb7c255f6d9d6d2573c6add7cb28022b151", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings.cshtml")] public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Usings_Runtime { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.ir.txt index 5e496ebd41..bdb82e73ec 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Usings_Runtime.ir.txt @@ -1,4 +1,5 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles UsingDirective - (1:0,1 [17] Usings.cshtml) - System.IO UsingDirective - (19:1,1 [34] Usings.cshtml) - Foo = System.Text.Encoding @@ -6,6 +7,7 @@ Document - UsingDirective - (71:4,1 [21] Usings.cshtml) - static System UsingDirective - (93:5,1 [29] Usings.cshtml) - static System.Console UsingDirective - (123:6,1 [43] Usings.cshtml) - static global::System.Text.Encoding + RazorSourceChecksumAttribute - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Usings_Runtime - - MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (68:3,0 [2] Usings.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt index 9b753e743e..e5c8ff35aa 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithConditionalAttribute.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [25] HtmlWithConditionalAttribute.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt index 25a8f89a4d..3486809b58 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/HtmlAttributeIntegrationTest/HtmlWithDataDashAttribute.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync HtmlContent - (0:0,0 [36] HtmlWithDataDashAttribute.cshtml) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs index 6961cd2e4d..38d08a7c75 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs @@ -1,9 +1,10 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.cshtml")] namespace Razor { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"38aa8e26c5d2a85c61d8e93fe69dd326fe82671b", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.cshtml")] public class Template : MyBaseType { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs index f4c0b6d245..2baca26a3f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs @@ -1,9 +1,10 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.MyClass), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.cshtml")] namespace Razor { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"38aa8e26c5d2a85c61d8e93fe69dd326fe82671b", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.cshtml")] protected internal class MyClass : CustomBaseType, global::System.IDisposable { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs index 30f1118650..0ca4f5d061 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs @@ -1,9 +1,10 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.cshtml")] namespace Razor { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"38aa8e26c5d2a85c61d8e93fe69dd326fe82671b", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.cshtml")] public class Template { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs index 7386ae0b19..8cff2ae67f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs @@ -1,9 +1,10 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(MyApp.Razor.Views.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.cshtml")] namespace MyApp.Razor.Views { #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"38aa8e26c5d2a85c61d8e93fe69dd326fe82671b", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.cshtml")] public class Template { #pragma warning disable 1998 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/NestedTagHelpers.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/NestedTagHelpers.ir.txt index 021d34383a..ab0e72e99a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/NestedTagHelpers.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/NestedTagHelpers.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/SimpleTagHelpers.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/SimpleTagHelpers.ir.txt index 12ebcf7df3..80661692b6 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/SimpleTagHelpers.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/SimpleTagHelpers.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.SingleQuotes PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/TagHelpersWithBoundAttributes.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/TagHelpersWithBoundAttributes.ir.txt index 2dd09583c8..3a72431dd8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/TagHelpersWithBoundAttributes.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/TagHelpersIntegrationTest/TagHelpersWithBoundAttributes.ir.txt @@ -1,5 +1,7 @@ Document - + RazorCompiledItemAttribute - NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - ClassDeclaration - - public - Template - - PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.SingleQuotes DefaultTagHelperRuntime - diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProject.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestRazorProject.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProject.cs rename to test/Microsoft.AspNetCore.Razor.Language.Test/TestRazorProject.cs diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/VirtualRazorProjectFileSystemTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/VirtualRazorProjectFileSystemTest.cs new file mode 100644 index 0000000000..f4501b1321 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/VirtualRazorProjectFileSystemTest.cs @@ -0,0 +1,400 @@ +// 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 Xunit; +using DirectoryNode = Microsoft.AspNetCore.Razor.Language.VirtualRazorProjectFileSystem.DirectoryNode; +using FileNode = Microsoft.AspNetCore.Razor.Language.VirtualRazorProjectFileSystem.FileNode; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class VirtualRazorProjectFileSystemTest + { + [Fact] + public void GetItem_ReturnsNotFound_IfFileDoesNotExistInRoot() + { + // Arrange + var path = "/root-file.cshtml"; + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + projectSystem.Add(new TestRazorProjectItem("/different-file.cshtml")); + var result = projectSystem.GetItem(path); + + // Assert + Assert.False(result.Exists); + } + + [Fact] + public void GetItem_ReturnsItemAddedToRoot() + { + // Arrange + var path = "/root-file.cshtml"; + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem(path); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem(path); + + // Assert + Assert.Same(projectItem, actual); + } + + [Theory] + [InlineData("/subDirectory/file.cshtml")] + [InlineData("/subDirectory/dir2/file.cshtml")] + [InlineData("/subDirectory/dir2/dir3/file.cshtml")] + public void GetItem_ReturnsItemAddedToNestedDirectory(string path) + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem(path); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem(path); + + // Assert + Assert.Same(projectItem, actual); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenNestedDirectoryDoesNotExist() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + var actual = projectSystem.GetItem("/subDirectory/dir3/file.cshtml"); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenNestedDirectoryDoesNotExist_AndPeerDirectoryExists() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem("/subDirectory/dir2/file.cshtml"); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem("/subDirectory/dir3/file.cshtml"); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenFileDoesNotExistInNestedDirectory() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem("/subDirectory/dir2/file.cshtml"); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem("/subDirectory/dir2/file2.cshtml"); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void EnumerateItems_AtRoot_ReturnsAllFiles() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var file1 = new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml"); + var file2 = new TestRazorProjectItem("/file2.cshtml"); + var file3 = new TestRazorProjectItem("/dir3/file3.cshtml"); + var file4 = new TestRazorProjectItem("/subDirectory/file4.cshtml"); + projectSystem.Add(file1); + projectSystem.Add(file2); + projectSystem.Add(file3); + projectSystem.Add(file4); + + // Act + var result = projectSystem.EnumerateItems("/"); + + // Assert + Assert.Equal(new[] { file2, file4, file1, file3 }, result); + } + + [Fact] + public void EnumerateItems_AtSubDirectory_ReturnsAllFilesUnderDirectoryHierarchy() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var file1 = new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml"); + var file2 = new TestRazorProjectItem("/file2.cshtml"); + var file3 = new TestRazorProjectItem("/dir3/file3.cshtml"); + var file4 = new TestRazorProjectItem("/subDirectory/file4.cshtml"); + projectSystem.Add(file1); + projectSystem.Add(file2); + projectSystem.Add(file3); + projectSystem.Add(file4); + + // Act + var result = projectSystem.EnumerateItems("/subDirectory"); + + // Assert + Assert.Equal(new[] { file4, file1 }, result); + } + + [Fact] + public void EnumerateItems_WithNoFilesInRoot_ReturnsEmptySequence() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + var result = projectSystem.EnumerateItems("/"); + + // Assert + Assert.Empty(result); + } + + [Fact] + public void EnumerateItems_ForNonExistentDirectory_ReturnsEmptySequence() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + projectSystem.Add(new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml")); + projectSystem.Add(new TestRazorProjectItem("/file2.cshtml")); + + // Act + var result = projectSystem.EnumerateItems("/dir3"); + + // Assert + Assert.Empty(result); + } + + [Fact] + public void GetHierarchicalItems_Works() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var viewImport1 = new TestRazorProjectItem("/_ViewImports.cshtml"); + var viewImport2 = new TestRazorProjectItem("/Views/Home/_ViewImports.cshtml"); + projectSystem.Add(viewImport1); + projectSystem.Add(viewImport2); + + // Act + var items = projectSystem.FindHierarchicalItems("/", "/Views/Home/Index.cshtml", "_ViewImports.cshtml"); + + // Assert + Assert.Collection( + items, + item => Assert.Same(viewImport2, item), + item => Assert.False(item.Exists), + item => Assert.Same(viewImport1, item)); + } + + [Fact] + public void DirectoryNode_GetDirectory_ReturnsRoot() + { + // Arrange + var root = new DirectoryNode("/"); + + // Act + var result = root.GetDirectory("/"); + + // Assert + Assert.Same(root, result); + } + + [Fact] + public void DirectoryNode_GetDirectory_ReturnsNull_IfDirectoryDoesNotExist() + { + // Arrange + var root = new DirectoryNode("/"); + + // Act + var result = root.GetDirectory("/does-not/exist"); + + // Assert + Assert.Null(result); + } + + [Fact] + public void DirectoryNode_AddFile_CanAddToRoot() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/File.txt"); + + // Act + root.AddFile(new FileNode("/File.txt", projectItem)); + + // Assert + Assert.Empty(root.Directories); + Assert.Collection( + root.Files, + file => Assert.Same(projectItem, file.ProjectItem)); + } + + [Fact] + public void DirectoryNode_AddFile_CanAddToNestedDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/Pages/Shared/_Layout.cshtml"); + + // Act + root.AddFile(new FileNode("/Pages/Shared/_Layout.cshtml", projectItem)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Shared/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_AddMultipleFiles_ToSameDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Pages/Shared/_Layout.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Pages/Shared/_Partial.cshtml"); + + // Act + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Shared/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem1, file.ProjectItem), + file => Assert.Same(projectItem2, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_AddsFiles_ToSiblingDirectories() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Pages/Products/Index.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Pages/Accounts/About.cshtml"); + + // Act + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Products/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem1, file.ProjectItem)); + }, + subDirectory => + { + Assert.Equal("/Pages/Accounts/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem2, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_GetItem_ReturnsItemAtRoot() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/_ViewStart.cshtml"); + root.AddFile(new FileNode(projectItem.FilePath, projectItem)); + + // Act + var result = root.GetItem(projectItem.FilePath); + + // Assert + Assert.Same(result, projectItem); + } + + [Fact] + public void DirectoryNode_GetItem_WhenFilePathSharesSameNameAsSiblingDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Home.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Home/About.cshtml"); + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Act + var result = root.GetItem(projectItem1.FilePath); + + // Assert + Assert.Same(result, projectItem1); + } + + [Fact] + public void DirectoryNode_GetItem_WhenFileNameIsSameAsDirectoryName() + { + // Arrange + var projectItem1 = new TestRazorProjectItem("/Home/Home.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Home/About.cshtml"); + var root = new DirectoryNode("/") + { + Directories = + { + new DirectoryNode("/Home/") + { + Files = + { + new FileNode(projectItem1.FilePath, projectItem1), + new FileNode(projectItem2.FilePath, projectItem2), + } + } + }, + }; + + // Act + var result = root.GetItem(projectItem1.FilePath); + + // Assert + Assert.Same(result, projectItem1); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Performance/Configs/CoreConfig.cs b/test/Microsoft.AspNetCore.Razor.Performance/Configs/CoreConfig.cs deleted file mode 100644 index 9e93e361c0..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Performance/Configs/CoreConfig.cs +++ /dev/null @@ -1,31 +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 BenchmarkDotNet.Columns; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Engines; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Validators; - -namespace Microsoft.AspNetCore.Razor.Performance -{ - public class CoreConfig : ManualConfig - { - public CoreConfig() - { - Add(JitOptimizationsValidator.FailOnError); - Add(MemoryDiagnoser.Default); - Add(StatisticColumn.OperationsPerSecond); - - Add(Job.Default - .With(BenchmarkDotNet.Environments.Runtime.Core) - .WithRemoveOutliers(false) - .With(new GcMode() { Server = true }) - .With(RunStrategy.Throughput) - .WithLaunchCount(3) - .WithWarmupCount(5) - .WithTargetCount(10)); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj b/test/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj deleted file mode 100644 index da0a1b14e0..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Performance/Microsoft.AspNetCore.Razor.Performance.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - netcoreapp2.0 - Exe - true - true - false - - - - - - - - - - - diff --git a/test/Microsoft.AspNetCore.Razor.Performance/Program.cs b/test/Microsoft.AspNetCore.Razor.Performance/Program.cs deleted file mode 100644 index 9191a1098c..0000000000 --- a/test/Microsoft.AspNetCore.Razor.Performance/Program.cs +++ /dev/null @@ -1,17 +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.Reflection; -using BenchmarkDotNet.Running; - -namespace Microsoft.AspNetCore.Razor.Performance -{ - public class Program - { - public static void Main(string[] args) - { - BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs index 7b9fc7bd66..23b723bc49 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs @@ -79,6 +79,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests var source = TestRazorSourceDocument.CreateResource(sourceFileName, GetType(), normalizeNewLines: true); var imports = new List(); + var importIdentifiers = new List(); while (true) { var importsFileName = Path.ChangeExtension(normalizedFileName + "_Imports" + imports.Count.ToString(), ".cshtml"); @@ -87,6 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests break; } + importIdentifiers.Add(normalizedFileName + "_Imports" + imports.Count.ToString()); imports.Add(TestRazorSourceDocument.CreateResource(importsFileName, GetType(), normalizeNewLines: true)); } @@ -227,45 +229,5 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests Assert.Equal(baseline, actual); } - - protected class ApiSetsIRTestAdapter : IntermediateNodePassBase, IRazorOptimizationPass - { - protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) - { - var walker = new ApiSetsIRWalker(); - walker.Visit(documentNode); - } - - private class ApiSetsIRWalker : IntermediateNodeWalker - { - public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) - { - node.ClassName = FileName.Replace('/', '_'); - - node.Modifiers.Clear(); - node.Modifiers.Add("public"); - - VisitDefault(node); - } - - public override void VisitNamespaceDeclaration(NamespaceDeclarationIntermediateNode node) - { - node.Content = "Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles"; - - VisitDefault(node); - } - - public override void VisitMethodDeclaration(MethodDeclarationIntermediateNode node) - { - node.Modifiers.Clear(); - node.Modifiers.Add("public"); - node.Modifiers.Add("async"); - node.MethodName = "ExecuteAsync"; - node.ReturnType = typeof(Task).FullName; - - VisitDefault(node); - } - } - } } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs index f91e4c65aa..1f9ec8a407 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, fileName: null); + var source = TestRazorSourceDocument.Create(document, filePath: null); var options = CreateParserOptions(directives, designTime); var context = new ParserContext(source, options); @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy markupParser.ParseDocument(); var root = context.Builder.Build(); - var diagnostics = context.ErrorSink.Errors?.Select(error => RazorDiagnostic.Create(error)); + var diagnostics = context.ErrorSink.Errors; var codeDocument = RazorCodeDocument.Create(source); @@ -77,7 +77,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, fileName: null); + var source = TestRazorSourceDocument.Create(document, filePath: null); var options = CreateParserOptions(directives, designTime); var context = new ParserContext(source, options); @@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy parser.ParseBlock(); var root = context.Builder.Build(); - var diagnostics = context.ErrorSink.Errors?.Select(error => RazorDiagnostic.Create(error)); + var diagnostics = context.ErrorSink.Errors; return RazorSyntaxTree.Create(root, source, diagnostics, options); } @@ -107,7 +107,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { directives = directives ?? Array.Empty(); - var source = TestRazorSourceDocument.Create(document, fileName: null); + var source = TestRazorSourceDocument.Create(document, filePath: null); var options = CreateParserOptions(directives, designTime); var context = new ParserContext(source, options); @@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy parser.ParseBlock(); var root = context.Builder.Build(); - var diagnostics = context.ErrorSink.Errors?.Select(error => RazorDiagnostic.Create(error)); + var diagnostics = context.ErrorSink.Errors; return RazorSyntaxTree.Create(root, source, diagnostics, options); } @@ -134,20 +134,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy internal virtual void ParseBlockTest(string document) { - ParseBlockTest(document, null, false, new RazorError[0]); + ParseBlockTest(document, null, false, new RazorDiagnostic[0]); } internal virtual void ParseBlockTest(string document, bool designTime) { - ParseBlockTest(document, null, designTime, new RazorError[0]); + ParseBlockTest(document, null, designTime, new RazorDiagnostic[0]); } - internal virtual void ParseBlockTest(string document, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, false, expectedErrors); } - internal virtual void ParseBlockTest(string document, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, bool designTime, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, null, designTime, expectedErrors); } @@ -167,22 +167,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseBlockTest(document, expectedRoot, designTime, null); } - internal virtual void ParseBlockTest(string document, Block expectedRoot, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, Block expectedRoot, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, expectedRoot, false, expectedErrors); } - internal virtual void ParseBlockTest(string document, IEnumerable directives, Block expectedRoot, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, IEnumerable directives, Block expectedRoot, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, directives, expectedRoot, false, expectedErrors); } - internal virtual void ParseBlockTest(string document, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors) { ParseBlockTest(document, null, expected, designTime, expectedErrors); } - internal virtual void ParseBlockTest(string document, IEnumerable directives, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, IEnumerable directives, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors) { var result = ParseBlock(document, directives, designTime); @@ -199,7 +199,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!ReferenceEquals(expected, IgnoreOutput)) { - EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateResults(result, expected, expectedErrors); } } @@ -213,22 +213,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null); } - internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedError) + internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedError) { SingleSpanBlockTest(document, document, blockKind, spanType, expectedError); } - internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedErrors) + internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedErrors) { - SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorError[0]); + SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorDiagnostic[0]); } - internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedError) + internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedError) { SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError); } - internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedErrors) + internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedErrors) { var result = ParseBlock(document, designTime: false); @@ -249,7 +249,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!ReferenceEquals(expected, IgnoreOutput)) { - EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateResults(result, expected, expectedErrors); } } @@ -263,12 +263,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest(document, expectedRoot, false, null); } - internal virtual void ParseDocumentTest(string document, Block expectedRoot, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, Block expectedRoot, params RazorDiagnostic[] expectedErrors) { ParseDocumentTest(document, expectedRoot, false, expectedErrors); } - internal virtual void ParseDocumentTest(string document, IEnumerable directives, Block expected, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, IEnumerable directives, Block expected, params RazorDiagnostic[] expectedErrors) { ParseDocumentTest(document, directives, expected, false, expectedErrors); } @@ -283,12 +283,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseDocumentTest(document, expectedRoot, designTime, null); } - internal virtual void ParseDocumentTest(string document, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors) { ParseDocumentTest(document, null, expected, designTime, expectedErrors); } - internal virtual void ParseDocumentTest(string document, IEnumerable directives, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, IEnumerable directives, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors) { var result = ParseDocument(document, directives, designTime); @@ -305,7 +305,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!ReferenceEquals(expected, IgnoreOutput)) { - EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList()); + EvaluateResults(result, expected, expectedErrors); } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs index 5b933b1749..ed7b3aadde 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs @@ -339,9 +339,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string directiveText, string typePattern = null, string assemblyName = null, - params RazorError[] legacyErrors) + params RazorDiagnostic[] errors) { - var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList(); + var diagnostics = errors.ToList(); return _self .With(new AddTagHelperChunkGenerator(lookupText, directiveText, typePattern, assemblyName, diagnostics)) .Accepts(AcceptedCharactersInternal.AnyExceptNewline); @@ -352,17 +352,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string directiveText, string typePattern = null, string assemblyName = null, - params RazorError[] legacyErrors) + params RazorDiagnostic[] errors) { - var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList(); + var diagnostics = errors.ToList(); return _self .With(new RemoveTagHelperChunkGenerator(lookupText, directiveText, typePattern, assemblyName, diagnostics)) .Accepts(AcceptedCharactersInternal.AnyExceptNewline); } - public SpanConstructor AsTagHelperPrefixDirective(string prefix, string directiveText, params RazorError[] legacyErrors) + public SpanConstructor AsTagHelperPrefixDirective(string prefix, string directiveText, params RazorDiagnostic[] errors) { - var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList(); + var diagnostics = errors.ToList(); return _self .With(new TagHelperPrefixDirectiveChunkGenerator(prefix, directiveText, diagnostics)) .Accepts(AcceptedCharactersInternal.AnyExceptNewline); diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorEngineBuilderExtensions.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorEngineBuilderExtensions.cs index 7bdd79b889..2b0531baa3 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorEngineBuilderExtensions.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorEngineBuilderExtensions.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; +using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language { @@ -25,5 +28,42 @@ namespace Microsoft.AspNetCore.Razor.Language feature.TagHelpers.AddRange(tagHelpers); return builder; } + + public static IRazorEngineBuilder ConfigureDocumentClassifier(this IRazorEngineBuilder builder) + { + var feature = builder.Features.OfType().FirstOrDefault(); + if (feature == null) + { + feature = new DefaultDocumentClassifierPassFeature(); + builder.Features.Add(feature); + } + + feature.ConfigureNamespace.Clear(); + feature.ConfigureClass.Clear(); + feature.ConfigureMethod.Clear(); + + feature.ConfigureNamespace.Add((RazorCodeDocument codeDocument, NamespaceDeclarationIntermediateNode node) => + { + node.Content = "Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles"; + }); + + feature.ConfigureClass.Add((RazorCodeDocument codeDocument, ClassDeclarationIntermediateNode node) => + { + node.ClassName = IntegrationTestBase.FileName.Replace('/', '_'); + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + }); + + feature.ConfigureMethod.Add((RazorCodeDocument codeDocument, MethodDeclarationIntermediateNode node) => + { + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + node.Modifiers.Add("async"); + node.MethodName = "ExecuteAsync"; + node.ReturnType = typeof(Task).FullName; + }); + + return builder; + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs new file mode 100644 index 0000000000..bcea84e918 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineBuilderExtensions.cs @@ -0,0 +1,70 @@ +// 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.Tasks; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public static class RazorProjectEngineBuilderExtensions + { + public static RazorProjectEngineBuilder AddTagHelpers(this RazorProjectEngineBuilder builder, params TagHelperDescriptor[] tagHelpers) + { + return AddTagHelpers(builder, (IEnumerable)tagHelpers); + } + + public static RazorProjectEngineBuilder AddTagHelpers(this RazorProjectEngineBuilder builder, IEnumerable tagHelpers) + { + var feature = (TestTagHelperFeature)builder.Features.OfType().FirstOrDefault(); + if (feature == null) + { + feature = new TestTagHelperFeature(); + builder.Features.Add(feature); + } + + feature.TagHelpers.AddRange(tagHelpers); + return builder; + } + + public static RazorProjectEngineBuilder ConfigureDocumentClassifier(this RazorProjectEngineBuilder builder) + { + var feature = builder.Features.OfType().FirstOrDefault(); + if (feature == null) + { + feature = new DefaultDocumentClassifierPassFeature(); + builder.Features.Add(feature); + } + + feature.ConfigureNamespace.Clear(); + feature.ConfigureClass.Clear(); + feature.ConfigureMethod.Clear(); + + feature.ConfigureNamespace.Add((RazorCodeDocument codeDocument, NamespaceDeclarationIntermediateNode node) => + { + node.Content = "Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles"; + }); + + feature.ConfigureClass.Add((RazorCodeDocument codeDocument, ClassDeclarationIntermediateNode node) => + { + node.ClassName = IntegrationTestBase.FileName.Replace('/', '_'); + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + }); + + feature.ConfigureMethod.Add((RazorCodeDocument codeDocument, MethodDeclarationIntermediateNode node) => + { + node.Modifiers.Clear(); + node.Modifiers.Add("public"); + node.Modifiers.Add("async"); + node.MethodName = "ExecuteAsync"; + node.ReturnType = typeof(Task).FullName; + }); + + return builder; + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.cs new file mode 100644 index 0000000000..f16fff0274 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectFileSystem.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 System.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class TestRazorProjectFileSystem : DefaultRazorProjectFileSystem + { + public new static RazorProjectFileSystem Empty = new TestRazorProjectFileSystem(); + + private readonly Dictionary _lookup; + + public TestRazorProjectFileSystem() + : this(new RazorProjectItem[0]) + { + } + + public TestRazorProjectFileSystem(IList items) : base("/") + { + _lookup = items.ToDictionary(item => item.FilePath); + } + + public override IEnumerable EnumerateItems(string basePath) + { + throw new NotImplementedException(); + } + + public override RazorProjectItem GetItem(string path) + { + if (!_lookup.TryGetValue(path, out var value)) + { + value = new NotFoundProjectItem("", path); + } + + return value; + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs index 3e0bd1e44f..d4f03fbf0d 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs @@ -9,12 +9,14 @@ namespace Microsoft.AspNetCore.Razor.Language public class TestRazorProjectItem : RazorProjectItem { public TestRazorProjectItem( - string path, + string filePath, string physicalPath = null, + string relativePhysicalPath = null, string basePath = "/") { - FilePath = path; + FilePath = filePath; PhysicalPath = physicalPath; + RelativePhysicalPath = relativePhysicalPath; BasePath = basePath; } @@ -24,7 +26,9 @@ namespace Microsoft.AspNetCore.Razor.Language public override string PhysicalPath { get; } - public override bool Exists => true; + public override string RelativePhysicalPath { get; } + + public override bool Exists { get; } = true; public string Content { get; set; } = "Default content"; diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorSourceDocument.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorSourceDocument.cs index 57a5fb196e..e731b03594 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorSourceDocument.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorSourceDocument.cs @@ -11,12 +11,35 @@ namespace Microsoft.AspNetCore.Razor.Language { public static class TestRazorSourceDocument { - public static RazorSourceDocument CreateResource(string path, Type type, Encoding encoding = null, bool normalizeNewLines = false) + public static RazorSourceDocument CreateResource(string resourcePath, Type type, Encoding encoding = null, bool normalizeNewLines = false) { - return CreateResource(path, type.GetTypeInfo().Assembly, encoding, normalizeNewLines); + return CreateResource(resourcePath, type.GetTypeInfo().Assembly, encoding, normalizeNewLines); } - public static RazorSourceDocument CreateResource(string path, Assembly assembly, Encoding encoding = null, bool normalizeNewLines = false) + public static RazorSourceDocument CreateResource(string resourcePath, Assembly assembly, Encoding encoding = null, bool normalizeNewLines = false) + { + var file = TestFile.Create(resourcePath, assembly); + + using (var input = file.OpenRead()) + using (var reader = new StreamReader(input)) + { + var content = reader.ReadToEnd(); + if (normalizeNewLines) + { + content = NormalizeNewLines(content); + } + + var properties = new RazorSourceDocumentProperties(resourcePath, resourcePath); + return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties); + } + } + + public static RazorSourceDocument CreateResource( + string path, + Assembly assembly, + Encoding encoding, + RazorSourceDocumentProperties properties, + bool normalizeNewLines = false) { var file = TestFile.Create(path, assembly); @@ -28,8 +51,8 @@ namespace Microsoft.AspNetCore.Razor.Language { content = NormalizeNewLines(content); } - - return new StringSourceDocument(content, encoding ?? Encoding.UTF8, path); + + return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties); } } @@ -52,14 +75,34 @@ namespace Microsoft.AspNetCore.Razor.Language return stream; } - public static RazorSourceDocument Create(string content = "Hello, world!", Encoding encoding = null, bool normalizeNewLines = false, string fileName = "test.cshtml") + public static RazorSourceDocument Create( + string content = "Hello, world!", + Encoding encoding = null, + bool normalizeNewLines = false, + string filePath = "test.cshtml", + string relativePath = "test.cshtml") { if (normalizeNewLines) { content = NormalizeNewLines(content); } - return new StringSourceDocument(content, encoding ?? Encoding.UTF8, fileName); + var properties = new RazorSourceDocumentProperties(filePath, relativePath); + return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties); + } + + public static RazorSourceDocument Create( + string content, + RazorSourceDocumentProperties properties, + Encoding encoding = null, + bool normalizeNewLines = false) + { + if (normalizeNewLines) + { + content = NormalizeNewLines(content); + } + + return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties); } private static string NormalizeNewLines(string content) diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs index 3a2cadef34..576c4e4e44 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/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.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Language.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj b/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj index 0fe0b6a3fc..1562a234c3 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj +++ b/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp2.1;netcoreapp2.0;net461 true diff --git a/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs b/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs index 7666a63722..2b7b7450cd 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs @@ -1,6 +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.Threading.Tasks; +using Microsoft.AspNetCore.Html; + namespace Microsoft.AspNetCore.Mvc.Razor { public abstract class RazorPage : RazorPageBase @@ -16,5 +19,30 @@ namespace Microsoft.AspNetCore.Mvc.Razor public override void EnsureRenderedBodyOrSections() { } + + protected virtual IHtmlContent RenderBody() + { + return null; + } + + public HtmlString RenderSection(string name) + { + return null; + } + + public HtmlString RenderSection(string name, bool required) + { + return null; + } + + public Task RenderSectionAsync(string name) + { + return null; + } + + public Task RenderSectionAsync(string name, bool required) + { + return null; + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj b/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj index 0fe0b6a3fc..1562a234c3 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj +++ b/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp2.1;netcoreapp2.0;net461 true diff --git a/test/Microsoft.AspNetCore.Razor.Test/Microsoft.AspNetCore.Razor.Test.csproj b/test/Microsoft.AspNetCore.Razor.Test/Microsoft.AspNetCore.Razor.Test.csproj new file mode 100644 index 0000000000..b178b1b2c2 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Test/Microsoft.AspNetCore.Razor.Test.csproj @@ -0,0 +1,29 @@ + + + + $(StandardTestTfms) + $(DefaultItemExcludes);TestFiles\**\* + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/DefaultTagHelperContentTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/DefaultTagHelperContentTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/DefaultTagHelperContentTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/DefaultTagHelperContentTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/NullHtmlEncoderTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/NullHtmlEncoderTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/NullHtmlEncoderTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/NullHtmlEncoderTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/ReadOnlyTagHelperAttributeListTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperAttributeListTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperAttributeListTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperAttributeListTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperAttributeListTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperContextTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperContextTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperContextTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperContextTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperOutputTest.cs similarity index 96% rename from test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs rename to test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperOutputTest.cs index 9d203102bd..df33c776a6 100644 --- a/test/Microsoft.AspNetCore.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Test/TagHelpers/TagHelperOutputTest.cs @@ -7,7 +7,6 @@ using System.IO; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Html; -using Microsoft.AspNetCore.Razor.Runtime.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers.Testing; using Microsoft.Extensions.WebEncoders.Testing; using Xunit; @@ -1037,15 +1036,6 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers { // Arrange var writer = new StringWriter(); - var tagHelperExecutionContext = new TagHelperExecutionContext( - tagName: output.TagName, - tagMode: output.TagMode, - items: new Dictionary(), - uniqueId: string.Empty, - executeChildContentAsync: () => Task.FromResult(result: true), - startTagHelperWritingScope: _ => { }, - endTagHelperWritingScope: () => new DefaultTagHelperContent()); - tagHelperExecutionContext.Output = output; var testEncoder = new HtmlTestEncoder(); // Act @@ -1067,16 +1057,6 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers var buffer = new HtmlContentBuilder(); - var tagHelperExecutionContext = new TagHelperExecutionContext( - tagName: output.TagName, - tagMode: output.TagMode, - items: new Dictionary(), - uniqueId: string.Empty, - executeChildContentAsync: () => Task.FromResult(result: true), - startTagHelperWritingScope: _ => { }, - endTagHelperWritingScope: () => new DefaultTagHelperContent()); - tagHelperExecutionContext.Output = output; - // Act ((IHtmlContentContainer)output).CopyTo(buffer); @@ -1097,16 +1077,6 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers var buffer = new HtmlContentBuilder(); - var tagHelperExecutionContext = new TagHelperExecutionContext( - tagName: output.TagName, - tagMode: output.TagMode, - items: new Dictionary(), - uniqueId: string.Empty, - executeChildContentAsync: () => Task.FromResult(result: true), - startTagHelperWritingScope: _ => { }, - endTagHelperWritingScope: () => new DefaultTagHelperContent()); - tagHelperExecutionContext.Output = output; - // Act ((IHtmlContentContainer)output).MoveTo(buffer); diff --git a/test/Microsoft.AspNetCore.Razor.Test/xunit.runner.json b/test/Microsoft.AspNetCore.Razor.Test/xunit.runner.json new file mode 100644 index 0000000000000000000000000000000000000000..d042e7bc202c778fed660f288eccf1e7bce9ead8 GIT binary patch literal 116 zcmezWubP3Efr~)_2$dLe8B!Ta7%~|08B!Qr7%~}(844J37!nyOfpS(DDwG&>kn|P< d^(6xJ + + + net46;$(StandardTestTfms) + + + + + + + + + + + + diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestRazorLanguageServices.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestRazorLanguageServices.cs new file mode 100644 index 0000000000..fe33148ab0 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestRazorLanguageServices.cs @@ -0,0 +1,48 @@ +// 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.CodeAnalysis.Razor; + +namespace Microsoft.CodeAnalysis.Host +{ + internal class TestRazorLanguageServices : HostLanguageServices + { + private readonly HostWorkspaceServices _workspaceServices; + private readonly IEnumerable _languageServices; + + public TestRazorLanguageServices(HostWorkspaceServices workspaceServices, IEnumerable languageServices) + { + if (workspaceServices == null) + { + throw new ArgumentNullException(nameof(workspaceServices)); + } + + if (languageServices == null) + { + throw new ArgumentNullException(nameof(languageServices)); + } + + _workspaceServices = workspaceServices; + _languageServices = languageServices; + } + + public override HostWorkspaceServices WorkspaceServices => _workspaceServices; + + public override string Language => RazorLanguage.Name; + + public override TLanguageService GetService() + { + var service = _languageServices.OfType().FirstOrDefault(); + + if (service == null) + { + throw new InvalidOperationException($"Test Razor language services not configured properly, missing language service '{typeof(TLanguageService).FullName}'."); + } + + return service; + } + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestServices.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestServices.cs new file mode 100644 index 0000000000..a9e53de621 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestServices.cs @@ -0,0 +1,47 @@ +// 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.CodeAnalysis.Host +{ + public class TestServices : HostServices + { + private readonly IEnumerable _workspaceServices; + private readonly IEnumerable _razorLanguageServices; + + private TestServices(IEnumerable workspaceServices, IEnumerable razorLanguageServices) + { + if (workspaceServices == null) + { + throw new ArgumentNullException(nameof(workspaceServices)); + } + + if (razorLanguageServices == null) + { + throw new ArgumentNullException(nameof(razorLanguageServices)); + } + + _workspaceServices = workspaceServices; + _razorLanguageServices = razorLanguageServices; + } + + protected override HostWorkspaceServices CreateWorkspaceServices(Workspace workspace) + { + if (workspace == null) + { + throw new ArgumentNullException(nameof(workspace)); + } + + return new TestWorkspaceServices(this, _workspaceServices, _razorLanguageServices, workspace); + } + + public static HostServices Create(IEnumerable razorLanguageServices) + => Create(Enumerable.Empty(), razorLanguageServices); + + public static HostServices Create(IEnumerable workspaceServices, IEnumerable razorLanguageServices) + => new TestServices(workspaceServices, razorLanguageServices); + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspace.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspace.cs new file mode 100644 index 0000000000..02dcab53d5 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspace.cs @@ -0,0 +1,26 @@ +// 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.CodeAnalysis.Host; + +namespace Microsoft.CodeAnalysis +{ + public static class TestWorkspace + { + private static readonly object WorkspaceLock = new object(); + + public static Workspace Create(Action configure = null) => Create(services: null, configure: configure); + + public static Workspace Create(HostServices services, Action configure = null) + { + lock (WorkspaceLock) + { + var workspace = services == null ? new AdhocWorkspace() : new AdhocWorkspace(services); + configure?.Invoke(workspace); + + return workspace; + } + } + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspaceServices.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspaceServices.cs new file mode 100644 index 0000000000..66d8f42f27 --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common/TestWorkspaceServices.cs @@ -0,0 +1,85 @@ +// 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.CodeAnalysis.Razor; + +namespace Microsoft.CodeAnalysis.Host +{ + internal class TestWorkspaceServices : HostWorkspaceServices + { + private static readonly Workspace DefaultWorkspace = TestWorkspace.Create(); + + private readonly HostServices _hostServices; + private readonly IEnumerable _workspaceServices; + private readonly TestRazorLanguageServices _razorLanguageServices; + private readonly Workspace _workspace; + + public TestWorkspaceServices( + HostServices hostServices, + IEnumerable workspaceServices, + IEnumerable razorLanguageServices, + Workspace workspace) + { + if (hostServices == null) + { + throw new ArgumentNullException(nameof(hostServices)); + } + + if (workspaceServices == null) + { + throw new ArgumentNullException(nameof(workspaceServices)); + } + + if (razorLanguageServices == null) + { + throw new ArgumentNullException(nameof(razorLanguageServices)); + } + + if (workspace == null) + { + throw new ArgumentNullException(nameof(workspace)); + } + + _hostServices = hostServices; + _workspaceServices = workspaceServices; + _razorLanguageServices = new TestRazorLanguageServices(this, razorLanguageServices); + _workspace = workspace; + } + + public override HostServices HostServices => _hostServices; + + public override Workspace Workspace => _workspace; + + public override TWorkspaceService GetService() + { + var service = _workspaceServices.OfType().FirstOrDefault(); + + if (service == null) + { + // Fallback to default host services to resolve roslyn specific features. + service = DefaultWorkspace.Services.GetService(); + } + + return service; + } + + public override HostLanguageServices GetLanguageServices(string languageName) + { + if (languageName != RazorLanguage.Name) + { + throw new InvalidOperationException($"Test services do not support language service '{languageName}'. The only language services supported are '{RazorLanguage.Name}'."); + } + + return _razorLanguageServices; + } + + public override IEnumerable SupportedLanguages => new[] { RazorLanguage.Name }; + + public override bool IsSupported(string languageName) => languageName == RazorLanguage.Name; + + public override IEnumerable FindLanguageServices(MetadataFilter filter) => throw new NotImplementedException(); + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj index bb5f05b323..d1ad2a9fab 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotManagerTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotManagerTest.cs index 53e4b476c0..eda57ab8ba 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotManagerTest.cs +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotManagerTest.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { public DefaultProjectSnapshotManagerTest() { - Workspace = new AdhocWorkspace(); + Workspace = TestWorkspace.Create(); ProjectManager = new TestProjectSnapshotManager(Enumerable.Empty(), Workspace); } @@ -209,6 +209,38 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem Assert.False(ProjectManager.WorkerStarted); } + [Fact] + public void ProjectBuildComplete_KnownProject_NotifiesBackgroundWorker() + { + // Arrange + var project = Workspace.CurrentSolution.AddProject("Test", "Test", LanguageNames.CSharp); + ProjectManager.ProjectAdded(project); + ProjectManager.Reset(); + + // Act + ProjectManager.ProjectBuildComplete(project); + + // Assert + Assert.False(ProjectManager.ListenersNotified); + Assert.True(ProjectManager.WorkerStarted); + } + + [Fact] + public void ProjectBuildComplete_IgnoresUnknownProject() + { + // Arrange + var project = Workspace.CurrentSolution.AddProject("Test", "Test", LanguageNames.CSharp); + + // Act + ProjectManager.ProjectBuildComplete(project); + + // Assert + Assert.Empty(ProjectManager.Projects); + + Assert.False(ProjectManager.ListenersNotified); + Assert.False(ProjectManager.WorkerStarted); + } + [Fact] public void ProjectRemoved_RemovesProject_NotifiesListeners_DoesNotStartBackgroundWorker() { diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs new file mode 100644 index 0000000000..2a72f46a6c --- /dev/null +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs @@ -0,0 +1,67 @@ +// 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.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Moq; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem +{ + public class DefaultProjectSnapshotTest + { + [Fact] + public void WithProjectChange_WithProject_CreatesSnapshot_UpdatesUnderlyingProject() + { + // Arrange + var underlyingProject = GetProject("Test1"); + var original = new DefaultProjectSnapshot(underlyingProject); + + var anotherProject = GetProject("Test1"); + + // Act + var snapshot = original.WithProjectChange(anotherProject); + + // Assert + Assert.Same(anotherProject, snapshot.UnderlyingProject); + Assert.Equal(original.ComputedVersion, snapshot.ComputedVersion); + Assert.Equal(original.Configuration, snapshot.Configuration); + } + + [Fact] + public void WithProjectChange_WithProject_CreatesSnapshot_UpdatesValues() + { + // Arrange + var underlyingProject = GetProject("Test1"); + var original = new DefaultProjectSnapshot(underlyingProject); + + var anotherProject = GetProject("Test1"); + var update = new ProjectSnapshotUpdateContext(anotherProject) + { + Configuration = Mock.Of(), + }; + + // Act + var snapshot = original.WithProjectChange(update); + + // Assert + Assert.Same(original.UnderlyingProject, snapshot.UnderlyingProject); + Assert.Equal(update.UnderlyingProject.Version, snapshot.ComputedVersion); + Assert.Same(update.Configuration, snapshot.Configuration); + } + + private Project GetProject(string name) + { + Project project = null; + TestWorkspace.Create(workspace => + { + project = workspace.AddProject(name, LanguageNames.CSharp); + }); + return project; + } + } +} diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/WorkspaceProjectSnapshotChangeTriggerTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/WorkspaceProjectSnapshotChangeTriggerTest.cs index c458b5388c..293f6e8bf0 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/WorkspaceProjectSnapshotChangeTriggerTest.cs +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/WorkspaceProjectSnapshotChangeTriggerTest.cs @@ -14,15 +14,31 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { public WorkspaceProjectSnapshotChangeTriggerTest() { - Workspace = new AdhocWorkspace(); - EmptySolution = Workspace.CurrentSolution.GetIsolatedSolution(); + Solution emptySolution = null; + Project project1 = null; + Project project2 = null; + Project project3 = null; + Solution solutionWithTwoProjects = null; + Solution solutionWithOneProject = null; - ProjectNumberOne = Workspace.CurrentSolution.AddProject("One", "One", LanguageNames.CSharp); - ProjectNumberTwo = ProjectNumberOne.Solution.AddProject("Two", "Two", LanguageNames.CSharp); - SolutionWithTwoProjects = ProjectNumberTwo.Solution; + Workspace = TestWorkspace.Create(ws => + { + emptySolution = ws.CurrentSolution.GetIsolatedSolution(); + project1 = ws.CurrentSolution.AddProject("One", "One", LanguageNames.CSharp); + project2 = project1.Solution.AddProject("Two", "Two", LanguageNames.CSharp); + solutionWithTwoProjects = project2.Solution; + + project3 = emptySolution.GetIsolatedSolution().AddProject("Three", "Three", LanguageNames.CSharp); + solutionWithOneProject = project3.Solution; + }); + + EmptySolution = emptySolution; + ProjectNumberOne = project1; + ProjectNumberTwo = project2; + ProjectNumberThree = project3; + SolutionWithTwoProjects = solutionWithTwoProjects; + SolutionWithOneProject = solutionWithOneProject; - ProjectNumberThree = EmptySolution.GetIsolatedSolution().AddProject("Three", "Three", LanguageNames.CSharp); - SolutionWithOneProject = ProjectNumberThree.Solution; } private Solution EmptySolution { get; } diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Editor/DefaultEditorSettingsManagerInternalTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultEditorSettingsManagerTest.cs similarity index 78% rename from test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Editor/DefaultEditorSettingsManagerInternalTest.cs rename to test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultEditorSettingsManagerTest.cs index d0a85604eb..750e40f60b 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Editor/DefaultEditorSettingsManagerInternalTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultEditorSettingsManagerTest.cs @@ -1,17 +1,18 @@ // 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 Microsoft.CodeAnalysis.Razor.Editor; using Xunit; -namespace Microsoft.CodeAnalysis.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { - public class DefaultEditorSettingsManagerInternalTest + public class DefaultEditorSettingsManagerTest : ForegroundDispatcherTestBase { [Fact] public void InitialSettingsAreDefault() { // Act - var manager = new DefaultEditorSettingsManagerInternal(); + var manager = new DefaultEditorSettingsManager(Dispatcher); // Assert Assert.Equal(EditorSettings.Default, manager.Current); @@ -21,7 +22,7 @@ namespace Microsoft.CodeAnalysis.Razor.Editor public void Update_TriggersChangedIfEditorSettingsAreDifferent() { // Arrange - var manager = new DefaultEditorSettingsManagerInternal(); + var manager = new DefaultEditorSettingsManager(Dispatcher); var called = false; manager.Changed += (caller, args) => { @@ -41,7 +42,7 @@ namespace Microsoft.CodeAnalysis.Razor.Editor public void Update_DoesNotTriggerChangedIfEditorSettingsAreSame() { // Arrange - var manager = new DefaultEditorSettingsManagerInternal(); + var manager = new DefaultEditorSettingsManager(Dispatcher); var called = false; manager.Changed += (caller, args) => { @@ -57,4 +58,4 @@ namespace Microsoft.CodeAnalysis.Razor.Editor Assert.Same(originalSettings, manager.Current); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs similarity index 85% rename from test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs rename to test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs index adeee1685c..74ede949ac 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTemplateEngineFactoryServiceTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultProjectEngineFactoryServiceTest.cs @@ -14,14 +14,19 @@ using MvcLatest = Microsoft.AspNetCore.Mvc.Razor.Extensions; namespace Microsoft.VisualStudio.Editor.Razor { - public class DefaultTemplateEngineFactoryServiceTest + public class DefaultProjectEngineFactoryServiceTest { - public DefaultTemplateEngineFactoryServiceTest() + public DefaultProjectEngineFactoryServiceTest() { - Workspace = new AdhocWorkspace(); + Project project = null; - var info = ProjectInfo.Create(ProjectId.CreateNewId("Test"), VersionStamp.Default, "Test", "Test", LanguageNames.CSharp, filePath: "/TestPath/SomePath/Test.csproj"); - Project = Workspace.CurrentSolution.AddProject(info).GetProject(info.Id); + Workspace = TestWorkspace.Create(workspace => + { + var info = ProjectInfo.Create(ProjectId.CreateNewId("Test"), VersionStamp.Default, "Test", "Test", LanguageNames.CSharp, filePath: "/TestPath/SomePath/Test.csproj"); + project = workspace.CurrentSolution.AddProject(info).GetProject(info.Id); + }); + + Project = project; } // We don't actually look at the project, we rely on the ProjectStateManager @@ -30,7 +35,7 @@ namespace Microsoft.VisualStudio.Editor.Razor public Workspace Workspace { get; } [Fact] - public void Create_CreatesDesignTimeTemplateEngine_ForLatest() + public void Create_CreatesTemplateEngine_ForLatest() { // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); @@ -44,13 +49,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("2.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -60,7 +64,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } [Fact] - public void Create_CreatesDesignTimeTemplateEngine_ForVersion1_1() + public void Create_CreatesTemplateEngine_ForVersion1_1() { // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); @@ -74,13 +78,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("1.1.3.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -104,7 +107,7 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("1.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => @@ -133,13 +136,12 @@ namespace Microsoft.VisualStudio.Editor.Razor new ProjectExtensibilityAssembly(new AssemblyIdentity("Microsoft.AspNetCore.Razor", new Version("3.0.0.0")))), }); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/SomePath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -154,13 +156,12 @@ namespace Microsoft.VisualStudio.Editor.Razor // Arrange var projectManager = new TestProjectSnapshotManager(Workspace); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/DifferentPath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -176,13 +177,12 @@ namespace Microsoft.VisualStudio.Editor.Razor var projectManager = new TestProjectSnapshotManager(Workspace); projectManager.ProjectAdded(Project); - var factoryService = new DefaultTemplateEngineFactoryService(projectManager); + var factoryService = new DefaultProjectEngineFactoryService(projectManager); // Act var engine = factoryService.Create("/TestPath/DifferentPath/", b => { b.Features.Add(new MyCoolNewFeature()); - Assert.True(b.DesignTime); }); // Assert @@ -209,4 +209,4 @@ namespace Microsoft.VisualStudio.Editor.Razor } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperCompletionServiceTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperCompletionServiceTest.cs index 1422e44815..f885a7d290 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperCompletionServiceTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperCompletionServiceTest.cs @@ -995,7 +995,7 @@ namespace Microsoft.VisualStudio.Editor.Razor private static DefaultTagHelperCompletionService CreateTagHelperCompletionFactsService() { - var tagHelperFactsService = new DefaultTagHelperFactsServiceInternal(); + var tagHelperFactsService = new DefaultTagHelperFactsService(); var completionFactService = new DefaultTagHelperCompletionService(tagHelperFactsService); return completionFactService; @@ -1069,4 +1069,4 @@ namespace Microsoft.VisualStudio.Editor.Razor return completionContext; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceInternalTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperFactsServiceTest.cs similarity index 94% rename from test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceInternalTest.cs rename to test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperFactsServiceTest.cs index 5001398a36..2a73fa8830 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceInternalTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTagHelperFactsServiceTest.cs @@ -6,9 +6,9 @@ using System.Linq; using Microsoft.AspNetCore.Razor.Language; using Xunit; -namespace Microsoft.CodeAnalysis.Razor +namespace Microsoft.VisualStudio.Editor.Razor { - public class DefaultTagHelperFactsServiceInternalTest + public class DefaultTagHelperFactsServiceTest { // Purposefully not thoroughly testing DefaultTagHelperFactsService.GetTagHelperBinding because it's a pass through // into TagHelperDescriptorProvider.GetTagHelperBinding. @@ -24,7 +24,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var binding = service.GetTagHelperBinding(documentContext, "!a", Enumerable.Empty>(), parentTag: null, parentIsTagHelper: false); @@ -66,7 +66,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build(), }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); var attributes = new[] { new KeyValuePair("asp-for", "Name") @@ -108,7 +108,7 @@ namespace Microsoft.CodeAnalysis.Razor documentDescriptors[0].BoundAttributes.Last() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); var binding = service.GetTagHelperBinding(documentContext, "a", Enumerable.Empty>(), parentTag: null, parentIsTagHelper: false); // Act @@ -143,7 +143,7 @@ namespace Microsoft.CodeAnalysis.Razor documentDescriptors[0].BoundAttributes.First() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); var binding = service.GetTagHelperBinding(documentContext, "input", Enumerable.Empty>(), parentTag: null, parentIsTagHelper: false); // Act @@ -164,7 +164,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "!strong", parentTag: null); @@ -184,7 +184,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "strong", "p"); @@ -217,7 +217,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "a", "div"); @@ -244,7 +244,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create("th", documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "thstrong", "div"); @@ -277,7 +277,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenTag(documentContext, "strong", "div"); @@ -297,7 +297,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenParent(documentContext, parentTag: null /* root */); @@ -322,7 +322,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenParent(documentContext, parentTag: null /* root */); @@ -343,7 +343,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenParent(documentContext, "p"); @@ -376,7 +376,7 @@ namespace Microsoft.CodeAnalysis.Razor .Build() }; var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors); - var service = new DefaultTagHelperFactsServiceInternal(); + var service = new DefaultTagHelperFactsService(); // Act var descriptors = service.GetTagHelpersGivenParent(documentContext, "div"); @@ -385,4 +385,4 @@ namespace Microsoft.CodeAnalysis.Razor Assert.Equal(expectedDescriptors, descriptors, TagHelperDescriptorComparer.CaseSensitive); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTextBufferProviderTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTextBufferProviderTest.cs index 939f4e5e79..752a11ddd4 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTextBufferProviderTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultTextBufferProviderTest.cs @@ -3,6 +3,7 @@ using System; using System.Collections.ObjectModel; +using System.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Text; @@ -92,13 +93,16 @@ namespace Microsoft.VisualStudio.Editor.Razor private static Document CreateDocumentWithoutText() { - var project = ProjectInfo - .Create(ProjectId.CreateNewId(), VersionStamp.Default, "TestProject", "TestAssembly", LanguageNames.CSharp) - .WithFilePath("/TestProject.csproj"); - var workspace = new AdhocWorkspace(); - workspace.AddProject(project); - var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); - var document = workspace.AddDocument(documentInfo); + Document document = null; + TestWorkspace.Create(workspace => + { + var project = ProjectInfo + .Create(ProjectId.CreateNewId(), VersionStamp.Default, "TestProject", "TestAssembly", LanguageNames.CSharp) + .WithFilePath("/TestProject.csproj"); + workspace.AddProject(project); + var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); + document = workspace.AddDocument(documentInfo); + }); return document; } @@ -114,28 +118,36 @@ namespace Microsoft.VisualStudio.Editor.Razor private static ITextBuffer CreateTextBuffer() { var textBuffer = new Mock(); - textBuffer.Setup(buffer => buffer.Properties) + textBuffer + .Setup(buffer => buffer.Properties) .Returns(new PropertyCollection()); var textImage = new Mock(); var textVersion = new Mock(); var textBufferSnapshot = new Mock(); - textBufferSnapshot.Setup(snapshot => snapshot.TextImage) + textBufferSnapshot + .Setup(snapshot => snapshot.TextImage) .Returns(textImage.Object); - textBufferSnapshot.Setup(snapshot => snapshot.Length) + textBufferSnapshot + .Setup(snapshot => snapshot.Length) .Returns(0); - textBufferSnapshot.Setup(snapshot => snapshot.Version) + textBufferSnapshot + .Setup(snapshot => snapshot.Version) .Returns(textVersion.Object); - textBufferSnapshot.Setup(snapshot => snapshot.TextBuffer) + textBufferSnapshot + .Setup(snapshot => snapshot.TextBuffer) .Returns(() => textBuffer.Object); - textBuffer.Setup(buffer => buffer.CurrentSnapshot) + textBuffer + .Setup(buffer => buffer.CurrentSnapshot) .Returns(() => textBufferSnapshot.Object); var contentType = new Mock(); - contentType.Setup(type => type.IsOfType(It.IsAny())) + contentType + .Setup(type => type.IsOfType(It.IsAny())) .Returns(val => val == RazorLanguage.ContentType); - textBuffer.Setup(buffer => buffer.ContentType) + textBuffer + .Setup(buffer => buffer.ContentType) .Returns(contentType.Object); return textBuffer.Object; @@ -144,13 +156,15 @@ namespace Microsoft.VisualStudio.Editor.Razor private static IBufferGraphFactoryService CreateBufferGraphService(ITextBuffer buffer) { var bufferGraph = new Mock(); - bufferGraph.Setup(graph => graph.GetTextBuffers(It.IsAny>())) + bufferGraph + .Setup(graph => graph.GetTextBuffers(It.IsAny>())) .Returns>(predicate => predicate(buffer) ? new Collection() { buffer } : new Collection()); var bufferGraphService = new Mock(); - bufferGraphService.Setup(service => service.CreateBufferGraph(buffer)) + bufferGraphService + .Setup(service => service.CreateBufferGraph(buffer)) .Returns(bufferGraph.Object); return bufferGraphService.Object; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs index 3117f5b585..cbf27bfa29 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs @@ -526,34 +526,34 @@ namespace Microsoft.VisualStudio.Editor.Razor return new TestParserManager(parser); } - private static RazorTemplateEngineFactoryService CreateTemplateEngineFactory( + private static RazorProjectEngineFactoryService CreateTemplateEngineFactory( string path = TestLinePragmaFileName, IEnumerable tagHelpers = null) { - var engine = RazorEngine.CreateDesignTime(builder => - { - RazorExtensions.Register(builder); - - if (tagHelpers != null) - { - builder.AddTagHelpers(tagHelpers); - } - }); - // GetImports on RazorTemplateEngine will at least check that the item exists, so we need to pretend // that it does. var items = new List(); items.Add(new TestRazorProjectItem(path)); + var fileSystem = new TestRazorProjectFileSystem(items); - var project = new TestRazorProject(items); + var engine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => + { + RazorExtensions.Register(b); - var templateEngine = new RazorTemplateEngine(engine, project); - templateEngine.Options.DefaultImports = RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml"); + if (tagHelpers != null) + { + b.AddTagHelpers(tagHelpers); + } - var templateEngineFactory = Mock.Of( - service => service.Create(It.IsAny(), It.IsAny>()) == templateEngine); + b.AddDefaultImports(new TestRazorProjectItem("_TestImports.cshtml") { Content = "@addTagHelper *, Test" }); + }); - return templateEngineFactory; + var factory = new Mock(); + factory + .Setup(f => f.Create(It.IsAny(), It.IsAny>())) + .Returns(engine); + + return factory.Object; } private async Task RunTypeKeywordTestAsync(string keyword) @@ -711,37 +711,9 @@ namespace Microsoft.VisualStudio.Editor.Razor } } - private class TestCompletionBroker : ICompletionBroker + private class TestCompletionBroker : VisualStudioCompletionBroker { - public ICompletionSession CreateCompletionSession(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret) - { - throw new NotImplementedException(); - } - - public void DismissAllSessions(ITextView textView) - { - throw new NotImplementedException(); - } - - public ReadOnlyCollection GetSessions(ITextView textView) - { - throw new NotImplementedException(); - } - - public bool IsCompletionActive(ITextView textView) - { - return false; - } - - public ICompletionSession TriggerCompletion(ITextView textView) - { - throw new NotImplementedException(); - } - - public ICompletionSession TriggerCompletion(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret) - { - throw new NotImplementedException(); - } + public override bool IsCompletionActive(ITextView textView) => false; } } } \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs index ecb42b2067..601796ad30 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserTest.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 System.Linq; using System.Threading; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; @@ -16,6 +15,15 @@ namespace Microsoft.VisualStudio.Editor.Razor { public class DefaultVisualStudioRazorParserTest : ForegroundDispatcherTestBase { + public DefaultVisualStudioRazorParserTest() + { + var engine = RazorProjectEngine.Create(RazorConfiguration.Default, RazorProjectFileSystem.Empty); + ProjectEngineFactory = Mock.Of( + f => f.Create(It.IsAny(), It.IsAny>()) == engine); + } + + private RazorProjectEngineFactoryService ProjectEngineFactory { get; } + private static VisualStudioDocumentTracker CreateDocumentTracker(bool isSupportedProject = true) { var documentTracker = Mock.Of(tracker => @@ -34,9 +42,9 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + Mock.Of(), new DefaultErrorReporter(), - Mock.Of()); + Mock.Of()); parser.Dispose(); // Act & Assert @@ -50,9 +58,9 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of()); + Mock.Of()); parser.Dispose(); // Act & Assert @@ -66,9 +74,9 @@ namespace Microsoft.VisualStudio.Editor.Razor var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of()); + Mock.Of()); parser.Dispose(); // Act & Assert @@ -82,9 +90,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { var called = false; parser.DocumentStructureChanged += (sender, e) => called = true; @@ -110,9 +118,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, documentTracker, - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { var called = false; parser.DocumentStructureChanged += (sender, e) => called = true; @@ -139,9 +147,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of()) + Mock.Of()) { BlockBackgroundIdleWork = new ManualResetEventSlim(), IdleDelay = TimeSpan.FromSeconds(5) @@ -169,9 +177,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of()) + Mock.Of()) { BlockBackgroundIdleWork = new ManualResetEventSlim(), IdleDelay = TimeSpan.FromSeconds(5) @@ -198,9 +206,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { parser.StartParser(); @@ -222,9 +230,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, documentTracker, - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { // Act parser.StartParser(); @@ -242,9 +250,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(isSupportedProject: true), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { // Act var result = parser.TryReinitializeParser(); @@ -261,9 +269,9 @@ namespace Microsoft.VisualStudio.Editor.Razor using (var parser = new DefaultVisualStudioRazorParser( Dispatcher, CreateDocumentTracker(isSupportedProject: false), - Mock.Of(), + ProjectEngineFactory, new DefaultErrorReporter(), - Mock.Of())) + Mock.Of())) { // Act var result = parser.TryReinitializeParser(); diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj b/test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj index 7e010cf2a9..6f4876aec0 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/Microsoft.VisualStudio.Editor.Razor.Test.csproj @@ -9,6 +9,7 @@ + diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorDirectiveCompletionProviderTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorDirectiveCompletionProviderTest.cs index c30b573b2a..1e5f5627ce 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorDirectiveCompletionProviderTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorDirectiveCompletionProviderTest.cs @@ -108,13 +108,16 @@ namespace Microsoft.VisualStudio.Editor.Razor public async Task ProvideCompletionAsync_DoesNotProvideCompletionsForDocumentWithoutPath() { // Arrange - var project = ProjectInfo + Document document = null; + TestWorkspace.Create(workspace => + { + var project = ProjectInfo .Create(ProjectId.CreateNewId(), VersionStamp.Default, "TestProject", "TestAssembly", LanguageNames.CSharp) .WithFilePath("/TestProject.csproj"); - var workspace = new AdhocWorkspace(); - workspace.AddProject(project); - var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); - var document = workspace.AddDocument(documentInfo); + workspace.AddProject(project); + var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); + document = workspace.AddDocument(documentInfo); + }); var codeDocumentProvider = new Mock(MockBehavior.Strict); var completionProvider = new FailOnGetCompletionsProvider(new Lazy(() => codeDocumentProvider.Object)); @@ -325,14 +328,17 @@ namespace Microsoft.VisualStudio.Editor.Razor private static Document CreateDocument() { - var project = ProjectInfo + Document document = null; + TestWorkspace.Create(workspace => + { + var project = ProjectInfo .Create(ProjectId.CreateNewId(), VersionStamp.Default, "TestProject", "TestAssembly", LanguageNames.CSharp) .WithFilePath("/TestProject.csproj"); - var workspace = new AdhocWorkspace(); - workspace.AddProject(project); - var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); - var document = workspace.AddDocument(documentInfo); - document = document.WithFilePath("Test.cshtml"); + workspace.AddProject(project); + var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "Test.cshtml"); + document = workspace.AddDocument(documentInfo); + document = document.WithFilePath("Test.cshtml"); + }); return document; } @@ -369,4 +375,4 @@ namespace Microsoft.VisualStudio.Editor.Razor } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs index 544f74a91d..8f48be572a 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs @@ -597,7 +597,7 @@ namespace Microsoft.VisualStudio.Editor.Razor var items = new List(); items.Add(new TestRazorProjectItem(path)); - var project = new TestRazorProject(items); + var project = new TestRazorProjectFileSystem(items); var templateEngine = new RazorTemplateEngine(engine, project); templateEngine.Options.DefaultImports = RazorSourceDocument.Create("@addTagHelper *, Test", "_TestImports.cshtml"); diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultVisualStudioWorkspaceAccessorTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultVisualStudioWorkspaceAccessorTest.cs new file mode 100644 index 0000000000..033a825a8a --- /dev/null +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultVisualStudioWorkspaceAccessorTest.cs @@ -0,0 +1,150 @@ +// 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.ObjectModel; +using Microsoft.CodeAnalysis; +using Microsoft.VisualStudio.Editor.Razor; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.Projection; +using Moq; +using Xunit; + +namespace Microsoft.VisualStudio.LanguageServices.Razor +{ + public class DefaultVisualStudioWorkspaceAccessorTest + { + [Fact] + public void TryGetWorkspace_CanGetWorkspaceFromProjectionBuffersOnly() + { + // Arrange + var textBuffer = Mock.Of(); + var workspaceAccessor = new TestWorkspaceAccessor(true, false); + + // Act + var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace); + + // Assert + Assert.True(result); + } + + [Fact] + public void TryGetWorkspace_CanGetWorkspaceFromBuffersInHierarchyOnly() + { + // Arrange + var textBuffer = Mock.Of(); + var workspaceAccessor = new TestWorkspaceAccessor(false, true); + + // Act + var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace); + + // Assert + Assert.True(result); + } + + [Fact] + public void TryGetWorkspace_CanGetWorkspaceFromBuffersInHierarchyOrProjectionBuffers() + { + // Arrange + var textBuffer = Mock.Of(); + var workspaceAccessor = new TestWorkspaceAccessor(true, true); + + // Act + var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace); + + // Assert + Assert.True(result); + } + + [Fact] + public void TryGetWorkspaceFromProjectionBuffer_NoProjectionBuffer_ReturnsFalse() + { + // Arrange + var bufferGraph = new Mock(); + bufferGraph.Setup(graph => graph.GetTextBuffers(It.IsAny>())) + .Returns>(predicate => new Collection()); + var bufferGraphService = new Mock(); + bufferGraphService.Setup(service => service.CreateBufferGraph(It.IsAny())) + .Returns(bufferGraph.Object); + var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(bufferGraphService.Object, Mock.Of(), TestWorkspace.Create()); + var textBuffer = Mock.Of(); + + // Act + var result = workspaceAccessor.TryGetWorkspaceFromProjectionBuffer(textBuffer, out var workspace); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryGetWorkspaceFromHostProject_NoHostProject_ReturnsFalse() + { + // Arrange + var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(Mock.Of(), Mock.Of(), TestWorkspace.Create()); + var textBuffer = Mock.Of(); + + // Act + var result = workspaceAccessor.TryGetWorkspaceFromHostProject(textBuffer, out var workspace); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryGetWorkspaceFromHostProject_HasHostProject_ReturnsTrueWithDefaultWorkspace() + { + // Arrange + var textBuffer = Mock.Of(); + var projectService = Mock.Of(service => service.GetHostProject(textBuffer) == new object()); + var defaultWorkspace = TestWorkspace.Create(); + var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(Mock.Of(), projectService, defaultWorkspace); + + // Act + var result = workspaceAccessor.TryGetWorkspaceFromHostProject(textBuffer, out var workspace); + + // Assert + Assert.True(result); + Assert.Same(defaultWorkspace, workspace); + } + + private class TestWorkspaceAccessor : DefaultVisualStudioWorkspaceAccessor + { + private readonly bool _canGetWorkspaceFromProjectionBuffer; + private readonly bool _canGetWorkspaceFromHostProject; + + internal TestWorkspaceAccessor(bool canGetWorkspaceFromProjectionBuffer, bool canGetWorkspaceFromHostProject) : + base( + Mock.Of(), + Mock.Of(), + TestWorkspace.Create()) + { + _canGetWorkspaceFromProjectionBuffer = canGetWorkspaceFromProjectionBuffer; + _canGetWorkspaceFromHostProject = canGetWorkspaceFromHostProject; + } + + internal override bool TryGetWorkspaceFromProjectionBuffer(ITextBuffer textBuffer, out Workspace workspace) + { + if (_canGetWorkspaceFromProjectionBuffer) + { + workspace = TestWorkspace.Create(); + return true; + } + + workspace = null; + return false; + } + + internal override bool TryGetWorkspaceFromHostProject(ITextBuffer textBuffer, out Workspace workspace) + { + if (_canGetWorkspaceFromHostProject) + { + workspace = TestWorkspace.Create(); + return true; + } + + workspace = null; + return false; + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultRazorEditorFactoryServiceTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultRazorEditorFactoryServiceTest.cs index f92620cec7..8bff7a066a 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultRazorEditorFactoryServiceTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultRazorEditorFactoryServiceTest.cs @@ -1,14 +1,15 @@ // 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 Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Utilities; using Moq; using Xunit; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { public class DefaultRazorEditorFactoryServiceTest { @@ -48,7 +49,25 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } [Fact] - public void EnsureTextBufferInitialized_StoresTracker() + public void TryInitializeTextBuffer_WorkspaceAccessorCanNotAccessWorkspace_ReturnsFalse() + { + // Arrange + Workspace workspace = null; + var workspaceAccessor = new Mock(); + workspaceAccessor.Setup(provider => provider.TryGetWorkspace(It.IsAny(), out workspace)) + .Returns(false); + var factoryService = new DefaultRazorEditorFactoryService(workspaceAccessor.Object); + var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); + + // Act + var result = factoryService.TryInitializeTextBuffer(textBuffer); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryInitializeTextBuffer_StoresTracker_ReturnsTrue() { // Arrange var expectedDocumentTracker = Mock.Of(); @@ -56,29 +75,31 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out VisualStudioDocumentTracker documentTracker)); Assert.Same(expectedDocumentTracker, documentTracker); } [Fact] - public void EnsureTextBufferInitialized_OnlyStoresTrackerOnTextBufferOnce() + public void TryInitializeTextBuffer_OnlyStoresTrackerOnTextBufferOnce_ReturnsTrue() { // Arrange var factoryService = CreateFactoryService(); var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); - factoryService.EnsureTextBufferInitialized(textBuffer); + factoryService.TryInitializeTextBuffer(textBuffer); var expectedDocumentTracker = textBuffer.Properties[typeof(VisualStudioDocumentTracker)]; // Create a second factory service so it generates a different tracker factoryService = CreateFactoryService(); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out VisualStudioDocumentTracker documentTracker)); Assert.Same(expectedDocumentTracker, documentTracker); } @@ -115,7 +136,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } [Fact] - public void EnsureTextBufferInitialized_StoresParser() + public void TryInitializeTextBuffer_StoresParser_ReturnsTrue() { // Arrange var expectedParser = Mock.Of(); @@ -123,29 +144,31 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(VisualStudioRazorParser), out VisualStudioRazorParser parser)); Assert.Same(expectedParser, parser); } [Fact] - public void EnsureTextBufferInitialized_OnlyStoresParserOnTextBufferOnce() + public void TryInitializeTextBuffer_OnlyStoresParserOnTextBufferOnce_ReturnsTrue() { // Arrange var factoryService = CreateFactoryService(); var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); - factoryService.EnsureTextBufferInitialized(textBuffer); + factoryService.TryInitializeTextBuffer(textBuffer); var expectedParser = textBuffer.Properties[typeof(VisualStudioRazorParser)]; // Create a second factory service so it generates a different parser factoryService = CreateFactoryService(); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(VisualStudioRazorParser), out VisualStudioRazorParser parser)); Assert.Same(expectedParser, parser); } @@ -182,7 +205,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor } [Fact] - public void EnsureTextBufferInitialized_StoresSmartIndenter() + public void TryInitializeTextBuffer_StoresSmartIndenter_ReturnsTrue() { // Arrange var expectedSmartIndenter = Mock.Of(); @@ -190,29 +213,31 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(BraceSmartIndenter), out BraceSmartIndenter smartIndenter)); Assert.Same(expectedSmartIndenter, smartIndenter); } [Fact] - public void EnsureTextBufferInitialized_OnlyStoresSmartIndenterOnTextBufferOnce() + public void TryInitializeTextBuffer_OnlyStoresSmartIndenterOnTextBufferOnce_ReturnsTrue() { // Arrange var factoryService = CreateFactoryService(); var textBuffer = Mock.Of(b => b.ContentType == RazorContentType && b.Properties == new PropertyCollection()); - factoryService.EnsureTextBufferInitialized(textBuffer); + factoryService.TryInitializeTextBuffer(textBuffer); var expectedSmartIndenter = textBuffer.Properties[typeof(BraceSmartIndenter)]; // Create a second factory service so it generates a different smart indenter factoryService = CreateFactoryService(); // Act - factoryService.EnsureTextBufferInitialized(textBuffer); + var result = factoryService.TryInitializeTextBuffer(textBuffer); // Assert + Assert.True(result); Assert.True(textBuffer.Properties.TryGetProperty(typeof(BraceSmartIndenter), out BraceSmartIndenter smartIndenter)); Assert.Same(expectedSmartIndenter, smartIndenter); } @@ -229,9 +254,22 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor var documentTrackerFactory = Mock.Of(f => f.Create(It.IsAny()) == documentTracker); var parserFactory = Mock.Of(f => f.Create(It.IsAny()) == parser); var smartIndenterFactory = Mock.Of(f => f.Create(It.IsAny()) == smartIndenter); - var factoryService = new DefaultRazorEditorFactoryService(documentTrackerFactory, parserFactory, smartIndenterFactory); + + var services = TestServices.Create(new ILanguageService[] + { + documentTrackerFactory, + parserFactory, + smartIndenterFactory + }); + + var workspace = TestWorkspace.Create(services); + var workspaceAccessor = new Mock(); + workspaceAccessor.Setup(p => p.TryGetWorkspace(It.IsAny(), out workspace)) + .Returns(true); + + var factoryService = new DefaultRazorEditorFactoryService(workspaceAccessor.Object); return factoryService; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultVisualStudioDocumentTrackerTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultVisualStudioDocumentTrackerTest.cs index 9a6e4552fe..3185ec2a1c 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultVisualStudioDocumentTrackerTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/DefaultVisualStudioDocumentTrackerTest.cs @@ -6,6 +6,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Editor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; @@ -26,13 +27,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor private ProjectSnapshotManager ProjectManager => Mock.Of(p => p.Projects == new List()); private TextBufferProjectService ProjectService => Mock.Of( - s => s.GetHierarchy(It.IsAny()) == Mock.Of() && + s => s.GetHostProject(It.IsAny()) == Mock.Of() && s.IsSupportedProject(It.IsAny()) == true && s.GetProjectPath(It.IsAny()) == "C:/Some/Path/TestProject.csproj"); - private EditorSettingsManagerInternal EditorSettingsManager => new DefaultEditorSettingsManagerInternal(); + private EditorSettingsManager EditorSettingsManager => new DefaultEditorSettingsManager(Mock.Of()); - private Workspace Workspace => new AdhocWorkspace(); + private Workspace Workspace => TestWorkspace.Create(); [Fact] public void EditorSettingsManager_Changed_TriggersContextChanged() diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs index 2b727a2139..2cae9c17b1 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs @@ -22,13 +22,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor private ProjectSnapshotManager ProjectManager { get; } = Mock.Of(p => p.Projects == new List()); private TextBufferProjectService ProjectService { get; } = Mock.Of( - s => s.GetHierarchy(It.IsAny()) == Mock.Of() && + s => s.GetHostProject(It.IsAny()) == Mock.Of() && s.IsSupportedProject(It.IsAny()) == true && s.GetProjectPath(It.IsAny()) == "C:/Some/Path/TestProject.csproj"); - private EditorSettingsManagerInternal EditorSettingsManager => new DefaultEditorSettingsManagerInternal(); + private EditorSettingsManager EditorSettingsManager => new DefaultEditorSettingsManager(Mock.Of()); - private Workspace Workspace { get; } = new AdhocWorkspace(); + private Workspace Workspace { get; } = TestWorkspace.Create(); private IContentType RazorContentType { get; } = Mock.Of(c => c.IsOfType(RazorLanguage.ContentType) == true); diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj index d182c95d31..09ab7e7662 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj @@ -21,6 +21,7 @@ + diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultProjectSnapshotWorkerTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultProjectSnapshotWorkerTest.cs deleted file mode 100644 index 1ab2f64753..0000000000 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultProjectSnapshotWorkerTest.cs +++ /dev/null @@ -1,53 +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 Moq; -using Xunit; - -namespace Microsoft.CodeAnalysis.Razor.ProjectSystem -{ - public class DefaultProjectSnapshotWorkerTest : ForegroundDispatcherTestBase - { - public DefaultProjectSnapshotWorkerTest() - { - Project = new AdhocWorkspace().AddProject("Test1", LanguageNames.CSharp); - - CompletionSource = new TaskCompletionSource(); - ConfigurationFactory = Mock.Of(f => f.GetConfigurationAsync(It.IsAny(), default(CancellationToken)) == CompletionSource.Task); - } - - private Project Project { get; } - - private ProjectExtensibilityConfigurationFactory ConfigurationFactory { get; } - - private TaskCompletionSource CompletionSource { get; } - - [ForegroundFact] - public async Task ProcessUpdateAsync_DoesntBlockForegroundThread() - { - // Arrange - var worker = new DefaultProjectSnapshotWorker(Dispatcher, ConfigurationFactory); - - var context = new ProjectSnapshotUpdateContext(Project); - - var configuration = Mock.Of(); - - // Act 1 -- We want to verify that this doesn't block the main thread - var task = worker.ProcessUpdateAsync(context); - - // Assert 1 - // - // We haven't let the background task proceed yet, so this is still null. - Assert.Null(context.Configuration); - - // Act 2 - Ok let's go - CompletionSource.SetResult(configuration); - await task; - - // Assert 2 - Assert.Same(configuration, context.Configuration); - } - } -} diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/ProjectSnapshotWorkerQueueTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/ProjectSnapshotWorkerQueueTest.cs index 7dc947f44e..f4129b8bd6 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/ProjectSnapshotWorkerQueueTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/ProjectSnapshotWorkerQueueTest.cs @@ -16,10 +16,17 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { public ProjectSnapshotWorkerQueueTest() { - Workspace = new AdhocWorkspace(); + Project project1 = null; + Project project2 = null; - Project1 = Workspace.CurrentSolution.AddProject("Test1", "Test1", LanguageNames.CSharp); - Project2 = Workspace.CurrentSolution.AddProject("Test2", "Test2", LanguageNames.CSharp); + Workspace = TestWorkspace.Create(workspace => + { + project1 = workspace.CurrentSolution.AddProject("Test1", "Test1", LanguageNames.CSharp); + project2 = workspace.CurrentSolution.AddProject("Test2", "Test2", LanguageNames.CSharp); + }); + + Project1 = project1; + Project2 = project2; } public Project Project1 { get; } diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TagHelperDescriptorSerializationTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TagHelperDescriptorSerializationTest.cs index cb2d82a79a..4e37727804 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TagHelperDescriptorSerializationTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TagHelperDescriptorSerializationTest.cs @@ -88,8 +88,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor builder.AllowChildTag("allowed-child-one") .AddMetadata("foo", "bar") .AddDiagnostic(RazorDiagnostic.Create( - new RazorDiagnosticDescriptor("id", () => "Test Message 1", RazorDiagnosticSeverity.Error), new SourceSpan(null, 10, 20, 30, 40))) - .AddDiagnostic(RazorDiagnostic.Create(new RazorError("Test Message 2", 10, 20, 30, 40))); + new RazorDiagnosticDescriptor("id", () => "Test Message", RazorDiagnosticSeverity.Error), new SourceSpan(null, 10, 20, 30, 40))); }); // Act @@ -186,4 +185,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor return descriptor; } } -} +} \ No newline at end of file diff --git a/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs b/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs index 81465d9541..613df16b0c 100644 --- a/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs +++ b/test/RazorPageGenerator.Test/RazorPageGeneratorTest.cs @@ -35,9 +35,10 @@ namespace RazorPageGenerator.Test { // Arrange var projectDirectory = TestProject.GetProjectDirectory(GetType()); - var razorEngine = Program.CreateRazorEngine("Microsoft.AspNetCore.TestGenerated"); + var projectEngine = Program.CreateProjectEngine("Microsoft.AspNetCore.TestGenerated", projectDirectory); + // Act - var results = Program.MainCore(razorEngine, projectDirectory); + var results = Program.MainCore(projectEngine, projectDirectory); // Assert Assert.Collection(results, diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj b/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj index 8dd9db4535..bcfa2e6662 100644 --- a/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj +++ b/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj @@ -42,10 +42,10 @@ v4.6 true true - true + false true true - false + true true @@ -263,6 +263,11 @@ + + + + + + + true + @@ -45,6 +51,13 @@ Copyright (c) .NET Foundation. All rights reserved. --> Implicit + + false + @@ -52,7 +65,10 @@ Copyright (c) .NET Foundation. All rights reserved. - + + $(IncludeRazorContentInPack) + + diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs index 37427a1cc3..08cdb17f82 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs @@ -233,6 +233,33 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } } + public static void NuspecDoesNotContain(MSBuildResult result, string nuspecPath, string expected) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (nuspecPath == null) + { + throw new ArgumentNullException(nameof(nuspecPath)); + } + + if (expected == null) + { + throw new ArgumentNullException(nameof(expected)); + } + + nuspecPath = Path.Combine(result.Project.DirectoryPath, nuspecPath); + FileExists(result, nuspecPath); + + var content = File.ReadAllText(nuspecPath); + if (content.Contains(expected)) + { + throw new NuspecFoundException(result, nuspecPath, content, expected); + } + } + public static void NupkgContains(MSBuildResult result, string nupkgPath, string filePath) { if (result == null) @@ -507,6 +534,34 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } } + private class NuspecFoundException : MSBuildXunitException + { + public NuspecFoundException(MSBuildResult result, string filePath, string content, string expected) + : base(result) + { + FilePath = filePath; + Content = content; + Expected = expected; + } + + public string Content { get; } + + public string Expected { get; } + + public string FilePath { get; } + + protected override string Heading + { + get + { + return + $"nuspec: '{FilePath}' should not contain the content {Expected}." + + Environment.NewLine + + $"actual content: {Content}"; + } + } + } + private class NupkgFileMissingException : MSBuildXunitException { public NupkgFileMissingException(MSBuildResult result, string nupkgPath, string filePath) diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs index d060fc02b8..d95267414f 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs @@ -26,6 +26,39 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests $""); + Assert.NuspecDoesNotContain( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + @""); + + Assert.NupkgContains( + result, + Path.Combine("bin", Configuration, "ClassLibrary.1.0.0.nupkg"), + Path.Combine("lib", "netcoreapp2.0", "ClassLibrary.PrecompiledViews.dll")); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet() + { + var result = await DotnetMSBuild("Pack", "/p:RazorCompileOnBuild=true /p:IncludeRazorContentInPack=true"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.PrecompiledViews.dll"); + + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + $""); + + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + @""); + Assert.NupkgContains( result, Path.Combine("bin", Configuration, "ClassLibrary.1.0.0.nupkg"), diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj index d3a47e0743..558cbea953 100644 --- a/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -24,12 +24,6 @@ - - - false - - - From 1c9088087be74ff8696437b6a0dd4ee8cf5852ce Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Feb 2018 15:08:20 -0800 Subject: [PATCH 23/56] Update to the latest Sdk and cleanup projects --- korebuild-lock.txt | 4 ++-- .../AppWithP2PReference/AppWithP2PReference.csproj | 8 +------- test/testapps/ClassLibrary/ClassLibrary.csproj | 8 +------- test/testapps/Directory.Build.props | 5 +++-- test/testapps/SimpleMvc/SimpleMvc.csproj | 8 +------- test/testapps/SimplePages/SimplePages.csproj | 8 +------- 6 files changed, 9 insertions(+), 32 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 538f6228c3..fd067867ea 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15707 -commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 +version:2.1.0-preview2-15710 +commithash:b4093fc577427094ef66271ded3b8acbb3bc31d0 diff --git a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj index 29fa0ee0be..b0ca8cfd76 100644 --- a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj +++ b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj @@ -1,11 +1,8 @@ - - - + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ - @@ -25,7 +22,4 @@ - - - diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj index 558cbea953..791350d163 100644 --- a/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -1,12 +1,9 @@ - - - + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ - @@ -26,7 +23,4 @@ - - - diff --git a/test/testapps/Directory.Build.props b/test/testapps/Directory.Build.props index 134f59524c..bb458103c9 100644 --- a/test/testapps/Directory.Build.props +++ b/test/testapps/Directory.Build.props @@ -5,8 +5,9 @@ $(MSBuildThisFileDirectory)..\..\ $([MSBuild]::EnsureTrailingSlash('$(SolutionRoot)')) - - <_RazorSdkPackageReferenced>true + + $(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.props + $(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets diff --git a/test/testapps/SimpleMvc/SimpleMvc.csproj b/test/testapps/SimpleMvc/SimpleMvc.csproj index 115efbaa0b..21ea1afc3c 100644 --- a/test/testapps/SimpleMvc/SimpleMvc.csproj +++ b/test/testapps/SimpleMvc/SimpleMvc.csproj @@ -1,12 +1,9 @@ - - - + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ - @@ -23,7 +20,4 @@ - - - diff --git a/test/testapps/SimplePages/SimplePages.csproj b/test/testapps/SimplePages/SimplePages.csproj index a8fba5b4b1..2928d33d45 100644 --- a/test/testapps/SimplePages/SimplePages.csproj +++ b/test/testapps/SimplePages/SimplePages.csproj @@ -1,12 +1,9 @@ - + - - <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ - @@ -22,8 +19,5 @@ - - - From c5e83c61f89037647c13169983a42d9d342ea850 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 20 Feb 2018 16:08:52 -0800 Subject: [PATCH 24/56] Changed AddDefaultImports to take strings instead of project items. - Strings here was important because any import added to the system dynamically needs to eventually make its way back to being a project item. With strings we can state that they do exist (have content) but do not have any file paths associated. - Updated all call sites to use the new AddDefaultImports string based api. #2080 --- .../RazorProjectEngineBuilderExtensions.cs | 39 +++++++++++++++++-- src/RazorPageGenerator/Program.cs | 36 ++--------------- ...tVisualStudioRazorParserIntegrationTest.cs | 2 +- .../RazorSyntaxTreePartialParserTest.cs | 2 +- 4 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs index 48695a6f97..ae92e4089b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorProjectEngineBuilderExtensions.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -151,7 +152,7 @@ namespace Microsoft.AspNetCore.Razor.Language /// The . /// The collection of imports. /// The . - public static RazorProjectEngineBuilder AddDefaultImports(this RazorProjectEngineBuilder builder, params RazorProjectItem[] imports) + public static RazorProjectEngineBuilder AddDefaultImports(this RazorProjectEngineBuilder builder, params string[] imports) { if (builder == null) { @@ -204,7 +205,7 @@ namespace Microsoft.AspNetCore.Razor.Language private class AdditionalImportsProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature { private readonly IImportProjectFeature _existingImportFeature; - private readonly RazorProjectItem[] _imports; + private readonly IEnumerable _imports; public override RazorProjectEngine ProjectEngine { @@ -216,10 +217,10 @@ namespace Microsoft.AspNetCore.Razor.Language } } - public AdditionalImportsProjectFeature(IImportProjectFeature existingImportFeature, params RazorProjectItem[] imports) + public AdditionalImportsProjectFeature(IImportProjectFeature existingImportFeature, params string[] imports) { _existingImportFeature = existingImportFeature; - _imports = imports; + _imports = imports.Select(import => new InMemoryProjectItem(import)); } public IReadOnlyList GetImports(RazorProjectItem projectItem) @@ -229,6 +230,36 @@ namespace Microsoft.AspNetCore.Razor.Language return imports; } + + private class InMemoryProjectItem : RazorProjectItem + { + private readonly byte[] _importBytes; + + public InMemoryProjectItem(string content) + { + if (string.IsNullOrEmpty(content)) + { + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(content)); + } + + var preamble = Encoding.UTF8.GetPreamble(); + var contentBytes = Encoding.UTF8.GetBytes(content); + + _importBytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_importBytes, 0); + contentBytes.CopyTo(_importBytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public override Stream Read() => new MemoryStream(_importBytes); + } } } } diff --git a/src/RazorPageGenerator/Program.cs b/src/RazorPageGenerator/Program.cs index 1aae7c86ef..f3ae757886 100644 --- a/src/RazorPageGenerator/Program.cs +++ b/src/RazorPageGenerator/Program.cs @@ -68,7 +68,10 @@ Examples: configure(builder); } - builder.AddDefaultImports(DefaultImportItem.Instance); + builder.AddDefaultImports(@" +@using System +@using System.Threading.Tasks +"); }); return projectEngine; } @@ -153,37 +156,6 @@ Examples: } } - private class DefaultImportItem : RazorProjectItem - { - private readonly byte[] _defaultImportBytes; - - private DefaultImportItem() - { - var preamble = Encoding.UTF8.GetPreamble(); - var content = @" -@using System -@using System.Threading.Tasks -"; - var contentBytes = Encoding.UTF8.GetBytes(content); - - _defaultImportBytes = new byte[preamble.Length + contentBytes.Length]; - preamble.CopyTo(_defaultImportBytes, 0); - contentBytes.CopyTo(_defaultImportBytes, preamble.Length); - } - - public override string BasePath => null; - - public override string FilePath => null; - - public override string PhysicalPath => null; - - public override bool Exists => true; - - public static DefaultImportItem Instance { get; } = new DefaultImportItem(); - - public override Stream Read() => new MemoryStream(_defaultImportBytes); - } - private class FileSystemRazorProjectItemWrapper : RazorProjectItem { private readonly RazorProjectItem _source; diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs index 2b07a09545..2102506035 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioRazorParserIntegrationTest.cs @@ -533,7 +533,7 @@ namespace Microsoft.VisualStudio.Editor.Razor { RazorExtensions.Register(builder); - builder.AddDefaultImports(new TestRazorProjectItem("_TestImports.cshtml") { Content = "@addTagHelper *, Test" }); + builder.AddDefaultImports("@addTagHelper *, Test"); if (tagHelpers != null) { diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs index a35ee3c13a..8b5ee4ef5a 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorSyntaxTreePartialParserTest.cs @@ -589,7 +589,7 @@ namespace Microsoft.VisualStudio.Editor.Razor { RazorExtensions.Register(builder); - builder.AddDefaultImports(new TestRazorProjectItem("_TestImports.cshtml") { Content = "@addTagHelper *, Test" }); + builder.AddDefaultImports("@addTagHelper *, Test"); if (tagHelpers != null) { From fed0970b333c09707920f493d0e70857cbf738ee Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 21 Feb 2018 11:26:04 -0800 Subject: [PATCH 25/56] Revert "Update to the latest Sdk and cleanup projects" This reverts commit 1c9088087be74ff8696437b6a0dd4ee8cf5852ce. --- korebuild-lock.txt | 4 ++-- .../AppWithP2PReference/AppWithP2PReference.csproj | 8 +++++++- test/testapps/ClassLibrary/ClassLibrary.csproj | 8 +++++++- test/testapps/Directory.Build.props | 5 ++--- test/testapps/SimpleMvc/SimpleMvc.csproj | 8 +++++++- test/testapps/SimplePages/SimplePages.csproj | 8 +++++++- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index fd067867ea..538f6228c3 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15710 -commithash:b4093fc577427094ef66271ded3b8acbb3bc31d0 +version:2.1.0-preview2-15707 +commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 diff --git a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj index b0ca8cfd76..29fa0ee0be 100644 --- a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj +++ b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj @@ -1,8 +1,11 @@ - + + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + @@ -22,4 +25,7 @@ + + + diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj index 791350d163..558cbea953 100644 --- a/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -1,9 +1,12 @@ - + + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + @@ -23,4 +26,7 @@ + + + diff --git a/test/testapps/Directory.Build.props b/test/testapps/Directory.Build.props index bb458103c9..134f59524c 100644 --- a/test/testapps/Directory.Build.props +++ b/test/testapps/Directory.Build.props @@ -5,9 +5,8 @@ $(MSBuildThisFileDirectory)..\..\ $([MSBuild]::EnsureTrailingSlash('$(SolutionRoot)')) - - $(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.props - $(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets + + <_RazorSdkPackageReferenced>true diff --git a/test/testapps/SimpleMvc/SimpleMvc.csproj b/test/testapps/SimpleMvc/SimpleMvc.csproj index 21ea1afc3c..115efbaa0b 100644 --- a/test/testapps/SimpleMvc/SimpleMvc.csproj +++ b/test/testapps/SimpleMvc/SimpleMvc.csproj @@ -1,9 +1,12 @@ - + + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + @@ -20,4 +23,7 @@ + + + diff --git a/test/testapps/SimplePages/SimplePages.csproj b/test/testapps/SimplePages/SimplePages.csproj index 2928d33d45..a8fba5b4b1 100644 --- a/test/testapps/SimplePages/SimplePages.csproj +++ b/test/testapps/SimplePages/SimplePages.csproj @@ -1,9 +1,12 @@ - + + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + @@ -19,5 +22,8 @@ + + + From 8938f6c8c28f78b477c7d9ed60c891cfa53e2384 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Feb 2018 15:16:07 -0800 Subject: [PATCH 26/56] Change the default extension for Razor views to .Views.dll --- ...ft.AspNetCore.Mvc.Razor.Extensions.targets | 7 +- .../Sdk.Razor.CurrentVersion.targets | 5 +- .../IntegrationTests/BuildIntegrationTest.cs | 58 +++++----- .../BuildServerIntegrationTest.cs | 14 +-- .../ConfigurationMetadataIntegrationTest.cs | 12 +- .../DesignTimeBuildIntegrationTest.cs | 4 +- .../IntegrationTests/PackIntegrationTest.cs | 16 +-- .../PublishIntegrationTest.cs | 104 +++++++++--------- .../RazorCompileIntegrationTest.cs | 16 +-- .../RazorGenerateIntegrationTest.cs | 6 +- 10 files changed, 125 insertions(+), 117 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets index 61a0e7a8dc..418a3f1b01 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets @@ -5,5 +5,10 @@ MVC will generally want to add support for runtime compilation, but only for applications. --> true + + + .Views - \ No newline at end of file + diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index c101bf26d2..67cec20d4c 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -91,9 +91,12 @@ Copyright (c) .NET Foundation. All rights reserved. $(IntermediateOutputPath)Razor\ + + + .Razor - $(TargetName).PrecompiledViews + $(TargetName)$(RazorTargetNameSuffix) + + + + + + + + + + + File + + + File + + + Project + + + + diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props index 00d411c6be..8df8703baa 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props @@ -72,27 +72,4 @@ Copyright (c) .NET Foundation. All rights reserved. - - - - - - - - File - - - File - - - Project - - - diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 67cec20d4c..52931c23f7 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -491,9 +491,15 @@ Copyright (c) .NET Foundation. All rights reserved. - + + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\Razor\Microsoft.NET.Sdk.Razor.DesignTime.targets + $(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Razor.DesignTime.targets + + + + diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj b/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj index 85c7323bf5..67dc3bf0e1 100644 --- a/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj +++ b/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj @@ -268,6 +268,21 @@ + + + + true + MSBuild + Microsoft\VisualStudio\Razor\ + + + + true + MSBuild + Microsoft\VisualStudio\Razor\Rules\ + + + + From 540e8437dabbce9f41ec32c94cd8e345ab1f86cc Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 21 Feb 2018 11:59:09 -0800 Subject: [PATCH 28/56] Enable PreserveCompilationContext by default --- .../build/netstandard2.0/Sdk.Razor.CurrentVersion.props | 2 ++ .../build/netstandard2.0/Sdk.Razor.CurrentVersion.targets | 7 ------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props index 8df8703baa..fcddf1cb87 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props @@ -62,6 +62,8 @@ Copyright (c) .NET Foundation. All rights reserved. Set to true to allow a Razor code generation to use a persistent build server process. --> false + + true diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 52931c23f7..97fddceaae 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -60,13 +60,6 @@ Copyright (c) .NET Foundation. All rights reserved. - - - true - - From 60e5818884470c923bcac4271dffb369c50aa89d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 21 Feb 2018 18:27:10 -0800 Subject: [PATCH 29/56] Use FeatureBranchVersionSuffix when generating VersionSuffix --- version.props | 1 + 1 file changed, 1 insertion(+) diff --git a/version.props b/version.props index 64f2d97dbc..68a44892f6 100644 --- a/version.props +++ b/version.props @@ -5,6 +5,7 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 + $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) 99999 From 64c86634a8393a43e0edb2efc02989e4aad8bbad Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 22 Feb 2018 17:15:58 -0800 Subject: [PATCH 30/56] Added a test to verify incremental TagHelper discovery --- .../IntegrationTests/Assert.cs | 36 ++++++++++++++++ .../RazorGenerateIntegrationTest.cs | 41 ++++++++++++++++++- test/testapps/SimpleMvc/SimpleTagHelper.cs | 8 ++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 test/testapps/SimpleMvc/SimpleTagHelper.cs diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs index 08cdb17f82..12445df451 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs @@ -100,6 +100,42 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests throw new BuildOutputMissingException(result, match); } + public static void FileContains(MSBuildResult result, string filePath, string match) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + filePath = Path.Combine(result.Project.DirectoryPath, filePath); + FileExists(result, filePath); + + var text = File.ReadAllText(filePath); + if (text.Contains(match)) + { + return; + } + + throw new FileContentMissingException(result, filePath, File.ReadAllText(filePath), match); + } + + public static void FileDoesNotContain(MSBuildResult result, string filePath, string match) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + filePath = Path.Combine(result.Project.DirectoryPath, filePath); + FileExists(result, filePath); + + var text = File.ReadAllText(filePath); + if (text.Contains(match)) + { + throw new FileContentFoundException(result, filePath, File.ReadAllText(filePath), match); + } + } + public static void FileContainsLine(MSBuildResult result, string filePath, string match) { if (result == null) diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs index 6f592d7784..bab76935dd 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs @@ -26,6 +26,14 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + // RazorGenerate should generate correct TagHelper caches + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.TagHelpers.input.cache"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"); + Assert.FileContains( + result, + Path.Combine(IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"), + @"""Name"":""SimpleMvc.SimpleTagHelper"""); + Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "_ViewImports.cs"); Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "_ViewStart.cs"); Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "Home", "About.cs"); @@ -44,7 +52,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Introducing a syntax error, an unclosed brace ReplaceContent("@{", "Views", "Home", "Index.cshtml"); - var result = await DotnetMSBuild("RazorGenerate"); + var result = await DotnetMSBuild(RazorGenerateTarget); Assert.BuildFailed(result); @@ -181,6 +189,37 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileDoesNotExist(result, generatedFile); } + [Fact(Skip = "https://github.com/aspnet/Razor/issues/2104")] + [InitializeTestProject("SimpleMvc")] + public async Task RazorGenerate_Rebuilds_IfTagHelpersChanged() + { + // Act - 1 + var expectedTagHelperCacheContent = @"""Name"":""SimpleMvc.SimpleTagHelper"""; + var result = await DotnetMSBuild(RazorGenerateTarget); + var file = Path.Combine(Project.DirectoryPath, "SimpleTagHelper.cs"); + var tagHelperOutputCache = Path.Combine(IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"); + var generatedFile = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cs"); + + // Assert - 1 + Assert.BuildPassed(result); + Assert.FileContains(result, tagHelperOutputCache, expectedTagHelperCacheContent); + var fileThumbPrint = GetThumbPrint(generatedFile); + + // Act - 2 + // Update the source content and build. We should expect the outputs to be regenerated. + // Timestamps on xplat are precise only to a second. Add a delay so we can ensure that MSBuild recognizes the + // file change. See https://github.com/dotnet/corefx/issues/26024 + await Task.Delay(TimeSpan.FromSeconds(1)); + ReplaceContent(string.Empty, file); + result = await DotnetMSBuild(RazorGenerateTarget); + + // Assert - 2 + Assert.BuildPassed(result); + Assert.FileDoesNotContain(result, tagHelperOutputCache, expectedTagHelperCacheContent); + var newThumbPrint = GetThumbPrint(generatedFile); + Assert.NotEqual(fileThumbPrint, newThumbPrint); + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task RazorGenerate_Noops_WithNoFiles() diff --git a/test/testapps/SimpleMvc/SimpleTagHelper.cs b/test/testapps/SimpleMvc/SimpleTagHelper.cs new file mode 100644 index 0000000000..a2abedef92 --- /dev/null +++ b/test/testapps/SimpleMvc/SimpleTagHelper.cs @@ -0,0 +1,8 @@ +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace SimpleMvc +{ + public class SimpleTagHelper : TagHelper + { + } +} \ No newline at end of file From b538ceba9365a018eadc48bbe57dc9b2a76cbd90 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 22 Feb 2018 11:51:17 -0800 Subject: [PATCH 31/56] Change final code documents to not contain non-existent imports. - Existent imports are imports that have content that contribute to the processing of a Razor document. Prior to this we had a legacy expectation that code documents had empty markers in them for all of their import locations. This proved troublesome when cross-referencing files that had file paths and were supposed to be existent but weren't in metadata. Now that we have a project engine with a de-coupled import feature we can rely on the import feature for finding all locations of important files and then strip out any non-existent items. --- .../DefaultRazorProjectEngine.cs | 23 ++++++++++-------- ...efaultRazorProjectEngineIntegrationTest.cs | 2 +- .../DefaultRazorProjectEngineTest.cs | 24 ++++++------------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs index e7eaafec22..89b667979a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorProjectEngine.cs @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Razor.Language var importFeature = GetRequiredFeature(); var importItems = importFeature.GetImports(projectItem); - var importSourceDocuments = importItems.Select(ConvertToSourceDocument); + var importSourceDocuments = GetImportSourceDocuments(importItems); var parserOptions = GetRequiredFeature().Create(ConfigureParserOptions); var codeGenerationOptions = GetRequiredFeature().Create(ConfigureCodeGenerationOptions); @@ -84,12 +84,11 @@ namespace Microsoft.AspNetCore.Razor.Language var importFeature = GetRequiredFeature(); var importItems = importFeature.GetImports(projectItem); - var importSourceDocuments = importItems.Select(ConvertToSourceDocument); + var importSourceDocuments = GetImportSourceDocuments(importItems); var parserOptions = GetRequiredFeature().Create(ConfigureDesignTimeParserOptions); var codeGenerationOptions = GetRequiredFeature().Create(ConfigureDesignTimeCodeGenerationOptions); - return RazorCodeDocument.Create(sourceDocument, importSourceDocuments, parserOptions, codeGenerationOptions); } @@ -138,17 +137,21 @@ namespace Microsoft.AspNetCore.Razor.Language } // Internal for testing - internal static RazorSourceDocument ConvertToSourceDocument(RazorProjectItem importItem) + internal static IReadOnlyList GetImportSourceDocuments(IReadOnlyList importItems) { - if (importItem.Exists) + var imports = new List(); + for (var i = 0; i < importItems.Count; i++) { - // Normal import, has file paths, content etc. - return RazorSourceDocument.ReadFrom(importItem); + var importItem = importItems[i]; + + if (importItem.Exists) + { + var sourceDocument = RazorSourceDocument.ReadFrom(importItem); + imports.Add(sourceDocument); + } } - // Marker import, doesn't exist, used as an identifier for "there could be something here". - var sourceDocumentProperties = new RazorSourceDocumentProperties(importItem.FilePath, importItem.RelativePhysicalPath); - return RazorSourceDocument.Create(string.Empty, sourceDocumentProperties); + return imports; } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs index 427b34c1b6..38b5082b2e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineIntegrationTest.cs @@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Arrange var projectItem = new TestRazorProjectItem("Index.cshtml"); - var testImport = Mock.Of(i => i.Read() == new MemoryStream() && i.FilePath == "testvalue"); + var testImport = Mock.Of(i => i.Read() == new MemoryStream() && i.FilePath == "testvalue" && i.Exists == true); var importFeature = new Mock(); importFeature .Setup(feature => feature.GetImports(It.IsAny())) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs index 171556ecf0..2ca4da9881 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorProjectEngineTest.cs @@ -9,29 +9,19 @@ namespace Microsoft.AspNetCore.Razor.Language public class DefaultRazorProjectEngineTest { [Fact] - public void ConvertToSourceDocument_ConvertsNormalImports() + public void GetImportSourceDocuments_DoesNotIncludeNonExistentItems() { // Arrange - var projectItem = new TestRazorProjectItem("Index.cshtml"); + var existingItem = new TestRazorProjectItem("Index.cshtml"); + var nonExistentItem = Mock.Of(item => item.Exists == false); + var items = new[] { existingItem, nonExistentItem }; // Act - var sourceDocument = DefaultRazorProjectEngine.ConvertToSourceDocument(projectItem); + var sourceDocuments = DefaultRazorProjectEngine.GetImportSourceDocuments(items); // Assert - Assert.NotNull(sourceDocument); - } - - [Fact] - public void ConvertToSourceDocument_ConvertsMarkerImports() - { - // Arrange - var projectItem = Mock.Of(item => item.FilePath == "Index.cshtml" && item.Exists == false); - - // Act - var sourceDocument = DefaultRazorProjectEngine.ConvertToSourceDocument(projectItem); - - // Assert - Assert.NotNull(sourceDocument); + var sourceDocument = Assert.Single(sourceDocuments); + Assert.Equal(existingItem.FilePath, sourceDocument.FilePath); } } } From aa21a6be6e450f86a4f3bef679b2a5c5860ab008 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 26 Feb 2018 10:22:29 -0800 Subject: [PATCH 32/56] Use File.Open overload that overwrites file entirely in DiscoverCommand (#2110) * Use File.Open overload that overwrites file entirely in DiscoverCommand Re-enable TagHelper discovery incrementalism test Fixes #2104 --- .../DiscoverCommand.cs | 4 +- .../IntegrationTests/Assert.cs | 47 +++++++++++++++++++ .../BuildIncrementalismTest.cs | 29 ++++++++++++ .../MSBuildIntegrationTestBase.cs | 3 ++ .../RazorGenerateIntegrationTest.cs | 34 -------------- test/testapps/SimpleMvc/SimpleTagHelper.cs | 2 +- 6 files changed, 82 insertions(+), 37 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs index 9ca5b3d8bb..2fedb87022 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs @@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.Razor.Tools { Serialize(stream, tagHelpers); - stream.Position = 0L; + stream.Position = 0; var newHash = Hash(stream); var existingHash = Hash(outputFilePath); @@ -158,7 +158,7 @@ namespace Microsoft.AspNetCore.Razor.Tools if (!HashesEqual(newHash, existingHash)) { stream.Position = 0; - using (var output = File.OpenWrite(outputFilePath)) + using (var output = File.Open(outputFilePath, FileMode.Create)) { stream.CopyTo(output); } diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs index 12445df451..b41e7e4bcc 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs @@ -136,6 +136,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } } + public static void FileContentEquals(MSBuildResult result, string filePath, string expected) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + filePath = Path.Combine(result.Project.DirectoryPath, filePath); + FileExists(result, filePath); + + var actual = File.ReadAllText(filePath); + if (!actual.Equals(expected, StringComparison.Ordinal)) + { + throw new FileContentNotEqualException(result, filePath, expected, actual); + } + } + public static void FileContainsLine(MSBuildResult result, string filePath, string match) { if (result == null) @@ -470,6 +487,36 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } } + private class FileContentNotEqualException : MSBuildXunitException + { + public FileContentNotEqualException(MSBuildResult result, string filePath, string expected, string actual) + : base(result) + { + FilePath = filePath; + Expected = expected; + Actual = actual; + } + + public string Actual { get; } + + public string FilePath { get; } + + public string Expected { get; } + + protected override string Heading + { + get + { + var builder = new StringBuilder(); + builder.AppendFormat("File content of '{0}' did not match the expected content: '{1}'.", FilePath, Expected); + builder.AppendLine(); + builder.AppendLine(); + builder.AppendLine(Actual); + return builder.ToString(); + } + } + } + private class FileMissingException : MSBuildXunitException { public FileMissingException(MSBuildResult result, string filePath) diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs index 6e2a123cdb..75cc832f72 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs @@ -56,5 +56,34 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } } } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorGenerate_RegeneratesTagHelperInputs_IfFileChanges() + { + // Act - 1 + var expectedTagHelperCacheContent = @"""Name"":""SimpleMvc.SimpleTagHelper"""; + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var file = Path.Combine(Project.DirectoryPath, "SimpleTagHelper.cs"); + var tagHelperOutputCache = Path.Combine(IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"); + var generatedFile = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cs"); + + // Assert - 1 + Assert.BuildPassed(result); + Assert.FileContains(result, tagHelperOutputCache, expectedTagHelperCacheContent); + var fileThumbPrint = GetThumbPrint(generatedFile); + + // Act - 2 + // Update the source content and build. We should expect the outputs to be regenerated. + ReplaceContent(string.Empty, file); + result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + + // Assert - 2 + Assert.BuildPassed(result); + Assert.FileContentEquals(result, tagHelperOutputCache, "[]"); + var newThumbPrint = GetThumbPrint(generatedFile); + Assert.NotEqual(fileThumbPrint, newThumbPrint); + } + } } diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs index b69109869b..020887b57c 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs @@ -92,6 +92,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } File.WriteAllText(filePath, content, Encoding.UTF8); + // Timestamps on xplat are precise only to a second. Update it's last write time by at least 1 second + // so we can ensure that MSBuild recognizes the file change. See https://github.com/dotnet/corefx/issues/26024 + File.SetLastWriteTimeUtc(filePath, File.GetLastWriteTimeUtc(filePath).AddSeconds(1)); } /// diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs index bab76935dd..c5254cfe37 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs @@ -109,9 +109,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Act - 2 // Update the source content and build. We should expect the outputs to be regenerated. - // Timestamps on xplat are precise only to a second. Add a delay so we can ensure that MSBuild recognizes the - // file change. See https://github.com/dotnet/corefx/issues/26024 - await Task.Delay(TimeSpan.FromSeconds(1)); ReplaceContent("Uodated content", file); result = await DotnetMSBuild(RazorGenerateTarget); @@ -189,37 +186,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileDoesNotExist(result, generatedFile); } - [Fact(Skip = "https://github.com/aspnet/Razor/issues/2104")] - [InitializeTestProject("SimpleMvc")] - public async Task RazorGenerate_Rebuilds_IfTagHelpersChanged() - { - // Act - 1 - var expectedTagHelperCacheContent = @"""Name"":""SimpleMvc.SimpleTagHelper"""; - var result = await DotnetMSBuild(RazorGenerateTarget); - var file = Path.Combine(Project.DirectoryPath, "SimpleTagHelper.cs"); - var tagHelperOutputCache = Path.Combine(IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"); - var generatedFile = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cs"); - - // Assert - 1 - Assert.BuildPassed(result); - Assert.FileContains(result, tagHelperOutputCache, expectedTagHelperCacheContent); - var fileThumbPrint = GetThumbPrint(generatedFile); - - // Act - 2 - // Update the source content and build. We should expect the outputs to be regenerated. - // Timestamps on xplat are precise only to a second. Add a delay so we can ensure that MSBuild recognizes the - // file change. See https://github.com/dotnet/corefx/issues/26024 - await Task.Delay(TimeSpan.FromSeconds(1)); - ReplaceContent(string.Empty, file); - result = await DotnetMSBuild(RazorGenerateTarget); - - // Assert - 2 - Assert.BuildPassed(result); - Assert.FileDoesNotContain(result, tagHelperOutputCache, expectedTagHelperCacheContent); - var newThumbPrint = GetThumbPrint(generatedFile); - Assert.NotEqual(fileThumbPrint, newThumbPrint); - } - [Fact] [InitializeTestProject("SimpleMvc")] public async Task RazorGenerate_Noops_WithNoFiles() diff --git a/test/testapps/SimpleMvc/SimpleTagHelper.cs b/test/testapps/SimpleMvc/SimpleTagHelper.cs index a2abedef92..7cc52922d9 100644 --- a/test/testapps/SimpleMvc/SimpleTagHelper.cs +++ b/test/testapps/SimpleMvc/SimpleTagHelper.cs @@ -5,4 +5,4 @@ namespace SimpleMvc public class SimpleTagHelper : TagHelper { } -} \ No newline at end of file +} From 2958a145e3e7db3efe2cf158c189dd611885f9a8 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 27 Feb 2018 09:13:40 -0800 Subject: [PATCH 33/56] Revert "Revert "Update to the latest Sdk and cleanup projects"" This reverts commit fed0970b333c09707920f493d0e70857cbf738ee. --- korebuild-lock.txt | 4 ++-- .../AppWithP2PReference/AppWithP2PReference.csproj | 8 +------- test/testapps/ClassLibrary/ClassLibrary.csproj | 8 +------- test/testapps/Directory.Build.props | 5 +++-- test/testapps/SimpleMvc/SimpleMvc.csproj | 8 +------- test/testapps/SimplePages/SimplePages.csproj | 8 +------- 6 files changed, 9 insertions(+), 32 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 538f6228c3..2c1067648b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15707 -commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 +version:2.1.0-preview2-15723 +commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 diff --git a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj index 29fa0ee0be..b0ca8cfd76 100644 --- a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj +++ b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj @@ -1,11 +1,8 @@ - - - + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ - @@ -25,7 +22,4 @@ - - - diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj index 558cbea953..791350d163 100644 --- a/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -1,12 +1,9 @@ - - - + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ - @@ -26,7 +23,4 @@ - - - diff --git a/test/testapps/Directory.Build.props b/test/testapps/Directory.Build.props index 134f59524c..bb458103c9 100644 --- a/test/testapps/Directory.Build.props +++ b/test/testapps/Directory.Build.props @@ -5,8 +5,9 @@ $(MSBuildThisFileDirectory)..\..\ $([MSBuild]::EnsureTrailingSlash('$(SolutionRoot)')) - - <_RazorSdkPackageReferenced>true + + $(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.props + $(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets diff --git a/test/testapps/SimpleMvc/SimpleMvc.csproj b/test/testapps/SimpleMvc/SimpleMvc.csproj index 115efbaa0b..21ea1afc3c 100644 --- a/test/testapps/SimpleMvc/SimpleMvc.csproj +++ b/test/testapps/SimpleMvc/SimpleMvc.csproj @@ -1,12 +1,9 @@ - - - + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ - @@ -23,7 +20,4 @@ - - - diff --git a/test/testapps/SimplePages/SimplePages.csproj b/test/testapps/SimplePages/SimplePages.csproj index a8fba5b4b1..2928d33d45 100644 --- a/test/testapps/SimplePages/SimplePages.csproj +++ b/test/testapps/SimplePages/SimplePages.csproj @@ -1,12 +1,9 @@ - + - - <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ - @@ -22,8 +19,5 @@ - - - From f51ddf68a6cb88dace6f950b53df6571385cbbce Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 27 Feb 2018 10:30:45 -0800 Subject: [PATCH 34/56] Add RazorGenerate items to UpToDateCheckInput Fixes #2048 --- .../Sdk.Razor.CurrentVersion.targets | 2 ++ .../BuildIntrospectionTest.cs | 23 +++++++++++++++++++ test/testapps/RazorTest.Introspection.targets | 4 ++++ 3 files changed, 29 insertions(+) create mode 100644 test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 97fddceaae..54160b1aaf 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -158,6 +158,8 @@ Copyright (c) .NET Foundation. All rights reserved. <_RazorDebugSymbolsIntermediatePath Condition="'$(_RazorDebugSymbolsProduced)'=='true'" Include="$(IntermediateOutputPath)$(RazorTargetName).pdb" /> + + false - - true diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 6a45be1bf2..2aad333593 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -58,6 +58,11 @@ Copyright (c) .NET Foundation. All rights reserved. RazorCoreCompile + + _InitializePreserveCompilationContext; + $(PrepareForBuildDependsOn) + + + + + true + + + - RazorSDK + netstandard2.0 diff --git a/test/testapps/Directory.Build.props b/test/testapps/Directory.Build.props index bb458103c9..20497a3aa4 100644 --- a/test/testapps/Directory.Build.props +++ b/test/testapps/Directory.Build.props @@ -12,7 +12,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/test/testapps/RazorTest.Introspection.targets b/test/testapps/RazorTest.Introspection.targets index 300a3ace5f..c78b200437 100644 --- a/test/testapps/RazorTest.Introspection.targets +++ b/test/testapps/RazorTest.Introspection.targets @@ -7,10 +7,6 @@ - - - - From 3e0360a8915d457abd19534adb2fe8f6581f589e Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 28 Feb 2018 13:21:04 -0800 Subject: [PATCH 37/56] Fix #2041 - Add static constructor to DocumentWriter The instance Create method was always supposed to be static. (cherry picked from commit e05c2abd949d6a9acdfb82ae17594031582ca06f) --- .../CodeGeneration/DocumentWriter.cs | 18 ++++++++++++++++++ .../DefaultRazorCSharpLoweringPhase.cs | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DocumentWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DocumentWriter.cs index fcfa014da2..68f7ddffc0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DocumentWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DocumentWriter.cs @@ -2,12 +2,30 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.ComponentModel; using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public abstract class DocumentWriter { + public static DocumentWriter CreateDefault(CodeTarget codeTarget, RazorCodeGenerationOptions options) + { + if (codeTarget == null) + { + throw new ArgumentNullException(nameof(codeTarget)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return new DefaultDocumentWriter(codeTarget, options); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method was intended to be static, use CreateDefault instead.")] public DocumentWriter Create(CodeTarget codeTarget, RazorCodeGenerationOptions options) { if (codeTarget == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCSharpLoweringPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCSharpLoweringPhase.cs index 4f9ff9f151..f09c68069a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCSharpLoweringPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorCSharpLoweringPhase.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language throw new InvalidOperationException(message); } - var writer = new DefaultDocumentWriter(documentNode.Target, documentNode.Options); + var writer = DocumentWriter.CreateDefault(documentNode.Target, documentNode.Options); var cSharpDocument = writer.WriteDocument(codeDocument, documentNode); codeDocument.SetCSharpDocument(cSharpDocument); } From 00485d9f1b944f2aa16309c533a58bfeee353acf Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 28 Feb 2018 13:14:58 -0800 Subject: [PATCH 38/56] Fix #2099 - make AssemblyExtension public This is needed when a runtime wants to construct its own configuration manually, especially useful in tests. (cherry picked from commit 92c511b2b4da8f77389f318a302efa62833d382d) --- src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs index 83b70cd7aa..97f1c31c15 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/AssemblyExtension.cs @@ -6,7 +6,7 @@ using System.Reflection; namespace Microsoft.AspNetCore.Razor.Language { - internal class AssemblyExtension : RazorExtension + public class AssemblyExtension : RazorExtension { public AssemblyExtension(string extensionName, Assembly assembly) { @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Language public Assembly Assembly { get; } - public RazorExtensionInitializer CreateInitializer() + internal RazorExtensionInitializer CreateInitializer() { // It's not an error to have an assembly with no initializers. This is useful to specify a dependency // that doesn't really provide any Razor configuration. From a9dca60a10b304c672cfc9900b1f50d2e0cc6b54 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Tue, 20 Feb 2018 18:50:53 -0800 Subject: [PATCH 39/56] Added support for AssemblyMetadata caching during build server TagHelper discovery --- .../Application.cs | 6 +- .../CachingMetadataReference.cs | 32 +++ .../CompilerHost.cs | 8 +- .../ConcurrentLruCache.cs | 207 ++++++++++++++++++ .../DiscoverCommand.cs | 2 +- .../MetadataCache.cs | 86 ++++++++ .../Program.cs | 8 +- .../ServerCommand.cs | 1 + .../ServerProtocol/ServerRequest.cs | 2 +- .../BuildServerIntegrationTest.cs | 19 ++ .../BuildServerTestFixture.cs | 3 +- .../ConcurrentLruCacheTest.cs | 120 ++++++++++ .../Infrastructure/ServerUtilities.cs | 3 +- .../MetadataCacheTest.cs | 103 +++++++++ .../ServerLifecycleTest.cs | 9 +- 15 files changed, 599 insertions(+), 10 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/CachingMetadataReference.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/ConcurrentLruCache.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Tools/MetadataCache.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Tools.Test/ConcurrentLruCacheTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Tools.Test/MetadataCacheTest.cs diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Application.cs b/src/Microsoft.AspNetCore.Razor.Tools/Application.cs index 06da6a9ec4..c9f569747a 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Application.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Application.cs @@ -6,17 +6,19 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using System.Threading; +using Microsoft.CodeAnalysis; using Microsoft.Extensions.CommandLineUtils; namespace Microsoft.AspNetCore.Razor.Tools { internal class Application : CommandLineApplication { - public Application(CancellationToken cancellationToken, ExtensionAssemblyLoader loader, ExtensionDependencyChecker checker) + public Application(CancellationToken cancellationToken, ExtensionAssemblyLoader loader, ExtensionDependencyChecker checker, Func assemblyReferenceProvider) { CancellationToken = cancellationToken; Checker = checker; Loader = loader; + AssemblyReferenceProvider = assemblyReferenceProvider; Name = "rzc"; FullName = "Microsoft ASP.NET Core Razor CLI tool"; @@ -37,6 +39,8 @@ namespace Microsoft.AspNetCore.Razor.Tools public ExtensionDependencyChecker Checker { get; } + public Func AssemblyReferenceProvider { get; } + public new int Execute(params string[] args) { try diff --git a/src/Microsoft.AspNetCore.Razor.Tools/CachingMetadataReference.cs b/src/Microsoft.AspNetCore.Razor.Tools/CachingMetadataReference.cs new file mode 100644 index 0000000000..0aeb381b21 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/CachingMetadataReference.cs @@ -0,0 +1,32 @@ +// 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 Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal sealed class CachingMetadataReference : PortableExecutableReference + { + private static readonly MetadataCache _metadataCache = new MetadataCache(); + + public CachingMetadataReference(string fullPath, MetadataReferenceProperties properties) + : base(properties, fullPath) + { + } + + protected override DocumentationProvider CreateDocumentationProvider() + { + return DocumentationProvider.Default; + } + + protected override Metadata GetMetadataImpl() + { + return _metadataCache.GetMetadata(FilePath); + } + + protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties) + { + return new CachingMetadataReference(FilePath, properties); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs b/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs index 553e9f5a87..a57b9e83a0 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs @@ -1,10 +1,12 @@ // 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; +using Microsoft.CodeAnalysis; namespace Microsoft.AspNetCore.Razor.Tools { @@ -30,8 +32,12 @@ namespace Microsoft.AspNetCore.Razor.Tools // consistently reject a request that doesn't specify everything it needs. Otherwise the request // could succeed sometimes if it relies on transient state. Loader = new DefaultExtensionAssemblyLoader(Path.Combine(Path.GetTempPath(), "Razor-Server")); + + AssemblyReferenceProvider = (path, properties) => new CachingMetadataReference(path, properties); } + public Func AssemblyReferenceProvider { get; } + public ExtensionAssemblyLoader Loader { get; } public override ServerResponse Execute(ServerRequest request, CancellationToken cancellationToken) @@ -48,7 +54,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var writer = ServerLogger.IsLoggingEnabled ? new StringWriter() : TextWriter.Null; var checker = new DefaultExtensionDependencyChecker(Loader, writer); - var app = new Application(cancellationToken, Loader, checker) + var app = new Application(cancellationToken, Loader, checker, AssemblyReferenceProvider) { Out = writer, Error = writer, diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ConcurrentLruCache.cs b/src/Microsoft.AspNetCore.Razor.Tools/ConcurrentLruCache.cs new file mode 100644 index 0000000000..0220615ec2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/ConcurrentLruCache.cs @@ -0,0 +1,207 @@ +// 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.Diagnostics; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + /// + /// Cache with a fixed size that evicts the least recently used members. + /// Thread-safe. + /// This was taken from https://github.com/dotnet/roslyn/blob/749c0ec135d7d080658dc1aa794d15229c3d10d2/src/Compilers/Core/Portable/InternalUtilities/ConcurrentLruCache.cs. + /// + internal class ConcurrentLruCache + { + private readonly int _capacity; + + private readonly Dictionary _cache; + private readonly LinkedList _nodeList; + // This is a naive course-grained lock, it can probably be optimized + private readonly object _lockObject = new object(); + + public ConcurrentLruCache(int capacity) + : this (capacity, EqualityComparer.Default) + { + } + + public ConcurrentLruCache(int capacity, IEqualityComparer comparer) + { + if (capacity <= 0) + { + throw new ArgumentOutOfRangeException(nameof(capacity)); + } + _capacity = capacity; + _cache = new Dictionary(capacity, comparer); + _nodeList = new LinkedList(); + } + + /// + /// Create cache from an array. The cache capacity will be the size + /// of the array. All elements of the array will be added to the + /// cache. If any duplicate keys are found in the array a + /// will be thrown. + /// + public ConcurrentLruCache(KeyValuePair[] array) + : this(array.Length) + { + foreach (var kvp in array) + { + UnsafeAdd(kvp.Key, kvp.Value); + } + } + + public int Count + { + get + { + lock (_lockObject) + { + return _cache.Count; + } + } + } + + public void Add(TKey key, TValue value) + { + lock (_lockObject) + { + UnsafeAdd(key, value); + } + } + + public TValue GetOrAdd(TKey key, TValue value) + { + lock (_lockObject) + { + if (UnsafeTryGetValue(key, out var result)) + { + return result; + } + else + { + UnsafeAdd(key, value); + return value; + } + } + } + + public bool TryGetValue(TKey key, out TValue value) + { + lock (_lockObject) + { + return UnsafeTryGetValue(key, out value); + } + } + + public bool Remove(TKey key) + { + lock (_lockObject) + { + return UnsafeRemove(key); + } + } + + /// + /// For testing. Very expensive. + /// + internal IEnumerable> TestingEnumerable + { + get + { + lock (_lockObject) + { + foreach (var key in _nodeList) + { + var kvp = new KeyValuePair(key, _cache[key].Value); + yield return kvp; + } + } + } + } + + /// + /// Doesn't lock. + /// + private bool UnsafeTryGetValue(TKey key, out TValue value) + { + if (_cache.TryGetValue(key, out var result)) + { + MoveNodeToTop(result.Node); + value = result.Value; + return true; + } + else + { + value = default(TValue); + return false; + } + } + + private void MoveNodeToTop(LinkedListNode node) + { + if (!object.ReferenceEquals(_nodeList.First, node)) + { + _nodeList.Remove(node); + _nodeList.AddFirst(node); + } + } + + /// + /// Expects non-empty cache. Does not lock. + /// + private void UnsafeEvictLastNode() + { + Debug.Assert(_capacity > 0); + var lastNode = _nodeList.Last; + _nodeList.Remove(lastNode); + _cache.Remove(lastNode.Value); + } + + private void UnsafeAddNodeToTop(TKey key, TValue value) + { + var node = new LinkedListNode(key); + _cache.Add(key, new CacheValue(value, node)); + _nodeList.AddFirst(node); + } + + /// + /// Doesn't lock. + /// + private void UnsafeAdd(TKey key, TValue value) + { + if (_cache.TryGetValue(key, out var result)) + { + throw new ArgumentException("Key already exists", nameof(key)); + } + else + { + if (_cache.Count == _capacity) + { + UnsafeEvictLastNode(); + } + UnsafeAddNodeToTop(key, value); + } + } + + private bool UnsafeRemove(TKey key) + { + _nodeList.Remove(key); + return _cache.Remove(key); + } + + private struct CacheValue + { + public CacheValue(TValue value, LinkedListNode node) + { + Value = value; + Node = node; + } + + public TValue Value { get; } + + public LinkedListNode Node { get; } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs index 2fedb87022..c846ef3692 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/DiscoverCommand.cs @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var metadataReferences = new MetadataReference[assemblies.Length]; for (var i = 0; i < assemblies.Length; i++) { - metadataReferences[i] = MetadataReference.CreateFromFile(assemblies[i]); + metadataReferences[i] = Parent.AssemblyReferenceProvider(assemblies[i], default(MetadataReferenceProperties)); } var engine = RazorProjectEngine.Create(configuration, RazorProjectFileSystem.Empty, b => diff --git a/src/Microsoft.AspNetCore.Razor.Tools/MetadataCache.cs b/src/Microsoft.AspNetCore.Razor.Tools/MetadataCache.cs new file mode 100644 index 0000000000..b0f9fd025e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/MetadataCache.cs @@ -0,0 +1,86 @@ +// 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.IO; +using System.Reflection.PortableExecutable; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class MetadataCache + { + // Store 1000 entries -- arbitrary number + private const int CacheSize = 1000; + private readonly ConcurrentLruCache _metadataCache = + new ConcurrentLruCache(CacheSize, StringComparer.OrdinalIgnoreCase); + + // For testing purposes only. + internal ConcurrentLruCache Cache => _metadataCache; + + internal Metadata GetMetadata(string fullPath) + { + var timestamp = GetFileTimeStamp(fullPath); + + // Check if we have an entry in the dictionary. + if (_metadataCache.TryGetValue(fullPath, out var entry)) + { + if (timestamp.HasValue && timestamp.Value == entry.Timestamp) + { + // The file has not changed since we cached it. Return the cached entry. + return entry.Metadata; + } + else + { + // The file has changed recently. Remove the cache entry. + _metadataCache.Remove(fullPath); + } + } + + Metadata metadata; + using (var fileStream = File.OpenRead(fullPath)) + { + metadata = AssemblyMetadata.CreateFromStream(fileStream, PEStreamOptions.PrefetchMetadata); + } + + _metadataCache.GetOrAdd(fullPath, new MetadataCacheEntry(timestamp.Value, metadata)); + + return metadata; + } + + private static DateTime? GetFileTimeStamp(string fullPath) + { + try + { + Debug.Assert(Path.IsPathRooted(fullPath)); + + return File.GetLastWriteTimeUtc(fullPath); + } + catch (Exception e) + { + // There are several exceptions that can occur here: NotSupportedException or PathTooLongException + // for a bad path, UnauthorizedAccessException for access denied, etc. Rather than listing them all, + // just catch all exceptions and log. + ServerLogger.LogException(e, $"Error getting timestamp of file {fullPath}."); + + return null; + } + } + + internal struct MetadataCacheEntry + { + public MetadataCacheEntry(DateTime timestamp, Metadata metadata) + { + Debug.Assert(timestamp.Kind == DateTimeKind.Utc); + + Timestamp = timestamp; + Metadata = metadata; + } + + public DateTime Timestamp { get; } + + public Metadata Metadata { get; } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs index 0b3b980c3a..386a8837c5 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs @@ -3,6 +3,7 @@ using System; using System.Threading; +using Microsoft.CodeAnalysis; namespace Microsoft.AspNetCore.Razor.Tools { @@ -19,7 +20,12 @@ namespace Microsoft.AspNetCore.Razor.Tools var loader = new DefaultExtensionAssemblyLoader(baseDirectory: null); var checker = new DefaultExtensionDependencyChecker(loader, Console.Error); - var application = new Application(cancel.Token, loader, checker); + var application = new Application( + cancel.Token, + loader, + checker, + (path, properties) => MetadataReference.CreateFromFile(path, properties)); + return application.Execute(args); } } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ServerCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/ServerCommand.cs index f44487ab25..65a70b51ed 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/ServerCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/ServerCommand.cs @@ -57,6 +57,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } var host = ConnectionHost.Create(Pipe.Value()); + var compilerHost = CompilerHost.Create(); ExecuteServerCore(host, compilerHost, Cancelled, eventBus: null, keepAlive: keepAlive); } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerRequest.cs b/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerRequest.cs index e1dd9308b0..34b6a39eb9 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerRequest.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerRequest.cs @@ -170,7 +170,7 @@ namespace Microsoft.AspNetCore.Razor.Tools /// /// Write a Request to the stream. /// - public async Task WriteAsync(Stream outStream, CancellationToken cancellationToken = default) + public async Task WriteAsync(Stream outStream, CancellationToken cancellationToken = default(CancellationToken)) { using (var memoryStream = new MemoryStream()) using (var writer = new BinaryWriter(memoryStream, Encoding.Unicode)) diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs index 570deb91aa..4c54a0cb11 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.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.IO; using System.Threading.Tasks; +using Microsoft.AspNetCore.Testing.xunit; using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests @@ -20,6 +22,12 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public Task Build_SimpleMvc_WithServer_UsingDotnetMSBuild_CanBuildSuccessfully() => Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind.Dotnet); + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [InitializeTestProject("SimpleMvc")] + public Task Build_SimpleMvc_WithServer_UsingDesktopMSBuild_CanBuildSuccessfully() + => Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind.Desktop); + private async Task Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind msBuildProcessKind) { var result = await DotnetMSBuild( @@ -32,6 +40,17 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, OutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, OutputPath, "SimpleMvc.Views.dll"); Assert.FileExists(result, OutputPath, "SimpleMvc.Views.pdb"); + + // Verify RazorTagHelper works + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.TagHelpers.input.cache"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"); + Assert.FileContains( + result, + Path.Combine(IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"), + @"""Name"":""SimpleMvc.SimpleTagHelper"""); + + // Verify RazorGenerate works + Assert.FileCountEquals(result, 8, RazorIntermediateOutputPath, "*.cs"); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs index d2d0aa98e5..a628f5224a 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs @@ -5,6 +5,7 @@ using System; using System.IO; using System.Threading; using Microsoft.AspNetCore.Razor.Tools; +using Microsoft.CodeAnalysis; using Moq; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests @@ -35,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected."); }); - var application = new Application(cts.Token, Mock.Of(), Mock.Of()); + var application = new Application(cts.Token, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of()); var exitCode = application.Execute("shutdown", "-w", "-p", PipeName); if (exitCode != 0) { diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ConcurrentLruCacheTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ConcurrentLruCacheTest.cs new file mode 100644 index 0000000000..77ad2f0cf4 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ConcurrentLruCacheTest.cs @@ -0,0 +1,120 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class ConcurrentLruCacheTest + { + [Fact] + public void ConcurrentLruCache_HoldsCapacity() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = input.Reverse(); + + // Act + var cache = new ConcurrentLruCache(input); + + // Assert + Assert.Equal(expected, cache.TestingEnumerable); + } + + [Fact] + public void Add_ThrowsIfKeyExists() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var cache = new ConcurrentLruCache(input); + + // Act & Assert + var exception = Assert.Throws(() => cache.Add(1, 1)); + Assert.StartsWith("Key already exists", exception.Message); + } + + [Fact] + public void GetOrAdd_AddsIfKeyDoesNotExist() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = GetKeyValueArray(Enumerable.Range(2, 3)).Reverse(); + var cache = new ConcurrentLruCache(input); + + // Act + cache.GetOrAdd(4, 4); + + // Assert + Assert.Equal(expected, cache.TestingEnumerable); + } + + [Fact] + public void Remove_RemovesEntry() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = GetKeyValueArray(Enumerable.Range(1, 2)).Reverse(); + var cache = new ConcurrentLruCache(input); + + // Act + var result = cache.Remove(3); + + // Assert + Assert.True(result); + Assert.Equal(expected, cache.TestingEnumerable); + } + + [Fact] + public void Remove_KeyNotFound_ReturnsFalse() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var cache = new ConcurrentLruCache(input); + + // Act + var result = cache.Remove(4); + + // Assert + Assert.False(result); + } + + [Fact] + public void Add_NoRead_EvictsLastNode() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = GetKeyValueArray(Enumerable.Range(2, 3)).Reverse(); + var cache = new ConcurrentLruCache(input); + + // Act + cache.Add(4, 4); + + // Assert + Assert.Equal(expected, cache.TestingEnumerable); + } + + [Fact] + public void Add_ReadLastNode_EvictsSecondOldestNode() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = GetKeyValueArray(new int[] { 4, 1, 3 }); + var cache = new ConcurrentLruCache(input); + + // Act + cache.GetOrAdd(1, 1); // Read to make this MRU + cache.Add(4, 4); // Add a new node + + // Assert + Assert.Equal(expected, cache.TestingEnumerable); + } + + private KeyValuePair[] GetKeyValueArray(IEnumerable inputArray) + { + return inputArray.Select(v => new KeyValuePair(v, v)).ToArray(); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs index b91723c9d0..e8b30514f9 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis; using Moq; namespace Microsoft.AspNetCore.Razor.Tools @@ -117,7 +118,7 @@ namespace Microsoft.AspNetCore.Razor.Tools CancellationToken ct, EventBus eventBus, TimeSpan? keepAlive) - : base(new Application(ct, Mock.Of(), Mock.Of())) + : base(new Application(ct, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of())) { _host = host; _compilerHost = compilerHost; diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/MetadataCacheTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/MetadataCacheTest.cs new file mode 100644 index 0000000000..fd4e54197c --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/MetadataCacheTest.cs @@ -0,0 +1,103 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class MetadataCacheTest + { + [Fact] + public void GetMetadata_AddsToCache() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var metadataCache = new MetadataCache(); + var assemblyFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + // Act + var result = metadataCache.GetMetadata(assemblyFilePath); + + // Assert + Assert.NotNull(result); + Assert.Equal(1, metadataCache.Cache.Count); + } + } + + [Fact] + public void GetMetadata_UsesCache() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var metadataCache = new MetadataCache(); + var assemblyFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + // Act 1 + var result = metadataCache.GetMetadata(assemblyFilePath); + + // Assert 1 + Assert.NotNull(result); + Assert.Equal(1, metadataCache.Cache.Count); + + // Act 2 + var cacheResult = metadataCache.GetMetadata(assemblyFilePath); + + // Assert 2 + Assert.Same(result, cacheResult); + Assert.Equal(1, metadataCache.Cache.Count); + } + } + + [Fact] + public void GetMetadata_MultipleFiles_ReturnsDifferentResultsAndAddsToCache() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var metadataCache = new MetadataCache(); + var assemblyFilePath1 = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + var assemblyFilePath2 = LoaderTestResources.Gamma.WriteToFile(directory.DirectoryPath, "Gamma.dll"); + + // Act + var result1 = metadataCache.GetMetadata(assemblyFilePath1); + var result2 = metadataCache.GetMetadata(assemblyFilePath2); + + // Assert + Assert.NotSame(result1, result2); + Assert.Equal(2, metadataCache.Cache.Count); + } + } + + [Fact] + public void GetMetadata_ReplacesCache_IfFileTimestampChanged() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var metadataCache = new MetadataCache(); + var assemblyFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + // Act 1 + var result = metadataCache.GetMetadata(assemblyFilePath); + + // Assert 1 + Assert.NotNull(result); + var entry = Assert.Single(metadataCache.Cache.TestingEnumerable); + Assert.Same(result, entry.Value.Metadata); + + // Act 2 + // Update the timestamp of the file + File.SetLastWriteTimeUtc(assemblyFilePath, File.GetLastWriteTimeUtc(assemblyFilePath).AddSeconds(1)); + var cacheResult = metadataCache.GetMetadata(assemblyFilePath); + + // Assert 2 + Assert.NotSame(result, cacheResult); + entry = Assert.Single(metadataCache.Cache.TestingEnumerable); + Assert.Same(cacheResult, entry.Value.Metadata); + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs index 27dd7e619f..7cb6b64ae0 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs @@ -116,7 +116,8 @@ namespace Microsoft.AspNetCore.Razor.Tools /// A shutdown request should not abort an existing compilation. It should be allowed to run to /// completion. /// - [Fact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + [ConditionalFact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_ShutdownRequest_DoesNotAbortCompilation() { // Arrange @@ -152,7 +153,8 @@ namespace Microsoft.AspNetCore.Razor.Tools /// /// Multiple clients should be able to send shutdown requests to the server. /// - [Fact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + [ConditionalFact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_MultipleShutdownRequests_HandlesSuccessfully() { // Arrange @@ -189,7 +191,8 @@ namespace Microsoft.AspNetCore.Razor.Tools } } - [Fact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + [ConditionalFact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_CancelCompilation_CancelsSuccessfully() { // Arrange From 0f1bc0e0bde2a16951ef1687a38e2379d823f385 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 1 Mar 2018 11:24:30 -0800 Subject: [PATCH 40/56] Fix flaky dispatcher test --- .../DefaultRequestDispatcher.cs | 2 ++ .../EventBus.cs | 7 +++++ .../DefaultRequestDispatcherTest.cs | 24 +++++++++++++-- .../Infrastructure/TestableEventBus.cs | 29 +++++++++++++------ .../ServerLifecycleTest.cs | 9 ++++-- 5 files changed, 57 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Tools/DefaultRequestDispatcher.cs b/src/Microsoft.AspNetCore.Razor.Tools/DefaultRequestDispatcher.cs index 26747a06b6..59d2bbc098 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/DefaultRequestDispatcher.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/DefaultRequestDispatcher.cs @@ -383,6 +383,8 @@ namespace Microsoft.AspNetCore.Razor.Tools ServerLogger.Log("End writing response."); reason = ConnectionResult.Reason.CompilationCompleted; + + _eventBus.CompilationCompleted(); } catch { diff --git a/src/Microsoft.AspNetCore.Razor.Tools/EventBus.cs b/src/Microsoft.AspNetCore.Razor.Tools/EventBus.cs index 958a637deb..dacd5c07e7 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/EventBus.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/EventBus.cs @@ -37,6 +37,13 @@ namespace Microsoft.AspNetCore.Razor.Tools public virtual void ConnectionCompleted(int count) { } + + /// + /// Called when a compilation is completed successfully and the response is written to the stream. + /// + public virtual void CompilationCompleted() + { + } /// /// Called when a bad client connection was detected and the server will be shutting down as a diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultRequestDispatcherTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultRequestDispatcherTest.cs index 4e4f702fed..495649bd3e 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultRequestDispatcherTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultRequestDispatcherTest.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Moq; @@ -335,7 +336,7 @@ namespace Microsoft.AspNetCore.Razor.Tools /// /// Ensure server respects keep alive and shuts down after processing simultaneous connections. /// - [Fact(Skip = "https://github.com/aspnet/Razor/issues/2018")] + [Fact] public async Task Dispatcher_ProcessSimultaneousConnections_HitsKeepAliveTimeout() { // Arrange @@ -352,6 +353,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var source = new TaskCompletionSource(); var connectionTask = CreateConnectionWithEmptyServerRequest(c => { + // Keep the connection active until we decide to end it. c.WaitForDisconnectAsyncFunc = _ => source.Task; }); list.Add(source); @@ -370,24 +372,42 @@ namespace Microsoft.AspNetCore.Razor.Tools }; }); - var keepAlive = TimeSpan.FromSeconds(1); var eventBus = new TestableEventBus(); + var completedCompilations = 0; + var allCompilationsComplete = new TaskCompletionSource(); + eventBus.CompilationComplete += (obj, args) => + { + if (++completedCompilations == totalCount) + { + // All compilations have completed. + allCompilationsComplete.SetResult(true); + } + }; + var keepAlive = TimeSpan.FromSeconds(1); var dispatcherTask = Task.Run(() => { var dispatcher = new DefaultRequestDispatcher(connectionHost.Object, compilerHost, CancellationToken.None, eventBus, keepAlive); dispatcher.Run(); }); + // Wait for all connections to be created. await readySource.Task; + + // Wait for all compilations to complete. + await allCompilationsComplete.Task; + + // Now allow all the connections to be disconnected. foreach (var source in list) { source.SetResult(true); } // Act + // Now dispatcher should be in an idle state with no active connections. await dispatcherTask; // Assert + Assert.False(eventBus.HasDetectedBadConnection); Assert.Equal(totalCount, eventBus.CompletedCount); Assert.True(eventBus.LastProcessedTime.HasValue, "LastProcessedTime should have had a value."); Assert.True(eventBus.HitKeepAliveTimeout, "HitKeepAliveTimeout should have been hit."); diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/TestableEventBus.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/TestableEventBus.cs index 4bc2465476..6430ce05df 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/TestableEventBus.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/TestableEventBus.cs @@ -2,21 +2,27 @@ // 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.Text; namespace Microsoft.AspNetCore.Razor.Tools { internal class TestableEventBus : EventBus { - public int ListeningCount; - public int ConnectionCount; - public int CompletedCount; - public DateTime? LastProcessedTime; - public TimeSpan? KeepAlive; - public bool HasDetectedBadConnection; - public bool HitKeepAliveTimeout; public event EventHandler Listening; + public event EventHandler CompilationComplete; + + public int ListeningCount { get; private set; } + + public int ConnectionCount { get; private set; } + + public int CompletedCount { get; private set; } + + public DateTime? LastProcessedTime { get; private set; } + + public TimeSpan? KeepAlive { get; private set; } + + public bool HasDetectedBadConnection { get; private set; } + + public bool HitKeepAliveTimeout { get; private set; } public override void ConnectionListening() { @@ -35,6 +41,11 @@ namespace Microsoft.AspNetCore.Razor.Tools LastProcessedTime = DateTime.Now; } + public override void CompilationCompleted() + { + CompilationComplete?.Invoke(this, EventArgs.Empty); + } + public override void UpdateKeepAlive(TimeSpan timeSpan) { KeepAlive = timeSpan; diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs index 7cb6b64ae0..3f415fe509 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs @@ -116,7 +116,8 @@ namespace Microsoft.AspNetCore.Razor.Tools /// A shutdown request should not abort an existing compilation. It should be allowed to run to /// completion. /// - [ConditionalFact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 + [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_ShutdownRequest_DoesNotAbortCompilation() { @@ -153,7 +154,8 @@ namespace Microsoft.AspNetCore.Razor.Tools /// /// Multiple clients should be able to send shutdown requests to the server. /// - [ConditionalFact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 + [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_MultipleShutdownRequests_HandlesSuccessfully() { @@ -191,7 +193,8 @@ namespace Microsoft.AspNetCore.Razor.Tools } } - [ConditionalFact(Skip = "Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991")] + // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 + [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_CancelCompilation_CancelsSuccessfully() { From 5bd650bdd158b1ed3a381ec83aa8d04c5340c761 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 27 Feb 2018 15:23:58 -0800 Subject: [PATCH 41/56] Pack should pack symbol nupkg * Update path calculation for BuiltProjectOutputGroupOutput to include full path. This matches the behavior of Microsoft.Common.targets. * Add Razor symbols to DebugSymbolsProjectOutputGroupOutput Fixes #2116 --- .../Sdk.Razor.CurrentVersion.targets | 47 ++++++++++++++----- .../IntegrationTests/Assert.cs | 17 ++++--- .../IntegrationTests/PackIntegrationTest.cs | 37 ++++++++++++++- 3 files changed, 80 insertions(+), 21 deletions(-) diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 2aad333593..6dbdf8f49a 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -58,6 +58,16 @@ Copyright (c) .NET Foundation. All rights reserved. RazorCoreCompile + + $(BuiltProjectOutputGroupDependsOn); + _RazorAddBuiltProjectOutputGroupOutput + + + + $(DebugSymbolsProjectOutputGroupDependsOn); + _RazorAddDebugSymbolsProjectOutputGroupOutput + + _InitializePreserveCompilationContext; $(PrepareForBuildDependsOn) @@ -337,16 +347,22 @@ Copyright (c) .NET Foundation. All rights reserved. --> - - $([MSBuild]::EnsureTrailingSlash('$(OutDir)')) - - - + + + + + + + + + @@ -414,18 +430,14 @@ Copyright (c) .NET Foundation. All rights reserved. --> - - $([MSBuild]::EnsureTrailingSlash('$(OutDir)')) - - + + + $([MSBuild]::EnsureTrailingSlash('$(OutDir)')) + $([MSBuild]::Escape($([MSBuild]::EnsureTrailingSlash($([System.IO.Path]::GetFullPath('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(RazorOutputPath)'))')))))) + + $(RazorTargetDir)$(RazorTargetName).dll + + + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\Razor\Microsoft.NET.Sdk.Razor.DesignTime.targets $(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Razor.DesignTime.targets diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs index b41e7e4bcc..55791a7284 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs @@ -313,7 +313,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } } - public static void NupkgContains(MSBuildResult result, string nupkgPath, string filePath) + // This method extracts the nupkg to a fixed directory path. To avoid the extra work of + // cleaning up after each invocation, this method accepts multiple files. + public static void NupkgContains(MSBuildResult result, string nupkgPath, params string[] filePaths) { if (result == null) { @@ -325,20 +327,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests throw new ArgumentNullException(nameof(nupkgPath)); } - if (filePath == null) + if (filePaths == null) { - throw new ArgumentNullException(nameof(filePath)); + throw new ArgumentNullException(nameof(filePaths)); } nupkgPath = Path.Combine(result.Project.DirectoryPath, nupkgPath); FileExists(result, nupkgPath); - var unzipped = Path.Combine(result.Project.DirectoryPath, "nupkg"); + var unzipped = Path.Combine(result.Project.DirectoryPath, Path.GetFileNameWithoutExtension(nupkgPath)); ZipFile.ExtractToDirectory(nupkgPath, unzipped); - if (!File.Exists(Path.Combine(unzipped, filePath))) + foreach (var filePath in filePaths) { - throw new NupkgFileMissingException(result, nupkgPath, filePath); + if (!File.Exists(Path.Combine(unzipped, filePath))) + { + throw new NupkgFileMissingException(result, nupkgPath, filePath); + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs index c040a2ca9b..c6ae4da25a 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs @@ -24,9 +24,15 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.NuspecContains( result, Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), - $""); + Assert.NuspecDoesNotContain( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + $""); + Assert.NuspecDoesNotContain( result, Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), @@ -38,6 +44,33 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll")); } + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Pack_WithIncludeSymbols_IncludesRazorPdb() + { + var result = await DotnetMSBuild("Pack", "/p:RazorCompileOnBuild=true /p:IncludeSymbols=true"); + + Assert.BuildPassed(result); + + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.symbols.nuspec"), + $""); + + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.symbols.nuspec"), + $""); + + Assert.NupkgContains( + result, + Path.Combine("bin", Configuration, "ClassLibrary.1.0.0.symbols.nupkg"), + Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.dll"), + Path.Combine("lib", "netstandard2.0", "ClassLibrary.Views.pdb")); + } + [Fact] [InitializeTestProject("ClassLibrary")] public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet() @@ -53,7 +86,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.NuspecContains( result, Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), - $""); Assert.NuspecContains( From 29bd5f49dd12d170187f8a17f88bd4e2abd648ba Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 2 Mar 2018 09:38:40 -0800 Subject: [PATCH 42/56] Fix build break --- .../IntegrationTests/PackIntegrationTest.cs | 71 +++++++++++-------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs index c6ae4da25a..983e7ea629 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.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.IO; +using System.Runtime.InteropServices; using System.Threading.Tasks; using Xunit; @@ -21,17 +22,21 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); - Assert.NuspecContains( - result, - Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), - $""); + if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Travis on OSX produces different full paths in C# and MSBuild + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + $""); - Assert.NuspecDoesNotContain( - result, - Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), - $""); + Assert.NuspecDoesNotContain( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + $""); + } Assert.NuspecDoesNotContain( result, @@ -52,17 +57,21 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildPassed(result); - Assert.NuspecContains( - result, - Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.symbols.nuspec"), - $""); + if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Travis on OSX produces different full paths in C# and MSBuild + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.symbols.nuspec"), + $""); - Assert.NuspecContains( - result, - Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.symbols.nuspec"), - $""); + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.symbols.nuspec"), + $""); + } Assert.NupkgContains( result, @@ -83,16 +92,20 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); - Assert.NuspecContains( - result, - Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), - $""); + if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Travis on OSX produces different full paths in C# and MSBuild + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + $""); - Assert.NuspecContains( - result, - Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), - @""); + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + @""); + } Assert.NupkgContains( result, From c444f65c5d23639028f748e0fd5211ab41478699 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 2 Mar 2018 10:47:13 -0800 Subject: [PATCH 43/56] Import capabilities to support solution explorer nesting Fixes #2047 --- .../Microsoft.NET.Sdk.Razor.DesignTime.targets | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets index ba35bd98c4..0b012be77c 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets @@ -23,6 +23,16 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + + + + File From 69a32c68e28e6e5b28dcb49611b003c99c24a3e2 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 4 Mar 2018 12:26:25 -0800 Subject: [PATCH 44/56] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 22 +++++++++++----------- korebuild-lock.txt | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a21fbae048..a415df57e5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,22 +4,22 @@ 0.10.11 - 2.1.0-preview2-15723 - 2.1.0-preview2-30192 - 2.1.0-preview2-30192 - 2.1.0-preview2-30192 + 2.1.0-preview2-15726 + 2.1.0-preview2-30230 + 2.1.0-preview2-30230 + 2.1.0-preview2-30230 15.7.0-preview-000011-1378327 15.7.0-preview-000011-1378327 15.7.0-preview-000011-1378327 2.6.1 2.6.1 - 2.1.0-preview2-30192 - 2.1.0-preview2-30192 + 2.1.0-preview2-30230 + 2.1.0-preview2-30230 2.1.0-preview2-25711-01 - 2.1.0-preview2-30192 - 2.1.0-preview2-30192 + 2.1.0-preview2-30230 + 2.1.0-preview2-30230 2.0.0 - 2.1.0-preview2-26130-04 + 2.1.0-preview2-26225-03 15.6.0 15.0.26606 15.6.161-preview @@ -42,8 +42,8 @@ 2.0.1 10.0.1 1.1.92 - 4.5.0-preview2-26130-01 - 4.5.0-preview2-26130-01 + 4.5.0-preview2-26224-02 + 4.5.0-preview2-26224-02 9.0.1 2.7.0-beta3-62512-06 2.7.0-beta3-62512-06 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2c1067648b..ad1d7d3c02 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15723 -commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 +version:2.1.0-preview2-15726 +commithash:599e691c41f502ed9e062b1822ce13b673fc916e From 41c923926e6e36434a5343791f2db9dfa1379e43 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Feb 2018 15:50:25 -0800 Subject: [PATCH 45/56] Make RazorCompileOnBuild=true Fixes #1986 --- .../Sdk.Razor.CurrentVersion.targets | 2 +- .../BuildIncrementalismTest.cs | 8 +-- .../IntegrationTests/BuildIntegrationTest.cs | 26 ++++----- .../BuildIntrospectionTest.cs | 2 +- .../BuildServerIntegrationTest.cs | 6 +- .../ConfigurationMetadataIntegrationTest.cs | 6 +- .../DesignTimeBuildIntegrationTest.cs | 2 +- .../IntegrationTests/PackIntegrationTest.cs | 4 +- .../PublishIntegrationTest.cs | 58 ++++++++++--------- 9 files changed, 58 insertions(+), 56 deletions(-) diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 6dbdf8f49a..fbad5a3ff9 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -79,7 +79,7 @@ Copyright (c) .NET Foundation. All rights reserved. Default values for properties that affect Razor targets to the standard build lifecycle. --> - false + true diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs index 75cc832f72..d4639b8c69 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests var thumbprintLookup = new Dictionary(); // Act 1 - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); var directoryPath = Path.Combine(result.Project.DirectoryPath, IntermediateOutputPath); var filesToIgnore = new[] @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // We want to make sure nothing changed between multiple incremental builds. using (var razorGenDirectoryLock = LockDirectory(RazorIntermediateOutputPath)) { - result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + result = await DotnetMSBuild("Build"); } Assert.BuildPassed(result); @@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { // Act - 1 var expectedTagHelperCacheContent = @"""Name"":""SimpleMvc.SimpleTagHelper"""; - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); var file = Path.Combine(Project.DirectoryPath, "SimpleTagHelper.cs"); var tagHelperOutputCache = Path.Combine(IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"); var generatedFile = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cs"); @@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Act - 2 // Update the source content and build. We should expect the outputs to be regenerated. ReplaceContent(string.Empty, file); - result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + result = await DotnetMSBuild("Build"); // Assert - 2 Assert.BuildPassed(result); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs index ecfa3c0f77..c2399f91f7 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests private async Task Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind msBuildProcessKind) { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true", msBuildProcessKind: msBuildProcessKind); + var result = await DotnetMSBuild("Build", msBuildProcessKind: msBuildProcessKind); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true); - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -61,9 +61,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [Fact] [InitializeTestProject("SimpleMvc")] - public async Task Build_SimpleMvc_NoopsWithRazorCompileOnPublish() + public async Task Build_SimpleMvc_NoopsWithRazorCompileOnBuild_False() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnPublish=true"); + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Introducing a C# semantic error ReplaceContent("@{ var foo = \"\".Substring(\"bleh\"); }", "Views", "Home", "Index.cshtml"); - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildFailed(result); @@ -95,7 +95,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimplePages")] public async Task Build_Works_WhenFilesAtDifferentPathsHaveSameNamespaceHierarchy() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); @@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public async Task Build_RazorOutputPath_SetToNonDefault() { var customOutputPath = Path.Combine("bin", Configuration, TargetFramework, "Razor"); - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true /p:RazorOutputPath={customOutputPath}"); + var result = await DotnetMSBuild("Build", $"/p:RazorOutputPath={customOutputPath}"); Assert.BuildPassed(result); @@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public async Task Build_MvcRazorOutputPath_SetToNonDefault() { var customOutputPath = Path.Combine("bin", Configuration, TargetFramework, "Razor"); - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true /p:MvcRazorOutputPath={customOutputPath}"); + var result = await DotnetMSBuild("Build", $"/p:MvcRazorOutputPath={customOutputPath}"); Assert.BuildPassed(result); @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_SkipsCopyingBinariesToOutputDirectory_IfCopyBuildOutputToOutputDirectory_IsUnset() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:CopyBuildOutputToOutputDirectory=false"); + var result = await DotnetMSBuild("Build", "/p:CopyBuildOutputToOutputDirectory=false"); Assert.BuildPassed(result); @@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_SkipsCopyingBinariesToOutputDirectory_IfCopyOutputSymbolsToOutputDirectory_IsUnset() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:CopyOutputSymbolsToOutputDirectory=false"); + var result = await DotnetMSBuild("Build", "/p:CopyOutputSymbolsToOutputDirectory=false"); Assert.BuildPassed(result); @@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_Works_WhenSymbolsAreNotGenerated() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:DebugType=none"); + var result = await DotnetMSBuild("Build", "/p:DebugType=none"); Assert.BuildPassed(result); @@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] public async Task Build_WithP2P_CopiesRazorAssembly() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); @@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests AddProjectFileContent(additionalProjectContent); Directory.CreateDirectory(Path.Combine(Project.DirectoryPath, "..", "LinkedDir")); - var result = await DotnetMSBuild("Build", "/t:_IntrospectRazorEmbeddedResources /p:RazorCompileOnBuild=true /p:EmbedRazorGenerateSources=true"); + var result = await DotnetMSBuild("Build", "/t:_IntrospectRazorEmbeddedResources /p:EmbedRazorGenerateSources=true"); Assert.BuildPassed(result); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs index 59e95d6805..ef0143eef7 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task RazorSdk_AddsCshtmlFilesToUpToDateCheckInput() { - var result = await DotnetMSBuild("_IntrospectUpToDateCheckInput", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("_IntrospectUpToDateCheckInput"); Assert.BuildPassed(result); Assert.BuildOutputContainsLine(result, $"UpToDateCheckInput: {Path.Combine("Views", "Home", "Index.cshtml")}"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs index 4c54a0cb11..57645715a3 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:RazorCompileOnBuild=true /p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true", + $"/p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true", msBuildProcessKind: msBuildProcessKind); Assert.BuildPassed(result); @@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:RazorCompileOnBuild=true /p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true"); + $"/p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:RazorCompileOnBuild=true /p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true"); + $"/p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "Whitespace in name.dll"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs index cbfafc5041..d406665da3 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_WithMvc_AddsConfigurationMetadata() { - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_WithGenerateRazorAssemblyInfo_False_SuppressesConfigurationMetadata() { - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true /p:GenerateRazorAssemblyInfo=false"); + var result = await DotnetMSBuild("Build", "/p:GenerateRazorAssemblyInfo=false"); Assert.BuildPassed(result); @@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { TargetFramework = "netstandard2.0"; - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs index ab55289280..a98712d2e0 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { // Using Compile here instead of CompileDesignTime because the latter is only defined when using // the VS targets. This is a close enough simulation for an SDK project - var result = await DotnetMSBuild("Compile", "/p:RazorCompileOnBuild=true /p:DesignTimeBuild=true /clp:PerformanceSummary"); + var result = await DotnetMSBuild("Compile", "/p:DesignTimeBuild=true /clp:PerformanceSummary"); Assert.BuildPassed(result); Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.dll"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs index 983e7ea629..d550a1b62b 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public async Task Pack_Works_IncludesRazorAssembly() { TargetFramework = "netstandard2.0"; - var result = await DotnetMSBuild("Pack", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Pack"); Assert.BuildPassed(result); @@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet() { TargetFramework = "netstandard2.0"; - var result = await DotnetMSBuild("Pack", "/p:RazorCompileOnBuild=true /p:IncludeRazorContentInPack=true"); + var result = await DotnetMSBuild("Pack", "/p:IncludeRazorContentInPack=true"); Assert.BuildPassed(result); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs index cab91e9f09..e299c31dec 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs @@ -17,9 +17,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); @@ -32,9 +29,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [Fact] [InitializeTestProject("SimpleMvc")] - public async Task Publish_WithRazorCompileOnBuild_PublishesAssembly() + public async Task Publish_PublishesAssembly() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Publish"); Assert.BuildPassed(result); @@ -57,7 +54,26 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_WithRazorCompileOnPublish_PublishesAssembly() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnPublish=true"); + var result = await DotnetMSBuild("Publish"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.pdb"); + + // By default refs and .cshtml files will not be copied on publish + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "refs"), "*.dll"); + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "Views"), "*.cshtml"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Publish_WithRazorCompileOnBuildFalse_PublishesAssembly() + { + // RazorCompileOnBuild is turned off, but RazorCompileOnPublish should still be enabled + var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=false"); Assert.BuildPassed(result); @@ -96,9 +112,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); @@ -115,7 +128,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true); - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Publish"); Assert.BuildPassed(result); @@ -162,7 +175,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_SkipsCopyingBinariesToOutputDirectory_IfCopyBuildOutputToOutputDirectory_IsUnset() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true /p:CopyBuildOutputToPublishDirectory=false"); + var result = await DotnetMSBuild("Publish", "/p:CopyBuildOutputToPublishDirectory=false"); Assert.BuildPassed(result); @@ -177,7 +190,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_SkipsCopyingBinariesToOutputDirectory_IfCopyOutputSymbolsToOutputDirectory_IsUnset() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true /p:CopyOutputSymbolsToPublishDirectory=false"); + var result = await DotnetMSBuild("Publish", "/p:CopyOutputSymbolsToPublishDirectory=false"); Assert.BuildPassed(result); @@ -191,7 +204,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_Works_WhenSymbolsAreNotGenerated() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true /p:DebugType=none"); + var result = await DotnetMSBuild("Publish", "/p:DebugType=none"); Assert.BuildPassed(result); @@ -207,13 +220,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_IncludeCshtmlAndRefAssemblies_CopiesFiles() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnPublish=true /p:CopyRazorGenerateFilesToPublishDirectory=true /p:CopyRefAssembliesToPublishDirectory=true"); + var result = await DotnetMSBuild("Publish", "/p:CopyRazorGenerateFilesToPublishDirectory=true /p:CopyRefAssembliesToPublishDirectory=true"); Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); @@ -228,13 +238,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_MvcRazorExcludeFilesFromPublish_False_CopiesFiles() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnPublish=true /p:MvcRazorExcludeViewFilesFromPublish=false /p:MvcRazorExcludeRefAssembliesFromPublish=false"); + var result = await DotnetMSBuild("Publish", "/p:MvcRazorExcludeViewFilesFromPublish=false /p:MvcRazorExcludeRefAssembliesFromPublish=false"); Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); @@ -249,7 +256,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] public async Task Publish_WithP2P_AndRazorCompileOnBuild_CopiesRazorAssembly() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Publish"); Assert.BuildPassed(result); @@ -267,15 +274,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] public async Task Publish_WithP2P_AndRazorCompileOnPublish_CopiesRazorAssembly() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnPublish=true"); + var result = await DotnetMSBuild("Publish"); Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.Views.pdb"); - Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "AppWithP2PReference.dll"); Assert.FileExists(result, PublishOutputPath, "AppWithP2PReference.pdb"); Assert.FileExists(result, PublishOutputPath, "AppWithP2PReference.Views.dll"); From 7e18efbf1fdfdf5c30672cb396218ebea9b406b3 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 1 Mar 2018 16:24:29 -0800 Subject: [PATCH 46/56] Fixed flaky shutdown tests --- .../Infrastructure/ServerUtilities.cs | 7 +- .../ServerLifecycleTest.cs | 65 ++++++++++++------- 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs index e8b30514f9..d6494d1d37 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs @@ -26,7 +26,8 @@ namespace Microsoft.AspNetCore.Razor.Tools internal static ServerData CreateServer( string pipeName = null, CompilerHost compilerHost = null, - ConnectionHost connectionHost = null) + ConnectionHost connectionHost = null, + Action onListening = null) { pipeName = pipeName ?? Guid.NewGuid().ToString(); compilerHost = compilerHost ?? CompilerHost.Create(); @@ -40,6 +41,10 @@ namespace Microsoft.AspNetCore.Razor.Tools { var eventBus = new TestableEventBus(); eventBus.Listening += (sender, e) => { serverListenSource.TrySetResult(true); }; + if (onListening != null) + { + eventBus.Listening += (sender, e) => onListening(sender, e); + } try { RunServer( diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs index 3f415fe509..9f8f059b87 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs @@ -116,17 +116,19 @@ namespace Microsoft.AspNetCore.Razor.Tools /// A shutdown request should not abort an existing compilation. It should be allowed to run to /// completion. /// - // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [Fact] public async Task ServerRunning_ShutdownRequest_DoesNotAbortCompilation() { // Arrange - var completionSource = new TaskCompletionSource(); + var startCompilationSource = new TaskCompletionSource(); + var finishCompilationSource = new TaskCompletionSource(); var host = CreateCompilerHost(c => c.ExecuteFunc = (req, ct) => { + // At this point, the connection has been accepted and the compilation has started. + startCompilationSource.SetResult(true); + // We want this to keep running even after the shutdown is seen. - completionSource.Task.Wait(); + finishCompilationSource.Task.Wait(); return EmptyServerResponse; }); @@ -134,13 +136,16 @@ namespace Microsoft.AspNetCore.Razor.Tools { var compileTask = ServerUtilities.Send(serverData.PipeName, EmptyServerRequest); + // Wait for the request to go through and trigger compilation. + await startCompilationSource.Task; + // Act // The compilation is now in progress, send the shutdown. await ServerUtilities.SendShutdown(serverData.PipeName); Assert.False(compileTask.IsCompleted); // Now let the task complete. - completionSource.SetResult(true); + finishCompilationSource.SetResult(true); // Assert var response = await compileTask; @@ -154,17 +159,19 @@ namespace Microsoft.AspNetCore.Razor.Tools /// /// Multiple clients should be able to send shutdown requests to the server. /// - // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [Fact] public async Task ServerRunning_MultipleShutdownRequests_HandlesSuccessfully() { // Arrange - var completionSource = new TaskCompletionSource(); + var startCompilationSource = new TaskCompletionSource(); + var finishCompilationSource = new TaskCompletionSource(); var host = CreateCompilerHost(c => c.ExecuteFunc = (req, ct) => { + // At this point, the connection has been accepted and the compilation has started. + startCompilationSource.SetResult(true); + // We want this to keep running even after the shutdown is seen. - completionSource.Task.Wait(); + finishCompilationSource.Task.Wait(); return EmptyServerResponse; }); @@ -172,6 +179,9 @@ namespace Microsoft.AspNetCore.Razor.Tools { var compileTask = ServerUtilities.Send(serverData.PipeName, EmptyServerRequest); + // Wait for the request to go through and trigger compilation. + await startCompilationSource.Task; + // Act for (var i = 0; i < 10; i++) { @@ -182,7 +192,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } // Now let the task complete. - completionSource.SetResult(true); + finishCompilationSource.SetResult(true); // Assert var response = await compileTask; @@ -193,9 +203,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } } - // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [Fact] public async Task ServerRunning_CancelCompilation_CancelsSuccessfully() { // Arrange @@ -213,18 +221,28 @@ namespace Microsoft.AspNetCore.Razor.Tools return new RejectedServerResponse(); }); - using (var serverData = ServerUtilities.CreateServer(compilerHost: host)) + var semaphore = new SemaphoreSlim(1); + Action onListening = (s, e) => { - var tasks = new List>(); + semaphore.Release(); + }; + using (var serverData = ServerUtilities.CreateServer(compilerHost: host, onListening: onListening)) + { + // Send all the requests. + var clients = new List(); for (var i = 0; i < requestCount; i++) { - var task = ServerUtilities.Send(serverData.PipeName, EmptyServerRequest); - tasks.Add(task); + // Wait for the server to start listening. + await semaphore.WaitAsync(TimeSpan.FromMinutes(1)); + + var client = await Client.ConnectAsync(serverData.PipeName, timeout: null, cancellationToken: default); + await EmptyServerRequest.WriteAsync(client.Stream); + clients.Add(client); } // Act // Wait until all of the connections are being processed by the server. - completionSource.Task.Wait(); + await completionSource.Task; // Now cancel var stats = await serverData.CancelAndCompleteAsync(); @@ -233,10 +251,13 @@ namespace Microsoft.AspNetCore.Razor.Tools Assert.Equal(requestCount, stats.Connections); Assert.Equal(requestCount, count); - foreach (var task in tasks) + // Read the server response to each client. + foreach (var client in clients) { + var task = ServerResponse.ReadAsync(client.Stream); // We expect this to throw because the stream is already closed. - await Assert.ThrowsAsync(() => task); + await Assert.ThrowsAnyAsync(() => task); + client.Dispose(); } } } From 27e6c699e521fefd3eca523405c5efc586d53050 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Mon, 5 Mar 2018 15:22:37 -0800 Subject: [PATCH 47/56] Don't print normal output as error --- .../CompilerHost.cs | 2 +- .../DefaultExtensionDependencyChecker.cs | 13 ++++++++----- src/Microsoft.AspNetCore.Razor.Tools/Program.cs | 2 +- .../DefaultExtensionDependencyCheckerTest.cs | 8 ++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs b/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs index a57b9e83a0..ce1b0791f2 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var writer = ServerLogger.IsLoggingEnabled ? new StringWriter() : TextWriter.Null; - var checker = new DefaultExtensionDependencyChecker(Loader, writer); + var checker = new DefaultExtensionDependencyChecker(Loader, writer, writer); var app = new Application(cancellationToken, Loader, checker, AssemblyReferenceProvider) { Out = writer, diff --git a/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs b/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs index f5ce49abac..79d01afb9d 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs @@ -26,15 +26,18 @@ namespace Microsoft.AspNetCore.Razor.Tools private readonly ExtensionAssemblyLoader _loader; private readonly TextWriter _output; + private readonly TextWriter _error; private readonly string[] _ignoredAssemblies; public DefaultExtensionDependencyChecker( ExtensionAssemblyLoader loader, TextWriter output, + TextWriter error, string[] ignoredAssemblies = null) { _loader = loader; _output = output; + _error = error; _ignoredAssemblies = ignoredAssemblies ?? DefaultIgnoredAssemblies; } @@ -46,8 +49,8 @@ namespace Microsoft.AspNetCore.Razor.Tools } catch (Exception ex) { - _output.WriteLine("Exception performing Extension dependency check:"); - _output.WriteLine(ex.ToString()); + _error.WriteLine("Exception performing Extension dependency check:"); + _error.WriteLine(ex.ToString()); return false; } } @@ -64,7 +67,7 @@ namespace Microsoft.AspNetCore.Razor.Tools if (!Path.IsPathRooted(item.FilePath)) { - _output.WriteLine($"The file path '{item.FilePath}' is not a rooted path. File paths must be absolute and fully-qualified."); + _error.WriteLine($"The file path '{item.FilePath}' is not a rooted path. File paths must be absolute and fully-qualified."); return false; } @@ -83,7 +86,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } // If we get here we can't resolve this assembly. This is an error. - _output.WriteLine($"Extension assembly '{item.Identity.Name}' depends on '{reference.ToString()} which is missing."); + _error.WriteLine($"Extension assembly '{item.Identity.Name}' depends on '{reference.ToString()} which is missing."); return false; } } @@ -110,7 +113,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var item = items[i]; if (item.Mvid != item.Assembly.ManifestModule.ModuleVersionId) { - _output.WriteLine($"Extension assembly '{item.Identity.Name}' at '{item.FilePath}' has a different ModuleVersionId than loaded assembly '{item.Assembly.FullName}'"); + _error.WriteLine($"Extension assembly '{item.Identity.Name}' at '{item.FilePath}' has a different ModuleVersionId than loaded assembly '{item.Assembly.FullName}'"); return false; } } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs index 386a8837c5..27807cd23e 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Razor.Tools // Prevent shadow copying. var loader = new DefaultExtensionAssemblyLoader(baseDirectory: null); - var checker = new DefaultExtensionDependencyChecker(loader, Console.Error); + var checker = new DefaultExtensionDependencyChecker(loader, Console.Out, Console.Error); var application = new Application( cancel.Token, diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs index 72d719fdc8..b9b9c8ac11 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); - var checker = new DefaultExtensionDependencyChecker(loader, output); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); // Act var result = checker.Check(new[] { alphaFilePath, }); @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); - var checker = new DefaultExtensionDependencyChecker(loader, output); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); // Act var result = checker.Check(new[] { alphaFilePath, betaFilePath, gammaFilePath, deltaFilePath, }); @@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); - var checker = new DefaultExtensionDependencyChecker(loader, output); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); // This will cause the loader to cache some inconsistent information. loader.LoadFromPath(alphaFilePath); @@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Razor.Tools loader .Setup(l => l.LoadFromPath(It.IsAny())) .Throws(new InvalidOperationException()); - var checker = new DefaultExtensionDependencyChecker(loader.Object, output); + var checker = new DefaultExtensionDependencyChecker(loader.Object, output, output); // Act var result = checker.Check(new[] { deltaFilePath, }); From 0d321771ad58dbca0887f522d86682f34fe74e21 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 5 Mar 2018 14:10:55 -0800 Subject: [PATCH 48/56] Make UseRazorBuildServer=true by default --- .../Sdk.Razor.CurrentVersion.props | 4 ++-- .../BuildIncrementalismTest.cs | 7 +++++- .../IntegrationTests/BuildIntegrationTest.cs | 23 +++++++++++++------ .../BuildIntrospectionTest.cs | 7 +++++- .../BuildServerIntegrationTest.cs | 12 ++++------ .../ConfigurationMetadataIntegrationTest.cs | 7 +++++- .../DesignTimeBuildIntegrationTest.cs | 7 +++++- .../MSBuildIntegrationTestBase.cs | 23 ++++++++++++++++--- .../IntegrationTests/PackIntegrationTest.cs | 7 +++++- .../PublishIntegrationTest.cs | 7 +++++- .../RazorCompileIntegrationTest.cs | 7 +++++- .../RazorGenerateIntegrationTest.cs | 7 +++++- 12 files changed, 91 insertions(+), 27 deletions(-) diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props index 8df8703baa..c9778644e2 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props @@ -59,9 +59,9 @@ Copyright (c) .NET Foundation. All rights reserved. false - false + true diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs index d4639b8c69..53192cf8cf 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs @@ -10,8 +10,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class BuildIncrementalismTest : MSBuildIntegrationTestBase + public class BuildIncrementalismTest : MSBuildIntegrationTestBase, IClassFixture { + public BuildIncrementalismTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task BuildIncremental_SimpleMvc_PersistsTargetInputFile() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs index c2399f91f7..b5a6f75bc8 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs @@ -12,23 +12,32 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class BuildIntegrationTest : MSBuildIntegrationTestBase + public class BuildIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public BuildIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] - public Task Build_SimpleMvc_UsingDotnetMSBuild_CanBuildSuccessfully() - => Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind.Dotnet); + public Task Build_SimpleMvc_UsingDotnetMSBuildAndWithoutBuildServer_CanBuildSuccessfully() + => Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind.Dotnet); [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.MacOSX)] [InitializeTestProject("SimpleMvc")] - public Task Build_SimpleMvc_UsingDesktopMSBuild_CanBuildSuccessfully() - => Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind.Desktop); + public Task Build_SimpleMvc_UsingDesktopMSBuildAndWithoutBuildServer_CanBuildSuccessfully() + => Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind.Desktop); - private async Task Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind msBuildProcessKind) + // This test is identical to the ones in BuildServerIntegrationTest except this one explicitly disables the Razor build server. + private async Task Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind msBuildProcessKind) { - var result = await DotnetMSBuild("Build", msBuildProcessKind: msBuildProcessKind); + var result = await DotnetMSBuild("Build", + "/p:UseRazorBuildServer=false", + suppressBuildServer: true, + msBuildProcessKind: msBuildProcessKind); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs index ef0143eef7..0e6875ee22 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs @@ -7,8 +7,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class BuildIntrospectionTest : MSBuildIntegrationTestBase + public class BuildIntrospectionTest : MSBuildIntegrationTestBase, IClassFixture { + public BuildIntrospectionTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task RazorSdk_AddsCshtmlFilesToUpToDateCheckInput() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs index 57645715a3..7ffbbc27e9 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs @@ -10,11 +10,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { public class BuildServerIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { - private readonly string _pipeName; - - public BuildServerIntegrationTest(BuildServerTestFixture fixture) + public BuildServerIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) { - _pipeName = fixture.PipeName; } [Fact] @@ -32,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true", + "/p:_RazorForceBuildServer=true", msBuildProcessKind: msBuildProcessKind); Assert.BuildPassed(result); @@ -59,7 +57,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true"); + "/p:_RazorForceBuildServer=true"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -74,7 +72,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true"); + "/p:_RazorForceBuildServer=true"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "Whitespace in name.dll"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs index d406665da3..b4f81e102e 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs @@ -7,8 +7,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class ConfigurationMetadataIntegrationTest : MSBuildIntegrationTestBase + public class ConfigurationMetadataIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public ConfigurationMetadataIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task Build_WithMvc_AddsConfigurationMetadata() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs index a98712d2e0..9fd41950e7 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs @@ -6,8 +6,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class DesignTimeBuildIntegrationTest : MSBuildIntegrationTestBase + public class DesignTimeBuildIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public DesignTimeBuildIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task DesignTimeBuild_DoesNotRunRazorTargets() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs index 020887b57c..5247f1aca9 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs @@ -15,8 +15,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { private static readonly AsyncLocal _project = new AsyncLocal(); - protected MSBuildIntegrationTestBase() + protected MSBuildIntegrationTestBase(BuildServerTestFixture buildServer) { + BuildServer = buildServer; } #if DEBUG @@ -44,19 +45,35 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests protected string TargetFramework { get; set; } = "netcoreapp2.0"; + protected BuildServerTestFixture BuildServer { get; set; } + internal Task DotnetMSBuild( string target, string args = null, bool suppressRestore = false, bool suppressTimeout = false, + bool suppressBuildServer = false, MSBuildProcessKind msBuildProcessKind = MSBuildProcessKind.Dotnet) { var timeout = suppressTimeout ? (TimeSpan?)Timeout.InfiniteTimeSpan : null; - var restoreArgument = suppressRestore ? "" : "/restore"; + var buildArgumentList = new List(); + + if (!suppressRestore) + { + buildArgumentList.Add("/restore"); + } + + if (!suppressBuildServer) + { + buildArgumentList.Add($"/p:_RazorBuildServerPipeName={BuildServer.PipeName}"); + } + + buildArgumentList.Add($"/t:{target} /p:Configuration={Configuration} {args}"); + var buildArguments = string.Join(" ", buildArgumentList); return MSBuildProcessManager.RunProcessAsync( Project, - $"{restoreArgument} /t:{target} /p:Configuration={Configuration} {args}", + buildArguments, timeout, msBuildProcessKind); } diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs index d550a1b62b..d217a3b02d 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs @@ -8,8 +8,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class PackIntegrationTest : MSBuildIntegrationTestBase + public class PackIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public PackIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("ClassLibrary")] public async Task Pack_Works_IncludesRazorAssembly() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs index e299c31dec..22407311fa 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs @@ -7,8 +7,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class PublishIntegrationTest : MSBuildIntegrationTestBase + public class PublishIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public PublishIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task Publish_RazorCompileOnPublish_IsDefault() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs index 88f325c7f9..c375b99354 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs @@ -9,8 +9,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class RazorCompileIntegrationTest : MSBuildIntegrationTestBase + public class RazorCompileIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public RazorCompileIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task RazorCompile_Success_CompilesAssembly() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs index c5254cfe37..0834a37974 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs @@ -10,10 +10,15 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class RazorGenerateIntegrationTest : MSBuildIntegrationTestBase + public class RazorGenerateIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { private const string RazorGenerateTarget = "RazorGenerate"; + public RazorGenerateIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task RazorGenerate_Success_GeneratesFilesOnDisk() From c4ba279fb52c4b94daaaacc0abf4dd081dc38b6c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 5 Mar 2018 15:24:33 -0800 Subject: [PATCH 49/56] Skipping flaky test and additional additional diagnositcs to Shutdown command --- .../ShutdownCommand.cs | 8 +++++--- .../IntegrationTests/BuildServerTestFixture.cs | 13 ++++++++++--- .../ServerLifecycleTest.cs | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs index f77b30f5b2..3e0907774b 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs @@ -57,19 +57,21 @@ namespace Microsoft.AspNetCore.Razor.Tools var process = Process.GetProcessById(response.ServerProcessId); process.WaitForExit(); } - catch (Exception) + catch (Exception ex) { // There is an inherent race here with the server process. If it has already shutdown - // by the time we try to access it then the operation has succeed. + // by the time we try to access it then the operation has succeeded. + Error.Write(ex); } Out.Write("Server pid:{0} shut down", response.ServerProcessId); } } } - catch (Exception) when (IsServerRunning()) + catch (Exception ex) when (IsServerRunning()) { // Ignore an exception that occurred while the server was shutting down. + Error.Write(ex); } return 0; diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs index a628f5224a..7f3933c0da 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs @@ -31,16 +31,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Shutdown the build server. using (var cts = new CancellationTokenSource(_defaultShutdownTimeout)) { + var writer = new StringWriter(); + cts.Token.Register(() => { - throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected."); + var output = writer.ToString(); + throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected.{Environment.NewLine}Output: {output}."); }); - var application = new Application(cts.Token, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of()); + var application = new Application(cts.Token, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of()) + { + Out = writer, + Error = writer, + }; var exitCode = application.Execute("shutdown", "-w", "-p", PipeName); if (exitCode != 0) { - var output = application.Error.ToString(); + var output = writer.ToString(); throw new InvalidOperationException( $"Build server at pipe {PipeName} failed to shutdown with exit code {exitCode}. Output: {output}"); } diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs index 9f8f059b87..b99de60bd2 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs @@ -203,7 +203,8 @@ namespace Microsoft.AspNetCore.Razor.Tools } } - [Fact] + [ConditionalFact(Skip = "https://github.com/aspnet/Razor/issues/1991")] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_CancelCompilation_CancelsSuccessfully() { // Arrange From 0dc95887eec63811428aac9aa2c373666152a546 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 6 Mar 2018 09:46:30 -0800 Subject: [PATCH 50/56] Set MSBuild dependency version to 15.6.82 This is the latest stable release of MSBuild package versions --- build/dependencies.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a415df57e5..d2659358ff 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,9 +8,9 @@ 2.1.0-preview2-30230 2.1.0-preview2-30230 2.1.0-preview2-30230 - 15.7.0-preview-000011-1378327 - 15.7.0-preview-000011-1378327 - 15.7.0-preview-000011-1378327 + 15.6.82 + 15.6.82 + 15.6.82 2.6.1 2.6.1 2.1.0-preview2-30230 From 53b3ebb68092c058a7475cdd6a2a7373046bfc79 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:05:37 -0800 Subject: [PATCH 51/56] Use dotnet-core feed in repos --- build/sources.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/sources.props b/build/sources.props index b97c0c5cfb..02efac4549 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,10 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); + https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; https://dotnet.myget.org/F/msbuild/api/v3/index.json; From 5502e905656078b1464e4c84025c7716885946e2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:05:37 -0800 Subject: [PATCH 52/56] Prepend FeatureBranchVersionPrefix if FeatureBranchVersionSuffix is specified --- version.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.props b/version.props index 68a44892f6..5965a8e4d2 100644 --- a/version.props +++ b/version.props @@ -5,7 +5,8 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 - $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) + a- + $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) 99999 From 16a0b69b5b17a5ca691d660775be473c7664fda4 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 6 Mar 2018 10:37:42 -0800 Subject: [PATCH 53/56] Remove AppVeyor file until reliability improves --- .appveyor.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index fd85abb361..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -init: -- git config --global core.autocrlf true -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -build_script: -- ps: .\run.ps1 default-build -clone_depth: 1 -environment: - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: 'off' -deploy: 'off' -os: Visual Studio 2017 Preview From 6bc5c976deb1036c2201c30fcb2ab2914f0e9fb1 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 6 Mar 2018 10:58:22 -0800 Subject: [PATCH 54/56] Remove AppVeyor status tag. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e584eaef12..e99bc694b5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ Razor ===== -AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/olbc8ur2jna0v27j/branch/dev?svg=true)](https://ci.appveyor.com/project/aspnetci/razor/branch/dev) - Travis: [![Travis](https://travis-ci.org/aspnet/Razor.svg?branch=dev)](https://travis-ci.org/aspnet/Razor) The Razor syntax provides a fast, terse, clean and lightweight way to combine server code with HTML to create dynamic web content. This repo contains the parser and the C# code generator for the Razor syntax. From c96d8e4bab3d03d6aef5ac5d8533ee8db3ced5a4 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Tue, 6 Mar 2018 17:47:43 -0800 Subject: [PATCH 55/56] Skip test correctly --- .../ServerLifecycleTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs index b99de60bd2..f91fbc5fdd 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs @@ -203,7 +203,8 @@ namespace Microsoft.AspNetCore.Razor.Tools } } - [ConditionalFact(Skip = "https://github.com/aspnet/Razor/issues/1991")] + // https://github.com/aspnet/Razor/issues/1991 + [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_CancelCompilation_CancelsSuccessfully() { From e085441ad3e9233b096e0e485b33cf1a07a390ef Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 7 Mar 2018 10:43:25 -0800 Subject: [PATCH 56/56] Don't limit parallel threads for xunit tests --- test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json b/test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json index fcf172c8fc..d00e4ae907 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json @@ -1,4 +1,5 @@ { "methodDisplay": "method", - "shadowCopy": false + "shadowCopy": false, + "maxParallelThreads": -1 } \ No newline at end of file