public WithInterceptorTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyWithInterceptor\bin\Debug\AssemblyWithInterceptor.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); var methodTimeLogger = assemblyWeaver.Assembly.GetType("MethodTimeLogger"); methodBaseField = methodTimeLogger.GetField("MethodBase"); }
public WithInterceptorTests() { beforeAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithInterceptor\bin\Debug\AssemblyWithInterceptor.dll"); assemblyWeaver = new AssemblyWeaver(beforeAssemblyPath); var methodTimeLogger = assemblyWeaver.Assembly.GetType("MethodTimeLogger"); methodBaseField = methodTimeLogger.GetField("MethodBase"); }
public void Foo() { var assemblyPath = Path.GetFullPath(@"C:\Code\Nancy\src\Nancy\obj\Debug\Nancy.dll"); var assemblyWeaver = new AssemblyWeaver(assemblyPath); Verifier.Verify(assemblyWeaver.Assembly.CodeBase.Remove(0, 8)); }
private static void SetupPerformanceProfiler( AssemblyWeaver assemblyWeaver, AssemblyResolver assemblyResolver, IEnumerable <MethodDefinition> methodDefinitions) => methodDefinitions .Where(m => m.ShouldEnableProfiler(assemblyResolver)) .Setup(assemblyWeaver) .Measure <PerformanceLogger>();
private static void SetupExceptionLogger( AssemblyWeaver assemblyWeaver, AssemblyResolver assemblyResolver, IEnumerable <MethodDefinition> methodDefinitions) => methodDefinitions .Where(m => m.ShouldEnableLogging(assemblyResolver)) .Setup(assemblyWeaver) .Rethrow <Exception, TestContextExceptionLogger>();
public WithInterceptorTests() { beforeAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithInterceptor\bin\Debug\AssemblyWithInterceptor.dll"); assemblyWeaver = new AssemblyWeaver(beforeAssemblyPath); var methodTimeLogger = assemblyWeaver.Assembly.GetType("MethodTimeLogger"); methodBaseField = methodTimeLogger.GetField("MethodBase"); }
public WithInterceptorTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyWithInterceptor\bin\Debug\AssemblyWithInterceptor.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); var methodTimeLogger = assemblyWeaver.Assembly.GetType("MethodTimeLogger"); methodBaseField = methodTimeLogger.GetField("MethodBase"); }
public WithInterceptorInReferenceTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyWIthInterceptorInReference\bin\Debug\AssemblyWIthInterceptorInReference.dll"); var assemblyToReference = AssemblyWeaver.FixAssemblyPath(Path.GetFullPath(@"..\..\..\AssemblyToReference\bin\Debug\AssemblyToReference.dll")); assemblyWeaver = new AssemblyWeaver(assemblyPath, new List<string> { assemblyToReference }); var interceptorAssembly = Assembly.LoadFrom(assemblyToReference); var methodTimeLogger = interceptorAssembly.GetType("MethodTimeLogger"); methodBaseField = methodTimeLogger.GetField("MethodBase"); }
public WithInterceptorInReferenceTests() { beforeAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWIthInterceptorInReference\bin\Debug\AssemblyWIthInterceptorInReference.dll"); var assemblyToReferencePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToReference\bin\Debug\AssemblyToReference.dll"); var assemblyToReference = AssemblyWeaver.FixAssemblyPath(assemblyToReferencePath); assemblyWeaver = new AssemblyWeaver(beforeAssemblyPath, new List<string> {assemblyToReference}); var interceptorAssembly = Assembly.LoadFrom(assemblyToReference); var methodTimeLogger = interceptorAssembly.GetType("MethodTimeLogger"); methodBaseField = methodTimeLogger.GetField("MethodBase"); }
public void WeaveMyApplication() { TraceLoggingConfiguration.TraceLoggingConfigurationBuilder config = TraceLoggingConfiguration.New .WithFilter(new PublicMethodsFilter()) .WithAdapterAssembly(typeof(Serilog.Log).Assembly.GetName().FullName) .WithLogManager(typeof(Serilog.Adapters.LogManagerAdapter).FullName) .WithLogger(typeof(Serilog.Adapters.LoggerAdapter).FullName) .WithStaticLogger(typeof(Serilog.Log).FullName); AssemblyWeaver.Execute("..\\..\\..\\TestApplication.Serilog\\bin\\debug\\TestApplication.Serilog.exe", config); }
public WithInterceptorInReferenceTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyWIthInterceptorInReference\bin\Debug\AssemblyWIthInterceptorInReference.dll"); var assemblyToReference = AssemblyWeaver.FixAssemblyPath(Path.GetFullPath(@"..\..\..\AssemblyToReference\bin\Debug\AssemblyToReference.dll")); assemblyWeaver = new AssemblyWeaver(assemblyPath, new List <string> { assemblyToReference }); var interceptorAssembly = Assembly.LoadFrom(assemblyToReference); var methodTimeLogger = interceptorAssembly.GetType("MethodTimeLogger"); methodBaseField = methodTimeLogger.GetField("MethodBase"); }
protected void Rewrite(string assemblyPath, ITraceLoggingFilter filter) { //Set-up log adapter to our mock var assembly = Assembly.GetExecutingAssembly(); var config = TraceLoggingConfiguration.New .WithFilter(filter) .WithAdapterAssembly(assembly.GetName().FullName) .WithLogManager(typeof(MockLogManagerAdapter).FullName) .WithLogger(typeof(IMockLogAdapter).FullName) .WithStaticLogger(typeof(MockLog).FullName); AssemblyWeaver.Execute(assemblyPath, config); }
public WithInterceptorInReferenceTests() { beforeAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWIthInterceptorInReference\bin\Debug\AssemblyWIthInterceptorInReference.dll"); var assemblyToReferencePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToReference\bin\Debug\AssemblyToReference.dll"); var assemblyToReference = AssemblyWeaver.FixAssemblyPath(assemblyToReferencePath); assemblyWeaver = new AssemblyWeaver(beforeAssemblyPath, new List <string> { assemblyToReference }); var interceptorAssembly = Assembly.LoadFrom(assemblyToReference); var methodTimeLogger = interceptorAssembly.GetType("MethodTimeLogger"); methodBaseField = methodTimeLogger.GetField("MethodBase"); }
public void The_xamlator_assembly_is_weaved_with_the_current_ip() { var task = new AssemblyWeaver(); task.Path = BuildConstants.XAMLATOR_ASSEMBLY; task.BuildEngine = Mock.Of <IBuildEngine>(); task.Execute(); var assembly = Assembly.LoadFrom(BuildConstants.XAMLATOR_ASSEMBLY); using (Stream stream = assembly.GetManifestResourceStream(BuildConstants.IDE_IP_RESOURCE_NAME)) using (StreamReader reader = new StreamReader(stream)) { var ip = reader.ReadLine(); Assert.AreEqual(BuildNetworkUtils.DeviceIps().First(), ip); } }
protected void Rewrite(string assemblyPath, ITraceLoggingFilter filter, bool traceConstructors = false) { //Set-up log adapter to our mock Assembly assembly = Assembly.GetExecutingAssembly(); TraceLoggingConfiguration.TraceLoggingConfigurationBuilder config = TraceLoggingConfiguration.New .WithFilter(filter) .WithAdapterAssembly(assembly.GetName().FullName) .WithLogManager(typeof(MockLogManagerAdapter).FullName) .WithLogger(typeof(MockLogAdapter).FullName) .WithStaticLogger(typeof(MockLog).FullName); if (traceConstructors) { config.WithConstructorTraceOn(); } AssemblyWeaver.Execute(assemblyPath, config); }
private static void Main(string[] args) { var options = new Options(); if (!Parser.Default.ParseArguments(args, options)) { throw new ArgumentException("Invalid parameters."); } /* In order to leave the main assembly unlocked, * we create a copy of the file and use it for readonly operations */ var readonlyAssemblyPath = CreateReadonlyAssembly(options.AssemblyPath); var dependencyDirectories = new List <string> { Path.GetDirectoryName(options.AssemblyPath) }; if (options.DependencyDirectories != null) { dependencyDirectories.AddRange(options.DependencyDirectories); } var assemblyWeaver = new AssemblyWeaver(options.AssemblyPath, dependencyDirectories); var assemblyResolver = new AssemblyResolver(readonlyAssemblyPath, dependencyDirectories); var definitionProvider = new DefinitionProvider(assemblyWeaver.AssemblyDefinition); if (options.ShouldEnableLogging) { SetupExceptionLogger(assemblyWeaver, assemblyResolver, definitionProvider.MethodDefinitions); } if (options.ShouldEnableProfiler) { SetupPerformanceProfiler(assemblyWeaver, assemblyResolver, definitionProvider.MethodDefinitions); } assemblyWeaver.Reweave(); }
static AssemblyWeaver() { Instance = new AssemblyWeaver(); }
public AssemblyWithAttributeOnAssemblyTests() { beforeAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithAttributeOnAssembly\bin\Debug\AssemblyWithAttributeOnAssembly.dll"); assemblyWeaver = new AssemblyWeaver(beforeAssemblyPath); }
public AssemblyWithAttributeOnModuleTests() { var assemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithAttributeOnModule\bin\Debug\AssemblyWithAttributeOnModule.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }
public AssemblyWithAttributeOnModuleTests() { beforeAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithAttributeOnModule\bin\Debug\AssemblyWithAttributeOnModule.dll"); assemblyWeaver = new AssemblyWeaver(beforeAssemblyPath); }
public WithoutInterceptorTests() { var assemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithoutInterceptor\bin\Debug\AssemblyWithoutInterceptor.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }
public WithoutInterceptorTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyWithoutInterceptor\bin\Debug\AssemblyWithoutInterceptor.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }
public AssemblyWithAttributeOnAssemblyTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyWithAttributeOnAssembly\bin\Debug\AssemblyWithAttributeOnAssembly.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }
public void Foo() { var assemblyPath = Path.GetFullPath(@"C:\Code\Nancy\src\Nancy\obj\Debug\Nancy.dll"); var assemblyWeaver = new AssemblyWeaver(assemblyPath); Verifier.Verify(assemblyWeaver.Assembly.CodeBase.Remove(0, 8)); }
public WithoutInterceptorTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\DebugWithoutInterceptor\AssemblyToProcess.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }
public AssemblyWithAttributeOnModuleTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyWithAttributeOnModule\bin\Debug\AssemblyWithAttributeOnModule.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }
public AssemblyWithAttributeOnAssemblyTests() { var assemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithAttributeOnAssembly\bin\Debug\AssemblyWithAttributeOnAssembly.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }
public WithNopInterceptorTests() { var assemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithNopInterceptor\bin\Debug\AssemblyWithNopInterceptor.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }
public AssemblyWithAttributeOnModuleTests() { var assemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\DebugWithAttributeOnModule\AssemblyWithAttributeOnModule.dll"); assemblyWeaver = new AssemblyWeaver(assemblyPath); }