From a4747bcd8bc029c478150fbf5027bea3143ba188 Mon Sep 17 00:00:00 2001 From: Colin Green Date: Tue, 19 Apr 2022 21:38:13 +0100 Subject: [PATCH] Change: IsGeneratableType will return false for Syste.Guid, DateOnly, and TimeOnly. These types report as SpecialType.None, but are System value/struct types that do not require a wrapper type. Note. DateOnly and TimeOnly were added in .NEt 6.0, and therefore are not part of NetStandard2.0 (and therefore are not currently known to Microsoft.CodeAnalysis). --- .../GeneratedTypeFilter.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/JsonMergePatch.SourceGenerator/GeneratedTypeFilter.cs b/src/JsonMergePatch.SourceGenerator/GeneratedTypeFilter.cs index c37e5bd..662b827 100644 --- a/src/JsonMergePatch.SourceGenerator/GeneratedTypeFilter.cs +++ b/src/JsonMergePatch.SourceGenerator/GeneratedTypeFilter.cs @@ -12,7 +12,17 @@ public static bool IsGeneratableType(ITypeSymbol typeInfo) bool generic = false; if (typeInfo is INamedTypeSymbol namedTypeInfo) generic = namedTypeInfo.IsGenericType; - return typeInfo.SpecialType == SpecialType.None && !typeInfo.IsAnonymousType && !typeInfo.IsAbstract && !generic && !typeInfo.IsStatic && typeInfo.TypeKind != TypeKind.Enum; + + // Check for System types that have SpecialType.None. + string typeName = typeInfo.ToDisplayString(); + bool isNonSpecialSystemType = typeName == "System.Guid" || typeName == "System.DateOnly" || typeName == "System.TimeOnly"; + + return typeInfo.SpecialType == SpecialType.None + && !isNonSpecialSystemType + && !typeInfo.IsAnonymousType + && !typeInfo.IsAbstract + && !generic && !typeInfo.IsStatic + && typeInfo.TypeKind != TypeKind.Enum; }