Skip to content

Commit

Permalink
Merge pull request #67 from colgreen/master
Browse files Browse the repository at this point in the history
Change: IsGeneratableType will return false for System.Guid, DateOnly, and TimeOnly
  • Loading branch information
ladeak authored Apr 25, 2022
2 parents 12fdfab + a4747bc commit 62682bb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/JsonMergePatch.SourceGenerator/GeneratedTypeFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 62682bb

Please sign in to comment.