get all fields, not just non-private

This commit is contained in:
JohnCorby 2022-01-13 21:43:48 -08:00
parent 7064cbb793
commit c6c475c344
2 changed files with 5 additions and 3 deletions

View File

@ -221,7 +221,10 @@ namespace Mirror.Weaver
{
foreach (FieldDefinition field in typeDefinition.Fields)
{
if (field.IsStatic || field.IsPrivate)
if (field.IsStatic)
continue;
if (field.HasCustomAttribute<System.Runtime.CompilerServices.CompilerGeneratedAttribute>())
continue;
if (field.IsNotSerialized)

View File

@ -314,7 +314,7 @@ namespace Mirror.Weaver
MethodDefinition ctor = Resolvers.ResolveDefaultPublicCtor(variable);
if (ctor == null)
{
Log.Error($"{variable.Name} can't be deserialized because it has no default constructor. Don't use {variable.Name} in [SyncVar]s, Rpcs, Cmds, etc.", variable);
// Log.Error($"{variable.Name} can't be deserialized because it has no default constructor. Don't use {variable.Name} in [SyncVar]s, Rpcs, Cmds, etc.", variable);
// WeavingFailed = true;
// return;
var resolvedVariable = variable.Resolve();
@ -323,7 +323,6 @@ namespace Mirror.Weaver
var ctorWorker = ctor.Body.GetILProcessor();
ctorWorker.Emit(OpCodes.Ret);
resolvedVariable.Methods.Add(ctor);
Log.Warning("created empty default ctor", variable);
}
MethodReference ctorRef = assembly.MainModule.ImportReference(ctor);