From 616ec1445977fc66f2828831b67a55d5e8f5071c Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sun, 2 Dec 2018 12:36:44 -0800 Subject: [PATCH] Remove Razor Runtime projects \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/39472ca0d6ea8f25712c4888d5b2bbc5afd24bb2 --- ...vc.Razor.Extensions.Version1_X.Test.csproj | 18 +- ...vc.Razor.Extensions.Version2_X.Test.csproj | 19 +- .../test/ViewComponentTypeVisitorTest.cs | 3 +- ...spNetCore.Mvc.Razor.Extensions.Test.csproj | 17 +- .../test/ViewComponentTypeVisitorTest.cs | 3 +- .../Microsoft.CodeAnalysis.Razor.Test.csproj | 5 +- ...NetCore.Razor.Test.MvcShim.ClassLib.csproj | 5 +- .../TagHelperExecutionContext.cs | 70 ++++++ .../TagHelperRunner.cs | 18 ++ .../TagHelperScopeManager.cs | 34 +++ .../HtmlAttributeNameAttribute.cs | 92 +++++++ .../HtmlAttributeNotBoundAttribute.cs | 21 ++ .../HtmlAttributeValueStyle.cs | 13 + .../HtmlTargetElementAttribute.cs | 86 +++++++ .../ITagHelper.cs | 16 ++ .../OutputElementHintAttribute.cs | 35 +++ .../ReadOnlyTagHelperAttributeList.cs | 190 +++++++++++++++ .../RestrictChildrenAttribute.cs | 42 ++++ .../TagHelper.cs | 26 ++ .../TagHelperAttribute.cs | 43 ++++ .../TagHelperAttributeList.cs | 230 ++++++++++++++++++ .../TagHelperContent.cs | 179 ++++++++++++++ .../TagHelperContext.cs | 118 +++++++++ .../TagHelperOutput.cs | 79 ++++++ .../TagMode.cs | 26 ++ .../TagStructure.cs | 28 +++ ...tCore.Razor.Test.MvcShim.Version1_X.csproj | 5 +- .../DefaultRazorCompiledItem.cs | 54 ++++ .../IRazorSourceChecksumMetadata.cs | 26 ++ .../RazorCompiledItem.cs | 40 +++ .../RazorCompiledItemAttribute.cs | 60 +++++ .../RazorCompiledItemExtensions.cs | 30 +++ .../RazorCompiledItemMetadataAttribute.cs | 35 +++ .../RazorConfigurationNameAttribute.cs | 38 +++ .../RazorExtensionAssemblyNameAttribute.cs | 50 ++++ .../RazorLanguageVersionAttribute.cs | 38 +++ .../RazorSourceChecksumAttribute.cs | 67 +++++ .../TagHelperExecutionContext.cs | 70 ++++++ .../TagHelperRunner.cs | 18 ++ .../TagHelperScopeManager.cs | 34 +++ .../HtmlAttributeNameAttribute.cs | 92 +++++++ .../HtmlAttributeNotBoundAttribute.cs | 21 ++ .../HtmlAttributeValueStyle.cs | 13 + .../HtmlTargetElementAttribute.cs | 86 +++++++ .../ITagHelper.cs | 13 + .../ITagHelperComponent.cs | 41 ++++ .../OutputElementHintAttribute.cs | 35 +++ .../ReadOnlyTagHelperAttributeList.cs | 190 +++++++++++++++ .../RestrictChildrenAttribute.cs | 42 ++++ .../TagHelper.cs | 26 ++ .../TagHelperAttribute.cs | 43 ++++ .../TagHelperAttributeList.cs | 230 ++++++++++++++++++ .../TagHelperComponent.cs | 39 +++ .../TagHelperContent.cs | 179 ++++++++++++++ .../TagHelperContext.cs | 118 +++++++++ .../TagHelperOutput.cs | 79 ++++++ .../TagMode.cs | 26 ++ .../TagStructure.cs | 28 +++ ...tCore.Razor.Test.MvcShim.Version2_X.csproj | 5 +- .../DefaultRazorCompiledItem.cs | 54 ++++ .../IRazorSourceChecksumMetadata.cs | 26 ++ .../RazorCompiledItem.cs | 40 +++ .../RazorCompiledItemAttribute.cs | 60 +++++ .../RazorCompiledItemExtensions.cs | 30 +++ .../RazorCompiledItemMetadataAttribute.cs | 35 +++ .../RazorConfigurationNameAttribute.cs | 38 +++ .../RazorExtensionAssemblyNameAttribute.cs | 50 ++++ .../RazorLanguageVersionAttribute.cs | 38 +++ .../RazorSourceChecksumAttribute.cs | 67 +++++ .../TagHelperExecutionContext.cs | 70 ++++++ .../TagHelperRunner.cs | 18 ++ .../TagHelperScopeManager.cs | 34 +++ .../HtmlAttributeNameAttribute.cs | 92 +++++++ .../HtmlAttributeNotBoundAttribute.cs | 21 ++ .../HtmlAttributeValueStyle.cs | 13 + .../HtmlTargetElementAttribute.cs | 86 +++++++ .../ITagHelper.cs | 13 + .../ITagHelperComponent.cs | 41 ++++ .../OutputElementHintAttribute.cs | 35 +++ .../ReadOnlyTagHelperAttributeList.cs | 190 +++++++++++++++ .../RestrictChildrenAttribute.cs | 42 ++++ .../TagHelper.cs | 26 ++ .../TagHelperAttribute.cs | 43 ++++ .../TagHelperAttributeList.cs | 230 ++++++++++++++++++ .../TagHelperComponent.cs | 39 +++ .../TagHelperContent.cs | 179 ++++++++++++++ .../TagHelperContext.cs | 118 +++++++++ .../TagHelperOutput.cs | 79 ++++++ .../TagMode.cs | 26 ++ .../TagStructure.cs | 28 +++ ...osoft.AspNetCore.Razor.Test.MvcShim.csproj | 5 +- .../AppWithP2PReference.csproj | 3 - .../ClassLibrary/ClassLibrary.csproj | 3 - .../ClassLibrary2/ClassLibrary2.csproj | 3 - .../LargeProject/LargeProject.csproj | 3 - .../MvcWithComponents.csproj | 3 - .../testassets/SimpleMvc/SimpleMvc.csproj | 3 - .../SimpleMvcFSharp/SimpleMvcFSharp.fsproj | 3 - .../testassets/SimplePages/SimplePages.csproj | 3 - 99 files changed, 5087 insertions(+), 90 deletions(-) create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/DefaultRazorCompiledItem.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/IRazorSourceChecksumMetadata.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItem.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemExtensions.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemMetadataAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorConfigurationNameAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorExtensionAssemblyNameAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorLanguageVersionAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorSourceChecksumAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelperComponent.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperComponent.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/DefaultRazorCompiledItem.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/IRazorSourceChecksumMetadata.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItem.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemExtensions.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemMetadataAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorConfigurationNameAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorExtensionAssemblyNameAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorLanguageVersionAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorSourceChecksumAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelperComponent.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperComponent.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs create mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test.csproj index c6a894ee1f..60f85d388f 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test.csproj +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test.csproj @@ -13,9 +13,10 @@ - - + + + @@ -25,19 +26,6 @@ - - - - false - Content - PreserveNewest - Build - - - - - - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Test.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Test.csproj index 82d2483d0b..5f09868d52 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Test.csproj +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Test.csproj @@ -13,9 +13,10 @@ - - + + + @@ -25,20 +26,6 @@ - - - - false - Content - PreserveNewest - Build - - - - - - - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTypeVisitorTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTypeVisitorTest.cs index 206b74375d..ad75c89bfb 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTypeVisitorTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTypeVisitorTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Reflection; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X @@ -13,7 +14,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X { private static readonly Assembly _assembly = typeof(ViewComponentTypeVisitorTest).GetTypeInfo().Assembly; - private static Compilation Compilation { get; } = TestCompilation.Create(_assembly); + private static CSharpCompilation Compilation { get; } = TestCompilation.Create(_assembly); // In practice MVC will provide a marker attribute for ViewComponents. To prevent a circular reference between MVC and Razor // we can use a test class as a marker. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj index 35bf3f778c..310177f1b9 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj @@ -13,9 +13,9 @@ - - + + @@ -25,19 +25,6 @@ - - - - false - Content - PreserveNewest - Build - - - - - - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTypeVisitorTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTypeVisitorTest.cs index 48e8cfeec8..3e72a824bc 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTypeVisitorTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTypeVisitorTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Reflection; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions @@ -13,7 +14,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { private static readonly Assembly _assembly = typeof(ViewComponentTypeVisitorTest).GetTypeInfo().Assembly; - private static Compilation Compilation { get; } = TestCompilation.Create(_assembly); + private static CSharpCompilation Compilation { get; } = TestCompilation.Create(_assembly); // In practice MVC will provide a marker attribute for ViewComponents. To prevent a circular reference between MVC and Razor // we can use a test class as a marker. diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/Microsoft.CodeAnalysis.Razor.Test.csproj b/src/Razor/Microsoft.CodeAnalysis.Razor/test/Microsoft.CodeAnalysis.Razor.Test.csproj index fa77866791..8334edb354 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/Microsoft.CodeAnalysis.Razor.Test.csproj +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/Microsoft.CodeAnalysis.Razor.Test.csproj @@ -14,9 +14,10 @@ - - + + + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj index 7043de7d02..ec9b435178 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj @@ -5,10 +5,7 @@ - - - - + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs new file mode 100644 index 0000000000..011d59083c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.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.Diagnostics; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperExecutionContext + { + public TagHelperExecutionContext( + string tagName, + TagMode tagMode, + IDictionary items, + string uniqueId, + Func executeChildContentAsync, + Action startTagHelperWritingScope, + Func endTagHelperWritingScope) + { + } + + public bool ChildContentRetrieved => false; + + public IDictionary Items { get; private set; } + + public IList TagHelpers => null; + + public TagHelperOutput Output { get; internal set; } + + public TagHelperContext Context { get; } + + public void Add(ITagHelper tagHelper) + { + } + + public void AddHtmlAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public void AddHtmlAttribute(TagHelperAttribute attribute) + { + } + + public void AddTagHelperAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public void AddTagHelperAttribute(TagHelperAttribute attribute) + { + } + + public void Reinitialize( + string tagName, + TagMode tagMode, + IDictionary items, + string uniqueId, + Func executeChildContentAsync) + { + } + + public Task SetOutputContentAsync() + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs new file mode 100644 index 0000000000..21f2b5b6fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.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 System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperRunner + { + public Task RunAsync(TagHelperExecutionContext executionContext) + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs new file mode 100644 index 0000000000..70f072bbc4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.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 System; +using System.Collections.Generic; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperScopeManager + { + public TagHelperScopeManager( + Action startTagHelperWritingScope, + Func endTagHelperWritingScope) + { + } + + public TagHelperExecutionContext Begin( + string tagName, + TagMode tagMode, + string uniqueId, + Func executeChildContentAsync) + { + throw null; + } + + public TagHelperExecutionContext End() + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs new file mode 100644 index 0000000000..aca16610b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs @@ -0,0 +1,92 @@ +// 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.TagHelpers +{ + /// + /// Used to override an property's HTML attribute name. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class HtmlAttributeNameAttribute : Attribute + { + private string _dictionaryAttributePrefix; + + /// + /// Instantiates a new instance of the class with + /// equal to null. + /// + /// + /// Associated property must not have a public setter and must be compatible with + /// where TKey is + /// . + /// + public HtmlAttributeNameAttribute() + { + } + + /// + /// Instantiates a new instance of the class. + /// + /// + /// HTML attribute name for the associated property. Must be null or empty if associated property does + /// not have a public setter and is compatible with + /// where TKey is + /// . Otherwise must not be null or empty. + /// + public HtmlAttributeNameAttribute(string name) + { + Name = name; + } + + /// + /// HTML attribute name of the associated property. + /// + /// + /// null or empty if and only if associated property does not have a public setter and is compatible + /// with where TKey is + /// . + /// + public string Name { get; } + + /// + /// Gets or sets the prefix used to match HTML attribute names. Matching attributes are added to the + /// associated property (an ). + /// + /// + /// If non-null associated property must be compatible with + /// where TKey is + /// . + /// + /// + /// + /// If associated property is compatible with + /// , default value is Name + "-". + /// must not be null or empty in this case. + /// + /// + /// Otherwise default value is null. + /// + /// + public string DictionaryAttributePrefix + { + get + { + return _dictionaryAttributePrefix; + } + set + { + _dictionaryAttributePrefix = value; + DictionaryAttributePrefixSet = true; + } + } + + /// + /// Gets an indication whether has been set. Used to distinguish an + /// uninitialized value from an explicit null setting. + /// + /// true if was set. false otherwise. + public bool DictionaryAttributePrefixSet { get; private set; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs new file mode 100644 index 0000000000..9d23480abd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.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; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Indicates the associated property should not be bound to HTML attributes. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class HtmlAttributeNotBoundAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + public HtmlAttributeNotBoundAttribute() + { + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs new file mode 100644 index 0000000000..7ac198567f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.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. + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public enum HtmlAttributeValueStyle + { + DoubleQuotes, + SingleQuotes, + NoQuotes, + Minimized, + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs new file mode 100644 index 0000000000..857d6a0e5d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.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; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Provides an 's target. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] + public sealed class HtmlTargetElementAttribute : Attribute + { + public const string ElementCatchAllTarget = "*"; + + /// + /// Instantiates a new instance of the class that targets all HTML + /// elements with the required . + /// + /// is set to *. + public HtmlTargetElementAttribute() + : this(ElementCatchAllTarget) + { + } + + /// + /// Instantiates a new instance of the class with the given + /// as its value. + /// + /// + /// The HTML tag the targets. + /// + /// A * value indicates this + /// targets all HTML elements with the required . + public HtmlTargetElementAttribute(string tag) + { + Tag = tag; + } + + /// + /// The HTML tag the targets. A * value indicates this + /// targets all HTML elements with the required . + /// + public string Tag { get; } + + /// + /// A comma-separated of attribute selectors the HTML element must match for the + /// to run. * at the end of an attribute name acts as a prefix match. A value + /// surrounded by square brackets is handled as a CSS attribute value selector. Operators ^=, $= and + /// = are supported e.g. "name", "[name]", "[name=value]", "[ name ^= 'value' ]". + /// + public string Attributes { get; set; } + + /// + /// The expected tag structure. Defaults to . + /// + /// + /// If and no other tag helpers applying to the same element specify + /// their the behavior is used: + /// + /// + /// <my-tag-helper></my-tag-helper> + /// <!-- OR --> + /// <my-tag-helper /> + /// + /// Otherwise, if another tag helper applying to the same element does specify their behavior, that behavior + /// is used. + /// + /// + /// If HTML elements can be written in the following formats: + /// + /// <my-tag-helper> + /// <!-- OR --> + /// <my-tag-helper /> + /// + /// + /// + public TagStructure TagStructure { get; set; } + + /// + /// The required HTML element name of the direct parent. A null value indicates any HTML element name is + /// allowed. + /// + public string ParentTag { get; set; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs new file mode 100644 index 0000000000..2f175f386a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.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.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public interface ITagHelper + { + int Order { get; } + + void Init(TagHelperContext context); + + Task ProcessAsync(TagHelperContext context, TagHelperOutput output); + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs new file mode 100644 index 0000000000..a97b5ef9ab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs @@ -0,0 +1,35 @@ +// 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.TagHelpers +{ + /// + /// Provides a hint of the 's output element. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public sealed class OutputElementHintAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + /// + /// The HTML element the may output. + /// + public OutputElementHintAttribute(string outputElement) + { + if (outputElement == null) + { + throw new ArgumentNullException(nameof(outputElement)); + } + + OutputElement = outputElement; + } + + /// + /// The HTML element the may output. + /// + public string OutputElement { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs new file mode 100644 index 0000000000..f3d1569a59 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs @@ -0,0 +1,190 @@ +// 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.ObjectModel; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// A read-only collection of s. + /// + public abstract class ReadOnlyTagHelperAttributeList : ReadOnlyCollection + { + private static readonly IReadOnlyList EmptyList = new TagHelperAttribute[0]; + + /// + /// Instantiates a new instance of with an empty + /// collection. + /// + protected ReadOnlyTagHelperAttributeList() + : base(new List()) + { + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public ReadOnlyTagHelperAttributeList(IList attributes) + : base(attributes) + { + } + + /// + /// Gets the first with + /// matching . + /// + /// + /// The of the to get. + /// + /// The first with + /// matching . + /// + /// is compared case-insensitively. + public TagHelperAttribute this[string name] + { + get + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + return Items[i]; + } + } + + return null; + } + } + + /// + /// Determines whether a with + /// matching exists in the collection. + /// + /// The of the + /// to get. + /// + /// true if a with the same + /// exists in the collection; otherwise, false. + /// + /// is compared case-insensitively. + public bool ContainsName(string name) + { + return this[name] != null; + } + + /// + /// Retrieves the first with + /// matching . + /// + /// The of the + /// to get. + /// When this method returns, the first with + /// matching , if found; otherwise, + /// null. + /// true if a with the same + /// exists in the collection; otherwise, false. + /// is compared case-insensitively. + public bool TryGetAttribute(string name, out TagHelperAttribute attribute) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + attribute = this[name]; + + return attribute != null; + } + + /// + /// Retrieves s in the collection with + /// matching . + /// + /// The of the + /// s to get. + /// When this method returns, the s with + /// matching . + /// true if at least one with the same + /// exists in the collection; otherwise, false. + /// is compared case-insensitively. + public bool TryGetAttributes(string name, out IReadOnlyList attributes) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + List matchedAttributes = null; + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + if (matchedAttributes == null) + { + matchedAttributes = new List(); + } + + matchedAttributes.Add(Items[i]); + } + } + attributes = matchedAttributes ?? EmptyList; + + return matchedAttributes != null; + } + + /// + /// Searches for a who's + /// case-insensitively matches and returns the zero-based index of the first + /// occurrence. + /// + /// The to locate in the collection. + /// The zero-based index of the first matching within the collection, + /// if found; otherwise, -1. + public int IndexOfName(string name) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + return i; + } + } + + return -1; + } + + /// + /// Determines if the specified has the same name as . + /// + /// The value to compare against s + /// . + /// The attribute to compare against. + /// true if case-insensitively matches s + /// . + protected static bool NameEquals(string name, TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return string.Equals(name, attribute.Name, StringComparison.OrdinalIgnoreCase); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs new file mode 100644 index 0000000000..bc4f6bac35 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs @@ -0,0 +1,42 @@ +// 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.TagHelpers +{ + /// + /// Restricts children of the 's element. + /// + /// Combining this attribute with a that specifies its + /// as will result + /// in this attribute being ignored. + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RestrictChildrenAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + /// + /// The tag name of an element allowed as a child. + /// + /// + /// Additional names of elements allowed as children. + /// + public RestrictChildrenAttribute(string childTag, params string[] childTags) + { + var concatenatedNames = new string[1 + childTags.Length]; + concatenatedNames[0] = childTag; + + childTags.CopyTo(concatenatedNames, 1); + + ChildTags = concatenatedNames; + } + + /// + /// Get the names of elements allowed as children. + /// + public IEnumerable ChildTags { get; } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs new file mode 100644 index 0000000000..ed9faca1bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.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.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public abstract class TagHelper : ITagHelper + { + public virtual int Order { get; } = 0; + + public virtual void Init(TagHelperContext context) + { + } + + public virtual void Process(TagHelperContext context, TagHelperOutput output) + { + } + + public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + Process(context, output); + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs new file mode 100644 index 0000000000..7bdd2aea22 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs @@ -0,0 +1,43 @@ +// 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.Encodings.Web; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public class TagHelperAttribute : IHtmlContentContainer + { + public TagHelperAttribute(string name) + { + } + + public TagHelperAttribute(string name, object value) + { + } + + public TagHelperAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public string Name { get; } + + public object Value { get; } + + public HtmlAttributeValueStyle ValueStyle { get; } + + public void WriteTo(TextWriter writer, HtmlEncoder encoder) + { + } + + public void CopyTo(IHtmlContentBuilder destination) + { + } + + public void MoveTo(IHtmlContentBuilder destination) + { + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs new file mode 100644 index 0000000000..308292294c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs @@ -0,0 +1,230 @@ +// 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.TagHelpers +{ + /// + /// A collection of s. + /// + public class TagHelperAttributeList : ReadOnlyTagHelperAttributeList, IList + { + /// + /// Instantiates a new instance of with an empty collection. + /// + public TagHelperAttributeList() + : base() + { + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public TagHelperAttributeList(IEnumerable attributes) + : base (new List(attributes)) + { + if (attributes == null) + { + throw new ArgumentNullException(nameof(attributes)); + } + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public TagHelperAttributeList(List attributes) + : base(attributes) + { + if (attributes == null) + { + throw new ArgumentNullException(nameof(attributes)); + } + } + + /// + /// + /// 's must not be null. + /// + public new TagHelperAttribute this[int index] + { + get + { + return base[index]; + } + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Items[index] = value; + } + } + + /// + /// Replaces the first with matching + /// and removes any additional matching s. If a + /// matching is not found, adds a with + /// and to the end of the collection. + /// + /// The of the to set. + /// + /// + /// The to set. + /// + /// is compared case-insensitively. + public void SetAttribute(string name, object value) + { + var attribute = new TagHelperAttribute(name, value); + SetAttribute(attribute); + } + + /// + /// Replaces the first with matching + /// 's and removes any additional matching + /// s. If a matching is not found, adds the + /// specified to the end of the collection. + /// + /// + /// The to set. + /// + /// 's is compared + /// case-insensitively. + public void SetAttribute(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + var attributeReplaced = false; + + // Perf: Avoid allocating enumerator + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(attribute.Name, Items[i])) + { + // We replace the first attribute with the provided attribute, remove all the rest. + if (!attributeReplaced) + { + // We replace the first attribute we find with the same name. + Items[i] = attribute; + attributeReplaced = true; + } + else + { + Items.RemoveAt(i--); + } + } + } + + // If we didn't replace an attribute value we should add value to the end of the collection. + if (!attributeReplaced) + { + Add(attribute); + } + } + + /// + bool ICollection.IsReadOnly => false; + + /// + /// Adds a to the end of the collection with the specified + /// and . + /// + /// The of the attribute to add. + /// The of the attribute to add. + public void Add(string name, object value) + { + var attribute = new TagHelperAttribute(name, value); + Items.Add(attribute); + } + + /// + public void Add(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + Items.Add(attribute); + } + + /// + public void Insert(int index, TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + Items.Insert(index, attribute); + } + + /// + /// + /// s is compared case-insensitively. + /// + public bool Remove(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return Items.Remove(attribute); + } + + /// + public void RemoveAt(int index) + { + Items.RemoveAt(index); + } + + /// + /// Removes all s with matching + /// . + /// + /// + /// The of s to remove. + /// + /// + /// true if at least 1 was removed; otherwise, false. + /// + /// is compared case-insensitively. + public bool RemoveAll(string name) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + var removedAtLeastOne = false; + for (var i = Items.Count - 1; i >= 0; i--) + { + if (NameEquals(name, Items[i])) + { + Items.RemoveAt(i); + removedAtLeastOne = true; + } + } + + return removedAtLeastOne; + } + + /// + public void Clear() + { + Items.Clear(); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs new file mode 100644 index 0000000000..7a6d380215 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs @@ -0,0 +1,179 @@ +// 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.Encodings.Web; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Abstract class used to buffer content returned by s. + /// + public abstract class TagHelperContent : IHtmlContentBuilder + { + /// + /// Gets a value indicating whether the content was modified. + /// + public abstract bool IsModified { get; } + + /// + /// Gets a value indicating whether the content is empty or whitespace. + /// + public abstract bool IsEmptyOrWhiteSpace { get; } + + /// + /// Sets the content. + /// + /// The that replaces the content. + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetHtmlContent(IHtmlContent htmlContent) + { + HtmlContentBuilderExtensions.SetHtmlContent(this, htmlContent); + return this; + } + + /// + /// Sets the content. + /// + /// + /// The that replaces the content. The value is assume to be unencoded + /// as-provided and will be HTML encoded before being written. + /// + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetContent(string unencoded) + { + HtmlContentBuilderExtensions.SetContent(this, unencoded); + return this; + } + + /// + /// Sets the content. + /// + /// + /// The that replaces the content. The value is assume to be HTML encoded + /// as-provided and no further encoding will be performed. + /// + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetHtmlContent(string encoded) + { + HtmlContentBuilderExtensions.SetHtmlContent(this, encoded); + return this; + } + + /// + /// Appends to the existing content. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent Append(string unencoded); + + /// + /// Appends to the existing content. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent AppendHtml(IHtmlContent htmlContent); + + /// + /// Appends to the existing content. is assumed + /// to be an HTML encoded and no further encoding will be performed. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent AppendHtml(string encoded); + + /// + /// Appends the specified to the existing content after + /// replacing each format item with the HTML encoded representation of the + /// corresponding item in the array. + /// + /// + /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). + /// + /// The object array to format. + /// A reference to this instance after the append operation has completed. + public TagHelperContent AppendFormat(string format, params object[] args) + { + HtmlContentBuilderExtensions.AppendFormat(this, null, format, args); + return this; + } + + /// + /// Appends the specified to the existing content with information from the + /// after replacing each format item with the HTML encoded + /// representation of the corresponding item in the array. + /// + /// An object that supplies culture-specific formatting information. + /// + /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). + /// + /// The object array to format. + /// A reference to this instance after the append operation has completed. + public TagHelperContent AppendFormat(IFormatProvider provider, string format, params object[] args) + { + HtmlContentBuilderExtensions.AppendFormat(this, provider, format, args); + return this; + } + + /// + /// Clears the content. + /// + /// A reference to this instance after the clear operation has completed. + public abstract TagHelperContent Clear(); + + /// + /// Clears the , so it can be reused. + /// + /// This method does more than what does. It also resets the + /// flag. + public abstract void Reinitialize(); + + /// + public abstract void CopyTo(IHtmlContentBuilder destination); + + /// + public abstract void MoveTo(IHtmlContentBuilder destination); + + /// + /// Gets the content. + /// + /// A containing the content. + public abstract string GetContent(); + + /// + /// Gets the content. + /// + /// The . + /// A containing the content. + public abstract string GetContent(HtmlEncoder encoder); + + /// + public abstract void WriteTo(TextWriter writer, HtmlEncoder encoder); + + /// + IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(IHtmlContent content) + { + return AppendHtml(content); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.Append(string unencoded) + { + return Append(unencoded); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(string encoded) + { + return AppendHtml(encoded); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.Clear() + { + return Clear(); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs new file mode 100644 index 0000000000..e09a552a0b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs @@ -0,0 +1,118 @@ +// 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.TagHelpers +{ + /// + /// Contains information related to the execution of s. + /// + public class TagHelperContext + { + private readonly TagHelperAttributeList _allAttributes; + + /// + /// Instantiates a new . + /// + /// The parsed HTML tag name of the element. + /// Every attribute associated with the current HTML element. + /// Collection of items used to communicate with other s. + /// The unique identifier for the source element this + /// applies to. + public TagHelperContext( + string tagName, + TagHelperAttributeList allAttributes, + IDictionary items, + string uniqueId) : this(allAttributes, items, uniqueId) + { + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + TagName = tagName; + } + + /// + /// Instantiates a new . + /// + /// Every attribute associated with the current HTML element. + /// Collection of items used to communicate with other s. + /// The unique identifier for the source element this + /// applies to. + public TagHelperContext( + TagHelperAttributeList allAttributes, + IDictionary items, + string uniqueId) + { + if (items == null) + { + throw new ArgumentNullException(nameof(items)); + } + + if (uniqueId == null) + { + throw new ArgumentNullException(nameof(uniqueId)); + } + + if (allAttributes == null) + { + throw new ArgumentNullException(nameof(allAttributes)); + } + + _allAttributes = allAttributes; + Items = items; + UniqueId = uniqueId; + } + + /// + /// The parsed HTML tag name of the element. + /// + public string TagName { get; private set; } + + /// + /// Every attribute associated with the current HTML element. + /// + public ReadOnlyTagHelperAttributeList AllAttributes => _allAttributes; + + /// + /// Gets the collection of items used to communicate with other s. + /// + /// + /// This is copy-on-write in order to ensure items added to this + /// collection are visible only to other s targeting child elements. + /// + public IDictionary Items { get; private set; } + + /// + /// An identifier unique to the HTML element this context is for. + /// + public string UniqueId { get; private set; } + + /// + /// Clears the and updates its state with the provided values. + /// + /// The HTML tag name to use. + /// The to use. + /// The unique id to use. + public void Reinitialize(string tagName, IDictionary items, string uniqueId) + { + TagName = tagName; + Reinitialize(items, uniqueId); + } + + /// + /// Clears the and updates its state with the provided values. + /// + /// The to use. + /// The unique id to use. + public void Reinitialize(IDictionary items, string uniqueId) + { + _allAttributes.Clear(); + Items = items; + UniqueId = uniqueId; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs new file mode 100644 index 0000000000..ed0c1e5308 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs @@ -0,0 +1,79 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public class TagHelperOutput : IHtmlContentContainer + { + public TagHelperOutput( + string tagName, + TagHelperAttributeList attributes, + Func> getChildContentAsync) + { + } + + public string TagName { get; set; } + + public TagHelperContent PreElement => null; + + public TagHelperContent PreContent => null; + + public TagHelperContent Content => null; + + public TagHelperContent PostContent => null; + + public TagHelperContent PostElement => null; + + public bool IsContentModified => true; + + public TagMode TagMode { get; set; } + + public TagHelperAttributeList Attributes { get; } + + public void Reinitialize(string tagName, TagMode tagMode) + { + } + + public void SuppressOutput() + { + } + + public Task GetChildContentAsync() + { + throw null; + } + + public Task GetChildContentAsync(bool useCachedResult) + { + throw null; + } + + public Task GetChildContentAsync(HtmlEncoder encoder) + { + throw null; + } + + public Task GetChildContentAsync(bool useCachedResult, HtmlEncoder encoder) + { + throw null; + } + + void IHtmlContentContainer.CopyTo(IHtmlContentBuilder destination) + { + } + + void IHtmlContentContainer.MoveTo(IHtmlContentBuilder destination) + { + } + + public void WriteTo(TextWriter writer, HtmlEncoder encoder) + { + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs new file mode 100644 index 0000000000..b9d60a706a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.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.TagHelpers +{ + /// + /// The mode in which an element should render. + /// + public enum TagMode + { + /// + /// Include both start and end tags. + /// + StartTagAndEndTag, + + /// + /// A self-closed tag. + /// + SelfClosing, + + /// + /// Only a start tag. + /// + StartTagOnly + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs new file mode 100644 index 0000000000..370f9372f2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.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. + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// The structure the element should be written in. + /// + public enum TagStructure + { + /// + /// If no other tag helper applies to the same element and specifies a , + /// will be used. + /// + Unspecified, + + /// + /// Element can be written as <my-tag-helper></my-tag-helper> or <my-tag-helper />. + /// + NormalOrSelfClosing, + + /// + /// Element can be written as <my-tag-helper> or <my-tag-helper />. + /// + /// Elements with a structure will never have any content. + WithoutEndTag + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj index 9fa0e8c4ae..bd2e0104cc 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj @@ -6,10 +6,7 @@ - - - - + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/DefaultRazorCompiledItem.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/DefaultRazorCompiledItem.cs new file mode 100644 index 0000000000..b5390b7c87 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/IRazorSourceChecksumMetadata.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/IRazorSourceChecksumMetadata.cs new file mode 100644 index 0000000000..dccdb2f871 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItem.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItem.cs new file mode 100644 index 0000000000..8eff0f4ea2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemAttribute.cs new file mode 100644 index 0000000000..8e4c003f87 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemExtensions.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemExtensions.cs new file mode 100644 index 0000000000..d6287e3253 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemMetadataAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemMetadataAttribute.cs new file mode 100644 index 0000000000..0b52fd5f1b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemMetadataAttribute.cs @@ -0,0 +1,35 @@ +// 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 +{ + /// + /// Defines a key/value metadata pair for the decorated Razor type. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] + public sealed class RazorCompiledItemMetadataAttribute : Attribute + { + /// + /// Creates a new . + /// + /// The key. + /// The value. + public RazorCompiledItemMetadataAttribute(string key, string value) + { + Key = key; + Value = value; + } + + /// + /// Gets the key. + /// + public string Key { get; } + + /// + /// Gets the value. + /// + public string Value { get; } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorConfigurationNameAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorConfigurationNameAttribute.cs new file mode 100644 index 0000000000..034e64c309 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorConfigurationNameAttribute.cs @@ -0,0 +1,38 @@ +// 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 name of a Razor configuration as defined by the Razor SDK. + /// + /// + /// This attribute is applied to an application's entry point assembly by the Razor SDK during the build, + /// so that the Razor configuration can be loaded at runtime based on the settings provided by the project + /// file. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class RazorConfigurationNameAttribute : Attribute + { + /// + /// Creates a new instance of . + /// + /// The name of the Razor configuration. + public RazorConfigurationNameAttribute(string configurationName) + { + if (configurationName == null) + { + throw new ArgumentNullException(nameof(configurationName)); + } + + ConfigurationName = configurationName; + } + + /// + /// Gets the name of the Razor configuration. + /// + public string ConfigurationName { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorExtensionAssemblyNameAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorExtensionAssemblyNameAttribute.cs new file mode 100644 index 0000000000..92a9d1c6ec --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorExtensionAssemblyNameAttribute.cs @@ -0,0 +1,50 @@ +// 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 name of a Razor extension as defined by the Razor SDK. + /// + /// + /// This attribute is applied to an application's entry point assembly by the Razor SDK during the build, + /// so that the Razor configuration can be loaded at runtime based on the settings provided by the project + /// file. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public sealed class RazorExtensionAssemblyNameAttribute : Attribute + { + /// + /// Creates a new instance of . + /// + /// The name of the extension. + /// The assembly name of the extension. + public RazorExtensionAssemblyNameAttribute(string extensionName, string assemblyName) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (assemblyName == null) + { + throw new ArgumentNullException(nameof(assemblyName)); + } + + ExtensionName = extensionName; + AssemblyName = assemblyName; + } + + /// + /// Gets the assembly name of the extension. + /// + public string AssemblyName { get; } + + /// + /// Gets the name of the extension. + /// + public string ExtensionName { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorLanguageVersionAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorLanguageVersionAttribute.cs new file mode 100644 index 0000000000..8f261143d0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorLanguageVersionAttribute.cs @@ -0,0 +1,38 @@ +// 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 name of a Razor configuration as defined by the Razor SDK. + /// + /// + /// This attribute is part of a set of metadata attributes that can be applied to an assembly at build + /// time by the Razor SDK. These attributes allow the Razor configuration to be loaded at runtime based + /// on the settings originally provided by the project file. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class RazorLanguageVersionAttribute : Attribute + { + /// + /// Creates a new instance of . + /// + /// The language version of Razor + public RazorLanguageVersionAttribute(string languageVersion) + { + if (languageVersion == null) + { + throw new ArgumentNullException(nameof(languageVersion)); + } + + LanguageVersion = languageVersion; + } + + /// + /// Gets the Razor language version. + /// + public string LanguageVersion { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorSourceChecksumAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Hosting/RazorSourceChecksumAttribute.cs new file mode 100644 index 0000000000..d1da25b300 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs new file mode 100644 index 0000000000..011d59083c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.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.Diagnostics; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperExecutionContext + { + public TagHelperExecutionContext( + string tagName, + TagMode tagMode, + IDictionary items, + string uniqueId, + Func executeChildContentAsync, + Action startTagHelperWritingScope, + Func endTagHelperWritingScope) + { + } + + public bool ChildContentRetrieved => false; + + public IDictionary Items { get; private set; } + + public IList TagHelpers => null; + + public TagHelperOutput Output { get; internal set; } + + public TagHelperContext Context { get; } + + public void Add(ITagHelper tagHelper) + { + } + + public void AddHtmlAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public void AddHtmlAttribute(TagHelperAttribute attribute) + { + } + + public void AddTagHelperAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public void AddTagHelperAttribute(TagHelperAttribute attribute) + { + } + + public void Reinitialize( + string tagName, + TagMode tagMode, + IDictionary items, + string uniqueId, + Func executeChildContentAsync) + { + } + + public Task SetOutputContentAsync() + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs new file mode 100644 index 0000000000..21f2b5b6fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.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 System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperRunner + { + public Task RunAsync(TagHelperExecutionContext executionContext) + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs new file mode 100644 index 0000000000..70f072bbc4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.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 System; +using System.Collections.Generic; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperScopeManager + { + public TagHelperScopeManager( + Action startTagHelperWritingScope, + Func endTagHelperWritingScope) + { + } + + public TagHelperExecutionContext Begin( + string tagName, + TagMode tagMode, + string uniqueId, + Func executeChildContentAsync) + { + throw null; + } + + public TagHelperExecutionContext End() + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs new file mode 100644 index 0000000000..aca16610b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs @@ -0,0 +1,92 @@ +// 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.TagHelpers +{ + /// + /// Used to override an property's HTML attribute name. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class HtmlAttributeNameAttribute : Attribute + { + private string _dictionaryAttributePrefix; + + /// + /// Instantiates a new instance of the class with + /// equal to null. + /// + /// + /// Associated property must not have a public setter and must be compatible with + /// where TKey is + /// . + /// + public HtmlAttributeNameAttribute() + { + } + + /// + /// Instantiates a new instance of the class. + /// + /// + /// HTML attribute name for the associated property. Must be null or empty if associated property does + /// not have a public setter and is compatible with + /// where TKey is + /// . Otherwise must not be null or empty. + /// + public HtmlAttributeNameAttribute(string name) + { + Name = name; + } + + /// + /// HTML attribute name of the associated property. + /// + /// + /// null or empty if and only if associated property does not have a public setter and is compatible + /// with where TKey is + /// . + /// + public string Name { get; } + + /// + /// Gets or sets the prefix used to match HTML attribute names. Matching attributes are added to the + /// associated property (an ). + /// + /// + /// If non-null associated property must be compatible with + /// where TKey is + /// . + /// + /// + /// + /// If associated property is compatible with + /// , default value is Name + "-". + /// must not be null or empty in this case. + /// + /// + /// Otherwise default value is null. + /// + /// + public string DictionaryAttributePrefix + { + get + { + return _dictionaryAttributePrefix; + } + set + { + _dictionaryAttributePrefix = value; + DictionaryAttributePrefixSet = true; + } + } + + /// + /// Gets an indication whether has been set. Used to distinguish an + /// uninitialized value from an explicit null setting. + /// + /// true if was set. false otherwise. + public bool DictionaryAttributePrefixSet { get; private set; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs new file mode 100644 index 0000000000..9d23480abd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.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; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Indicates the associated property should not be bound to HTML attributes. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class HtmlAttributeNotBoundAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + public HtmlAttributeNotBoundAttribute() + { + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs new file mode 100644 index 0000000000..7ac198567f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.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. + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public enum HtmlAttributeValueStyle + { + DoubleQuotes, + SingleQuotes, + NoQuotes, + Minimized, + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs new file mode 100644 index 0000000000..857d6a0e5d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.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; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Provides an 's target. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] + public sealed class HtmlTargetElementAttribute : Attribute + { + public const string ElementCatchAllTarget = "*"; + + /// + /// Instantiates a new instance of the class that targets all HTML + /// elements with the required . + /// + /// is set to *. + public HtmlTargetElementAttribute() + : this(ElementCatchAllTarget) + { + } + + /// + /// Instantiates a new instance of the class with the given + /// as its value. + /// + /// + /// The HTML tag the targets. + /// + /// A * value indicates this + /// targets all HTML elements with the required . + public HtmlTargetElementAttribute(string tag) + { + Tag = tag; + } + + /// + /// The HTML tag the targets. A * value indicates this + /// targets all HTML elements with the required . + /// + public string Tag { get; } + + /// + /// A comma-separated of attribute selectors the HTML element must match for the + /// to run. * at the end of an attribute name acts as a prefix match. A value + /// surrounded by square brackets is handled as a CSS attribute value selector. Operators ^=, $= and + /// = are supported e.g. "name", "[name]", "[name=value]", "[ name ^= 'value' ]". + /// + public string Attributes { get; set; } + + /// + /// The expected tag structure. Defaults to . + /// + /// + /// If and no other tag helpers applying to the same element specify + /// their the behavior is used: + /// + /// + /// <my-tag-helper></my-tag-helper> + /// <!-- OR --> + /// <my-tag-helper /> + /// + /// Otherwise, if another tag helper applying to the same element does specify their behavior, that behavior + /// is used. + /// + /// + /// If HTML elements can be written in the following formats: + /// + /// <my-tag-helper> + /// <!-- OR --> + /// <my-tag-helper /> + /// + /// + /// + public TagStructure TagStructure { get; set; } + + /// + /// The required HTML element name of the direct parent. A null value indicates any HTML element name is + /// allowed. + /// + public string ParentTag { get; set; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs new file mode 100644 index 0000000000..ec86a32a11 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.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. + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Contract used to filter matching HTML elements. + /// Marker interface for s. + /// + public interface ITagHelper : ITagHelperComponent + { + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelperComponent.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelperComponent.cs new file mode 100644 index 0000000000..3b2059be51 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelperComponent.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.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Contract used to modify an HTML element. + /// + public interface ITagHelperComponent + { + /// + /// When a set of s are executed, their 's + /// are first invoked in the specified ; then their + /// 's are invoked in the specified + /// . Lower values are executed first. + /// + int Order { get; } + + /// + /// Initializes the with the given . Additions to + /// should be done within this method to ensure they're added prior to + /// executing the children. + /// + /// Contains information associated with the current HTML tag. + /// When more than one runs on the same element, + /// may be invoked prior to . + /// + void Init(TagHelperContext context); + + /// + /// Asynchronously executes the with the given and + /// . + /// + /// Contains information associated with the current HTML tag. + /// A stateful HTML element used to generate an HTML tag. + /// A that on completion updates the . + Task ProcessAsync(TagHelperContext context, TagHelperOutput output); + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs new file mode 100644 index 0000000000..a97b5ef9ab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs @@ -0,0 +1,35 @@ +// 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.TagHelpers +{ + /// + /// Provides a hint of the 's output element. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public sealed class OutputElementHintAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + /// + /// The HTML element the may output. + /// + public OutputElementHintAttribute(string outputElement) + { + if (outputElement == null) + { + throw new ArgumentNullException(nameof(outputElement)); + } + + OutputElement = outputElement; + } + + /// + /// The HTML element the may output. + /// + public string OutputElement { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs new file mode 100644 index 0000000000..f3d1569a59 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs @@ -0,0 +1,190 @@ +// 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.ObjectModel; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// A read-only collection of s. + /// + public abstract class ReadOnlyTagHelperAttributeList : ReadOnlyCollection + { + private static readonly IReadOnlyList EmptyList = new TagHelperAttribute[0]; + + /// + /// Instantiates a new instance of with an empty + /// collection. + /// + protected ReadOnlyTagHelperAttributeList() + : base(new List()) + { + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public ReadOnlyTagHelperAttributeList(IList attributes) + : base(attributes) + { + } + + /// + /// Gets the first with + /// matching . + /// + /// + /// The of the to get. + /// + /// The first with + /// matching . + /// + /// is compared case-insensitively. + public TagHelperAttribute this[string name] + { + get + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + return Items[i]; + } + } + + return null; + } + } + + /// + /// Determines whether a with + /// matching exists in the collection. + /// + /// The of the + /// to get. + /// + /// true if a with the same + /// exists in the collection; otherwise, false. + /// + /// is compared case-insensitively. + public bool ContainsName(string name) + { + return this[name] != null; + } + + /// + /// Retrieves the first with + /// matching . + /// + /// The of the + /// to get. + /// When this method returns, the first with + /// matching , if found; otherwise, + /// null. + /// true if a with the same + /// exists in the collection; otherwise, false. + /// is compared case-insensitively. + public bool TryGetAttribute(string name, out TagHelperAttribute attribute) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + attribute = this[name]; + + return attribute != null; + } + + /// + /// Retrieves s in the collection with + /// matching . + /// + /// The of the + /// s to get. + /// When this method returns, the s with + /// matching . + /// true if at least one with the same + /// exists in the collection; otherwise, false. + /// is compared case-insensitively. + public bool TryGetAttributes(string name, out IReadOnlyList attributes) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + List matchedAttributes = null; + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + if (matchedAttributes == null) + { + matchedAttributes = new List(); + } + + matchedAttributes.Add(Items[i]); + } + } + attributes = matchedAttributes ?? EmptyList; + + return matchedAttributes != null; + } + + /// + /// Searches for a who's + /// case-insensitively matches and returns the zero-based index of the first + /// occurrence. + /// + /// The to locate in the collection. + /// The zero-based index of the first matching within the collection, + /// if found; otherwise, -1. + public int IndexOfName(string name) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + return i; + } + } + + return -1; + } + + /// + /// Determines if the specified has the same name as . + /// + /// The value to compare against s + /// . + /// The attribute to compare against. + /// true if case-insensitively matches s + /// . + protected static bool NameEquals(string name, TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return string.Equals(name, attribute.Name, StringComparison.OrdinalIgnoreCase); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs new file mode 100644 index 0000000000..bc4f6bac35 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs @@ -0,0 +1,42 @@ +// 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.TagHelpers +{ + /// + /// Restricts children of the 's element. + /// + /// Combining this attribute with a that specifies its + /// as will result + /// in this attribute being ignored. + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RestrictChildrenAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + /// + /// The tag name of an element allowed as a child. + /// + /// + /// Additional names of elements allowed as children. + /// + public RestrictChildrenAttribute(string childTag, params string[] childTags) + { + var concatenatedNames = new string[1 + childTags.Length]; + concatenatedNames[0] = childTag; + + childTags.CopyTo(concatenatedNames, 1); + + ChildTags = concatenatedNames; + } + + /// + /// Get the names of elements allowed as children. + /// + public IEnumerable ChildTags { get; } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs new file mode 100644 index 0000000000..ed9faca1bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.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.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public abstract class TagHelper : ITagHelper + { + public virtual int Order { get; } = 0; + + public virtual void Init(TagHelperContext context) + { + } + + public virtual void Process(TagHelperContext context, TagHelperOutput output) + { + } + + public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + Process(context, output); + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs new file mode 100644 index 0000000000..7bdd2aea22 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs @@ -0,0 +1,43 @@ +// 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.Encodings.Web; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public class TagHelperAttribute : IHtmlContentContainer + { + public TagHelperAttribute(string name) + { + } + + public TagHelperAttribute(string name, object value) + { + } + + public TagHelperAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public string Name { get; } + + public object Value { get; } + + public HtmlAttributeValueStyle ValueStyle { get; } + + public void WriteTo(TextWriter writer, HtmlEncoder encoder) + { + } + + public void CopyTo(IHtmlContentBuilder destination) + { + } + + public void MoveTo(IHtmlContentBuilder destination) + { + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs new file mode 100644 index 0000000000..308292294c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs @@ -0,0 +1,230 @@ +// 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.TagHelpers +{ + /// + /// A collection of s. + /// + public class TagHelperAttributeList : ReadOnlyTagHelperAttributeList, IList + { + /// + /// Instantiates a new instance of with an empty collection. + /// + public TagHelperAttributeList() + : base() + { + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public TagHelperAttributeList(IEnumerable attributes) + : base (new List(attributes)) + { + if (attributes == null) + { + throw new ArgumentNullException(nameof(attributes)); + } + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public TagHelperAttributeList(List attributes) + : base(attributes) + { + if (attributes == null) + { + throw new ArgumentNullException(nameof(attributes)); + } + } + + /// + /// + /// 's must not be null. + /// + public new TagHelperAttribute this[int index] + { + get + { + return base[index]; + } + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Items[index] = value; + } + } + + /// + /// Replaces the first with matching + /// and removes any additional matching s. If a + /// matching is not found, adds a with + /// and to the end of the collection. + /// + /// The of the to set. + /// + /// + /// The to set. + /// + /// is compared case-insensitively. + public void SetAttribute(string name, object value) + { + var attribute = new TagHelperAttribute(name, value); + SetAttribute(attribute); + } + + /// + /// Replaces the first with matching + /// 's and removes any additional matching + /// s. If a matching is not found, adds the + /// specified to the end of the collection. + /// + /// + /// The to set. + /// + /// 's is compared + /// case-insensitively. + public void SetAttribute(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + var attributeReplaced = false; + + // Perf: Avoid allocating enumerator + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(attribute.Name, Items[i])) + { + // We replace the first attribute with the provided attribute, remove all the rest. + if (!attributeReplaced) + { + // We replace the first attribute we find with the same name. + Items[i] = attribute; + attributeReplaced = true; + } + else + { + Items.RemoveAt(i--); + } + } + } + + // If we didn't replace an attribute value we should add value to the end of the collection. + if (!attributeReplaced) + { + Add(attribute); + } + } + + /// + bool ICollection.IsReadOnly => false; + + /// + /// Adds a to the end of the collection with the specified + /// and . + /// + /// The of the attribute to add. + /// The of the attribute to add. + public void Add(string name, object value) + { + var attribute = new TagHelperAttribute(name, value); + Items.Add(attribute); + } + + /// + public void Add(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + Items.Add(attribute); + } + + /// + public void Insert(int index, TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + Items.Insert(index, attribute); + } + + /// + /// + /// s is compared case-insensitively. + /// + public bool Remove(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return Items.Remove(attribute); + } + + /// + public void RemoveAt(int index) + { + Items.RemoveAt(index); + } + + /// + /// Removes all s with matching + /// . + /// + /// + /// The of s to remove. + /// + /// + /// true if at least 1 was removed; otherwise, false. + /// + /// is compared case-insensitively. + public bool RemoveAll(string name) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + var removedAtLeastOne = false; + for (var i = Items.Count - 1; i >= 0; i--) + { + if (NameEquals(name, Items[i])) + { + Items.RemoveAt(i); + removedAtLeastOne = true; + } + } + + return removedAtLeastOne; + } + + /// + public void Clear() + { + Items.Clear(); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperComponent.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperComponent.cs new file mode 100644 index 0000000000..1a2c748cab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperComponent.cs @@ -0,0 +1,39 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// An abstract base class for . + /// + public abstract class TagHelperComponent : ITagHelperComponent + { + /// + /// Default order is 0. + public virtual int Order => 0; + + /// + public virtual void Init(TagHelperContext context) + { + } + + /// + /// Synchronously executes the with the given and + /// . + /// + /// Contains information associated with the current HTML tag. + /// A stateful HTML element used to generate an HTML tag. + public virtual void Process(TagHelperContext context, TagHelperOutput output) + { + } + + /// + public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + Process(context, output); + return Task.CompletedTask; + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs new file mode 100644 index 0000000000..7a6d380215 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs @@ -0,0 +1,179 @@ +// 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.Encodings.Web; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Abstract class used to buffer content returned by s. + /// + public abstract class TagHelperContent : IHtmlContentBuilder + { + /// + /// Gets a value indicating whether the content was modified. + /// + public abstract bool IsModified { get; } + + /// + /// Gets a value indicating whether the content is empty or whitespace. + /// + public abstract bool IsEmptyOrWhiteSpace { get; } + + /// + /// Sets the content. + /// + /// The that replaces the content. + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetHtmlContent(IHtmlContent htmlContent) + { + HtmlContentBuilderExtensions.SetHtmlContent(this, htmlContent); + return this; + } + + /// + /// Sets the content. + /// + /// + /// The that replaces the content. The value is assume to be unencoded + /// as-provided and will be HTML encoded before being written. + /// + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetContent(string unencoded) + { + HtmlContentBuilderExtensions.SetContent(this, unencoded); + return this; + } + + /// + /// Sets the content. + /// + /// + /// The that replaces the content. The value is assume to be HTML encoded + /// as-provided and no further encoding will be performed. + /// + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetHtmlContent(string encoded) + { + HtmlContentBuilderExtensions.SetHtmlContent(this, encoded); + return this; + } + + /// + /// Appends to the existing content. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent Append(string unencoded); + + /// + /// Appends to the existing content. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent AppendHtml(IHtmlContent htmlContent); + + /// + /// Appends to the existing content. is assumed + /// to be an HTML encoded and no further encoding will be performed. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent AppendHtml(string encoded); + + /// + /// Appends the specified to the existing content after + /// replacing each format item with the HTML encoded representation of the + /// corresponding item in the array. + /// + /// + /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). + /// + /// The object array to format. + /// A reference to this instance after the append operation has completed. + public TagHelperContent AppendFormat(string format, params object[] args) + { + HtmlContentBuilderExtensions.AppendFormat(this, null, format, args); + return this; + } + + /// + /// Appends the specified to the existing content with information from the + /// after replacing each format item with the HTML encoded + /// representation of the corresponding item in the array. + /// + /// An object that supplies culture-specific formatting information. + /// + /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). + /// + /// The object array to format. + /// A reference to this instance after the append operation has completed. + public TagHelperContent AppendFormat(IFormatProvider provider, string format, params object[] args) + { + HtmlContentBuilderExtensions.AppendFormat(this, provider, format, args); + return this; + } + + /// + /// Clears the content. + /// + /// A reference to this instance after the clear operation has completed. + public abstract TagHelperContent Clear(); + + /// + /// Clears the , so it can be reused. + /// + /// This method does more than what does. It also resets the + /// flag. + public abstract void Reinitialize(); + + /// + public abstract void CopyTo(IHtmlContentBuilder destination); + + /// + public abstract void MoveTo(IHtmlContentBuilder destination); + + /// + /// Gets the content. + /// + /// A containing the content. + public abstract string GetContent(); + + /// + /// Gets the content. + /// + /// The . + /// A containing the content. + public abstract string GetContent(HtmlEncoder encoder); + + /// + public abstract void WriteTo(TextWriter writer, HtmlEncoder encoder); + + /// + IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(IHtmlContent content) + { + return AppendHtml(content); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.Append(string unencoded) + { + return Append(unencoded); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(string encoded) + { + return AppendHtml(encoded); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.Clear() + { + return Clear(); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs new file mode 100644 index 0000000000..e09a552a0b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs @@ -0,0 +1,118 @@ +// 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.TagHelpers +{ + /// + /// Contains information related to the execution of s. + /// + public class TagHelperContext + { + private readonly TagHelperAttributeList _allAttributes; + + /// + /// Instantiates a new . + /// + /// The parsed HTML tag name of the element. + /// Every attribute associated with the current HTML element. + /// Collection of items used to communicate with other s. + /// The unique identifier for the source element this + /// applies to. + public TagHelperContext( + string tagName, + TagHelperAttributeList allAttributes, + IDictionary items, + string uniqueId) : this(allAttributes, items, uniqueId) + { + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + TagName = tagName; + } + + /// + /// Instantiates a new . + /// + /// Every attribute associated with the current HTML element. + /// Collection of items used to communicate with other s. + /// The unique identifier for the source element this + /// applies to. + public TagHelperContext( + TagHelperAttributeList allAttributes, + IDictionary items, + string uniqueId) + { + if (items == null) + { + throw new ArgumentNullException(nameof(items)); + } + + if (uniqueId == null) + { + throw new ArgumentNullException(nameof(uniqueId)); + } + + if (allAttributes == null) + { + throw new ArgumentNullException(nameof(allAttributes)); + } + + _allAttributes = allAttributes; + Items = items; + UniqueId = uniqueId; + } + + /// + /// The parsed HTML tag name of the element. + /// + public string TagName { get; private set; } + + /// + /// Every attribute associated with the current HTML element. + /// + public ReadOnlyTagHelperAttributeList AllAttributes => _allAttributes; + + /// + /// Gets the collection of items used to communicate with other s. + /// + /// + /// This is copy-on-write in order to ensure items added to this + /// collection are visible only to other s targeting child elements. + /// + public IDictionary Items { get; private set; } + + /// + /// An identifier unique to the HTML element this context is for. + /// + public string UniqueId { get; private set; } + + /// + /// Clears the and updates its state with the provided values. + /// + /// The HTML tag name to use. + /// The to use. + /// The unique id to use. + public void Reinitialize(string tagName, IDictionary items, string uniqueId) + { + TagName = tagName; + Reinitialize(items, uniqueId); + } + + /// + /// Clears the and updates its state with the provided values. + /// + /// The to use. + /// The unique id to use. + public void Reinitialize(IDictionary items, string uniqueId) + { + _allAttributes.Clear(); + Items = items; + UniqueId = uniqueId; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs new file mode 100644 index 0000000000..ed0c1e5308 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs @@ -0,0 +1,79 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public class TagHelperOutput : IHtmlContentContainer + { + public TagHelperOutput( + string tagName, + TagHelperAttributeList attributes, + Func> getChildContentAsync) + { + } + + public string TagName { get; set; } + + public TagHelperContent PreElement => null; + + public TagHelperContent PreContent => null; + + public TagHelperContent Content => null; + + public TagHelperContent PostContent => null; + + public TagHelperContent PostElement => null; + + public bool IsContentModified => true; + + public TagMode TagMode { get; set; } + + public TagHelperAttributeList Attributes { get; } + + public void Reinitialize(string tagName, TagMode tagMode) + { + } + + public void SuppressOutput() + { + } + + public Task GetChildContentAsync() + { + throw null; + } + + public Task GetChildContentAsync(bool useCachedResult) + { + throw null; + } + + public Task GetChildContentAsync(HtmlEncoder encoder) + { + throw null; + } + + public Task GetChildContentAsync(bool useCachedResult, HtmlEncoder encoder) + { + throw null; + } + + void IHtmlContentContainer.CopyTo(IHtmlContentBuilder destination) + { + } + + void IHtmlContentContainer.MoveTo(IHtmlContentBuilder destination) + { + } + + public void WriteTo(TextWriter writer, HtmlEncoder encoder) + { + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs new file mode 100644 index 0000000000..b9d60a706a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.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.TagHelpers +{ + /// + /// The mode in which an element should render. + /// + public enum TagMode + { + /// + /// Include both start and end tags. + /// + StartTagAndEndTag, + + /// + /// A self-closed tag. + /// + SelfClosing, + + /// + /// Only a start tag. + /// + StartTagOnly + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs new file mode 100644 index 0000000000..370f9372f2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.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. + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// The structure the element should be written in. + /// + public enum TagStructure + { + /// + /// If no other tag helper applies to the same element and specifies a , + /// will be used. + /// + Unspecified, + + /// + /// Element can be written as <my-tag-helper></my-tag-helper> or <my-tag-helper />. + /// + NormalOrSelfClosing, + + /// + /// Element can be written as <my-tag-helper> or <my-tag-helper />. + /// + /// Elements with a structure will never have any content. + WithoutEndTag + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.csproj index 9fa0e8c4ae..bd2e0104cc 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X/Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.csproj @@ -6,10 +6,7 @@ - - - - + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/DefaultRazorCompiledItem.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/DefaultRazorCompiledItem.cs new file mode 100644 index 0000000000..b5390b7c87 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/IRazorSourceChecksumMetadata.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/IRazorSourceChecksumMetadata.cs new file mode 100644 index 0000000000..dccdb2f871 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItem.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItem.cs new file mode 100644 index 0000000000..8eff0f4ea2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemAttribute.cs new file mode 100644 index 0000000000..8e4c003f87 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemExtensions.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemExtensions.cs new file mode 100644 index 0000000000..d6287e3253 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemMetadataAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemMetadataAttribute.cs new file mode 100644 index 0000000000..0b52fd5f1b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorCompiledItemMetadataAttribute.cs @@ -0,0 +1,35 @@ +// 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 +{ + /// + /// Defines a key/value metadata pair for the decorated Razor type. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] + public sealed class RazorCompiledItemMetadataAttribute : Attribute + { + /// + /// Creates a new . + /// + /// The key. + /// The value. + public RazorCompiledItemMetadataAttribute(string key, string value) + { + Key = key; + Value = value; + } + + /// + /// Gets the key. + /// + public string Key { get; } + + /// + /// Gets the value. + /// + public string Value { get; } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorConfigurationNameAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorConfigurationNameAttribute.cs new file mode 100644 index 0000000000..034e64c309 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorConfigurationNameAttribute.cs @@ -0,0 +1,38 @@ +// 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 name of a Razor configuration as defined by the Razor SDK. + /// + /// + /// This attribute is applied to an application's entry point assembly by the Razor SDK during the build, + /// so that the Razor configuration can be loaded at runtime based on the settings provided by the project + /// file. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class RazorConfigurationNameAttribute : Attribute + { + /// + /// Creates a new instance of . + /// + /// The name of the Razor configuration. + public RazorConfigurationNameAttribute(string configurationName) + { + if (configurationName == null) + { + throw new ArgumentNullException(nameof(configurationName)); + } + + ConfigurationName = configurationName; + } + + /// + /// Gets the name of the Razor configuration. + /// + public string ConfigurationName { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorExtensionAssemblyNameAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorExtensionAssemblyNameAttribute.cs new file mode 100644 index 0000000000..92a9d1c6ec --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorExtensionAssemblyNameAttribute.cs @@ -0,0 +1,50 @@ +// 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 name of a Razor extension as defined by the Razor SDK. + /// + /// + /// This attribute is applied to an application's entry point assembly by the Razor SDK during the build, + /// so that the Razor configuration can be loaded at runtime based on the settings provided by the project + /// file. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public sealed class RazorExtensionAssemblyNameAttribute : Attribute + { + /// + /// Creates a new instance of . + /// + /// The name of the extension. + /// The assembly name of the extension. + public RazorExtensionAssemblyNameAttribute(string extensionName, string assemblyName) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (assemblyName == null) + { + throw new ArgumentNullException(nameof(assemblyName)); + } + + ExtensionName = extensionName; + AssemblyName = assemblyName; + } + + /// + /// Gets the assembly name of the extension. + /// + public string AssemblyName { get; } + + /// + /// Gets the name of the extension. + /// + public string ExtensionName { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorLanguageVersionAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorLanguageVersionAttribute.cs new file mode 100644 index 0000000000..8f261143d0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorLanguageVersionAttribute.cs @@ -0,0 +1,38 @@ +// 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 name of a Razor configuration as defined by the Razor SDK. + /// + /// + /// This attribute is part of a set of metadata attributes that can be applied to an assembly at build + /// time by the Razor SDK. These attributes allow the Razor configuration to be loaded at runtime based + /// on the settings originally provided by the project file. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class RazorLanguageVersionAttribute : Attribute + { + /// + /// Creates a new instance of . + /// + /// The language version of Razor + public RazorLanguageVersionAttribute(string languageVersion) + { + if (languageVersion == null) + { + throw new ArgumentNullException(nameof(languageVersion)); + } + + LanguageVersion = languageVersion; + } + + /// + /// Gets the Razor language version. + /// + public string LanguageVersion { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorSourceChecksumAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Hosting/RazorSourceChecksumAttribute.cs new file mode 100644 index 0000000000..d1da25b300 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.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/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.cs new file mode 100644 index 0000000000..011d59083c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperExecutionContext.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.Diagnostics; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperExecutionContext + { + public TagHelperExecutionContext( + string tagName, + TagMode tagMode, + IDictionary items, + string uniqueId, + Func executeChildContentAsync, + Action startTagHelperWritingScope, + Func endTagHelperWritingScope) + { + } + + public bool ChildContentRetrieved => false; + + public IDictionary Items { get; private set; } + + public IList TagHelpers => null; + + public TagHelperOutput Output { get; internal set; } + + public TagHelperContext Context { get; } + + public void Add(ITagHelper tagHelper) + { + } + + public void AddHtmlAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public void AddHtmlAttribute(TagHelperAttribute attribute) + { + } + + public void AddTagHelperAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public void AddTagHelperAttribute(TagHelperAttribute attribute) + { + } + + public void Reinitialize( + string tagName, + TagMode tagMode, + IDictionary items, + string uniqueId, + Func executeChildContentAsync) + { + } + + public Task SetOutputContentAsync() + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.cs new file mode 100644 index 0000000000..21f2b5b6fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperRunner.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 System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperRunner + { + public Task RunAsync(TagHelperExecutionContext executionContext) + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.cs new file mode 100644 index 0000000000..70f072bbc4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Runtime.TagHelpers/TagHelperScopeManager.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 System; +using System.Collections.Generic; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers +{ + public class TagHelperScopeManager + { + public TagHelperScopeManager( + Action startTagHelperWritingScope, + Func endTagHelperWritingScope) + { + } + + public TagHelperExecutionContext Begin( + string tagName, + TagMode tagMode, + string uniqueId, + Func executeChildContentAsync) + { + throw null; + } + + public TagHelperExecutionContext End() + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs new file mode 100644 index 0000000000..aca16610b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNameAttribute.cs @@ -0,0 +1,92 @@ +// 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.TagHelpers +{ + /// + /// Used to override an property's HTML attribute name. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class HtmlAttributeNameAttribute : Attribute + { + private string _dictionaryAttributePrefix; + + /// + /// Instantiates a new instance of the class with + /// equal to null. + /// + /// + /// Associated property must not have a public setter and must be compatible with + /// where TKey is + /// . + /// + public HtmlAttributeNameAttribute() + { + } + + /// + /// Instantiates a new instance of the class. + /// + /// + /// HTML attribute name for the associated property. Must be null or empty if associated property does + /// not have a public setter and is compatible with + /// where TKey is + /// . Otherwise must not be null or empty. + /// + public HtmlAttributeNameAttribute(string name) + { + Name = name; + } + + /// + /// HTML attribute name of the associated property. + /// + /// + /// null or empty if and only if associated property does not have a public setter and is compatible + /// with where TKey is + /// . + /// + public string Name { get; } + + /// + /// Gets or sets the prefix used to match HTML attribute names. Matching attributes are added to the + /// associated property (an ). + /// + /// + /// If non-null associated property must be compatible with + /// where TKey is + /// . + /// + /// + /// + /// If associated property is compatible with + /// , default value is Name + "-". + /// must not be null or empty in this case. + /// + /// + /// Otherwise default value is null. + /// + /// + public string DictionaryAttributePrefix + { + get + { + return _dictionaryAttributePrefix; + } + set + { + _dictionaryAttributePrefix = value; + DictionaryAttributePrefixSet = true; + } + } + + /// + /// Gets an indication whether has been set. Used to distinguish an + /// uninitialized value from an explicit null setting. + /// + /// true if was set. false otherwise. + public bool DictionaryAttributePrefixSet { get; private set; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.cs new file mode 100644 index 0000000000..9d23480abd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeNotBoundAttribute.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; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Indicates the associated property should not be bound to HTML attributes. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class HtmlAttributeNotBoundAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + public HtmlAttributeNotBoundAttribute() + { + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.cs new file mode 100644 index 0000000000..7ac198567f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlAttributeValueStyle.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. + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public enum HtmlAttributeValueStyle + { + DoubleQuotes, + SingleQuotes, + NoQuotes, + Minimized, + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.cs new file mode 100644 index 0000000000..857d6a0e5d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/HtmlTargetElementAttribute.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; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Provides an 's target. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] + public sealed class HtmlTargetElementAttribute : Attribute + { + public const string ElementCatchAllTarget = "*"; + + /// + /// Instantiates a new instance of the class that targets all HTML + /// elements with the required . + /// + /// is set to *. + public HtmlTargetElementAttribute() + : this(ElementCatchAllTarget) + { + } + + /// + /// Instantiates a new instance of the class with the given + /// as its value. + /// + /// + /// The HTML tag the targets. + /// + /// A * value indicates this + /// targets all HTML elements with the required . + public HtmlTargetElementAttribute(string tag) + { + Tag = tag; + } + + /// + /// The HTML tag the targets. A * value indicates this + /// targets all HTML elements with the required . + /// + public string Tag { get; } + + /// + /// A comma-separated of attribute selectors the HTML element must match for the + /// to run. * at the end of an attribute name acts as a prefix match. A value + /// surrounded by square brackets is handled as a CSS attribute value selector. Operators ^=, $= and + /// = are supported e.g. "name", "[name]", "[name=value]", "[ name ^= 'value' ]". + /// + public string Attributes { get; set; } + + /// + /// The expected tag structure. Defaults to . + /// + /// + /// If and no other tag helpers applying to the same element specify + /// their the behavior is used: + /// + /// + /// <my-tag-helper></my-tag-helper> + /// <!-- OR --> + /// <my-tag-helper /> + /// + /// Otherwise, if another tag helper applying to the same element does specify their behavior, that behavior + /// is used. + /// + /// + /// If HTML elements can be written in the following formats: + /// + /// <my-tag-helper> + /// <!-- OR --> + /// <my-tag-helper /> + /// + /// + /// + public TagStructure TagStructure { get; set; } + + /// + /// The required HTML element name of the direct parent. A null value indicates any HTML element name is + /// allowed. + /// + public string ParentTag { get; set; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.cs new file mode 100644 index 0000000000..ec86a32a11 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelper.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. + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Contract used to filter matching HTML elements. + /// Marker interface for s. + /// + public interface ITagHelper : ITagHelperComponent + { + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelperComponent.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelperComponent.cs new file mode 100644 index 0000000000..3b2059be51 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ITagHelperComponent.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.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Contract used to modify an HTML element. + /// + public interface ITagHelperComponent + { + /// + /// When a set of s are executed, their 's + /// are first invoked in the specified ; then their + /// 's are invoked in the specified + /// . Lower values are executed first. + /// + int Order { get; } + + /// + /// Initializes the with the given . Additions to + /// should be done within this method to ensure they're added prior to + /// executing the children. + /// + /// Contains information associated with the current HTML tag. + /// When more than one runs on the same element, + /// may be invoked prior to . + /// + void Init(TagHelperContext context); + + /// + /// Asynchronously executes the with the given and + /// . + /// + /// Contains information associated with the current HTML tag. + /// A stateful HTML element used to generate an HTML tag. + /// A that on completion updates the . + Task ProcessAsync(TagHelperContext context, TagHelperOutput output); + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs new file mode 100644 index 0000000000..a97b5ef9ab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/OutputElementHintAttribute.cs @@ -0,0 +1,35 @@ +// 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.TagHelpers +{ + /// + /// Provides a hint of the 's output element. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public sealed class OutputElementHintAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + /// + /// The HTML element the may output. + /// + public OutputElementHintAttribute(string outputElement) + { + if (outputElement == null) + { + throw new ArgumentNullException(nameof(outputElement)); + } + + OutputElement = outputElement; + } + + /// + /// The HTML element the may output. + /// + public string OutputElement { get; } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs new file mode 100644 index 0000000000..f3d1569a59 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/ReadOnlyTagHelperAttributeList.cs @@ -0,0 +1,190 @@ +// 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.ObjectModel; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// A read-only collection of s. + /// + public abstract class ReadOnlyTagHelperAttributeList : ReadOnlyCollection + { + private static readonly IReadOnlyList EmptyList = new TagHelperAttribute[0]; + + /// + /// Instantiates a new instance of with an empty + /// collection. + /// + protected ReadOnlyTagHelperAttributeList() + : base(new List()) + { + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public ReadOnlyTagHelperAttributeList(IList attributes) + : base(attributes) + { + } + + /// + /// Gets the first with + /// matching . + /// + /// + /// The of the to get. + /// + /// The first with + /// matching . + /// + /// is compared case-insensitively. + public TagHelperAttribute this[string name] + { + get + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + return Items[i]; + } + } + + return null; + } + } + + /// + /// Determines whether a with + /// matching exists in the collection. + /// + /// The of the + /// to get. + /// + /// true if a with the same + /// exists in the collection; otherwise, false. + /// + /// is compared case-insensitively. + public bool ContainsName(string name) + { + return this[name] != null; + } + + /// + /// Retrieves the first with + /// matching . + /// + /// The of the + /// to get. + /// When this method returns, the first with + /// matching , if found; otherwise, + /// null. + /// true if a with the same + /// exists in the collection; otherwise, false. + /// is compared case-insensitively. + public bool TryGetAttribute(string name, out TagHelperAttribute attribute) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + attribute = this[name]; + + return attribute != null; + } + + /// + /// Retrieves s in the collection with + /// matching . + /// + /// The of the + /// s to get. + /// When this method returns, the s with + /// matching . + /// true if at least one with the same + /// exists in the collection; otherwise, false. + /// is compared case-insensitively. + public bool TryGetAttributes(string name, out IReadOnlyList attributes) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + List matchedAttributes = null; + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + if (matchedAttributes == null) + { + matchedAttributes = new List(); + } + + matchedAttributes.Add(Items[i]); + } + } + attributes = matchedAttributes ?? EmptyList; + + return matchedAttributes != null; + } + + /// + /// Searches for a who's + /// case-insensitively matches and returns the zero-based index of the first + /// occurrence. + /// + /// The to locate in the collection. + /// The zero-based index of the first matching within the collection, + /// if found; otherwise, -1. + public int IndexOfName(string name) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(name, Items[i])) + { + return i; + } + } + + return -1; + } + + /// + /// Determines if the specified has the same name as . + /// + /// The value to compare against s + /// . + /// The attribute to compare against. + /// true if case-insensitively matches s + /// . + protected static bool NameEquals(string name, TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return string.Equals(name, attribute.Name, StringComparison.OrdinalIgnoreCase); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs new file mode 100644 index 0000000000..bc4f6bac35 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/RestrictChildrenAttribute.cs @@ -0,0 +1,42 @@ +// 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.TagHelpers +{ + /// + /// Restricts children of the 's element. + /// + /// Combining this attribute with a that specifies its + /// as will result + /// in this attribute being ignored. + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RestrictChildrenAttribute : Attribute + { + /// + /// Instantiates a new instance of the class. + /// + /// + /// The tag name of an element allowed as a child. + /// + /// + /// Additional names of elements allowed as children. + /// + public RestrictChildrenAttribute(string childTag, params string[] childTags) + { + var concatenatedNames = new string[1 + childTags.Length]; + concatenatedNames[0] = childTag; + + childTags.CopyTo(concatenatedNames, 1); + + ChildTags = concatenatedNames; + } + + /// + /// Get the names of elements allowed as children. + /// + public IEnumerable ChildTags { get; } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.cs new file mode 100644 index 0000000000..ed9faca1bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelper.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.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public abstract class TagHelper : ITagHelper + { + public virtual int Order { get; } = 0; + + public virtual void Init(TagHelperContext context) + { + } + + public virtual void Process(TagHelperContext context, TagHelperOutput output) + { + } + + public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + Process(context, output); + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs new file mode 100644 index 0000000000..7bdd2aea22 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttribute.cs @@ -0,0 +1,43 @@ +// 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.Encodings.Web; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public class TagHelperAttribute : IHtmlContentContainer + { + public TagHelperAttribute(string name) + { + } + + public TagHelperAttribute(string name, object value) + { + } + + public TagHelperAttribute(string name, object value, HtmlAttributeValueStyle valueStyle) + { + } + + public string Name { get; } + + public object Value { get; } + + public HtmlAttributeValueStyle ValueStyle { get; } + + public void WriteTo(TextWriter writer, HtmlEncoder encoder) + { + } + + public void CopyTo(IHtmlContentBuilder destination) + { + } + + public void MoveTo(IHtmlContentBuilder destination) + { + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs new file mode 100644 index 0000000000..308292294c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperAttributeList.cs @@ -0,0 +1,230 @@ +// 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.TagHelpers +{ + /// + /// A collection of s. + /// + public class TagHelperAttributeList : ReadOnlyTagHelperAttributeList, IList + { + /// + /// Instantiates a new instance of with an empty collection. + /// + public TagHelperAttributeList() + : base() + { + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public TagHelperAttributeList(IEnumerable attributes) + : base (new List(attributes)) + { + if (attributes == null) + { + throw new ArgumentNullException(nameof(attributes)); + } + } + + /// + /// Instantiates a new instance of with the specified + /// . + /// + /// The collection to wrap. + public TagHelperAttributeList(List attributes) + : base(attributes) + { + if (attributes == null) + { + throw new ArgumentNullException(nameof(attributes)); + } + } + + /// + /// + /// 's must not be null. + /// + public new TagHelperAttribute this[int index] + { + get + { + return base[index]; + } + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Items[index] = value; + } + } + + /// + /// Replaces the first with matching + /// and removes any additional matching s. If a + /// matching is not found, adds a with + /// and to the end of the collection. + /// + /// The of the to set. + /// + /// + /// The to set. + /// + /// is compared case-insensitively. + public void SetAttribute(string name, object value) + { + var attribute = new TagHelperAttribute(name, value); + SetAttribute(attribute); + } + + /// + /// Replaces the first with matching + /// 's and removes any additional matching + /// s. If a matching is not found, adds the + /// specified to the end of the collection. + /// + /// + /// The to set. + /// + /// 's is compared + /// case-insensitively. + public void SetAttribute(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + var attributeReplaced = false; + + // Perf: Avoid allocating enumerator + for (var i = 0; i < Items.Count; i++) + { + if (NameEquals(attribute.Name, Items[i])) + { + // We replace the first attribute with the provided attribute, remove all the rest. + if (!attributeReplaced) + { + // We replace the first attribute we find with the same name. + Items[i] = attribute; + attributeReplaced = true; + } + else + { + Items.RemoveAt(i--); + } + } + } + + // If we didn't replace an attribute value we should add value to the end of the collection. + if (!attributeReplaced) + { + Add(attribute); + } + } + + /// + bool ICollection.IsReadOnly => false; + + /// + /// Adds a to the end of the collection with the specified + /// and . + /// + /// The of the attribute to add. + /// The of the attribute to add. + public void Add(string name, object value) + { + var attribute = new TagHelperAttribute(name, value); + Items.Add(attribute); + } + + /// + public void Add(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + Items.Add(attribute); + } + + /// + public void Insert(int index, TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + Items.Insert(index, attribute); + } + + /// + /// + /// s is compared case-insensitively. + /// + public bool Remove(TagHelperAttribute attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return Items.Remove(attribute); + } + + /// + public void RemoveAt(int index) + { + Items.RemoveAt(index); + } + + /// + /// Removes all s with matching + /// . + /// + /// + /// The of s to remove. + /// + /// + /// true if at least 1 was removed; otherwise, false. + /// + /// is compared case-insensitively. + public bool RemoveAll(string name) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + // Perf: Avoid allocating enumerator + var removedAtLeastOne = false; + for (var i = Items.Count - 1; i >= 0; i--) + { + if (NameEquals(name, Items[i])) + { + Items.RemoveAt(i); + removedAtLeastOne = true; + } + } + + return removedAtLeastOne; + } + + /// + public void Clear() + { + Items.Clear(); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperComponent.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperComponent.cs new file mode 100644 index 0000000000..1a2c748cab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperComponent.cs @@ -0,0 +1,39 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// An abstract base class for . + /// + public abstract class TagHelperComponent : ITagHelperComponent + { + /// + /// Default order is 0. + public virtual int Order => 0; + + /// + public virtual void Init(TagHelperContext context) + { + } + + /// + /// Synchronously executes the with the given and + /// . + /// + /// Contains information associated with the current HTML tag. + /// A stateful HTML element used to generate an HTML tag. + public virtual void Process(TagHelperContext context, TagHelperOutput output) + { + } + + /// + public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + Process(context, output); + return Task.CompletedTask; + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs new file mode 100644 index 0000000000..7a6d380215 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContent.cs @@ -0,0 +1,179 @@ +// 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.Encodings.Web; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Abstract class used to buffer content returned by s. + /// + public abstract class TagHelperContent : IHtmlContentBuilder + { + /// + /// Gets a value indicating whether the content was modified. + /// + public abstract bool IsModified { get; } + + /// + /// Gets a value indicating whether the content is empty or whitespace. + /// + public abstract bool IsEmptyOrWhiteSpace { get; } + + /// + /// Sets the content. + /// + /// The that replaces the content. + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetHtmlContent(IHtmlContent htmlContent) + { + HtmlContentBuilderExtensions.SetHtmlContent(this, htmlContent); + return this; + } + + /// + /// Sets the content. + /// + /// + /// The that replaces the content. The value is assume to be unencoded + /// as-provided and will be HTML encoded before being written. + /// + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetContent(string unencoded) + { + HtmlContentBuilderExtensions.SetContent(this, unencoded); + return this; + } + + /// + /// Sets the content. + /// + /// + /// The that replaces the content. The value is assume to be HTML encoded + /// as-provided and no further encoding will be performed. + /// + /// A reference to this instance after the set operation has completed. + public TagHelperContent SetHtmlContent(string encoded) + { + HtmlContentBuilderExtensions.SetHtmlContent(this, encoded); + return this; + } + + /// + /// Appends to the existing content. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent Append(string unencoded); + + /// + /// Appends to the existing content. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent AppendHtml(IHtmlContent htmlContent); + + /// + /// Appends to the existing content. is assumed + /// to be an HTML encoded and no further encoding will be performed. + /// + /// The to be appended. + /// A reference to this instance after the append operation has completed. + public abstract TagHelperContent AppendHtml(string encoded); + + /// + /// Appends the specified to the existing content after + /// replacing each format item with the HTML encoded representation of the + /// corresponding item in the array. + /// + /// + /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). + /// + /// The object array to format. + /// A reference to this instance after the append operation has completed. + public TagHelperContent AppendFormat(string format, params object[] args) + { + HtmlContentBuilderExtensions.AppendFormat(this, null, format, args); + return this; + } + + /// + /// Appends the specified to the existing content with information from the + /// after replacing each format item with the HTML encoded + /// representation of the corresponding item in the array. + /// + /// An object that supplies culture-specific formatting information. + /// + /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). + /// + /// The object array to format. + /// A reference to this instance after the append operation has completed. + public TagHelperContent AppendFormat(IFormatProvider provider, string format, params object[] args) + { + HtmlContentBuilderExtensions.AppendFormat(this, provider, format, args); + return this; + } + + /// + /// Clears the content. + /// + /// A reference to this instance after the clear operation has completed. + public abstract TagHelperContent Clear(); + + /// + /// Clears the , so it can be reused. + /// + /// This method does more than what does. It also resets the + /// flag. + public abstract void Reinitialize(); + + /// + public abstract void CopyTo(IHtmlContentBuilder destination); + + /// + public abstract void MoveTo(IHtmlContentBuilder destination); + + /// + /// Gets the content. + /// + /// A containing the content. + public abstract string GetContent(); + + /// + /// Gets the content. + /// + /// The . + /// A containing the content. + public abstract string GetContent(HtmlEncoder encoder); + + /// + public abstract void WriteTo(TextWriter writer, HtmlEncoder encoder); + + /// + IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(IHtmlContent content) + { + return AppendHtml(content); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.Append(string unencoded) + { + return Append(unencoded); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(string encoded) + { + return AppendHtml(encoded); + } + + /// + IHtmlContentBuilder IHtmlContentBuilder.Clear() + { + return Clear(); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs new file mode 100644 index 0000000000..e09a552a0b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperContext.cs @@ -0,0 +1,118 @@ +// 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.TagHelpers +{ + /// + /// Contains information related to the execution of s. + /// + public class TagHelperContext + { + private readonly TagHelperAttributeList _allAttributes; + + /// + /// Instantiates a new . + /// + /// The parsed HTML tag name of the element. + /// Every attribute associated with the current HTML element. + /// Collection of items used to communicate with other s. + /// The unique identifier for the source element this + /// applies to. + public TagHelperContext( + string tagName, + TagHelperAttributeList allAttributes, + IDictionary items, + string uniqueId) : this(allAttributes, items, uniqueId) + { + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + TagName = tagName; + } + + /// + /// Instantiates a new . + /// + /// Every attribute associated with the current HTML element. + /// Collection of items used to communicate with other s. + /// The unique identifier for the source element this + /// applies to. + public TagHelperContext( + TagHelperAttributeList allAttributes, + IDictionary items, + string uniqueId) + { + if (items == null) + { + throw new ArgumentNullException(nameof(items)); + } + + if (uniqueId == null) + { + throw new ArgumentNullException(nameof(uniqueId)); + } + + if (allAttributes == null) + { + throw new ArgumentNullException(nameof(allAttributes)); + } + + _allAttributes = allAttributes; + Items = items; + UniqueId = uniqueId; + } + + /// + /// The parsed HTML tag name of the element. + /// + public string TagName { get; private set; } + + /// + /// Every attribute associated with the current HTML element. + /// + public ReadOnlyTagHelperAttributeList AllAttributes => _allAttributes; + + /// + /// Gets the collection of items used to communicate with other s. + /// + /// + /// This is copy-on-write in order to ensure items added to this + /// collection are visible only to other s targeting child elements. + /// + public IDictionary Items { get; private set; } + + /// + /// An identifier unique to the HTML element this context is for. + /// + public string UniqueId { get; private set; } + + /// + /// Clears the and updates its state with the provided values. + /// + /// The HTML tag name to use. + /// The to use. + /// The unique id to use. + public void Reinitialize(string tagName, IDictionary items, string uniqueId) + { + TagName = tagName; + Reinitialize(items, uniqueId); + } + + /// + /// Clears the and updates its state with the provided values. + /// + /// The to use. + /// The unique id to use. + public void Reinitialize(IDictionary items, string uniqueId) + { + _allAttributes.Clear(); + Items = items; + UniqueId = uniqueId; + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs new file mode 100644 index 0000000000..ed0c1e5308 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagHelperOutput.cs @@ -0,0 +1,79 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Html; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + public class TagHelperOutput : IHtmlContentContainer + { + public TagHelperOutput( + string tagName, + TagHelperAttributeList attributes, + Func> getChildContentAsync) + { + } + + public string TagName { get; set; } + + public TagHelperContent PreElement => null; + + public TagHelperContent PreContent => null; + + public TagHelperContent Content => null; + + public TagHelperContent PostContent => null; + + public TagHelperContent PostElement => null; + + public bool IsContentModified => true; + + public TagMode TagMode { get; set; } + + public TagHelperAttributeList Attributes { get; } + + public void Reinitialize(string tagName, TagMode tagMode) + { + } + + public void SuppressOutput() + { + } + + public Task GetChildContentAsync() + { + throw null; + } + + public Task GetChildContentAsync(bool useCachedResult) + { + throw null; + } + + public Task GetChildContentAsync(HtmlEncoder encoder) + { + throw null; + } + + public Task GetChildContentAsync(bool useCachedResult, HtmlEncoder encoder) + { + throw null; + } + + void IHtmlContentContainer.CopyTo(IHtmlContentBuilder destination) + { + } + + void IHtmlContentContainer.MoveTo(IHtmlContentBuilder destination) + { + } + + public void WriteTo(TextWriter writer, HtmlEncoder encoder) + { + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.cs new file mode 100644 index 0000000000..b9d60a706a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagMode.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.TagHelpers +{ + /// + /// The mode in which an element should render. + /// + public enum TagMode + { + /// + /// Include both start and end tags. + /// + StartTagAndEndTag, + + /// + /// A self-closed tag. + /// + SelfClosing, + + /// + /// Only a start tag. + /// + StartTagOnly + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.cs new file mode 100644 index 0000000000..370f9372f2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.TagHelpers/TagStructure.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. + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// The structure the element should be written in. + /// + public enum TagStructure + { + /// + /// If no other tag helper applies to the same element and specifies a , + /// will be used. + /// + Unspecified, + + /// + /// Element can be written as <my-tag-helper></my-tag-helper> or <my-tag-helper />. + /// + NormalOrSelfClosing, + + /// + /// Element can be written as <my-tag-helper> or <my-tag-helper />. + /// + /// Elements with a structure will never have any content. + WithoutEndTag + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj index 9fa0e8c4ae..bd2e0104cc 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj @@ -6,10 +6,7 @@ - - - - + diff --git a/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj b/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj index 5fe34308bc..550e8fa2d7 100644 --- a/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj +++ b/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj @@ -22,13 +22,10 @@ - - - diff --git a/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj b/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj index 3325932c1e..9b38b6b7f6 100644 --- a/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj +++ b/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj @@ -25,13 +25,10 @@ - - - diff --git a/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj b/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj index 4337c0f72c..b13a9c8071 100644 --- a/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj +++ b/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj @@ -24,13 +24,10 @@ - - - diff --git a/src/Razor/test/testassets/LargeProject/LargeProject.csproj b/src/Razor/test/testassets/LargeProject/LargeProject.csproj index 0d61cb941b..a4b035712a 100644 --- a/src/Razor/test/testassets/LargeProject/LargeProject.csproj +++ b/src/Razor/test/testassets/LargeProject/LargeProject.csproj @@ -16,13 +16,10 @@ - - - diff --git a/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj b/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj index 723b5fa1d1..23d69bef39 100644 --- a/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj +++ b/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj @@ -16,13 +16,10 @@ - - - diff --git a/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj b/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj index 0b62bda87c..275ae61610 100644 --- a/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj +++ b/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj @@ -16,13 +16,10 @@ - - - diff --git a/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj b/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj index 3e409f1d78..5264c82b76 100644 --- a/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj +++ b/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj @@ -21,13 +21,10 @@ - - - diff --git a/src/Razor/test/testassets/SimplePages/SimplePages.csproj b/src/Razor/test/testassets/SimplePages/SimplePages.csproj index 304df87d0e..d131016beb 100644 --- a/src/Razor/test/testassets/SimplePages/SimplePages.csproj +++ b/src/Razor/test/testassets/SimplePages/SimplePages.csproj @@ -16,13 +16,10 @@ - - -