diff --git a/ILSpy.BamlDecompiler/BamlResourceEntryNode.cs b/ILSpy.BamlDecompiler/BamlResourceEntryNode.cs index 30444af81..dc93117cf 100644 --- a/ILSpy.BamlDecompiler/BamlResourceEntryNode.cs +++ b/ILSpy.BamlDecompiler/BamlResourceEntryNode.cs @@ -50,7 +50,7 @@ namespace ILSpy.BamlDecompiler { var asm = this.Ancestors().OfType().FirstOrDefault().LoadedAssembly; Data.Position = 0; - XDocument xamlDocument = LoadIntoDocument(asm.GetAssemblyResolver(), asm.AssemblyDefinition, Data, cancellationToken); + XDocument xamlDocument = LoadIntoDocument(asm.GetAssemblyResolver(), asm.GetAssemblyDefinitionAsync().Result, Data, cancellationToken); output.Write(xamlDocument.ToString()); return true; } diff --git a/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs b/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs index 2a1e50477..4128a002e 100644 --- a/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs +++ b/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs @@ -35,7 +35,7 @@ namespace ILSpy.BamlDecompiler public string WriteResourceToFile(LoadedAssembly assembly, string fileName, Stream stream, DecompilationOptions options) { - var document = BamlResourceEntryNode.LoadIntoDocument(assembly.GetAssemblyResolver(), assembly.AssemblyDefinition, stream, options.CancellationToken); + var document = BamlResourceEntryNode.LoadIntoDocument(assembly.GetAssemblyResolver(), assembly.GetAssemblyDefinitionAsync().Result, stream, options.CancellationToken); fileName = Path.ChangeExtension(fileName, ".xaml"); document.Save(Path.Combine(options.SaveAsProjectDirectory, fileName)); return fileName; diff --git a/ILSpy/Languages/CSharpLanguage.cs b/ILSpy/Languages/CSharpLanguage.cs index 4be6e9518..14339e981 100644 --- a/ILSpy/Languages/CSharpLanguage.cs +++ b/ILSpy/Languages/CSharpLanguage.cs @@ -288,7 +288,7 @@ namespace ICSharpCode.ILSpy void AddReferenceWarningMessage(AssemblyDefinition assembly, ITextOutput output) { - var loadedAssembly = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().FirstOrDefault(la => la.AssemblyDefinition == assembly); + var loadedAssembly = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().FirstOrDefault(la => la.GetAssemblyDefinitionAsync().Result == assembly); if (loadedAssembly == null || !loadedAssembly.LoadedAssemblyReferencesInfo.Any(i => i.Value.HasErrors)) return; const string line1 = "Warning: Some assembly references could not be loaded. This might lead to incorrect decompilation of some parts,"; @@ -322,15 +322,16 @@ namespace ICSharpCode.ILSpy public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options) { + var module = assembly.GetModuleDefinitionAsync().Result; if (options.FullDecompilation && options.SaveAsProjectDirectory != null) { var decompiler = new ILSpyWholeProjectDecompiler(assembly, options); decompiler.ProjectGuid = App.CommandLineArguments.FixedGuid; - decompiler.DecompileProject(assembly.ModuleDefinition, options.SaveAsProjectDirectory, new TextOutputWriter(output), options.CancellationToken); + decompiler.DecompileProject(module, options.SaveAsProjectDirectory, new TextOutputWriter(output), options.CancellationToken); } else { - AddReferenceWarningMessage(assembly.AssemblyDefinition, output); + AddReferenceWarningMessage(module.Assembly, output); output.WriteLine(); base.DecompileAssembly(assembly, output, options); - ModuleDefinition mainModule = assembly.ModuleDefinition; + ModuleDefinition mainModule = module; if (mainModule.Types.Count > 0) { output.Write("// Global type: "); output.WriteReference(mainModule.Types[0].FullName, mainModule.Types[0]); @@ -353,7 +354,7 @@ namespace ICSharpCode.ILSpy // don't automatically load additional assemblies when an assembly node is selected in the tree view using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) { - CSharpDecompiler decompiler = new CSharpDecompiler(assembly.ModuleDefinition, options.DecompilerSettings); + CSharpDecompiler decompiler = new CSharpDecompiler(module, options.DecompilerSettings); decompiler.CancellationToken = options.CancellationToken; SyntaxTree st; if (options.FullDecompilation) { diff --git a/ILSpy/Languages/ILLanguage.cs b/ILSpy/Languages/ILLanguage.cs index 9e618150a..36b58402d 100644 --- a/ILSpy/Languages/ILLanguage.cs +++ b/ILSpy/Languages/ILLanguage.cs @@ -118,16 +118,17 @@ namespace ICSharpCode.ILSpy output.WriteLine(); var dis = CreateDisassembler(output, options); + var module = assembly.GetModuleDefinitionAsync().Result; if (options.FullDecompilation) - dis.WriteAssemblyReferences(assembly.ModuleDefinition); - if (assembly.AssemblyDefinition != null) - dis.WriteAssemblyHeader(assembly.AssemblyDefinition); + dis.WriteAssemblyReferences(module); + if (module.Assembly != null) + dis.WriteAssemblyHeader(module.Assembly); output.WriteLine(); - dis.WriteModuleHeader(assembly.ModuleDefinition); + dis.WriteModuleHeader(module); if (options.FullDecompilation) { output.WriteLine(); output.WriteLine(); - dis.WriteModuleContents(assembly.ModuleDefinition); + dis.WriteModuleContents(module); } } diff --git a/ILSpy/Languages/Language.cs b/ILSpy/Languages/Language.cs index 4fc5d71dd..3741be548 100644 --- a/ILSpy/Languages/Language.cs +++ b/ILSpy/Languages/Language.cs @@ -87,15 +87,15 @@ namespace ICSharpCode.ILSpy public virtual void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options) { WriteCommentLine(output, assembly.FileName); - if (assembly.AssemblyDefinition != null) { - var name = assembly.AssemblyDefinition.Name; + if (assembly.GetAssemblyDefinitionAsync().Result != null) { + var name = assembly.GetAssemblyDefinitionAsync().Result.Name; if (name.IsWindowsRuntime) { WriteCommentLine(output, name.Name + " [WinRT]"); } else { WriteCommentLine(output, name.FullName); } } else { - WriteCommentLine(output, assembly.ModuleDefinition.Name); + WriteCommentLine(output, assembly.GetModuleDefinitionAsync().Result.Name); } } diff --git a/ILSpy/LoadedAssembly.cs b/ILSpy/LoadedAssembly.cs index c89225dcd..093912d0b 100644 --- a/ILSpy/LoadedAssembly.cs +++ b/ILSpy/LoadedAssembly.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; using System.Windows.Threading; using ICSharpCode.Decompiler; @@ -37,7 +38,6 @@ namespace ICSharpCode.ILSpy readonly AssemblyList assemblyList; readonly string fileName; readonly string shortName; - readonly Lazy targetFrameworkId; readonly Dictionary loadedAssemblyReferences = new Dictionary(); public LoadedAssembly(AssemblyList assemblyList, string fileName, Stream stream = null) @@ -51,14 +51,17 @@ namespace ICSharpCode.ILSpy this.assemblyTask = Task.Factory.StartNew(LoadAssembly, stream); // requires that this.fileName is set this.shortName = Path.GetFileNameWithoutExtension(fileName); - this.targetFrameworkId = new Lazy(() => AssemblyDefinition?.DetectTargetFrameworkId(), false); } /// /// Returns a target framework identifier in the form '<framework>Version=v<version>'. /// Returns an empty string if no TargetFrameworkAttribute was found or the file doesn't contain an assembly header, i.e., is only a module. /// - public string TargetFrameworkId => targetFrameworkId.Value ?? string.Empty; + public async Task GetTargetFrameworkIdAsync() + { + var assembly = await GetAssemblyDefinitionAsync(); + return assembly?.DetectTargetFrameworkId() ?? string.Empty; + } public Dictionary LoadedAssemblyReferencesInfo => loadedAssemblyReferences; @@ -66,25 +69,19 @@ namespace ICSharpCode.ILSpy /// Gets the Cecil ModuleDefinition. /// Can be null when there was a load error. /// - public ModuleDefinition ModuleDefinition { - get { - try { - return assemblyTask.Result; - } catch (AggregateException) { - return null; - } - } + public Task GetModuleDefinitionAsync() + { + return assemblyTask; } /// /// Gets the Cecil AssemblyDefinition. /// Is null when there was a load error; or when opening a netmodule. /// - public AssemblyDefinition AssemblyDefinition { - get { - var module = this.ModuleDefinition; - return module != null ? module.Assembly : null; - } + public async Task GetAssemblyDefinitionAsync() + { + var module = await assemblyTask; + return module != null ? module.Assembly : null; } public AssemblyList AssemblyList => assemblyList; @@ -95,8 +92,8 @@ namespace ICSharpCode.ILSpy public string Text { get { - if (AssemblyDefinition != null) { - return String.Format("{0} ({1})", ShortName, AssemblyDefinition.Name.Version); + if (IsLoaded && !HasLoadError) { + return String.Format("{0} ({1})", ShortName, GetAssemblyDefinitionAsync().Result.Name.Version); } else { return ShortName; } @@ -196,25 +193,25 @@ namespace ICSharpCode.ILSpy public AssemblyDefinition Resolve(AssemblyNameReference name) { var node = parent.LookupReferencedAssembly(name); - return node != null ? node.AssemblyDefinition : null; + return node != null ? node.GetAssemblyDefinitionAsync().Result : null; } public AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters) { var node = parent.LookupReferencedAssembly(name); - return node != null ? node.AssemblyDefinition : null; + return node != null ? node.GetAssemblyDefinitionAsync().Result : null; } public AssemblyDefinition Resolve(string fullName) { var node = parent.LookupReferencedAssembly(fullName); - return node != null ? node.AssemblyDefinition : null; + return node != null ? node.GetAssemblyDefinitionAsync().Result : null; } public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters) { var node = parent.LookupReferencedAssembly(fullName); - return node != null ? node.AssemblyDefinition : null; + return node != null ? node.GetAssemblyDefinitionAsync().Result : null; } public void Dispose() @@ -254,7 +251,8 @@ namespace ICSharpCode.ILSpy LoadedAssembly LookupReferencedAssemblyInternal(string fullName) { foreach (LoadedAssembly asm in assemblyList.GetAssemblies()) { - if (asm.AssemblyDefinition != null && fullName.Equals(asm.AssemblyDefinition.FullName, StringComparison.OrdinalIgnoreCase)) { + var asmDef = asm.GetAssemblyDefinitionAsync().Result; + if (asmDef != null && fullName.Equals(asmDef.FullName, StringComparison.OrdinalIgnoreCase)) { return asm; } } @@ -266,7 +264,7 @@ namespace ICSharpCode.ILSpy return (LoadedAssembly)App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Func(LookupReferencedAssembly), fullName); } - var resolver = new MyUniversalResolver(this) { TargetFramework = TargetFrameworkId }; + var resolver = new MyUniversalResolver(this) { TargetFramework = GetTargetFrameworkIdAsync().Result }; var name = AssemblyNameReference.Parse(fullName); var file = resolver.Resolve(name); @@ -282,7 +280,8 @@ namespace ICSharpCode.ILSpy LoadedAssembly LookupWinRTMetadata(string name) { foreach (LoadedAssembly asm in assemblyList.GetAssemblies()) { - if (asm.AssemblyDefinition != null && name.Equals(asm.AssemblyDefinition.Name.Name, StringComparison.OrdinalIgnoreCase)) + var asmDef = asm.GetAssemblyDefinitionAsync().Result; + if (asmDef!= null && name.Equals(asmDef.Name.Name, StringComparison.OrdinalIgnoreCase)) return asm; } if (assemblyLoadDisableCount > 0) @@ -302,7 +301,7 @@ namespace ICSharpCode.ILSpy public Task ContinueWhenLoaded(Action> onAssemblyLoaded, TaskScheduler taskScheduler) { - return this.assemblyTask.ContinueWith(onAssemblyLoaded, taskScheduler); + return this.assemblyTask.ContinueWith(onAssemblyLoaded, default(CancellationToken), TaskContinuationOptions.RunContinuationsAsynchronously, taskScheduler); } /// diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index b1fe3526b..f4fad536e 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -31,6 +31,7 @@ using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Threading; using ICSharpCode.Decompiler; using ICSharpCode.Decompiler.Documentation; using ICSharpCode.ILSpy.TextView; @@ -280,7 +281,7 @@ namespace ICSharpCode.ILSpy } } else { foreach (LoadedAssembly asm in commandLineLoadedAssemblies) { - ModuleDefinition def = asm.ModuleDefinition; + ModuleDefinition def = asm.GetModuleDefinitionAsync().Result; if (def != null) { MemberReference mr = XmlDocKeyProvider.FindMemberByKey(def, args.NavigateTo); if (mr != null) { @@ -299,7 +300,7 @@ namespace ICSharpCode.ILSpy } else if (commandLineLoadedAssemblies.Count == 1) { // NavigateTo == null and an assembly was given on the command-line: // Select the newly loaded assembly - JumpToReference(commandLineLoadedAssemblies[0].ModuleDefinition); + JumpToReference(commandLineLoadedAssemblies[0].GetModuleDefinitionAsync().Result); } if (args.Search != null) { @@ -327,6 +328,12 @@ namespace ICSharpCode.ILSpy } void MainWindow_Loaded(object sender, RoutedEventArgs e) + { + + Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(InitializeAssemblyListAndOpenAssemblies)); + } + + void InitializeAssemblyListAndOpenAssemblies() { ILSpySettings spySettings = this.spySettings; this.spySettings = null; diff --git a/ILSpy/SearchPane.cs b/ILSpy/SearchPane.cs index 94e705a7b..39a143f03 100644 --- a/ILSpy/SearchPane.cs +++ b/ILSpy/SearchPane.cs @@ -216,7 +216,7 @@ namespace ICSharpCode.ILSpy try { var searcher = GetSearchStrategy(searchMode, searchTerm); foreach (var loadedAssembly in assemblies) { - ModuleDefinition module = loadedAssembly.ModuleDefinition; + ModuleDefinition module = loadedAssembly.GetModuleDefinitionAsync().Result; if (module == null) continue; CancellationToken cancellationToken = cts.Token; diff --git a/ILSpy/TreeNodes/Analyzer/AnalyzedAttributeAppliedToTreeNode.cs b/ILSpy/TreeNodes/Analyzer/AnalyzedAttributeAppliedToTreeNode.cs index adf9de926..1be5999c7 100644 --- a/ILSpy/TreeNodes/Analyzer/AnalyzedAttributeAppliedToTreeNode.cs +++ b/ILSpy/TreeNodes/Analyzer/AnalyzedAttributeAppliedToTreeNode.cs @@ -295,21 +295,21 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer string requiredAssemblyFullName = asm.FullName; - IEnumerable assemblies = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().Where(assy => assy.AssemblyDefinition != null); + IEnumerable assemblies = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().Where(assy => assy.GetAssemblyDefinitionAsync().Result != null); foreach (var assembly in assemblies) { ct.ThrowIfCancellationRequested(); bool found = false; - foreach (var reference in assembly.AssemblyDefinition.MainModule.AssemblyReferences) { + foreach (var reference in assembly.GetAssemblyDefinitionAsync().Result.MainModule.AssemblyReferences) { if (requiredAssemblyFullName == reference.FullName) { found = true; break; } } if (found) { - var typeref = GetScopeTypeReferenceInAssembly(assembly.AssemblyDefinition); + var typeref = GetScopeTypeReferenceInAssembly(assembly.GetAssemblyDefinitionAsync().Result); if (typeref != null) - yield return new Tuple(assembly.AssemblyDefinition, typeref); + yield return new Tuple(assembly.GetAssemblyDefinitionAsync().Result, typeref); } } } @@ -334,9 +334,9 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer foreach (var assembly in assemblies) { ct.ThrowIfCancellationRequested(); if (friendAssemblies.Contains(assembly.ShortName)) { - var typeref = GetScopeTypeReferenceInAssembly(assembly.AssemblyDefinition); + var typeref = GetScopeTypeReferenceInAssembly(assembly.GetAssemblyDefinitionAsync().Result); if (typeref != null) { - yield return new Tuple(assembly.AssemblyDefinition, typeref); + yield return new Tuple(assembly.GetAssemblyDefinitionAsync().Result, typeref); } } } diff --git a/ILSpy/TreeNodes/Analyzer/AnalyzerEntityTreeNode.cs b/ILSpy/TreeNodes/Analyzer/AnalyzerEntityTreeNode.cs index 2e2c98845..afd890465 100644 --- a/ILSpy/TreeNodes/Analyzer/AnalyzerEntityTreeNode.cs +++ b/ILSpy/TreeNodes/Analyzer/AnalyzerEntityTreeNode.cs @@ -38,7 +38,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer public override bool HandleAssemblyListChanged(ICollection removedAssemblies, ICollection addedAssemblies) { foreach (LoadedAssembly asm in removedAssemblies) { - if (this.Member.Module == asm.ModuleDefinition) + if (this.Member.Module == asm.GetModuleDefinitionAsync().Result) return false; // remove this node } this.Children.RemoveAll( diff --git a/ILSpy/TreeNodes/Analyzer/ScopedWhereUsedAnalyzer.cs b/ILSpy/TreeNodes/Analyzer/ScopedWhereUsedAnalyzer.cs index e5359ea63..ecce52a7e 100644 --- a/ILSpy/TreeNodes/Analyzer/ScopedWhereUsedAnalyzer.cs +++ b/ILSpy/TreeNodes/Analyzer/ScopedWhereUsedAnalyzer.cs @@ -254,19 +254,19 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer string requiredAssemblyFullName = asm.FullName; - IEnumerable assemblies = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().Where(assy => assy.AssemblyDefinition != null); + IEnumerable assemblies = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().Where(assy => assy.GetAssemblyDefinitionAsync().Result != null); foreach (var assembly in assemblies) { ct.ThrowIfCancellationRequested(); bool found = false; - foreach (var reference in assembly.AssemblyDefinition.MainModule.AssemblyReferences) { + foreach (var reference in assembly.GetAssemblyDefinitionAsync().Result.MainModule.AssemblyReferences) { if (requiredAssemblyFullName == reference.FullName) { found = true; break; } } - if (found && AssemblyReferencesScopeType(assembly.AssemblyDefinition)) - yield return assembly.AssemblyDefinition; + if (found && AssemblyReferencesScopeType(assembly.GetAssemblyDefinitionAsync().Result)) + yield return assembly.GetAssemblyDefinitionAsync().Result; } } @@ -289,8 +289,8 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer foreach (var assembly in assemblies) { ct.ThrowIfCancellationRequested(); - if (friendAssemblies.Contains(assembly.ShortName) && AssemblyReferencesScopeType(assembly.AssemblyDefinition)) { - yield return assembly.AssemblyDefinition; + if (friendAssemblies.Contains(assembly.ShortName) && AssemblyReferencesScopeType(assembly.GetAssemblyDefinitionAsync().Result)) { + yield return assembly.GetAssemblyDefinitionAsync().Result; } } } diff --git a/ILSpy/TreeNodes/AssemblyListTreeNode.cs b/ILSpy/TreeNodes/AssemblyListTreeNode.cs index a8fb51dd4..08937fead 100644 --- a/ILSpy/TreeNodes/AssemblyListTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyListTreeNode.cs @@ -185,7 +185,7 @@ namespace ICSharpCode.ILSpy.TreeNodes return null; App.Current.Dispatcher.VerifyAccess(); foreach (AssemblyTreeNode node in this.Children) { - if (node.LoadedAssembly.IsLoaded && node.LoadedAssembly.ModuleDefinition == module) + if (node.LoadedAssembly.IsLoaded && node.LoadedAssembly.GetModuleDefinitionAsync().Result == module) return node; } return null; @@ -197,7 +197,7 @@ namespace ICSharpCode.ILSpy.TreeNodes return null; App.Current.Dispatcher.VerifyAccess(); foreach (AssemblyTreeNode node in this.Children) { - if (node.LoadedAssembly.IsLoaded && node.LoadedAssembly.AssemblyDefinition == asm) + if (node.LoadedAssembly.IsLoaded && node.LoadedAssembly.GetAssemblyDefinitionAsync().Result == asm) return node; } return null; diff --git a/ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs b/ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs index 91b136bd9..12dc54262 100644 --- a/ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs @@ -77,7 +77,7 @@ namespace ICSharpCode.ILSpy.TreeNodes if (assemblyListNode != null) { var refNode = assemblyListNode.FindAssemblyNode(parentAssembly.LoadedAssembly.LookupReferencedAssembly(r)); if (refNode != null) { - ModuleDefinition module = refNode.LoadedAssembly.ModuleDefinition; + ModuleDefinition module = refNode.LoadedAssembly.GetModuleDefinitionAsync().Result; if (module != null) { foreach (var childRef in module.AssemblyReferences) this.Children.Add(new AssemblyReferenceTreeNode(childRef, refNode)); diff --git a/ILSpy/TreeNodes/AssemblyTreeNode.cs b/ILSpy/TreeNodes/AssemblyTreeNode.cs index e86bf7846..8782d2a88 100644 --- a/ILSpy/TreeNodes/AssemblyTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyTreeNode.cs @@ -95,19 +95,20 @@ namespace ICSharpCode.ILSpy.TreeNodes if (assembly.HasLoadError) return "Assembly could not be loaded. Click here for details."; - if (tooltip == null) { + if (tooltip == null && assembly.IsLoaded) { tooltip = new TextBlock(); - if (assembly.AssemblyDefinition != null) { + var module = assembly.GetModuleDefinitionAsync().Result; + if (assembly.GetAssemblyDefinitionAsync().Result != null) { tooltip.Inlines.Add(new Bold(new Run("Name: "))); - tooltip.Inlines.Add(new Run(assembly.AssemblyDefinition.FullName)); + tooltip.Inlines.Add(new Run(module.Assembly.FullName)); tooltip.Inlines.Add(new LineBreak()); } tooltip.Inlines.Add(new Bold(new Run("Location: "))); tooltip.Inlines.Add(new Run(assembly.FileName)); tooltip.Inlines.Add(new LineBreak()); tooltip.Inlines.Add(new Bold(new Run("Architecture: "))); - tooltip.Inlines.Add(new Run(CSharpLanguage.GetPlatformDisplayName(assembly.ModuleDefinition))); - string runtimeName = CSharpLanguage.GetRuntimeDisplayName(assembly.ModuleDefinition); + tooltip.Inlines.Add(new Run(CSharpLanguage.GetPlatformDisplayName(module))); + string runtimeName = CSharpLanguage.GetRuntimeDisplayName(module); if (runtimeName != null) { tooltip.Inlines.Add(new LineBreak()); tooltip.Inlines.Add(new Bold(new Run("Runtime: "))); @@ -129,6 +130,7 @@ namespace ICSharpCode.ILSpy.TreeNodes // change from "Loading" icon to final icon RaisePropertyChanged("Icon"); RaisePropertyChanged("ExpandedIcon"); + RaisePropertyChanged("Tooltip"); if (moduleTask.IsFaulted) { RaisePropertyChanged("ShowExpander"); // cannot expand assemblies with load error // observe the exception so that the Task's finalizer doesn't re-throw it @@ -143,7 +145,7 @@ namespace ICSharpCode.ILSpy.TreeNodes protected override void LoadChildren() { - ModuleDefinition moduleDefinition = assembly.ModuleDefinition; + ModuleDefinition moduleDefinition = assembly.GetModuleDefinitionAsync().Result; if (moduleDefinition == null) { // if we crashed on loading, then we don't have any children return; @@ -381,7 +383,7 @@ namespace ICSharpCode.ILSpy.TreeNodes foreach (var node in context.SelectedTreeNodes) { var la = ((AssemblyTreeNode)node).LoadedAssembly; if (!la.HasLoadError) { - foreach (var assyRef in la.ModuleDefinition.AssemblyReferences) { + foreach (var assyRef in la.GetModuleDefinitionAsync().Result.AssemblyReferences) { la.LookupReferencedAssembly(assyRef.FullName); } } diff --git a/ILSpy/TreeNodes/DerivedTypesTreeNode.cs b/ILSpy/TreeNodes/DerivedTypesTreeNode.cs index 440ab60bf..881cf2104 100644 --- a/ILSpy/TreeNodes/DerivedTypesTreeNode.cs +++ b/ILSpy/TreeNodes/DerivedTypesTreeNode.cs @@ -60,7 +60,7 @@ namespace ICSharpCode.ILSpy.TreeNodes IEnumerable FetchChildren(CancellationToken cancellationToken) { // FetchChildren() runs on the main thread; but the enumerator will be consumed on a background thread - var assemblies = list.GetAssemblies().Select(node => node.ModuleDefinition).Where(asm => asm != null).ToArray(); + var assemblies = list.GetAssemblies().Select(node => node.GetModuleDefinitionAsync().Result).Where(asm => asm != null).ToArray(); return FindDerivedTypes(type, assemblies, cancellationToken); } diff --git a/ILSpy/TreeNodes/ILSpyTreeNode.cs b/ILSpy/TreeNodes/ILSpyTreeNode.cs index 825e4f699..a24217f94 100644 --- a/ILSpy/TreeNodes/ILSpyTreeNode.cs +++ b/ILSpy/TreeNodes/ILSpyTreeNode.cs @@ -150,11 +150,11 @@ namespace ICSharpCode.ILSpy.TreeNodes } } - protected override void OnIsVisibleChanged() + /*protected override void OnIsVisibleChanged() { base.OnIsVisibleChanged(); EnsureChildrenFiltered(); - } + }*/ internal void EnsureChildrenFiltered() { diff --git a/ILSpy/TreeNodes/ReferenceFolderTreeNode.cs b/ILSpy/TreeNodes/ReferenceFolderTreeNode.cs index 674e87022..a788411ab 100644 --- a/ILSpy/TreeNodes/ReferenceFolderTreeNode.cs +++ b/ILSpy/TreeNodes/ReferenceFolderTreeNode.cs @@ -61,7 +61,7 @@ namespace ICSharpCode.ILSpy.TreeNodes public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) { - language.WriteCommentLine(output, $"Detected Target-Framework-Id: {parentAssembly.LoadedAssembly.TargetFrameworkId}"); + language.WriteCommentLine(output, $"Detected Target-Framework-Id: {parentAssembly.LoadedAssembly.GetTargetFrameworkIdAsync().Result}"); App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(EnsureLazyChildren)); output.WriteLine(); language.WriteCommentLine(output, "Referenced assemblies (in metadata order):"); diff --git a/TestPlugin/ContextMenuCommand.cs b/TestPlugin/ContextMenuCommand.cs index ea46bfdfb..c67d38879 100644 --- a/TestPlugin/ContextMenuCommand.cs +++ b/TestPlugin/ContextMenuCommand.cs @@ -27,7 +27,7 @@ namespace TestPlugin if (context.SelectedTreeNodes == null) return; AssemblyTreeNode node = (AssemblyTreeNode)context.SelectedTreeNodes[0]; - AssemblyDefinition asm = node.LoadedAssembly.AssemblyDefinition; + AssemblyDefinition asm = node.LoadedAssembly.GetAssemblyDefinitionAsync().Result; if (asm != null) { SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = node.LoadedAssembly.FileName;