Output: Don't initialize statics or consts to default in struct constructors (CS0131)
This commit is contained in:
@@ -491,8 +491,9 @@ namespace Il2CppInspector
|
|||||||
// Struct construvctors must initialize all fields in the struct
|
// Struct construvctors must initialize all fields in the struct
|
||||||
if (fields.Any()) {
|
if (fields.Any()) {
|
||||||
var paramNames = method.DeclaredParameters.Select(p => p.Name);
|
var paramNames = method.DeclaredParameters.Select(p => p.Name);
|
||||||
sb.Append(" {\n" + string.Join("\n",
|
sb.Append(" {\n" + string.Join("\n", fields
|
||||||
fields.Select(f => $"{prefix}\t\t{(paramNames.Contains(f.Name) ? "this." : "")}{f.Name} = default;"))
|
.Where(f => !f.IsStatic && !f.IsLiteral)
|
||||||
|
.Select(f => $"{prefix}\t\t{(paramNames.Contains(f.Name) ? "this." : "")}{f.Name} = default;"))
|
||||||
+ $"\n{prefix}\t}}");
|
+ $"\n{prefix}\t}}");
|
||||||
} else
|
} else
|
||||||
sb.Append(" {}");
|
sb.Append(" {}");
|
||||||
|
|||||||
Reference in New Issue
Block a user