From 7985121bab897497157f8468c8ef1bea94a99a4b Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 3 Nov 2016 11:12:27 -0700 Subject: [PATCH] [Fixes #5207] Support IsIndexer for ViewComponent tag helpers --- .../Properties/AssemblyInfo.cs | 1 - .../ViewComponentTagHelperChunkVisitor.cs | 16 +++++- ...ViewComponentTagHelperDescriptorFactory.cs | 52 +++++++++++++++++-- .../project.json | 4 ++ .../Properties/AssemblyInfo.cs | 1 - ...sWebSite.Home.ViewComponentTagHelpers.html | 7 +++ .../Internal/ChunkVisitorTestFactory.cs | 51 ++++++++++++++++++ .../GeneratedViewComponentTagHelperClasses.cs | 20 +++++++ .../Internal/DefaultTagHelperActivatorTest.cs | 2 +- .../Internal/DefaultTagHelperFactoryTest.cs | 2 +- ...ComponentTagHelperDescriptorFactoryTest.cs | 22 ++++---- .../RazorPageActivatorTest.cs | 14 ++--- .../RazorPageCreateModelExpressionTest.cs | 2 +- .../RazorPageCreateTagHelperTest.cs | 2 +- .../RazorPageTest.cs | 2 +- .../RazorViewTest.cs | 4 +- .../project.json | 4 ++ .../Views/Home/ViewComponentTagHelpers.cshtml | 1 + 18 files changed, 176 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Mvc.Core/Properties/AssemblyInfo.cs index 4adf6b6cd7..6304623dc5 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Properties/AssemblyInfo.cs @@ -6,7 +6,6 @@ using System.Resources; using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Core.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: NeutralResourcesLanguage("en-us")] diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Host/Internal/ViewComponentTagHelperChunkVisitor.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Host/Internal/ViewComponentTagHelperChunkVisitor.cs index d1bca55fc1..a85649481d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Host/Internal/ViewComponentTagHelperChunkVisitor.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Host/Internal/ViewComponentTagHelperChunkVisitor.cs @@ -131,9 +131,23 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host.Internal $"global::{_context.ViewContextTypeName}", ViewContextVariable); + var indexerAttributes = descriptor.Attributes.Where(a => a.IsIndexer); + foreach (var attribute in descriptor.Attributes) { + if (attribute.IsIndexer) + { + continue; + } + Writer.WriteAutoPropertyDeclaration("public", attribute.TypeName, attribute.PropertyName); + + if (indexerAttributes.Any(a => string.Equals(a.PropertyName, attribute.PropertyName, StringComparison.Ordinal))) + { + Writer.Write(" = ") + .WriteStartNewObject(attribute.TypeName) + .WriteEndMethodInvocation(); + } } } @@ -173,7 +187,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host.Internal private string[] GetMethodParameters(TagHelperDescriptor descriptor) { - var propertyNames = descriptor.Attributes.Select(attribute => attribute.PropertyName); + var propertyNames = descriptor.Attributes.Where(a => !a.IsIndexer).Select(attribute => attribute.PropertyName); var joinedPropertyNames = string.Join(", ", propertyNames); var parametersString = $" new {{ { joinedPropertyNames } }}"; diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Internal/ViewComponentTagHelperDescriptorFactory.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Internal/ViewComponentTagHelperDescriptorFactory.cs index 7e1a3847be..68879327be 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Internal/ViewComponentTagHelperDescriptorFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/Internal/ViewComponentTagHelperDescriptorFactory.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc.Razor.Host; using Microsoft.AspNetCore.Mvc.ViewComponents; using Microsoft.AspNetCore.Razor.Compilation.TagHelpers; using Microsoft.AspNetCore.Razor.Runtime.TagHelpers; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Mvc.Razor.Internal { @@ -89,6 +90,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal { var methodParameters = viewComponentDescriptor.MethodInfo.GetParameters(); var attributeDescriptors = new List(); + var indexerDescriptors = new List(); + var requiredAttributeDescriptors = new List(); foreach (var parameter in methodParameters) { @@ -105,14 +108,53 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal descriptor.IsIndexer = false; attributeDescriptors.Add(descriptor); + + var indexerDescriptor = GetIndexerAttributeDescriptor(parameter, lowerKebabName); + if (indexerDescriptor != null) + { + indexerDescriptors.Add(indexerDescriptor); + } + else + { + // Set required attributes only for non-indexer attributes. Indexer attributes can't be required attributes + // because there are two ways of setting values for the attribute. + requiredAttributeDescriptors.Add(new TagHelperRequiredAttributeDescriptor + { + Name = lowerKebabName + }); + } } + attributeDescriptors.AddRange(indexerDescriptors); tagHelperDescriptor.Attributes = attributeDescriptors; - tagHelperDescriptor.RequiredAttributes = tagHelperDescriptor.Attributes.Select( - attribute => new TagHelperRequiredAttributeDescriptor - { - Name = attribute.Name - }); + tagHelperDescriptor.RequiredAttributes = requiredAttributeDescriptors; + } + + private TagHelperAttributeDescriptor GetIndexerAttributeDescriptor(ParameterInfo parameter, string name) + { + var dictionaryTypeArguments = ClosedGenericMatcher.ExtractGenericInterface( + parameter.ParameterType, + typeof(IDictionary<,>)) + ?.GenericTypeArguments + .Select(t => t.IsGenericParameter ? null : t) + .ToArray(); + + if (dictionaryTypeArguments?[0] != typeof(string)) + { + return null; + } + + var type = dictionaryTypeArguments[1]; + var descriptor = new TagHelperAttributeDescriptor + { + Name = name + "-", + PropertyName = parameter.Name, + TypeName = GetCSharpTypeName(type), + IsEnum = type.GetTypeInfo().IsEnum, + IsIndexer = true + }; + + return descriptor; } private string GetTagName(ViewComponentDescriptor descriptor) diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/project.json b/src/Microsoft.AspNetCore.Mvc.Razor/project.json index 1875c4fd17..5425f89d9d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/project.json +++ b/src/Microsoft.AspNetCore.Mvc.Razor/project.json @@ -26,6 +26,10 @@ "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.1.0-*", "Microsoft.CodeAnalysis.CSharp": "1.3.0", "Microsoft.Extensions.FileProviders.Composite": "1.1.0-*", + "Microsoft.Extensions.ClosedGenericMatcher.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Microsoft.Extensions.HashCodeCombiner.Sources": { "version": "1.1.0-*", "type": "build" diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Properties/AssemblyInfo.cs index cb2cfb0eeb..50ebd12fa5 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Properties/AssemblyInfo.cs @@ -6,7 +6,6 @@ using System.Resources; using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.ViewFeatures.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Formatters.Xml.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] [assembly: AssemblyMetadata("Serviceable", "True")] diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/compiler/resources/TagHelpersWebSite.Home.ViewComponentTagHelpers.html b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/compiler/resources/TagHelpersWebSite.Home.ViewComponentTagHelpers.html index 65b64d9efb..b6caedd04c 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/compiler/resources/TagHelpersWebSite.Home.ViewComponentTagHelpers.html +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/compiler/resources/TagHelpersWebSite.Home.ViewComponentTagHelpers.html @@ -23,6 +23,13 @@ Two Three +
Items:
+
+ foo
+ One + Two + Three +

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????+
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????+
??????????????????????????????????????????????????????????????????????????????????????????????????I77III$77I7III???????????????????????????????????????????????????????????????????????????????????????+
?????????????????????????????????????????????????????????????????????????????????????????I??7$OO8ODNNDDDNNNNDDNN8Z8Z$77????????????????????????????????????????????????????????????????????????????????+
?????????????????????????????????????????????????????????????????????????????????????I7IZO88NDNNDDNNMNNNMMNMNNMNNMMNDDDDOOII???????????????????????????????????????????????????????????????????????????+
???????????????????????????????????????????????????????????????????????????????I?7I$ZDN8DNNNNNNDNNNNNMNMMMMMMMNNNMNNMNNNDDDD88$$???????????????????????????????????????????????????????????????????????+
???????????????????????????????????????????????????????????????????????????I??7O88DDDNNNDNNNNNNNDDDNNNNNNMNNNNNMNNMMNMNNNNNDNN8D8Z$$???????????????????????????????????????????????????????????????????+
???????????????????????????????????????????????????????????????????????????I$O8DDDNDNNDNNDDDNNNDNNNNNDNNNNNNNNNNNNNNDMMMNMMNNNND8D88$7??+??????????????????????????????????????????????????????????????+
?????????????????????????????????????????????????????????????????????????7Z8NDDDNNNNDNDNNNNDNNNNNNNNDNNDNNNNDNNNNNNNNNNNNNMNNMNNNDDDOD$O$??????????????????????????????????????????????????????????????+
??????????????????????????????????????????????????????????????????????I$8DNNNNDNNNDNNDDDD8DNDNNNDDDDDDDDDDDNDNNNNNNDDNNNNNMMNNNNNNND8NZDD8O$I??????????????????????????????????????????????????????????+
???????????????????????????????????????????????????????????????????I7O8DDNDNNNNNNNNNN8D8DNDNDD8DDDD88DDD8D8DDDDNNNNNNNDNDDDNNNDDMMNDNDDND88DOZ?????????????????????????????????????????????????????????+
?????????????????????????????????????????????????????????????????IIO88NDDDNNDNDNDDD88O88DDDDDN8DD8888O88888DDDDNDDN8D8DDDDDDDDDDDNNNDDNNDNDOOO$I???????????????????????????????????????????????????????+
????????????????????????????????????????????????????????????????IONDDNDDNMNNND888OZZOOODDO888ODO8OOZOOOOOO88888DDDDDD8DDDD88888DDNNNN8NDNDDO8D8OZ??????????????????????????????????????????????????????+
??????????????????????????????????????????????????????????????I7OD8NDDD8DNDNN88OZ$$$$ZOOO8888OOOOZOOZZZZOZZ8888888OOOZ8OOOOOO8O88888NNNDN8DDNO888O$I???????????????????????????????????????????????????+
??????????????????????????????????????????????????????????????7ZDDDDNNDNDND8OZZZ$$$ZZZOZOOO8OZOZZZZ$Z$ZZZOO$ZZOOOOOZOZZZZZZOOOOOOOO88DDNN8NDN8DNN8DZI??????????????????????????????????????????????????+
????????????????????????????????????????????????????????????IOD8DNDDDDNDD8OOZ$$$$$$$$$Z$8$ZOZ$ZZ$77777$7$$$$$$ZOOZ$$Z$$ZZZZZZZZOOZOOO8DDNNNN8DDD8DNDZ7I????????????????????????????????????????????????+
???????????????????????????????????????????????????????????7ONNDDDDDDDDDOOZ$$$77777777$$Z$77$$77III77I777Z$7$$$$$77777$$$$$$$ZZZOOOOOO8DDDNNNDNDNONND8Z7I??????????????????????????????????????????????+
??????????????????????????????????????????????????????????7$8DD8NDDN8D8Z$$777777II77777777$7$$$7IIIIIII7II77I77777777777777$$$$$ZZZZOOO88ODNNNDDDDODNNN8I??????????????????????????????????????????????+
?????????????????????????????????????????????????????????IZ8888DDDDD88Z$777777IIIIIIIII77$777II?IIIIIIIIIII7III777III777II77$$$Z$$Z$ZZZOOO88DD8NN88DDDDNDZ?????????????????????????????????????????????+
???????????????????????????????????????????????????????IZDDD88DDD888Z7777IIIIIIII?IIII?III7I???I???II??I?777III?IIIIIIIIIII777$$$$$$$$$ZZOO88DDNDDDDDNNDD8ZI???????????????????????????????????????????+
??????????????????????????????????????????????????????I$8NN8OD8N8D8Z$7I7IIIIIIII?I??I??I???????III???????I?I?I??III?IIIIII77777$$$$$$$$$ZZO88DDNDDDDNDDOD88O7??????????????????????????????????????????+
?????????????????????????????????????????????????????IO8DNN8D8DDD8Z$7I7IIIIIIIII????????+????I???++++++++??+???????IIIIIIII77777$7$$7$$$$$ZO88D8DDDND8NNDNNNZI?????????????????????????????????????????+
?????????????????????????????????????????????????????$8DDD8D88D88Z$7I7IIIIIIIII??I???????+?+?++++++++++++??+??????I?IIIIIII77I777777777$$$ZZO888D8DDO8DDDNND87?????????????????????????????????????????+
?????????????????????????????????????????????????????ODDNODD8D88O$777IIIIIIIII?II???????+++++++++++++++?+?+????????IIIIIIII7777777777777$7$$ZO8DODD8888NDDNND8$I???????????????????????????????????????+
????????????????????????????????????????????????????78888OO888DO$777IIIIIIIII?I????????+++++++++++++++++++++++???????IIIIIII777I777777777777$O88888O8888DNDDDDZI???????????????????????????????????????+
???????????????????????????????????????????????????IO88$8OODN8OZ777IIIIIIIIII??????+??++++++++++++++++++++++?++????????IIIIIII777I7777777777$ZZ88OOO88D8888DD887I??????????????????????????????????????+
??????????????????????????????????????????????????I7OO888888OOO$777IIIIIIII????????++++++++++++++++++++++++++++?+???????IIIIIIII7I77777777777$ZO88O8ZO88D88N8D8O7??????????????????????????????????????+
?????????????????????????????????????????????????I?I88D8OD8OOOZ777IIIIIIII???????++++++++++++++++++++++++++++++++????????IIIIII7777II77II77777$ZOOZOO88O8O8DD88OI??????????????????????????????????????+
??????????????????????????????????????????????????IZOOOZOOO$OO$7777IIIIII???????++++++++++=+++=+++=+++++++++++++++++?????IIIIIIIII7I7IIIIII777$O8ZZZO8ZZ8Z8DND8DO$?????????????????????????????????????+
??????????????????????????????????????????????????IZOZ8OZOZO8Z7777IIIIII???????++++++++=++=============+==+=++++++++++????I??III7IIIIIIIIIII77$ZOZ$ZZO8ZO$8O8DDDO7?????????????????????????????????????+
?????????????????????????????????????????????????I7O8OOZ$ZOOZ77777IIIII??????++++++=+++=====================+=++++++++????????IIIIIIIIIIIIIIII7ZOZZ$$ZZOO878DO8DDOI????????????????????????????????????+
??????????????????????????????????????????????????IZO$ZZZOZ$$$7777IIIII??????++++++==========================+++++++++?+??????I?IIIIIIIIIIIII77$ZO$ZZZ$8Z8OZ88DDO7$????????????????????????????????????+
??????????????????????????????????????????????????$$$ZO$ZZ$Z$$77IIIIIII?????++++++==============================++++++++++???????IIIIIIIIIIII77$OZZZ$8ZZO8Z$8D8D8O7?????????????????????????????????????
??????????????????????????????????????????????????$ZZOOO$I$$Z$77IIIII??????+++++++++=========================+==+++++++++++???????IIIIIIIIIIII7$Z$OZ$O$ZOZOOOO888O$????????????????????????????????????+
?????????????????????????????????????????????????7$OZOZZ$Z7$$77IIIIII??????+++++++================================+++=++++++?+????I??IIIIIIIII7$$ZZO$ZZZO$ZZ8O88D8ZI????????????????????????????????????
?????????????????????????????????????????????????7OZO$Z$$7$$$77IIIIII?I???+++++++=+===============================+++++++++????????IIIIIIIIIII7$Z$OO$OOOZOOZ8N88DOII????????????????????????????????????
?????????????????????????????????????????????????7$Z$Z$Z$77ZZ77IIIII??????+++++==================================+=+==++++??+???????IIIIIIIIII7ZZZ$ZOZZ8OOODD8888O$?????????????????????????????????????
?????????????????????????????????????????????????IOZ8$Z$77$O$77IIIII???????++++=+=+===================================+++++++??????I?I?IIIIIII7$ZOZZ$Z$ZOOO888888ZI?????????????????????????????????????
?????????????????????????????????????????????????788ZZ$77$Z$$77III????????+++++================~===================+==++++++?????????I?IIIIII77$OZZOZ7ZZ$OOZO88DZZ7?????????????????????????????????????
????????????????????????????????????????????????I7ZZ$$I7$O7$77III?I????????+++++++============~=======================++++?+??????????IIIIIII77$ZZZZ$$Z$ZZOZ8D8OOZ?I????????????????????????????????????
????????????????????????????????????????????????I7$$777$Z$$$77IIIIII???????++++++=========~====~===~==================+++++++??????????I?IIII77$ZZ$ZZ$ZZO$ZODOO8OZ?I????????????????????????????????????
????????????????????????????????????????????????I777I$$7$$Z$IIIIII????????++++++++================~===============+=+++++++++????????????IIII777$Z$$ZZ$ZZZ$O8ZZZ87I?????????????????????????????????????
?????????????????????????????????????????????????I$$77$7Z$$7IIIIII???????++++++++++===============================+++++++++++?????????????IIIII7$ZZZ$O7Z7OZ$$OZ887??????????????????????????????????????
?????????????????????????????????????????????????I$$7$77Z7$7IIII?I???????+?++++++++=============================+++++++++++++?????????????????I7$ZZ$Z$$$7$$7O$OO8Z?????????????????????????????????????+
?????????????????????????????????????????????????I7$777$7$$7IIIII???????+?++++++++==============================+++++++++++?????????????I????II77Z$$$7Z77Z$7Z$888$??????????????????????????????????????
????????????????????????????????????????????????I7$777777$$IIIII?III?????++?++++++================================++++?+++?+??????????????????III$$Z$7$$I$Z7OOZOOII?????????????????????????????????????
????????????????????????????????????????????????II$$77$$7$7IIIIIIII????????++++++++==============================+++++????????????????????????III$$$$$7$I7$7$Z$OZI??????????????????????????????????????
?????????????????????????????????????????????????7$$I77$$$IIIIIIIIIII?????++++++++++=============================++++++++????????III??????????I?I7$$$$$I$7I?ZIZZZ7?????????????????????????????????????+
?????????????????????????????????????????????????$Z$$77IZ7IIIIII7IIII????????+++++++==+=========================+++++++++????????I?IIIII????????II7$I$77I7$?Z$OOZ7I?????????????????????????????????????
????????????????????????????????????????????????II777$7$$IIIIIIIIIII????+???+++++++++===========================++++++?++????????IIIIIIIII???????II7777I77I+7$OZZZ??????????????????????????????????????
?I???????????????????????????????????????????????I$77$7$$IIIIIIIIII????????+??++++++++=+======================+=+++++++?????????I??IIIIIII?????????777I7I7I?I$$OZ7??????????????????????????????????????
?????????????????????????????????????????????????I$7$$$$$IIIIIII7II???I??????????+++++++++==================+++++++++??+???????II?IIIIIIII?????????7I$II?7?77I$OZ$??????????????????????????????????????
?????????????????????????????????????????????????I7$7$$$$IIIII7I7III7IIIIIII777777I???+?+++===========++++++++++????III?IIIIIIIIIIIIIIIIIII????????I7$$7II777I$OZ7I?????????????????????????????????????
????????????????????????????????????????????????II$$$$ZZ$IIIIII7II7I77$77$Z$ZOOOO8OZ77I???++++++===++++++++???III7$$ZZZZ7$777777II7IIIIIIII????????7$$$7I7I$778887??????????????????????????????????????
?I????????????????????????????????????????????I777$Z$Z$O$7IIIII7I777$7$77$ZZZOZZZ$Z$$7III???++++++++++?+?+???I$$$OOZOOOOOZZ$7$77$777IIII??I????????7$Z7777$7778O$I??????????????????????????????????????
?I???????????????????????????????????????????IIIII7Z$OZ8$7IIIII777Z$7$7I???++????II77777II????+??+++++??????III777$$$Z$$7I777$$77$$$7IIII??I?I?I???I$$$$$$77IO8ZI???????????????????????????????????????
?III??????????????????????????????????????????7I??I7ZOZ8$IIIII777Z$III??+?+??II7777$77II7II??????+++?????IIIII7IIIIII???+++++???I$7$$7II??I?II?????7$7ZOO7Z$ZOO$Z$$77I??????????????????????????????????
?III??????????????????????????????????????????I7I?II$ZZO77IIII7$$77II??II$$Z8DNNDNDDOII77I77I???+++++???III77II7$777$OOOO$7I????I??I77777IIIII?????7ZZ7OZ$$ZZO$$77II????????????????????????????????????
?IIII?????????????????????????????????????????I???III88O7IIII7II7?IIII$O8D8$I8DD.M.D8I7I?IIII??++===++??IIII7II?IZOI$8NNNNNDOZ$7II???IIIIIIIIII???I7ZOIZZ$7$Z$77I???O7+?????????????????????????????????
?III????????????????????????????????????????????????7Z8Z77IIIII????I7$Z$$77I+I8O8888?==+7I+?II?++++++??III7?++I7?+=~7O8NND88?$8DOO7????????I?IIIIIIIZO$Z77+777II?=+I77??????????????????????????????????
?I??????????????????????????????????????????????+?I??ZO$7IIII??????IIII?????I?II?IIIIIII77??II??++++??I7I7I+?7+I=?=~=ZO8888II7$Z8OZZII??I???III?IIIIZ$8O7$+III??==?III+?????????????????????????????????
?I??????????????????????????????????????????????????IO8$7IIII??????????+?+++++??????+?+++?IIIII???++?I77I7II?????I??II7III?I7I7II7$777I?????+??????I7$8OZ??I??I?+=III?+?????????????????????????????????
?II??????????????????????????????????????????????????$877IIIII??+??????++++++++++++++????IIIII???+???I77IIII+?+?????????????????IIII7IIII???II??????77OZ$?I?III?+?II????????????????????????????????????
?III???????????????????????????????????????????????+??Z77IIIII?I?+??++++++?+++++?????????IIII7I?????II777I?I?????????++++++++?????????III???????????I7O$???IIIII??7II???????????????????????????????????
?III????I??????????????????????????????????????????+++I77IIIII????++++++++++++++++++++??III7II?????III7777I????????????+??+??????????????????I???????77I??7IIIIII?77?+??????????????????????????????????
?IIIII??I????????????????????????????????????????I?+?+I77III???????++++++++++++++++++???I77III?I????II7777I??????????????????????????+???I????????????I??7$777III?7I?+??????????????????????????????????
?IIIIIII?????????????????????????????????????????II??II77III???I??++++++++++++++++++++?I7IIIIIIIIIIIII777$7II????????????++++++++++++????????????++??????$777II???7?????????????????????????????????????
?IIIIIII??????????????????????????????????????????I??II77I????????++++++++++++++++++??IIIIIIIII?I?III7I77777I??????????++++++++++++++????????I???++??????7777II?I?I?+???????????????????????????????????
?IIIIIIIIIII???????????????????????????????????????????77I????????+++++++++++++++++??IIIIIIIIIII?IIIII7777777????++++++?+?+++++??++?????????????++??????+77777I?+7?+????????????????????????????????????
?IIIIIIIIIIII??????????????????????????????????????????I7I???????++++++++++++++++++?IIIIIIIII????IIIII7777777II??+++++++++++++++++++?+??????????+???????I77$$I7I?I+?????????????????????????????????III?
?IIIIIIIIIIII??I??????????????????????????????????????+?7I????????++++++++=++++++++???III7I?I?????IIII777777III???+++++++++++++++++++?????????+++??????I7$Z$$7I?7????????????????????????????III???IIII?
?IIIIII?IIIIIIIII?????????????????????????????????????+?7II??????+?+++++++===+=+++???I7IIII????????III7777777I???+++++++++++++++++++?????????++++??????Z$777II+7???????????????????????II???IIII??IIIII?
?IIIIIIIIIIII????I?????????????????????????????????????+77I???????+++++++====++++??I77II7II????+????III7777777I???++++++++++++++++++++??????++++???????$77I???7I??????????????????????IIIIIIIIIIIIIIIII?
?IIIIIIIIIIII???III?????????????????????????????????????I7II?????++++++++=++++++??I77IIIII?????+???IIII777777$$7???++++++++++++++++?+?????++++++??????IIII??77I?????????????????IIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIII??II????????????????????????????????I????77III?????+++++++++++??III7III7III???+???IIIIII7777$7$$I???++++++++++++++??????+++++++?????+?II77?I7I+??????????????III?IIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIII??I????????????????????????????????I????77I?II????++++++++???IIIIIIIIIIII?+++++??????IIIIII777$$I????+?+++++++++++????++++++++++???+7II7II?I+???????????????IIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIII???I???????????????????????????????II???77II????????++?+???II77IIIIIIIIII??+++++++??????IIIIII$7II????++++++++++++????++++=++++++??$77?77I?????????????????IIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIII????????????????????????????????????I??II7II????????????II7$7IIIIII77III7II??++??????IIII??I?7$7II?????????+??+??????++++++++++++?+Z77IIIII??????????I???IIIIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIIII??I?????????????????????????????????I7$77IIII????????III$7I?IIIIIII77$$77II?????IIIIII7$Z$$$$77II?IIIIIII???????????+++++++++++++?O$7??II+????????I?I?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIIIIIIII????????????????????????????????????7IIII???????I7$?????IIIIII77I7$$$777777I7$$$$$7$7$77IIIIIIIII??????I77I?I???++++++++++++??7$7I??+?????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIIIIIIIIII????????????????????????????????I?I7III???????7I??++??II?III7777777$77I77777$777777777II7IIIII?II????++?77I????++++++++++????7Z7II??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIIIIIIIIII???????????????????????????????????7III?I?+++?I+??++???IIIIIII7II77III??IIIIIII7II77777IIIIII????????+++?I7???++++++++++++I??I????I??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIIIIIIIII?IIIII??????????????????????????????IIII???++++?++?II???III7IIIIIII????+?++?+???III777I7II7IIIII????I?I?++?7???+++++++++?+?I???I?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIIIIIIIIIIIIIIII?????????????????????????????I7II??I?+==++++?+?I??IIIIIII????++++++++++?+???IIIIIIIIIIIIIII7I????++?II?+++?+++++???I????I?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?????????????????????????I?I7I?I??I?+==+=+?++IODZIIIIII?I??+?+++++++++++??I??IIIIII777$8OI??+?+++?II?+?+I++?+??????II?I?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII??????????????????IIII????I7I??+?I++====+?+??7N8OZ$77III??+++++++++++++????III7$ZOOODI??+++++++?7?+????++??????I?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII????????????????????I??III7II?++I?+++==+?++??IODI?I=?7I777I??????IIII77777I$$$$IDZ7????+?++==+?7?++?I++?????+???IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII??????????III?I?IIIIII?I7II?++I?+++++++++???IOI?+~+~~?===?77I?++7?==7+~+$?77$I???????+++=++I?+++???????????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII??????????IIIIIIIIIIIIII7II?++?I?+++++++??????I$??=~:=~~::=~:~:~?~~~?~=+777???????????++=++7+++??????I?????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII??????????IIIIIIIIIIIIIII7II?++?I?+++++++???I????I?+~?=~~~=~~~~=?=~+?I7I?+?IIII??????+++=+I?++?????II???I??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?IIIIIIIIIIIIIIIII??7II??++?I?++++++????II????IIII?+=?=++?IIIIII???I??III??????+++=++7++???????II?7+??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII77I??+?I???+++????IIIII?????????????+???????I??????????????++++I?++?????III??++??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7II??+?I???+++????I?I?I????+++++++++++???I?I????????????+++++?I++????IIIII??++??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?77II???I??++?+?????????II??????????????III???????????????++++7++?+??III?I??++???IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7II????I??+??+++????????????IIIIIIIII???????????????????+++?I++???II?I?II?++???IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7II???II?????+???????++???II??????????+???????????????????I?++???II?II??++????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7I????I??+??+++?+??++++++I????????+?++????????????????+?+?+????IIIII??++????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?I77II?II??????++++?+++++++????????++++?+????????????????+?+++?????II??+++????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7II?III?????++++++++++++????????++++?????????I??????+++??+?????II???++I???IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7IIIIII????+++++++++++?+????????++++++???????????+?++?++?????III??????????I###ZIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII77IIIII?????+++++++++++??+??+???+++++???+???????+++?+?+?????IIII??????+????#####OIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII777IIII?????+++++?++?+???????????++?+??????????++???+++????7III????????????#######ZIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII77777III???+?+??++???++?+???+?????????????????????+?+?+??II?III?I?I+?+?+??I########OIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII77I$777II??+????????????????????????????????????+++?+??II7IIIIIII???+?+??I$O########ZIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII77I7$77II??????+????????????????????????????????+??+?III7777IIII????????I7ZO########OIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII77II7$77II??????????????????+???????????????????????II7$7777III???I?I?II7$ZO#########$IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIO#77I7$$77I????????????++??++????????????????????I?II7$$7777III??II?IIII77$ZO#########OIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII###$7II7$$$7II?????+++?++??+++?++?+??+??????????IIII$$Z$$777III??I?????III77ZO##########$IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7####Z7III7$$$7I?????????+++?+++????++??+???????III77ZZ$$77IIIII????????III777ZO##########OIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIZ######77III7$7$$7II?????++???++++++??+?????III7777$Z$$$77IIII????????????III7$Z#############7IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7#######77III7$77$$$7IIII???????+++++??????III77$$ZZ$$777IIIII???????????????I77##############OO7IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII########$7III777III7$$77I?II?????????IIIII777$$$Z$$$77IIIIIII????+?+????????III$#################OO7IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII##########7IIII777IIIII7$Z777II?IIIIIII777$$ZZ$$$$777IIIII???????++++??+???????IO#####################IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7Z###########77II777II??IIII777$ZZ$7$77$$$$77777777777II?????????+++++++++????????$######################O7IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7Z###############77II777II??????I?III?????+????IIIIIIIII7II????????+?++++++++++++++??7Z#######################ZIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7$###################77III77II??++??????++++++++++?????????I????+++??++++++++++++++++++?I$########################OO$IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7$Z######################Z77III777II?++??+++++++=+++++++?????????????+++++++++++++++++++++++?$############################O$IIIIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7$O###########################?$7IIII777I?+?+++++++=+=++++++++????????++++++++++++++++++++++++++?7################################$IIIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7Z################################+Z7IIII777II?++++=+++++=++++++?++??++++++++=+++++++++++++++++++++?7##################################OZIIIIIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII$O###################################Z?Z$7IIII777I?++++===+++++++++++++++++++=====++++++=+++++++++++++I$#######################################7IIIIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII$#######################################IIZ$7IIIII777I??++==+++++++++++++++?++++=====+=+=+=+++++++=+++++?$#########################################O7IIIIIIIIIIIIIIIIIIII
IIIIIIIIIIIIIIIIIIIIIIIIIIII$##########################################?IZ$7IIIII77I7I?+++++++?+++???++??++++==========++++++++===+++?IZ############################################ZIIIIIIIIIIIIIIIII7I
IIIIIIIIIIIIIIIIIIIIIIIII$O############################################?IO77IIIIII7777?+++++????????+++++++++++=========+++=++++===+?IO##############################################O$7II7IIIIIIIIII77I
IIIIIIIIIIIIIIIIIIIIII7Z###############################################?I#77II???II7777I???????++++++++++++++=========++++++++====+?I#################################################ZOZ7III7IIIII7I77I
IIIIIIIIIIIIIIIIIII7$O#################################################??#$77I???IIII777I????+++++++++++++++=+=======++++++++==+=+?I###################################################O#OZ7777IIIIII7II
IIIIIIIIIIIIIIIII7Z####################################################$+#$77II???IIIII77II????+++++++++++++======+===+++++++==++?I########################################################OZ7777777I77I
IIIIIIIIIIIIIII$O#######################################################=#Z77II????IIIIIIIII????++++++++++==========+=++=+++==++?7###########################################################OZ$I777777I
IIIIIIIIIIII7Z##########################################################=Z#777I??????IIIIIIII???++++++++++=====+++=======+=+=+??Z##############################################################ZZ$III77I
IIIIIIIIII7Z############################################################I+#777II?????I?I??????++++++++++=+=========++=+++++++??#################################################################ZZZZ777I

diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Host.Test/Internal/ChunkVisitorTestFactory.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Host.Test/Internal/ChunkVisitorTestFactory.cs index f5e6ab592a..b3a3621f61 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Host.Test/Internal/ChunkVisitorTestFactory.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Host.Test/Internal/ChunkVisitorTestFactory.cs @@ -44,6 +44,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host GetTagHelperChunk("Baz"), GetNestedViewComponentTagHelperChunk("Foo", visitedTagHelperChunks), GetViewComponentTagHelperChunk("Bar", visitedTagHelperChunks), + GetIndexerViewComponentTagHelperChunk( + "Bee", + visitedTagHelperChunks, + "System.Collections.Generic.Dictionary>"), }; } @@ -120,5 +124,52 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host return tagHelperChunk; } + + private static TagHelperChunk GetIndexerViewComponentTagHelperChunk(string name, bool visitedTagHelperChunks, string attributeTypeName) + { + var typeName = visitedTagHelperChunks ? $"{_testNamespace}.{_testClass}.{name}Type" : $"{name}Type"; + + var attribute = new TagHelperAttributeDescriptor + { + Name = "attribute", + PropertyName = "Attribute", + TypeName = attributeTypeName + }; + + var indexerAttribute = new TagHelperAttributeDescriptor + { + Name = attribute.Name + "-", + PropertyName = attribute.PropertyName, + TypeName = attributeTypeName, + IsIndexer = true + }; + + var tagHelperDescriptor = new TagHelperDescriptor + { + AssemblyName = $"{name}Assembly", + TagName = name.ToLowerInvariant(), + TypeName = typeName, + Attributes = new[] + { + attribute, + indexerAttribute + } + }; + + tagHelperDescriptor.PropertyBag.Add( + ViewComponentTagHelperDescriptorConventions.ViewComponentNameKey, + name); + + var tagHelperChunk = new TagHelperChunk( + $"vc:{name.ToLowerInvariant()}", + TagMode.SelfClosing, + new List(), + new[] + { + tagHelperDescriptor + }); + + return tagHelperChunk; + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Host.Test/TestFiles/Output/Runtime/GeneratedViewComponentTagHelperClasses.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Host.Test/TestFiles/Output/Runtime/GeneratedViewComponentTagHelperClasses.cs index c9a10c3b54..c83d7a93df 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Host.Test/TestFiles/Output/Runtime/GeneratedViewComponentTagHelperClasses.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Host.Test/TestFiles/Output/Runtime/GeneratedViewComponentTagHelperClasses.cs @@ -36,3 +36,23 @@ public class __Generated__BarViewComponentTagHelper : Microsoft.AspNetCore.Razor output.Content.SetHtmlContent(viewContent); } } +[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute("bee")] +public class __Generated__BeeViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper +{ + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _viewComponentHelper = null; + public __Generated__BeeViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper viewComponentHelper) + { + _viewComponentHelper = viewComponentHelper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.Collections.Generic.Dictionary> Attribute { get; set; } + = new System.Collections.Generic.Dictionary>(); + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_viewComponentHelper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var viewContent = await _viewComponentHelper.InvokeAsync("Bee", new { Attribute }); + output.TagName = null; + output.Content.SetHtmlContent(viewContent); + } +} diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/DefaultTagHelperActivatorTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/DefaultTagHelperActivatorTest.cs index eee737ee0b..83a690499e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/DefaultTagHelperActivatorTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/DefaultTagHelperActivatorTest.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal { var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); var metadataProvider = new EmptyModelMetadataProvider(); - var viewData = new ViewDataDictionary(metadataProvider); + var viewData = new ViewDataDictionary(metadataProvider, new ModelStateDictionary()); var viewContext = new ViewContext( actionContext, Mock.Of(), diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/DefaultTagHelperFactoryTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/DefaultTagHelperFactoryTest.cs index 28c2d4da61..54c6bad46a 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/DefaultTagHelperFactoryTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/DefaultTagHelperFactoryTest.cs @@ -158,7 +158,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal { var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); var metadataProvider = new EmptyModelMetadataProvider(); - var viewData = new ViewDataDictionary(metadataProvider); + var viewData = new ViewDataDictionary(metadataProvider, new ModelStateDictionary()); var viewContext = new ViewContext( actionContext, Mock.Of(), diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/ViewComponentTagHelperDescriptorFactoryTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/ViewComponentTagHelperDescriptorFactoryTest.cs index 16e10ff83c..11c930be8d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/ViewComponentTagHelperDescriptorFactoryTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/Internal/ViewComponentTagHelperDescriptorFactoryTest.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc.Razor.Host; using Microsoft.AspNetCore.Mvc.Razor.Internal; using Microsoft.AspNetCore.Mvc.ViewComponents; using Microsoft.AspNetCore.Razor.Compilation.TagHelpers; +using Microsoft.AspNetCore.Razor.TagHelpers.Testing; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Test.Internal @@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.Internal var descriptors = factory.CreateDescriptors(assemblyName); // Assert - Assert.Equal(expectedDescriptors, descriptors, TagHelperDescriptorComparer.Default); + Assert.Equal(expectedDescriptors, descriptors, CaseSensitiveTagHelperDescriptorComparer.Default); } public static TheoryData TypeData @@ -219,7 +220,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.Internal { Name = "test-enum", PropertyName = "testEnum", - TypeName = typeof(TestEnum).FullName, + TypeName = ViewComponentTagHelperDescriptorFactory.GetCSharpTypeName(typeof(TestEnum)), IsEnum = true }, @@ -273,14 +274,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.Internal { Name = "foo", PropertyName = "Foo", - TypeName = "System.Collections.Generic.List" + TypeName = ViewComponentTagHelperDescriptorFactory.GetCSharpTypeName(typeof(List)) }, new TagHelperAttributeDescriptor { Name = "bar", PropertyName = "Bar", - TypeName = "System.Collections.Generic.Dictionary" + TypeName = ViewComponentTagHelperDescriptorFactory.GetCSharpTypeName(typeof(Dictionary)) + }, + + new TagHelperAttributeDescriptor + { + Name = "bar-", + PropertyName = "Bar", + TypeName = typeof(int).FullName, + IsIndexer = true } }, RequiredAttributes = new List @@ -288,11 +297,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.Internal new TagHelperRequiredAttributeDescriptor { Name = "foo" - }, - - new TagHelperRequiredAttributeDescriptor - { - Name = "bar" } } }; diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageActivatorTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageActivatorTest.cs index 5f366b235a..81e1a231d9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageActivatorTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageActivatorTest.cs @@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor var viewContext = new ViewContext( actionContext, Mock.Of(), - new ViewDataDictionary(new EmptyModelMetadataProvider()), + new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()), Mock.Of(), TextWriter.Null, new HtmlHelperOptions()); @@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor var viewContext = new ViewContext( actionContext, Mock.Of(), - new ViewDataDictionary(new EmptyModelMetadataProvider()), + new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()), Mock.Of(), TextWriter.Null, new HtmlHelperOptions()); @@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor }; var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); - var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider()) + var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()) { Model = new MyModel() }; @@ -208,7 +208,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor }; var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); - var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider()) + var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()) { Model = new MyModel() }; @@ -257,7 +257,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor }; var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); - var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider()); + var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()); var viewContext = new ViewContext( actionContext, Mock.Of(), @@ -302,7 +302,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor var viewContext = new ViewContext( actionContext, Mock.Of(), - new ViewDataDictionary(new EmptyModelMetadataProvider()), + new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()), Mock.Of(), TextWriter.Null, new HtmlHelperOptions()); @@ -343,7 +343,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor var viewContext = new ViewContext( actionContext, Mock.Of(), - new ViewDataDictionary(new EmptyModelMetadataProvider()), + new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()), Mock.Of(), TextWriter.Null, new HtmlHelperOptions()); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageCreateModelExpressionTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageCreateModelExpressionTest.cs index fa1c14aac9..b16c2fe500 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageCreateModelExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageCreateModelExpressionTest.cs @@ -220,7 +220,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor private static ViewContext CreateViewContext() { var provider = new TestModelMetadataProvider(); - var viewData = new ViewDataDictionary(provider); + var viewData = new ViewDataDictionary(provider, new ModelStateDictionary()); var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton(provider); serviceCollection.AddSingleton(); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageCreateTagHelperTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageCreateTagHelperTest.cs index 07936833f4..f4acfc4de6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageCreateTagHelperTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageCreateTagHelperTest.cs @@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor .Returns(serviceProvider.Object); var actionContext = new ActionContext(httpContext.Object, new RouteData(), new ActionDescriptor()); - var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider()); + var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()); var viewContext = new ViewContext( actionContext, Mock.Of(), diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageTest.cs index 01710f1fa7..56cba25a0d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorPageTest.cs @@ -1501,7 +1501,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor return new ViewContext( actionContext, viewMock.Object, - new ViewDataDictionary(new EmptyModelMetadataProvider()), + new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()), Mock.Of(), writer, new HtmlHelperOptions()); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorViewTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorViewTest.cs index b16e79509a..068727a67e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorViewTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorViewTest.cs @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor public async Task RenderAsync_AsPartial_ActivatesViews_WithThePassedInViewContext() { // Arrange - var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider()); + var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()); var page = new TestableRazorPage(v => { // viewData is assigned to ViewContext by the activator @@ -1672,7 +1672,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor return new ViewContext( actionContext, view, - new ViewDataDictionary(new EmptyModelMetadataProvider()), + new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()), Mock.Of(), new StringWriter(), new HtmlHelperOptions()); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/project.json b/test/Microsoft.AspNetCore.Mvc.Razor.Test/project.json index 4cae2cf422..6b2be9dbc6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/project.json +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/project.json @@ -22,6 +22,10 @@ "Microsoft.AspNetCore.Mvc.DataAnnotations": "1.1.0-*", "Microsoft.AspNetCore.Mvc.Formatters.Xml": "1.1.0-*", "Microsoft.AspNetCore.Mvc.Razor": "1.1.0-*", + "Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Microsoft.AspNetCore.Mvc.TestCommon": { "version": "1.1.0-*", "type": "build" diff --git a/test/WebSites/TagHelpersWebSite/Views/Home/ViewComponentTagHelpers.cshtml b/test/WebSites/TagHelpersWebSite/Views/Home/ViewComponentTagHelpers.cshtml index e98fcd6a24..96bf087a91 100644 --- a/test/WebSites/TagHelpersWebSite/Views/Home/ViewComponentTagHelpers.cshtml +++ b/test/WebSites/TagHelpersWebSite/Views/Home/ViewComponentTagHelpers.cshtml @@ -7,6 +7,7 @@ } +