Skip to content

Commit

Permalink
Tweak WinRT types matching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Dec 27, 2024
1 parent c031808 commit 9ae5fba
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ public static bool IsWellKnownWinRTProjectedValueType(this ITypeSymbol symbol, b
// projected enum type or struct type (ie. some projected value type in general, except
// for 'Nullable<T>' values), then we can just use 'null' and bypass creating the property
// metadata. The WinRT runtime will automatically instantiate a default value for us.
if (symbol.IsContainedInNamespace(WellKnownTypeNames.XamlNamespace(useWindowsUIXaml)) ||
if (symbol.IsContainedInNamespace(WellKnownTypeNames.XamlNamespace(useWindowsUIXaml)))
{
return true;
}

// Special case for projected numeric types
if (symbol.Name is "Matrix3x2" or "Matrix4x4" or "Plane" or "Quaternion" or "Vector2" or "Vector3" or "Vector4" &&
symbol.IsContainedInNamespace("System.Numerics"))
{
return true;
Expand All @@ -51,17 +57,17 @@ public static bool IsWellKnownWinRTProjectedValueType(this ITypeSymbol symbol, b

// Lastly, special case the well known primitive types
if (symbol.SpecialType is
SpecialType.System_Int32 or
SpecialType.System_Byte or
SpecialType.System_SByte or
SpecialType.System_Int16 or
SpecialType.System_UInt16 or
SpecialType.System_UInt32 or
SpecialType.System_Int64 or
SpecialType.System_UInt64 or
SpecialType.System_Char or
SpecialType.System_Single or
SpecialType.System_Double)
SpecialType.System_Int32 or
SpecialType.System_Byte or
SpecialType.System_SByte or
SpecialType.System_Int16 or
SpecialType.System_UInt16 or
SpecialType.System_UInt32 or
SpecialType.System_Int64 or
SpecialType.System_UInt64 or
SpecialType.System_Char or
SpecialType.System_Single or
SpecialType.System_Double)
{
return true;
}
Expand Down

0 comments on commit 9ae5fba

Please sign in to comment.