diff --git a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs index 970069ae9..567882d08 100644 --- a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs +++ b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs @@ -2225,6 +2225,9 @@ public void TestGetRuntimeClassName() Assert.Equal("Windows.Foundation.IReference`1", Class.GetName(arr3.GetValue(0))); Assert.Equal(string.Empty, Class.GetName(arr4[0])); Assert.Equal("Windows.Foundation.IReference`1", Class.GetName(arr5.GetValue(0))); + + Assert.Equal("Windows.Foundation.IReference`1", Class.GetName(typeof(IProperties1))); + Assert.Equal("Windows.Foundation.IReference`1", Class.GetName(typeof(Type))); } [Fact] @@ -2312,6 +2315,13 @@ public void TypeInfoGenerics() Assert.Equal("Windows.Foundation.Collections.IVector`1", typeName); } + [Fact] + public void TypeInfoType() + { + var typeName = Class.GetTypeNameForType(typeof(Type)); + Assert.Equal("Windows.UI.Xaml.Interop.TypeName", typeName); + } + [Fact] public void TestGenericTypeMarshalling() { diff --git a/src/WinRT.Runtime/Projections/Type.cs b/src/WinRT.Runtime/Projections/Type.cs index 80bcd751d..107d5ef68 100644 --- a/src/WinRT.Runtime/Projections/Type.cs +++ b/src/WinRT.Runtime/Projections/Type.cs @@ -73,7 +73,7 @@ private static (String Name, TypeKind Kind) ToAbi(global::System.Type value) { kind = TypeKind.Primitive; } - else if (value == typeof(object) || value == typeof(string) || value == typeof(Guid) || value == typeof(System.Type)) + else if (value == typeof(object) || value == typeof(string) || value == typeof(Guid) || value == typeof(global::System.Type)) { kind = TypeKind.Metadata; } diff --git a/src/WinRT.Runtime/TypeNameSupport.cs b/src/WinRT.Runtime/TypeNameSupport.cs index 3be0eb162..1b00e6292 100644 --- a/src/WinRT.Runtime/TypeNameSupport.cs +++ b/src/WinRT.Runtime/TypeNameSupport.cs @@ -334,11 +334,15 @@ private static bool TryAppendSimpleTypeName(Type type, StringBuilder builder, Ty else if (type == typeof(object)) { builder.Append("Object"); + } + else if ((flags & TypeNameGenerationFlags.ForGetRuntimeClassName) != 0 && type.IsTypeOfType()) + { + builder.Append("Windows.UI.Xaml.Interop.TypeName"); } else { var projectedAbiTypeName = Projections.FindCustomAbiTypeNameForType(type); - if (projectedAbiTypeName is object) + if (projectedAbiTypeName is not null) { builder.Append(projectedAbiTypeName); }