bool TryCoreCompile(MethodDefinition initComp, ILRootNode rootnode, string xamlFilePath, TaskLoggingHelper loggingHelper, 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); var visitorContext = new ILContext(il, body, module) { XamlFilePath = xamlFilePath, LoggingHelper = loggingHelper, }; rootnode.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null); rootnode.Accept(new ExpandMarkupsVisitor(visitorContext), null); rootnode.Accept(new PruneIgnoredNodesVisitor(), null); rootnode.Accept(new SimplifyOnPlatformVisitor(TargetFramework), null); rootnode.Accept(new CreateObjectVisitor(visitorContext), null); rootnode.Accept(new SetNamescopesAndRegisterNamesVisitor(visitorContext), null); rootnode.Accept(new SetFieldVisitor(visitorContext), null); rootnode.Accept(new SetResourcesVisitor(visitorContext), null); rootnode.Accept(new SetPropertiesVisitor(visitorContext, true), null); il.Emit(Ret); initComp.Body = body; exception = null; return(true); } catch (Exception e) { exception = e; return(false); } }
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); var visitorContext = new ILContext(il, body, module) { DefineDebug = DebugSymbols || (!string.IsNullOrEmpty(DebugType) && DebugType.ToLowerInvariant() != "none"), XamlFilePath = xamlFilePath }; rootnode.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null); rootnode.Accept(new ExpandMarkupsVisitor(visitorContext), null); rootnode.Accept(new PruneIgnoredNodesVisitor(), null); rootnode.Accept(new CreateObjectVisitor(visitorContext), null); rootnode.Accept(new SetNamescopesAndRegisterNamesVisitor(visitorContext), null); rootnode.Accept(new SetFieldVisitor(visitorContext), null); rootnode.Accept(new SetResourcesVisitor(visitorContext), null); rootnode.Accept(new SetPropertiesVisitor(visitorContext, true), null); il.Emit(Ret); initComp.Body = body; exception = null; return(true); } catch (Exception e) { exception = e; return(false); } }