Пример #1
0
        public void SingleMethod()
        {
            var assemblyPath = FixtureHelper.IsolateAssembly <StandardAssemblyToProcessReference>();
            var type         = typeof(MethodRefTestCases);
            var methodName   = nameof(MethodRefTestCases.ReturnMethodHandle);

            using var module = ModuleDefinition.ReadModule(assemblyPath);
            var weavingContext = new ModuleWeavingContext(module, new WeaverConfig(null, module));

            var typeDef   = module.GetTypes().Single(i => i.FullName == type.FullName);
            var methodDef = typeDef.Methods.Single(i => i.Name == methodName);

            new MethodWeaver(weavingContext, methodDef).Process();
        }
        static InvalidAssemblyToProcessFixture()
        {
            var weavingTask = new ModuleWeaver();

            TestResult = weavingTask.ExecuteTestRun(
                FixtureHelper.IsolateAssembly <InvalidAssemblyToProcessReference>(),
                false,
                beforeExecuteCallback: AssemblyToProcessFixture.BeforeExecuteCallback
                );

            using var assemblyResolver = new TestAssemblyResolver();

            ResultModule = ModuleDefinition.ReadModule(TestResult.AssemblyPath, new ReaderParameters(ReadingMode.Immediate)
            {
                AssemblyResolver = assemblyResolver
            });
        }