Skip to content

Commit 83f6720

Browse files
authored
fix constructor lookup for AOT runtime (#210)
This is fix for 'unable to find default constructor to type 'X' for AOT runtimes like iOS, WebGL etc.
1 parent b7b1bf4 commit 83f6720

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Assets/Colyseus/Runtime/GameDevWare.Serialization/Metadata/MetadataReflection.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,15 @@ public static bool TryGetConstructor(Type type, out Func<object> ctrFn, out Cons
197197
ctrFn = null;
198198
defaultConstructor = null;
199199

200-
if (AotRuntime || type.IsAbstract || type.IsInterface)
200+
if (type.IsAbstract || type.IsInterface)
201201
return false;
202202

203203
defaultConstructor = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault(ctr => ctr.GetParameters().Length == 0);
204204

205+
if (AotRuntime && defaultConstructor != null) {
206+
return true;
207+
}
208+
205209
if (defaultConstructor == null)
206210
return false;
207211

0 commit comments

Comments
 (0)