Model: Add FieldInfo.RequiresUnsafeContext
This commit is contained in:
@@ -82,6 +82,9 @@ namespace Il2CppInspector.Reflection {
|
|||||||
// True if the field is declared as static
|
// True if the field is declared as static
|
||||||
public bool IsStatic => (Attributes & FieldAttributes.Static) == FieldAttributes.Static;
|
public bool IsStatic => (Attributes & FieldAttributes.Static) == FieldAttributes.Static;
|
||||||
|
|
||||||
|
// Returns true if using this field requires that the using method is declared as unsafe
|
||||||
|
public bool RequiresUnsafeContext => FieldType.RequiresUnsafeContext || GetCustomAttributes("System.Runtime.CompilerServices.FixedBufferAttribute").Any();
|
||||||
|
|
||||||
public override MemberTypes MemberType => MemberTypes.Field;
|
public override MemberTypes MemberType => MemberTypes.Field;
|
||||||
|
|
||||||
public FieldInfo(Il2CppInspector pkg, int fieldIndex, TypeInfo declaringType) :
|
public FieldInfo(Il2CppInspector pkg, int fieldIndex, TypeInfo declaringType) :
|
||||||
@@ -158,8 +161,6 @@ namespace Il2CppInspector.Reflection {
|
|||||||
public string GetModifierString() {
|
public string GetModifierString() {
|
||||||
var modifiers = new StringBuilder(GetAccessModifierString());
|
var modifiers = new StringBuilder(GetAccessModifierString());
|
||||||
|
|
||||||
if (FieldType.RequiresUnsafeContext || GetCustomAttributes("System.Runtime.CompilerServices.FixedBufferAttribute").Any())
|
|
||||||
modifiers.Append("unsafe ");
|
|
||||||
if (IsLiteral)
|
if (IsLiteral)
|
||||||
modifiers.Append("const ");
|
modifiers.Append("const ");
|
||||||
// All const fields are also static by implication
|
// All const fields are also static by implication
|
||||||
@@ -167,6 +168,8 @@ namespace Il2CppInspector.Reflection {
|
|||||||
modifiers.Append("static ");
|
modifiers.Append("static ");
|
||||||
if (IsInitOnly)
|
if (IsInitOnly)
|
||||||
modifiers.Append("readonly ");
|
modifiers.Append("readonly ");
|
||||||
|
if (RequiresUnsafeContext)
|
||||||
|
modifiers.Append("unsafe ");
|
||||||
if (IsPinvokeImpl)
|
if (IsPinvokeImpl)
|
||||||
modifiers.Append("extern ");
|
modifiers.Append("extern ");
|
||||||
if (GetCustomAttributes("System.Runtime.CompilerServices.FixedBufferAttribute").Any())
|
if (GetCustomAttributes("System.Runtime.CompilerServices.FixedBufferAttribute").Any())
|
||||||
|
|||||||
Reference in New Issue
Block a user