bool TryCoreCompile(MethodDefinition initComp, MethodDefinition initCompRuntime, ILRootNode rootnode, string xamlFilePath, out Exception exception) { try { var body = new MethodBody(initComp); var module = body.Method.Module; body.InitLocals = true; var il = body.GetILProcessor(); var resourcePath = GetPathForType(module, initComp.DeclaringType); il.Emit(Nop); if (initCompRuntime != null) { // Generating branching code for the Previewer //First using the ResourceLoader var nop = Instruction.Create(Nop); il.Emit(Newobj, module.ImportCtorReference(("System.Maui.Core", "System.Maui.Internals", "ResourceLoader/ResourceLoadingQuery"), 0)); //AssemblyName il.Emit(Dup); //dup the RLQ il.Emit(Ldtoken, module.ImportReference(initComp.DeclaringType)); il.Emit(Call, module.ImportMethodReference(("mscorlib", "System", "Type"), methodName: "GetTypeFromHandle", parameterTypes: new[] { ("mscorlib", "System", "RuntimeTypeHandle") }, isStatic: true));