From 398155760160676135b0192cb729ced7960a3323 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Wed, 5 Feb 2020 10:29:08 +0100 Subject: [PATCH] Output: Don't initialize statics or consts to default in struct constructors (CS0131) --- Il2CppDumper/Il2CppCSharpDumper.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Il2CppDumper/Il2CppCSharpDumper.cs b/Il2CppDumper/Il2CppCSharpDumper.cs index 064397d..2b32d7f 100644 --- a/Il2CppDumper/Il2CppCSharpDumper.cs +++ b/Il2CppDumper/Il2CppCSharpDumper.cs @@ -491,8 +491,9 @@ namespace Il2CppInspector // Struct construvctors must initialize all fields in the struct if (fields.Any()) { var paramNames = method.DeclaredParameters.Select(p => p.Name); - sb.Append(" {\n" + string.Join("\n", - fields.Select(f => $"{prefix}\t\t{(paramNames.Contains(f.Name) ? "this." : "")}{f.Name} = default;")) + sb.Append(" {\n" + string.Join("\n", fields + .Where(f => !f.IsStatic && !f.IsLiteral) + .Select(f => $"{prefix}\t\t{(paramNames.Contains(f.Name) ? "this." : "")}{f.Name} = default;")) + $"\n{prefix}\t}}"); } else sb.Append(" {}");