diff --git a/Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs index d880e52c..bdc593f1 100644 --- a/Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs @@ -1,3 +1,4 @@ +using System; using Cpp2IL.Core.Utils; using LibCpp2IL.BinaryStructures; @@ -11,9 +12,15 @@ public ArrayTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext refe { } - public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_ARRAY; + public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_ARRAY; - public override string DefaultName => $"{ElementType.Name}[{Rank}]"; + public sealed override string DefaultName => $"{ElementType.DefaultName}[{Rank}]"; + + public sealed override string? OverrideName + { + get => $"{ElementType.Name}[{Rank}]"; + set => throw new NotSupportedException(); + } public sealed override bool IsValueType => false; diff --git a/Cpp2IL.Core/Model/Contexts/BoxedTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/BoxedTypeAnalysisContext.cs index 1c950f45..0cbac529 100644 --- a/Cpp2IL.Core/Model/Contexts/BoxedTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/BoxedTypeAnalysisContext.cs @@ -11,9 +11,15 @@ public BoxedTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext refe { } - public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_BOXED; + public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_BOXED; - public override string DefaultName => ElementType.Name; + public sealed override string DefaultName => ElementType.DefaultName; + + public sealed override string? OverrideName + { + get => ElementType.OverrideName; + set => ElementType.OverrideName = value; + } public sealed override bool IsValueType => false; } diff --git a/Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs index ebb2e15d..1a83d149 100644 --- a/Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs @@ -1,3 +1,4 @@ +using System; using LibCpp2IL.BinaryStructures; namespace Cpp2IL.Core.Model.Contexts; @@ -10,9 +11,15 @@ public ByRefTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext refe { } - public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_BYREF; + public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_BYREF; - public override string DefaultName => $"{ElementType.Name}&"; + public sealed override string DefaultName => $"{ElementType.DefaultName}&"; + + public sealed override string? OverrideName + { + get => $"{ElementType.Name}&"; + set => throw new NotSupportedException(); + } public sealed override bool IsValueType => false; diff --git a/Cpp2IL.Core/Model/Contexts/CustomModifierTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/CustomModifierTypeAnalysisContext.cs index 0bdff777..90f823ea 100644 --- a/Cpp2IL.Core/Model/Contexts/CustomModifierTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/CustomModifierTypeAnalysisContext.cs @@ -1,3 +1,4 @@ +using System; using LibCpp2IL.BinaryStructures; namespace Cpp2IL.Core.Model.Contexts; @@ -9,11 +10,19 @@ public class CustomModifierTypeAnalysisContext(TypeAnalysisContext elementType, public bool Required { get; } = required; - public override Il2CppTypeEnum Type => Required ? Il2CppTypeEnum.IL2CPP_TYPE_CMOD_REQD : Il2CppTypeEnum.IL2CPP_TYPE_CMOD_OPT; + public sealed override Il2CppTypeEnum Type => Required ? Il2CppTypeEnum.IL2CPP_TYPE_CMOD_REQD : Il2CppTypeEnum.IL2CPP_TYPE_CMOD_OPT; - public override string DefaultName => Required - ? $"{ElementType.Name} modreq({ModifierType.Name})" - : $"{ElementType.Name} modopt({ModifierType.Name})"; + public sealed override string DefaultName => Required + ? $"{ElementType.DefaultName} modreq({ModifierType.DefaultFullName})" + : $"{ElementType.DefaultName} modopt({ModifierType.DefaultFullName})"; + + public sealed override string? OverrideName + { + get => Required + ? $"{ElementType.Name} modreq({ModifierType.FullName})" + : $"{ElementType.Name} modopt({ModifierType.FullName})"; + set => throw new NotSupportedException(); + } public sealed override bool IsValueType => ElementType.IsValueType; } diff --git a/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs index 1cf646a0..fe483eec 100644 --- a/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs @@ -15,15 +15,27 @@ public class GenericInstanceTypeAnalysisContext : ReferencedTypeAnalysisContext public List GenericArguments { get; } = []; - public override TypeAttributes DefaultAttributes => GenericType.DefaultAttributes; + public sealed override TypeAttributes DefaultAttributes => GenericType.DefaultAttributes; - public override TypeAttributes? OverrideAttributes { get => GenericType.OverrideAttributes; set => GenericType.OverrideAttributes = value; } + public sealed override TypeAttributes? OverrideAttributes { get => GenericType.OverrideAttributes; set => GenericType.OverrideAttributes = value; } - public override string DefaultName => $"{GenericType.Name}<{string.Join(", ", GenericArguments.Select(a => a.Name))}>"; + public sealed override string DefaultName => $"{GenericType.DefaultName}<{string.Join(", ", GenericArguments.Select(a => a.DefaultFullName))}>"; - public override string DefaultNamespace => GenericType.Namespace; + public sealed override string? OverrideName + { + get => $"{GenericType.Name}<{string.Join(", ", GenericArguments.Select(a => a.FullName))}>"; + set => throw new NotSupportedException(); + } + + public sealed override string DefaultNamespace => GenericType.DefaultNamespace; + + public sealed override string? OverrideNamespace + { + get => GenericType.OverrideNamespace; + set => GenericType.OverrideNamespace = value; + } - public override TypeAnalysisContext? DefaultBaseType { get; } + public sealed override TypeAnalysisContext? DefaultBaseType { get; } public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_GENERICINST; diff --git a/Cpp2IL.Core/Model/Contexts/GenericParameterTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/GenericParameterTypeAnalysisContext.cs index 3a850ad7..77653244 100644 --- a/Cpp2IL.Core/Model/Contexts/GenericParameterTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/GenericParameterTypeAnalysisContext.cs @@ -16,9 +16,17 @@ public class GenericParameterTypeAnalysisContext : ReferencedTypeAnalysisContext public sealed override string DefaultNamespace => ""; + public sealed override string? OverrideNamespace + { + get => null; + set + { + } + } + public int Index { get; } - public override Il2CppTypeEnum Type { get; } + public sealed override Il2CppTypeEnum Type { get; } public new GenericParameterAttributes DefaultAttributes { get; } public new GenericParameterAttributes? OverrideAttributes { get; set; } diff --git a/Cpp2IL.Core/Model/Contexts/PinnedTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/PinnedTypeAnalysisContext.cs index d3e2759b..a00aeeee 100644 --- a/Cpp2IL.Core/Model/Contexts/PinnedTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/PinnedTypeAnalysisContext.cs @@ -11,9 +11,15 @@ public PinnedTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext ref { } - public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_PINNED; + public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_PINNED; - public override string DefaultName => ElementType.Name; + public sealed override string DefaultName => ElementType.DefaultName; + + public sealed override string? OverrideName + { + get => ElementType.OverrideName; + set => ElementType.OverrideName = value; + } public sealed override bool IsValueType => false; } diff --git a/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs index 7f682348..91a295f9 100644 --- a/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs @@ -1,3 +1,4 @@ +using System; using Cpp2IL.Core.Utils; using LibCpp2IL.BinaryStructures; @@ -11,9 +12,15 @@ public PointerTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext re { } - public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_PTR; + public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_PTR; - public override string DefaultName => $"{ElementType.Name}*"; + public sealed override string DefaultName => $"{ElementType.DefaultName}*"; + + public sealed override string? OverrideName + { + get => $"{ElementType.Name}*"; + set => throw new NotSupportedException(); + } public sealed override bool IsValueType => false; } diff --git a/Cpp2IL.Core/Model/Contexts/ReferencedTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/ReferencedTypeAnalysisContext.cs index d0a8a946..44dd5250 100644 --- a/Cpp2IL.Core/Model/Contexts/ReferencedTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/ReferencedTypeAnalysisContext.cs @@ -15,11 +15,6 @@ public abstract class ReferencedTypeAnalysisContext(AssemblyAnalysisContext refe public override AssemblyAnalysisContext CustomAttributeAssembly => DeclaringAssembly; - public override string ToString() - { - return DefaultName; - } - public override string GetCSharpSourceString() { return Name; diff --git a/Cpp2IL.Core/Model/Contexts/SentinelTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/SentinelTypeAnalysisContext.cs index ac69b1e2..8cdb101f 100644 --- a/Cpp2IL.Core/Model/Contexts/SentinelTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/SentinelTypeAnalysisContext.cs @@ -6,5 +6,20 @@ public sealed class SentinelTypeAnalysisContext(AssemblyAnalysisContext referenc { public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_SENTINEL; public override string DefaultName => "<>"; + public override string? OverrideName + { + get => null; + set + { + } + } + public override string DefaultNamespace => ""; + public override string? OverrideNamespace + { + get => null; + set + { + } + } public override bool IsValueType => false; } diff --git a/Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs index 72aad8b5..5e1c8b89 100644 --- a/Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs @@ -1,3 +1,4 @@ +using System; using Cpp2IL.Core.Utils; using LibCpp2IL.BinaryStructures; @@ -11,9 +12,15 @@ public SzArrayTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext re { } - public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_SZARRAY; + public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_SZARRAY; - public override string DefaultName => $"{ElementType.Name}[]"; + public sealed override string DefaultName => $"{ElementType.DefaultName}[]"; + + public sealed override string? OverrideName + { + get => $"{ElementType.Name}[]"; + set => throw new NotSupportedException(); + } public sealed override bool IsValueType => false; } diff --git a/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs index d11dfb91..e05ab750 100644 --- a/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/TypeAnalysisContext.cs @@ -61,7 +61,7 @@ public class TypeAnalysisContext : HasGenericParameters, ITypeInfoProvider, ICSh public virtual string DefaultNamespace => Definition?.Namespace ?? throw new("Subclasses of TypeAnalysisContext must override DefaultNs"); - public string? OverrideNamespace { get; set; } + public virtual string? OverrideNamespace { get; set; } public string Namespace { diff --git a/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs index 44278f84..50491eea 100644 --- a/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs @@ -12,7 +12,13 @@ public abstract class WrappedTypeAnalysisContext( { public virtual TypeAnalysisContext ElementType { get; } = elementType; - public override string DefaultNamespace => ElementType.Namespace; + public sealed override string DefaultNamespace => ElementType.DefaultNamespace; + + public sealed override string? OverrideNamespace + { + get => ElementType.OverrideNamespace; + set => ElementType.OverrideNamespace = value; + } public static WrappedTypeAnalysisContext Create(Il2CppType rawType, AssemblyAnalysisContext referencedFrom) {