mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Add error message for missing parameter-less constructor (#233)
* Add error message for missing parameter-less constructor * Add error message for missing parameter-less constructor
This commit is contained in:
parent
eb1863a96c
commit
4a3fc70d14
@ -1,4 +1,5 @@
|
||||
// SyncList code
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
@ -27,7 +28,17 @@ public static void GenerateSyncListInstanceInitializer(ILProcessor ctorWorker, F
|
||||
|
||||
// Not initialized by the user in the field definition, e.g:
|
||||
// public SyncListInt Foo;
|
||||
var listCtor = Weaver.scriptDef.MainModule.ImportReference(fd.FieldType.Resolve().Methods.First<MethodDefinition>(x => x.Name == ".ctor" && !x.HasParameters));
|
||||
MethodReference listCtor;
|
||||
try
|
||||
{
|
||||
listCtor = Weaver.scriptDef.MainModule.ImportReference(fd.FieldType.Resolve().Methods.First<MethodDefinition>(x => x.Name == ".ctor" && !x.HasParameters));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Weaver.fail = true;
|
||||
Log.Error($"Missing parameter-less constructor for: {fd.FieldType.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
ctorWorker.Append(ctorWorker.Create(OpCodes.Ldarg_0));
|
||||
ctorWorker.Append(ctorWorker.Create(OpCodes.Newobj, listCtor));
|
||||
|
Loading…
Reference in New Issue
Block a user