protected override bool Process(AssemblyStitcherContext context) { if (AlreadyProcessed(context)) { return(false); } #if DEBUG _logging = new MultiLogging(new DefaultLogging(Logging), new FileLogging("MrAdvice.log")); _logging.WriteDebug("Start"); #else _logging = Logging; #endif if (context.Module == null) { _logging.WriteError("Target assembly {0} could not be loaded", context.AssemblyPath); return(false); } try { // instances are created here // please also note poor man's dependency injection (which is enough for us here) var assemblyResolver = context.AssemblyResolver; var typeResolver = new TypeResolver(context.Module) { Logging = _logging, AssemblyResolver = assemblyResolver }; var typeLoader = new TypeLoader(() => LoadWeavedAssembly(context, assemblyResolver)); var aspectWeaver = new AspectWeaver { Logging = _logging, TypeResolver = typeResolver, TypeLoader = typeLoader }; BlobberHelper.Setup(); //Assembly.Load("System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes"); //Assembly.Load("System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes"); Assembly.Load("MrAdvice, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c0e7e6eab6f293d8"); return(aspectWeaver.Weave(context.Module)); } catch (Exception e) { _logging.WriteError("Internal error: {0}", e.ToString()); for (var ie = e.InnerException; ie != null; ie = ie.InnerException) { _logging.WriteError("Inner exception: {0}", e.ToString()); } } return(false); }
/// <summary> /// Processes the specified context. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> /// <exception cref="InvalidOperationException">Ignore.</exception> protected override bool Process(AssemblyStitcherContext context) { BlobberHelper.Setup(); #if DEBUG _logging = new MultiLogging(new DefaultLogging(Logging), new FileLogging("MrAdvice.log")); _logging.WriteDebug("Start"); #else _logging = Logging; #endif if (context.Module is null) { _logging.WriteError("Target assembly {0} could not be loaded", context.AssemblyPath); return(false); } try { // instances are created here // please also note poor man's dependency injection (which is enough for us here) var assemblyResolver = context.AssemblyResolver; var typeResolver = new TypeResolver(context.Module) { Logging = _logging, AssemblyResolver = assemblyResolver }; var typeLoader = new TypeLoader(() => LoadWeavedAssembly(context, assemblyResolver)); var aspectWeaver = new AspectWeaver { Logging = _logging, TypeResolver = typeResolver, TypeLoader = typeLoader }; // second chance: someone had the marker file missing if (aspectWeaver.FindShortcutType(context.Module) is not null) { return(false); } return(aspectWeaver.Weave(context.Module)); } catch (Exception e) { _logging.WriteError("Internal error: {0}", e.ToString()); for (var ie = e.InnerException; ie is not null; ie = ie.InnerException) { _logging.WriteError("Inner exception: {0}", e.ToString()); } } return(false); }
protected override bool Process(AssemblyStitcherContext context) { if (AlreadyProcessed(context)) { return(false); } #if DEBUG _logging = new MultiLogging(new DefaultLogging(Logging), new FileLogging("MrAdvice.log")); _logging.WriteDebug("Start"); #else _logging = Logging; #endif try { // instances are created here // please also note poor man's dependency injection (which is enough for us here) var assemblyResolver = context.AssemblyResolver; var typeResolver = new TypeResolver { Logging = _logging, AssemblyResolver = assemblyResolver }; var typeLoader = new TypeLoader(() => LoadWeavedAssembly(context, assemblyResolver)); var aspectWeaver = new AspectWeaver { Logging = _logging, TypeResolver = typeResolver, TypeLoader = typeLoader }; // TODO: use blobber's resolution (WTF?) AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; BlobberHelper.Setup(); return(aspectWeaver.Weave(context.Module)); } catch (Exception e) { _logging.WriteError("Internal error: {0}", e.ToString()); for (var ie = e.InnerException; ie != null; ie = ie.InnerException) { _logging.WriteError("Inner exception: {0}", e.ToString()); } } return(false); }
protected override bool Process(AssemblyStitcherContext context) { BlobberHelper.Setup(); if (AlreadyProcessed(context)) { return(false); } #if DEBUG _logging = new MultiLogging(new DefaultLogging(Logging), new FileLogging("MrAdvice.log")); _logging.WriteDebug("Start"); #else _logging = Logging; #endif if (context.Module == null) { _logging.WriteError("Target assembly {0} could not be loaded", context.AssemblyPath); return(false); } try { try { const string mrAdviceAssemblyName = "MrAdvice, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c0e7e6eab6f293d8"; var mrAdviceAssembly = LoadEmbeddedAssembly(mrAdviceAssemblyName); if (mrAdviceAssembly == null) { _logging.WriteError("Can't find/load embedded MrAdvice assembly (WTF?), exiting"); return(false); } } catch (FileNotFoundException) { _logging.WriteError("Can't load MrAdvice assembly (WTF?), exiting"); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { _logging.Write("Assembly in AppDomain: {0}", assembly.GetName()); } return(false); } // instances are created here // please also note poor man's dependency injection (which is enough for us here) var assemblyResolver = context.AssemblyResolver; var typeResolver = new TypeResolver(context.Module) { Logging = _logging, AssemblyResolver = assemblyResolver }; var typeLoader = new TypeLoader(() => LoadWeavedAssembly(context, assemblyResolver)); var aspectWeaver = new AspectWeaver { Logging = _logging, TypeResolver = typeResolver, TypeLoader = typeLoader }; // second chance: someone had the marker file missing if (aspectWeaver.FindShortcutType(context.Module) != null) { return(false); } return(aspectWeaver.Weave(context.Module)); } catch (Exception e) { _logging.WriteError("Internal error: {0}", e.ToString()); for (var ie = e.InnerException; ie != null; ie = ie.InnerException) { _logging.WriteError("Inner exception: {0}", e.ToString()); } } return(false); }
/// <summary> /// Entry point for nested process (for isolation). /// </summary> /// <param name="args">The arguments.</param> /// <returns></returns> public static int Main(string[] args) { BlobberHelper.Setup(); return(Run(new MrAdviceTask(), args)); }