You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you try to emit a class that implements an interface with a default interface method, and the class does not override the defaulted method, the resulting assembly crashes the assembly generator with the following stack trace.
Unhandled exception. System.InvalidCastException: Specified cast is not valid.
at System.Reflection.Throw.InvalidCast()
at System.Reflection.Metadata.TypeDefinitionHandle.op_Explicit(EntityHandle handle)
at Lokad.ILPack.AssemblyGenerator.DeclareInterfacesAndCreateInterfaceMap(Type type, TypeDefinitionHandle handle)
at Lokad.ILPack.AssemblyGenerator.CreateType(Type type, List`1 genericParams)
at Lokad.ILPack.AssemblyGenerator.CreateTypes(IEnumerable`1 types, List`1 genericParams)
at Lokad.ILPack.AssemblyGenerator.CreateModules(IEnumerable`1 moduleInfo)
at Lokad.ILPack.AssemblyGenerator.GenerateAssemblyBytes(Assembly assembly, IEnumerable`1 referencedDynamicAssembly)
at Lokad.ILPack.AssemblyGenerator.GenerateAssembly(Assembly assembly, IEnumerable`1 referencedDynamicAssembly, String path)
at Lokad.ILPack.AssemblyGenerator.GenerateAssembly(Assembly assembly, String path).
For completeness, the following code reproduces this bug:
usingSystem.Reflection;usingSystem.Reflection.Emit;usingLokad.ILPack;varassemblyBuilder=AssemblyBuilder.DefineDynamicAssembly(newAssemblyName("Demo"),AssemblyBuilderAccess.RunAndCollect);varmoduleBuilder=assemblyBuilder.DefineDynamicModule("ModuleName");vartypeBuilder=moduleBuilder.DefineType("Crash",TypeAttributes.Public,typeof(object),new[]{typeof(IDefaultedMethod)});typeBuilder.DefineDefaultConstructor(MethodAttributes.Public);typeBuilder.CreateType();newAssemblyGenerator().GenerateAssembly(assemblyBuilder,"demo.dll");publicinterfaceIDefaultedMethod{publicvoidDefault(){}// omitting this line allows the assembly generator to emit demo.dll}
The text was updated successfully, but these errors were encountered:
Hi @Freekjan, thanks a lot for your very precise report. I don't have resources to assign to the case at the moment, but we will try, at some point, to make another round of bugfixes on this project.
If you try to emit a class that implements an interface with a default interface method, and the class does not override the defaulted method, the resulting assembly crashes the assembly generator with the following stack trace.
For completeness, the following code reproduces this bug:
The text was updated successfully, but these errors were encountered: