Skip to content

Commit 9ae5fba

Browse files
committed
Tweak WinRT types matching logic
1 parent c031808 commit 9ae5fba

File tree

1 file changed

+18
-12
lines changed
  • components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.SourceGenerators/Extensions

1 file changed

+18
-12
lines changed

components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.SourceGenerators/Extensions/WinRTExtensions.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ public static bool IsWellKnownWinRTProjectedValueType(this ITypeSymbol symbol, b
3030
// projected enum type or struct type (ie. some projected value type in general, except
3131
// for 'Nullable<T>' values), then we can just use 'null' and bypass creating the property
3232
// metadata. The WinRT runtime will automatically instantiate a default value for us.
33-
if (symbol.IsContainedInNamespace(WellKnownTypeNames.XamlNamespace(useWindowsUIXaml)) ||
33+
if (symbol.IsContainedInNamespace(WellKnownTypeNames.XamlNamespace(useWindowsUIXaml)))
34+
{
35+
return true;
36+
}
37+
38+
// Special case for projected numeric types
39+
if (symbol.Name is "Matrix3x2" or "Matrix4x4" or "Plane" or "Quaternion" or "Vector2" or "Vector3" or "Vector4" &&
3440
symbol.IsContainedInNamespace("System.Numerics"))
3541
{
3642
return true;
@@ -51,17 +57,17 @@ public static bool IsWellKnownWinRTProjectedValueType(this ITypeSymbol symbol, b
5157

5258
// Lastly, special case the well known primitive types
5359
if (symbol.SpecialType is
54-
SpecialType.System_Int32 or
55-
SpecialType.System_Byte or
56-
SpecialType.System_SByte or
57-
SpecialType.System_Int16 or
58-
SpecialType.System_UInt16 or
59-
SpecialType.System_UInt32 or
60-
SpecialType.System_Int64 or
61-
SpecialType.System_UInt64 or
62-
SpecialType.System_Char or
63-
SpecialType.System_Single or
64-
SpecialType.System_Double)
60+
SpecialType.System_Int32 or
61+
SpecialType.System_Byte or
62+
SpecialType.System_SByte or
63+
SpecialType.System_Int16 or
64+
SpecialType.System_UInt16 or
65+
SpecialType.System_UInt32 or
66+
SpecialType.System_Int64 or
67+
SpecialType.System_UInt64 or
68+
SpecialType.System_Char or
69+
SpecialType.System_Single or
70+
SpecialType.System_Double)
6571
{
6672
return true;
6773
}

0 commit comments

Comments
 (0)