diff --git a/src/Uno.CodeGen.Tests.ExternalClasses/MyViewModel.cs b/src/Uno.CodeGen.Tests.ExternalClasses/MyViewModel.cs index 5b1bbb2..06f4978 100644 --- a/src/Uno.CodeGen.Tests.ExternalClasses/MyViewModel.cs +++ b/src/Uno.CodeGen.Tests.ExternalClasses/MyViewModel.cs @@ -15,6 +15,7 @@ // // ****************************************************************** using System; +using System.Collections.Generic; namespace Uno.CodeGen.Tests.ExternalClasses { @@ -27,6 +28,7 @@ namespace Uno.CodeGen.Tests.ExternalClasses [Inject] public DateTime MyDateTimeProperty { get; private set; } [Inject("name")] public object MyObjectProperty { get; private set; } [Inject] public Func MyFuncStringProperty { get; private set; } + [Inject] public List MyListStringProperty { get; private set; } // Fields [Inject] public string MyStringField; @@ -35,5 +37,6 @@ namespace Uno.CodeGen.Tests.ExternalClasses [Inject] public DateTime MyDateTimeField; [Inject("name")] public object MyObjectField; [Inject] public Func MyFuncStringField; + [Inject] public List MyListStringField; } } diff --git a/src/Uno.CodeGen.Tests/Given_Injectable.cs b/src/Uno.CodeGen.Tests/Given_Injectable.cs index 2b1c180..04fdf86 100644 --- a/src/Uno.CodeGen.Tests/Given_Injectable.cs +++ b/src/Uno.CodeGen.Tests/Given_Injectable.cs @@ -33,6 +33,7 @@ namespace Uno.CodeGen.Tests var @string = "Hello world!"; var dateTime = DateTime.Now; var providedName = default(string); + var strings = new List { "A", "B", "C" }; var vm = new MyViewModel(); @@ -59,6 +60,10 @@ namespace Uno.CodeGen.Tests providedName = name; return name; } + if (type == typeof(List)) + { + return strings; + } throw new NotSupportedException(); }); @@ -70,6 +75,7 @@ namespace Uno.CodeGen.Tests Assert.AreEqual(dateTime, vm.MyDateTimeProperty); Assert.AreEqual(providedName, vm.MyObjectProperty); Assert.AreEqual(@string, vm.MyFuncStringProperty()); + Assert.AreEqual(strings, vm.MyListStringProperty); // Fields Assert.AreEqual(boolean, vm.MyBooleanField); @@ -78,6 +84,7 @@ namespace Uno.CodeGen.Tests Assert.AreEqual(dateTime, vm.MyDateTimeField); Assert.AreEqual(providedName, vm.MyObjectField); Assert.AreEqual(@string, vm.MyFuncStringField()); + Assert.AreEqual(strings, vm.MyListStringField); } } -} \ No newline at end of file +} diff --git a/src/Uno.CodeGen/InjectableGenerator.cs b/src/Uno.CodeGen/InjectableGenerator.cs index 30aa694..c9fce85 100644 --- a/src/Uno.CodeGen/InjectableGenerator.cs +++ b/src/Uno.CodeGen/InjectableGenerator.cs @@ -83,13 +83,13 @@ namespace Uno { var memberName = attribute.member.Name; var memberType = GetMemberType(attribute.member); - var memberTypeName = memberType?.GetFullMetadataName(); + var memberTypeName = memberType?.ToDisplayString(); var name = attribute.attribute.ConstructorArguments.Select(x => x.Value?.ToString()).FirstOrDefault(); var nameLiteral = name != null ? $"\"{name}\"" : "null"; if (memberType.IsFunc(out ITypeSymbol funcResultType)) // Resolve lazily { - var funcResultTypeName = funcResultType?.GetFullMetadataName(); + var funcResultTypeName = funcResultType?.ToDisplayString(); builder.AppendLineInvariant($"{memberName} = () => ({funcResultTypeName})resolver(typeof({funcResultTypeName}), {nameLiteral});"); } else @@ -117,4 +117,4 @@ namespace Uno } } } -} \ No newline at end of file +}