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


C# Module.LoadDebugInformation方法代码示例

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


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

示例1: DoMutate_Returns_Correct_Sequences

        public void DoMutate_Returns_Correct_Sequences()
        {
            var module = new Module(Assembly.GetExecutingAssembly().Location);
            module.LoadDebugInformation();
            var method = module.Definition
                .Types.Single(t => t.Name == "VariableReadClassUnderTest")
                .Methods.Single(t => t.Name == "AddAndDouble");

            var mutatedInstruction = method.Body.Instructions.First(i => i.OpCode == OpCodes.Ldarg_1);
            string hexPrefix = string.Format("{0:x4}: ", mutatedInstruction.Offset);

            var mutator = new VariableReadTurtle();
            IList<MutantMetaData> mutations = mutator
                .Mutate(method, module, method.Body.Instructions.Select(i => i.Offset).ToArray()).ToList();

            // V2 is only read for the return statement; this case is excluded in the code.
            Assert.AreEqual(9, mutations.Count);
            StringAssert.EndsWith(hexPrefix + "read substitution Int32.a => Int32.b", mutations[0].Description);
            StringAssert.EndsWith("read substitution Int32.a => Int32.total", mutations[1].Description);
            StringAssert.EndsWith("read substitution Int32.a => Int32.CS$1$0000", mutations[2].Description);
            StringAssert.EndsWith("read substitution Int32.b => Int32.a", mutations[3].Description);
            StringAssert.EndsWith("read substitution Int32.b => Int32.total", mutations[4].Description);
            StringAssert.EndsWith("read substitution Int32.b => Int32.CS$1$0000", mutations[5].Description);
            StringAssert.EndsWith("read substitution Int32.total => Int32.a", mutations[6].Description);
            StringAssert.EndsWith("read substitution Int32.total => Int32.b", mutations[7].Description);
            StringAssert.EndsWith("read substitution Int32.total => Int32.CS$1$0000", mutations[8].Description);
        }
开发者ID:dbremner,项目名称:ninjaturtles,代码行数:27,代码来源:VariableReadTurtleTests.cs

示例2: CreateMutant_Returns_Correct_Sequences

        public void CreateMutant_Returns_Correct_Sequences()
        {
            var module = new Module(Assembly.GetExecutingAssembly().Location);
            module.LoadDebugInformation();
            var method = module.Definition
                .Types.Single(t => t.Name == "SequencePointDeletionClassUnderTest")
                .Methods.Single(t => t.Name == "SimpleMethod");

            var mutator = new SequencePointDeletionTurtle();
            IList<MutantMetaData> mutations = mutator
                .Mutate(method, module, method.Body.Instructions.Select(i => i.Offset).ToArray()).ToList();

            Assert.AreEqual(3, mutations.Count);
            StringAssert.EndsWith("deleting Ldarg, Stloc", mutations[0].Description);
            StringAssert.EndsWith("deleting Ldloc, Ldarg, Ldarg, Mul, Add, Stloc", mutations[1].Description);
            StringAssert.EndsWith("deleting Ldloc, Ldarg, Ldarg, Mul, Ldarg, Mul, Add, Stloc", mutations[2].Description);
        }
开发者ID:dbremner,项目名称:ninjaturtles,代码行数:17,代码来源:SequencePointDeletionTurtleTests.cs

示例3: DoMutate_Returns_Correct_Sequences_With_Fields

        public void DoMutate_Returns_Correct_Sequences_With_Fields()
        {
            var module = new Module(Assembly.GetExecutingAssembly().Location);
            module.LoadDebugInformation();
            var method = module.Definition
                .Types.Single(t => t.Name == "VariableWriteClassUnderTest")
                .Methods.Single(t => t.Name == "AddWithPointlessNonsenseViaFields");

            var mutator = new VariableWriteTurtle();
            IList<MutantMetaData> mutations = mutator
                .Mutate(method, module, method.Body.Instructions.Select(i => i.Offset).ToArray()).ToList();

            Assert.AreEqual(2, mutations.Count);
            StringAssert.EndsWith("write substitution Int32._pointlessA => Int32.CS$1$0000", mutations[0].Description);
            StringAssert.EndsWith("write substitution Int32._pointlessB => Int32.CS$1$0000", mutations[1].Description);
        }
开发者ID:dbremner,项目名称:ninjaturtles,代码行数:16,代码来源:VariableWriteTurtleTests.cs

示例4: DoMutate_Returns_No_Results_As_Appropriate

        public void DoMutate_Returns_No_Results_As_Appropriate()
        {
            var module = new Module(Assembly.GetExecutingAssembly().Location);
            module.LoadDebugInformation();
            var method = module.Definition
                .Types.Single(t => t.Name == "VariableWriteClassUnderTest")
                .Methods.Single(t => t.Name == "AddWithoutPointlessNonsense");

            var mutator = new VariableWriteTurtle();
            IList<MutantMetaData> mutations = mutator
                .Mutate(method, module, method.Body.Instructions.Select(i => i.Offset).ToArray()).ToList();

            Assert.AreEqual(0, mutations.Count);
        }
开发者ID:dbremner,项目名称:ninjaturtles,代码行数:14,代码来源:VariableWriteTurtleTests.cs

示例5: DoMutate_Skips_Writes_In_Dispose

        public void DoMutate_Skips_Writes_In_Dispose()
        {
            var assembly = CreateTestAssembly();

            string tempAssemblyFileName = GetTempAssemblyFileName();
            assembly.Write(tempAssemblyFileName);
            var module = new Module(tempAssemblyFileName);
            module.LoadDebugInformation();

            var method = module.Definition
                .Types.Single(t => t.Name == "TestClass")
                .Methods.Single(t => t.Name == "TestMethod");

            var mutator = new VariableWriteTurtle();
            IList<MutantMetaData> mutations = mutator
                .Mutate(method, module, method.Body.Instructions.Select(i => i.Offset).ToArray()).ToList();

            Assert.AreEqual(1, mutations.Count);
            string expectedMessage = string.Format(
                "{0:x4}: write substitution Int32. => Int32.",
                _mutatedInstruction.Offset);
            StringAssert.EndsWith(expectedMessage, mutations[0].Description);
        }
开发者ID:dbremner,项目名称:ninjaturtles,代码行数:23,代码来源:VariableWriteTurtleTests.cs


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