Browse Source

Merge remote-tracking branch 'origin/master' into newdecompiler.

Note: due to massive conflicts, this merge effectively reverts Christoph's ILSpy.AddIn commits from 2017-03-05.
pull/863/head
Daniel Grunwald 8 years ago
parent
commit
f54c621ec4
  1. 3
      ICSharpCode.Decompiler/Output/TextTokenWriter.cs
  2. 2
      ILSpy.AddIn/license.txt
  3. 2
      ILSpy/ContextMenuEntry.cs
  4. 3
      ILSpy/ILSpy.csproj
  5. BIN
      ILSpy/Images/Copy.png
  6. BIN
      ILSpy/Images/Library.png
  7. BIN
      ILSpy/Images/OverlayStatic.png
  8. BIN
      ILSpy/Images/SearchMsdn.png
  9. 15
      ILSpy/Languages/CSharpLanguage.cs
  10. 7
      ILSpy/Languages/Language.cs
  11. 14
      ILSpy/LoadedAssembly.cs
  12. 9
      ILSpy/MainWindow.xaml
  13. 35
      ILSpy/MainWindow.xaml.cs
  14. 1
      ILSpy/SearchPane.xaml
  15. 15
      ILSpy/TextView/DecompilerTextView.cs
  16. 2
      ILSpy/TextView/DecompilerTextView.xaml
  17. 2
      ILSpy/TreeNodes/Analyzer/AnalyzeContextMenuEntry.cs
  18. 2
      ILSpy/TreeNodes/Analyzer/RemoveAnalyzeContextMenuEntry.cs
  19. 6
      ILSpy/TreeNodes/AssemblyTreeNode.cs
  20. 42
      ILSpy/TreeNodes/CopyFullyQualifiedTypeNameContextMenuEntry.cs
  21. 4
      ILSpy/TreeNodes/MethodTreeNode.cs
  22. 33
      ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs
  23. 2
      ILSpy/TreeNodes/SearchMsdnContextMenuEntry.cs
  24. 8
      ILSpy/VB/VBLanguage.cs
  25. 6
      SharpTreeView/ICSharpCode.TreeView.csproj
  26. 4
      SharpTreeView/SharpTreeView.cs
  27. 21
      SharpTreeView/SharpTreeViewAutomationPeer.cs
  28. 5
      SharpTreeView/SharpTreeViewItem.cs
  29. 77
      SharpTreeView/SharpTreeViewItemAutomationPeer.cs

3
ICSharpCode.Decompiler/Output/TextTokenWriter.cs

@ -191,7 +191,8 @@ namespace ICSharpCode.Decompiler @@ -191,7 +191,8 @@ namespace ICSharpCode.Decompiler
public override void WriteKeyword(Role role, string keyword)
{
if (keyword == "this" || keyword == "base") {
//To make reference for 'this' and 'base' keywords in the ClassName():this() expression
if (role == ConstructorInitializer.ThisKeywordRole || role == ConstructorInitializer.BaseKeywordRole) {
if (nodeStack.Peek() is ConstructorInitializer initializer && initializer.GetSymbol() is IMember member) {
var cecil = typeSystem.GetCecil(member);
if (cecil != null) {

2
ILSpy.AddIn/license.txt

@ -3,7 +3,7 @@ The following MIT license applies to ILSpy, NRefactory and ICSharpCode.Decompile @@ -3,7 +3,7 @@ The following MIT license applies to ILSpy, NRefactory and ICSharpCode.Decompile
MIT license:
Copyright (c) 2011-2016 AlphaSierraPapa for the SharpDevelop team
Copyright (c) 2011-2017 AlphaSierraPapa for the SharpDevelop team
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

2
ILSpy/ContextMenuEntry.cs

@ -109,6 +109,8 @@ namespace ICSharpCode.ILSpy @@ -109,6 +109,8 @@ namespace ICSharpCode.ILSpy
public ExportContextMenuEntryAttribute()
: base(typeof(IContextMenuEntry))
{
// entries default to end of menu unless given specific order position
Order = double.MaxValue;
}
public string Icon { get; set; }

3
ILSpy/ILSpy.csproj

@ -191,6 +191,7 @@ @@ -191,6 +191,7 @@
<Compile Include="TreeNodes\Analyzer\Helpers.cs" />
<Compile Include="TreeNodes\Analyzer\ScopedWhereUsedAnalyzer.cs" />
<Compile Include="TreeNodes\BaseTypesEntryNode.cs" />
<Compile Include="TreeNodes\CopyFullyQualifiedTypeNameContextMenuEntry.cs" />
<Compile Include="TreeNodes\DerivedTypesEntryNode.cs" />
<Compile Include="TreeNodes\FilterResult.cs" />
<Compile Include="TreeNodes\IMemberTreeNode.cs" />
@ -348,6 +349,8 @@ @@ -348,6 +349,8 @@
<ItemGroup>
<Resource Include="Images\Sort.png" />
<Resource Include="Images\SearchMsdn.png" />
<Resource Include="Images\Copy.png" />
</ItemGroup>
<ItemGroup>

BIN
ILSpy/Images/Copy.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

BIN
ILSpy/Images/Library.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 417 B

BIN
ILSpy/Images/OverlayStatic.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 347 B

BIN
ILSpy/Images/SearchMsdn.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

15
ILSpy/Languages/CSharpLanguage.cs

@ -421,10 +421,12 @@ namespace ICSharpCode.ILSpy @@ -421,10 +421,12 @@ namespace ICSharpCode.ILSpy
((ComposedType)astType).PointerRank--;
}
astType.AcceptVisitor(new CSharpOutputVisitor(w, FormattingOptionsFactory.CreateAllman()));
astType.AcceptVisitor(new CSharpOutputVisitor(w, TypeToStringFormattingOptions));
return w.ToString();
}
*/
static readonly CSharpFormattingOptions TypeToStringFormattingOptions = FormattingOptionsFactory.CreateEmpty();
*/
public override string FormatPropertyName(PropertyDefinition property, bool? isIndexer)
{
if (property == null)
@ -455,6 +457,15 @@ namespace ICSharpCode.ILSpy @@ -455,6 +457,15 @@ namespace ICSharpCode.ILSpy
} else
return property.Name;
}
public override string FormatMethodName(MethodDefinition method)
{
if (method == null)
throw new ArgumentNullException("method");
return (method.IsConstructor) ? method.DeclaringType.Name : method.Name;
}
/*
public override string FormatTypeName(TypeDefinition type)
{

7
ILSpy/Languages/Language.cs

@ -134,6 +134,13 @@ namespace ICSharpCode.ILSpy @@ -134,6 +134,13 @@ namespace ICSharpCode.ILSpy
return property.Name;
}
public virtual string FormatMethodName(MethodDefinition method)
{
if (method == null)
throw new ArgumentNullException("method");
return method.Name;
}
public virtual string FormatTypeName(TypeDefinition type)
{
if (type == null)

14
ILSpy/LoadedAssembly.cs

@ -143,6 +143,20 @@ namespace ICSharpCode.ILSpy @@ -143,6 +143,20 @@ namespace ICSharpCode.ILSpy
private void LoadSymbols(ModuleDefinition module)
{
if (!module.HasDebugHeader) {
return;
}
byte[] headerBytes;
var debugHeader = module.GetDebugHeader(out headerBytes);
if (debugHeader.Type != 2) {
// the debug type is not IMAGE_DEBUG_TYPE_CODEVIEW
return;
}
if (debugHeader.MajorVersion != 0 || debugHeader.MinorVersion != 0) {
// the PDB type is not compatible with PdbReaderProvider. It is probably a Portable PDB
return;
}
// search for pdb in same directory as dll
string pdbName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".pdb");
if (File.Exists(pdbName)) {

9
ILSpy/MainWindow.xaml

@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
</Window.TaskbarItemInfo>
<DockPanel>
<!-- Main menu -->
<Menu DockPanel.Dock="Top" Name="mainMenu" Height="23">
<Menu DockPanel.Dock="Top" Name="mainMenu" Height="23" KeyboardNavigation.TabNavigation="None">
<MenuItem Header="_File" /> <!-- contents of file menu are added using MEF -->
<MenuItem Header="_View">
<MenuItem Header="Show _internal types and members" IsCheckable="True" IsChecked="{Binding FilterSettings.ShowInternalApi}">
@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
<!-- ToolBar -->
<ToolBar
Name="toolBar"
DockPanel.Dock="Top" ToolBarTray.IsLocked="True">
DockPanel.Dock="Top" ToolBarTray.IsLocked="True" KeyboardNavigation.TabNavigation="None">
<ToolBar.Resources>
<!-- Make images transparent if menu command is disabled -->
<Style TargetType="{x:Type Image}">
@ -113,6 +113,7 @@ @@ -113,6 +113,7 @@
<!-- Left pane: Tree View of assemblies and classes -->
<tv:SharpTreeView
Name="treeView"
AutomationProperties.Name="Assemblies and Classes"
SelectionChanged="TreeView_SelectionChanged"
ShowRoot="False"
AllowDropOrder="True"
@ -142,7 +143,7 @@ @@ -142,7 +143,7 @@
<RowDefinition Height="0" Name="bottomPaneRow" />
</Grid.RowDefinitions>
<Border BorderBrush="Black" BorderThickness="1" Name="updatePanel" Visibility="Collapsed">
<DockPanel>
<DockPanel KeyboardNavigation.TabNavigation="Contained">
<Button DockPanel.Dock="Right" Click="updatePanelCloseButtonClick" MinWidth="0">X</Button>
<StackPanel Orientation="Horizontal">
<TextBlock Name="updatePanelMessage" Margin="4,0" VerticalAlignment="Center">A new ILSpy version is available.</TextBlock>
@ -152,6 +153,7 @@ @@ -152,6 +153,7 @@
</Border>
<controls:DockedPane x:Name="topPane" Grid.Row="1" Title="Top" Visibility="Collapsed"
AutomationProperties.Name="Close top pane"
CloseButtonClicked="TopPane_CloseButtonClicked" Margin="0,0,0,3"
BorderThickness="1,1,0,1" />
@ -181,6 +183,7 @@ @@ -181,6 +183,7 @@
Visibility="{Binding Visibility, ElementName=bottomPane}" />
<controls:DockedPane x:Name="bottomPane" Grid.Row="5" Title="Bottom" Visibility="Collapsed"
AutomationProperties.Name="Close"
CloseButtonClicked="BottomPane_CloseButtonClicked" Margin="0,3,0,0" BorderThickness="1,1,0,1"/>
</Grid>
</Grid>

35
ILSpy/MainWindow.xaml.cs

@ -850,7 +850,7 @@ namespace ICSharpCode.ILSpy @@ -850,7 +850,7 @@ namespace ICSharpCode.ILSpy
sessionSettings.WindowBounds = this.RestoreBounds;
sessionSettings.SplitterPosition = leftColumn.Width.Value / (leftColumn.Width.Value + rightColumn.Width.Value);
if (topPane.Visibility == Visibility.Visible)
sessionSettings.BottomPaneSplitterPosition = topPaneRow.Height.Value / (topPaneRow.Height.Value + textViewRow.Height.Value);
sessionSettings.TopPaneSplitterPosition = topPaneRow.Height.Value / (topPaneRow.Height.Value + textViewRow.Height.Value);
if (bottomPane.Visibility == Visibility.Visible)
sessionSettings.BottomPaneSplitterPosition = bottomPaneRow.Height.Value / (bottomPaneRow.Height.Value + textViewRow.Height.Value);
sessionSettings.Save();
@ -873,10 +873,40 @@ namespace ICSharpCode.ILSpy @@ -873,10 +873,40 @@ namespace ICSharpCode.ILSpy
}
#region Top/Bottom Pane management
/// <summary>
/// When grid is resized using splitter, row height value could become greater than 1.
/// As result, when a new pane is shown, both textView and pane could become very small.
/// This method normalizes two rows and ensures that height is less then 1.
/// </summary>
void NormalizePaneRowHeightValues(RowDefinition pane1Row, RowDefinition pane2Row)
{
var pane1Height = pane1Row.Height;
var pane2Height = pane2Row.Height;
//only star height values are normalized.
if (!pane1Height.IsStar || !pane2Height.IsStar)
{
return;
}
var totalHeight = pane1Height.Value + pane2Height.Value;
if (totalHeight == 0)
{
return;
}
pane1Row.Height = new GridLength(pane1Height.Value / totalHeight, GridUnitType.Star);
pane2Row.Height = new GridLength(pane2Height.Value / totalHeight, GridUnitType.Star);
}
public void ShowInTopPane(string title, object content)
{
topPaneRow.MinHeight = 100;
if (sessionSettings.TopPaneSplitterPosition > 0 && sessionSettings.TopPaneSplitterPosition < 1) {
//Ensure all 3 blocks are in fair conditions
NormalizePaneRowHeightValues(bottomPaneRow, textViewRow);
textViewRow.Height = new GridLength(1 - sessionSettings.TopPaneSplitterPosition, GridUnitType.Star);
topPaneRow.Height = new GridLength(sessionSettings.TopPaneSplitterPosition, GridUnitType.Star);
}
@ -907,6 +937,9 @@ namespace ICSharpCode.ILSpy @@ -907,6 +937,9 @@ namespace ICSharpCode.ILSpy
{
bottomPaneRow.MinHeight = 100;
if (sessionSettings.BottomPaneSplitterPosition > 0 && sessionSettings.BottomPaneSplitterPosition < 1) {
//Ensure all 3 blocks are in fair conditions
NormalizePaneRowHeightValues(topPaneRow, textViewRow);
textViewRow.Height = new GridLength(1 - sessionSettings.BottomPaneSplitterPosition, GridUnitType.Star);
bottomPaneRow.Height = new GridLength(sessionSettings.BottomPaneSplitterPosition, GridUnitType.Star);
}

1
ILSpy/SearchPane.xaml

@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal">
<Label Margin="0,-1" Target="searchModeComboBox">_Search for:</Label>
<ComboBox Width="100" Name="searchModeComboBox" Margin="1"
TextSearch.TextPath="Name"
SelectionChanged="SearchModeComboBox_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>

15
ILSpy/TextView/DecompilerTextView.cs

@ -28,6 +28,7 @@ using System.Threading.Tasks; @@ -28,6 +28,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
@ -99,6 +100,10 @@ namespace ICSharpCode.ILSpy.TextView @@ -99,6 +100,10 @@ namespace ICSharpCode.ILSpy.TextView
textEditor.SetBinding(Control.FontSizeProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFontSize") });
textEditor.SetBinding(TextEditor.WordWrapProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("EnableWordWrap") });
// disable Tab editing command (useless for read-only editor); allow using tab for focus navigation instead
RemoveEditCommand(EditingCommands.TabForward);
RemoveEditCommand(EditingCommands.TabBackward);
textMarkerService = new TextMarkerService(textEditor.TextArea.TextView);
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
@ -116,6 +121,16 @@ namespace ICSharpCode.ILSpy.TextView @@ -116,6 +121,16 @@ namespace ICSharpCode.ILSpy.TextView
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
}
void RemoveEditCommand(RoutedUICommand command)
{
var handler = textEditor.TextArea.DefaultInputHandler.Editing;
var inputBinding = handler.InputBindings.FirstOrDefault(b => b.Command == command);
if (inputBinding != null)
handler.InputBindings.Remove(inputBinding);
var commandBinding = handler.CommandBindings.FirstOrDefault(b => b.Command == command);
if (commandBinding != null)
handler.CommandBindings.Remove(commandBinding);
}
#endregion
#region Line margin

2
ILSpy/TextView/DecompilerTextView.xaml

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
<Grid>
<Border BorderThickness="1,1,0,1" BorderBrush="#FF828790">
<Grid>
<ae:TextEditor Name="textEditor" FontFamily="Consolas" FontSize="10pt" IsReadOnly="True"
<ae:TextEditor Name="textEditor" AutomationProperties.Name="Decompilation" FontFamily="Consolas" FontSize="10pt" IsReadOnly="True"
Background="{DynamicResource {x:Static SystemColors.InfoBrushKey}}"
Foreground="{DynamicResource {x:Static SystemColors.InfoTextBrushKey}}">
<ae:TextEditor.Resources>

2
ILSpy/TreeNodes/Analyzer/AnalyzeContextMenuEntry.cs

@ -21,7 +21,7 @@ using Mono.Cecil; @@ -21,7 +21,7 @@ using Mono.Cecil;
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
{
[ExportContextMenuEntryAttribute(Header = "Analyze", Icon = "images/Search.png")]
[ExportContextMenuEntry(Header = "Analyze", Icon = "images/Search.png", Category = "Analyze", Order = 100)]
internal sealed class AnalyzeContextMenuEntry : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)

2
ILSpy/TreeNodes/Analyzer/RemoveAnalyzeContextMenuEntry.cs

@ -20,7 +20,7 @@ using System.Linq; @@ -20,7 +20,7 @@ using System.Linq;
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
{
[ExportContextMenuEntryAttribute(Header = "Remove", Icon = "images/Delete.png")]
[ExportContextMenuEntry(Header = "Remove", Icon = "images/Delete.png", Category = "Analyze", Order = 200)]
internal sealed class RemoveAnalyzeContextMenuEntry : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)

6
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -295,7 +295,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -295,7 +295,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
[ExportContextMenuEntryAttribute(Header = "_Remove", Icon = "images/Delete.png")]
[ExportContextMenuEntry(Header = "_Remove", Icon = "images/Delete.png")]
sealed class RemoveAssembly : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
@ -352,7 +352,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -352,7 +352,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
[ExportContextMenuEntry(Header = "_Load Dependencies")]
[ExportContextMenuEntry(Header = "_Load Dependencies", Category = "Dependencies")]
sealed class LoadDependencies : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
@ -383,7 +383,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -383,7 +383,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
[ExportContextMenuEntry(Header = "_Add To Main List")]
[ExportContextMenuEntry(Header = "_Add To Main List", Category = "Dependencies")]
sealed class AddToMainList : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)

42
ILSpy/TreeNodes/CopyFullyQualifiedTypeNameContextMenuEntry.cs

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
using System.Windows;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.TreeNodes
{
[ExportContextMenuEntry(Header = "Copy FQ Name", Icon = "images/Copy.png", Order = 9999)]
public class CopyFullyQualifiedTypeNameContextMenuEntry : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
{
return GetTypeNodeFromContext(context) != null;
}
public bool IsEnabled(TextViewContext context) => true;
public void Execute(TextViewContext context)
{
var typeDefinition = GetTypeNodeFromContext(context)?.TypeDefinition;
if (typeDefinition == null) return;
Clipboard.SetText(GetFullyQualifiedName(typeDefinition));
}
private TypeTreeNode GetTypeNodeFromContext(TextViewContext context)
{
return context.SelectedTreeNodes?.Length == 1 ? context.SelectedTreeNodes[0] as TypeTreeNode : null;
}
/// <summary>
/// Resolve full type name using .NET type representation for nested types.
/// </summary>
private string GetFullyQualifiedName(TypeDefinition typeDefinition)
{
if (typeDefinition.IsNested)
{
return $"{GetFullyQualifiedName(typeDefinition.DeclaringType)}+{typeDefinition.Name}";
}
return $"{typeDefinition.Namespace}.{typeDefinition.Name}";
}
}
}

4
ILSpy/TreeNodes/MethodTreeNode.cs

@ -71,7 +71,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -71,7 +71,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
b.Append(") : ");
b.Append(language.TypeToString(method.ReturnType, false, method.MethodReturnType));
b.Append(method.MetadataToken.ToSuffixString());
return HighlightSearchMatch(method.Name, b.ToString());
return HighlightSearchMatch(language.FormatMethodName(method), b.ToString());
}
public override object Icon
@ -95,7 +95,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -95,7 +95,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
if (method.IsSpecialName &&
(method.Name == ".ctor" || method.Name == ".cctor")) {
return Images.GetIcon(MemberIcon.Constructor, GetOverlayIcon(method.Attributes), false);
return Images.GetIcon(MemberIcon.Constructor, GetOverlayIcon(method.Attributes), method.IsStatic);
}
if (method.HasPInvokeInfo)

33
ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

@ -27,6 +27,8 @@ using System.Resources; @@ -27,6 +27,8 @@ using System.Resources;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using Microsoft.Win32;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.TreeNodes
@ -112,6 +114,37 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -112,6 +114,37 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
public override bool Save(DecompilerTextView textView)
{
EmbeddedResource er = this.Resource as EmbeddedResource;
if (er != null) {
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = DecompilerTextView.CleanUpName(er.Name);
dlg.Filter = "Resources file (*.resources)|*.resources|Resource XML file|*.resx";
if (dlg.ShowDialog() == true) {
Stream s = er.GetResourceStream();
s.Position = 0;
switch (dlg.FilterIndex) {
case 1:
using (var fs = dlg.OpenFile()) {
s.CopyTo(fs);
}
break;
case 2:
var reader = new ResourceReader(s);
using (var writer = new ResXResourceWriter(dlg.OpenFile())) {
foreach (DictionaryEntry entry in reader) {
writer.AddResource(entry.Key.ToString(), entry.Value);
}
}
break;
}
}
return true;
}
return false;
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
EnsureLazyChildren();

2
ILSpy/TreeNodes/SearchMsdnContextMenuEntry.cs

@ -21,7 +21,7 @@ using System.Diagnostics; @@ -21,7 +21,7 @@ using System.Diagnostics;
namespace ICSharpCode.ILSpy.TreeNodes
{
[ExportContextMenuEntryAttribute(Header = "Search MSDN...", Icon = "images/Search.png")]
[ExportContextMenuEntry(Header = "Search MSDN...", Icon = "images/SearchMsdn.png", Order = 9999)]
internal sealed class SearchMsdnContextMenuEntry : IContextMenuEntry
{
private static string msdnAddress = "http://msdn.microsoft.com/en-us/library/{0}";

8
ILSpy/VB/VBLanguage.cs

@ -401,6 +401,14 @@ namespace ICSharpCode.ILSpy.VB @@ -401,6 +401,14 @@ namespace ICSharpCode.ILSpy.VB
});
}
public override string FormatMethodName(MethodDefinition method)
{
if (method == null)
throw new ArgumentNullException("method");
return (method.IsConstructor) ? method.DeclaringType.Name : method.Name;
}
public override string FormatTypeName(TypeDefinition type)
{
if (type == null)

6
SharpTreeView/ICSharpCode.TreeView.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
@ -31,6 +31,8 @@ @@ -31,6 +31,8 @@
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Xaml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="UIAutomationTypes" />
<Reference Include="WindowsBase" />
</ItemGroup>
@ -58,8 +60,10 @@ @@ -58,8 +60,10 @@
<Compile Include="SharpTreeNodeCollection.cs" />
<Compile Include="SharpTreeNodeView.cs" />
<Compile Include="SharpTreeView.cs" />
<Compile Include="SharpTreeViewAutomationPeer.cs" />
<Compile Include="SharpTreeViewItem.cs" />
<Compile Include="SharpTreeViewTextSearch.cs" />
<Compile Include="SharpTreeViewItemAutomationPeer.cs" />
<Compile Include="TreeFlattener.cs" />
<Compile Include="TreeTraversal.cs" />
</ItemGroup>

4
SharpTreeView/SharpTreeView.cs

@ -362,6 +362,10 @@ namespace ICSharpCode.TreeView @@ -362,6 +362,10 @@ namespace ICSharpCode.TreeView
return null;
}
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
{
return new SharpTreeViewAutomationPeer(this);
}
#region Track selection
protected override void OnSelectionChanged(SelectionChangedEventArgs e)

21
SharpTreeView/SharpTreeViewAutomationPeer.cs

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
namespace ICSharpCode.TreeView
{
class SharpTreeViewAutomationPeer : FrameworkElementAutomationPeer
{
internal SharpTreeViewAutomationPeer(SharpTreeView owner ): base(owner)
{
}
//private SharpTreeView SharpTreeView { get { return (SharpTreeView)base.Owner; } }
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Tree;
}
}
}

5
SharpTreeView/SharpTreeViewItem.cs

@ -40,6 +40,11 @@ namespace ICSharpCode.TreeView @@ -40,6 +40,11 @@ namespace ICSharpCode.TreeView
}
}
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
{
return new SharpTreeViewItemAutomationPeer(this);
}
#region Mouse
Point startPoint;

77
SharpTreeView/SharpTreeViewItemAutomationPeer.cs

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
namespace ICSharpCode.TreeView
{
class SharpTreeViewItemAutomationPeer : FrameworkElementAutomationPeer, IExpandCollapseProvider
{
internal SharpTreeViewItemAutomationPeer(SharpTreeViewItem owner)
: base(owner)
{
SharpTreeViewItem.DataContextChanged += OnDataContextChanged;
SharpTreeNode node = SharpTreeViewItem.DataContext as SharpTreeNode;
if (node == null) return;
node.PropertyChanged += OnPropertyChanged;
}
private SharpTreeViewItem SharpTreeViewItem { get { return (SharpTreeViewItem)base.Owner; } }
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.TreeItem;
}
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.ExpandCollapse)
return this;
return base.GetPattern(patternInterface);
}
public void Collapse()
{
}
public void Expand()
{
}
public ExpandCollapseState ExpandCollapseState {
get {
SharpTreeNode node = SharpTreeViewItem.DataContext as SharpTreeNode;
if (node == null || !node.ShowExpander)
return ExpandCollapseState.LeafNode;
return node.IsExpanded ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed;
}
}
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "IsExpanded") return;
SharpTreeNode node = sender as SharpTreeNode;
if (node == null || node.Children.Count == 0) return;
bool newValue = node.IsExpanded;
bool oldValue = !newValue;
RaisePropertyChangedEvent(
ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty,
oldValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed,
newValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed);
}
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
SharpTreeNode oldNode = e.OldValue as SharpTreeNode;
if (oldNode != null)
oldNode.PropertyChanged -= OnPropertyChanged;
SharpTreeNode newNode = e.NewValue as SharpTreeNode;
if (newNode != null)
newNode.PropertyChanged += OnPropertyChanged;
}
}
}
Loading…
Cancel
Save