Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where RuntimeClassName for boxed type object was empty string #1548

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Tests/UnitTest/TestComponentCSharp_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,9 @@ public void TestGetRuntimeClassName()
Assert.Equal("Windows.Foundation.IReference`1<Int32>", Class.GetName(arr3.GetValue(0)));
Assert.Equal(string.Empty, Class.GetName(arr4[0]));
Assert.Equal("Windows.Foundation.IReference`1<Windows.Foundation.PropertyType>", Class.GetName(arr5.GetValue(0)));

Assert.Equal("Windows.Foundation.IReference`1<Windows.UI.Xaml.Interop.TypeName>", Class.GetName(typeof(IProperties1)));
Assert.Equal("Windows.Foundation.IReference`1<Windows.UI.Xaml.Interop.TypeName>", Class.GetName(typeof(Type)));
}

[Fact]
Expand Down Expand Up @@ -2312,6 +2315,13 @@ public void TypeInfoGenerics()
Assert.Equal("Windows.Foundation.Collections.IVector`1<Int32>", typeName);
}

[Fact]
public void TypeInfoType()
{
var typeName = Class.GetTypeNameForType(typeof(Type));
Assert.Equal("Windows.UI.Xaml.Interop.TypeName", typeName);
}

[Fact]
public void TestGenericTypeMarshalling()
{
Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Projections/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion src/WinRT.Runtime/TypeNameSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down