From 138e379f3c4de502b8067b9a49c4bb60bab7a158 Mon Sep 17 00:00:00 2001 From: Sam Byass Date: Tue, 25 Jun 2024 22:24:24 +0100 Subject: [PATCH] Core: DummyDll: Fix valuetype not being set on type references --- .../Model/Contexts/GenericInstanceTypeAnalysisContext.cs | 2 ++ Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs | 2 +- Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs index 7e36b119..042c4c84 100644 --- a/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs @@ -22,6 +22,8 @@ public class GenericInstanceTypeAnalysisContext : ReferencedTypeAnalysisContext public sealed override int GenericParameterCount => GenericArguments.Count; + public sealed override bool IsValueType => GenericType.IsValueType; //We don't set a definition so the default implementation cannot determine if we're a value type or not. + public GenericInstanceTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext referencedFrom) : base(referencedFrom) { //Generic type has to be a type definition diff --git a/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs index eefa4f01..c61d0ad4 100644 --- a/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs @@ -232,7 +232,7 @@ public static ITypeInfoProvider GetSndnProviderForType(ApplicationAnalysisContex public string RewrittenTypeName => Name; public string TypeNamespace => Namespace; public virtual bool IsGenericInstance => false; - public bool IsValueType => Definition?.IsValueType ?? BaseType is { Namespace: "System", Name: "ValueType" }; + public virtual bool IsValueType => Definition?.IsValueType ?? BaseType is { Namespace: "System", Name: "ValueType" }; public bool IsEnumType => Definition?.IsEnumType ?? BaseType is { Namespace: "System", Name: "Enum" }; public bool IsInterface => Definition?.IsInterface ?? ((TypeAttributes & TypeAttributes.Interface) != default); public IEnumerable GenericArgumentInfoProviders => Array.Empty(); diff --git a/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs index ed27a87d..4c19f563 100644 --- a/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs @@ -12,6 +12,8 @@ public abstract class WrappedTypeAnalysisContext : ReferencedTypeAnalysisContext public override string DefaultNs => ElementType.Namespace; + public override bool IsValueType => ElementType.IsValueType; //We don't set a definition so the default implementation cannot determine if we're a value type or not. + protected WrappedTypeAnalysisContext(TypeAnalysisContext elementType, AssemblyAnalysisContext referencedFrom) : base(referencedFrom) { ElementType = elementType;