diff --git a/ICSharpCode.Decompiler/DecompilerSettings.cs b/ICSharpCode.Decompiler/DecompilerSettings.cs index e0da5f5ceb..1032093b39 100644 --- a/ICSharpCode.Decompiler/DecompilerSettings.cs +++ b/ICSharpCode.Decompiler/DecompilerSettings.cs @@ -1959,6 +1959,21 @@ public bool ApplyWindowsRuntimeProjections { } } + bool autoLoadAssemblyReferences = true; + + [Category("DecompilerSettings.Other")] + [Description("DecompilerSettings.AutoLoadAssemblyReferences")] + public bool AutoLoadAssemblyReferences { + get { return autoLoadAssemblyReferences; } + set { + if (autoLoadAssemblyReferences != value) + { + autoLoadAssemblyReferences = value; + OnPropertyChanged(); + } + } + } + #endregion bool forStatement = true; diff --git a/ILSpy/Commands/GeneratePdbContextMenuEntry.cs b/ILSpy/Commands/GeneratePdbContextMenuEntry.cs index 84bafc4239..64e8acfeff 100644 --- a/ILSpy/Commands/GeneratePdbContextMenuEntry.cs +++ b/ILSpy/Commands/GeneratePdbContextMenuEntry.cs @@ -80,7 +80,7 @@ internal static void GeneratePdbForAssembly(LoadedAssembly assembly) { try { - var decompiler = new CSharpDecompiler(file, assembly.GetAssemblyResolver(), options.DecompilerSettings); + var decompiler = new CSharpDecompiler(file, assembly.GetAssemblyResolver(options.DecompilerSettings.AutoLoadAssemblyReferences), options.DecompilerSettings); decompiler.CancellationToken = ct; PortablePdbWriter.WritePdb(file, decompiler, options.DecompilerSettings, stream, progress: options.Progress); } diff --git a/ILSpy/Languages/CSharpLanguage.cs b/ILSpy/Languages/CSharpLanguage.cs index b098c8c4ad..fbf2a1ce0e 100644 --- a/ILSpy/Languages/CSharpLanguage.cs +++ b/ILSpy/Languages/CSharpLanguage.cs @@ -122,7 +122,7 @@ public override IReadOnlyList LanguageVersions { CSharpDecompiler CreateDecompiler(PEFile module, DecompilationOptions options) { - CSharpDecompiler decompiler = new CSharpDecompiler(module, module.GetAssemblyResolver(), options.DecompilerSettings); + CSharpDecompiler decompiler = new CSharpDecompiler(module, module.GetAssemblyResolver(options.DecompilerSettings.AutoLoadAssemblyReferences), options.DecompilerSettings); decompiler.CancellationToken = options.CancellationToken; decompiler.DebugInfoProvider = module.GetDebugInfoOrNull(); while (decompiler.AstTransforms.Count > transformCount) @@ -416,7 +416,7 @@ public override ProjectId DecompileAssembly(LoadedAssembly assembly, ITextOutput base.DecompileAssembly(assembly, output, options); // don't automatically load additional assemblies when an assembly node is selected in the tree view - IAssemblyResolver assemblyResolver = assembly.GetAssemblyResolver(loadOnDemand: options.FullDecompilation); + IAssemblyResolver assemblyResolver = assembly.GetAssemblyResolver(loadOnDemand: options.FullDecompilation && options.DecompilerSettings.AutoLoadAssemblyReferences); var typeSystem = new DecompilerTypeSystem(module, assemblyResolver, options.DecompilerSettings); var globalType = typeSystem.MainModule.TypeDefinitions.FirstOrDefault(); if (globalType != null) @@ -507,7 +507,7 @@ class ILSpyWholeProjectDecompiler : WholeProjectDecompiler readonly DecompilationOptions options; public ILSpyWholeProjectDecompiler(LoadedAssembly assembly, DecompilationOptions options) - : base(options.DecompilerSettings, assembly.GetAssemblyResolver(), assembly.GetAssemblyReferenceClassifier(options.DecompilerSettings.ApplyWindowsRuntimeProjections), assembly.GetDebugInfoOrNull()) + : base(options.DecompilerSettings, assembly.GetAssemblyResolver(options.DecompilerSettings.AutoLoadAssemblyReferences, options.DecompilerSettings.ApplyWindowsRuntimeProjections), assembly.GetAssemblyReferenceClassifier(options.DecompilerSettings.ApplyWindowsRuntimeProjections), assembly.GetDebugInfoOrNull()) { this.assembly = assembly; this.options = options; diff --git a/ILSpy/Properties/Resources.Designer.cs b/ILSpy/Properties/Resources.Designer.cs index 07d6d8832b..1866a7b293 100644 --- a/ILSpy/Properties/Resources.Designer.cs +++ b/ILSpy/Properties/Resources.Designer.cs @@ -774,6 +774,15 @@ public static string DecompilerSettings_AsyncEnumerator { } } + /// + /// Looks up a localized string similar to Automatically load assembly references. + /// + public static string DecompilerSettings_AutoLoadAssemblyReferences { + get { + return ResourceManager.GetString("DecompilerSettings.AutoLoadAssemblyReferences", resourceCulture); + } + } + /// /// Looks up a localized string similar to User-defined checked operators. /// diff --git a/ILSpy/Properties/Resources.resx b/ILSpy/Properties/Resources.resx index e7bc5c4e7a..cc08fca35e 100644 --- a/ILSpy/Properties/Resources.resx +++ b/ILSpy/Properties/Resources.resx @@ -282,6 +282,9 @@ Are you sure you want to continue? Decompile async IAsyncEnumerator methods + + Automatically load assembly references + User-defined checked operators diff --git a/ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs b/ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs index d2a5b138fa..ad003ffcc8 100644 --- a/ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs @@ -75,7 +75,7 @@ public override void ActivateItem(System.Windows.RoutedEventArgs e) protected override void LoadChildren() { - var resolver = parentAssembly.LoadedAssembly.GetAssemblyResolver(); + var resolver = parentAssembly.LoadedAssembly.GetAssemblyResolver(MainWindow.Instance.CurrentDecompilerSettings.AutoLoadAssemblyReferences); var module = resolver.Resolve(r); if (module != null) {