[Fixes #1058] Added a test to verify nested enum behavior
This commit is contained in:
parent
5c5462afba
commit
c71f6e7c3f
|
|
@ -158,7 +158,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
|||
.Name("catch-all")
|
||||
.PropertyName("CatchAll")
|
||||
.AsEnum()
|
||||
.TypeName(typeof(MyEnum).FullName),
|
||||
.TypeName($"{typeof(TestTagHelperDescriptors).FullName}.{nameof(MyEnum)}"),
|
||||
}),
|
||||
CreateTagHelperDescriptor(
|
||||
tagName: "input",
|
||||
|
|
@ -170,7 +170,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
|||
.Name("value")
|
||||
.PropertyName("Value")
|
||||
.AsEnum()
|
||||
.TypeName(typeof(MyEnum).FullName),
|
||||
.TypeName($"{typeof(TestTagHelperDescriptors).FullName}.{nameof(MyEnum)}"),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
|
@ -42,19 +42,19 @@ __TestNamespace_InputTagHelper.Value = MyEnum.MyValue;
|
|||
__TestNamespace_InputTagHelper = CreateTagHelper<global::TestNamespace.InputTagHelper>();
|
||||
__TestNamespace_CatchAllTagHelper = CreateTagHelper<global::TestNamespace.CatchAllTagHelper>();
|
||||
#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml"
|
||||
__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors+MyEnum.MyValue;
|
||||
__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MyValue;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
__TestNamespace_InputTagHelper = CreateTagHelper<global::TestNamespace.InputTagHelper>();
|
||||
__TestNamespace_CatchAllTagHelper = CreateTagHelper<global::TestNamespace.CatchAllTagHelper>();
|
||||
#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml"
|
||||
__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors+MyEnum.MySecondValue;
|
||||
__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MySecondValue;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml"
|
||||
__TestNamespace_CatchAllTagHelper.CatchAll = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors+MyEnum.MyValue;
|
||||
__TestNamespace_CatchAllTagHelper.CatchAll = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MyValue;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ AddHtmlAttributeValue("", 130, MyEnum.MySecondValue, 130, 21, false);
|
|||
__TestNamespace_CatchAllTagHelper = CreateTagHelper<global::TestNamespace.CatchAllTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper);
|
||||
#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml"
|
||||
__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors+MyEnum.MyValue;
|
||||
__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MyValue;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
@ -109,13 +109,13 @@ __TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Langua
|
|||
__TestNamespace_CatchAllTagHelper = CreateTagHelper<global::TestNamespace.CatchAllTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper);
|
||||
#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml"
|
||||
__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors+MyEnum.MySecondValue;
|
||||
__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MySecondValue;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
__tagHelperExecutionContext.AddTagHelperAttribute("value", __TestNamespace_InputTagHelper.Value, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
|
||||
#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml"
|
||||
__TestNamespace_CatchAllTagHelper.CatchAll = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors+MyEnum.MyValue;
|
||||
__TestNamespace_CatchAllTagHelper.CatchAll = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MyValue;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
|
|||
|
|
@ -353,7 +353,30 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
|
|||
.TypeName(typeof(CustomEnum).FullName)
|
||||
.AsEnum())
|
||||
.Build()
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(NestedEnumTagHelper),
|
||||
TagHelperDescriptorBuilder.Create(typeof(NestedEnumTagHelper).FullName, AssemblyName)
|
||||
.TagMatchingRule(ruleBuilder => ruleBuilder.RequireTagName("nested-enum"))
|
||||
.BindAttribute(builder =>
|
||||
builder
|
||||
.Name("non-enum-property")
|
||||
.PropertyName(nameof(NestedEnumTagHelper.NonEnumProperty))
|
||||
.TypeName(typeof(int).FullName))
|
||||
.BindAttribute(builder =>
|
||||
builder
|
||||
.Name("enum-property")
|
||||
.PropertyName(nameof(NestedEnumTagHelper.EnumProperty))
|
||||
.TypeName(typeof(CustomEnum).FullName)
|
||||
.AsEnum())
|
||||
.BindAttribute(builder =>
|
||||
builder
|
||||
.Name("nested-enum-property")
|
||||
.PropertyName(nameof(NestedEnumTagHelper.NestedEnumProperty))
|
||||
.TypeName($"{typeof(NestedEnumTagHelper).FullName}.{nameof(NestedEnumTagHelper.NestedEnum)}")
|
||||
.AsEnum())
|
||||
.Build()
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,17 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces.Test
|
|||
{
|
||||
}
|
||||
|
||||
public class NestedEnumTagHelper : EnumTagHelper
|
||||
{
|
||||
public NestedEnum NestedEnumProperty { get; set; }
|
||||
|
||||
public enum NestedEnum
|
||||
{
|
||||
NestedOne,
|
||||
NestedTwo
|
||||
}
|
||||
}
|
||||
|
||||
[HtmlTargetElement("input", ParentTag = "div")]
|
||||
public class RequiredParentTagHelper : TagHelper
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue