Exemplo n.º 1
0
        public override ILPostProcessResult Process(ICompiledAssembly compiledAssembly)
        {
            bool   willProcess = WillProcess(compiledAssembly);
            string logText     = willProcess ? "Processing" : "Skipping";

            Log($"{logText} {compiledAssembly.Name}");
            if (!willProcess)
            {
                return(null);
            }

            var logger = new WeaverLogger();
            var weaver = new Weaver(logger);

            var assemblyDefinition = weaver.Weave(compiledAssembly);

            // write
            var pe  = new MemoryStream();
            var pdb = new MemoryStream();

            var writerParameters = new WriterParameters
            {
                SymbolWriterProvider = new PortablePdbWriterProvider(),
                SymbolStream         = pdb,
                WriteSymbols         = true
            };

            assemblyDefinition?.Write(pe, writerParameters);

            logText = assemblyDefinition != null ? "Success" : "Failed";
            Log($"{logText} {compiledAssembly.Name}");
            return(new ILPostProcessResult(new InMemoryAssembly(pe.ToArray(), pdb.ToArray()), logger.Diagnostics));
        }
Exemplo n.º 2
0
        public override ILPostProcessResult Process(ICompiledAssembly compiledAssembly)
        {
            if (!WillProcess(compiledAssembly))
            {
                return(null);
            }

            var logger = new WeaverLogger();
            var weaver = new Weaver(logger);

            AssemblyDefinition assemblyDefinition = weaver.Weave(compiledAssembly);

            // write
            var pe  = new MemoryStream();
            var pdb = new MemoryStream();

            var writerParameters = new WriterParameters
            {
                SymbolWriterProvider = new PortablePdbWriterProvider(),
                SymbolStream         = pdb,
                WriteSymbols         = true
            };

            assemblyDefinition?.Write(pe, writerParameters);

            return(new ILPostProcessResult(new InMemoryAssembly(pe.ToArray(), pdb.ToArray()), logger.Diagnostics));
        }