Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decompile base & derived types in place #3081

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ILSpy/TreeNodes/BaseTypesEntryNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal static bool ActivateItem(SharpTreeNode node, ITypeDefinition def)

public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, language.TypeToString(type, includeNamespace: true));
language.DecompileType(type, output, options);
}

IEntity IMemberTreeNode.Member => type;
Expand Down
3 changes: 2 additions & 1 deletion ILSpy/TreeNodes/BaseTypesTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public override void Decompile(Language language, ITextOutput output, Decompilat
App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(EnsureLazyChildren));
foreach (ILSpyTreeNode child in this.Children)
{
child.Decompile(language, output, options);
if (child is IMemberTreeNode { Member: ITypeDefinition childType })
language.WriteCommentLine(output, language.TypeToString(childType, includeNamespace: true));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ILSpy/TreeNodes/DerivedTypesEntryNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override void ActivateItem(System.Windows.RoutedEventArgs e)

public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, language.TypeToString(type, includeNamespace: true));
language.DecompileType(type, output, options);
}

IEntity IMemberTreeNode.Member => type;
Expand Down
10 changes: 9 additions & 1 deletion ILSpy/TreeNodes/DerivedTypesTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Threading;

using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.TypeSystem;
Expand Down Expand Up @@ -101,7 +103,13 @@ static bool IsSameType(SRM.MetadataReader referenceMetadata, SRM.EntityHandle ty

public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
threading.Decompile(language, output, options, EnsureLazyChildren);
App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(EnsureLazyChildren));
for (int i = 0; i < Children.Count; i++)
{
// LazyChildren are async and will not be ready on first call, avoid foreach.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how avoiding foreach helps here, you still have a race condition.

if (Children[i] is IMemberTreeNode { Member: ITypeDefinition childType })
language.WriteCommentLine(output, language.TypeToString(childType, includeNamespace: true));
}
}
}
}