Exemplo n.º 1
0
    void RoundTripMutableCopyAndAddGenericParameter2(string assemblyName)
    {
        PeVerifyResult expectedResult = PeVerify.VerifyAssembly(assemblyName);
        IAssembly      assembly       = LoadAssembly(assemblyName);
        var            copier1        = new MetadataDeepCopier(host);
        var            codeAssembly   = copier1.Copy(assembly);

        for (int i = 0; i < 30; i++)
        {
            AddGenericParameters adder = new AddGenericParameters(host, codeAssembly.AllTypes, i);
            codeAssembly = (Assembly)adder.Rewrite(codeAssembly);
        }
        AssertWriteToPeFile(expectedResult, codeAssembly, null);
    }
Exemplo n.º 2
0
    void RoundTripAddGenericParameterNoCopyTestDecompilation(string assemblyName, string pdbName)
    {
        PeVerifyResult expectedResult = PeVerify.VerifyAssembly(assemblyName);
        IAssembly      assembly       = LoadAssembly(assemblyName);

        using (var f = File.OpenRead(pdbName)) {
            using (var pdbReader = new PdbReader(f, host)) {
                var codeAssembly           = Decompiler.GetCodeModelFromMetadataModel(this.host, assembly, pdbReader);
                AddGenericParameters adder = new AddGenericParameters(host, codeAssembly.AllTypes, 0);
                codeAssembly = (Assembly)adder.Rewrite(codeAssembly);
                Checker checker = new Checker(this.host);
                checker.Traverse(codeAssembly);
                Debug.Assert(checker.Errors.Count == 0);
                AssertWriteToPeFile(expectedResult, codeAssembly, pdbReader);
            }
        }
    }