[Fixes #1058] Added a test to verify nested enum behavior

This commit is contained in:
Ajay Bhargav Baaskaran 2017-05-04 16:35:23 -07:00
parent 5c5462afba
commit c71f6e7c3f
5 changed files with 43 additions and 9 deletions

View File

@ -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)}"),
}),
};
}

View File

@ -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

View File

@ -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

View File

@ -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()
},
};
}
}

View File

@ -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
{