当前位置: 首页>>代码示例>>C#>>正文


C# ModuleWeaver.Execute方法代码示例

本文整理汇总了C#中ModuleWeaver.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleWeaver.Execute方法的具体用法?C# ModuleWeaver.Execute怎么用?C# ModuleWeaver.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModuleWeaver的用法示例。


在下文中一共展示了ModuleWeaver.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExistingTests

    public ExistingTests()
    {
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToProcessExistingAttribute\bin\Debug\AssemblyToProcessExistingAttribute.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif

        afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "2.dll");
        File.Copy(beforeAssemblyPath, afterAssemblyPath, true);

        var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath);
        var currentDirectory = AssemblyLocation.CurrentDirectory();
        var moduleWeaver = new ModuleWeaver
                           {
                               ModuleDefinition = moduleDefinition,
                               AddinDirectoryPath = currentDirectory,
                               SolutionDirectoryPath = currentDirectory,
                               AssemblyFilePath = afterAssemblyPath,
                           };

        moduleWeaver.Execute();
        moduleDefinition.Write(afterAssemblyPath);
        moduleWeaver.AfterWeaving();

        assembly = Assembly.LoadFile(afterAssemblyPath);
    }
开发者ID:Fody,项目名称:Stamp,代码行数:26,代码来源:ExistingTests.cs

示例2: WeaverHelper

    public WeaverHelper(string projectPath)
    {
        this.projectPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\TestAssemblies", projectPath));

        GetAssemblyPath();

        var newAssembly = assemblyPath.Replace(".dll", "2.dll");
        File.Copy(assemblyPath, newAssembly, true);

        var assemblyResolver = new TestAssemblyResolver(assemblyPath, this.projectPath);
        var moduleDefinition = ModuleDefinition.ReadModule(newAssembly, new ReaderParameters
                                                                            {
                                                                                AssemblyResolver = assemblyResolver
                                                                            });
        var weavingTask = new ModuleWeaver
                              {
                                  ModuleDefinition = moduleDefinition,
                                  AssemblyResolver = assemblyResolver
                              };

        weavingTask.Execute();

        moduleDefinition.Write(newAssembly);

        Assembly = Assembly.LoadFile(newAssembly);
    }
开发者ID:mdabbagh88,项目名称:PropertyChanging,代码行数:26,代码来源:WeaverHelper.cs

示例3: TaskTests

    public TaskTests()
    {
        beforeAssemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll");
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif

        afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "2.dll");
        File.Copy(beforeAssemblyPath, afterAssemblyPath, true);

        var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath);
        var currentDirectory = AssemblyLocation.CurrentDirectory();
        var weavingTask = new ModuleWeaver
                          {
                              ModuleDefinition = moduleDefinition,
                              AddinDirectoryPath = currentDirectory,
                              SolutionDirectoryPath = currentDirectory,
                              AssemblyFilePath = afterAssemblyPath,
                              SvnHelper = new MockSvnHelper(),
                          };

        weavingTask.Execute();
        moduleDefinition.Write(afterAssemblyPath);
        weavingTask.AfterWeaving();

        assembly = Assembly.LoadFile(afterAssemblyPath);
    }
开发者ID:krk,项目名称:Stamp,代码行数:27,代码来源:TaskTests.cs

示例4: WeaverHelper

    public WeaverHelper(string projectPath)
    {
        this.projectPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\TestAssemblies", projectPath));

        GetAssemblyPath();

        AfterAssemblyPath = BeforeAssemblyPath.Replace(".dll", "2.dll");
        File.Copy(BeforeAssemblyPath, AfterAssemblyPath, true);

        var assemblyResolver = new TestAssemblyResolver(BeforeAssemblyPath, this.projectPath);
        var readerParameters = new ReaderParameters
        {
            AssemblyResolver = assemblyResolver
        };
        var moduleDefinition = ModuleDefinition.ReadModule(AfterAssemblyPath, readerParameters);
        var weavingTask = new ModuleWeaver
                              {
                                  ModuleDefinition = moduleDefinition,
                                  AssemblyResolver = assemblyResolver
                              };

        weavingTask.Execute();

        moduleDefinition.Write(AfterAssemblyPath);

        Assembly = Assembly.LoadFile(AfterAssemblyPath);
    }
开发者ID:Fody,项目名称:PropertyChanged,代码行数:27,代码来源:WeaverHelper.cs

示例5: VerifyRefError

    public void VerifyRefError()
    {
        var errors = new List<string>();
        var assemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToProcessWithErrors\bin\Debug\AssemblyToProcessWithErrors.dll"));
        #if (!DEBUG)
        assemblyPath = assemblyPath.Replace("Debug", "Release");
        #endif

        var moduleDefinition = ModuleDefinition.ReadModule(assemblyPath, new ReaderParameters
                                                                         {
                                                                             //SymbolStream = symbolStream,
                                                                             ReadSymbols = true
                                                                         });

        var weavingTask = new ModuleWeaver
                          {
                              ModuleDefinition = moduleDefinition,
                              LogErrorPoint = (s, p) => errors.Add(s)
                          };

        weavingTask.Execute();
        Assert.Contains("Method 'ClassUsingOutParam.Method' uses member 'ClassWithField.Member' as a 'ref' or 'out' parameter. This is not supported by Fielder. Please convert this field to a property manually.", errors);
        Assert.Contains("Method 'ClassUsingRefParam.Method' uses member 'ClassWithField.Member' as a 'ref' or 'out' parameter. This is not supported by Fielder. Please convert this field to a property manually.", errors);
        Assert.AreEqual(2, errors.Count);
    }
开发者ID:Fody,项目名称:Fielder,代码行数:25,代码来源:CheckForErrors.cs

示例6: Setup

    public void Setup()
    {
        var projectPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\AssemblyToProcess\AssemblyToProcess.csproj"));
        assemblyPath = Path.Combine(Path.GetDirectoryName(projectPath), @"bin\Debug\AssemblyToProcess.dll");
#if (!DEBUG)
        assemblyPath = assemblyPath.Replace("Debug", "Release");
#endif

        newAssemblyPath = assemblyPath.Replace(".dll", "2.dll");
        shadowAssemblyPath = assemblyPath.Replace(".dll", "2shadow.dll");
        File.Copy(assemblyPath, newAssemblyPath, true);
        File.Copy(assemblyPath, shadowAssemblyPath, true);
        
        var moduleDefinition = ModuleDefinition.ReadModule(newAssemblyPath);
        var weavingTask = new ModuleWeaver
        {
            ModuleDefinition = moduleDefinition            
        };

        weavingTask.Execute();

        moduleDefinition.Write(newAssemblyPath);

        assembly = Assembly.LoadFile(newAssemblyPath);
    }
开发者ID:qkub,项目名称:ExpandoIntelligizer,代码行数:25,代码来源:WeaverTests.cs

示例7: VerifyAssembly

    public void VerifyAssembly(string assemblyPath)
    {

        Debug.WriteLine("Verifying " + assemblyPath);
        var cleanAssembly = assemblyPath.Replace(".dll", "2.dll");
        var newAssembly = assemblyPath.Replace(".dll", "3.dll");
        File.Copy(assemblyPath, cleanAssembly, true);
        File.Copy(assemblyPath, newAssembly, true);

        var assemblyResolver = new MockAssemblyResolver();
        var moduleDefinition = ModuleDefinition.ReadModule(cleanAssembly);
        var weavingTask = new ModuleWeaver
        {
            ModuleDefinition = moduleDefinition,
            AssemblyResolver = assemblyResolver,
        };
        moduleDefinition.Write(cleanAssembly);

        moduleDefinition = ModuleDefinition.ReadModule(newAssembly);
        weavingTask.ModuleDefinition = moduleDefinition;
        weavingTask.Execute();
        moduleDefinition.Write(newAssembly);

        Verifier.Verify(cleanAssembly, newAssembly);
    }
开发者ID:dpisanu,项目名称:NullGuard,代码行数:25,代码来源:LargeAssemblyTest.cs

示例8: ModuleWeaverOrdinalTests

    public ModuleWeaverOrdinalTests()
    {
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll"));
#if (!DEBUG)
       beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "3.dll");
        File.Copy(beforeAssemblyPath, afterAssemblyPath, true);

        var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath);

        var weavingTask = new ModuleWeaver
            {
                Config = XElement.Parse(@"<Caseless StringComparison="" ordinal ""/>"),
                ModuleDefinition = moduleDefinition,
            };

        weavingTask.Execute();
        moduleDefinition.Assembly.Name.Name += "ForOrdinal";
        moduleDefinition.Write(afterAssemblyPath);
        var assembly = Assembly.LoadFrom(afterAssemblyPath);
        var type = assembly.GetType("TargetClass", true);
        targetClass = Activator.CreateInstance(type);
    }
开发者ID:Fody,项目名称:Caseless,代码行数:27,代码来源:ModuleWeaverOrdinalTests.cs

示例9: Simple

    public void Simple()
    {
        var beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithExcludes\bin\Debug\AssemblyWithExcludes.dll"));
        #if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
        #endif

        var afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "2.dll");
        File.Copy(beforeAssemblyPath, afterAssemblyPath, true);

        var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath);
        var weavingTask = new ModuleWeaver
        {
            ModuleDefinition = moduleDefinition,
            ExcludeNamespaces = new List<string> { "ExcludeNamespace"}
        };

        weavingTask.Execute();
        moduleDefinition.Write(afterAssemblyPath);

        var assembly = Assembly.LoadFile(afterAssemblyPath);

        var excludeType = assembly.GetType("ExcludeNamespace.ExcludeClass");
        Assert.IsFalse(excludeType.GetMethod("Method").IsVirtual);
        var includeType = assembly.GetType("IncludeNamespace.IncludeClass");
        Assert.IsTrue(includeType.GetMethod("Method").IsVirtual);

        var inNamespaceButWithAttributeType = assembly.GetType("IncludeNamespace.InNamespaceButWithAttributeClass");
        Assert.IsFalse(inNamespaceButWithAttributeType.GetMethod("Method").IsVirtual);
        var notInNamespaceButWithAttributeType = assembly.GetType("ExcludeNamespace.NotInNamespaceButWithAttributeClass");
        Assert.IsFalse(notInNamespaceButWithAttributeType.GetMethod("Method").IsVirtual);
        #if(DEBUG)
        Verifier.Verify(beforeAssemblyPath, afterAssemblyPath);
        #endif
    }
开发者ID:Fody,项目名称:Virtuosity,代码行数:35,代码来源:AssemblyWithExcludesTest.cs

示例10: Weave

    public static string Weave(string assemblyPath)
    {
        var newAssembly = assemblyPath.Replace(".dll", "2.dll");
        var oldPdb = assemblyPath.Replace(".dll", ".pdb");
        var newPdb = assemblyPath.Replace(".dll", "2.pdb");
        File.Copy(assemblyPath, newAssembly, true);
        File.Copy(oldPdb, newPdb, true);

        var assemblyResolver = new MockAssemblyResolver
            {
                Directory = Path.GetDirectoryName(assemblyPath)
            };

        using (var symbolStream = File.OpenRead(newPdb))
        {
            var readerParameters = new ReaderParameters
                {
                    ReadSymbols = true,
                    SymbolStream = symbolStream,
                    SymbolReaderProvider = new PdbReaderProvider()
                };
            var moduleDefinition = ModuleDefinition.ReadModule(newAssembly, readerParameters);

            var weavingTask = new ModuleWeaver
                {
                    ModuleDefinition = moduleDefinition,
                    AssemblyResolver = assemblyResolver
                };

            weavingTask.Execute();
            moduleDefinition.Write(newAssembly);

            return newAssembly;
        }
    }
开发者ID:AndreGleichner,项目名称:Anotar,代码行数:35,代码来源:WeaverHelper.cs

示例11: WeaveAssembly

        public static Assembly WeaveAssembly()
        {
            string configurationName = "Release";

            #if DEBUG
                configurationName = "Debug";
            #endif

            string assemblyPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\AssemblyToProcess\bin", configurationName, "AssemblyToProcess.dll"));

            string newAssembly = assemblyPath.Replace(".dll", "2.dll");

            File.Copy(assemblyPath, newAssembly, true);

            ModuleDefinition moduleDefinition = ModuleDefinition.ReadModule(newAssembly);

            ModuleWeaver weavingTask = new ModuleWeaver
            {
                ModuleDefinition = moduleDefinition
            };

            weavingTask.Execute();

            moduleDefinition.Write(newAssembly);

            return Assembly.LoadFile(newAssembly);
        }
开发者ID:mdabbagh88,项目名称:RemoveReference.Fody,代码行数:27,代码来源:WeaverHelper.cs

示例12: AssemblyWeaver

    static AssemblyWeaver()
    {
        BeforeAssemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll");
        BeforeAssemblyPathSymbols = Path.ChangeExtension(BeforeAssemblyPath, "pdb");

        #if (!DEBUG)
        BeforeAssemblyPath = BeforeAssemblyPath.Replace("Debug", "Release");
        BeforeAssemblyPathSymbols = BeforeAssemblyPathSymbols.Replace("Debug", "Release");
        #endif
        AfterAssemblyPath = BeforeAssemblyPath.Replace(".dll", "2.dll");
        AfterAssemblyPathSymbols = Path.ChangeExtension(AfterAssemblyPath, "pdb");

        File.Copy(BeforeAssemblyPath, AfterAssemblyPath, true);
        File.Copy(BeforeAssemblyPathSymbols, AfterAssemblyPathSymbols, true);

        var assemblyResolver = new MockAssemblyResolver();
        var moduleDefinition = ModuleDefinition.ReadModule(AfterAssemblyPath, new ReaderParameters { ReadSymbols = true });

        var weavingTask = new ModuleWeaver
        {
            ModuleDefinition = moduleDefinition,
            AssemblyResolver = assemblyResolver,
            LogError = LogError,
            LogInfo = LogInfo,
            DefineConstants = new[] { "DEBUG" }, // Always testing the debug weaver
        };

        weavingTask.Execute();
        moduleDefinition.Write(AfterAssemblyPath, new WriterParameters { WriteSymbols = true });

        Assembly = Assembly.LoadFile(AfterAssemblyPath);
    }
开发者ID:RobertGiesecke,项目名称:Visualize,代码行数:32,代码来源:AssemblyWeaver.cs

示例13: ProcessAssemblyBaseTest

        protected ProcessAssemblyBaseTest( string relativePath )
        {
            BeforeAssemblyPath = Path.GetFullPath( relativePath );
            #if !DEBUG
            BeforeAssemblyPath = BeforeAssemblyPath.Replace("Debug", "Release");
            #endif

            AfterAssemblyPath = BeforeAssemblyPath.Replace( ".dll", "2.dll" );
            File.Copy( BeforeAssemblyPath, AfterAssemblyPath, true );

            var moduleDefinition = ModuleDefinition.ReadModule( AfterAssemblyPath );

            var currentDirectory = AssemblyLocation.CurrentDirectory();
            PersistentInfo = PersistentInfo.LoadFromPath( currentDirectory );
            StandardInfo = new StandardInfo( PersistentInfo, moduleDefinition );

            var moduleWeaver = new ModuleWeaver
            {
                ModuleDefinition = moduleDefinition,
                AddinDirectoryPath = currentDirectory,
                SolutionDirectoryPath = currentDirectory,
                AssemblyFilePath = AfterAssemblyPath,
            };

            moduleWeaver.Execute();
            moduleDefinition.Write( AfterAssemblyPath );
            moduleWeaver.AfterWeaving();

            AfterAssembly = Assembly.LoadFile( AfterAssemblyPath );
        }
开发者ID:ismailfatih,项目名称:CK-Stamp,代码行数:30,代码来源:ProcessAssemblyBaseTest.cs

示例14: IntegrationTests

    public IntegrationTests()
    {
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif

        afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "2.dll");
        File.Copy(beforeAssemblyPath, afterAssemblyPath, true);

        var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath);
        var weavingTask = new ModuleWeaver
        {
            ModuleDefinition = moduleDefinition,
            AssemblyResolver = new MockAssemblyResolver(),
            LogWarning = s => warnings.Add(s),
            LogError = s => errors.Add(s),
            HideObsoleteMembers = true
        };

        weavingTask.Execute();
        moduleDefinition.Write(afterAssemblyPath);

        assembly = Assembly.LoadFile(afterAssemblyPath);
    }
开发者ID:Fody,项目名称:Obsolete,代码行数:25,代码来源:IntegrationTests.cs

示例15: AssemblyWeaver

    public AssemblyWeaver(string assemblyPath, List<string> referenceAssemblyPaths = null)
    {
        if (referenceAssemblyPaths == null)
        {
            referenceAssemblyPaths  = new List<string>();
        }
        assemblyPath = FixAssemblyPath(assemblyPath);

        var newAssembly = assemblyPath.Replace(".dll", "2.dll");
        File.Copy(assemblyPath, newAssembly, true);

        var assemblyResolver = new MockAssemblyResolver();
        foreach (var referenceAssemblyPath in referenceAssemblyPaths)
        {
            var directoryName = Path.GetDirectoryName(referenceAssemblyPath);
            assemblyResolver.AddSearchDirectory(directoryName);
        }
        var readerParameters = new ReaderParameters
        {
            AssemblyResolver = assemblyResolver
        };
        var moduleDefinition = ModuleDefinition.ReadModule(newAssembly, readerParameters);
        var weavingTask = new ModuleWeaver
        {
            ModuleDefinition = moduleDefinition,
            AssemblyResolver = assemblyResolver,
            LogError = LogError,
            ReferenceCopyLocalPaths = referenceAssemblyPaths
        };

        weavingTask.Execute();
        moduleDefinition.Write(newAssembly);

        Assembly = Assembly.LoadFrom(newAssembly);
    }
开发者ID:GavinOsborn,项目名称:MethodTimer,代码行数:35,代码来源:AssemblyWeaver.cs


注:本文中的ModuleWeaver.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。