Browse Source

Merge branch 'master' into bookmarks

pull/263/head
Ronny Klier 14 years ago
parent
commit
487bc84ac6
  1. 3
      ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  2. 9
      ICSharpCode.Decompiler/Tests/PInvoke.cs
  3. 34
      ILSpy/AssemblyListManager.cs
  4. 34
      ILSpy/Commands/OpenListCommand.cs
  5. 24
      ILSpy/CreateListDialog.xaml
  6. 49
      ILSpy/CreateListDialog.xaml.cs
  7. 12
      ILSpy/ILSpy.csproj
  8. 48
      ILSpy/MainWindow.xaml.cs
  9. 41
      ILSpy/OpenListDialog.xaml
  10. 184
      ILSpy/OpenListDialog.xaml.cs
  11. 18
      ILSpy/TreeNodes/AssemblyTreeNode.cs
  12. 25
      ILSpy/XmlDoc/XmlDocKeyProvider.cs
  13. 33
      NRefactory/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs
  14. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/InsertParenthesesVisitor.cs
  15. 4
      doc/Command Line.txt

3
ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs

@ -1012,7 +1012,8 @@ namespace ICSharpCode.Decompiler.Ast @@ -1012,7 +1012,8 @@ namespace ICSharpCode.Decompiler.Ast
// Convert 'ref' into 'out' where necessary
for (int i = 0; i < methodArgs.Count && i < cecilMethod.Parameters.Count; i++) {
DirectionExpression dir = methodArgs[i] as DirectionExpression;
if (dir != null && cecilMethod.Parameters[i].IsOut)
ParameterDefinition p = cecilMethod.Parameters[i];
if (dir != null && p.IsOut && !p.IsIn)
dir.FieldDirection = FieldDirection.Out;
}
}

9
ICSharpCode.Decompiler/Tests/PInvoke.cs

@ -84,4 +84,13 @@ public class PInvoke @@ -84,4 +84,13 @@ public class PInvoke
public void CustomMarshal2([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "MyCompany.MyMarshaler", MarshalCookie = "Cookie")] object o)
{
}
[DllImport("ws2_32.dll", SetLastError = true)]
internal static extern IntPtr ioctlsocket([In] IntPtr socketHandle, [In] int cmd, [In] [Out] ref int argp);
public void CallMethodWithInOutParameter()
{
int num = 0;
PInvoke.ioctlsocket(IntPtr.Zero, 0, ref num);
}
}

34
ILSpy/AssemblyListManager.cs

@ -90,5 +90,39 @@ namespace ICSharpCode.ILSpy @@ -90,5 +90,39 @@ namespace ICSharpCode.ILSpy
doc.Add(list.SaveAsXml());
});
}
public bool CreateList(AssemblyList list)
{
if (!AssemblyLists.Contains(list.ListName))
{
AssemblyLists.Add(list.ListName);
SaveList(list);
return true;
}
return false;
}
public bool DeleteList(string Name)
{
if (AssemblyLists.Contains(Name))
{
AssemblyLists.Remove(Name);
ILSpySettings.Update(
delegate(XElement root)
{
XElement doc = root.Element("AssemblyLists");
if (doc == null)
{
return;
}
XElement listElement = doc.Elements("List").FirstOrDefault(e => (string)e.Attribute("name") == Name);
if (listElement != null)
listElement.Remove();
});
return true;
}
return false;
}
}
}

34
ILSpy/Commands/OpenListCommand.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
// Copyright (c) 2011 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:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(Menu = "_File", Header = "Open _List", MenuIcon = "Images/AssemblyList.png", MenuCategory = "Open", MenuOrder = 1.7)]
sealed class OpenListCommand : SimpleCommand
{
public override void Execute(object parameter)
{
OpenListDialog dlg = new OpenListDialog();
dlg.Owner = MainWindow.Instance;
if (dlg.ShowDialog() == true)
MainWindow.Instance.ShowAssemblyList(dlg.SelectedListName);
}
}
}

24
ILSpy/CreateListDialog.xaml

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
<Window
x:Class="ICSharpCode.ILSpy.CreateListDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
Title="New list"
Style="{DynamicResource DialogWindow}"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Width="300"
Height="150"
FocusManager.FocusedElement="{Binding ElementName=listView}">
<Grid Margin="12,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<Label>Enter a list name:</Label>
<TextBox Margin="8,8" Name="ListName" TextChanged="TextBox_TextChanged"></TextBox>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="8,0">
<Button IsDefault="True" Margin="2,0" IsEnabled="False" Name="okButton" Click="OKButton_Click">Create</Button>
<Button IsCancel="True" Margin="2,0">Cancel</Button>
</StackPanel>
</Grid>
</Window>

49
ILSpy/CreateListDialog.xaml.cs

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ICSharpCode.ILSpy
{
/// <summary>
/// Interaction logic for Create.xaml
/// </summary>
public partial class CreateListDialog : Window
{
public CreateListDialog()
{
InitializeComponent();
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
okButton.IsEnabled = !string.IsNullOrWhiteSpace(ListName.Text);
}
private void OKButton_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrWhiteSpace(ListName.Text))
{
this.DialogResult = true;
}
}
public string NewListName
{
get
{
return ListName.Text;
}
}
}
}

12
ILSpy/ILSpy.csproj

@ -102,11 +102,15 @@ @@ -102,11 +102,15 @@
<Compile Include="CommandLineArguments.cs" />
<Compile Include="Commands\ExitCommand.cs" />
<Compile Include="Commands\CommandWrapper.cs" />
<Compile Include="Commands\OpenListCommand.cs" />
<Compile Include="Controls\DockedPane.cs" />
<Compile Include="Commands\DecompileAllCommand.cs" />
<Compile Include="Commands\ExportCommandAttribute.cs" />
<Compile Include="Controls\SearchBox.cs" />
<Compile Include="Controls\SortableGridViewColumn.cs" />
<Compile Include="CreateListDialog.xaml.cs">
<DependentUpon>CreateListDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Languages\CSharpLanguage.cs" />
<Compile Include="DecompilationOptions.cs" />
<Compile Include="ExtensionMethods.cs" />
@ -140,6 +144,9 @@ @@ -140,6 +144,9 @@
<DependentUpon>ResourceStringTable.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenListDialog.xaml.cs">
<DependentUpon>OpenListDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Options\DecompilerSettingsPanel.xaml.cs">
<DependentUpon>DecompilerSettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
@ -265,8 +272,13 @@ @@ -265,8 +272,13 @@
<Page Include="Controls\SearchBoxStyle.xaml">
<DependentUpon>SearchBox.cs</DependentUpon>
</Page>
<Page Include="CreateListDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml" />
<Page Include="OpenFromGacDialog.xaml" />
<Page Include="OpenListDialog.xaml" />
<Page Include="Options\DecompilerSettingsPanel.xaml" />
<Page Include="Options\DisplaySettingsPanel.xaml" />
<Page Include="Options\OptionsDialog.xaml" />

48
ILSpy/MainWindow.xaml.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.ILSpy @@ -51,7 +51,7 @@ namespace ICSharpCode.ILSpy
ILSpySettings spySettings;
internal SessionSettings sessionSettings;
AssemblyListManager assemblyListManager;
internal AssemblyListManager assemblyListManager;
AssemblyList assemblyList;
AssemblyListTreeNode assemblyListTreeNode;
@ -242,14 +242,29 @@ namespace ICSharpCode.ILSpy @@ -242,14 +242,29 @@ namespace ICSharpCode.ILSpy
{
if (args.NavigateTo != null) {
bool found = false;
foreach (LoadedAssembly asm in commandLineLoadedAssemblies) {
AssemblyDefinition def = asm.AssemblyDefinition;
if (def != null) {
MemberReference mr = XmlDocKeyProvider.FindMemberByKey(def.MainModule, args.NavigateTo);
if (mr != null) {
found = true;
JumpToReference(mr);
break;
if (args.NavigateTo.StartsWith("N:", StringComparison.Ordinal)) {
string namespaceName = args.NavigateTo.Substring(2);
foreach (LoadedAssembly asm in commandLineLoadedAssemblies) {
AssemblyTreeNode asmNode = assemblyListTreeNode.FindAssemblyNode(asm);
if (asmNode != null) {
NamespaceTreeNode nsNode = asmNode.FindNamespaceNode(namespaceName);
if (nsNode != null) {
found = true;
SelectNode(nsNode);
break;
}
}
}
} else {
foreach (LoadedAssembly asm in commandLineLoadedAssemblies) {
AssemblyDefinition def = asm.AssemblyDefinition;
if (def != null) {
MemberReference mr = XmlDocKeyProvider.FindMemberByKey(def.MainModule, args.NavigateTo);
if (mr != null) {
found = true;
JumpToReference(mr);
break;
}
}
}
}
@ -323,6 +338,21 @@ namespace ICSharpCode.ILSpy @@ -323,6 +338,21 @@ namespace ICSharpCode.ILSpy
}
#endregion
public void ShowAssemblyList(string name)
{
ILSpySettings settings = this.spySettings;
if (settings == null)
{
settings = ILSpySettings.Load();
}
AssemblyList list = this.assemblyListManager.LoadList(settings, name);
//Only load a new list when it is a different one
if (list.ListName != CurrentAssemblyList.ListName)
{
ShowAssemblyList(list);
}
}
void ShowAssemblyList(AssemblyList assemblyList)
{
history.Clear();

41
ILSpy/OpenListDialog.xaml

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
<Window
x:Class="ICSharpCode.ILSpy.OpenListDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
Title="Open List"
Style="{DynamicResource DialogWindow}"
WindowStartupLocation="CenterOwner"
ResizeMode="CanResizeWithGrip"
MinWidth="380"
MinHeight="250"
Height="350"
Width="380"
FocusManager.FocusedElement="{Binding ElementName=listView}">
<Grid Margin="12,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<Label>Select a list:</Label>
</StackPanel>
<ListView Name="listView" Grid.Row="1" Margin="0, 8" controls:SortableGridViewColumn.SortMode="Automatic" SelectionChanged="ListView_SelectionChanged"
Loaded="listView_Loaded" SelectionMode="Single">
<ListView.View>
<GridView>
<controls:SortableGridViewColumn x:Name="nameColumn" Header="Name" DisplayMemberBinding="{Binding .}" />
</GridView>
</ListView.View>
</ListView>
<DockPanel Grid.Row="2">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" HorizontalAlignment="Right">
<Button IsDefault="True" Margin="2,0" IsEnabled="False" Name="okButton" Click="OKButton_Click">Open</Button>
<Button IsCancel="True" Margin="2,0">Cancel</Button>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" HorizontalAlignment="Left">
<Button Margin="2,0" Click="CreateButton_Click">Create</Button>
<Button Margin="2,0" IsEnabled="False" Name="removeButton" Click="RemoveButton_Click">Remove</Button>
</StackPanel>
</DockPanel>
</Grid>
</Window>

184
ILSpy/OpenListDialog.xaml.cs

@ -0,0 +1,184 @@ @@ -0,0 +1,184 @@
// Copyright (c) 2011 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:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Windows;
using System.Windows.Controls;
using Mono.Cecil;
namespace ICSharpCode.ILSpy
{
/// <summary>
/// Interaction logic for OpenListDialog.xaml
/// </summary>
public partial class OpenListDialog : Window
{
public const string DotNet4List = ".NET 4 (WPF)";
public const string DotNet35List = ".NET 3.5";
public const string ASPDotNetMVC3List = "ASP.NET (MVC3)";
AssemblyListManager manager;
public OpenListDialog()
{
InitializeComponent();
manager = MainWindow.Instance.assemblyListManager;
}
private void listView_Loaded(object sender, RoutedEventArgs e)
{
listView.ItemsSource = manager.AssemblyLists;
CreateDefaultAssemblyLists();
}
void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
okButton.IsEnabled = listView.SelectedItem != null;
removeButton.IsEnabled = listView.SelectedItem != null;
}
void OKButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
}
public string SelectedListName
{
get
{
return listView.SelectedItem.ToString();
}
}
private void CreateDefaultAssemblyLists()
{
if (!manager.AssemblyLists.Contains(DotNet4List))
{
AssemblyList dotnet4 = new AssemblyList(DotNet4List);
AddToList(dotnet4, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(dotnet4, "PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet4, "PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet4, "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
if (dotnet4.assemblies.Count > 0)
{
manager.CreateList(dotnet4);
}
}
if (!manager.AssemblyLists.Contains(DotNet35List))
{
AssemblyList dotnet35 = new AssemblyList(DotNet35List);
AddToList(dotnet35, "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet35, "PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet35, "WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
if (dotnet35.assemblies.Count > 0)
{
manager.CreateList(dotnet35);
}
}
if (!manager.AssemblyLists.Contains(ASPDotNetMVC3List))
{
AssemblyList mvc = new AssemblyList(ASPDotNetMVC3List);
AddToList(mvc, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
if (mvc.assemblies.Count > 0)
{
manager.CreateList(mvc);
}
}
}
private void AddToList(AssemblyList list, string FullName)
{
AssemblyNameReference reference = AssemblyNameReference.Parse(FullName);
string file = GacInterop.FindAssemblyInNetGac(reference);
if (file != null)
list.OpenAssembly(file);
}
private void CreateButton_Click(object sender, RoutedEventArgs e)
{
CreateListDialog dlg = new CreateListDialog();
dlg.Owner = this;
dlg.Closing += (s, args) =>
{
if (dlg.DialogResult == true)
{
if (manager.AssemblyLists.Contains(dlg.NewListName))
{
args.Cancel = true;
MessageBox.Show("A list with the same name was found.", null, MessageBoxButton.OK);
}
}
};
if (dlg.ShowDialog() == true)
{
manager.CreateList(new AssemblyList(dlg.NewListName));
}
}
private void RemoveButton_Click(object sender, RoutedEventArgs e)
{
if (listView.SelectedItem != null)
manager.DeleteList(listView.SelectedItem.ToString());
}
}
}

18
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -139,6 +139,9 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -139,6 +139,9 @@ namespace ICSharpCode.ILSpy.TreeNodes
get { return true; }
}
/// <summary>
/// Finds the node for a top-level type.
/// </summary>
public TypeTreeNode FindTypeNode(TypeDefinition def)
{
if (def == null)
@ -151,6 +154,21 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -151,6 +154,21 @@ namespace ICSharpCode.ILSpy.TreeNodes
return null;
}
/// <summary>
/// Finds the node for a namespace.
/// </summary>
public NamespaceTreeNode FindNamespaceNode(string namespaceName)
{
if (string.IsNullOrEmpty(namespaceName))
return null;
EnsureLazyChildren();
NamespaceTreeNode node;
if (namespaces.TryGetValue(namespaceName, out node))
return node;
else
return null;
}
public override bool CanDrag(SharpTreeNode[] nodes)
{
return nodes.All(n => n is AssemblyTreeNode);

25
ILSpy/XmlDoc/XmlDocKeyProvider.cs

@ -48,10 +48,7 @@ namespace ICSharpCode.ILSpy.XmlDoc @@ -48,10 +48,7 @@ namespace ICSharpCode.ILSpy.XmlDoc
b.Append("M:");
AppendTypeName(b, member.DeclaringType);
b.Append('.');
if (member.Name == ".ctor")
b.Append("#ctor");
else
b.Append(member.Name);
b.Append(member.Name.Replace('.', '#'));
IList<ParameterDefinition> parameters;
if (member is PropertyDefinition) {
parameters = ((PropertyDefinition)member).Parameters;
@ -162,10 +159,10 @@ namespace ICSharpCode.ILSpy.XmlDoc @@ -162,10 +159,10 @@ namespace ICSharpCode.ILSpy.XmlDoc
static MemberReference FindMember(ModuleDefinition module, string key, Func<TypeDefinition, IEnumerable<MemberReference>> memberSelector)
{
Debug.WriteLine("Looking for member " + key);
int pos = key.IndexOf('(');
int parenPos = key.IndexOf('(');
int dotPos;
if (pos > 0) {
dotPos = key.LastIndexOf('.', pos - 1, pos);
if (parenPos > 0) {
dotPos = key.LastIndexOf('.', parenPos - 1, parenPos);
} else {
dotPos = key.LastIndexOf('.');
}
@ -173,14 +170,24 @@ namespace ICSharpCode.ILSpy.XmlDoc @@ -173,14 +170,24 @@ namespace ICSharpCode.ILSpy.XmlDoc
TypeDefinition type = FindType(module, key.Substring(2, dotPos - 2));
if (type == null)
return null;
Debug.WriteLine("Searching in type " + type.FullName);
string shortName;
if (parenPos > 0) {
shortName = key.Substring(dotPos + 1, parenPos - (dotPos + 1));
} else {
shortName = key.Substring(dotPos + 1);
}
Debug.WriteLine("Searching in type {0} for {1}", type.FullName, shortName);
MemberReference shortNameMatch = null;
foreach (MemberReference member in memberSelector(type)) {
string memberKey = GetKey(member);
Debug.WriteLine(memberKey);
if (memberKey == key)
return member;
if (shortName == member.Name)
shortNameMatch = member;
}
return null;
// if there's no match by ID string (key), return the match by name.
return shortNameMatch;
}
static TypeDefinition FindType(ModuleDefinition module, string name)

33
NRefactory/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs

@ -345,5 +345,38 @@ namespace ICSharpCode.NRefactory.CSharp @@ -345,5 +345,38 @@ namespace ICSharpCode.NRefactory.CSharp
Assert.AreEqual("a && (b || c)", InsertRequired(expr));
Assert.AreEqual("a && (b || c)", InsertReadable(expr));
}
[Test]
public void ArrayCreationInIndexer()
{
Expression expr = new IndexerExpression {
Target = new ArrayCreateExpression {
Type = new PrimitiveType("int"),
Arguments = { new PrimitiveExpression(1) }
},
Arguments = { new PrimitiveExpression(0) }
};
Assert.AreEqual("(new int[1]) [0]", InsertRequired(expr));
Assert.AreEqual("(new int[1]) [0]", InsertReadable(expr));
}
[Test]
public void ArrayCreationWithInitializerInIndexer()
{
Expression expr = new IndexerExpression {
Target = new ArrayCreateExpression {
Type = new PrimitiveType("int"),
Arguments = { new PrimitiveExpression(1) },
Initializer = new ArrayInitializerExpression {
Elements = { new PrimitiveExpression(42) }
}
},
Arguments = { new PrimitiveExpression(0) }
};
Assert.AreEqual("new int[1] { 42 } [0]", InsertRequired(expr));
Assert.AreEqual("(new int[1] { 42 }) [0]", InsertReadable(expr));
}
}
}

5
NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/InsertParenthesesVisitor.cs

@ -132,6 +132,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -132,6 +132,11 @@ namespace ICSharpCode.NRefactory.CSharp
public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
{
ParenthesizeIfRequired(indexerExpression.Target, Primary);
ArrayCreateExpression ace = indexerExpression.Target as ArrayCreateExpression;
if (ace != null && (InsertParenthesesForReadability || ace.Initializer.IsNull)) {
// require parentheses for "(new int[1])[0]"
Parenthesize(indexerExpression.Target);
}
return base.VisitIndexerExpression(indexerExpression, data);
}

4
doc/Command Line.txt

@ -25,9 +25,11 @@ Available options: @@ -25,9 +25,11 @@ Available options:
/clearList Clears the assembly list before loading the specified assemblies.
[Note: Assembly Lists are not yet implemented]
/navigateTo:tag Navigates to the member specified by the given XML documentation tag.
/navigateTo:tag Navigates to the member specified by the given ID string.
The member is searched for only in the assemblies specified on the command line.
Example: 'ILSpy ILSpy.exe /navigateTo:T:ICSharpCode.ILSpy.CommandLineArguments'
The syntax of ID strings is described in appendix A of the C# language specification.
/language:name Selects the specified language.
Example: 'ILSpy /language:C#' or 'ILSpy /language:IL'

Loading…
Cancel
Save