CS: Add unsafe modifier to struct constructors where necessary (CS0214)
This commit is contained in:
@@ -16,6 +16,12 @@ namespace Il2CppInspector.Reflection
|
|||||||
|
|
||||||
public static readonly string TypeConstructorName = ".cctor";
|
public static readonly string TypeConstructorName = ".cctor";
|
||||||
|
|
||||||
|
// Struct construvctors must initialize all non-literal fields in the struct
|
||||||
|
// If any of them are of an unsafe type, the constructor must also be declared unsafe
|
||||||
|
public override bool RequiresUnsafeContext => base.RequiresUnsafeContext ||
|
||||||
|
(!IsAbstract && DeclaringType.IsValueType &&
|
||||||
|
DeclaringType.DeclaredFields.Any(f => !f.IsLiteral && f.IsStatic == IsStatic && f.RequiresUnsafeContext));
|
||||||
|
|
||||||
public override MemberTypes MemberType => MemberTypes.Constructor;
|
public override MemberTypes MemberType => MemberTypes.Constructor;
|
||||||
|
|
||||||
public ConstructorInfo(Il2CppInspector pkg, int methodIndex, TypeInfo declaringType) : base(pkg, methodIndex, declaringType) { }
|
public ConstructorInfo(Il2CppInspector pkg, int methodIndex, TypeInfo declaringType) : base(pkg, methodIndex, declaringType) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user