Clean up some compiler messages

This commit is contained in:
Katy Coe
2019-11-28 04:00:32 +01:00
parent f77a9e5289
commit de846ea6db
4 changed files with 13 additions and 13 deletions

View File

@@ -257,7 +257,7 @@ namespace Il2CppInspector
var setAccess = (prop.SetMethod?.Attributes ?? 0) & MethodAttributes.MemberAccessMask;
var primary = getAccess >= setAccess ? prop.GetMethod : prop.SetMethod;
sb.Append($"{prefix}\t{primary.GetModifierString(scope)}{prop.PropertyType.GetScopedCSharpName(scope)} ");
sb.Append($"{prefix}\t{primary.GetModifierString()}{prop.PropertyType.GetScopedCSharpName(scope)} ");
// Non-indexer
if ((!prop.CanRead || !prop.GetMethod.DeclaredParameters.Any()) && (!prop.CanWrite || prop.SetMethod.DeclaredParameters.Count == 1))
@@ -293,7 +293,7 @@ namespace Il2CppInspector
sb.Append(evt.CustomAttributes.OrderBy(a => a.AttributeType.Name)
.ToString(scope, prefix + "\t", emitPointer: !SuppressMetadata, mustCompile: MustCompile));
string modifiers = evt.AddMethod?.GetModifierString(scope);
string modifiers = evt.AddMethod?.GetModifierString();
sb.Append($"{prefix}\t{modifiers}event {evt.EventHandlerType.GetScopedCSharpName(scope)} {evt.Name}");
if (!MustCompile) {
@@ -323,7 +323,7 @@ namespace Il2CppInspector
sb.Append(method.CustomAttributes.OrderBy(a => a.AttributeType.Name)
.ToString(scope, prefix + "\t", emitPointer: !SuppressMetadata, mustCompile: MustCompile));
sb.Append($"{prefix}\t{method.GetModifierString(scope)}{method.DeclaringType.UnmangledBaseName}{method.GetTypeParametersString(scope)}(");
sb.Append($"{prefix}\t{method.GetModifierString()}{method.DeclaringType.UnmangledBaseName}{method.GetTypeParametersString(scope)}(");
sb.Append(method.GetParametersString(scope, !SuppressMetadata) + ")" + (method.IsAbstract? ";" : @" {}"));
sb.Append((!SuppressMetadata && method.VirtualAddress != null ? $" // {method.VirtualAddress.ToAddressString()}" : "") + "\n");
}
@@ -417,7 +417,7 @@ namespace Il2CppInspector
// IL2CPP doesn't seem to retain return type attributes
//writer.Append(method.ReturnType.CustomAttributes.ToString(prefix + "\t", "return: ", emitPointer: !SuppressMetadata));
writer.Append($"{prefix}\t{method.GetModifierString(scope)}");
writer.Append($"{prefix}\t{method.GetModifierString()}");
// Finalizers become destructors
if (method.Name == "Finalize" && method.IsVirtual && method.ReturnType.FullName == "System.Void" && method.IsFamily)

View File

@@ -37,7 +37,8 @@ namespace Il2CppInspector
Position = arch.Offset;
Endianness = Endianness.Little;
var s = new MemoryStream(ReadBytes((int) arch.Size));
using var s = new MemoryStream(ReadBytes((int) arch.Size));
return (IFileFormatReader) MachOReader32.Load(s) ?? MachOReader64.Load(s);
}
}

View File

@@ -150,7 +150,7 @@ namespace Il2CppInspector.Reflection
_ => ""
};
public string GetModifierString(Scope usingScope) {
public string GetModifierString() {
// Interface methods and properties have no visible modifiers (they are always declared 'public abstract')
if (DeclaringType.IsInterface)
return string.Empty;
@@ -176,7 +176,7 @@ namespace Il2CppInspector.Reflection
if ((DeclaringType.BaseType?.GetAllMethods().Any(m => m.GetSignatureString() == GetSignatureString() && m.IsHideBySig) ?? false)
&& (((Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.ReuseSlot && !IsVirtual)
|| (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot))
modifiers.Append($"new ");
modifiers.Append("new ");
if (Name == "op_Implicit")
modifiers.Append("implicit ");

View File

@@ -90,7 +90,7 @@ namespace Il2CppInspector.Reflection {
public List<MethodInfo> DeclaredMethods { get; } = new List<MethodInfo>();
private int[] declaredNestedTypes;
private readonly int[] declaredNestedTypes;
public IEnumerable<TypeInfo> DeclaredNestedTypes => declaredNestedTypes.Select(x => Assembly.Model.TypesByDefinitionIndex[x]);
public List<PropertyInfo> DeclaredProperties { get; } = new List<PropertyInfo>();
@@ -191,8 +191,8 @@ namespace Il2CppInspector.Reflection {
&& usingScope.Substring(0, usingScope.IndexOf('.', diff))
== declaringScope.Substring(0, declaringScope.IndexOf('.', diff)))
diff = usingScope.IndexOf('.', diff) + 1;
usingScope = usingScope.Substring(0, usingScope.Length - 1);
declaringScope = declaringScope.Substring(0, declaringScope.Length - 1);
usingScope = usingScope.Remove(usingScope.Length - 1);
declaringScope = declaringScope.Remove(declaringScope.Length - 1);
// This is the mutual root namespace and optionally nested types that the two scopes share
var mutualRootScope = usingScope.Substring(0, diff - 1);
@@ -656,9 +656,8 @@ namespace Il2CppInspector.Reflection {
}
// Initialize a type that is a generic parameter of a generic method
public TypeInfo(MethodBase declaringMethod, Il2CppGenericParameter param) : this(declaringMethod.DeclaringType, param) {
DeclaringMethod = declaringMethod;
}
public TypeInfo(MethodBase declaringMethod, Il2CppGenericParameter param) : this(declaringMethod.DeclaringType, param)
=> DeclaringMethod = declaringMethod;
// Get all the other types directly referenced by this type (single level depth; no recursion)
public List<TypeInfo> GetAllTypeReferences() {