зеркало из https://github.com/dotnet/razor.git
Remove Razor Runtime projects
This commit is contained in:
Родитель
a6dc88e455
Коммит
39472ca0d6
|
@ -10,18 +10,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{92463391-81BE-462B-AC3C-78C6C760741F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor", "src\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj", "{EDA30434-C567-44DC-B8B6-2566A7F77163}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime", "src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj", "{D0196096-1B01-4133-AACE-1A10A0F7247C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageGenerator", "src\RazorPageGenerator\RazorPageGenerator.csproj", "{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language", "src\Microsoft.AspNetCore.Razor.Language\Microsoft.AspNetCore.Razor.Language.csproj", "{932F3C9C-A6C0-40D3-BA50-9309886242FC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language.Test", "test\Microsoft.AspNetCore.Razor.Language.Test\Microsoft.AspNetCore.Razor.Language.Test.csproj", "{969357A4-CCF1-46D9-B002-9AA072AFC75C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime.Test", "test\Microsoft.AspNetCore.Razor.Runtime.Test\Microsoft.AspNetCore.Razor.Runtime.Test.csproj", "{277AB67E-9C8D-4799-A18C-C628E70A8664}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces", "src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj", "{0F265874-C592-448B-BC4F-3430AB03E0DC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.Razor", "src\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj", "{4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}"
|
||||
|
@ -64,8 +58,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.Razor.Test", "test\Microsoft.NET.Sdk.Razor.Test\Microsoft.NET.Sdk.Razor.Test.csproj", "{1D90F276-E1CA-4FDF-A173-EB889E7D3150}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test", "test\Microsoft.AspNetCore.Razor.Test\Microsoft.AspNetCore.Razor.Test.csproj", "{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "benchmarks\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{6205467F-E381-4C42-AEEC-763BD62B3D5E}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{C2C98051-0F39-47F2-80B6-E72B29159F2C}"
|
||||
|
@ -94,14 +86,6 @@ Global
|
|||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -114,10 +98,6 @@ Global
|
|||
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0F265874-C592-448B-BC4F-3430AB03E0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0F265874-C592-448B-BC4F-3430AB03E0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0F265874-C592-448B-BC4F-3430AB03E0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -202,10 +182,6 @@ Global
|
|||
{1D90F276-E1CA-4FDF-A173-EB889E7D3150}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D90F276-E1CA-4FDF-A173-EB889E7D3150}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D90F276-E1CA-4FDF-A173-EB889E7D3150}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -251,12 +227,9 @@ Global
|
|||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{932F3C9C-A6C0-40D3-BA50-9309886242FC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{969357A4-CCF1-46D9-B002-9AA072AFC75C} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{0F265874-C592-448B-BC4F-3430AB03E0DC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{42403DAF-F0BC-4F3A-B7F2-46D7013345D8} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
|
@ -278,7 +251,6 @@ Global
|
|||
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{1D90F276-E1CA-4FDF-A173-EB889E7D3150} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{6205467F-E381-4C42-AEEC-763BD62B3D5E} = {C2C98051-0F39-47F2-80B6-E72B29159F2C}
|
||||
{933101DA-C4CC-401A-AA01-2784E1025B7F} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{3E7F2D49-3B45-45A8-9893-F73EC1EEBAAB} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
|
|
|
@ -10,18 +10,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{92463391-81BE-462B-AC3C-78C6C760741F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor", "src\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj", "{EDA30434-C567-44DC-B8B6-2566A7F77163}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime", "src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj", "{D0196096-1B01-4133-AACE-1A10A0F7247C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageGenerator", "src\RazorPageGenerator\RazorPageGenerator.csproj", "{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language", "src\Microsoft.AspNetCore.Razor.Language\Microsoft.AspNetCore.Razor.Language.csproj", "{932F3C9C-A6C0-40D3-BA50-9309886242FC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language.Test", "test\Microsoft.AspNetCore.Razor.Language.Test\Microsoft.AspNetCore.Razor.Language.Test.csproj", "{969357A4-CCF1-46D9-B002-9AA072AFC75C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime.Test", "test\Microsoft.AspNetCore.Razor.Runtime.Test\Microsoft.AspNetCore.Razor.Runtime.Test.csproj", "{277AB67E-9C8D-4799-A18C-C628E70A8664}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces", "src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj", "{0F265874-C592-448B-BC4F-3430AB03E0DC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.Razor", "src\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj", "{4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}"
|
||||
|
@ -64,8 +58,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.Razor.Test", "test\Microsoft.NET.Sdk.Razor.Test\Microsoft.NET.Sdk.Razor.Test.csproj", "{1D90F276-E1CA-4FDF-A173-EB889E7D3150}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test", "test\Microsoft.AspNetCore.Razor.Test\Microsoft.AspNetCore.Razor.Test.csproj", "{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Performance", "benchmarks\Microsoft.AspNetCore.Razor.Performance\Microsoft.AspNetCore.Razor.Performance.csproj", "{6205467F-E381-4C42-AEEC-763BD62B3D5E}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{C2C98051-0F39-47F2-80B6-E72B29159F2C}"
|
||||
|
@ -100,22 +92,6 @@ Global
|
|||
ReleaseNoVSIX|Any CPU = ReleaseNoVSIX|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
|
@ -140,14 +116,6 @@ Global
|
|||
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{0F265874-C592-448B-BC4F-3430AB03E0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0F265874-C592-448B-BC4F-3430AB03E0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0F265874-C592-448B-BC4F-3430AB03E0DC}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
|
@ -316,14 +284,6 @@ Global
|
|||
{1D90F276-E1CA-4FDF-A173-EB889E7D3150}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D90F276-E1CA-4FDF-A173-EB889E7D3150}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D90F276-E1CA-4FDF-A173-EB889E7D3150}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
|
@ -425,12 +385,9 @@ Global
|
|||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{EDA30434-C567-44DC-B8B6-2566A7F77163} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{D0196096-1B01-4133-AACE-1A10A0F7247C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{932F3C9C-A6C0-40D3-BA50-9309886242FC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{969357A4-CCF1-46D9-B002-9AA072AFC75C} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{277AB67E-9C8D-4799-A18C-C628E70A8664} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{0F265874-C592-448B-BC4F-3430AB03E0DC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{42403DAF-F0BC-4F3A-B7F2-46D7013345D8} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
|
@ -452,7 +409,6 @@ Global
|
|||
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{1D90F276-E1CA-4FDF-A173-EB889E7D3150} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{323553F0-14AB-4FBD-9CF0-1CC0BE8056F8} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{6205467F-E381-4C42-AEEC-763BD62B3D5E} = {C2C98051-0F39-47F2-80B6-E72B29159F2C}
|
||||
{933101DA-C4CC-401A-AA01-2784E1025B7F} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{3E7F2D49-3B45-45A8-9893-F73EC1EEBAAB} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// A loader implementation that can load <see cref="RazorCompiledItem"/> objects from an
|
||||
/// <see cref="Assembly"/> using reflection.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Inherit from <see cref="RazorCompiledItemLoader"/> to customize the behavior when loading
|
||||
/// <see cref="RazorCompiledItem"/> objects from an <see cref="Assembly"/>. The default implementations of methods
|
||||
/// defined by this class use reflection in a trivial way to load attributes from the assembly.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Inheriting from <see cref="RazorCompiledItemLoader"/> is useful when an implementation needs to consider
|
||||
/// additional configuration or data outside of the <see cref="Assembly"/> being loaded.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Subclasses of <see cref="RazorCompiledItemLoader"/> can return subclasses of <see cref="RazorCompiledItem"/>
|
||||
/// with additional data members by overriding <see cref="CreateItem(RazorCompiledItemAttribute)"/>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public class RazorCompiledItemLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads a list of <see cref="RazorCompiledItem"/> objects from the provided <see cref="Assembly"/>.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The assembly to search.</param>
|
||||
/// <returns>A list of <see cref="RazorCompiledItem"/> objects.</returns>
|
||||
public virtual IReadOnlyList<RazorCompiledItem> LoadItems(Assembly assembly)
|
||||
{
|
||||
if (assembly == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(assembly));
|
||||
}
|
||||
|
||||
var items = new List<RazorCompiledItem>();
|
||||
foreach (var attribute in LoadAttributes(assembly))
|
||||
{
|
||||
items.Add(CreateItem(attribute));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="RazorCompiledItem"/> from a <see cref="RazorCompiledItemAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="attribute">The <see cref="RazorCompiledItemAttribute"/>.</param>
|
||||
/// <returns>A <see cref="RazorCompiledItem"/> created from <paramref name="attribute"/>.</returns>
|
||||
protected virtual RazorCompiledItem CreateItem(RazorCompiledItemAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
return new DefaultRazorCompiledItem(attribute.Type, attribute.Kind, attribute.Identifier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the list of <see cref="RazorCompiledItemAttribute"/> attributes defined for the provided
|
||||
/// <see cref="Assembly"/>.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The <see cref="Assembly"/> to search.</param>
|
||||
/// <returns>A list of <see cref="RazorCompiledItemAttribute"/> attributes.</returns>
|
||||
protected IEnumerable<RazorCompiledItemAttribute> LoadAttributes(Assembly assembly)
|
||||
{
|
||||
if (assembly == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(assembly));
|
||||
}
|
||||
|
||||
return assembly.GetCustomAttributes<RazorCompiledItemAttribute>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>Runtime infrastructure for rendering Razor pages and tag helpers.</Description>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageTags>$(PackageTags);taghelper;taghelpers</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="$(MicrosoftAspNetCoreHtmlAbstractionsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.CopyOnWriteDictionary.Sources" PrivateAssets="All" Version="$(MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Runtime.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
|
||||
[assembly: TypeForwardedTo(typeof(DefaultTagHelperContent))]
|
||||
[assembly: TypeForwardedTo(typeof(HtmlAttributeNameAttribute))]
|
||||
[assembly: TypeForwardedTo(typeof(HtmlAttributeNotBoundAttribute))]
|
||||
[assembly: TypeForwardedTo(typeof(HtmlTargetElementAttribute))]
|
||||
[assembly: TypeForwardedTo(typeof(ITagHelper))]
|
||||
[assembly: TypeForwardedTo(typeof(ITagHelperComponent))]
|
||||
[assembly: TypeForwardedTo(typeof(NullHtmlEncoder))]
|
||||
[assembly: TypeForwardedTo(typeof(OutputElementHintAttribute))]
|
||||
[assembly: TypeForwardedTo(typeof(ReadOnlyTagHelperAttributeList))]
|
||||
[assembly: TypeForwardedTo(typeof(RestrictChildrenAttribute))]
|
||||
[assembly: TypeForwardedTo(typeof(TagHelper))]
|
||||
[assembly: TypeForwardedTo(typeof(TagHelperAttribute))]
|
||||
[assembly: TypeForwardedTo(typeof(TagHelperAttributeList))]
|
||||
[assembly: TypeForwardedTo(typeof(TagHelperComponent))]
|
||||
[assembly: TypeForwardedTo(typeof(TagHelperContent))]
|
||||
[assembly: TypeForwardedTo(typeof(TagHelperContext))]
|
||||
[assembly: TypeForwardedTo(typeof(TagHelperOutput))]
|
|
@ -1,44 +0,0 @@
|
|||
// <auto-generated />
|
||||
namespace Microsoft.AspNetCore.Razor.Runtime
|
||||
{
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
internal static class Resources
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("Microsoft.AspNetCore.Razor.Runtime.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
|
||||
/// <summary>
|
||||
/// Must call '{2}.{1}' before calling '{2}.{0}'.
|
||||
/// </summary>
|
||||
internal static string ScopeManager_EndCannotBeCalledWithoutACallToBegin
|
||||
{
|
||||
get => GetString("ScopeManager_EndCannotBeCalledWithoutACallToBegin");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Must call '{2}.{1}' before calling '{2}.{0}'.
|
||||
/// </summary>
|
||||
internal static string FormatScopeManager_EndCannotBeCalledWithoutACallToBegin(object p0, object p1, object p2)
|
||||
=> string.Format(CultureInfo.CurrentCulture, GetString("ScopeManager_EndCannotBeCalledWithoutACallToBegin"), p0, p1, p2);
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
||||
System.Diagnostics.Debug.Assert(value != null);
|
||||
|
||||
if (formatterNames != null)
|
||||
{
|
||||
for (var i = 0; i < formatterNames.Length; i++)
|
||||
{
|
||||
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ScopeManager_EndCannotBeCalledWithoutACallToBegin" xml:space="preserve">
|
||||
<value>Must call '{2}.{1}' before calling '{2}.{0}'.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1,323 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class used to store information about a <see cref="ITagHelper"/>'s execution lifetime.
|
||||
/// </summary>
|
||||
public class TagHelperExecutionContext
|
||||
{
|
||||
private readonly List<ITagHelper> _tagHelpers;
|
||||
private readonly Action<HtmlEncoder> _startTagHelperWritingScope;
|
||||
private readonly Func<TagHelperContent> _endTagHelperWritingScope;
|
||||
private TagHelperContent _childContent;
|
||||
private Func<Task> _executeChildContentAsync;
|
||||
private Dictionary<HtmlEncoder, TagHelperContent> _perEncoderChildContent;
|
||||
private TagHelperAttributeList _allAttributes;
|
||||
|
||||
/// <summary>
|
||||
/// Internal for testing purposes only.
|
||||
/// </summary>
|
||||
internal TagHelperExecutionContext(string tagName, TagMode tagMode)
|
||||
: this(tagName,
|
||||
tagMode,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () => Task.CompletedTask,
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new <see cref="TagHelperExecutionContext"/>.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The HTML tag name in the Razor source.</param>
|
||||
/// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
|
||||
/// <param name="items">The collection of items used to communicate with other
|
||||
/// <see cref="ITagHelper"/>s</param>
|
||||
/// <param name="uniqueId">An identifier unique to the HTML element this context is for.</param>
|
||||
/// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
|
||||
/// <param name="startTagHelperWritingScope">
|
||||
/// A delegate used to start a writing scope in a Razor page and optionally override the page's
|
||||
/// <see cref="HtmlEncoder"/> within that scope.
|
||||
/// </param>
|
||||
/// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
|
||||
public TagHelperExecutionContext(
|
||||
string tagName,
|
||||
TagMode tagMode,
|
||||
IDictionary<object, object> items,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync,
|
||||
Action<HtmlEncoder> startTagHelperWritingScope,
|
||||
Func<TagHelperContent> endTagHelperWritingScope)
|
||||
{
|
||||
if (startTagHelperWritingScope == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(startTagHelperWritingScope));
|
||||
}
|
||||
|
||||
if (endTagHelperWritingScope == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(endTagHelperWritingScope));
|
||||
}
|
||||
|
||||
_tagHelpers = new List<ITagHelper>();
|
||||
_allAttributes = new TagHelperAttributeList();
|
||||
|
||||
Context = new TagHelperContext(tagName, _allAttributes, items, uniqueId);
|
||||
Output = new TagHelperOutput(tagName, new TagHelperAttributeList(), GetChildContentAsync)
|
||||
{
|
||||
TagMode = tagMode
|
||||
};
|
||||
|
||||
Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync);
|
||||
|
||||
_startTagHelperWritingScope = startTagHelperWritingScope;
|
||||
_endTagHelperWritingScope = endTagHelperWritingScope;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if <see cref="GetChildContentAsync"/> has been called.
|
||||
/// </summary>
|
||||
public bool ChildContentRetrieved
|
||||
{
|
||||
get
|
||||
{
|
||||
return _childContent != null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of items used to communicate with other <see cref="ITagHelper"/>s.
|
||||
/// </summary>
|
||||
public IDictionary<object, object> Items { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="ITagHelper"/>s that should be run.
|
||||
/// </summary>
|
||||
public IList<ITagHelper> TagHelpers
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tagHelpers;
|
||||
}
|
||||
}
|
||||
|
||||
// Internal set for testing.
|
||||
/// <summary>
|
||||
/// The <see cref="ITagHelper"/>'s output.
|
||||
/// </summary>
|
||||
public TagHelperOutput Output { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITagHelper"/>'s context.
|
||||
/// </summary>
|
||||
public TagHelperContext Context { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Tracks the given <paramref name="tagHelper"/>.
|
||||
/// </summary>
|
||||
/// <param name="tagHelper">The tag helper to track.</param>
|
||||
public void Add(ITagHelper tagHelper)
|
||||
{
|
||||
if (tagHelper == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tagHelper));
|
||||
}
|
||||
|
||||
_tagHelpers.Add(tagHelper);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracks the HTML attribute.
|
||||
/// </summary>
|
||||
/// <param name="name">The HTML attribute name.</param>
|
||||
/// <param name="value">The HTML attribute value.</param>
|
||||
/// <param name="valueStyle">The value style of the attribute.</param>
|
||||
public void AddHtmlAttribute(string name, object value, HtmlAttributeValueStyle valueStyle)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var attribute = new TagHelperAttribute(name, value, valueStyle);
|
||||
AddHtmlAttribute(attribute);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracks the HTML attribute.
|
||||
/// </summary>
|
||||
/// <param name="attribute">The <see cref="TagHelperAttribute"/> to track.</param>
|
||||
public void AddHtmlAttribute(TagHelperAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
Output.Attributes.Add(attribute);
|
||||
_allAttributes.Add(attribute);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracks the <see cref="ITagHelper"/> bound attribute.
|
||||
/// </summary>
|
||||
/// <param name="name">The bound attribute name.</param>
|
||||
/// <param name="value">The attribute value.</param>
|
||||
/// <param name="valueStyle">The value style of the attribute.</param>
|
||||
public void AddTagHelperAttribute(string name, object value, HtmlAttributeValueStyle valueStyle)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var attribute = new TagHelperAttribute(name, value, valueStyle);
|
||||
_allAttributes.Add(attribute);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracks the <see cref="ITagHelper"/> bound attribute.
|
||||
/// </summary>
|
||||
/// <param name="attribute">The bound attribute.</param>
|
||||
public void AddTagHelperAttribute(TagHelperAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
_allAttributes.Add(attribute);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the <see cref="TagHelperExecutionContext"/> and updates its state with the provided values.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The tag name to use.</param>
|
||||
/// <param name="tagMode">The <see cref="TagMode"/> to use.</param>
|
||||
/// <param name="items">The <see cref="IDictionary{Object, Object}"/> to use.</param>
|
||||
/// <param name="uniqueId">The unique id to use.</param>
|
||||
/// <param name="executeChildContentAsync">The <see cref="Func{Task}"/> to use.</param>
|
||||
public void Reinitialize(
|
||||
string tagName,
|
||||
TagMode tagMode,
|
||||
IDictionary<object, object> items,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync)
|
||||
{
|
||||
if (tagName == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tagName));
|
||||
}
|
||||
|
||||
if (items == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(items));
|
||||
}
|
||||
|
||||
if (uniqueId == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uniqueId));
|
||||
}
|
||||
|
||||
if (executeChildContentAsync == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(executeChildContentAsync));
|
||||
}
|
||||
|
||||
Items = items;
|
||||
_executeChildContentAsync = executeChildContentAsync;
|
||||
_tagHelpers.Clear();
|
||||
_perEncoderChildContent?.Clear();
|
||||
_childContent = null;
|
||||
|
||||
Context.Reinitialize(tagName, Items, uniqueId);
|
||||
Output.Reinitialize(tagName, tagMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes children asynchronously with the page's <see cref="HtmlEncoder" /> in scope and
|
||||
/// sets <see cref="Output"/>'s <see cref="TagHelperOutput.Content"/> to the rendered results.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> that on completion sets <see cref="Output"/>'s
|
||||
/// <see cref="TagHelperOutput.Content"/> to the children's rendered content.</returns>
|
||||
public async Task SetOutputContentAsync()
|
||||
{
|
||||
var childContent = _childContent;
|
||||
|
||||
if (childContent == null)
|
||||
{
|
||||
_startTagHelperWritingScope(null);
|
||||
try
|
||||
{
|
||||
await _executeChildContentAsync();
|
||||
}
|
||||
finally
|
||||
{
|
||||
childContent = _endTagHelperWritingScope();
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Assert(!Output.IsContentModified);
|
||||
|
||||
Output.Content.SetHtmlContent(childContent);
|
||||
}
|
||||
|
||||
// Internal for testing.
|
||||
internal async Task<TagHelperContent> GetChildContentAsync(bool useCachedResult, HtmlEncoder encoder)
|
||||
{
|
||||
// Get cached content for this encoder.
|
||||
TagHelperContent childContent;
|
||||
if (encoder == null)
|
||||
{
|
||||
childContent = _childContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_perEncoderChildContent == null)
|
||||
{
|
||||
childContent = null;
|
||||
_perEncoderChildContent = new Dictionary<HtmlEncoder, TagHelperContent>();
|
||||
}
|
||||
else
|
||||
{
|
||||
_perEncoderChildContent.TryGetValue(encoder, out childContent);
|
||||
}
|
||||
}
|
||||
|
||||
if (!useCachedResult || childContent == null)
|
||||
{
|
||||
_startTagHelperWritingScope(encoder);
|
||||
try
|
||||
{
|
||||
await _executeChildContentAsync();
|
||||
}
|
||||
finally
|
||||
{
|
||||
childContent = _endTagHelperWritingScope();
|
||||
}
|
||||
|
||||
if (encoder == null)
|
||||
{
|
||||
_childContent = childContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
_perEncoderChildContent[encoder] = childContent;
|
||||
}
|
||||
}
|
||||
|
||||
return new DefaultTagHelperContent().SetHtmlContent(childContent);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// A class used to run <see cref="ITagHelper"/>s.
|
||||
/// </summary>
|
||||
public class TagHelperRunner
|
||||
{
|
||||
/// <summary>
|
||||
/// Calls the <see cref="ITagHelperComponent.ProcessAsync"/> method on <see cref="ITagHelper"/>s.
|
||||
/// </summary>
|
||||
/// <param name="executionContext">Contains information associated with running <see cref="ITagHelper"/>s.
|
||||
/// </param>
|
||||
/// <returns>Resulting <see cref="TagHelperOutput"/> from processing all of the
|
||||
/// <paramref name="executionContext"/>'s <see cref="ITagHelper"/>s.</returns>
|
||||
public async Task RunAsync(TagHelperExecutionContext executionContext)
|
||||
{
|
||||
if (executionContext == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(executionContext));
|
||||
}
|
||||
|
||||
var tagHelperContext = executionContext.Context;
|
||||
|
||||
OrderTagHelpers(executionContext.TagHelpers);
|
||||
|
||||
for (var i = 0; i < executionContext.TagHelpers.Count; i++)
|
||||
{
|
||||
executionContext.TagHelpers[i].Init(tagHelperContext);
|
||||
}
|
||||
|
||||
var tagHelperOutput = executionContext.Output;
|
||||
|
||||
for (var i = 0; i < executionContext.TagHelpers.Count; i++)
|
||||
{
|
||||
await executionContext.TagHelpers[i].ProcessAsync(tagHelperContext, tagHelperOutput);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OrderTagHelpers(IList<ITagHelper> tagHelpers)
|
||||
{
|
||||
// Using bubble-sort here due to its simplicity. It'd be an extreme corner case to ever have more than 3 or
|
||||
// 4 tag helpers simultaneously.
|
||||
ITagHelper temp = null;
|
||||
for (var i = 0; i < tagHelpers.Count; i++)
|
||||
{
|
||||
for (var j = i + 1; j < tagHelpers.Count; j++)
|
||||
{
|
||||
if (tagHelpers[j].Order < tagHelpers[i].Order)
|
||||
{
|
||||
temp = tagHelpers[i];
|
||||
tagHelpers[i] = tagHelpers[j];
|
||||
tagHelpers[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,176 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class that manages <see cref="TagHelperExecutionContext"/> scopes.
|
||||
/// </summary>
|
||||
public class TagHelperScopeManager
|
||||
{
|
||||
private readonly ExecutionContextPool _executionContextPool;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new <see cref="TagHelperScopeManager"/>.
|
||||
/// </summary>
|
||||
/// <param name="startTagHelperWritingScope">
|
||||
/// A delegate used to start a writing scope in a Razor page and optionally override the page's
|
||||
/// <see cref="HtmlEncoder"/> within that scope.
|
||||
/// </param>
|
||||
/// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
|
||||
public TagHelperScopeManager(
|
||||
Action<HtmlEncoder> startTagHelperWritingScope,
|
||||
Func<TagHelperContent> endTagHelperWritingScope)
|
||||
{
|
||||
if (startTagHelperWritingScope == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(startTagHelperWritingScope));
|
||||
}
|
||||
|
||||
if (endTagHelperWritingScope == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(endTagHelperWritingScope));
|
||||
}
|
||||
|
||||
_executionContextPool = new ExecutionContextPool(startTagHelperWritingScope, endTagHelperWritingScope);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a <see cref="TagHelperExecutionContext"/> scope.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The HTML tag name that the scope is associated with.</param>
|
||||
/// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
|
||||
/// <param name="uniqueId">An identifier unique to the HTML element this scope is for.</param>
|
||||
/// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
|
||||
/// <returns>A <see cref="TagHelperExecutionContext"/> to use.</returns>
|
||||
public TagHelperExecutionContext Begin(
|
||||
string tagName,
|
||||
TagMode tagMode,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync)
|
||||
{
|
||||
if (tagName == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tagName));
|
||||
}
|
||||
|
||||
if (uniqueId == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uniqueId));
|
||||
}
|
||||
|
||||
if (executeChildContentAsync == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(executeChildContentAsync));
|
||||
}
|
||||
|
||||
IDictionary<object, object> items;
|
||||
var parentExecutionContext = _executionContextPool.Current;
|
||||
|
||||
// If we're not wrapped by another TagHelper, then there will not be a parentExecutionContext.
|
||||
if (parentExecutionContext != null)
|
||||
{
|
||||
items = new CopyOnWriteDictionary<object, object>(
|
||||
parentExecutionContext.Items,
|
||||
comparer: EqualityComparer<object>.Default);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new Dictionary<object, object>();
|
||||
}
|
||||
|
||||
var executionContext = _executionContextPool.Rent(
|
||||
tagName,
|
||||
tagMode,
|
||||
items,
|
||||
uniqueId,
|
||||
executeChildContentAsync);
|
||||
|
||||
return executionContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends a <see cref="TagHelperExecutionContext"/> scope.
|
||||
/// </summary>
|
||||
/// <returns>If the current scope is nested, the parent <see cref="TagHelperExecutionContext"/>.
|
||||
/// <c>null</c> otherwise.</returns>
|
||||
public TagHelperExecutionContext End()
|
||||
{
|
||||
if (_executionContextPool.Current == null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
Resources.FormatScopeManager_EndCannotBeCalledWithoutACallToBegin(
|
||||
nameof(End),
|
||||
nameof(Begin),
|
||||
nameof(TagHelperScopeManager)));
|
||||
}
|
||||
|
||||
_executionContextPool.ReturnCurrent();
|
||||
|
||||
var parentExecutionContext = _executionContextPool.Current;
|
||||
|
||||
return parentExecutionContext;
|
||||
}
|
||||
|
||||
private class ExecutionContextPool
|
||||
{
|
||||
private readonly Action<HtmlEncoder> _startTagHelperWritingScope;
|
||||
private readonly Func<TagHelperContent> _endTagHelperWritingScope;
|
||||
private readonly List<TagHelperExecutionContext> _executionContexts;
|
||||
private int _nextIndex;
|
||||
|
||||
public ExecutionContextPool(
|
||||
Action<HtmlEncoder> startTagHelperWritingScope,
|
||||
Func<TagHelperContent> endTagHelperWritingScope)
|
||||
{
|
||||
_executionContexts = new List<TagHelperExecutionContext>();
|
||||
_startTagHelperWritingScope = startTagHelperWritingScope;
|
||||
_endTagHelperWritingScope = endTagHelperWritingScope;
|
||||
}
|
||||
|
||||
public TagHelperExecutionContext Current => _nextIndex > 0 ? _executionContexts[_nextIndex - 1] : null;
|
||||
|
||||
public TagHelperExecutionContext Rent(
|
||||
string tagName,
|
||||
TagMode tagMode,
|
||||
IDictionary<object, object> items,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync)
|
||||
{
|
||||
TagHelperExecutionContext tagHelperExecutionContext;
|
||||
|
||||
if (_nextIndex == _executionContexts.Count)
|
||||
{
|
||||
tagHelperExecutionContext = new TagHelperExecutionContext(
|
||||
tagName,
|
||||
tagMode,
|
||||
items,
|
||||
uniqueId,
|
||||
executeChildContentAsync,
|
||||
_startTagHelperWritingScope,
|
||||
_endTagHelperWritingScope);
|
||||
|
||||
_executionContexts.Add(tagHelperExecutionContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
tagHelperExecutionContext = _executionContexts[_nextIndex];
|
||||
tagHelperExecutionContext.Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync);
|
||||
}
|
||||
|
||||
_nextIndex++;
|
||||
|
||||
return tagHelperExecutionContext;
|
||||
}
|
||||
|
||||
public void ReturnCurrent() => _nextIndex--;
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,23 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Summary>Razor is a markup syntax for adding server-side logic to web pages. This package contains runtime components for rendering Razor pages and implementing tag helpers.</Summary>
|
||||
<Description>$(Summary)
|
||||
|
||||
Commonly used types:
|
||||
Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute
|
||||
Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute
|
||||
Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper</Description>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageTags>$(PackageTags);taghelper;taghelpers</PackageTags>
|
||||
|
||||
<!-- Required to implement an HtmlEncoder -->
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="$(MicrosoftAspNetCoreHtmlAbstractionsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.HashCodeCombiner.Sources" PrivateAssets="All" Version="$(MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,7 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
|
|
@ -1,348 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Default concrete <see cref="TagHelperContent"/>.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{" + nameof(DebuggerToString) + "(),nq}")]
|
||||
public class DefaultTagHelperContent : TagHelperContent
|
||||
{
|
||||
private object _singleContent;
|
||||
private bool _isSingleContentSet;
|
||||
private bool _isModified;
|
||||
private bool _hasContent;
|
||||
private List<object> _buffer;
|
||||
|
||||
private List<object> Buffer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_buffer == null)
|
||||
{
|
||||
_buffer = new List<object>();
|
||||
}
|
||||
|
||||
if (_isSingleContentSet)
|
||||
{
|
||||
Debug.Assert(_buffer.Count == 0);
|
||||
|
||||
_buffer.Add(_singleContent);
|
||||
_isSingleContentSet = false;
|
||||
}
|
||||
|
||||
return _buffer;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsModified => _isModified;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>Returns <c>true</c> for a cleared <see cref="TagHelperContent"/>.</remarks>
|
||||
public override bool IsEmptyOrWhiteSpace
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_hasContent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
using (var writer = new EmptyOrWhiteSpaceWriter())
|
||||
{
|
||||
if (_isSingleContentSet)
|
||||
{
|
||||
return IsEmptyOrWhiteSpaceCore(_singleContent, writer);
|
||||
}
|
||||
|
||||
for (var i = 0; i < (_buffer?.Count ?? 0); i++)
|
||||
{
|
||||
if (!IsEmptyOrWhiteSpaceCore(Buffer[i], writer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override TagHelperContent Append(string unencoded) => AppendCore(unencoded);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override TagHelperContent AppendHtml(IHtmlContent htmlContent) => AppendCore(htmlContent);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override TagHelperContent AppendHtml(string encoded)
|
||||
{
|
||||
if (encoded == null)
|
||||
{
|
||||
return AppendCore(null);
|
||||
}
|
||||
|
||||
return AppendCore(new HtmlString(encoded));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void CopyTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
if (destination == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
}
|
||||
|
||||
if (!_hasContent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isSingleContentSet)
|
||||
{
|
||||
CopyToCore(_singleContent, destination);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < (_buffer?.Count ?? 0); i++)
|
||||
{
|
||||
CopyToCore(Buffer[i], destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void MoveTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
if (destination == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
}
|
||||
|
||||
if (!_hasContent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isSingleContentSet)
|
||||
{
|
||||
MoveToCore(_singleContent, destination);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < (_buffer?.Count ?? 0); i++)
|
||||
{
|
||||
MoveToCore(Buffer[i], destination);
|
||||
}
|
||||
}
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override TagHelperContent Clear()
|
||||
{
|
||||
_hasContent = false;
|
||||
_isModified = true;
|
||||
_isSingleContentSet = false;
|
||||
_buffer?.Clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Reinitialize()
|
||||
{
|
||||
Clear();
|
||||
_isModified = false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string GetContent() => GetContent(HtmlEncoder.Default);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string GetContent(HtmlEncoder encoder)
|
||||
{
|
||||
if (!_hasContent)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
using (var writer = new StringWriter())
|
||||
{
|
||||
WriteTo(writer, encoder);
|
||||
return writer.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteTo(TextWriter writer, HtmlEncoder encoder)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(writer));
|
||||
}
|
||||
|
||||
if (encoder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(encoder));
|
||||
}
|
||||
|
||||
if (!_hasContent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isSingleContentSet)
|
||||
{
|
||||
WriteToCore(_singleContent, writer, encoder);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < (_buffer?.Count ?? 0); i++)
|
||||
{
|
||||
WriteToCore(Buffer[i], writer, encoder);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteToCore(object entry, TextWriter writer, HtmlEncoder encoder)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry is string stringValue)
|
||||
{
|
||||
encoder.Encode(writer, stringValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
((IHtmlContent)entry).WriteTo(writer, encoder);
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyToCore(object entry, IHtmlContentBuilder destination)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry is string entryAsString)
|
||||
{
|
||||
destination.Append(entryAsString);
|
||||
}
|
||||
else if (entry is IHtmlContentContainer entryAsContainer)
|
||||
{
|
||||
entryAsContainer.CopyTo(destination);
|
||||
}
|
||||
else
|
||||
{
|
||||
destination.AppendHtml((IHtmlContent)entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveToCore(object entry, IHtmlContentBuilder destination)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry is string entryAsString)
|
||||
{
|
||||
destination.Append(entryAsString);
|
||||
}
|
||||
else if (entry is IHtmlContentContainer entryAsContainer)
|
||||
{
|
||||
entryAsContainer.MoveTo(destination);
|
||||
}
|
||||
else
|
||||
{
|
||||
destination.AppendHtml((IHtmlContent)entry);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsEmptyOrWhiteSpaceCore(object entry, EmptyOrWhiteSpaceWriter writer)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entry is string stringValue)
|
||||
{
|
||||
// Do not encode the string because encoded value remains whitespace from user's POV.
|
||||
return string.IsNullOrWhiteSpace(stringValue);
|
||||
}
|
||||
|
||||
// Use NullHtmlEncoder to avoid treating encoded whitespace as non-whitespace e.g. "\t" as "	".
|
||||
((IHtmlContent)entry).WriteTo(writer, NullHtmlEncoder.Default);
|
||||
|
||||
return writer.IsEmptyOrWhiteSpace;
|
||||
}
|
||||
|
||||
private TagHelperContent AppendCore(object entry)
|
||||
{
|
||||
if (!_hasContent)
|
||||
{
|
||||
_isSingleContentSet = true;
|
||||
_singleContent = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer.Add(entry);
|
||||
}
|
||||
|
||||
_isModified = true;
|
||||
_hasContent = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private string DebuggerToString()
|
||||
{
|
||||
return GetContent();
|
||||
}
|
||||
|
||||
// Overrides Write(string) to find if the content written is empty/whitespace.
|
||||
private class EmptyOrWhiteSpaceWriter : TextWriter
|
||||
{
|
||||
public override Encoding Encoding
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEmptyOrWhiteSpace { get; private set; } = true;
|
||||
|
||||
public override void Write(char value)
|
||||
{
|
||||
if (IsEmptyOrWhiteSpace && !char.IsWhiteSpace(value))
|
||||
{
|
||||
IsEmptyOrWhiteSpace = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(string value)
|
||||
{
|
||||
if (IsEmptyOrWhiteSpace && !string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
IsEmptyOrWhiteSpace = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Encodings.Web;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="HtmlEncoder"/> that does not encode. Should not be used when writing directly to a response
|
||||
/// expected to contain valid HTML.
|
||||
/// </summary>
|
||||
public class NullHtmlEncoder : HtmlEncoder
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a <see cref="NullHtmlEncoder"/> instance.
|
||||
/// </summary>
|
||||
protected NullHtmlEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="HtmlEncoder"/> instance that does not encode. Should not be used when writing directly to a
|
||||
/// response expected to contain valid HTML.
|
||||
/// </summary>
|
||||
public static new NullHtmlEncoder Default { get; } = new NullHtmlEncoder();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int MaxOutputCharactersPerInputCharacter
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Encode(string value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Encode(TextWriter output, char[] value, int startIndex, int characterCount)
|
||||
{
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (characterCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
output.Write(value, startIndex, characterCount);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Encode(TextWriter output, string value, int startIndex, int characterCount)
|
||||
{
|
||||
if (output == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (characterCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
output.Write(value.Substring(startIndex, characterCount));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override unsafe int FindFirstCharacterToEncode(char* text, int textLength)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override unsafe bool TryEncodeUnicodeScalar(
|
||||
int unicodeScalar,
|
||||
char* buffer,
|
||||
int bufferLength,
|
||||
out int numberOfCharactersWritten)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
|
||||
numberOfCharactersWritten = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool WillEncode(int unicodeScalar)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// An abstract base class for <see cref="ITagHelper"/>.
|
||||
/// </summary>
|
||||
public abstract class TagHelper : ITagHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// When a set of <see cref="ITagHelper"/>s are executed, their <see cref="Init(TagHelperContext)"/>'s
|
||||
/// are first invoked in the specified <see cref="Order"/>; then their
|
||||
/// <see cref="ProcessAsync(TagHelperContext, TagHelperOutput)"/>'s are invoked in the specified
|
||||
/// <see cref="Order"/>. Lower values are executed first.
|
||||
/// </summary>
|
||||
/// <remarks>Default order is <c>0</c>.</remarks>
|
||||
public virtual int Order { get; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="ITagHelper"/> with the given <paramref name="context"/>. Additions to
|
||||
/// <see cref="TagHelperContext.Items"/> should be done within this method to ensure they're added prior to
|
||||
/// executing the children.
|
||||
/// </summary>
|
||||
/// <param name="context">Contains information associated with the current HTML tag.</param>
|
||||
/// <remarks>When more than one <see cref="ITagHelper"/> runs on the same element,
|
||||
/// <see cref="M:TagHelperOutput.GetChildContentAsync"/> may be invoked prior to <see cref="ProcessAsync"/>.
|
||||
/// </remarks>
|
||||
public virtual void Init(TagHelperContext context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously executes the <see cref="TagHelper"/> with the given <paramref name="context"/> and
|
||||
/// <paramref name="output"/>.
|
||||
/// </summary>
|
||||
/// <param name="context">Contains information associated with the current HTML tag.</param>
|
||||
/// <param name="output">A stateful HTML element used to generate an HTML tag.</param>
|
||||
public virtual void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously executes the <see cref="TagHelper"/> with the given <paramref name="context"/> and
|
||||
/// <paramref name="output"/>.
|
||||
/// </summary>
|
||||
/// <param name="context">Contains information associated with the current HTML tag.</param>
|
||||
/// <param name="output">A stateful HTML element used to generate an HTML tag.</param>
|
||||
/// <returns>A <see cref="Task"/> that on completion updates the <paramref name="output"/>.</returns>
|
||||
/// <remarks>By default this calls into <see cref="Process"/>.</remarks>.
|
||||
public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
Process(context, output);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,277 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// An HTML tag helper attribute.
|
||||
/// </summary>
|
||||
public class TagHelperAttribute : IHtmlContentContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="TagHelperAttribute"/> with the specified <paramref name="name"/>.
|
||||
/// <see cref="ValueStyle"/> is set to <see cref="HtmlAttributeValueStyle.Minimized"/> and <see cref="Value"/> to
|
||||
/// <c>null</c>.
|
||||
/// </summary>
|
||||
/// <param name="name">The <see cref="Name"/> of the attribute.</param>
|
||||
public TagHelperAttribute(string name)
|
||||
: this(name, value: null, valueStyle: HtmlAttributeValueStyle.Minimized)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="TagHelperAttribute"/> with the specified <paramref name="name"/>
|
||||
/// and <paramref name="value"/>. <see cref="ValueStyle"/> is set to <see cref="HtmlAttributeValueStyle.DoubleQuotes"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The <see cref="Name"/> of the attribute.</param>
|
||||
/// <param name="value">The <see cref="Value"/> of the attribute.</param>
|
||||
public TagHelperAttribute(string name, object value)
|
||||
: this(name, value, valueStyle: HtmlAttributeValueStyle.DoubleQuotes)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="TagHelperAttribute"/> with the specified <paramref name="name"/>,
|
||||
/// <paramref name="value"/> and <paramref name="valueStyle"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The <see cref="Name"/> of the new instance.</param>
|
||||
/// <param name="value">The <see cref="Value"/> of the new instance.</param>
|
||||
/// <param name="valueStyle">The <see cref="ValueStyle"/> of the new instance.</param>
|
||||
/// <remarks>If <paramref name="valueStyle"/> is <see cref="HtmlAttributeValueStyle.Minimized"/>,
|
||||
/// <paramref name="value"/> is ignored when this instance is rendered.</remarks>
|
||||
public TagHelperAttribute(string name, object value, HtmlAttributeValueStyle valueStyle)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
Name = name;
|
||||
Value = value;
|
||||
ValueStyle = valueStyle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the attribute.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the attribute.
|
||||
/// </summary>
|
||||
public object Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value style of the attribute.
|
||||
/// </summary>
|
||||
public HtmlAttributeValueStyle ValueStyle { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks><see cref="Name"/> is compared case-insensitively.</remarks>
|
||||
public bool Equals(TagHelperAttribute other)
|
||||
{
|
||||
return
|
||||
other != null &&
|
||||
string.Equals(Name, other.Name, StringComparison.OrdinalIgnoreCase) &&
|
||||
ValueStyle == other.ValueStyle &&
|
||||
(ValueStyle == HtmlAttributeValueStyle.Minimized || Equals(Value, other.Value));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void WriteTo(TextWriter writer, HtmlEncoder encoder)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(writer));
|
||||
}
|
||||
|
||||
if (encoder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(encoder));
|
||||
}
|
||||
|
||||
writer.Write(Name);
|
||||
|
||||
if (ValueStyle == HtmlAttributeValueStyle.Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var valuePrefix = GetAttributeValuePrefix(ValueStyle);
|
||||
if (valuePrefix != null)
|
||||
{
|
||||
writer.Write(valuePrefix);
|
||||
}
|
||||
|
||||
var htmlContent = Value as IHtmlContent;
|
||||
if (htmlContent != null)
|
||||
{
|
||||
htmlContent.WriteTo(writer, encoder);
|
||||
}
|
||||
else if (Value != null)
|
||||
{
|
||||
encoder.Encode(writer, Value.ToString());
|
||||
}
|
||||
|
||||
var valueSuffix = GetAttributeValueSuffix(ValueStyle);
|
||||
if (valueSuffix != null)
|
||||
{
|
||||
writer.Write(valueSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void CopyTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
if (destination == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
}
|
||||
|
||||
destination.AppendHtml(Name);
|
||||
|
||||
if (ValueStyle == HtmlAttributeValueStyle.Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var valuePrefix = GetAttributeValuePrefix(ValueStyle);
|
||||
if (valuePrefix != null)
|
||||
{
|
||||
destination.AppendHtml(valuePrefix);
|
||||
}
|
||||
|
||||
string valueAsString;
|
||||
IHtmlContentContainer valueAsHtmlContainer;
|
||||
IHtmlContent valueAsHtmlContent;
|
||||
if ((valueAsString = Value as string) != null)
|
||||
{
|
||||
destination.Append(valueAsString);
|
||||
}
|
||||
else if ((valueAsHtmlContainer = Value as IHtmlContentContainer) != null)
|
||||
{
|
||||
valueAsHtmlContainer.CopyTo(destination);
|
||||
}
|
||||
else if ((valueAsHtmlContent = Value as IHtmlContent) != null)
|
||||
{
|
||||
destination.AppendHtml(valueAsHtmlContent);
|
||||
}
|
||||
else if (Value != null)
|
||||
{
|
||||
destination.Append(Value.ToString());
|
||||
}
|
||||
|
||||
var valueSuffix = GetAttributeValueSuffix(ValueStyle);
|
||||
if (valueSuffix != null)
|
||||
{
|
||||
destination.AppendHtml(valueSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void MoveTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
if (destination == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
}
|
||||
|
||||
destination.AppendHtml(Name);
|
||||
|
||||
if (ValueStyle == HtmlAttributeValueStyle.Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var valuePrefix = GetAttributeValuePrefix(ValueStyle);
|
||||
if (valuePrefix != null)
|
||||
{
|
||||
destination.AppendHtml(valuePrefix);
|
||||
}
|
||||
|
||||
string valueAsString;
|
||||
IHtmlContentContainer valueAsHtmlContainer;
|
||||
IHtmlContent valueAsHtmlContent;
|
||||
if ((valueAsString = Value as string) != null)
|
||||
{
|
||||
destination.Append(valueAsString);
|
||||
}
|
||||
else if ((valueAsHtmlContainer = Value as IHtmlContentContainer) != null)
|
||||
{
|
||||
valueAsHtmlContainer.MoveTo(destination);
|
||||
}
|
||||
else if ((valueAsHtmlContent = Value as IHtmlContent) != null)
|
||||
{
|
||||
destination.AppendHtml(valueAsHtmlContent);
|
||||
}
|
||||
else if (Value != null)
|
||||
{
|
||||
destination.Append(Value.ToString());
|
||||
}
|
||||
|
||||
var valueSuffix = GetAttributeValueSuffix(ValueStyle);
|
||||
if (valueSuffix != null)
|
||||
{
|
||||
destination.AppendHtml(valueSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as TagHelperAttribute;
|
||||
|
||||
return Equals(other);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var hashCodeCombiner = HashCodeCombiner.Start();
|
||||
hashCodeCombiner.Add(Name, StringComparer.Ordinal);
|
||||
|
||||
if (ValueStyle != HtmlAttributeValueStyle.Minimized)
|
||||
{
|
||||
hashCodeCombiner.Add(Value);
|
||||
}
|
||||
|
||||
hashCodeCombiner.Add(ValueStyle);
|
||||
|
||||
return hashCodeCombiner.CombinedHash;
|
||||
}
|
||||
|
||||
private static string GetAttributeValuePrefix(HtmlAttributeValueStyle valueStyle)
|
||||
{
|
||||
switch (valueStyle)
|
||||
{
|
||||
case HtmlAttributeValueStyle.DoubleQuotes:
|
||||
return "=\"";
|
||||
case HtmlAttributeValueStyle.SingleQuotes:
|
||||
return "='";
|
||||
case HtmlAttributeValueStyle.NoQuotes:
|
||||
return "=";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetAttributeValueSuffix(HtmlAttributeValueStyle valueStyle)
|
||||
{
|
||||
switch (valueStyle)
|
||||
{
|
||||
case HtmlAttributeValueStyle.DoubleQuotes:
|
||||
return "\"";
|
||||
case HtmlAttributeValueStyle.SingleQuotes:
|
||||
return "'";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,454 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class used to represent the output of an <see cref="ITagHelper"/>.
|
||||
/// </summary>
|
||||
public class TagHelperOutput : IHtmlContentContainer
|
||||
{
|
||||
private readonly Func<bool, HtmlEncoder, Task<TagHelperContent>> _getChildContentAsync;
|
||||
private TagHelperContent _preElement;
|
||||
private TagHelperContent _preContent;
|
||||
private TagHelperContent _content;
|
||||
private TagHelperContent _postContent;
|
||||
private TagHelperContent _postElement;
|
||||
private bool _wasSuppressOutputCalled;
|
||||
|
||||
// Internal for testing
|
||||
internal TagHelperOutput(string tagName)
|
||||
: this(
|
||||
tagName,
|
||||
new TagHelperAttributeList(),
|
||||
(useCachedResult, encoder) => Task.FromResult<TagHelperContent>(new DefaultTagHelperContent()))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="TagHelperOutput"/>.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The HTML element's tag name.</param>
|
||||
/// <param name="attributes">The HTML attributes.</param>
|
||||
/// <param name="getChildContentAsync">
|
||||
/// A delegate used to execute children asynchronously with the given <see cref="HtmlEncoder"/> in scope and
|
||||
/// return their rendered content.
|
||||
/// </param>
|
||||
public TagHelperOutput(
|
||||
string tagName,
|
||||
TagHelperAttributeList attributes,
|
||||
Func<bool, HtmlEncoder, Task<TagHelperContent>> getChildContentAsync)
|
||||
{
|
||||
if (getChildContentAsync == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(getChildContentAsync));
|
||||
}
|
||||
|
||||
if (attributes == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attributes));
|
||||
}
|
||||
|
||||
TagName = tagName;
|
||||
_getChildContentAsync = getChildContentAsync;
|
||||
Attributes = attributes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The HTML element's tag name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A whitespace or <c>null</c> value results in no start or end tag being rendered.
|
||||
/// </remarks>
|
||||
public string TagName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Content that precedes the HTML element.
|
||||
/// </summary>
|
||||
/// <remarks>Value is rendered before the HTML element.</remarks>
|
||||
public TagHelperContent PreElement
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_preElement == null)
|
||||
{
|
||||
_preElement = new DefaultTagHelperContent();
|
||||
}
|
||||
|
||||
return _preElement;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The HTML element's pre content.
|
||||
/// </summary>
|
||||
/// <remarks>Value is prepended to the <see cref="ITagHelper"/>'s final output.</remarks>
|
||||
public TagHelperContent PreContent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_preContent == null)
|
||||
{
|
||||
_preContent = new DefaultTagHelperContent();
|
||||
}
|
||||
|
||||
return _preContent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the HTML element's main content.
|
||||
/// </summary>
|
||||
/// <remarks>Value occurs in the <see cref="ITagHelper"/>'s final output after <see cref="PreContent"/> and
|
||||
/// before <see cref="PostContent"/></remarks>
|
||||
public TagHelperContent Content
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_content == null)
|
||||
{
|
||||
_content = new DefaultTagHelperContent();
|
||||
}
|
||||
|
||||
return _content;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The HTML element's post content.
|
||||
/// </summary>
|
||||
/// <remarks>Value is appended to the <see cref="ITagHelper"/>'s final output.</remarks>
|
||||
public TagHelperContent PostContent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_postContent == null)
|
||||
{
|
||||
_postContent = new DefaultTagHelperContent();
|
||||
}
|
||||
|
||||
return _postContent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Content that follows the HTML element.
|
||||
/// </summary>
|
||||
/// <remarks>Value is rendered after the HTML element.</remarks>
|
||||
public TagHelperContent PostElement
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_postElement == null)
|
||||
{
|
||||
_postElement = new DefaultTagHelperContent();
|
||||
}
|
||||
|
||||
return _postElement;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>true</c> if <see cref="Content"/> has been set, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
public bool IsContentModified
|
||||
{
|
||||
get
|
||||
{
|
||||
return _wasSuppressOutputCalled || _content?.IsModified == true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Syntax of the element in the generated HTML.
|
||||
/// </summary>
|
||||
public TagMode TagMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The HTML element's attributes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// MVC will HTML encode <see cref="string"/> values when generating the start tag. It will not HTML encode
|
||||
/// a <c>Microsoft.AspNetCore.Mvc.Rendering.HtmlString</c> instance. MVC converts most other types to a
|
||||
/// <see cref="string"/>, then HTML encodes the result.
|
||||
/// </remarks>
|
||||
public TagHelperAttributeList Attributes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Clears the <see cref="TagHelperOutput"/> and updates its state with the provided values.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The tag name to use.</param>
|
||||
/// <param name="tagMode">The <see cref="TagMode"/> to use.</param>
|
||||
public void Reinitialize(string tagName, TagMode tagMode)
|
||||
{
|
||||
TagName = tagName;
|
||||
TagMode = tagMode;
|
||||
Attributes.Clear();
|
||||
|
||||
_preElement?.Reinitialize();
|
||||
_preContent?.Reinitialize();
|
||||
_content?.Reinitialize();
|
||||
_postContent?.Reinitialize();
|
||||
_postElement?.Reinitialize();
|
||||
|
||||
_wasSuppressOutputCalled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes <see cref="TagHelperOutput"/> to generate nothing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Sets <see cref="TagName"/> to <c>null</c>, and clears <see cref="PreElement"/>, <see cref="PreContent"/>,
|
||||
/// <see cref="Content"/>, <see cref="PostContent"/>, and <see cref="PostElement"/> to suppress output.
|
||||
/// </remarks>
|
||||
public void SuppressOutput()
|
||||
{
|
||||
TagName = null;
|
||||
_wasSuppressOutputCalled = true;
|
||||
_preElement?.Clear();
|
||||
_preContent?.Clear();
|
||||
_content?.Clear();
|
||||
_postContent?.Clear();
|
||||
_postElement?.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes children asynchronously and returns their rendered content.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> that on completion returns content rendered by children.</returns>
|
||||
/// <remarks>
|
||||
/// This method is memoized. Multiple calls will not cause children to re-execute with the page's original
|
||||
/// <see cref="HtmlEncoder"/>.
|
||||
/// </remarks>
|
||||
public Task<TagHelperContent> GetChildContentAsync()
|
||||
{
|
||||
return GetChildContentAsync(useCachedResult: true, encoder: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes children asynchronously and returns their rendered content.
|
||||
/// </summary>
|
||||
/// <param name="useCachedResult">
|
||||
/// If <c>true</c>, multiple calls will not cause children to re-execute with the page's original
|
||||
/// <see cref="HtmlEncoder"/>; returns cached content.
|
||||
/// </param>
|
||||
/// <returns>A <see cref="Task"/> that on completion returns content rendered by children.</returns>
|
||||
public Task<TagHelperContent> GetChildContentAsync(bool useCachedResult)
|
||||
{
|
||||
return GetChildContentAsync(useCachedResult, encoder: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes children asynchronously with the given <paramref name="encoder"/> in scope and returns their
|
||||
/// rendered content.
|
||||
/// </summary>
|
||||
/// <param name="encoder">
|
||||
/// The <see cref="HtmlEncoder"/> to use when the page handles non-<see cref="IHtmlContent"/> C# expressions.
|
||||
/// If <c>null</c>, executes children with the page's current <see cref="HtmlEncoder"/>.
|
||||
/// </param>
|
||||
/// <returns>A <see cref="Task"/> that on completion returns content rendered by children.</returns>
|
||||
/// <remarks>
|
||||
/// This method is memoized. Multiple calls with the same <see cref="HtmlEncoder"/> instance will not cause
|
||||
/// children to re-execute with that encoder in scope.
|
||||
/// </remarks>
|
||||
public Task<TagHelperContent> GetChildContentAsync(HtmlEncoder encoder)
|
||||
{
|
||||
return GetChildContentAsync(useCachedResult: true, encoder: encoder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes children asynchronously with the given <paramref name="encoder"/> in scope and returns their
|
||||
/// rendered content.
|
||||
/// </summary>
|
||||
/// <param name="useCachedResult">
|
||||
/// If <c>true</c>, multiple calls with the same <see cref="HtmlEncoder"/> will not cause children to
|
||||
/// re-execute; returns cached content.
|
||||
/// </param>
|
||||
/// <param name="encoder">
|
||||
/// The <see cref="HtmlEncoder"/> to use when the page handles non-<see cref="IHtmlContent"/> C# expressions.
|
||||
/// If <c>null</c>, executes children with the page's current <see cref="HtmlEncoder"/>.
|
||||
/// </param>
|
||||
/// <returns>A <see cref="Task"/> that on completion returns content rendered by children.</returns>
|
||||
public Task<TagHelperContent> GetChildContentAsync(bool useCachedResult, HtmlEncoder encoder)
|
||||
{
|
||||
return _getChildContentAsync(useCachedResult, encoder);
|
||||
}
|
||||
|
||||
void IHtmlContentContainer.CopyTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
if (destination == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
}
|
||||
|
||||
_preElement?.CopyTo(destination);
|
||||
|
||||
var isTagNameNullOrWhitespace = string.IsNullOrWhiteSpace(TagName);
|
||||
|
||||
if (!isTagNameNullOrWhitespace)
|
||||
{
|
||||
destination.AppendHtml("<");
|
||||
destination.AppendHtml(TagName);
|
||||
|
||||
// Perf: Avoid allocating enumerator
|
||||
for (var i = 0; i < Attributes.Count; i++)
|
||||
{
|
||||
var attribute = Attributes[i];
|
||||
destination.AppendHtml(" ");
|
||||
attribute.CopyTo(destination);
|
||||
}
|
||||
|
||||
if (TagMode == TagMode.SelfClosing)
|
||||
{
|
||||
destination.AppendHtml(" /");
|
||||
}
|
||||
|
||||
destination.AppendHtml(">");
|
||||
}
|
||||
|
||||
if (isTagNameNullOrWhitespace || TagMode == TagMode.StartTagAndEndTag)
|
||||
{
|
||||
_preContent?.CopyTo(destination);
|
||||
|
||||
_content?.CopyTo(destination);
|
||||
|
||||
_postContent?.CopyTo(destination);
|
||||
}
|
||||
|
||||
if (!isTagNameNullOrWhitespace && TagMode == TagMode.StartTagAndEndTag)
|
||||
{
|
||||
destination.AppendHtml("</");
|
||||
destination.AppendHtml(TagName);
|
||||
destination.AppendHtml(">");
|
||||
}
|
||||
|
||||
_postElement?.CopyTo(destination);
|
||||
}
|
||||
|
||||
void IHtmlContentContainer.MoveTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
if (destination == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
}
|
||||
|
||||
_preElement?.MoveTo(destination);
|
||||
|
||||
var isTagNameNullOrWhitespace = string.IsNullOrWhiteSpace(TagName);
|
||||
|
||||
if (!isTagNameNullOrWhitespace)
|
||||
{
|
||||
destination.AppendHtml("<");
|
||||
destination.AppendHtml(TagName);
|
||||
|
||||
// Perf: Avoid allocating enumerator
|
||||
for (var i = 0; i < Attributes.Count; i++)
|
||||
{
|
||||
var attribute = Attributes[i];
|
||||
destination.AppendHtml(" ");
|
||||
attribute.MoveTo(destination);
|
||||
}
|
||||
|
||||
if (TagMode == TagMode.SelfClosing)
|
||||
{
|
||||
destination.AppendHtml(" /");
|
||||
}
|
||||
|
||||
destination.AppendHtml(">");
|
||||
}
|
||||
|
||||
if (isTagNameNullOrWhitespace || TagMode == TagMode.StartTagAndEndTag)
|
||||
{
|
||||
_preContent?.MoveTo(destination);
|
||||
_content?.MoveTo(destination);
|
||||
_postContent?.MoveTo(destination);
|
||||
}
|
||||
|
||||
if (!isTagNameNullOrWhitespace && TagMode == TagMode.StartTagAndEndTag)
|
||||
{
|
||||
destination.AppendHtml("</");
|
||||
destination.AppendHtml(TagName);
|
||||
destination.AppendHtml(">");
|
||||
}
|
||||
|
||||
_postElement?.MoveTo(destination);
|
||||
|
||||
// Depending on the code path we took, these might need to be cleared.
|
||||
_preContent?.Clear();
|
||||
_content?.Clear();
|
||||
_postContent?.Clear();
|
||||
Attributes.Clear();
|
||||
}
|
||||
|
||||
public void WriteTo(TextWriter writer, HtmlEncoder encoder)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(writer));
|
||||
}
|
||||
|
||||
if (encoder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(encoder));
|
||||
}
|
||||
|
||||
_preElement?.WriteTo(writer, encoder);
|
||||
|
||||
var isTagNameNullOrWhitespace = string.IsNullOrWhiteSpace(TagName);
|
||||
|
||||
if (!isTagNameNullOrWhitespace)
|
||||
{
|
||||
writer.Write("<");
|
||||
writer.Write(TagName);
|
||||
|
||||
// Perf: Avoid allocating enumerator
|
||||
for (var i = 0; i < Attributes.Count; i++)
|
||||
{
|
||||
var attribute = Attributes[i];
|
||||
writer.Write(" ");
|
||||
attribute.WriteTo(writer, encoder);
|
||||
}
|
||||
|
||||
if (TagMode == TagMode.SelfClosing)
|
||||
{
|
||||
writer.Write(" /");
|
||||
}
|
||||
|
||||
writer.Write(">");
|
||||
}
|
||||
|
||||
if (isTagNameNullOrWhitespace || TagMode == TagMode.StartTagAndEndTag)
|
||||
{
|
||||
_preContent?.WriteTo(writer, encoder);
|
||||
|
||||
_content?.WriteTo(writer, encoder);
|
||||
|
||||
_postContent?.WriteTo(writer, encoder);
|
||||
}
|
||||
|
||||
if (!isTagNameNullOrWhitespace && TagMode == TagMode.StartTagAndEndTag)
|
||||
{
|
||||
writer.Write("</");
|
||||
writer.Write(TagName);
|
||||
writer.Write(">");
|
||||
}
|
||||
|
||||
_postElement?.WriteTo(writer, encoder);
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,9 +13,9 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor.Extensions\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.CodeAnalysis.Razor\Microsoft.CodeAnalysis.Razor.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -25,19 +25,6 @@
|
|||
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- We need this to compile but don't want it referenced by the project. It is included dynamically in CodeGeneration tests. -->
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj">
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
<OutputItemType>Content</OutputItemType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Targets>Build</Targets>
|
||||
</ProjectReference>
|
||||
|
||||
<!-- Due to how DependencyContext.Load handles our special MvcShim reference above we need to also reference the MvcShim's DiagnosticSource dependency -->
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourcePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyDepsFromShims" AfterTargets="Build">
|
||||
<ItemGroup>
|
||||
<MvcShim Condition="$(TargetFramework) != ''" Include="$(ArtifactsBinDir)\Microsoft.AspNetCore.Razor.Test.MvcShim\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.deps.json" />
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.CodeAnalysis.Razor\Microsoft.CodeAnalysis.Razor.csproj" />
|
||||
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -25,19 +26,6 @@
|
|||
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- We need this to compile but don't want it referenced by the project. It is included dynamically in CodeGeneration tests. -->
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj">
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
<OutputItemType>Content</OutputItemType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Targets>Build</Targets>
|
||||
</ProjectReference>
|
||||
|
||||
<!-- Due to how DependencyContext.Load handles our special MvcShim reference above we need to also reference the MvcShim's DiagnosticSource dependency -->
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourcePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MvcShim Condition="$(TargetFramework) != ''" Include="$(ArtifactsBinDir)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.deps.json" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.CodeAnalysis.Razor\Microsoft.CodeAnalysis.Razor.csproj" />
|
||||
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -25,20 +26,6 @@
|
|||
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- We need this to compile but don't want it referenced by the project. It is included dynamically in CodeGeneration tests. -->
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.csproj">
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
<OutputItemType>Content</OutputItemType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Targets>Build</Targets>
|
||||
</ProjectReference>
|
||||
|
||||
<!-- Due to how DependencyContext.Load handles our special MvcShim reference above we need to also reference the MvcShim's DiagnosticSource dependency -->
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourcePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<Target Name="CopyDepsFromShims" AfterTargets="Build">
|
||||
<ItemGroup>
|
||||
<MvcShim Condition="$(TargetFramework) != ''" Include="$(ArtifactsBinDir)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.deps.json" />
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**\*</DefaultItemExcludes>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\shared\Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources\**\*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.WebEncoders" Version="$(MicrosoftExtensionsWebEncodersPackageVersion)" />
|
||||
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,593 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
|
||||
using Microsoft.Extensions.WebEncoders.Testing;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
|
||||
{
|
||||
public class TagHelperExecutionContextTest
|
||||
{
|
||||
[Fact]
|
||||
public async Task SetOutputContentAsync_CanHandleExceptionThrowingChildContent()
|
||||
{
|
||||
// Arrange
|
||||
var calledEnd = false;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () => throw new Exception(),
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () =>
|
||||
{
|
||||
calledEnd = true;
|
||||
return new DefaultTagHelperContent();
|
||||
});
|
||||
|
||||
// Act & Assert
|
||||
await Assert.ThrowsAsync<Exception>(async () => await executionContext.SetOutputContentAsync());
|
||||
Assert.True(calledEnd);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetChildContentAsync_CanHandleExceptionThrowingChildContent()
|
||||
{
|
||||
// Arrange
|
||||
var calledEnd = false;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () => throw new Exception(),
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () =>
|
||||
{
|
||||
calledEnd = true;
|
||||
return new DefaultTagHelperContent();
|
||||
});
|
||||
|
||||
// Act & Assert
|
||||
await Assert.ThrowsAsync<Exception>(
|
||||
async () => await executionContext.GetChildContentAsync(useCachedResult: false, encoder: null));
|
||||
Assert.True(calledEnd);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SetOutputContentAsync_SetsOutputsContent()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelperContent = new DefaultTagHelperContent();
|
||||
var content = "Hello from child content";
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () =>
|
||||
{
|
||||
tagHelperContent.SetContent(content);
|
||||
|
||||
return Task.FromResult(result: true);
|
||||
},
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => tagHelperContent);
|
||||
|
||||
// Act
|
||||
await executionContext.SetOutputContentAsync();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(content, executionContext.Output.Content.GetContent());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecutionContext_Reinitialize_UpdatesTagHelperOutputAsExpected()
|
||||
{
|
||||
// Arrange
|
||||
var tagName = "div";
|
||||
var tagMode = TagMode.StartTagOnly;
|
||||
var callCount = 0;
|
||||
Func<Task> executeChildContentAsync = () =>
|
||||
{
|
||||
callCount++;
|
||||
return Task.FromResult(true);
|
||||
};
|
||||
Action<HtmlEncoder> startTagHelperWritingScope = _ => { };
|
||||
Func<TagHelperContent> endTagHelperWritingScope = () => null;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
tagName,
|
||||
tagMode,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: executeChildContentAsync,
|
||||
startTagHelperWritingScope: startTagHelperWritingScope,
|
||||
endTagHelperWritingScope: endTagHelperWritingScope);
|
||||
var updatedTagName = "p";
|
||||
var updatedTagMode = TagMode.SelfClosing;
|
||||
var updatedCallCount = 0;
|
||||
Func<Task> updatedExecuteChildContentAsync = () =>
|
||||
{
|
||||
updatedCallCount++;
|
||||
return Task.FromResult(true);
|
||||
};
|
||||
executionContext.AddHtmlAttribute(new TagHelperAttribute("something"));
|
||||
|
||||
// Act - 1
|
||||
executionContext.Reinitialize(
|
||||
updatedTagName,
|
||||
updatedTagMode,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: updatedExecuteChildContentAsync);
|
||||
executionContext.AddHtmlAttribute(new TagHelperAttribute("Another attribute"));
|
||||
|
||||
// Assert - 1
|
||||
var output = executionContext.Output;
|
||||
Assert.Equal(updatedTagName, output.TagName);
|
||||
Assert.Equal(updatedTagMode, output.TagMode);
|
||||
var attribute = Assert.Single(output.Attributes);
|
||||
Assert.Equal("Another attribute", attribute.Name);
|
||||
|
||||
// Act - 2
|
||||
await output.GetChildContentAsync();
|
||||
|
||||
// Assert - 2
|
||||
Assert.Equal(0, callCount);
|
||||
Assert.Equal(1, updatedCallCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExecutionContext_Reinitialize_UpdatesTagHelperContextAsExpected()
|
||||
{
|
||||
// Arrange
|
||||
var tagName = "div";
|
||||
var tagMode = TagMode.StartTagOnly;
|
||||
var items = new Dictionary<object, object>();
|
||||
var uniqueId = "some unique id";
|
||||
var callCount = 0;
|
||||
Func<Task> executeChildContentAsync = () =>
|
||||
{
|
||||
callCount++;
|
||||
return Task.FromResult(true);
|
||||
};
|
||||
Action<HtmlEncoder> startWritingScope = _ => { };
|
||||
Func<TagHelperContent> endWritingScope = () => null;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
tagName,
|
||||
tagMode,
|
||||
items,
|
||||
uniqueId,
|
||||
executeChildContentAsync,
|
||||
startWritingScope,
|
||||
endWritingScope);
|
||||
var updatedItems = new Dictionary<object, object>();
|
||||
var updatedUniqueId = "another unique id";
|
||||
executionContext.AddHtmlAttribute(new TagHelperAttribute("something"));
|
||||
|
||||
// Act
|
||||
executionContext.Reinitialize(
|
||||
tagName,
|
||||
tagMode,
|
||||
updatedItems,
|
||||
updatedUniqueId,
|
||||
executeChildContentAsync);
|
||||
executionContext.AddHtmlAttribute(new TagHelperAttribute("Another attribute"));
|
||||
|
||||
// Assert
|
||||
var context = executionContext.Context;
|
||||
var attribute = Assert.Single(context.AllAttributes);
|
||||
Assert.Equal(tagName, context.TagName);
|
||||
Assert.Equal("Another attribute", attribute.Name);
|
||||
Assert.Equal(updatedUniqueId, context.UniqueId);
|
||||
Assert.Same(updatedItems, context.Items);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(TagMode.SelfClosing)]
|
||||
[InlineData(TagMode.StartTagAndEndTag)]
|
||||
[InlineData(TagMode.StartTagOnly)]
|
||||
public void ExecutionContext_CreateTagHelperOutput_ReturnsExpectedTagMode(TagMode tagMode)
|
||||
{
|
||||
// Arrange
|
||||
var executionContext = new TagHelperExecutionContext("p", tagMode);
|
||||
|
||||
// Act
|
||||
var output = executionContext.Output;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(tagMode, output.TagMode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParentItems_SetsItemsProperty()
|
||||
{
|
||||
// Arrange
|
||||
var expectedItems = new Dictionary<object, object>
|
||||
{
|
||||
{ "test-entry", 1234 }
|
||||
};
|
||||
|
||||
// Act
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: expectedItems,
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: async () => await Task.FromResult(result: true),
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent());
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(executionContext.Items);
|
||||
Assert.Same(expectedItems, executionContext.Items);
|
||||
}
|
||||
|
||||
public static TheoryData<HtmlEncoder> HtmlEncoderData
|
||||
{
|
||||
get
|
||||
{
|
||||
return new TheoryData<HtmlEncoder>
|
||||
{
|
||||
null,
|
||||
HtmlEncoder.Default,
|
||||
NullHtmlEncoder.Default,
|
||||
new HtmlTestEncoder(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static TheoryData<HtmlEncoder> HtmlEncoderDataLessNull
|
||||
{
|
||||
get
|
||||
{
|
||||
var data = new TheoryData<HtmlEncoder>();
|
||||
foreach (var row in HtmlEncoderData)
|
||||
{
|
||||
var encoder = (HtmlEncoder)(row[0]);
|
||||
if (encoder != null)
|
||||
{
|
||||
data.Add(encoder);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(HtmlEncoderData))]
|
||||
public async Task GetChildContentAsync_ReturnsExpectedContent(HtmlEncoder encoder)
|
||||
{
|
||||
// Arrange
|
||||
var tagHelperContent = new DefaultTagHelperContent();
|
||||
var executionCount = 0;
|
||||
var content = "Hello from child content";
|
||||
var expectedContent = $"HtmlEncode[[{content}]]";
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () =>
|
||||
{
|
||||
executionCount++;
|
||||
tagHelperContent.SetContent(content);
|
||||
|
||||
return Task.FromResult(result: true);
|
||||
},
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => tagHelperContent);
|
||||
|
||||
// Act
|
||||
var actualContent = await executionContext.GetChildContentAsync(useCachedResult: true, encoder: encoder);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedContent, actualContent.GetContent(new HtmlTestEncoder()));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(HtmlEncoderData))]
|
||||
public async Task GetChildContentAsync_StartsWritingScopeWithGivenEncoder(HtmlEncoder encoder)
|
||||
{
|
||||
// Arrange
|
||||
HtmlEncoder passedEncoder = null;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () => Task.FromResult(result: true),
|
||||
startTagHelperWritingScope: encoderArgument => passedEncoder = encoderArgument,
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent());
|
||||
|
||||
// Act
|
||||
await executionContext.GetChildContentAsync(useCachedResult: true, encoder: encoder);
|
||||
|
||||
// Assert
|
||||
Assert.Same(encoder, passedEncoder);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(HtmlEncoderData))]
|
||||
public async Task GetChildContentAsync_CachesValue(HtmlEncoder encoder)
|
||||
{
|
||||
// Arrange
|
||||
var executionCount = 0;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () =>
|
||||
{
|
||||
executionCount++;
|
||||
return Task.FromResult(result: true);
|
||||
},
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent());
|
||||
|
||||
// Act
|
||||
var content1 = await executionContext.GetChildContentAsync(useCachedResult: true, encoder: encoder);
|
||||
var content2 = await executionContext.GetChildContentAsync(useCachedResult: true, encoder: encoder);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(1, executionCount);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(HtmlEncoderDataLessNull))]
|
||||
public async Task GetChildContentAsync_CachesValuePerEncoder(HtmlEncoder encoder)
|
||||
{
|
||||
// Arrange
|
||||
var executionCount = 0;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () =>
|
||||
{
|
||||
executionCount++;
|
||||
return Task.FromResult(result: true);
|
||||
},
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent());
|
||||
|
||||
// Act
|
||||
var content1 = await executionContext.GetChildContentAsync(useCachedResult: true, encoder: null);
|
||||
var content2 = await executionContext.GetChildContentAsync(useCachedResult: true, encoder: encoder);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, executionCount);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(HtmlEncoderData))]
|
||||
public async Task GetChildContentAsync_CachesValuePerEncoderInstance(HtmlEncoder encoder)
|
||||
{
|
||||
// Arrange
|
||||
var executionCount = 0;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () =>
|
||||
{
|
||||
executionCount++;
|
||||
return Task.FromResult(result: true);
|
||||
},
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent());
|
||||
|
||||
// HtmlEncoderData includes another HtmlTestEncoder instance but method compares HtmlEncoder instances.
|
||||
var firstEncoder = new HtmlTestEncoder();
|
||||
|
||||
// Act
|
||||
var content1 = await executionContext.GetChildContentAsync(useCachedResult: true, encoder: firstEncoder);
|
||||
var content2 = await executionContext.GetChildContentAsync(useCachedResult: true, encoder: encoder);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, executionCount);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(HtmlEncoderData))]
|
||||
public async Task GetChildContentAsync_CanExecuteChildrenMoreThanOnce(HtmlEncoder encoder)
|
||||
{
|
||||
// Arrange
|
||||
var executionCount = 0;
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () =>
|
||||
{
|
||||
executionCount++;
|
||||
return Task.FromResult(result: true);
|
||||
},
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent());
|
||||
|
||||
// Act
|
||||
await executionContext.GetChildContentAsync(useCachedResult: false, encoder: encoder);
|
||||
await executionContext.GetChildContentAsync(useCachedResult: false, encoder: encoder);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, executionCount);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task GetChildContentAsync_ReturnsNewObjectEveryTimeItIsCalled(bool useCachedResult)
|
||||
{
|
||||
// Arrange
|
||||
var executionContext = new TagHelperExecutionContext(
|
||||
"p",
|
||||
tagMode: TagMode.StartTagAndEndTag,
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: () => Task.FromResult(result: true),
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent());
|
||||
|
||||
// Act
|
||||
var content1 = await executionContext.GetChildContentAsync(useCachedResult, encoder: null);
|
||||
var content2 = await executionContext.GetChildContentAsync(useCachedResult, encoder: null);
|
||||
|
||||
// Assert
|
||||
Assert.NotSame(content1, content2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddHtmlAttribute_MaintainsHtmlAttributes()
|
||||
{
|
||||
// Arrange
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var expectedAttributes = new TagHelperAttributeList
|
||||
{
|
||||
{ "class", "btn" },
|
||||
};
|
||||
expectedAttributes.Add(new TagHelperAttribute("type", "text", HtmlAttributeValueStyle.SingleQuotes));
|
||||
|
||||
// Act
|
||||
executionContext.AddHtmlAttribute("class", "btn", HtmlAttributeValueStyle.DoubleQuotes);
|
||||
executionContext.AddHtmlAttribute("type", "text", HtmlAttributeValueStyle.SingleQuotes);
|
||||
var output = executionContext.Output;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(
|
||||
expectedAttributes,
|
||||
output.Attributes,
|
||||
CaseSensitiveTagHelperAttributeComparer.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddHtmlAttribute_MaintainsMinimizedHtmlAttributes()
|
||||
{
|
||||
// Arrange
|
||||
var executionContext = new TagHelperExecutionContext("input", tagMode: TagMode.StartTagOnly);
|
||||
var expectedAttributes = new TagHelperAttributeList
|
||||
{
|
||||
new TagHelperAttribute("checked"),
|
||||
new TagHelperAttribute("visible"),
|
||||
};
|
||||
|
||||
// Act
|
||||
executionContext.AddHtmlAttribute(new TagHelperAttribute("checked"));
|
||||
executionContext.AddHtmlAttribute(new TagHelperAttribute("visible"));
|
||||
var output = executionContext.Output;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(
|
||||
expectedAttributes,
|
||||
output.Attributes,
|
||||
CaseSensitiveTagHelperAttributeComparer.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddHtmlAttribute_MaintainsHtmlAttributes_VariousStyles()
|
||||
{
|
||||
// Arrange
|
||||
var executionContext = new TagHelperExecutionContext("input", tagMode: TagMode.SelfClosing);
|
||||
var expectedAttributes = new TagHelperAttributeList
|
||||
{
|
||||
{ "class", "btn" },
|
||||
{ "foo", "bar" }
|
||||
};
|
||||
expectedAttributes.Add(new TagHelperAttribute("valid", "true", HtmlAttributeValueStyle.NoQuotes));
|
||||
expectedAttributes.Add(new TagHelperAttribute("type", "text", HtmlAttributeValueStyle.SingleQuotes));
|
||||
expectedAttributes.Add(new TagHelperAttribute(name: "checked"));
|
||||
expectedAttributes.Add(new TagHelperAttribute(name: "visible"));
|
||||
|
||||
// Act
|
||||
executionContext.AddHtmlAttribute("class", "btn", HtmlAttributeValueStyle.DoubleQuotes);
|
||||
executionContext.AddHtmlAttribute("foo", "bar", HtmlAttributeValueStyle.DoubleQuotes);
|
||||
executionContext.AddHtmlAttribute("valid", "true", HtmlAttributeValueStyle.NoQuotes);
|
||||
executionContext.AddHtmlAttribute("type", "text", HtmlAttributeValueStyle.SingleQuotes);
|
||||
executionContext.AddHtmlAttribute(new TagHelperAttribute("checked"));
|
||||
executionContext.AddHtmlAttribute(new TagHelperAttribute("visible"));
|
||||
var output = executionContext.Output;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(
|
||||
expectedAttributes,
|
||||
output.Attributes,
|
||||
CaseSensitiveTagHelperAttributeComparer.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TagHelperExecutionContext_MaintainsAllAttributes()
|
||||
{
|
||||
// Arrange
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var expectedAttributes = new TagHelperAttributeList
|
||||
{
|
||||
{ "class", "btn" },
|
||||
};
|
||||
expectedAttributes.Add(new TagHelperAttribute("something", true, HtmlAttributeValueStyle.SingleQuotes));
|
||||
expectedAttributes.Add(new TagHelperAttribute("type", "text", HtmlAttributeValueStyle.NoQuotes));
|
||||
|
||||
// Act
|
||||
executionContext.AddHtmlAttribute("class", "btn", HtmlAttributeValueStyle.DoubleQuotes);
|
||||
executionContext.AddTagHelperAttribute("something", true, HtmlAttributeValueStyle.SingleQuotes);
|
||||
executionContext.AddHtmlAttribute("type", "text", HtmlAttributeValueStyle.NoQuotes);
|
||||
var context = executionContext.Context;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(
|
||||
expectedAttributes,
|
||||
context.AllAttributes,
|
||||
CaseSensitiveTagHelperAttributeComparer.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Add_MaintainsTagHelpers()
|
||||
{
|
||||
// Arrange
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var tagHelper = new PTagHelper();
|
||||
|
||||
// Act
|
||||
executionContext.Add(tagHelper);
|
||||
|
||||
// Assert
|
||||
var singleTagHelper = Assert.Single(executionContext.TagHelpers);
|
||||
Assert.Same(tagHelper, singleTagHelper);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Add_MaintainsMultipleTagHelpers()
|
||||
{
|
||||
// Arrange
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var tagHelper1 = new PTagHelper();
|
||||
var tagHelper2 = new PTagHelper();
|
||||
|
||||
// Act
|
||||
executionContext.Add(tagHelper1);
|
||||
executionContext.Add(tagHelper2);
|
||||
|
||||
// Assert
|
||||
var tagHelpers = executionContext.TagHelpers.ToArray();
|
||||
Assert.Equal(2, tagHelpers.Length);
|
||||
Assert.Same(tagHelper1, tagHelpers[0]);
|
||||
Assert.Same(tagHelper2, tagHelpers[1]);
|
||||
}
|
||||
|
||||
private class PTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,293 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
|
||||
{
|
||||
public class TagHelperRunnerTest
|
||||
{
|
||||
[Fact]
|
||||
public async Task RunAsync_CallsInitPriorToProcessAsync()
|
||||
{
|
||||
// Arrange
|
||||
var runner = new TagHelperRunner();
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var incrementer = 0;
|
||||
var callbackTagHelper = new CallbackTagHelper(
|
||||
initCallback: () =>
|
||||
{
|
||||
Assert.Equal(0, incrementer);
|
||||
|
||||
incrementer++;
|
||||
},
|
||||
processAsyncCallback: () =>
|
||||
{
|
||||
Assert.Equal(1, incrementer);
|
||||
|
||||
incrementer++;
|
||||
});
|
||||
executionContext.Add(callbackTagHelper);
|
||||
|
||||
// Act
|
||||
await runner.RunAsync(executionContext);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, incrementer);
|
||||
}
|
||||
|
||||
public static TheoryData TagHelperOrderData
|
||||
{
|
||||
get
|
||||
{
|
||||
// tagHelperOrders, expectedTagHelperOrders
|
||||
return new TheoryData<int[], int[]>
|
||||
{
|
||||
{
|
||||
new[] { 1000, int.MaxValue, 0 },
|
||||
new[] { 0, 1000, int.MaxValue }
|
||||
},
|
||||
{
|
||||
new[] { int.MaxValue, int.MaxValue, int.MinValue },
|
||||
new[] { int.MinValue, int.MaxValue, int.MaxValue }
|
||||
},
|
||||
{
|
||||
new[] { 0, 0, int.MinValue },
|
||||
new[] { int.MinValue, 0, 0 }
|
||||
},
|
||||
{
|
||||
new[] { int.MinValue, -1000, 0 },
|
||||
new[] { int.MinValue, -1000, 0 }
|
||||
},
|
||||
{
|
||||
new[] { 0, 1000, int.MaxValue },
|
||||
new[] { 0, 1000, int.MaxValue }
|
||||
},
|
||||
{
|
||||
new[] { int.MaxValue, int.MinValue, int.MaxValue, -1000, int.MaxValue, 0 },
|
||||
new[] { int.MinValue, -1000, 0, int.MaxValue, int.MaxValue, int.MaxValue }
|
||||
},
|
||||
{
|
||||
new[] { 0, 0, 0, 0 },
|
||||
new[] { 0, 0, 0, 0 }
|
||||
},
|
||||
|
||||
{
|
||||
new[] { 1000, int.MaxValue, 0, -1000, int.MinValue },
|
||||
new[] { int.MinValue, -1000, 0, 1000, int.MaxValue }
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(TagHelperOrderData))]
|
||||
public async Task RunAsync_OrdersTagHelpers(
|
||||
int[] tagHelperOrders,
|
||||
int[] expectedTagHelperOrders)
|
||||
{
|
||||
// Arrange
|
||||
var runner = new TagHelperRunner();
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var processOrder = new List<int>();
|
||||
|
||||
foreach (var order in tagHelperOrders)
|
||||
{
|
||||
var orderedTagHelper = new OrderedTagHelper(order)
|
||||
{
|
||||
ProcessOrderTracker = processOrder
|
||||
};
|
||||
executionContext.Add(orderedTagHelper);
|
||||
}
|
||||
|
||||
// Act
|
||||
await runner.RunAsync(executionContext);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedTagHelperOrders, processOrder);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(TagMode.SelfClosing)]
|
||||
[InlineData(TagMode.StartTagAndEndTag)]
|
||||
[InlineData(TagMode.StartTagOnly)]
|
||||
public async Task RunAsync_SetsTagHelperOutputTagMode(TagMode tagMode)
|
||||
{
|
||||
// Arrange
|
||||
var runner = new TagHelperRunner();
|
||||
var executionContext = new TagHelperExecutionContext("p", tagMode);
|
||||
var tagHelper = new TagHelperContextTouchingTagHelper();
|
||||
|
||||
executionContext.Add(tagHelper);
|
||||
executionContext.AddTagHelperAttribute("foo", true, HtmlAttributeValueStyle.DoubleQuotes);
|
||||
|
||||
// Act
|
||||
await runner.RunAsync(executionContext);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(tagMode, executionContext.Output.TagMode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RunAsync_ProcessesAllTagHelpers()
|
||||
{
|
||||
// Arrange
|
||||
var runner = new TagHelperRunner();
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var executableTagHelper1 = new ExecutableTagHelper();
|
||||
var executableTagHelper2 = new ExecutableTagHelper();
|
||||
|
||||
// Act
|
||||
executionContext.Add(executableTagHelper1);
|
||||
executionContext.Add(executableTagHelper2);
|
||||
await runner.RunAsync(executionContext);
|
||||
|
||||
// Assert
|
||||
Assert.True(executableTagHelper1.Processed);
|
||||
Assert.True(executableTagHelper2.Processed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RunAsync_AllowsModificationOfTagHelperOutput()
|
||||
{
|
||||
// Arrange
|
||||
var runner = new TagHelperRunner();
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var executableTagHelper = new ExecutableTagHelper();
|
||||
|
||||
// Act
|
||||
executionContext.Add(executableTagHelper);
|
||||
executionContext.AddHtmlAttribute("class", "btn", HtmlAttributeValueStyle.DoubleQuotes);
|
||||
await runner.RunAsync(executionContext);
|
||||
|
||||
// Assert
|
||||
var output = executionContext.Output;
|
||||
Assert.Equal("foo", output.TagName);
|
||||
Assert.Equal("somethingelse", output.Attributes["class"].Value);
|
||||
Assert.Equal("world", output.Attributes["hello"].Value);
|
||||
Assert.Equal(TagMode.SelfClosing, output.TagMode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RunAsync_AllowsDataRetrievalFromTagHelperContext()
|
||||
{
|
||||
// Arrange
|
||||
var runner = new TagHelperRunner();
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var tagHelper = new TagHelperContextTouchingTagHelper();
|
||||
|
||||
// Act
|
||||
executionContext.Add(tagHelper);
|
||||
executionContext.AddTagHelperAttribute("foo", true, HtmlAttributeValueStyle.DoubleQuotes);
|
||||
await runner.RunAsync(executionContext);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("True", executionContext.Output.Attributes["foo"].Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RunAsync_ConfiguresTagHelperContextWithExecutionContextsItems()
|
||||
{
|
||||
// Arrange
|
||||
var runner = new TagHelperRunner();
|
||||
var executionContext = new TagHelperExecutionContext("p", TagMode.StartTagAndEndTag);
|
||||
var tagHelper = new ContextInspectingTagHelper();
|
||||
executionContext.Add(tagHelper);
|
||||
|
||||
// Act
|
||||
await runner.RunAsync(executionContext);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(tagHelper.ContextProcessedWith);
|
||||
Assert.Same(tagHelper.ContextProcessedWith.Items, executionContext.Items);
|
||||
}
|
||||
|
||||
private class ExecutableTagHelper : TagHelper
|
||||
{
|
||||
public bool Processed { get; set; }
|
||||
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
Processed = true;
|
||||
|
||||
output.TagName = "foo";
|
||||
|
||||
var classIndex = output.Attributes.IndexOfName("class");
|
||||
if (classIndex != -1)
|
||||
{
|
||||
output.Attributes[classIndex] = new TagHelperAttribute("class", "somethingelse");
|
||||
}
|
||||
|
||||
output.Attributes.Add("hello", "world");
|
||||
output.TagMode = TagMode.SelfClosing;
|
||||
}
|
||||
}
|
||||
|
||||
private class ContextInspectingTagHelper : TagHelper
|
||||
{
|
||||
public TagHelperContext ContextProcessedWith { get; set; }
|
||||
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
ContextProcessedWith = context;
|
||||
}
|
||||
}
|
||||
|
||||
private class TagHelperContextTouchingTagHelper : TagHelper
|
||||
{
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
output.Attributes.Add("foo", context.AllAttributes["foo"].Value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private class OrderedTagHelper : TagHelper
|
||||
{
|
||||
public OrderedTagHelper(int order)
|
||||
{
|
||||
Order = order;
|
||||
}
|
||||
|
||||
public override int Order { get; }
|
||||
public IList<int> ProcessOrderTracker { get; set; }
|
||||
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
// If using this class for testing, ensure that ProcessOrderTracker is always set prior to Process
|
||||
// execution.
|
||||
Debug.Assert(ProcessOrderTracker != null);
|
||||
|
||||
ProcessOrderTracker.Add(Order);
|
||||
}
|
||||
}
|
||||
|
||||
private class CallbackTagHelper : TagHelper
|
||||
{
|
||||
private readonly Action _initCallback;
|
||||
private readonly Action _processAsyncCallback;
|
||||
|
||||
public CallbackTagHelper(Action initCallback, Action processAsyncCallback)
|
||||
{
|
||||
_initCallback = initCallback;
|
||||
_processAsyncCallback = processAsyncCallback;
|
||||
}
|
||||
|
||||
public override void Init(TagHelperContext context)
|
||||
{
|
||||
_initCallback();
|
||||
}
|
||||
|
||||
public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
_processAsyncCallback();
|
||||
|
||||
return base.ProcessAsync(context, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,244 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
|
||||
{
|
||||
public class TagHelperScopeManagerTest
|
||||
{
|
||||
[Fact]
|
||||
public void Begin_DoesNotRequireParentExecutionContext()
|
||||
{
|
||||
// Arrange & Act
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
|
||||
// Act
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
executionContext.Items["test-entry"] = 1234;
|
||||
|
||||
// Assert
|
||||
var executionContextItem = Assert.Single(executionContext.Items);
|
||||
Assert.Equal("test-entry", (string)executionContextItem.Key, StringComparer.Ordinal);
|
||||
Assert.Equal(1234, executionContextItem.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Begin_ReturnedExecutionContext_ItemsAreRetrievedFromParentExecutionContext()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
var parentExecutionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
parentExecutionContext.Items["test-entry"] = 1234;
|
||||
|
||||
// Act
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
|
||||
// Assert
|
||||
var executionContextItem = Assert.Single(executionContext.Items);
|
||||
Assert.Equal("test-entry", (string)executionContextItem.Key, StringComparer.Ordinal);
|
||||
Assert.Equal(1234, executionContextItem.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Begin_DoesShallowCopyOfParentItems()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
var parentComplexObject = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||
var parentExecutionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
parentExecutionContext.Items["test-entry"] = parentComplexObject;
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
|
||||
// Act
|
||||
((Dictionary<string, int>)executionContext.Items["test-entry"]).Add("from-child", 1234);
|
||||
|
||||
// Assert
|
||||
var executionContextItem = Assert.Single(executionContext.Items);
|
||||
Assert.Equal("test-entry", (string)executionContextItem.Key, StringComparer.Ordinal);
|
||||
Assert.Same(parentComplexObject, executionContextItem.Value);
|
||||
var parentEntry = Assert.Single(parentComplexObject);
|
||||
Assert.Equal("from-child", parentEntry.Key, StringComparer.Ordinal);
|
||||
Assert.Equal(1234, parentEntry.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Begin_ReturnedExecutionContext_ItemsModificationDoesNotAffectParent()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
var parentExecutionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
parentExecutionContext.Items["test-entry"] = 1234;
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
|
||||
// Act
|
||||
executionContext.Items["test-entry"] = 2222;
|
||||
|
||||
// Assert
|
||||
var executionContextItem = Assert.Single(executionContext.Items);
|
||||
Assert.Equal("test-entry", (string)executionContextItem.Key, StringComparer.Ordinal);
|
||||
Assert.Equal(2222, executionContextItem.Value);
|
||||
var parentExecutionContextItem = Assert.Single(parentExecutionContext.Items);
|
||||
Assert.Equal("test-entry", (string)parentExecutionContextItem.Key, StringComparer.Ordinal);
|
||||
Assert.Equal(1234, parentExecutionContextItem.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Begin_ReturnedExecutionContext_ItemsInsertionDoesNotAffectParent()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
var parentExecutionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
|
||||
// Act
|
||||
executionContext.Items["new-entry"] = 2222;
|
||||
|
||||
// Assert
|
||||
var executionContextItem = Assert.Single(executionContext.Items);
|
||||
Assert.Equal("new-entry", (string)executionContextItem.Key, StringComparer.Ordinal);
|
||||
Assert.Equal(2222, executionContextItem.Value);
|
||||
Assert.Empty(parentExecutionContext.Items);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Begin_ReturnedExecutionContext_ItemsRemovalDoesNotAffectParent()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
var parentExecutionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
parentExecutionContext.Items["test-entry"] = 1234;
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
|
||||
// Act
|
||||
executionContext.Items.Remove("test-entry");
|
||||
|
||||
// Assert
|
||||
Assert.Empty(executionContext.Items);
|
||||
var parentExecutionContextItem = Assert.Single(parentExecutionContext.Items);
|
||||
Assert.Equal("test-entry", (string)parentExecutionContextItem.Key, StringComparer.Ordinal);
|
||||
Assert.Equal(1234, parentExecutionContextItem.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Begin_CreatesContexts_TagHelperOutput_WithAppropriateTagName()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
|
||||
// Act
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
var output = executionContext.Output;
|
||||
|
||||
// Assert
|
||||
Assert.Equal("p", output.TagName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Begin_CanNest()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
|
||||
// Act
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
executionContext = BeginDefaultScope(scopeManager, tagName: "div");
|
||||
var output = executionContext.Output;
|
||||
|
||||
// Assert
|
||||
Assert.Equal("div", output.TagName);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(TagMode.SelfClosing)]
|
||||
[InlineData(TagMode.StartTagAndEndTag)]
|
||||
[InlineData(TagMode.StartTagOnly)]
|
||||
public void Begin_SetsExecutionContexts_TagHelperOutputTagMode(TagMode tagMode)
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
|
||||
// Act
|
||||
var executionContext = BeginDefaultScope(scopeManager, "p", tagMode);
|
||||
var output = executionContext.Output;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(tagMode, output.TagMode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void End_ReturnsParentExecutionContext()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
|
||||
// Act
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
executionContext = BeginDefaultScope(scopeManager, tagName: "div");
|
||||
executionContext = scopeManager.End();
|
||||
var output = executionContext.Output;
|
||||
|
||||
// Assert
|
||||
Assert.Equal("p", output.TagName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void End_ReturnsNullIfNoNestedContext()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
|
||||
// Act
|
||||
var executionContext = BeginDefaultScope(scopeManager, tagName: "p");
|
||||
executionContext = BeginDefaultScope(scopeManager, tagName: "div");
|
||||
executionContext = scopeManager.End();
|
||||
executionContext = scopeManager.End();
|
||||
|
||||
// Assert
|
||||
Assert.Null(executionContext);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void End_ThrowsIfNoScope()
|
||||
{
|
||||
// Arrange
|
||||
var scopeManager = CreateDefaultScopeManager();
|
||||
var expectedError = string.Format(
|
||||
"Must call '{2}.{1}' before calling '{2}.{0}'.",
|
||||
nameof(TagHelperScopeManager.End),
|
||||
nameof(TagHelperScopeManager.Begin),
|
||||
nameof(TagHelperScopeManager));
|
||||
|
||||
// Act & Assert
|
||||
var ex = Assert.Throws<InvalidOperationException>(() =>
|
||||
{
|
||||
scopeManager.End();
|
||||
});
|
||||
|
||||
Assert.Equal(expectedError, ex.Message);
|
||||
}
|
||||
|
||||
private static TagHelperScopeManager CreateDefaultScopeManager()
|
||||
{
|
||||
return new TagHelperScopeManager(
|
||||
startTagHelperWritingScope: _ => { },
|
||||
endTagHelperWritingScope: () => new DefaultTagHelperContent());
|
||||
}
|
||||
|
||||
private static TagHelperExecutionContext BeginDefaultScope(
|
||||
TagHelperScopeManager scopeManager,
|
||||
string tagName,
|
||||
TagMode tagMode = TagMode.StartTagAndEndTag)
|
||||
{
|
||||
return scopeManager.Begin(
|
||||
tagName,
|
||||
tagMode,
|
||||
uniqueId: string.Empty,
|
||||
executeChildContentAsync: async () => await Task.FromResult(result: true));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||
{
|
||||
public class Valid_PlainTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
public class Valid_InheritedTagHelper : Valid_PlainTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
public class SingleAttributeTagHelper : TagHelper
|
||||
{
|
||||
public int IntAttribute { get; set; }
|
||||
}
|
||||
|
||||
public class MissingAccessorTagHelper : TagHelper
|
||||
{
|
||||
public string ValidAttribute { get; set; }
|
||||
public string InvalidNoGetAttribute { set { } }
|
||||
public string InvalidNoSetAttribute { get { return string.Empty; } }
|
||||
}
|
||||
|
||||
public class NonPublicAccessorTagHelper : TagHelper
|
||||
{
|
||||
public string ValidAttribute { get; set; }
|
||||
public string InvalidPrivateSetAttribute { get; private set; }
|
||||
public string InvalidPrivateGetAttribute { private get; set; }
|
||||
protected string InvalidProtectedAttribute { get; set; }
|
||||
internal string InvalidInternalAttribute { get; set; }
|
||||
protected internal string InvalidProtectedInternalAttribute { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The summary for <see cref="DocumentedTagHelper"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Inherits from <see cref="TagHelper"/>.
|
||||
/// </remarks>
|
||||
[OutputElementHint("p")]
|
||||
public class DocumentedTagHelper : TagHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// This <see cref="SummaryProperty"/> is of type <see cref="string"/>.
|
||||
/// </summary>
|
||||
public string SummaryProperty { get; set; }
|
||||
|
||||
/// <remarks>
|
||||
/// The <see cref="SummaryProperty"/> may be <c>null</c>.
|
||||
/// </remarks>
|
||||
public int RemarksProperty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is a complex <see cref="IDictionary{string, bool}"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="SummaryProperty"/><see cref="RemarksProperty"/>
|
||||
/// </remarks>
|
||||
public IDictionary<string, bool> RemarksAndSummaryProperty { get; set; }
|
||||
|
||||
public bool UndocumentedProperty { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,429 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||
{
|
||||
public enum CustomEnum
|
||||
{
|
||||
FirstValue,
|
||||
SecondValue
|
||||
}
|
||||
|
||||
public class EnumTagHelper : TagHelper
|
||||
{
|
||||
public int NonEnumProperty { get; set; }
|
||||
|
||||
public CustomEnum EnumProperty { get; set; }
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p")]
|
||||
[HtmlTargetElement("input")]
|
||||
public class MultiEnumTagHelper : EnumTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("input", ParentTag = "div")]
|
||||
public class RequiredParentTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p", ParentTag = "div")]
|
||||
[HtmlTargetElement("input", ParentTag = "section")]
|
||||
public class MultiSpecifiedRequiredParentTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p")]
|
||||
[HtmlTargetElement("input", ParentTag = "div")]
|
||||
public class MultiWithUnspecifiedRequiredParentTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[RestrictChildren("p")]
|
||||
public class RestrictChildrenTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[RestrictChildren("p", "strong")]
|
||||
public class DoubleRestrictChildrenTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p")]
|
||||
[HtmlTargetElement("div")]
|
||||
[RestrictChildren("p", "strong")]
|
||||
public class MultiTargetRestrictChildrenTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("input", TagStructure = TagStructure.WithoutEndTag)]
|
||||
public class TagStructureTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p", TagStructure = TagStructure.NormalOrSelfClosing)]
|
||||
[HtmlTargetElement("input", TagStructure = TagStructure.WithoutEndTag)]
|
||||
public class MultiSpecifiedTagStructureTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p")]
|
||||
[HtmlTargetElement("input", TagStructure = TagStructure.WithoutEndTag)]
|
||||
public class MultiWithUnspecifiedTagStructureTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Always)]
|
||||
public class DefaultEditorBrowsableTagHelper : TagHelper
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Always)]
|
||||
public int Property { get; set; }
|
||||
}
|
||||
|
||||
public class HiddenPropertyEditorBrowsableTagHelper : TagHelper
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public int Property { get; set; }
|
||||
}
|
||||
|
||||
public class MultiPropertyEditorBrowsableTagHelper : TagHelper
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public int Property { get; set; }
|
||||
|
||||
public virtual int Property2 { get; set; }
|
||||
}
|
||||
|
||||
public class OverriddenPropertyEditorBrowsableTagHelper : MultiPropertyEditorBrowsableTagHelper
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override int Property2 { get; set; }
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public class EditorBrowsableTagHelper : TagHelper
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public virtual int Property { get; set; }
|
||||
}
|
||||
|
||||
public class InheritedEditorBrowsableTagHelper : EditorBrowsableTagHelper
|
||||
{
|
||||
public override int Property { get; set; }
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
public class OverriddenEditorBrowsableTagHelper : EditorBrowsableTagHelper
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
public override int Property { get; set; }
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p")]
|
||||
[HtmlTargetElement("div")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public class MultiEditorBrowsableTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement(Attributes = "class*")]
|
||||
public class AttributeWildcardTargetingTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement(Attributes = "class*,style*")]
|
||||
public class MultiAttributeWildcardTargetingTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement(Attributes = "class")]
|
||||
public class AttributeTargetingTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement(Attributes = "class,style")]
|
||||
public class MultiAttributeTargetingTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement(Attributes = "custom")]
|
||||
[HtmlTargetElement(Attributes = "class,style")]
|
||||
public class MultiAttributeAttributeTargetingTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement(Attributes = "style")]
|
||||
public class InheritedAttributeTargetingTagHelper : AttributeTargetingTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("input", Attributes = "class")]
|
||||
public class RequiredAttributeTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("div", Attributes = "class")]
|
||||
public class InheritedRequiredAttributeTagHelper : RequiredAttributeTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("div", Attributes = "class")]
|
||||
[HtmlTargetElement("input", Attributes = "class")]
|
||||
public class MultiAttributeRequiredAttributeTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("input", Attributes = "style")]
|
||||
[HtmlTargetElement("input", Attributes = "class")]
|
||||
public class MultiAttributeSameTagRequiredAttributeTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("input", Attributes = "class,style")]
|
||||
public class MultiRequiredAttributeTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("div", Attributes = "style")]
|
||||
public class InheritedMultiRequiredAttributeTagHelper : MultiRequiredAttributeTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("div", Attributes = "class,style")]
|
||||
[HtmlTargetElement("input", Attributes = "class,style")]
|
||||
public class MultiTagMultiRequiredAttributeTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p")]
|
||||
[HtmlTargetElement("div")]
|
||||
public class MultiTagTagHelper
|
||||
{
|
||||
public string ValidAttribute { get; set; }
|
||||
}
|
||||
|
||||
public class InheritedMultiTagTagHelper : MultiTagTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("p")]
|
||||
[HtmlTargetElement("p")]
|
||||
[HtmlTargetElement("div")]
|
||||
[HtmlTargetElement("div")]
|
||||
public class DuplicateTagNameTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("data-condition")]
|
||||
public class OverrideNameTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
public class InheritedSingleAttributeTagHelper : SingleAttributeTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
public class DuplicateAttributeNameTagHelper
|
||||
{
|
||||
public string MyNameIsLegion { get; set; }
|
||||
|
||||
[HtmlAttributeName("my-name-is-legion")]
|
||||
public string Fred { get; set; }
|
||||
}
|
||||
|
||||
public class NotBoundAttributeTagHelper
|
||||
{
|
||||
public object BoundProperty { get; set; }
|
||||
|
||||
[HtmlAttributeNotBound]
|
||||
public string NotBoundProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("unused")]
|
||||
[HtmlAttributeNotBound]
|
||||
public string NamedNotBoundProperty { get; set; }
|
||||
}
|
||||
|
||||
public class OverriddenAttributeTagHelper
|
||||
{
|
||||
[HtmlAttributeName("SomethingElse")]
|
||||
public virtual string ValidAttribute1 { get; set; }
|
||||
|
||||
[HtmlAttributeName("Something-Else")]
|
||||
public string ValidAttribute2 { get; set; }
|
||||
}
|
||||
|
||||
public class InheritedOverriddenAttributeTagHelper : OverriddenAttributeTagHelper
|
||||
{
|
||||
public override string ValidAttribute1 { get; set; }
|
||||
}
|
||||
|
||||
public class InheritedNotOverriddenAttributeTagHelper : OverriddenAttributeTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
public class ALLCAPSTAGHELPER : TagHelper
|
||||
{
|
||||
public int ALLCAPSATTRIBUTE { get; set; }
|
||||
}
|
||||
|
||||
public class CAPSOnOUTSIDETagHelper : TagHelper
|
||||
{
|
||||
public int CAPSOnOUTSIDEATTRIBUTE { get; set; }
|
||||
}
|
||||
|
||||
public class capsONInsideTagHelper : TagHelper
|
||||
{
|
||||
public int capsONInsideattribute { get; set; }
|
||||
}
|
||||
|
||||
public class One1Two2Three3TagHelper : TagHelper
|
||||
{
|
||||
public int One1Two2Three3Attribute { get; set; }
|
||||
}
|
||||
|
||||
public class ONE1TWO2THREE3TagHelper : TagHelper
|
||||
{
|
||||
public int ONE1TWO2THREE3Attribute { get; set; }
|
||||
}
|
||||
|
||||
public class First_Second_ThirdHiTagHelper : TagHelper
|
||||
{
|
||||
public int First_Second_ThirdAttribute { get; set; }
|
||||
}
|
||||
|
||||
public class UNSuffixedCLASS : TagHelper
|
||||
{
|
||||
public int UNSuffixedATTRIBUTE { get; set; }
|
||||
}
|
||||
|
||||
public class InvalidBoundAttribute : TagHelper
|
||||
{
|
||||
public string DataSomething { get; set; }
|
||||
}
|
||||
|
||||
public class InvalidBoundAttributeWithValid : SingleAttributeTagHelper
|
||||
{
|
||||
public string DataSomething { get; set; }
|
||||
}
|
||||
|
||||
public class OverriddenInvalidBoundAttributeWithValid : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("valid-something")]
|
||||
public string DataSomething { get; set; }
|
||||
}
|
||||
|
||||
public class OverriddenValidBoundAttributeWithInvalid : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("data-something")]
|
||||
public string ValidSomething { get; set; }
|
||||
}
|
||||
|
||||
public class OverriddenValidBoundAttributeWithInvalidUpperCase : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("DATA-SOMETHING")]
|
||||
public string ValidSomething { get; set; }
|
||||
}
|
||||
|
||||
public class DefaultValidHtmlAttributePrefix : TagHelper
|
||||
{
|
||||
public IDictionary<string, string> DictionaryProperty { get; set; }
|
||||
}
|
||||
|
||||
public class SingleValidHtmlAttributePrefix : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("valid-name")]
|
||||
public IDictionary<string, string> DictionaryProperty { get; set; }
|
||||
}
|
||||
|
||||
public class MultipleValidHtmlAttributePrefix : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("valid-name1", DictionaryAttributePrefix = "valid-prefix1-")]
|
||||
public Dictionary<string, object> DictionaryProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name2", DictionaryAttributePrefix = "valid-prefix2-")]
|
||||
public DictionarySubclass DictionarySubclassProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name3", DictionaryAttributePrefix = "valid-prefix3-")]
|
||||
public DictionaryWithoutParameterlessConstructor DictionaryWithoutParameterlessConstructorProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name4", DictionaryAttributePrefix = "valid-prefix4-")]
|
||||
public GenericDictionarySubclass<object> GenericDictionarySubclassProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name5", DictionaryAttributePrefix = "valid-prefix5-")]
|
||||
public SortedDictionary<string, int> SortedDictionaryProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name6")]
|
||||
public string StringProperty { get; set; }
|
||||
|
||||
public IDictionary<string, int> GetOnlyDictionaryProperty { get; }
|
||||
|
||||
[HtmlAttributeName(DictionaryAttributePrefix = "valid-prefix6")]
|
||||
public IDictionary<string, string> GetOnlyDictionaryPropertyWithAttributePrefix { get; }
|
||||
}
|
||||
|
||||
public class SingleInvalidHtmlAttributePrefix : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("valid-name", DictionaryAttributePrefix = "valid-prefix")]
|
||||
public string StringProperty { get; set; }
|
||||
}
|
||||
|
||||
public class MultipleInvalidHtmlAttributePrefix : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("valid-name1")]
|
||||
public long LongProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name2", DictionaryAttributePrefix = "valid-prefix2-")]
|
||||
public Dictionary<int, string> DictionaryOfIntProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name3", DictionaryAttributePrefix = "valid-prefix3-")]
|
||||
public IReadOnlyDictionary<string, object> ReadOnlyDictionaryProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name4", DictionaryAttributePrefix = "valid-prefix4-")]
|
||||
public int IntProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName("valid-name5", DictionaryAttributePrefix = "valid-prefix5-")]
|
||||
public DictionaryOfIntSubclass DictionaryOfIntSubclassProperty { get; set; }
|
||||
|
||||
[HtmlAttributeName(DictionaryAttributePrefix = "valid-prefix6")]
|
||||
public IDictionary<int, string> GetOnlyDictionaryAttributePrefix { get; }
|
||||
|
||||
[HtmlAttributeName("invalid-name7")]
|
||||
public IDictionary<string, object> GetOnlyDictionaryPropertyWithAttributeName { get; }
|
||||
}
|
||||
|
||||
public class DictionarySubclass : Dictionary<string, string>
|
||||
{
|
||||
}
|
||||
|
||||
public class DictionaryWithoutParameterlessConstructor : Dictionary<string, string>
|
||||
{
|
||||
public DictionaryWithoutParameterlessConstructor(int count)
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class DictionaryOfIntSubclass : Dictionary<int, string>
|
||||
{
|
||||
}
|
||||
|
||||
public class GenericDictionarySubclass<TValue> : Dictionary<string, TValue>
|
||||
{
|
||||
}
|
||||
|
||||
[OutputElementHint("strong")]
|
||||
public class OutputElementHintTagHelper : TagHelper
|
||||
{
|
||||
}
|
||||
|
||||
[HtmlTargetElement("a")]
|
||||
[HtmlTargetElement("p")]
|
||||
[OutputElementHint("div")]
|
||||
public class MulitpleDescriptorTagHelperWithOutputElementHint : TagHelper
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Microsoft.AspNetCore.Razor.Runtime.Test</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper">
|
||||
<summary>
|
||||
nl-BE: The summary for <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
nl-BE: Inherits from <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.TagHelper" />.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty">
|
||||
<summary>
|
||||
nl-BE: This <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> is of type <see cref="T:System.String" />.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty">
|
||||
<remarks>
|
||||
nl-BE: The <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> may be <c>null</c>.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksAndSummaryProperty">
|
||||
<summary>
|
||||
nl-BE: This is a complex <see cref="T:System.Collections.Generic.IDictionary`2" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
nl-BE: <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /><see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty" />
|
||||
</remarks>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Microsoft.AspNetCore.Razor.Runtime.Test</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper">
|
||||
<summary>
|
||||
en-GB: The summary for <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
en-GB: Inherits from <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.TagHelper" />.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty">
|
||||
<summary>
|
||||
en-GB: This <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> is of type <see cref="T:System.String" />.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty">
|
||||
<remarks>
|
||||
en-GB: The <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> may be <c>null</c>.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksAndSummaryProperty">
|
||||
<summary>
|
||||
en-GB: This is a complex <see cref="T:System.Collections.Generic.IDictionary`2" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
en-GB: <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /><see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty" />
|
||||
</remarks>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Microsoft.AspNetCore.Razor.Runtime.Test</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper">
|
||||
<summary>
|
||||
en: The summary for <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
en: Inherits from <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.TagHelper" />.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty">
|
||||
<summary>
|
||||
en: This <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> is of type <see cref="T:System.String" />.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty">
|
||||
<remarks>
|
||||
en: The <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> may be <c>null</c>.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksAndSummaryProperty">
|
||||
<summary>
|
||||
en: This is a complex <see cref="T:System.Collections.Generic.IDictionary`2" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
en: <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /><see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty" />
|
||||
</remarks>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Microsoft.AspNetCore.Razor.Runtime.Test</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper">
|
||||
<summary>
|
||||
fr-FR: The summary for <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
fr-FR: Inherits from <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.TagHelper" />.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty">
|
||||
<summary>
|
||||
fr-FR: This <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> is of type <see cref="T:System.String" />.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty">
|
||||
<remarks>
|
||||
fr-FR: The <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> may be <c>null</c>.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksAndSummaryProperty">
|
||||
<summary>
|
||||
fr-FR: This is a complex <see cref="T:System.Collections.Generic.IDictionary`2" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
fr-FR: <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /><see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty" />
|
||||
</remarks>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Microsoft.AspNetCore.Razor.Runtime.Test</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper">
|
||||
<summary>
|
||||
fr: The summary for <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
fr: Inherits from <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.TagHelper" />.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty">
|
||||
<summary>
|
||||
fr: This <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> is of type <see cref="T:System.String" />.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty">
|
||||
<remarks>
|
||||
fr: The <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /> may be <c>null</c>.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksAndSummaryProperty">
|
||||
<summary>
|
||||
fr: This is a complex <see cref="T:System.Collections.Generic.IDictionary`2" />.
|
||||
</summary>
|
||||
<remarks>
|
||||
fr: <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty" /><see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty" />
|
||||
</remarks>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Microsoft.AspNetCore.Razor.Runtime.Test</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper">
|
||||
<summary>
|
||||
The summary for <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper"/>.
|
||||
</summary>
|
||||
<remarks>
|
||||
Inherits from <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.TagHelper"/>.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty">
|
||||
<summary>
|
||||
This <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty"/> is of type <see cref="T:System.String"/>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty">
|
||||
<remarks>
|
||||
The <see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty"/> may be <c>null</c>.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksAndSummaryProperty">
|
||||
<summary>
|
||||
This is a complex <see cref="T:System.Collections.Generic.IDictionary`2"/>.
|
||||
</summary>
|
||||
<remarks>
|
||||
<see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.SummaryProperty"/><see cref="P:Microsoft.AspNetCore.Razor.TagHelpers.DocumentedTagHelper.RemarksProperty"/>
|
||||
</remarks>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"methodDisplay": "method",
|
||||
"shadowCopy": false
|
||||
}
|
|
@ -5,10 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="$(MicrosoftAspNetCoreHtmlAbstractionsPackageVersion)" />
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourcePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -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<object, object> items,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync,
|
||||
Action<HtmlEncoder> startTagHelperWritingScope,
|
||||
Func<TagHelperContent> endTagHelperWritingScope)
|
||||
{
|
||||
}
|
||||
|
||||
public bool ChildContentRetrieved => false;
|
||||
|
||||
public IDictionary<object, object> Items { get; private set; }
|
||||
|
||||
public IList<ITagHelper> 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<object, object> items,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync)
|
||||
{
|
||||
}
|
||||
|
||||
public Task SetOutputContentAsync()
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<HtmlEncoder> startTagHelperWritingScope,
|
||||
Func<TagHelperContent> endTagHelperWritingScope)
|
||||
{
|
||||
}
|
||||
|
||||
public TagHelperExecutionContext Begin(
|
||||
string tagName,
|
||||
TagMode tagMode,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync)
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
public TagHelperExecutionContext End()
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<bool, HtmlEncoder, Task<TagHelperContent>> 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<TagHelperContent> GetChildContentAsync()
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
public Task<TagHelperContent> GetChildContentAsync(bool useCachedResult)
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
public Task<TagHelperContent> GetChildContentAsync(HtmlEncoder encoder)
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
public Task<TagHelperContent> GetChildContentAsync(bool useCachedResult, HtmlEncoder encoder)
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
void IHtmlContentContainer.CopyTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
}
|
||||
|
||||
void IHtmlContentContainer.MoveTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
}
|
||||
|
||||
public void WriteTo(TextWriter writer, HtmlEncoder encoder)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,10 +6,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="$(MicrosoftAspNetCoreHtmlAbstractionsPackageVersion)" />
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourcePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -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<object, object> items,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync,
|
||||
Action<HtmlEncoder> startTagHelperWritingScope,
|
||||
Func<TagHelperContent> endTagHelperWritingScope)
|
||||
{
|
||||
}
|
||||
|
||||
public bool ChildContentRetrieved => false;
|
||||
|
||||
public IDictionary<object, object> Items { get; private set; }
|
||||
|
||||
public IList<ITagHelper> 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<object, object> items,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync)
|
||||
{
|
||||
}
|
||||
|
||||
public Task SetOutputContentAsync()
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<HtmlEncoder> startTagHelperWritingScope,
|
||||
Func<TagHelperContent> endTagHelperWritingScope)
|
||||
{
|
||||
}
|
||||
|
||||
public TagHelperExecutionContext Begin(
|
||||
string tagName,
|
||||
TagMode tagMode,
|
||||
string uniqueId,
|
||||
Func<Task> executeChildContentAsync)
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
public TagHelperExecutionContext End()
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to override an <see cref="ITagHelper"/> property's HTML attribute name.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class HtmlAttributeNameAttribute : Attribute
|
||||
{
|
||||
private string _dictionaryAttributePrefix;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of the <see cref="HtmlAttributeNameAttribute"/> class with <see cref="Name"/>
|
||||
/// equal to <c>null</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Associated property must not have a public setter and must be compatible with
|
||||
/// <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/> where <c>TKey</c> is
|
||||
/// <see cref="string"/>.
|
||||
/// </remarks>
|
||||
public HtmlAttributeNameAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of the <see cref="HtmlAttributeNameAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// HTML attribute name for the associated property. Must be <c>null</c> or empty if associated property does
|
||||
/// not have a public setter and is compatible with
|
||||
/// <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/> where <c>TKey</c> is
|
||||
/// <see cref="string"/>. Otherwise must not be <c>null</c> or empty.
|
||||
/// </param>
|
||||
public HtmlAttributeNameAttribute(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HTML attribute name of the associated property.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>null</c> or empty if and only if associated property does not have a public setter and is compatible
|
||||
/// with <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/> where <c>TKey</c> is
|
||||
/// <see cref="string"/>.
|
||||
/// </value>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prefix used to match HTML attribute names. Matching attributes are added to the
|
||||
/// associated property (an <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/>).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If non-<c>null</c> associated property must be compatible with
|
||||
/// <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/> where <c>TKey</c> is
|
||||
/// <see cref="string"/>.
|
||||
/// </remarks>
|
||||
/// <value>
|
||||
/// <para>
|
||||
/// If associated property is compatible with
|
||||
/// <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/>, default value is <c>Name + "-"</c>.
|
||||
/// <see cref="Name"/> must not be <c>null</c> or empty in this case.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Otherwise default value is <c>null</c>.
|
||||
/// </para>
|
||||
/// </value>
|
||||
public string DictionaryAttributePrefix
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionaryAttributePrefix;
|
||||
}
|
||||
set
|
||||
{
|
||||
_dictionaryAttributePrefix = value;
|
||||
DictionaryAttributePrefixSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an indication whether <see cref="DictionaryAttributePrefix"/> has been set. Used to distinguish an
|
||||
/// uninitialized <see cref="DictionaryAttributePrefix"/> value from an explicit <c>null</c> setting.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if <see cref="DictionaryAttributePrefix"/> was set. <c>false</c> otherwise.</value>
|
||||
public bool DictionaryAttributePrefixSet { get; private set; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the associated <see cref="ITagHelper"/> property should not be bound to HTML attributes.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class HtmlAttributeNotBoundAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of the <see cref="HtmlAttributeNotBoundAttribute"/> class.
|
||||
/// </summary>
|
||||
public HtmlAttributeNotBoundAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides an <see cref="ITagHelper"/>'s target.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
|
||||
public sealed class HtmlTargetElementAttribute : Attribute
|
||||
{
|
||||
public const string ElementCatchAllTarget = "*";
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of the <see cref="HtmlTargetElementAttribute"/> class that targets all HTML
|
||||
/// elements with the required <see cref="Attributes"/>.
|
||||
/// </summary>
|
||||
/// <remarks><see cref="Tag"/> is set to <c>*</c>.</remarks>
|
||||
public HtmlTargetElementAttribute()
|
||||
: this(ElementCatchAllTarget)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of the <see cref="HtmlTargetElementAttribute"/> class with the given
|
||||
/// <paramref name="tag"/> as its <see cref="Tag"/> value.
|
||||
/// </summary>
|
||||
/// <param name="tag">
|
||||
/// The HTML tag the <see cref="ITagHelper"/> targets.
|
||||
/// </param>
|
||||
/// <remarks>A <c>*</c> <paramref name="tag"/> value indicates this <see cref="ITagHelper"/>
|
||||
/// targets all HTML elements with the required <see cref="Attributes"/>.</remarks>
|
||||
public HtmlTargetElementAttribute(string tag)
|
||||
{
|
||||
Tag = tag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The HTML tag the <see cref="ITagHelper"/> targets. A <c>*</c> value indicates this <see cref="ITagHelper"/>
|
||||
/// targets all HTML elements with the required <see cref="Attributes"/>.
|
||||
/// </summary>
|
||||
public string Tag { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A comma-separated <see cref="string"/> of attribute selectors the HTML element must match for the
|
||||
/// <see cref="ITagHelper"/> to run. <c>*</c> 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 <c>^=</c>, <c>$=</c> and
|
||||
/// <c>=</c> are supported e.g. <c>"name"</c>, <c>"[name]"</c>, <c>"[name=value]"</c>, <c>"[ name ^= 'value' ]"</c>.
|
||||
/// </summary>
|
||||
public string Attributes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The expected tag structure. Defaults to <see cref="TagStructure.Unspecified"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If <see cref="TagStructure.Unspecified"/> and no other tag helpers applying to the same element specify
|
||||
/// their <see cref="TagStructure"/> the <see cref="TagStructure.NormalOrSelfClosing"/> behavior is used:
|
||||
/// <para>
|
||||
/// <code>
|
||||
/// <my-tag-helper></my-tag-helper>
|
||||
/// <!-- OR -->
|
||||
/// <my-tag-helper />
|
||||
/// </code>
|
||||
/// Otherwise, if another tag helper applying to the same element does specify their behavior, that behavior
|
||||
/// is used.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If <see cref="TagStructure.WithoutEndTag"/> HTML elements can be written in the following formats:
|
||||
/// <code>
|
||||
/// <my-tag-helper>
|
||||
/// <!-- OR -->
|
||||
/// <my-tag-helper />
|
||||
/// </code>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public TagStructure TagStructure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The required HTML element name of the direct parent. A <c>null</c> value indicates any HTML element name is
|
||||
/// allowed.
|
||||
/// </summary>
|
||||
public string ParentTag { get; set; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a hint of the <see cref="ITagHelper"/>'s output element.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class OutputElementHintAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of the <see cref="OutputElementHintAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="outputElement">
|
||||
/// The HTML element the <see cref="ITagHelper"/> may output.
|
||||
/// </param>
|
||||
public OutputElementHintAttribute(string outputElement)
|
||||
{
|
||||
if (outputElement == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(outputElement));
|
||||
}
|
||||
|
||||
OutputElement = outputElement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The HTML element the <see cref="ITagHelper"/> may output.
|
||||
/// </summary>
|
||||
public string OutputElement { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// A read-only collection of <see cref="TagHelperAttribute"/>s.
|
||||
/// </summary>
|
||||
public abstract class ReadOnlyTagHelperAttributeList : ReadOnlyCollection<TagHelperAttribute>
|
||||
{
|
||||
private static readonly IReadOnlyList<TagHelperAttribute> EmptyList = new TagHelperAttribute[0];
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="ReadOnlyTagHelperAttributeList"/> with an empty
|
||||
/// collection.
|
||||
/// </summary>
|
||||
protected ReadOnlyTagHelperAttributeList()
|
||||
: base(new List<TagHelperAttribute>())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="ReadOnlyTagHelperAttributeList"/> with the specified
|
||||
/// <paramref name="attributes"/>.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The collection to wrap.</param>
|
||||
public ReadOnlyTagHelperAttributeList(IList<TagHelperAttribute> attributes)
|
||||
: base(attributes)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first <see cref="TagHelperAttribute"/> with <see cref="TagHelperAttribute.Name"/>
|
||||
/// matching <paramref name="name"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// The <see cref="TagHelperAttribute.Name"/> of the <see cref="TagHelperAttribute"/> to get.
|
||||
/// </param>
|
||||
/// <returns>The first <see cref="TagHelperAttribute"/> with <see cref="TagHelperAttribute.Name"/>
|
||||
/// matching <paramref name="name"/>.
|
||||
/// </returns>
|
||||
/// <remarks><paramref name="name"/> is compared case-insensitively.</remarks>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a <see cref="TagHelperAttribute"/> with <see cref="TagHelperAttribute.Name"/>
|
||||
/// matching <paramref name="name"/> exists in the collection.
|
||||
/// </summary>
|
||||
/// <param name="name">The <see cref="TagHelperAttribute.Name"/> of the
|
||||
/// <see cref="TagHelperAttribute"/> to get.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if a <see cref="TagHelperAttribute"/> with the same
|
||||
/// <see cref="TagHelperAttribute.Name"/> exists in the collection; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <remarks><paramref name="name"/> is compared case-insensitively.</remarks>
|
||||
public bool ContainsName(string name)
|
||||
{
|
||||
return this[name] != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the first <see cref="TagHelperAttribute"/> with <see cref="TagHelperAttribute.Name"/>
|
||||
/// matching <paramref name="name"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The <see cref="TagHelperAttribute.Name"/> of the
|
||||
/// <see cref="TagHelperAttribute"/> to get.</param>
|
||||
/// <param name="attribute">When this method returns, the first <see cref="TagHelperAttribute"/> with
|
||||
/// <see cref="TagHelperAttribute.Name"/> matching <paramref name="name"/>, if found; otherwise,
|
||||
/// <c>null</c>.</param>
|
||||
/// <returns><c>true</c> if a <see cref="TagHelperAttribute"/> with the same
|
||||
/// <see cref="TagHelperAttribute.Name"/> exists in the collection; otherwise, <c>false</c>.</returns>
|
||||
/// <remarks><paramref name="name"/> is compared case-insensitively.</remarks>
|
||||
public bool TryGetAttribute(string name, out TagHelperAttribute attribute)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
attribute = this[name];
|
||||
|
||||
return attribute != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves <see cref="TagHelperAttribute"/>s in the collection with
|
||||
/// <see cref="TagHelperAttribute.Name"/> matching <paramref name="name"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The <see cref="TagHelperAttribute.Name"/> of the
|
||||
/// <see cref="TagHelperAttribute"/>s to get.</param>
|
||||
/// <param name="attributes">When this method returns, the <see cref="TagHelperAttribute"/>s with
|
||||
/// <see cref="TagHelperAttribute.Name"/> matching <paramref name="name"/>.</param>
|
||||
/// <returns><c>true</c> if at least one <see cref="TagHelperAttribute"/> with the same
|
||||
/// <see cref="TagHelperAttribute.Name"/> exists in the collection; otherwise, <c>false</c>.</returns>
|
||||
/// <remarks><paramref name="name"/> is compared case-insensitively.</remarks>
|
||||
public bool TryGetAttributes(string name, out IReadOnlyList<TagHelperAttribute> attributes)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
// Perf: Avoid allocating enumerator
|
||||
List<TagHelperAttribute> matchedAttributes = null;
|
||||
for (var i = 0; i < Items.Count; i++)
|
||||
{
|
||||
if (NameEquals(name, Items[i]))
|
||||
{
|
||||
if (matchedAttributes == null)
|
||||
{
|
||||
matchedAttributes = new List<TagHelperAttribute>();
|
||||
}
|
||||
|
||||
matchedAttributes.Add(Items[i]);
|
||||
}
|
||||
}
|
||||
attributes = matchedAttributes ?? EmptyList;
|
||||
|
||||
return matchedAttributes != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a <see cref="TagHelperAttribute"/> who's <see cref="TagHelperAttribute.Name"/>
|
||||
/// case-insensitively matches <paramref name="name"/> and returns the zero-based index of the first
|
||||
/// occurrence.
|
||||
/// </summary>
|
||||
/// <param name="name">The <see cref="TagHelperAttribute.Name"/> to locate in the collection.</param>
|
||||
/// <returns>The zero-based index of the first matching <see cref="TagHelperAttribute"/> within the collection,
|
||||
/// if found; otherwise, -1.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the specified <paramref name="attribute"/> has the same name as <paramref name="name"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The value to compare against <paramref name="attribute"/>s
|
||||
/// <see cref="TagHelperAttribute.Name"/>.</param>
|
||||
/// <param name="attribute">The attribute to compare against.</param>
|
||||
/// <returns><c>true</c> if <paramref name="name"/> case-insensitively matches <paramref name="attribute"/>s
|
||||
/// <see cref="TagHelperAttribute.Name"/>.</returns>
|
||||
protected static bool NameEquals(string name, TagHelperAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
return string.Equals(name, attribute.Name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Restricts children of the <see cref="ITagHelper"/>'s element.
|
||||
/// </summary>
|
||||
/// <remarks>Combining this attribute with a <see cref="HtmlTargetElementAttribute"/> that specifies its
|
||||
/// <see cref="HtmlTargetElementAttribute.TagStructure"/> as <see cref="TagStructure.WithoutEndTag"/> will result
|
||||
/// in this attribute being ignored.</remarks>
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
|
||||
public class RestrictChildrenAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of the <see cref="RestrictChildrenAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="childTag">
|
||||
/// The tag name of an element allowed as a child.
|
||||
/// </param>
|
||||
/// <param name="childTags">
|
||||
/// Additional names of elements allowed as children.
|
||||
/// </param>
|
||||
public RestrictChildrenAttribute(string childTag, params string[] childTags)
|
||||
{
|
||||
var concatenatedNames = new string[1 + childTags.Length];
|
||||
concatenatedNames[0] = childTag;
|
||||
|
||||
childTags.CopyTo(concatenatedNames, 1);
|
||||
|
||||
ChildTags = concatenatedNames;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the names of elements allowed as children.
|
||||
/// </summary>
|
||||
public IEnumerable<string> ChildTags { get; }
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of <see cref="TagHelperAttribute"/>s.
|
||||
/// </summary>
|
||||
public class TagHelperAttributeList : ReadOnlyTagHelperAttributeList, IList<TagHelperAttribute>
|
||||
{
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="TagHelperAttributeList"/> with an empty collection.
|
||||
/// </summary>
|
||||
public TagHelperAttributeList()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="TagHelperAttributeList"/> with the specified
|
||||
/// <paramref name="attributes"/>.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The collection to wrap.</param>
|
||||
public TagHelperAttributeList(IEnumerable<TagHelperAttribute> attributes)
|
||||
: base (new List<TagHelperAttribute>(attributes))
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new instance of <see cref="TagHelperAttributeList"/> with the specified
|
||||
/// <paramref name="attributes"/>.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The collection to wrap.</param>
|
||||
public TagHelperAttributeList(List<TagHelperAttribute> attributes)
|
||||
: base(attributes)
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// <paramref name="value"/>'s <see cref="TagHelperAttribute.Name"/> must not be <c>null</c>.
|
||||
/// </remarks>
|
||||
public new TagHelperAttribute this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return base[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
Items[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the first <see cref="TagHelperAttribute"/> with <see cref="TagHelperAttribute.Name"/> matching
|
||||
/// <paramref name="name"/> and removes any additional matching <see cref="TagHelperAttribute"/>s. If a
|
||||
/// matching <see cref="TagHelperAttribute"/> is not found, adds a <see cref="TagHelperAttribute"/> with
|
||||
/// <paramref name="name"/> and <paramref name="value"/> to the end of the collection.</summary>
|
||||
/// <param name="name">
|
||||
/// The <see cref="TagHelperAttribute.Name"/> of the <see cref="TagHelperAttribute"/> to set.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// The <see cref="TagHelperAttribute.Value"/> to set.
|
||||
/// </param>
|
||||
/// <remarks><paramref name="name"/> is compared case-insensitively.</remarks>
|
||||
public void SetAttribute(string name, object value)
|
||||
{
|
||||
var attribute = new TagHelperAttribute(name, value);
|
||||
SetAttribute(attribute);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the first <see cref="TagHelperAttribute"/> with <see cref="TagHelperAttribute.Name"/> matching
|
||||
/// <paramref name="attribute"/>'s <see cref="TagHelperAttribute.Name"/> and removes any additional matching
|
||||
/// <see cref="TagHelperAttribute"/>s. If a matching <see cref="TagHelperAttribute"/> is not found, adds the
|
||||
/// specified <paramref name="attribute"/> to the end of the collection.
|
||||
/// </summary>
|
||||
/// <param name="attribute">
|
||||
/// The <see cref="TagHelperAttribute"/> to set.
|
||||
/// </param>
|
||||
/// <remarks><paramref name="attribute"/>'s <see cref="TagHelperAttribute.Name"/> is compared
|
||||
/// case-insensitively.</remarks>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
bool ICollection<TagHelperAttribute>.IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="TagHelperAttribute"/> to the end of the collection with the specified
|
||||
/// <paramref name="name"/> and <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The <see cref="TagHelperAttribute.Name"/> of the attribute to add.</param>
|
||||
/// <param name="value">The <see cref="TagHelperAttribute.Value"/> of the attribute to add.</param>
|
||||
public void Add(string name, object value)
|
||||
{
|
||||
var attribute = new TagHelperAttribute(name, value);
|
||||
Items.Add(attribute);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Add(TagHelperAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
Items.Add(attribute);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Insert(int index, TagHelperAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
Items.Insert(index, attribute);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// <paramref name="attribute"/>s <see cref="TagHelperAttribute.Name"/> is compared case-insensitively.
|
||||
/// </remarks>
|
||||
public bool Remove(TagHelperAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
return Items.Remove(attribute);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
Items.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all <see cref="TagHelperAttribute"/>s with <see cref="TagHelperAttribute.Name"/> matching
|
||||
/// <paramref name="name"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// The <see cref="TagHelperAttribute.Name"/> of <see cref="TagHelperAttribute"/>s to remove.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if at least 1 <see cref="TagHelperAttribute"/> was removed; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <remarks><paramref name="name"/> is compared case-insensitively.</remarks>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Clear()
|
||||
{
|
||||
Items.Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class used to buffer content returned by <see cref="ITagHelper"/>s.
|
||||
/// </summary>
|
||||
public abstract class TagHelperContent : IHtmlContentBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content was modified.
|
||||
/// </summary>
|
||||
public abstract bool IsModified { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content is empty or whitespace.
|
||||
/// </summary>
|
||||
public abstract bool IsEmptyOrWhiteSpace { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the content.
|
||||
/// </summary>
|
||||
/// <param name="htmlContent">The <see cref="IHtmlContent"/> that replaces the content.</param>
|
||||
/// <returns>A reference to this instance after the set operation has completed.</returns>
|
||||
public TagHelperContent SetHtmlContent(IHtmlContent htmlContent)
|
||||
{
|
||||
HtmlContentBuilderExtensions.SetHtmlContent(this, htmlContent);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the content.
|
||||
/// </summary>
|
||||
/// <param name="unencoded">
|
||||
/// The <see cref="string"/> that replaces the content. The value is assume to be unencoded
|
||||
/// as-provided and will be HTML encoded before being written.
|
||||
/// </param>
|
||||
/// <returns>A reference to this instance after the set operation has completed.</returns>
|
||||
public TagHelperContent SetContent(string unencoded)
|
||||
{
|
||||
HtmlContentBuilderExtensions.SetContent(this, unencoded);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the content.
|
||||
/// </summary>
|
||||
/// <param name="encoded">
|
||||
/// The <see cref="string"/> that replaces the content. The value is assume to be HTML encoded
|
||||
/// as-provided and no further encoding will be performed.
|
||||
/// </param>
|
||||
/// <returns>A reference to this instance after the set operation has completed.</returns>
|
||||
public TagHelperContent SetHtmlContent(string encoded)
|
||||
{
|
||||
HtmlContentBuilderExtensions.SetHtmlContent(this, encoded);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends <paramref name="unencoded"/> to the existing content.
|
||||
/// </summary>
|
||||
/// <param name="unencoded">The <see cref="string"/> to be appended.</param>
|
||||
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||
public abstract TagHelperContent Append(string unencoded);
|
||||
|
||||
/// <summary>
|
||||
/// Appends <paramref name="htmlContent"/> to the existing content.
|
||||
/// </summary>
|
||||
/// <param name="htmlContent">The <see cref="IHtmlContent"/> to be appended.</param>
|
||||
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||
public abstract TagHelperContent AppendHtml(IHtmlContent htmlContent);
|
||||
|
||||
/// <summary>
|
||||
/// Appends <paramref name="encoded"/> to the existing content. <paramref name="encoded"/> is assumed
|
||||
/// to be an HTML encoded <see cref="string"/> and no further encoding will be performed.
|
||||
/// </summary>
|
||||
/// <param name="encoded">The <see cref="string"/> to be appended.</param>
|
||||
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||
public abstract TagHelperContent AppendHtml(string encoded);
|
||||
|
||||
/// <summary>
|
||||
/// Appends the specified <paramref name="format"/> to the existing content after
|
||||
/// replacing each format item with the HTML encoded <see cref="string"/> representation of the
|
||||
/// corresponding item in the <paramref name="args"/> array.
|
||||
/// </summary>
|
||||
/// <param name="format">
|
||||
/// The composite format <see cref="string"/> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx).
|
||||
/// </param>
|
||||
/// <param name="args">The object array to format.</param>
|
||||
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||
public TagHelperContent AppendFormat(string format, params object[] args)
|
||||
{
|
||||
HtmlContentBuilderExtensions.AppendFormat(this, null, format, args);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends the specified <paramref name="format"/> to the existing content with information from the
|
||||
/// <paramref name="provider"/> after replacing each format item with the HTML encoded <see cref="string"/>
|
||||
/// representation of the corresponding item in the <paramref name="args"/> array.
|
||||
/// </summary>
|
||||
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <param name="format">
|
||||
/// The composite format <see cref="string"/> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx).
|
||||
/// </param>
|
||||
/// <param name="args">The object array to format.</param>
|
||||
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||
public TagHelperContent AppendFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
HtmlContentBuilderExtensions.AppendFormat(this, provider, format, args);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the content.
|
||||
/// </summary>
|
||||
/// <returns>A reference to this instance after the clear operation has completed.</returns>
|
||||
public abstract TagHelperContent Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Clears the <see cref="TagHelperContent"/>, so it can be reused.
|
||||
/// </summary>
|
||||
/// <remarks>This method does more than what <see cref="Clear"/> does. It also resets the
|
||||
/// <see cref="IsModified"/> flag.</remarks>
|
||||
public abstract void Reinitialize();
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void CopyTo(IHtmlContentBuilder destination);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void MoveTo(IHtmlContentBuilder destination);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="string"/> containing the content.</returns>
|
||||
public abstract string GetContent();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content.
|
||||
/// </summary>
|
||||
/// <param name="encoder">The <see cref="HtmlEncoder"/>.</param>
|
||||
/// <returns>A <see cref="string"/> containing the content.</returns>
|
||||
public abstract string GetContent(HtmlEncoder encoder);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void WriteTo(TextWriter writer, HtmlEncoder encoder);
|
||||
|
||||
/// <inheritdoc />
|
||||
IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(IHtmlContent content)
|
||||
{
|
||||
return AppendHtml(content);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
IHtmlContentBuilder IHtmlContentBuilder.Append(string unencoded)
|
||||
{
|
||||
return Append(unencoded);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(string encoded)
|
||||
{
|
||||
return AppendHtml(encoded);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
IHtmlContentBuilder IHtmlContentBuilder.Clear()
|
||||
{
|
||||
return Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information related to the execution of <see cref="ITagHelper"/>s.
|
||||
/// </summary>
|
||||
public class TagHelperContext
|
||||
{
|
||||
private readonly TagHelperAttributeList _allAttributes;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new <see cref="TagHelperContext"/>.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The parsed HTML tag name of the element.</param>
|
||||
/// <param name="allAttributes">Every attribute associated with the current HTML element.</param>
|
||||
/// <param name="items">Collection of items used to communicate with other <see cref="ITagHelper"/>s.</param>
|
||||
/// <param name="uniqueId">The unique identifier for the source element this <see cref="TagHelperContext" />
|
||||
/// applies to.</param>
|
||||
public TagHelperContext(
|
||||
string tagName,
|
||||
TagHelperAttributeList allAttributes,
|
||||
IDictionary<object, object> items,
|
||||
string uniqueId) : this(allAttributes, items, uniqueId)
|
||||
{
|
||||
if (tagName == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tagName));
|
||||
}
|
||||
|
||||
TagName = tagName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new <see cref="TagHelperContext"/>.
|
||||
/// </summary>
|
||||
/// <param name="allAttributes">Every attribute associated with the current HTML element.</param>
|
||||
/// <param name="items">Collection of items used to communicate with other <see cref="ITagHelper"/>s.</param>
|
||||
/// <param name="uniqueId">The unique identifier for the source element this <see cref="TagHelperContext" />
|
||||
/// applies to.</param>
|
||||
public TagHelperContext(
|
||||
TagHelperAttributeList allAttributes,
|
||||
IDictionary<object, object> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The parsed HTML tag name of the element.
|
||||
/// </summary>
|
||||
public string TagName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Every attribute associated with the current HTML element.
|
||||
/// </summary>
|
||||
public ReadOnlyTagHelperAttributeList AllAttributes => _allAttributes;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of items used to communicate with other <see cref="ITagHelper"/>s.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This <see cref="IDictionary{Object, Object}" /> is copy-on-write in order to ensure items added to this
|
||||
/// collection are visible only to other <see cref="ITagHelper"/>s targeting child elements.
|
||||
/// </remarks>
|
||||
public IDictionary<object, object> Items { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// An identifier unique to the HTML element this context is for.
|
||||
/// </summary>
|
||||
public string UniqueId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Clears the <see cref="TagHelperContext"/> and updates its state with the provided values.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The HTML tag name to use.</param>
|
||||
/// <param name="items">The <see cref="IDictionary{Object, Object}"/> to use.</param>
|
||||
/// <param name="uniqueId">The unique id to use.</param>
|
||||
public void Reinitialize(string tagName, IDictionary<object, object> items, string uniqueId)
|
||||
{
|
||||
TagName = tagName;
|
||||
Reinitialize(items, uniqueId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the <see cref="TagHelperContext"/> and updates its state with the provided values.
|
||||
/// </summary>
|
||||
/// <param name="items">The <see cref="IDictionary{Object, Object}"/> to use.</param>
|
||||
/// <param name="uniqueId">The unique id to use.</param>
|
||||
public void Reinitialize(IDictionary<object, object> items, string uniqueId)
|
||||
{
|
||||
_allAttributes.Clear();
|
||||
Items = items;
|
||||
UniqueId = uniqueId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<bool, HtmlEncoder, Task<TagHelperContent>> 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<TagHelperContent> GetChildContentAsync()
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
public Task<TagHelperContent> GetChildContentAsync(bool useCachedResult)
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
public Task<TagHelperContent> GetChildContentAsync(HtmlEncoder encoder)
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
public Task<TagHelperContent> GetChildContentAsync(bool useCachedResult, HtmlEncoder encoder)
|
||||
{
|
||||
throw null;
|
||||
}
|
||||
|
||||
void IHtmlContentContainer.CopyTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
}
|
||||
|
||||
void IHtmlContentContainer.MoveTo(IHtmlContentBuilder destination)
|
||||
{
|
||||
}
|
||||
|
||||
public void WriteTo(TextWriter writer, HtmlEncoder encoder)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The mode in which an element should render.
|
||||
/// </summary>
|
||||
public enum TagMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Include both start and end tags.
|
||||
/// </summary>
|
||||
StartTagAndEndTag,
|
||||
|
||||
/// <summary>
|
||||
/// A self-closed tag.
|
||||
/// </summary>
|
||||
SelfClosing,
|
||||
|
||||
/// <summary>
|
||||
/// Only a start tag.
|
||||
/// </summary>
|
||||
StartTagOnly
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The structure the element should be written in.
|
||||
/// </summary>
|
||||
public enum TagStructure
|
||||
{
|
||||
/// <summary>
|
||||
/// If no other tag helper applies to the same element and specifies a <see cref="TagStructure"/>,
|
||||
/// <see cref="NormalOrSelfClosing"/> will be used.
|
||||
/// </summary>
|
||||
Unspecified,
|
||||
|
||||
/// <summary>
|
||||
/// Element can be written as <my-tag-helper></my-tag-helper> or <my-tag-helper />.
|
||||
/// </summary>
|
||||
NormalOrSelfClosing,
|
||||
|
||||
/// <summary>
|
||||
/// Element can be written as <my-tag-helper> or <my-tag-helper />.
|
||||
/// </summary>
|
||||
/// <remarks>Elements with a <see cref="WithoutEndTag"/> structure will never have any content.</remarks>
|
||||
WithoutEndTag
|
||||
}
|
||||
}
|
|
@ -6,10 +6,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="$(MicrosoftAspNetCoreHtmlAbstractionsPackageVersion)" />
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourcePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -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<object> Metadata
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_metadata == null)
|
||||
{
|
||||
_metadata = Type.GetCustomAttributes(inherit: true);
|
||||
}
|
||||
|
||||
return _metadata;
|
||||
}
|
||||
}
|
||||
|
||||
public override Type Type { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// A metadata object containing the checksum of a source file that contributed to a compiled item.
|
||||
/// </summary>
|
||||
public interface IRazorSourceChecksumMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the checksum as string of hex-encoded bytes.
|
||||
/// </summary>
|
||||
string Checksum { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the algorithm used to create this checksum.
|
||||
/// </summary>
|
||||
string ChecksumAlgorithm { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of the source file associated with this checksum.
|
||||
/// </summary>
|
||||
string Identifier { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies a compiled item that can be identified and loaded.
|
||||
/// </summary>
|
||||
public abstract class RazorCompiledItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public abstract string Identifier { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of compiled item. The kind is used programmatically to associate behaviors and semantics
|
||||
/// with the item.
|
||||
/// </summary>
|
||||
public abstract string Kind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of arbitrary metadata associated with the item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For items loaded with the default implementation of <see cref="RazorCompiledItemLoader"/>, the
|
||||
/// metadata collection will return all attributes defined on the <see cref="Type"/>.
|
||||
/// </remarks>
|
||||
public abstract IReadOnlyList<object> Metadata { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Type"/> of the compiled item.
|
||||
/// </summary>
|
||||
public abstract Type Type { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies that an assembly contains a compiled Razor asset.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
|
||||
public sealed class RazorCompiledItemAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="RazorCompiledItemAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="type">The <see cref="Type"/> of the compiled item.</param>
|
||||
/// <param name="kind">
|
||||
/// The kind of the compiled item. The kind is used programmatically to associate behaviors with the item.
|
||||
/// </param>
|
||||
/// <param name="identifier">
|
||||
/// 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.
|
||||
/// </param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of compiled item. The kind is used programmatically to associate behaviors and semantics
|
||||
/// with the item.
|
||||
/// </summary>
|
||||
public string Kind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public string Identifier { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Type"/> of the compiled item. The type should be contained in the assembly associated
|
||||
/// with this instance of <see cref="RazorCompiledItemAttribute"/>.
|
||||
/// </summary>
|
||||
public Type Type { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="RazorCompiledItem"/>.
|
||||
/// </summary>
|
||||
public static class RazorCompiledItemExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="IRazorSourceChecksumMetadata"/> associated with <paramref name="item"/>.
|
||||
/// </summary>
|
||||
/// <param name="item">The <see cref="RazorCompiledItem"/>.</param>
|
||||
/// <returns>A list of <see cref="IRazorSourceChecksumMetadata"/>.</returns>
|
||||
public static IReadOnlyList<IRazorSourceChecksumMetadata> GetChecksumMetadata(this RazorCompiledItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return item.Metadata.OfType<IRazorSourceChecksumMetadata>().ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a key/value metadata pair for the decorated Razor type.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class RazorCompiledItemMetadataAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="RazorCompiledItemMetadataAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public RazorCompiledItemMetadataAttribute(string key, string value)
|
||||
{
|
||||
Key = key;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the key.
|
||||
/// </summary>
|
||||
public string Key { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value.
|
||||
/// </summary>
|
||||
public string Value { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the name of a Razor configuration as defined by the Razor SDK.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class RazorConfigurationNameAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="RazorConfigurationNameAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="configurationName">The name of the Razor configuration.</param>
|
||||
public RazorConfigurationNameAttribute(string configurationName)
|
||||
{
|
||||
if (configurationName == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(configurationName));
|
||||
}
|
||||
|
||||
ConfigurationName = configurationName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the Razor configuration.
|
||||
/// </summary>
|
||||
public string ConfigurationName { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the name of a Razor extension as defined by the Razor SDK.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
|
||||
public sealed class RazorExtensionAssemblyNameAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="RazorExtensionAssemblyNameAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="extensionName">The name of the extension.</param>
|
||||
/// <param name="assemblyName">The assembly name of the extension.</param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assembly name of the extension.
|
||||
/// </summary>
|
||||
public string AssemblyName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the extension.
|
||||
/// </summary>
|
||||
public string ExtensionName { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the name of a Razor configuration as defined by the Razor SDK.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class RazorLanguageVersionAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="RazorLanguageVersionAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="languageVersion">The language version of Razor</param>
|
||||
public RazorLanguageVersionAttribute(string languageVersion)
|
||||
{
|
||||
if (languageVersion == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(languageVersion));
|
||||
}
|
||||
|
||||
LanguageVersion = languageVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Razor language version.
|
||||
/// </summary>
|
||||
public string LanguageVersion { get; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the checksum of a source file that contributed to a compiled item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// These attributes are added by the Razor infrastructure when generating code to assist runtime
|
||||
/// implementations to determine the integrity of compiled items.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Runtime implementations should access the checksum metadata for an item using
|
||||
/// <see cref="RazorCompiledItemExtensions.GetChecksumMetadata(RazorCompiledItem)"/>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class RazorSourceChecksumAttribute : Attribute, IRazorSourceChecksumMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="RazorSourceChecksumAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="checksumAlgorithm">The algorithm used to create this checksum.</param>
|
||||
/// <param name="checksum">The checksum as a string of hex-encoded bytes.</param>
|
||||
/// <param name="identifier">The identifier associated with this thumbprint.</param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the checksum as string of hex-encoded bytes.
|
||||
/// </summary>
|
||||
public string Checksum { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the algorithm used to create this checksum.
|
||||
/// </summary>
|
||||
public string ChecksumAlgorithm { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of the source file associated with this checksum.
|
||||
/// </summary>
|
||||
public string Identifier { get; }
|
||||
}
|
||||
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче