Skip to content

Commit

Permalink
Add IBundleEntryNode interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Dec 30, 2023
1 parent e5dc3b4 commit 6d0f609
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ You should have received a copy of the GNU General Public License

using dnlib.DotNet;
using dnlib.PE;
using dnSpy.Contracts.Bundles;
using dnSpy.Contracts.TreeView;

namespace dnSpy.Contracts.Documents.TreeView {
/// <summary>
/// A .NET assembly file
/// </summary>
public abstract class AssemblyDocumentNode : DsDocumentNode, IMDTokenNode {
public abstract class AssemblyDocumentNode : DsDocumentNode, IMDTokenNode, IBundleEntryNode {
/// <summary>
/// Gets the <see cref="IDsDocument"/> instance
/// </summary>
Expand All @@ -37,6 +38,7 @@ public abstract class AssemblyDocumentNode : DsDocumentNode, IMDTokenNode {
public bool IsExe => (Document.ModuleDef!.Characteristics & Characteristics.Dll) == 0;

IMDTokenProvider? IMDTokenNode.Reference => Document.AssemblyDef;
BundleEntry? IBundleEntryNode.BundleEntry => Document.BundleEntry;

/// <summary>
/// Constructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
using System.Diagnostics;
using dnSpy.Contracts.Bundles;
using dnSpy.Contracts.TreeView;

namespace dnSpy.Contracts.Documents.TreeView {
/// <summary>
/// JSON bundle entry node
/// </summary>
public abstract class JsonBundleEntryNode : DocumentTreeNodeData {
public abstract class JsonBundleEntryNode : DocumentTreeNodeData, IBundleEntryNode {
/// <inheritdoc/>
public BundleEntry BundleEntry { get; }

/// <summary>
/// Constructor
/// </summary>
protected JsonBundleEntryNode(BundleEntry bundleEntry) => Debug2.Assert(bundleEntry is not null);
protected JsonBundleEntryNode(BundleEntry bundleEntry) {
Debug2.Assert(bundleEntry is not null);
BundleEntry = bundleEntry;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@ You should have received a copy of the GNU General Public License

using System.Diagnostics;
using dnlib.DotNet;
using dnSpy.Contracts.Bundles;
using dnSpy.Contracts.TreeView;

namespace dnSpy.Contracts.Documents.TreeView {
/// <summary>
/// A .NET module file
/// </summary>
public abstract class ModuleDocumentNode : DsDocumentNode, IMDTokenNode {
public abstract class ModuleDocumentNode : DsDocumentNode, IMDTokenNode, IBundleEntryNode {
/// <summary>
/// Gets the <see cref="IDsDocument"/> instance
/// </summary>
public new IDsDotNetDocument Document => (IDsDotNetDocument)base.Document;

IMDTokenProvider? IMDTokenNode.Reference => Document.ModuleDef;
BundleEntry? IBundleEntryNode.BundleEntry => Document.BundleEntry;

/// <summary>
/// Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ You should have received a copy of the GNU General Public License

using System.Diagnostics;
using dnlib.PE;
using dnSpy.Contracts.Bundles;
using dnSpy.Contracts.TreeView;

namespace dnSpy.Contracts.Documents.TreeView {
/// <summary>
/// A PE file (but not a .NET file)
/// </summary>
public abstract class PEDocumentNode : DsDocumentNode {
public abstract class PEDocumentNode : DsDocumentNode, IBundleEntryNode {
/// <summary>
/// true if it's an .exe file, false if it's a .dll file
/// </summary>
public bool IsExe => (Document.PEImage!.ImageNTHeaders.FileHeader.Characteristics & Characteristics.Dll) == 0;

BundleEntry? IBundleEntryNode.BundleEntry => Document.BundleEntry;

/// <summary>
/// Constructor
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
using System.Diagnostics;
using dnSpy.Contracts.Bundles;
using dnSpy.Contracts.TreeView;

namespace dnSpy.Contracts.Documents.TreeView {
/// <summary>
/// Unknown bundle entry node
/// </summary>
public abstract class UnknownBundleEntryNode : DocumentTreeNodeData {
public abstract class UnknownBundleEntryNode : DocumentTreeNodeData, IBundleEntryNode {
/// <inheritdoc/>
public BundleEntry BundleEntry { get; }

/// <summary>
/// Constructor
/// </summary>
protected UnknownBundleEntryNode(BundleEntry bundleEntry) => Debug2.Assert(bundleEntry is not null);
protected UnknownBundleEntryNode(BundleEntry bundleEntry) {
Debug2.Assert(bundleEntry is not null);
BundleEntry = bundleEntry;
}
}
}
32 changes: 32 additions & 0 deletions dnSpy/dnSpy.Contracts.DnSpy/TreeView/IBundleEntryNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (C) 2023 ElektroKill
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see <http://www.gnu.org/licenses/>.
*/

using dnSpy.Contracts.Bundles;

namespace dnSpy.Contracts.TreeView {
/// <summary>
/// A node which can be a bundle entry
/// </summary>
public interface IBundleEntryNode {
/// <summary>
/// Gets the bundle entry for this node or null
/// </summary>
BundleEntry? BundleEntry { get; }
}
}

0 comments on commit 6d0f609

Please sign in to comment.