From 6a1b729c22021c23d2bc0b4294c0087e2b74c431 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Sun, 29 Jun 2025 00:54:23 -0700 Subject: [PATCH] Fix bug in IsValueType --- Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs index b432db77..dbaaa2e1 100644 --- a/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs @@ -340,7 +340,20 @@ public static ITypeInfoProvider GetSndnProviderForType(ApplicationAnalysisContex string ITypeInfoProvider.RewrittenTypeName => Name; string ITypeInfoProvider.TypeNamespace => Namespace; public virtual bool IsGenericInstance => false; - public virtual bool IsValueType => Definition?.IsValueType ?? BaseType is { Namespace: "System", Name: "ValueType" }; + public virtual bool IsValueType + { + get + { + if (Definition is not null) + return Definition.IsValueType; + + if (BaseType is { Namespace: "System", Name: "ValueType" }) + return Namespace is not "System" || Name is not "Enum"; // Enum is a reference type + + return IsEnumType; + } + } + public bool IsEnumType => Definition?.IsEnumType ?? BaseType is { Namespace: "System", Name: "Enum" }; IEnumerable ITypeInfoProvider.GenericArgumentInfoProviders => []; IEnumerable ITypeInfoProvider.FieldInfoProviders => Fields;