예제 #1
0
        IEnumerable <ScriptCompilerBase.ResponseFileData> ParseResponseFileData(MonoIsland island)
        {
            var systemReferenceDirectories = CSharpLanguage.GetCSharpCompiler(island._target, true, "Assembly-CSharp") == CSharpCompiler.Microsoft &&
                                             PlayerSettings.GetScriptingBackend(BuildPipeline.GetBuildTargetGroup(island._target)) == ScriptingImplementation.WinRTDotNET && !island._editor
                ? MicrosoftCSharpCompiler.GetClassLibraries(island._target, island._editor)
                : MonoLibraryHelpers.GetSystemReferenceDirectories(island._api_compatibility_level);

            Dictionary <string, ScriptCompilerBase.ResponseFileData> responseFilesData = island._responseFiles.ToDictionary(x => x, x => ScriptCompilerBase.ParseResponseFileFromFile(
                                                                                                                                Path.Combine(_projectDirectory, x),
                                                                                                                                _projectDirectory,
                                                                                                                                systemReferenceDirectories
                                                                                                                                ));

            Dictionary <string, ScriptCompilerBase.ResponseFileData> responseFilesWithErrors = responseFilesData.Where(x => x.Value.Errors.Any())
                                                                                               .ToDictionary(x => x.Key, x => x.Value);

            if (responseFilesWithErrors.Any())
            {
                foreach (var error in responseFilesWithErrors)
                {
                    foreach (var valueError in error.Value.Errors)
                    {
                        UnityEngine.Debug.LogErrorFormat("{0} Parse Error : {1}", error.Key, valueError);
                    }
                }
            }

            return(responseFilesData.Select(x => x.Value));
        }
예제 #2
0
 public void Setup()
 {
     assemblyList           = new AssemblyList();
     testAssembly           = assemblyList.OpenAssembly(typeof(MethodUsesAnalyzerTests).Assembly.Location);
     testAssemblyTypeSystem = new DecompilerTypeSystem(testAssembly.GetPEFileOrNull(), testAssembly.GetAssemblyResolver());
     language = new CSharpLanguage();
 }
예제 #3
0
        public static dynamic FormatCode(SourceInfo sourceInfo)
        {
            var assemblies = new[]
            {
                Assembly.Load("Microsoft.CodeAnalysis"),
                Assembly.Load("Microsoft.CodeAnalysis.CSharp"),
                Assembly.Load("Microsoft.CodeAnalysis.Features"),
                Assembly.Load("Microsoft.CodeAnalysis.CSharp.Features"),
            };

            var partTypes = MefHostServices.DefaultAssemblies.Concat(assemblies)
                            .Distinct()
                            .SelectMany(x => x.GetTypes())
                            .ToArray();

            var compositionContext = new ContainerConfiguration()
                                     .WithParts(partTypes)
                                     .CreateContainer();

            var host = MefHostServices.Create(compositionContext);

            var workspace      = new AdhocWorkspace(host);
            var sourceLanguage = new CSharpLanguage();

            SyntaxTree syntaxTree = sourceLanguage.ParseText(sourceInfo.SourceCode, SourceCodeKind.Script);
            var        root       = (CompilationUnitSyntax)syntaxTree.GetRoot();

            return(Formatter.Format(root, workspace).ToFullString());
        }
예제 #4
0
 public static AssemblyTypeInfoGenerator.ClassInfo[] ExtractAssemblyTypeInfo(BuildTarget targetPlatform, bool isEditor, string assemblyPathName, string[] searchDirs)
 {
     if (CSharpLanguage.GetUseMicrosoftCSharpCompiler(targetPlatform, isEditor, assemblyPathName))
     {
         WSASDK wSASDK = EditorUserBuildSettings.wsaSDK;
         if (wSASDK == WSASDK.UniversalSDK81)
         {
             wSASDK = WSASDK.SDK81;
         }
         string nETCoreFrameworkReferencesDirectory = MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(wSASDK);
         searchDirs = new List <string>(searchDirs)
         {
             nETCoreFrameworkReferencesDirectory
         }.ToArray();
     }
     AssemblyTypeInfoGenerator.ClassInfo[] result;
     try
     {
         AssemblyTypeInfoGenerator assemblyTypeInfoGenerator = new AssemblyTypeInfoGenerator(assemblyPathName, searchDirs);
         result = assemblyTypeInfoGenerator.GatherClassInfo();
     }
     catch (Exception ex)
     {
         throw new Exception(string.Concat(new object[]
         {
             "ExtractAssemblyTypeInfo: Failed to process ",
             assemblyPathName,
             ", ",
             ex
         }));
     }
     return(result);
 }
예제 #5
0
        void DecompilePartial(DecompilePartialType info)
        {
            var builder = CreateAstBuilder(info.Context, CSharpLanguage.CreateDecompilerSettings(langSettings.Settings, info.UseUsingDeclarations), currentType: info.Type);

            builder.AddType(info.Type);
            RunTransformsAndGenerateCode(builder, info.Output, info.Context, new DecompilePartialTransform(info.Type, info.Definitions, info.ShowDefinitions, info.AddPartialKeyword, info.InterfacesToRemove));
        }
예제 #6
0
        private void ExecuteSearchDuplicates(CodeAnalyzerParameters parameters)
        {
            if (!Directory.Exists(_workingFolder))
            {
                Directory.CreateDirectory(_workingFolder);
            }
            int svnRevision             = GetCurrentSvnRevision(parameters.Directory);
            var language                = new CSharpLanguage();
            var fileContents            = GetFolderContents(parameters.Directory, parameters.SearchFilter, language.PreliminaryProcess);
            var duplicateFindParameters = new DuplicateFindParameters(6, new CSharpLanguage());
            var filesCombiner           = new DuplicateFinder(fileContents, duplicateFindParameters);
            var result = filesCombiner.FindDuplicates();
            var folder = Path.Combine(_workingFolder, svnRevision.ToString());

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            if (!CommitsList.Contains(svnRevision.ToString()))
            {
                File.AppendAllText(CommitsFileName, svnRevision + "\n");
                CommitsList.Add(svnRevision.ToString());
            }
            var reportFileName = Path.Combine(folder, "duplicate.xml");

            File.WriteAllText(reportFileName, result.ToXml());

            var previousReport = Path.Combine(_workingFolder, GetPreviousSvnRevision().ToString(),
                                              "duplicate.xml");

            Console.WriteLine("Lines: " + result.Count);
            CreateHtmlReport(result);
        }
예제 #7
0
        static void Main(string[] args)
        {
            BaseAssemblyResolver.MonoCecilResolvePath = @"G:\Work\金茂重构\接口并行期分支\src\00-ERP站点\bin";
            var language = new CSharpLanguage();
            AvalonEditTextOutput textOutput = new AvalonEditTextOutput();
            var str = File.ReadAllText(@"options.json");
            DecompilationOptions decompilationOptions = Newtonsoft.Json.JsonConvert.DeserializeObject <DecompilationOptions>(str);
            ReaderParameters     parameters           = new ReaderParameters
            {
                ReadingMode = ReadingMode.Deferred,
                ReadSymbols = false,
            };
            var module = ModuleDefinition.ReadModule(@"G:\Work\金茂重构\接口并行期分支\src\00-ERP站点\bin\Mysoft.Cbxt.PayMng.dll", parameters);
            var types  = module.Types;

            foreach (var t in types)
            {
                if (t.FullName == "Mysoft.Cbxt.PayMng.AppInitializer")
                {
                    //language.DecompileType(t, textOutput, decompilationOptions);
                    //Console.WriteLine(textOutput.b.ToString());
                    var ms = t.Methods;
                    foreach (var m in ms)
                    {
                        Console.WriteLine($"Name:{m.Name}; IsVirtual:{m.IsVirtual}; Public:{m.IsPublic}");
                    }
                }
            }
            Console.Read();
        }
예제 #8
0
        /// <summary>
        /// 获取反编译的类信息
        /// </summary>
        public static AvalonEditTextOutput GetDecompilerTypeInfo(string dllPath, string modulePath, string typeFullName)
        {
            if (CacheDictDecompilerTypeInfo.ContainsKey(typeFullName))
            {
                return(CacheDictDecompilerTypeInfo[typeFullName]);
            }

            BaseAssemblyResolver.MonoCecilResolvePath = dllPath;
            AvalonEditTextOutput textOutput = new AvalonEditTextOutput();
            ReaderParameters     parameters = new ReaderParameters
            {
                ReadingMode = ReadingMode.Deferred,
                ReadSymbols = false,
            };
            var module = ModuleDefinition.ReadModule(modulePath, parameters);
            var types  = module.Types;

            foreach (var t in types)
            {
                if (t.FullName == typeFullName)
                {
                    CSharpLanguage.DecompileType(t, textOutput, DecompilationOptions);
                    break;
                }
            }

            module = null;
            CacheDictDecompilerTypeInfo.Add(typeFullName, textOutput);

            return(textOutput);
        }
예제 #9
0
        public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
        {
            if (options.FullDecompilation && options.SaveAsProjectDirectory != null)
            {
                HashSet <string> directories = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                var files = WriteCodeFilesInProject(assembly.ModuleDefinition, options, directories).ToList();
                files.AddRange(WriteResourceFilesInProject(assembly, options, directories));
                WriteProjectFile(new TextOutputWriter(output), files, assembly.ModuleDefinition);
            }
            else
            {
                base.DecompileAssembly(assembly, output, options);
                output.WriteLine();
                ModuleDefinition mainModule = assembly.ModuleDefinition;
                if (mainModule.Types.Count > 0)
                {
                    output.Write("// Global type: ");
                    output.WriteReference(mainModule.Types[0].FullName, mainModule.Types[0]);
                    output.WriteLine();
                }
                if (mainModule.EntryPoint != null)
                {
                    output.Write("' Entry point: ");
                    output.WriteReference(mainModule.EntryPoint.DeclaringType.FullName + "." + mainModule.EntryPoint.Name, mainModule.EntryPoint);
                    output.WriteLine();
                }
                WriteCommentLine(output, "Architecture: " + CSharpLanguage.GetPlatformDisplayName(mainModule));
                if ((mainModule.Attributes & ModuleAttributes.ILOnly) == 0)
                {
                    WriteCommentLine(output, "This assembly contains unmanaged code.");
                }
                switch (mainModule.Runtime)
                {
                case TargetRuntime.Net_1_0:
                    WriteCommentLine(output, "Runtime: .NET 1.0");
                    break;

                case TargetRuntime.Net_1_1:
                    WriteCommentLine(output, "Runtime: .NET 1.1");
                    break;

                case TargetRuntime.Net_2_0:
                    WriteCommentLine(output, "Runtime: .NET 2.0");
                    break;

                case TargetRuntime.Net_4_0:
                    WriteCommentLine(output, "Runtime: .NET 4.0");
                    break;
                }
                output.WriteLine();

                // don't automatically load additional assemblies when an assembly node is selected in the tree view
                using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) {
                    AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.ModuleDefinition);
                    codeDomBuilder.AddAssembly(assembly.ModuleDefinition, onlyAssemblyLevel: !options.FullDecompilation);
                    RunTransformsAndGenerateCode(codeDomBuilder, output, options, assembly.ModuleDefinition);
                }
            }
        }
예제 #10
0
        public static List <string> GetMethodParams(string scriptCode, int position, ILogger log = null)
        {
            //position = position - 2;
            List <string> overloads = new List <string>();
            var           meta      = AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES");

            string[] assembliesNames = meta.ToString().Split(';', StringSplitOptions.None);
            var      sourceLanguage  = new CSharpLanguage();
            //SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(scriptCode);
            SyntaxTree syntaxTree   = sourceLanguage.ParseText(scriptCode, SourceCodeKind.Script);
            var        root         = (CompilationUnitSyntax)syntaxTree.GetRoot();
            var        thisAssembly = typeof(CompleteCode).Assembly;
            var        loadContext  = AssemblyLoadContext.GetLoadContext(thisAssembly);


            var Mscorlib    = MetadataReference.CreateFromFile(typeof(object).Assembly.Location);
            var compilation = CSharpCompilation.Create("MyCompilation",
                                                       syntaxTrees: new[] { syntaxTree }, references: CompileResources.PortableExecutableCompletionReferences);

            var model = compilation.GetSemanticModel(syntaxTree);

            var theToken = syntaxTree.GetRoot().FindToken(position);
            var theNode  = theToken.Parent;

            while (!theNode.IsKind(SyntaxKind.InvocationExpression))
            {
                theNode = theNode.Parent;
                if (theNode == null)
                {
                    break;                  // There isn't an InvocationExpression in this branch of the tree
                }
            }

            if (theNode == null)
            {
                overloads = null;
            }
            else
            {
                var symbolInfo     = model.GetSymbolInfo(theNode);
                var symbol         = symbolInfo.Symbol;
                var containingType = symbol?.ContainingType;

                if (symbolInfo.CandidateSymbols != default && symbolInfo.CandidateSymbols.Length > 0)
                {
                    foreach (var parameters in symbolInfo.CandidateSymbols)
                    {
                        var i = parameters.ToMinimalDisplayParts(model, position);
                        if (parameters.Kind == SymbolKind.Method)
                        {
                            var mp = parameters.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
                            overloads.Add(mp);
                        }
                    }
                }
            }
            return(overloads);
        }
예제 #11
0
        private Compilation GenerateCompilation(string assemblyName, params string[] files)
        {
            var sourceLanguage = new CSharpLanguage();
            var syntaxTrees    = files.Select(s => sourceLanguage.ParseText(_fileUtil.FileReadAllText(s), SourceCodeKind.Regular));

            return(sourceLanguage
                   .CreateLibraryCompilation(assemblyName: assemblyName, enableOptimisations: false)
                   .AddSyntaxTrees(syntaxTrees.ToArray()));
        }
예제 #12
0
 public void Setup()
 {
     Stub.SetupApplication();
     Options.DecompilerSettingsPanel.TestSetup(new Decompiler.DecompilerSettings());
     assemblyList           = new AssemblyList("Test");
     testAssembly           = assemblyList.OpenAssembly(typeof(MethodUsesAnalyzerTests).Assembly.Location);
     testAssemblyTypeSystem = new SimpleCompilation(testAssembly.GetPEFileOrNull(), assemblyList.OpenAssembly(typeof(void).Assembly.Location).GetPEFileOrNull());
     language = new CSharpLanguage();
 }
예제 #13
0
 public void Setup()
 {
     assemblyList = new AssemblyList();
     testAssembly = assemblyList.OpenAssembly(typeof(MethodUsesAnalyzerTests).Assembly.Location);
     assemblyList.OpenAssembly(typeof(void).Assembly.Location);
     testAssemblyTypeSystem = testAssembly.GetTypeSystemOrNull();
     language       = new CSharpLanguage();
     typeDefinition = testAssemblyTypeSystem.FindType(typeof(TestCases.Main.MainAssembly)).GetDefinition();
 }
예제 #14
0
        public string Decompile(object @object)
        {
            if (@object == null)
            {
                return(String.Empty);
            }
            Language l = new CSharpLanguage();

            ITextOutput output  = new RtfTextOutput();
            var         options = new DecompilationOptions();

            if (@object is AssemblyDefinition)
            {
                l.DecompileAssembly((AssemblyDefinition)@object, output, options);
            }
            else if (@object is TypeDefinition)
            {
                l.DecompileType((TypeDefinition)@object, output, options);
            }
            else if (@object is MethodDefinition)
            {
                l.DecompileMethod((MethodDefinition)@object, output, options);
            }
            else if (@object is FieldDefinition)
            {
                l.DecompileField((FieldDefinition)@object, output, options);
            }
            else if (@object is PropertyDefinition)
            {
                l.DecompileProperty((PropertyDefinition)@object, output, options);
            }
            else if (@object is EventDefinition)
            {
                l.DecompileEvent((EventDefinition)@object, output, options);
            }
            else if (@object is AssemblyNameReference)
            {
                output.Write("// Assembly Reference ");
                output.WriteDefinition(@object.ToString(), null);
                output.WriteLine();
            }
            else if (@object is ModuleReference)
            {
                output.Write("// Module Reference ");
                output.WriteDefinition(@object.ToString(), null);
                output.WriteLine();
            }
            else
            {
                output.Write(String.Format("// {0} ", @object.GetType().Name));
                output.WriteDefinition(@object.ToString(), null);
                output.WriteLine();
            }

            return(output.ToString());
        }
예제 #15
0
        private void SetupDecompilerAndOriginalSource(MethodDefinition method)
        {
            _cSharpDecompiler = new CSharpLanguage();
            var decompilationOutput = new PlainTextOutput();

            _decompilationOptions = new DecompilationOptions();
            _cSharpDecompiler.DecompileMethod(method, decompilationOutput, _decompilationOptions);
            _oldText = decompilationOutput.ToString();
            _differ  = new SideBySideDiffBuilder(new Differ());
        }
예제 #16
0
 public void Setup()
 {
     Stub.SetupApplication();
     Options.DecompilerSettingsPanel.TestSetup(new Decompiler.DecompilerSettings());
     assemblyList = new AssemblyList("Test");
     testAssembly = assemblyList.OpenAssembly(typeof(MethodUsesAnalyzerTests).Assembly.Location);
     assemblyList.OpenAssembly(typeof(void).Assembly.Location);
     testAssemblyTypeSystem = testAssembly.GetTypeSystemOrNull();
     language       = new CSharpLanguage();
     typeDefinition = testAssemblyTypeSystem.FindType(typeof(TestCases.Main.MainAssembly)).GetDefinition();
 }
        /// <summary>
        /// Writes an implementation of the <see cref="IDataSourceWrapper"/> interface.
        /// </summary>
        /// <param name="dataSourceWrapperInfo">A <see cref="DataSourceWrapperInfo"/> describing the data source wrapper for which to write an <see cref="IDataSourceWrapper"/> implementation.</param>
        public void WriteIDataSourceWrapperImplementation(DataSourceWrapperInfo dataSourceWrapperInfo)
        {
            WriteLine("public override Object WrappedDataSource");
            WriteLine("{");

            WriteLine("get { return value; }");

            WriteLine("}");

            WriteLine("private readonly {0} value;", CSharpLanguage.GetCSharpTypeName(dataSourceWrapperInfo.DataSourceType));
        }
예제 #18
0
        public void CorporaterMainAreEqual()
        {
            ILanguage  language    = new CSharpLanguage();
            Programmer programmer  = new Corporater(language);
            string     constResult = string.Format("Работа:{0}{1}Оплата{2}{1}", programmer.DoWork(), Environment.NewLine, programmer.EarnMoney());
            string     result;

            result = B_Example.Instance.Main(false, language);

            Assert.AreEqual(constResult, result);
        }
        /// <summary>
        /// Writes a constructor for the specified data source wrapper.
        /// </summary>
        /// <param name="dataSourceWrapperInfo">A <see cref="DataSourceWrapperInfo"/> describing the data source for which to write a constructor.</param>
        public void WriteConstructor(DataSourceWrapperInfo dataSourceWrapperInfo)
        {
            WriteLine("public {0}({1} dataSource, {2} namescope) : base(namescope)", dataSourceWrapperInfo.DataSourceWrapperName,
                      CSharpLanguage.GetCSharpTypeName(dataSourceWrapperInfo.DataSourceType),
                      CSharpLanguage.GetCSharpTypeName(typeof(Namescope)));
            WriteLine("{");

            WriteLine("this.value = dataSource;");

            WriteLine("}");
        }
예제 #20
0
        public void PreliminaryProcess_SecondTypeCommentsMultilineTest()
        {
            var input = new List <string> {
                "abc/*comment", "some nice text", "some another text", "bla-bla*/def/*comm*/gh"
            };
            var expected = new List <string> {
                "abc", "", "", "defgh"
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
예제 #21
0
        public void PreliminaryProcess_AssembleOperators_2Lines()
        {
            var input = new List <string> {
                "abcde", "fghij;"
            };
            var expected = new List <string> {
                "abcde fghij;", ""
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
예제 #22
0
        public void PreliminaryProcess_AssembleOperators_ManyLinesBrackets()
        {
            var input = new List <string> {
                "aaa;", "abcde", "fghij", "klmno", "pqrst", "{"
            };
            var expected = new List <string> {
                "aaa;", "abcde fghij klmno pqrst", "", "", "", "{"
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
예제 #23
0
        public void PreliminaryProcess_Trim()
        {
            var input = new List <string> {
                "    \tabcde\t\t", " abc      "
            };
            var expected = new List <string> {
                "abcde", "abc"
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
        private static void GetMethodDecompiledCSharpCode(PlainTextOutput textOutput, MethodDefinition method)
        {
            DecompilerSettings decompilerSettings = new DecompilerSettings {
                UsingDeclarations    = false,
                UsingStatement       = false,
                ShowXmlDocumentation = false,
            };

            CSharpLanguage language = new CSharpLanguage();

            language.DecompileMethod(method, textOutput, decompilerSettings);
        }
예제 #25
0
        public void PreliminaryProcess_AssembleOperators_TwoAssembles()
        {
            var input = new List <string> {
                "aaa", "bbb;", "ccc", "ddd;"
            };
            var expected = new List <string> {
                "aaa bbb;", "", "ccc ddd;", ""
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
예제 #26
0
        public void PreliminaryProcess_Using()
        {
            var input = new List <string> {
                "using aab;", "usingAbb"
            };
            var expected = new List <string> {
                "", "usingAbb"
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
예제 #27
0
        public void PreliminaryProcess_Region()
        {
            var input = new List <string> {
                "#region abcde", "#regionion"
            };
            var expected = new List <string> {
                "", "#regionion"
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
예제 #28
0
        public void PreliminaryProcess_DoubleSpaces()
        {
            var input = new List <string> {
                "abc\t\td      e", "a   b   c\"   \""
            };
            var expected = new List <string> {
                "abc d e", "a b c\"   \""
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
예제 #29
0
        public void PreliminaryProcess_FirstTypeCommentsTest()
        {
            var input = new List <string> {
                "abcde", "abc//line comment", "\"//\"//line comment"
            };
            var expected = new List <string> {
                "abcde", "abc", "\"//\""
            };
            var result = new CSharpLanguage().PreliminaryProcess(input);

            CollectionAssert.AreEqual(expected, result);
        }
예제 #30
0
파일: VBLanguage.cs 프로젝트: danysu/dnSpy
        public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options, DecompileAssemblyFlags flags = DecompileAssemblyFlags.AssemblyAndModule)
        {
            if (options.FullDecompilation && options.SaveAsProjectDirectory != null)
            {
                HashSet <string> directories = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                var files = WriteCodeFilesInProject(assembly.ModuleDefinition, options, directories).ToList();
                files.AddRange(WriteResourceFilesInProject(assembly, options, directories));
                WriteProjectFile(new TextOutputWriter(output), files, assembly, options);
            }
            else
            {
                bool decompileAsm = (flags & DecompileAssemblyFlags.Assembly) != 0;
                bool decompileMod = (flags & DecompileAssemblyFlags.Module) != 0;
                base.DecompileAssembly(assembly, output, options, flags);
                output.WriteLine();
                ModuleDef mainModule = assembly.ModuleDefinition;
                if (decompileMod && mainModule.Types.Count > 0)
                {
                    output.Write("' Global type: ", TextTokenType.Comment);
                    output.WriteReference(IdentifierEscaper.Escape(mainModule.GlobalType.FullName), mainModule.GlobalType, TextTokenType.Comment);
                    output.WriteLine();
                }
                if (decompileMod || decompileAsm)
                {
                    PrintEntryPoint(assembly, output);
                }
                if (decompileMod)
                {
                    WriteCommentLine(output, "Architecture: " + CSharpLanguage.GetPlatformDisplayName(mainModule));
                    if (!mainModule.IsILOnly)
                    {
                        WriteCommentLine(output, "This assembly contains unmanaged code.");
                    }
                    string runtimeName = ICSharpCode.ILSpy.CSharpLanguage.GetRuntimeDisplayName(mainModule);
                    if (runtimeName != null)
                    {
                        WriteCommentLine(output, "Runtime: " + runtimeName);
                    }
                }
                if (decompileMod || decompileAsm)
                {
                    output.WriteLine();
                }

                // don't automatically load additional assemblies when an assembly node is selected in the tree view
                using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) {
                    AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.ModuleDefinition);
                    codeDomBuilder.AddAssembly(assembly.ModuleDefinition, !options.FullDecompilation, decompileAsm, decompileMod);
                    RunTransformsAndGenerateCode(codeDomBuilder, output, options, assembly.ModuleDefinition);
                }
            }
        }