Skip to content

Commit

Permalink
SharpTreeView: Split into ILSpyX.TreeView and ILSpy.Controls.TreeView (
Browse files Browse the repository at this point in the history
…#3240)

* Changes necessary for making SharpTreeNode cross platform by proxying System.Windows dependencies
* Add ITreeNodeImagesProvider for node icons
* Move InternalsVisibleTo to csproj (possible since net50)
* Move view models and other xplat class for SharpTreeView to ILSpyX, Windows-dependent classes to ILSpy/Controls/TreeView
* Move GetDoubleClickTime to NativeMethods
  • Loading branch information
christophwille authored Jul 28, 2024
1 parent 2e7991e commit d54ac41
Show file tree
Hide file tree
Showing 61 changed files with 308 additions and 240 deletions.
21 changes: 13 additions & 8 deletions ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningsAsErrors>nullable</WarningsAsErrors>

<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>

<NeutralLanguage>en-US</NeutralLanguage>
<GenerateAssemblyVersionAttribute>False</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>False</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>False</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>

<PropertyGroup>
<PackageId>ICSharpCode.ILSpyX</PackageId>
<PackageVersion>8.0.0.0-noversion</PackageVersion>
Expand All @@ -32,22 +32,27 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>Copyright 2022-$([System.DateTime]::Now.Year) AlphaSierraPapa</Copyright>
<PackageTags>C# Decompiler ILSpy</PackageTags>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>


<ItemGroup>
<InternalsVisibleTo Include="ILSpy" Key="00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf" />
<InternalsVisibleTo Include="ILSpy.Tests" Key="00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf" />
</ItemGroup>

<ItemGroup>
<None Include="PackageReadme.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.template.cs" />
</ItemGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand Down Expand Up @@ -77,7 +82,7 @@
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj" />
</ItemGroup>

<Target Name="ILSpyUpdateAssemblyInfo" AfterTargets="ResolveProjectReferences">
<ReadLinesFromFile ContinueOnError="true" File="..\VERSION">
<Output TaskParameter="Lines" PropertyName="PackageVersion" />
Expand Down
4 changes: 0 additions & 4 deletions ICSharpCode.ILSpyX/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@

[assembly: SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
Justification = "AssemblyInformationalVersion does not need to be a parsable version")]

[assembly: InternalsVisibleTo("ILSpy, PublicKey=00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf")]
[assembly: InternalsVisibleTo("ILSpy.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf")]

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
using System.Collections.Generic;
using System.Diagnostics;

namespace ICSharpCode.TreeView
#nullable disable

namespace ICSharpCode.ILSpyX.TreeView
{
// This part of SharpTreeNode controls the 'flat list' data structure, which emulates
// a big flat list containing the whole tree; allowing access by visible index.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
{
public interface IPlatformDataObject
{
bool GetDataPresent(string format);
object GetData(string format);

void SetData(string format, object data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
{
public interface IPlatformDragDrop
{
XPlatDragDropEffects DoDragDrop(object dragSource, object data, XPlatDragDropEffects allowedEffects);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
{
public interface IPlatformDragEventArgs
{
XPlatDragDropEffects Effects { get; set; }
IPlatformDataObject Data { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
{
public interface IPlatformRoutedEventArgs
{
bool Handled { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
{
public interface ITreeNodeImagesProvider
{
object Assembly { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;

namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
{
//
// Summary:
// Specifies the effects of a drag-and-drop operation.
[Flags]
public enum XPlatDragDropEffects
{
//
// Summary:
// Scrolling is about to start or is currently occurring in the drop target.
Scroll = int.MinValue,
//
// Summary:
// The data is copied, removed from the drag source, and scrolled in the drop target.
All = -2147483645,
//
// Summary:
// The drop target does not accept the data.
None = 0,
//
// Summary:
// The data is copied to the drop target.
Copy = 1,
//
// Summary:
// The data from the drag source is moved to the drop target.
Move = 2,
//
// Summary:
// The data from the drag source is linked to the drop target.
Link = 4
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace ICSharpCode.TreeView
#nullable disable

using ICSharpCode.ILSpyX.TreeView.PlatformAbstractions;

namespace ICSharpCode.ILSpyX.TreeView
{
public partial class SharpTreeNode : INotifyPropertyChanged
{
protected static ITreeNodeImagesProvider ImagesProvider { get; private set; }
public static void SetImagesProvider(ITreeNodeImagesProvider provider) => ImagesProvider = provider;

SharpTreeNodeCollection modelChildren;
internal SharpTreeNode modelParent;
bool isVisible = true;
Expand Down Expand Up @@ -584,7 +588,7 @@ public virtual void DeleteCore()
throw new NotSupportedException(GetType().Name + " does not support deletion");
}

public virtual IDataObject Copy(SharpTreeNode[] nodes)
public virtual IPlatformDataObject Copy(SharpTreeNode[] nodes)
{
throw new NotSupportedException(GetType().Name + " does not support copy/paste or drag'n'drop");
}
Expand Down Expand Up @@ -614,25 +618,26 @@ public virtual bool CanDrag(SharpTreeNode[] nodes)
return false;
}

public virtual void StartDrag(DependencyObject dragSource, SharpTreeNode[] nodes)
public virtual void StartDrag(object dragSource, SharpTreeNode[] nodes, IPlatformDragDrop dragdropManager)
{
DragDropEffects effects = DragDropEffects.All;
XPlatDragDropEffects effects = XPlatDragDropEffects.All;
if (!nodes.All(n => n.CanDelete()))
effects &= ~DragDropEffects.Move;
DragDropEffects result = DragDrop.DoDragDrop(dragSource, Copy(nodes), effects);
if (result == DragDropEffects.Move)
effects &= ~XPlatDragDropEffects.Move;

XPlatDragDropEffects result = dragdropManager.DoDragDrop(dragSource, Copy(nodes), effects);
if (result == XPlatDragDropEffects.Move)
{
foreach (SharpTreeNode node in nodes)
node.DeleteCore();
}
}

public virtual bool CanDrop(DragEventArgs e, int index)
public virtual bool CanDrop(IPlatformDragEventArgs e, int index)
{
return false;
}

internal void InternalDrop(DragEventArgs e, int index)
internal void InternalDrop(IPlatformDragEventArgs e, int index)
{
if (LazyLoading)
{
Expand All @@ -643,7 +648,7 @@ internal void InternalDrop(DragEventArgs e, int index)
Drop(e, index);
}

public virtual void Drop(DragEventArgs e, int index)
public virtual void Drop(IPlatformDragEventArgs e, int index)
{
throw new NotSupportedException(GetType().Name + " does not support Drop()");
}
Expand Down Expand Up @@ -703,14 +708,14 @@ public void RaisePropertyChanged(string name)
/// <summary>
/// Gets called when the item is double-clicked.
/// </summary>
public virtual void ActivateItem(RoutedEventArgs e)
public virtual void ActivateItem(IPlatformRoutedEventArgs e)
{
}

/// <summary>
/// Gets called when the item is clicked with the middle mouse button.
/// </summary>
public virtual void ActivateItemSecondary(RoutedEventArgs e)
public virtual void ActivateItemSecondary(IPlatformRoutedEventArgs e)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
using System.Diagnostics;
using System.Linq;

namespace ICSharpCode.TreeView
#nullable disable

namespace ICSharpCode.ILSpyX.TreeView
{
/// <summary>
/// Collection that validates that inserted nodes do not have another parent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
using System.Collections.Specialized;
using System.Diagnostics;

namespace ICSharpCode.TreeView
#nullable disable

namespace ICSharpCode.ILSpyX.TreeView
{
sealed class TreeFlattener : IList, INotifyCollectionChanged
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System;
using System.Collections.Generic;

namespace ICSharpCode.TreeView
namespace ICSharpCode.ILSpyX.TreeView
{
/// <summary>
/// Static helper methods for traversing trees.
Expand Down
1 change: 0 additions & 1 deletion ILSpy.Wpf.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"ILSpy.ReadyToRun\\ILSpy.ReadyToRun.csproj",
"ILSpy.Tests\\ILSpy.Tests.csproj",
"ILSpy\\ILSpy.csproj",
"SharpTreeView\\ICSharpCode.TreeView.csproj",
"TestPlugin\\TestPlugin.csproj"
]
}
Expand Down
8 changes: 1 addition & 7 deletions ILSpy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{F45DB999-7E7
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy", "ILSpy\ILSpy.csproj", "{1E85EFF9-E370-4683-83E4-8A3D063FF791}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.TreeView", "SharpTreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler", "ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj", "{984CC812-9470-4A13-AFF9-CC44068D666C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.Tests", "ICSharpCode.Decompiler.Tests\ICSharpCode.Decompiler.Tests.csproj", "{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}"
Expand All @@ -36,7 +34,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.Test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.ILSpyX", "ICSharpCode.ILSpyX\ICSharpCode.ILSpyX.csproj", "{F8EFCF9D-B9A3-4BA0-A1B2-B026A71DAC22}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.BamlDecompiler", "ICSharpCode.BamlDecompiler\ICSharpCode.BamlDecompiler.csproj", "{81A30182-3378-4952-8880-F44822390040}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.BamlDecompiler", "ICSharpCode.BamlDecompiler\ICSharpCode.BamlDecompiler.csproj", "{81A30182-3378-4952-8880-F44822390040}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -48,10 +46,6 @@ Global
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Release|Any CPU.Build.0 = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|Any CPU.Build.0 = Release|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
5 changes: 3 additions & 2 deletions ILSpy/Analyzers/AnalyzerEntityTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpyX;
using ICSharpCode.TreeView;
using ICSharpCode.ILSpyX.TreeView.PlatformAbstractions;
using ICSharpCode.ILSpyX.TreeView;

namespace ICSharpCode.ILSpy.Analyzers
{
Expand All @@ -33,7 +34,7 @@ public abstract class AnalyzerEntityTreeNode : AnalyzerTreeNode, IMemberTreeNode
{
public abstract IEntity Member { get; }

public override void ActivateItem(System.Windows.RoutedEventArgs e)
public override void ActivateItem(IPlatformRoutedEventArgs e)
{
e.Handled = true;
if (this.Member == null || this.Member.MetadataToken.IsNil)
Expand Down
4 changes: 2 additions & 2 deletions ILSpy/Analyzers/AnalyzerTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using System.Linq;

using ICSharpCode.ILSpyX;
using ICSharpCode.TreeView;
using ICSharpCode.ILSpyX.TreeView;

namespace ICSharpCode.ILSpy.Analyzers
{
Expand Down Expand Up @@ -56,7 +56,7 @@ public override void Delete()
DeleteCore();
}

protected override void OnChildrenChanged(NotifyCollectionChangedEventArgs e)
internal protected override void OnChildrenChanged(NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
Expand Down
3 changes: 2 additions & 1 deletion ILSpy/Analyzers/AnalyzerTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
using ICSharpCode.ILSpy.Docking;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX;
using ICSharpCode.TreeView;
using ICSharpCode.ILSpy.Controls.TreeView;
using ICSharpCode.ILSpyX.TreeView;

namespace ICSharpCode.ILSpy.Analyzers
{
Expand Down
3 changes: 2 additions & 1 deletion ILSpy/Analyzers/TreeNodes/AnalyzedModuleTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX.Analyzers;
using ICSharpCode.ILSpyX.TreeView.PlatformAbstractions;

namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
{
Expand Down Expand Up @@ -52,7 +53,7 @@ protected override void LoadChildren()
}
}

public override void ActivateItem(RoutedEventArgs e)
public override void ActivateItem(IPlatformRoutedEventArgs e)
{
e.Handled = true;
if (analyzedModule.MetadataFile == null)
Expand Down
Loading

0 comments on commit d54ac41

Please sign in to comment.