Browse Source

Most of assembly scout working. Needs resources from Fidalgo, info view browsing via hyperlinks is disabled, and speed improvements required.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@629 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 20 years ago
parent
commit
34e2d508a1
  1. 6
      src/AddIns/DisplayBindings/AssemblyScout/AssemblyScout.sln
  2. 47
      src/AddIns/DisplayBindings/AssemblyScout/Project/AssemblyScout.addin
  3. 61
      src/AddIns/DisplayBindings/AssemblyScout/Project/AssemblyScout.csproj
  4. 10
      src/AddIns/DisplayBindings/AssemblyScout/Project/AssemblyScout.csproj.user
  5. 0
      src/AddIns/DisplayBindings/AssemblyScout/Project/Configuration/AssemblyInfo.cs
  6. 4
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyScoutBinding.cs
  7. 2
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyScoutCommands.cs
  8. 4
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyScoutOptionPanel.cs
  9. 60
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyScoutViewContent.cs
  10. 107
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyTree.cs
  11. 11
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/ExtendedPropPanel.cs
  12. 32
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/ILDasmView.cs
  13. 131
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/InfoView.cs
  14. 23
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/Nodes/AssemblyTreeNode.cs
  15. 23
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/Nodes/MemberNode.cs
  16. 9
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/Nodes/ResourceNode.cs
  17. 21
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/Nodes/TypeNode.cs
  18. 33
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SearchPanel.cs
  19. 262
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyAttribute.cs
  20. 484
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyClass.cs
  21. 135
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyEvent.cs
  22. 161
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyField.cs
  23. 158
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyMethod.cs
  24. 83
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyParameter.cs
  25. 184
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyProperty.cs
  26. 225
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyReturnType.cs
  27. 24
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SourceView.cs
  28. 209
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/TempProject.cs
  29. 20
      src/AddIns/DisplayBindings/AssemblyScout/Project/Src/XmlView.cs

6
src/AddIns/DisplayBindings/AssemblyScout/AssemblyScout.sln

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.612
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyScout", "Project\AssemblyScout.csproj", "{DDD402CD-1D04-4E3F-B563-A4CACC500188}"
EndProject
Global
EndGlobal

47
src/AddIns/DisplayBindings/AssemblyScout/Project/AssemblyScout.addin

@ -9,11 +9,56 @@ @@ -9,11 +9,56 @@
<Import assembly="AssemblyScout.dll"/>
</Runtime>
<Path name = "/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id = "AssemblyScout"
insertbefore = "Text"
fileNamePattern = "\.(dll|exe)$"
languagePattern = "^AssemblyBinaryFile$"
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutBinding" />
</Path>
<Path name="/SharpDevelop/Workbench/FileFilter">
<FileFilter id = "Assemblies"
insertbefore="AllFiles"
name = "${res:SharpDevelop.FileFilter.AssemblyFiles}"
extensions = "*.exe;*.dll"/>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/View">
<MenuItem id = "ShowAssemblyScout"
insertafter = "ViewItemsSeparator"
insertbefore = "FullScreen"
label = "Assembly Scout"
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutCommand"/>
</Extension>
</Path>
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<DialogPanel id = "AssemblyScoutOptions"
label = "${res:Dialog.Options.IDEOptions.AssemblyScout.PanelName}"
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutOptionPanel"/>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu">
<Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutViewContent">
<MenuItem id = "AssemblyScout" insertafter="View" insertbefore="Tools" label="${res:Dialog.Options.IDEOptions.AssemblyScout.PanelName}">
<MenuItem id = "LoadAssembly"
label = "${res:ObjectBrowser.Menu.LoadAssembly}"
icon = "Icons.16x16.OpenAssembly"
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadAssemblyCommand"/>
<MenuItem id = "LoadStdAssemblies"
label = "${res:ObjectBrowser.Menu.LoadStd}"
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadStdAssembliesCommand"/>
<MenuItem id = "LoadRefAssemblies"
label = "${res:ObjectBrowser.Menu.LoadRef}"
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadRefAssembliesCommand"/>
<MenuItem id = "AssemblySeparator"
label = "-"/>
<MenuItem id = "AssemblyScoutGoBack"
label = "${res:ObjectBrowser.Menu.GoBack}"
icon = "Icons.16x16.BrowserBefore"
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.BackCommand"/>
</MenuItem>
</Condition>
</Path>
</AddIn>

61
src/AddIns/DisplayBindings/AssemblyScout/Project/AssemblyScout.csproj

@ -34,24 +34,65 @@ @@ -34,24 +34,65 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
<Reference Include="ICSharpCode.SharpAssembly">
<HintPath>..\..\..\..\..\bin\ICSharpCode.SharpAssembly.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.Core">
<HintPath>..\..\..\..\..\bin\ICSharpCode.Core.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop">
<HintPath>..\..\..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="WeifenLuo.WinFormsUI.Docking">
<HintPath>..\..\..\..\..\bin\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="AssemblyScout.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\XmlView.cs" />
<Compile Include="Src\AssemblyScoutBinding.cs" />
<Compile Include="Src\AssemblyScoutCommand.cs" />
<Compile Include="Src\AssemblyScoutCommands.cs" />
<Compile Include="Src\AssemblyScoutOptionPanel.cs" />
<Compile Include="Src\AssemblyScoutViewContent.cs" />
<Compile Include="Src\AssemblyTree.cs" />
<Compile Include="Src\ExtendedPropPanel.cs" />
<Compile Include="Src\ILDasmView.cs" />
<Compile Include="Src\InfoView.cs" />
<Compile Include="Src\SearchPanel.cs" />
<Compile Include="Src\SourceView.cs" />
<Compile Include="Src\TempProject.cs" />
<Compile Include="Src\Nodes\TypeNode.cs" />
<Compile Include="Src\Nodes\AssemblyTreeNode.cs" />
<Compile Include="Src\Nodes\FolderNode.cs" />
<Compile Include="Src\Nodes\MemberNode.cs" />
<Compile Include="Src\Nodes\MethodNode.cs" />
<Compile Include="Src\Nodes\ResourceNode.cs" />
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyClass.cs" />
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyEvent.cs" />
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyField.cs" />
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyMethod.cs" />
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyParameter.cs" />
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyProperty.cs" />
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyReturnType.cs" />
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<Folder Include="Configuration" />
<Folder Include="Src" />
<Folder Include="Src\Nodes" />
<Folder Include="Resources" />
<Folder Include="Src\SharpAssemblyLayer" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

10
src/AddIns/DisplayBindings/AssemblyScout/Project/AssemblyScout.csproj.user

@ -1,4 +1,9 @@ @@ -1,4 +1,9 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastOpenVersion>8.0.50215</LastOpenVersion>
<ProjectView>ShowAllFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram>
<StartAction>Program</StartAction>
@ -6,9 +11,4 @@ @@ -6,9 +11,4 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup>
<PropertyGroup>
<LastOpenVersion>8.0.50215</LastOpenVersion>
<ProjectView>ShowAllFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
</Project>

0
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyInfo.cs → src/AddIns/DisplayBindings/AssemblyScout/Project/Configuration/AssemblyInfo.cs

4
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyScoutBinding.cs

@ -12,9 +12,9 @@ using System.Resources; @@ -12,9 +12,9 @@ using System.Resources;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Internal.Project;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Gui;
using UI = WeifenLuo.WinFormsUI;
//using UI = WeifenLuo.WinFormsUI;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{

2
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyScoutCommands.cs

@ -12,7 +12,7 @@ using System.Resources; @@ -12,7 +12,7 @@ using System.Resources;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Internal.Project;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Commands;

4
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyScoutOptionPanel.cs

@ -15,10 +15,6 @@ using System.Windows.Forms; @@ -15,10 +15,6 @@ using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Internal.ExternalTool;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout

60
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyScoutViewContent.cs

@ -12,12 +12,10 @@ using System.Resources; @@ -12,12 +12,10 @@ using System.Resources;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Internal.Project;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.Core;
using UI = WeifenLuo.WinFormsUI;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
@ -25,9 +23,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -25,9 +23,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
// AssemblyScoutViewContent Class
///////////////////////////////////////////
public class AssemblyScoutViewContent : AbstractViewContent
{
public ResourceService ress = (ResourceService)ServiceManager.Services.GetService(typeof(ResourceService));
{
public UI.DockPanel leftTabs, rightTabs;
Control control = null;
AssemblyTree tree = null;
@ -70,14 +66,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -70,14 +66,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
}
}
public override bool IsDirty {
get {
return false;
}
set {
}
}
public override bool IsViewOnly {
get {
return true;
@ -92,7 +80,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -92,7 +80,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
set {
workbenchWindow = value;
if (FileName == "") {
workbenchWindow.Title = ress.GetString("ObjectBrowser.AssemblyScout");
workbenchWindow.Title = StringParser.Parse("${res:ObjectBrowser.AssemblyScout}");
} else {
workbenchWindow.Title = FileName;
}
@ -128,7 +116,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -128,7 +116,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
return false;
}
public IViewContent CreateContentForFile(string fileName)
{
Load(fileName);
@ -163,8 +150,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -163,8 +150,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
this.TitleName = Path.GetFileName(filename);
}
public AssemblyScoutViewContent()
{
Panel panel = new Panel();
@ -180,7 +165,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -180,7 +165,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
this.tree = assemblyTree;
UI.DockContent treeviewpage = new UI.DockContent();
treeviewpage.Text = ress.GetString("ObjectBrowser.Tree");
treeviewpage.Text = StringParser.Parse("${res:ObjectBrowser.Tree}");
treeviewpage.Icon = ResourceService.GetIcon("Icons.16x16.Class");
treeviewpage.DockPadding.All = 8;
treeviewpage.Controls.Add(assemblyTree);
@ -189,7 +174,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -189,7 +174,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
treeviewpage.Show(leftTabs);
UI.DockContent indexviewpage = new UI.DockContent();
indexviewpage.Text = ress.GetString("ObjectBrowser.Search");
indexviewpage.Text = StringParser.Parse("${res:ObjectBrowser.Search}");
indexviewpage.Icon = ResourceService.GetIcon("Icons.16x16.FindIcon");
SearchPanel SearchPanel = new SearchPanel(assemblyTree);
SearchPanel.ParentDisplayInfo = this;
@ -215,7 +200,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -215,7 +200,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
rightTabs.AllowRedocking = false;
UI.DockContent memberpage = new UI.DockContent();
memberpage.Text = ress.GetString("ObjectBrowser.Info");
memberpage.Text = StringParser.Parse("${res:ObjectBrowser.Info}");
memberpage.Icon = ResourceService.GetIcon("Icons.16x16.Information");
memberpage.DockPadding.All = 8;
memberpage.Controls.Add(new InfoView(assemblyTree));
@ -224,7 +209,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -224,7 +209,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
memberpage.Show(rightTabs);
UI.DockContent ildasmviewpage = new UI.DockContent();
ildasmviewpage.Text = ress.GetString("ObjectBrowser.Disasm");
ildasmviewpage.Text = StringParser.Parse("${res:ObjectBrowser.Disasm}");
ildasmviewpage.Icon = ResourceService.GetIcon("Icons.16x16.ILDasm");
ildasmviewpage.DockPadding.All = 8;
ildasmviewpage.Controls.Add(new ILDasmView(assemblyTree));
@ -233,7 +218,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -233,7 +218,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ildasmviewpage.Show(rightTabs);
UI.DockContent sourceviewpage = new UI.DockContent();
sourceviewpage.Text = ress.GetString("ObjectBrowser.Source");
sourceviewpage.Text = StringParser.Parse("${res:ObjectBrowser.Source}");
sourceviewpage.Icon = ResourceService.GetIcon("Icons.16x16.TextFileIcon");
sourceviewpage.DockPadding.All = 8;
sourceviewpage.Controls.Add(new SourceView(assemblyTree));
@ -242,7 +227,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -242,7 +227,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
sourceviewpage.Show(rightTabs);
UI.DockContent xmlviewpage = new UI.DockContent();
xmlviewpage.Text = ress.GetString("ObjectBrowser.XML");
xmlviewpage.Text = StringParser.Parse("${res:ObjectBrowser.XML}");
xmlviewpage.Icon = ResourceService.GetIcon("Icons.16x16.XMLFileIcon");
xmlviewpage.DockPadding.All = 8;
xmlviewpage.Controls.Add(new XmlView(assemblyTree));
@ -251,7 +236,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -251,7 +236,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
xmlviewpage.Show(rightTabs);
UI.DockContent extproppage = new UI.DockContent();
extproppage.Text = ress.GetString("ObjectBrowser.Extended");
extproppage.Text = StringParser.Parse("${res:ObjectBrowser.Extended}");
extproppage.Icon = ResourceService.GetIcon("Icons.16x16.Property");
extproppage.DockPadding.All = 8;
extproppage.Controls.Add(new ExtendedPropsPanel(assemblyTree));
@ -267,7 +252,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -267,7 +252,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
memberpage.Activate();
this.control = panel;
this.TitleName = ress.GetString("ObjectBrowser.AssemblyScout");
this.TitleName = StringParser.Parse("${res:ObjectBrowser.AssemblyScout}");
}
public void LoadStdAssemblies() {
@ -284,23 +269,20 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -284,23 +269,20 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
}
public void LoadRefAssemblies() {
IProjectService projectService = (IProjectService)ServiceManager.Services.GetService(typeof(IProjectService));
try {
if (projectService.CurrentSelectedProject == null) return;
foreach(ProjectReference pr in projectService.CurrentSelectedProject.ProjectReferences) {
if (pr.ReferenceType == ReferenceType.Project || pr.ReferenceType == ReferenceType.Typelib) continue;
if (!tree.IsAssemblyLoaded(pr.GetReferencedFileName(null))) {
try {
tree.LoadFile(pr.GetReferencedFileName(null));
} catch (Exception) {
//MessageBox.Show("Object Browser error:\nError loading assembly " + pr.GetReferencedFileName(null) + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
if (ProjectService.CurrentProject == null) return;
foreach(ProjectItem item in ProjectService.CurrentProject.Items) {
if (item.ItemType == ItemType.Reference) {
if (!tree.IsAssemblyLoaded(item.FileName)) {
try {
tree.LoadFile(item.FileName);
} catch (Exception) {
//MessageBox.Show("Object Browser error:\nError loading assembly " + pr.GetReferencedFileName(null) + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
} catch (Exception) {}
}
}
}

107
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/AssemblyTree.cs

@ -20,23 +20,20 @@ using Microsoft.Win32; @@ -20,23 +20,20 @@ using Microsoft.Win32;
using System.Diagnostics;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Internal.Project.Collections;
using ICSharpCode.SharpDevelop.Internal.Project;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Internal.ExternalTool;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
public class AssemblyTree : TreeView
{
static AmbienceService AmbienceService = (AmbienceService)ServiceManager.Services.GetService(typeof(AmbienceService));
public static IAmbience CurrentAmbience = AmbienceService.CurrentAmbience;
public ResourceService ress = (ResourceService)ServiceManager.Services.GetService(typeof(ResourceService));
ArrayList assemblies = new ArrayList();
AssemblyScoutViewContent _parent;
PropertyService propSvc;
public ShowOptions showInternalTypes, showInternalMembers;
public ShowOptions showPrivateTypes, showPrivateMembers;
@ -45,8 +42,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -45,8 +42,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
MenuItem mnuBack;
MenuItem mnuLoadAsm, mnuLoadStd, mnuLoadRef;
//MenuItem mnuShowPrivTypes, mnuShowIntTypes;
//MenuItem mnuShowPrivMem, mnuShowIntMem, mnuShowSpecial;
MenuItem mnuRemAsm, mnuCopyTree, mnuSaveRes, mnuJump, mnuOpenRef, mnuDisAsm;
Stack history = new Stack();
@ -63,33 +58,25 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -63,33 +58,25 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
Dock = DockStyle.Fill;
string resPrefix = "ObjectBrowser.Menu.";
propSvc = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
this.ImageList = ClassBrowserIconService.ImageList;
LabelEdit = false;
HotTracking = false;
AllowDrop = true;
HideSelection = false;
//Sorted = true;
mnuBack = new MenuItem(ress.GetString(resPrefix + "GoBack"), new EventHandler(Back));
mnuLoadAsm = new MenuItem(ress.GetString(resPrefix + "LoadAssembly"), new EventHandler(LoadAssembly));
mnuLoadStd = new MenuItem(ress.GetString(resPrefix + "LoadStd"), new EventHandler(LoadStdAssemblies));
mnuLoadRef = new MenuItem(ress.GetString(resPrefix + "LoadRef"), new EventHandler(LoadRefAssemblies));
//mnuShowPrivTypes = new MenuItem(ress.GetString(resPrefix + "ShowPrivTypes"), new EventHandler(ShowPrivTypesEvt));
//mnuShowIntTypes = new MenuItem(ress.GetString(resPrefix + "ShowIntTypes"), new EventHandler(ShowIntTypesEvt));
//mnuShowPrivMem = new MenuItem(ress.GetString(resPrefix + "ShowPrivMem"), new EventHandler(ShowPrivMemEvt));
//mnuShowIntMem = new MenuItem(ress.GetString(resPrefix + "ShowIntMem"), new EventHandler(ShowIntMemEvt));
//mnuShowSpecial = new MenuItem(ress.GetString(resPrefix + "ShowSpecial"), new EventHandler(ShowSpecialEvt));
mnuRemAsm = new MenuItem(ress.GetString(resPrefix + "RemoveAsm"), new EventHandler(RemoveAssembly));
mnuCopyTree = new MenuItem(ress.GetString(resPrefix + "CopyTree"), new EventHandler(CopyAssemblyTree));
mnuSaveRes = new MenuItem(ress.GetString(resPrefix + "SaveRes"), new EventHandler(SaveCurrentResource));
mnuJump = new MenuItem(ress.GetString(resPrefix + "JumpType"), new EventHandler(JumpLink));
mnuOpenRef = new MenuItem(ress.GetString(resPrefix + "OpenRef"), new EventHandler(OpenReference));
mnuDisAsm = new MenuItem(ress.GetString(resPrefix + "DisasmToFile"), new EventHandler(DisAssembly));
mnuBack = new MenuItem(StringParser.Parse("${res:" + resPrefix + "GoBack}"), new EventHandler(Back));
mnuLoadAsm = new MenuItem(StringParser.Parse("${res:" + resPrefix + "LoadAssembly}"), new EventHandler(LoadAssembly));
mnuLoadStd = new MenuItem(StringParser.Parse("${res:" + resPrefix + "LoadStd}"), new EventHandler(LoadStdAssemblies));
mnuLoadRef = new MenuItem(StringParser.Parse("${res:" + resPrefix + "LoadRef}"), new EventHandler(LoadRefAssemblies));
mnuRemAsm = new MenuItem(StringParser.Parse("${res:" + resPrefix + "RemoveAsm}"), new EventHandler(RemoveAssembly));
mnuCopyTree = new MenuItem(StringParser.Parse("${res:" + resPrefix + "CopyTree}"), new EventHandler(CopyAssemblyTree));
mnuSaveRes = new MenuItem(StringParser.Parse("${res:" + resPrefix + "SaveRes}"), new EventHandler(SaveCurrentResource));
mnuJump = new MenuItem(StringParser.Parse("${res:" + resPrefix + "JumpType}"), new EventHandler(JumpLink));
mnuOpenRef = new MenuItem(StringParser.Parse("${res:" + resPrefix + "OpenRef}"), new EventHandler(OpenReference));
mnuDisAsm = new MenuItem(StringParser.Parse("${res:" + resPrefix + "DisasmToFile}"), new EventHandler(DisAssembly));
ContextMenu = new ContextMenu(new MenuItem[] {
mnuBack,
@ -98,13 +85,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -98,13 +85,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
mnuLoadStd,
mnuLoadRef,
new MenuItem("-"),
// mnuShowPrivTypes,
// mnuShowIntTypes,
// new MenuItem("-"),
// mnuShowPrivMem,
// mnuShowIntMem,
// mnuShowSpecial,
// new MenuItem("-"),
mnuRemAsm,
mnuCopyTree,
mnuSaveRes,
@ -113,11 +93,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -113,11 +93,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
mnuDisAsm
});
showPrivateTypes = (ShowOptions)propSvc.Get("AddIns.AssemblyScout.privateTypesBox", 1);
showInternalTypes = (ShowOptions)propSvc.Get("AddIns.AssemblyScout.internalTypesBox", 1);
showPrivateMembers = (ShowOptions)propSvc.Get("AddIns.AssemblyScout.privateMembersBox", 1);
showInternalMembers = (ShowOptions)propSvc.Get("AddIns.AssemblyScout.internalMembersBox", 1);
showSpecial = propSvc.Get("AddIns.AssemblyScout.ShowSpecialMethods", false);
showPrivateTypes = (ShowOptions)PropertyService.Get("AddIns.AssemblyScout.privateTypesBox", 1);
showInternalTypes = (ShowOptions)PropertyService.Get("AddIns.AssemblyScout.internalTypesBox", 1);
showPrivateMembers = (ShowOptions)PropertyService.Get("AddIns.AssemblyScout.privateMembersBox", 1);
showInternalMembers = (ShowOptions)PropertyService.Get("AddIns.AssemblyScout.internalMembersBox", 1);
showSpecial = PropertyService.Get("AddIns.AssemblyScout.ShowSpecialMethods", false);
_parent = parent;
}
@ -201,8 +181,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -201,8 +181,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
public void GoToMember(IMember member)
{
string paramtext = "";
TypeNode typenode = GetTypeNode((SA.SharpAssembly)member.DeclaringType.DeclaredIn, member.DeclaringType.Namespace, member.DeclaringType.FullyQualifiedName);
SharpAssemblyClass declaringType = member.DeclaringType as SharpAssemblyClass;
TypeNode typenode = GetTypeNode((SA.SharpAssembly)declaringType.DeclaredIn, declaringType.Namespace, declaringType.FullyQualifiedName);
if (typenode == null) return;
bool isEnum = false;
@ -280,7 +260,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -280,7 +260,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
public void GoToType(IClass type)
{
AssemblyTreeNode node = GetTypeNode((SA.SharpAssembly)type.DeclaredIn, type.Namespace, type.FullyQualifiedName);
AssemblyTreeNode node = GetTypeNode((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn, type.Namespace, type.FullyQualifiedName);
if (node == null) {
Console.WriteLine("No node for type found");
return;
@ -292,7 +272,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -292,7 +272,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
public void GoToType(IReturnType type)
{
AssemblyTreeNode node = GetTypeNode((SA.SharpAssembly)type.DeclaredIn, type.Namespace, type.FullyQualifiedName);
AssemblyTreeNode node = GetTypeNode((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn, type.Namespace, type.FullyQualifiedName);
if (node == null) return;
node.EnsureVisible();
@ -335,7 +315,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -335,7 +315,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
AddAssembly(SA.SharpAssembly.Load(attr.RefName.FullName, System.IO.Path.GetDirectoryName(attr.Assembly.Location)));
OpenAssemblyByName(attr);
} catch(Exception ex) {
MessageBox.Show(String.Format(ress.GetString("ObjectBrowser.LoadError"), attr.RefName.Name, ex.Message), ress.GetString("Global.ErrorText"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
MessageBox.Show(String.Format(StringParser.Parse("${res:ObjectBrowser.LoadError}"), attr.RefName.Name, ex.Message), StringParser.Parse("${res:Global.ErrorText}"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
@ -396,13 +376,12 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -396,13 +376,12 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
using (SelectReferenceDialog selDialog = new SelectReferenceDialog(new TempProject())) {
if (selDialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
foreach (ProjectReference refInfo in selDialog.ReferenceInformations) {
if (refInfo.ReferenceType == ReferenceType.Typelib) continue;
if (refInfo.ReferenceType == ReferenceType.Project) continue;
if (!IsAssemblyLoaded(refInfo.GetReferencedFileName(null))) {
foreach (ProjectItem item in selDialog.ReferenceInformations) {
if (item.ItemType != ItemType.Reference) continue;
if (!IsAssemblyLoaded(item.FileName)) {
try {
LoadFile(refInfo.GetReferencedFileName(null));
LoadFile(item.FileName);
} catch (Exception) {}
}
}
@ -423,7 +402,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -423,7 +402,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
void ShowPrivTypesEvt(object sender, EventArgs e)
{
showPrivateTypes = !showPrivateTypes;
propSvc.Set("ObjectBrowser.ShowPrivTypes", showPrivateTypes);
PropertyService.Set("ObjectBrowser.ShowPrivTypes", showPrivateTypes);
mnuShowPrivTypes.Checked = showPrivateTypes;
RePopulateTreeView();
}
@ -431,7 +410,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -431,7 +410,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
void ShowIntTypesEvt(object sender, EventArgs e)
{
showInternalTypes = !showInternalTypes;
propSvc.Set("ObjectBrowser.ShowIntTypes", showInternalTypes);
PropertyService.Set("ObjectBrowser.ShowIntTypes", showInternalTypes);
mnuShowIntTypes.Checked = showInternalTypes;
RePopulateTreeView();
}
@ -439,7 +418,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -439,7 +418,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
void ShowPrivMemEvt(object sender, EventArgs e)
{
showPrivateMembers = !showPrivateMembers;
propSvc.Set("ObjectBrowser.ShowPrivMembers", showPrivateMembers);
PropertyService.Set("ObjectBrowser.ShowPrivMembers", showPrivateMembers);
mnuShowPrivMem.Checked = showPrivateMembers;
RePopulateTreeView();
}
@ -447,7 +426,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -447,7 +426,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
void ShowIntMemEvt(object sender, EventArgs e)
{
showInternalMembers = !showInternalMembers;
propSvc.Set("ObjectBrowser.ShowIntMembers", showInternalMembers);
PropertyService.Set("ObjectBrowser.ShowIntMembers", showInternalMembers);
mnuShowIntMem.Checked = showInternalMembers;
RePopulateTreeView();
}
@ -455,7 +434,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -455,7 +434,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
void ShowSpecialEvt(object sender, EventArgs e)
{
showSpecial = !showSpecial;
propSvc.Set("ObjectBrowser.ShowSpecialMethods", showSpecial);
PropertyService.Set("ObjectBrowser.ShowSpecialMethods", showSpecial);
mnuShowSpecial.Checked = showSpecial;
RePopulateTreeView();
}
@ -514,11 +493,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -514,11 +493,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
try {
string args = '"' + asm.Location + "\" /NOBAR /OUT=\"" + sdialog.FileName + "\" /ALL ";
RegistryKey regKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\.NETFramework");
string cmd = (string)regKey.GetValue("sdkInstallRoot");
if (cmd == null) cmd = (string)regKey.GetValue("sdkInstallRootv1.1");
ProcessStartInfo psi = new ProcessStartInfo(FileUtility.GetDirectoryNameWithSeparator(cmd) +
"bin\\ildasm.exe", args);
ProcessStartInfo psi = new ProcessStartInfo(Path.Combine(FileUtility.NetSdkInstallRoot, "bin\\ildasm.exe"), args);
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
@ -530,9 +505,9 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -530,9 +505,9 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
MessageBox.Show(String.Format(ress.GetString("ObjectBrowser.ILDasmOutput"), output));
MessageBox.Show(String.Format(StringParser.Parse("${res:ObjectBrowser.ILDasmOutput}"), output));
} catch(Exception ex) {
MessageBox.Show(String.Format(ress.GetString("ObjectBrowser.ILDasmError"), ex.ToString()));
MessageBox.Show(String.Format(StringParser.Parse("${res:ObjectBrowser.ILDasmError}"), ex.ToString()));
}
}
@ -551,7 +526,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -551,7 +526,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
SaveFileDialog sdialog = new SaveFileDialog();
sdialog.AddExtension = true;
sdialog.FileName = name;
sdialog.Filter = ress.GetString("ObjectBrowser.Filters.Binary") + "|*.*";
sdialog.Filter = StringParser.Parse("${res:ObjectBrowser.Filters.Binary}") + "|*.*";
sdialog.DefaultExt = ".bin";
DialogResult dr = sdialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);

11
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/ExtendedPropPanel.cs

@ -3,6 +3,7 @@ using System; @@ -3,6 +3,7 @@ using System;
using System.Windows.Forms;
using System.Drawing;
using System.Reflection;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout {
@ -109,13 +110,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout { @@ -109,13 +110,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout {
{
cap.Location = new Point(0, 0);
cap.Size = new Size(Width, 32);
cap.Text = tree.ress.GetString("ObjectBrowser.Welcome");
cap.Text = StringParser.Parse("${res:ObjectBrowser.Welcome}");
cap.Font = new Font("Tahoma", 14);
cap.BackColor = SystemColors.ControlLight;
cap.TextAlign = ContentAlignment.MiddleLeft;
cap.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
string backt = tree.ress.GetString("ObjectBrowser.Back");
string backt = StringParser.Parse("${res:ObjectBrowser.Back}");
back.Size = new Size(40, 16);
back.Location = new Point(Width - back.Width, 44);
back.Text = backt;
@ -127,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout { @@ -127,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout {
typ.Location = new Point(0, 44);
typ.Size = new Size(Width - back.Width, 16);
typ.Font = new Font(Font, FontStyle.Bold);
typ.Text = tree.ress.GetString("ObjectBrowser.WelcomeText");
typ.Text = StringParser.Parse("${res:ObjectBrowser.WelcomeText}");
typ.TextAlign = ContentAlignment.TopLeft;
typ.Anchor = cap.Anchor;
@ -139,11 +140,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout { @@ -139,11 +140,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout {
list.View = View.Details;
namecol = new ColumnHeader();
namecol.Text = tree.ress.GetString("ObjectBrowser.Props.Property");
namecol.Text = StringParser.Parse("${res:ObjectBrowser.Props.Property}");
namecol.Width = 120;
valuecol = new ColumnHeader();
valuecol.Text = tree.ress.GetString("ObjectBrowser.Props.Value");
valuecol.Text = StringParser.Parse("${res:ObjectBrowser.Props.Value}");
valuecol.Width = 300;
list.Columns.Add(namecol);

32
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/ILDasmView.cs

@ -16,6 +16,7 @@ using ICSharpCode.Core; @@ -16,6 +16,7 @@ using ICSharpCode.Core;
using Microsoft.Win32;
using ICSharpCode.SharpDevelop.Dom;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
@ -42,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -42,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
chk.Location = new Point(0, 0);
chk.Size = new Size(250, 16);
chk.Text = tree.ress.GetString("ObjectBrowser.ILDasm.Enable");
chk.Text = StringParser.Parse("${res:ObjectBrowser.ILDasm.Enable}");
chk.FlatStyle = FlatStyle.System;
chk.CheckedChanged += new EventHandler(Check);
@ -75,16 +76,25 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -75,16 +76,25 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
if (node.Attribute is SA.SharpAssembly) {
assembly = (SA.SharpAssembly)node.Attribute;
} else if (node.Attribute is IClass) {
IClass type = (IClass)node.Attribute;
} else if (node.Attribute is SharpAssemblyClass) {
// TODO Check this works - was node.Attribute is IClass if statement.
SharpAssemblyClass type = (SharpAssemblyClass)node.Attribute;
item += type.FullyQualifiedName;
assembly = (SA.SharpAssembly)type.DeclaredIn;
} else if (node.Attribute is IMethod) {
IMethod method = (IMethod)node.Attribute;
} else if (node.Attribute is SharpAssemblyMethod) {
// TODO Check this works - was node.Attribute is IMethod if statement.
SharpAssemblyMethod method = (SharpAssemblyMethod)node.Attribute;
item += method.DeclaringType.FullyQualifiedName + "::" + method.Name;
assembly = (SA.SharpAssembly)method.DeclaringType.DeclaredIn;
SharpAssemblyClass type = method.DeclaringType as SharpAssemblyClass;
if (type != null) {
assembly = (SA.SharpAssembly)type.DeclaredIn;
} else {
LoggingService.Error("ILDasmView.SelectedNode - Should not be getting here.");
tb.Text = StringParser.Parse("${res:ObjectBrowser.ILDasm.NoView}");
return;
}
} else {
tb.Text = tree.ress.GetString("ObjectBrowser.ILDasm.NoView");
tb.Text = StringParser.Parse("${res:ObjectBrowser.ILDasm.NoView}");
return;
}
tb.Text = GetILDASMOutput(assembly, item).Replace("\n", "\r\n");
@ -96,11 +106,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -96,11 +106,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
try {
string args = '"' + assembly.Location + '"' + item + " /NOBAR /TEXT";
RegistryKey regKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\.NETFramework");
string cmd = (string)regKey.GetValue("sdkInstallRoot");
if (cmd == null) cmd = (string)regKey.GetValue("sdkInstallRootv1.1");
ProcessStartInfo psi = new ProcessStartInfo(FileUtility.GetDirectoryNameWithSeparator(cmd) +
"bin\\ildasm.exe", args);
ProcessStartInfo psi = new ProcessStartInfo(Path.Combine(FileUtility.NetSdkInstallRoot, "bin\\ildasm.exe"), args);
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
@ -130,7 +136,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -130,7 +136,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
return output;
} catch (Exception) {
return tree.ress.GetString("ObjectBrowser.ILDasm.NotInstalled");
return StringParser.Parse("${res:ObjectBrowser.ILDasm.NotInstalled}");
}
}

131
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/InfoView.cs

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Drawing.Printing;
@ -20,7 +21,7 @@ using System.Text.RegularExpressions; @@ -20,7 +21,7 @@ using System.Text.RegularExpressions;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.Core;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
@ -34,9 +35,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -34,9 +35,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
Panel pan = new Panel();
AssemblyTree tree;
IParserService ParserService;
IAmbience ambience;
PropertyService PropertyService;
ArrayList references = new ArrayList();
string cssPath;
@ -45,10 +44,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -45,10 +44,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
public InfoView(AssemblyTree tree)
{
PropertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
ambience = AmbienceService.CurrentAmbience;
this.tree = tree;
@ -80,13 +75,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -80,13 +75,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
cap.Location = new Point(0, 0);
cap.Size = new Size(Width, 32);
cap.Text = tree.ress.GetString("ObjectBrowser.Welcome");
cap.Text = StringParser.Parse("${res:ObjectBrowser.Welcome}");
cap.Font = new Font("Tahoma", 14);
cap.BackColor = SystemColors.ControlLight;
cap.TextAlign = ContentAlignment.MiddleLeft;
cap.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
string backt = tree.ress.GetString("ObjectBrowser.Back");
string backt = StringParser.Parse("${res:ObjectBrowser.Back}");
back.Size = new Size(40, 16);
back.Location = new Point(Width - back.Width, 44);
back.Text = backt;
@ -98,18 +93,19 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -98,18 +93,19 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
typ.Location = new Point(0, 44);
typ.Size = new Size(Width - back.Width, 16);
typ.Font = new Font(Font, FontStyle.Bold);
typ.Text = tree.ress.GetString("ObjectBrowser.WelcomeText");
typ.Text = StringParser.Parse("${res:ObjectBrowser.WelcomeText}");
typ.TextAlign = ContentAlignment.TopLeft;
typ.Anchor = cap.Anchor;
ht = new WebBrowser();
//ht.Size = new Size(20, 20);
//ht.Location = new Point(20, 20);
ht.Navigating += new WebBrowserNavigatingEventHandler (HtmlControlBeforeNavigate);
//ht.Navigating += new WebBrowserNavigatingEventHandler (HtmlControlBeforeNavigate);
CreateImage(ResourceService.GetIcon("Icons.16x16.Class").ToBitmap());
// TODO: StyleSheet
// TODO: StyleSheet
// ht.CascadingStyleSheet = cssPath;
string html = RenderHead() + tree.ress.GetString("ObjectBrowser.Info.SelectNode") + RenderFoot();
string html = RenderHead() + StringParser.Parse("${res:ObjectBrowser.Info.SelectNode}") + RenderFoot();
LoggingService.Debug("Html=" + html);
ht.DocumentText = html;
pan.Location = new Point(0, 72);
@ -127,8 +123,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -127,8 +123,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
Dock = DockStyle.Fill;
tree.AfterSelect += new TreeViewEventHandler(SelectNode);
ParserService = (IParserService)ServiceManager.Services.GetService(typeof(IParserService));
}
~InfoView() {
@ -141,41 +135,43 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -141,41 +135,43 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
e.Cancel = true;
try {
string url = e.Url;
int refnr = Int32.Parse(url.Substring(5, url.Length - 6));
object obj = references[refnr];
if (obj is IClass) {
// Go To Type
tree.GoToType((IClass)obj);
// try {
// tree.SelectedNode.Expand();
// } catch {}
} else if (obj is AssemblyTree.RefNodeAttribute) {
// Open Assembly Reference
tree.OpenAssemblyByName((AssemblyTree.RefNodeAttribute)obj);
} else if (obj is SaveResLink) {
SaveResLink link = (SaveResLink)obj;
tree.SaveResource(link.Asm, link.Name);
} else if (obj is NamespaceLink) {
NamespaceLink ns = (NamespaceLink)obj;
tree.GoToNamespace(ns.Asm, ns.Name);
}
} catch {
string url = e.Url.ToString();
url = e.Url.OriginalString;
Console.WriteLine("url=" + url);
// int refnr = Int32.Parse(url.Substring(5, url.Length - 6));
// object obj = references[refnr];
//
// if (obj is IClass) {
// // Go To Type
// tree.GoToType((IClass)obj);
// // try {
// // tree.SelectedNode.Expand();
// // } catch {}
// } else if (obj is AssemblyTree.RefNodeAttribute) {
// // Open Assembly Reference
// tree.OpenAssemblyByName((AssemblyTree.RefNodeAttribute)obj);
// } else if (obj is SaveResLink) {
// SaveResLink link = (SaveResLink)obj;
// tree.SaveResource(link.Asm, link.Name);
// } else if (obj is NamespaceLink) {
// NamespaceLink ns = (NamespaceLink)obj;
// tree.GoToNamespace(ns.Asm, ns.Name);
// }
} catch (Exception ex){
LoggingService.Debug("Something failed following this link.\r\n" + ex.ToString());
MessageService.ShowError("Something failed following this link.");
}
}
string RenderHead()
{
return "<div><p>";
return String.Concat("<html><head><link rel='stylesheet' type='text/css' href='", cssPath, "'/></head><body><div><p>");
}
string RenderFoot()
{
return "</div>";
return "</div></body></html>";
}
void SelectNode(object sender, TreeViewEventArgs e)
@ -190,7 +186,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -190,7 +186,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ambience.ConversionFlags = ConversionFlags.AssemblyScoutDefaults;
CreateImage(tree.ImageList.Images[node.ImageIndex]);
ht.Cursor = Cursors.Default;
//ht.Cursor = Cursors.Default;
StringBuilder htmlSB = new StringBuilder(RenderHead());
try {
@ -246,12 +242,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -246,12 +242,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
break;
}
} catch(Exception ex) {
htmlSB.Append("<p class='bottomline'>" + tree.ress.GetString("ObjectBrowser.Info.CollectError") + "<p>" + ex.ToString().Replace("\n", "<br>"));
htmlSB.Append("<p class='bottomline'>" + StringParser.Parse("${res:ObjectBrowser.Info.CollectError}") + "<p>" + ex.ToString().Replace("\n", "<br>"));
}
htmlSB.Append(RenderFoot());
ht.DocumentText = htmlSB.ToString();
LoggingService.Debug("Html=" + htmlSB.ToString());
}
string GetLinkInfo(IClass type)
@ -260,7 +257,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -260,7 +257,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
text.Append("<p>");
text.Append(RT("LinkedType"));
text.Append(" ");
text.Append(GetInAsm((SA.SharpAssembly)type.DeclaredIn));
SharpAssemblyClass sharpAssemblyType = type as SharpAssemblyClass;
text.Append(GetInAsm((SA.SharpAssembly)sharpAssemblyType.DeclaredIn));
return text.ToString();
}
@ -281,11 +279,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -281,11 +279,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
string GetFolderInfo(string folder)
{
if (folder == tree.ress.GetString("ObjectBrowser.Nodes.Resources"))
if (folder == StringParser.Parse("${res:ObjectBrowser.Nodes.Resources}"))
return RT("ResFInfo");
else if (folder == tree.ress.GetString("ObjectBrowser.Nodes.References"))
else if (folder == StringParser.Parse("${res:ObjectBrowser.Nodes.References}"))
return RT("RefFInfo");
else if (folder == tree.ress.GetString("ObjectBrowser.Nodes.Modules"))
else if (folder == StringParser.Parse("${res:ObjectBrowser.Nodes.Modules}"))
return RT("ModFInfo");
else
return RT("NoInfo");
@ -428,7 +426,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -428,7 +426,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ret.Append("<br>");
ret.Append(GetCustomAttribs(info));
IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
//IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
IClass c = info.DeclaringType;
if(c == null) goto noDoc;
foreach(IEvent e in c.Events) {
if(e.Name == info.Name) {
@ -447,7 +446,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -447,7 +446,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ret.Append("<br>");
ret.Append(GetInType(info.DeclaringType));
ret.Append("<p>");
ret.Append(GetInAsm((SA.SharpAssembly)info.DeclaringType.DeclaredIn));
SharpAssemblyClass declaringType = info.DeclaringType as SharpAssemblyClass;
ret.Append(GetInAsm((SA.SharpAssembly)declaringType.DeclaredIn));
return ret.ToString();
}
@ -469,7 +469,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -469,7 +469,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ret.Append("<br>");
ret.Append(GetCustomAttribs(info));
IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
//IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
IClass c = info.DeclaringType;
if(c == null) goto noDoc;
foreach(IField f in c.Fields) {
if(f.Name == info.Name) {
@ -488,7 +489,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -488,7 +489,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ret.Append("<br>");
ret.Append(GetInType(info.DeclaringType));
ret.Append("<p>");
ret.Append(GetInAsm((SA.SharpAssembly)info.DeclaringType.DeclaredIn));
SharpAssemblyClass declaringType = info.DeclaringType as SharpAssemblyClass;
ret.Append(GetInAsm((SA.SharpAssembly)declaringType.DeclaredIn));
return ret.ToString();
}
@ -502,7 +504,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -502,7 +504,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ret.Append("<br>");
ret.Append(GetCustomAttribs(info));
IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
//IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
IClass c = info.DeclaringType;
if(c == null) goto noDoc;
foreach(IMethod cc in c.Methods) {
if (cc.Name == info.Name) {
@ -521,7 +524,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -521,7 +524,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ret.Append("<br>");
ret.Append(GetInType(info.DeclaringType));
ret.Append("<p>");
ret.Append(GetInAsm((SA.SharpAssembly)info.DeclaringType.DeclaredIn));
SharpAssemblyClass declaringType = info.DeclaringType as SharpAssemblyClass;
ret.Append(GetInAsm((SA.SharpAssembly)declaringType.DeclaredIn));
return ret.ToString();
}
@ -535,7 +539,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -535,7 +539,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ret.Append("<br>");
ret.Append(GetCustomAttribs(info));
IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
//IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
IClass c = info.DeclaringType;
if(c == null) goto noDoc;
foreach(IProperty p in c.Properties) {
if(p.Name == info.Name) {
@ -554,7 +559,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -554,7 +559,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
ret.Append("<br>");
ret.Append(GetInType(info.DeclaringType));
ret.Append("<p>");
ret.Append(GetInAsm((SA.SharpAssembly)info.DeclaringType.DeclaredIn));
SharpAssemblyClass declaringType = info.DeclaringType as SharpAssemblyClass;
ret.Append(GetInAsm((SA.SharpAssembly)declaringType.DeclaredIn));
return ret.ToString();
}
@ -573,7 +579,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -573,7 +579,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
t.Append("<br>");
t.Append(GetCustomAttribs(type));
IClass c = ParserService.GetClass(type.FullyQualifiedName.Replace("+", "."));
//IClass c = ParserService.GetClass(type.FullyQualifiedName.Replace("+", "."));
IClass c = type;
if (c == null) goto noDoc;
if (c.Documentation == null || c.Documentation == "") goto noDoc;
t.Append("<p class='bottomline'>");
@ -586,11 +593,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -586,11 +593,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
if (type.Namespace == null || type.Namespace == "") goto inAsm;
t.Append("<br>");
t.Append(GetInNS((SA.SharpAssembly)type.DeclaredIn, type.Namespace));
t.Append(GetInNS((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn, type.Namespace));
inAsm:
t.Append("<p>");
t.Append(GetInAsm((SA.SharpAssembly)type.DeclaredIn));
t.Append(GetInAsm((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn));
return t.ToString();
}
@ -603,16 +610,17 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -603,16 +610,17 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
string GetCustomAttribs(IClass type)
{
if (type.Attributes.Count == 0) return "";
return GetCustomAttribs(type.Attributes[0].Attributes);
return GetCustomAttribs(type.Attributes);
}
string GetCustomAttribs(IMember member)
{
if (member.Attributes.Count == 0) return "";
return GetCustomAttribs(member.Attributes[0].Attributes);
return GetCustomAttribs(member.Attributes);
//return GetCustomAttribs(member.Attributes[0].Attributes);
}
string GetCustomAttribs(AttributeCollection ca)
string GetCustomAttribs(IList<IAttribute> ca)
{
StringBuilder text = new StringBuilder();
try {
@ -762,12 +770,12 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -762,12 +770,12 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
string RT(string ResName)
{
return tree.ress.GetString(String.Concat("ObjectBrowser.Info.", ResName));
return StringParser.Parse(String.Concat("${res:", "ObjectBrowser.Info.", ResName, "}"));
}
string RTD(string ResName)
{
return tree.ress.GetString(String.Concat("ObjectBrowser.Info.Doc.", ResName));
return StringParser.Parse(String.Concat("${res:", "ObjectBrowser.Info.Doc.", ResName, "}"));
}
string ln(int rnr, string text)
@ -794,7 +802,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -794,7 +802,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
return true;
} catch { return false; }
}
}
public class GradientLabel : Label

23
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/Nodes/AssemblyTreeNode.cs

@ -10,7 +10,6 @@ using System.Collections; @@ -10,7 +10,6 @@ using System.Collections;
using System.Windows.Forms;
using System.Drawing;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
@ -50,13 +49,10 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -50,13 +49,10 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
protected const int DELEGATEINDEX = CLASSINDEX + 7 * 4;
protected NodeType type;
protected string name;
protected object attribute;
protected bool populated = false;
public static ResourceService ress = (ResourceService)ServiceManager.Services.GetService(typeof(ResourceService));
public NodeType Type {
get {
return type;
@ -78,20 +74,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -78,20 +74,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
}
}
public string Name {
get {
return name;
}
set {
name = value;
}
}
public AssemblyTreeNode(string name, object attribute, NodeType type) : base(name)
{
this.attribute = attribute;
this.type = type;
this.name = name;
Name = name;
SetIcon();
}
@ -99,8 +86,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -99,8 +86,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
protected virtual void SetIcon()
{
switch (type) {
case NodeType.Link:
break;
@ -172,7 +157,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -172,7 +157,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
try {
types = SharpAssemblyClass.GetAssemblyTypes(assembly);
} catch {
MessageBox.Show(ress.GetString("ObjectBrowser.ErrorLoadingTypes"), ress.GetString("Global.WarningText"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
MessageBox.Show(StringParser.Parse("${res:ObjectBrowser.ErrorLoadingTypes}"), StringParser.Parse("${res:Global.WarningText}"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
ArrayList nodes = new ArrayList();
@ -235,14 +220,14 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -235,14 +220,14 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
TreeNode node = new FolderNode(System.IO.Path.GetFileName(assembly.Location), assembly, NodeType.Library, 2, 2);
parentnode.Nodes.Add(node);
FolderNode resourcefolder = new FolderNode(ress.GetString("ObjectBrowser.Nodes.Resources"), assembly, NodeType.Folder, 6, 7);
FolderNode resourcefolder = new FolderNode(StringParser.Parse("${res:ObjectBrowser.Nodes.Resources}"), assembly, NodeType.Folder, 6, 7);
string[] resources = assembly.GetManifestResourceNames();
foreach (string resource in resources) {
resourcefolder.Nodes.Add(new ResourceNode(resource, assembly, true));
}
parentnode.Nodes.Add(resourcefolder);
FolderNode referencefolder = new FolderNode(ress.GetString("ObjectBrowser.Nodes.References"), assembly, NodeType.Folder, 9, 10);
FolderNode referencefolder = new FolderNode(StringParser.Parse("${res:ObjectBrowser.Nodes.References}"), assembly, NodeType.Folder, 9, 10);
SA.SharpAssemblyName[] references = assembly.GetReferencedAssemblies();
foreach (SA.SharpAssemblyName name in references) {
referencefolder.Nodes.Add(new AssemblyTreeNode(name.Name, new AssemblyTree.RefNodeAttribute(assembly, name), NodeType.Reference));

23
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/Nodes/MemberNode.cs

@ -7,10 +7,10 @@ @@ -7,10 +7,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
@ -59,13 +59,14 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -59,13 +59,14 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
void CreateSpecialNodes(IProperty prop)
{
IMethod getm = prop.GetterMethod;
IMethod setm = prop.SetterMethod;
if (getm != null)
Nodes.Add(new MethodNode(getm));
if (setm != null)
Nodes.Add(new MethodNode(setm));
// TODO - No IProperty.Getter/Setter Method.
// IMethod getm = prop.GetterMethod;
// IMethod setm = prop.SetterMethod;
//
// if (getm != null)
// Nodes.Add(new MethodNode(getm));
// if (setm != null)
// Nodes.Add(new MethodNode(setm));
}
void CreateSpecialNodes(IEvent evt)
@ -84,8 +85,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -84,8 +85,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
protected override void SetIcon()
{
if (attribute == null)
return;
switch (type) {
@ -112,8 +111,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -112,8 +111,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
}
}
static
public static string GetShortMemberName(IMember mi, bool IsEnum) {
string ret = "";
@ -157,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -157,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
return ret;
}
public static string GetParams(ParameterCollection piarr, bool IncludeBrackets) {
public static string GetParams(IList<IParameter> piarr, bool IncludeBrackets) {
string param = "";
foreach(IParameter pi in piarr) {
param += GetNestedName(AssemblyTree.CurrentAmbience.GetIntrinsicTypeName(pi.ReturnType.FullyQualifiedName)) + ", ";

9
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/Nodes/ResourceNode.cs

@ -12,8 +12,7 @@ using System.Resources; @@ -12,8 +12,7 @@ using System.Resources;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.Core;
using SA = ICSharpCode.SharpAssembly.Assembly;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
@ -30,9 +29,9 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -30,9 +29,9 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
public override void Populate(ShowOptions Private, ShowOptions Internal)
{
if (name.ToLower().EndsWith(".resources")) {
if (Name.ToLower().EndsWith(".resources")) {
SA.SharpAssembly assembly = (SA.SharpAssembly)attribute;
byte[] res = assembly.GetManifestResource(name);
byte[] res = assembly.GetManifestResource(Name);
ResourceReader resreader = new ResourceReader(new MemoryStream(res));
IDictionaryEnumerator en = resreader.GetEnumerator();
@ -53,7 +52,5 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -53,7 +52,5 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
}
populated = true;
}
}
}

21
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/Nodes/TypeNode.cs

@ -10,7 +10,6 @@ using System.Collections; @@ -10,7 +10,6 @@ using System.Collections;
using System.Windows.Forms;
using System.Drawing;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
@ -27,7 +26,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -27,7 +26,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
protected override void SetIcon()
{
ImageIndex = SelectedImageIndex = ClassBrowserIconService.GetIcon((IClass)attribute);
}
@ -37,31 +35,26 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -37,31 +35,26 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
Nodes.Clear();
AssemblyTreeNode supertype = new AssemblyTreeNode(ress.GetString("ObjectBrowser.Nodes.SuperTypes"), type, NodeType.SuperTypes);
AssemblyTreeNode supertype = new AssemblyTreeNode(StringParser.Parse("${res:ObjectBrowser.Nodes.SuperTypes}"), type, NodeType.SuperTypes);
Nodes.Add(supertype);
SharpAssemblyClass sharptype = type as SharpAssemblyClass;
if (sharptype == null) goto nobase;
AddBaseTypes(sharptype, supertype, ClassBrowserIconService);
// TODO: SubTypes is not implemented
// Nodes.Add(new ReflectionNode("SubTypes", type, ReflectionNodeType.SubTypes));
AddBaseTypes(sharptype, supertype);
nobase:
populated = true;
}
private void AddBaseTypes(SharpAssemblyClass type, AssemblyTreeNode node, ClassBrowserIconsService ClassBrowserIconService)
private void AddBaseTypes(SharpAssemblyClass type, AssemblyTreeNode node)
{
foreach (SharpAssemblyClass rettype in type.BaseTypeCollection) {
AssemblyTreeNode basetype = new AssemblyTreeNode(rettype.Name, rettype, NodeType.Link);
basetype.ImageIndex = basetype.SelectedImageIndex = ClassBrowserIconService.GetIcon(rettype);
node.Nodes.Add(basetype);
AddBaseTypes(rettype, basetype, ClassBrowserIconService);
AddBaseTypes(rettype, basetype);
}
}
@ -75,7 +68,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -75,7 +68,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
foreach (IMethod info in type.Methods) {
if (Private == ShowOptions.Hide && info.IsPrivate) continue;
if (Internal == ShowOptions.Hide && info.IsInternal) continue;
if (!info.IsConstructor && info.IsSpecialName) continue;
if (!info.IsConstructor && SharpAssemblyMethod.IsSpecial(info)) continue;
MemberNode node = new MemberNode(info);
if ((info.IsInternal && Internal == ShowOptions.GreyOut) ||
@ -111,7 +104,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -111,7 +104,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
foreach (IField info in type.Fields) {
if (Private == ShowOptions.Hide && info.IsPrivate) continue;
if (Internal == ShowOptions.Hide && info.IsInternal) continue;
if (info.IsSpecialName) continue;
if (SharpAssemblyField.IsSpecial(info)) continue;
MemberNode node = new MemberNode(info, type.ClassType == ClassType.Enum);
if ((info.IsInternal && Internal == ShowOptions.GreyOut) ||

33
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SearchPanel.cs

@ -14,7 +14,6 @@ using System.Windows.Forms; @@ -14,7 +14,6 @@ using System.Windows.Forms;
using System.Threading;
using System.Resources;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
@ -40,13 +39,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -40,13 +39,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
this.tree = tree;
searchfor.Text = tree.ress.GetString("ObjectBrowser.Search.SearchFor");
searchfor.Text = StringParser.Parse("${res:ObjectBrowser.Search.SearchFor}");
searchfor.Location = new Point(0, 0);
searchfor.Size = new Size(70, 12);
searchfor.Anchor = AnchorStyles.Top | AnchorStyles.Left;
searchfor.FlatStyle = FlatStyle.System;
foundcount.Text = "0 " + tree.ress.GetString("ObjectBrowser.Search.ItemsFound");
foundcount.Text = "0 " + StringParser.Parse("${res:ObjectBrowser.Search.ItemsFound}");
foundcount.Location = new Point(searchfor.Width + 5, 0);
foundcount.Size = new Size(Width - searchfor.Width - 5, searchfor.Height);
foundcount.TextAlign = ContentAlignment.TopRight;
@ -61,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -61,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
button.Location = new Point(Width - 52, 44);
button.Size = new Size(52, 21);
button.Text = tree.ress.GetString("ObjectBrowser.Search.Search");
button.Text = StringParser.Parse("${res:ObjectBrowser.Search.Search}");
button.Anchor = AnchorStyles.Top | AnchorStyles.Right;
button.Click += new EventHandler(DoSearch);
button.FlatStyle = FlatStyle.System;
@ -71,8 +70,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -71,8 +70,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
searchtypes.Height = 30;
searchtypes.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
searchtypes.DropDownStyle = ComboBoxStyle.DropDownList;
searchtypes.Items.Add(tree.ress.GetString("ObjectBrowser.Search.TypesAndMembers"));
searchtypes.Items.Add(tree.ress.GetString("ObjectBrowser.Search.TypesOnly"));
searchtypes.Items.Add(StringParser.Parse("${res:ObjectBrowser.Search.TypesAndMembers}"));
searchtypes.Items.Add(StringParser.Parse("${res:ObjectBrowser.Search.TypesOnly}"));
searchtypes.SelectedIndex = 0;
itemsfound.Location = new Point(0, 71);
@ -84,8 +83,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -84,8 +83,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
itemsfound.View = View.Details;
itemsfound.SmallImageList = tree.ImageList;
itemsfound.Columns.Add(tree.ress.GetString("ObjectBrowser.Search.Name"), 160, HorizontalAlignment.Left);
itemsfound.Columns.Add(tree.ress.GetString("ObjectBrowser.Search.Type"), 70, HorizontalAlignment.Left);
itemsfound.Columns.Add(StringParser.Parse("${res:ObjectBrowser.Search.Name}"), 160, HorizontalAlignment.Left);
itemsfound.Columns.Add(StringParser.Parse("${res:ObjectBrowser.Search.Type}"), 70, HorizontalAlignment.Left);
itemsfound.Columns.Add("Namespace", 125, HorizontalAlignment.Left);
itemsfound.Columns.Add("Assembly", 75, HorizontalAlignment.Left);
itemsfound.DoubleClick += new EventHandler(SelectItem);
@ -128,10 +127,10 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -128,10 +127,10 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
class TypeItem : ListViewItem {
public IClass type;
public TypeItem(string Namespace, IClass type, Color forecolor) :
base (new string[] {type.Name, GetType(type), Namespace, ((SA.SharpAssembly)type.DeclaredIn).Name})
base (new string[] {type.Name, GetType(type), Namespace, ((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn).Name})
{
this.type = type;
this.ImageIndex = ((ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService))).GetIcon(type);
this.ImageIndex = ClassBrowserIconService.GetIcon(type);
this.ForeColor = forecolor;
}
@ -153,18 +152,18 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -153,18 +152,18 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
public IMember member;
public MemberItem(string Namespace, IMember member, Color forecolor) :
base (new string[] {member.DeclaringType.Name + "." + member.Name, GetType(member), Namespace, ((SA.SharpAssembly)member.DeclaringType.DeclaredIn).Name})
base (new string[] {member.DeclaringType.Name + "." + member.Name, GetType(member), Namespace, ((SA.SharpAssembly)((SharpAssemblyClass)member.DeclaringType).DeclaredIn).Name})
{
this.ForeColor = forecolor;
this.member = member;
if(member is IMethod) {
this.ImageIndex = ((ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService))).GetIcon(member as IMethod);
this.ImageIndex = ClassBrowserIconService.GetIcon(member as IMethod);
} else if(member is IField) {
this.ImageIndex = ((ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService))).GetIcon(member as IField);
this.ImageIndex = ClassBrowserIconService.GetIcon(member as IField);
} else if(member is IProperty) {
this.ImageIndex = ((ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService))).GetIcon(member as IProperty);
this.ImageIndex = ClassBrowserIconService.GetIcon(member as IProperty);
} else if(member is IEvent) {
this.ImageIndex = ((ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService))).GetIcon(member as IEvent);
this.ImageIndex = ClassBrowserIconService.GetIcon(member as IEvent);
}
}
@ -217,7 +216,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -217,7 +216,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
}
itemsfound.EndUpdate();
foundcount.Text = itemsfound.Items.Count.ToString() + " " + tree.ress.GetString("ObjectBrowser.Search.ItemsFound");
foundcount.Text = itemsfound.Items.Count.ToString() + " " + StringParser.Parse("${res:ObjectBrowser.Search.ItemsFound}");
}
void ProcessType(string Namespace, string searchfor, bool searchMembers, IClass type, Color nodecolor)
@ -243,7 +242,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -243,7 +242,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
private void ProcessMember(string Namespace, IMember member, string searchfor)
{
if(member is IMethod) {
if (member.IsSpecialName) return;
if (SharpAssemblyMethod.IsSpecial(member as IMethod)) return;
}
if(member.IsPrivate && (tree.showPrivateMembers == ShowOptions.Hide)) return;

262
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyAttribute.cs

@ -0,0 +1,262 @@ @@ -0,0 +1,262 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Xml;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpAssembly.Metadata.Rows;
using ICSharpCode.SharpAssembly.Metadata;
using ICSharpCode.SharpAssembly.PE;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
[Serializable]
public class SharpAssemblyAttribute : DefaultAttribute
{
SharpAssemblyClass attributeType;
public SharpAssemblyClass AttributeType {
get {
return attributeType;
}
}
public SharpAssemblyAttribute(SA.SharpAssembly assembly, SA.SharpCustomAttribute attribute) : base(null)
{
uint sigOffset = 0;
if (attribute.IsMemberRef) {
MemberRef[] memberTable = assembly.Tables.MemberRef;
TypeRef[] typeRefTable = assembly.Tables.TypeRef;
sigOffset = memberTable[attribute.MemberIndex].Signature;
uint trIndex = memberTable[attribute.MemberIndex].Class;
int table = assembly.Reader.GetCodedIndexTable(CodedIndex.MemberRefParent, ref trIndex);
if (table != 1) {
Console.WriteLine("SharpAssemblyAttribute: unsupported MemberRefParent coded index");
return; // unsupported
}
attributeType = SharpAssemblyClass.FromTypeRef(assembly, trIndex);
} else {
TypeDef[] typeDefTable = assembly.Tables.TypeDef;
sigOffset = assembly.Tables.Method[attribute.MemberIndex].Signature;
uint tdIndex = 0;
for (uint i = 1; i <= typeDefTable.GetUpperBound(0); ++i) {
if (typeDefTable[i].MethodList <= attribute.MemberIndex && i == typeDefTable.GetUpperBound(0)) {
tdIndex = i;
break;
}
if (typeDefTable[i].MethodList <= attribute.MemberIndex && typeDefTable[i+1].MethodList > attribute.MemberIndex) {
tdIndex = i;
break;
}
}
attributeType = SharpAssemblyClass.FromTypeDef(assembly, tdIndex);
}
if (attributeType != null) Name = attributeType.FullyQualifiedName;
if (attribute.ValueIndex == 0) return;
try {
// Get return types of positional arguments by inspecting the method signature
int size = assembly.Reader.LoadBlob(ref sigOffset);
sigOffset += 1; // skip calling convention
int numReturnTypes = assembly.Reader.LoadBlob(ref sigOffset);
SharpAssemblyReturnType dummy = SharpAssemblyReturnType.Create(assembly, ref sigOffset);
SharpAssemblyReturnType[] returnTypes = new SharpAssemblyReturnType[numReturnTypes];
for (int i = 0; i < returnTypes.Length; ++i) {
returnTypes[i] = SharpAssemblyReturnType.Create(assembly, ref sigOffset);
}
// Get the return type values and the named arguments
byte[] argBlob = assembly.Reader.GetBlobFromHeap(attribute.ValueIndex);
Stream str = new MemoryStream(argBlob);
BinaryReader binaryReader = new BinaryReader(str);
ushort prolog = binaryReader.ReadUInt16();
if (prolog != 1) {
Console.WriteLine("SharpAssemblyAttribute: Wrong prolog in argument list");
return;
}
// read positional arguments
for (int i = 0; i < returnTypes.Length; ++i) {
string rettypename = returnTypes[i].Name;
SharpAssemblyClass underlyingClass = returnTypes[i].UnderlyingClass;
// enum -> determine base integer size and try to display the user-friendly name of the value
if (underlyingClass != null && underlyingClass.IsSubclassOf("System.Enum")) {
//underlyingClass.LoadMembers();
foreach (IField field in underlyingClass.Fields) {
if (field.Name.EndsWith("value__")) {
rettypename = field.ReturnType.Name;
break;
}
}
object argValue = GetFixedArg(argBlob, binaryReader, rettypename);
foreach (IField field in underlyingClass.Fields) {
if (field is SharpAssemblyField) {
try {
if (((field as SharpAssemblyField).InitialValue as IComparable).CompareTo(argValue) == 0) {
// TODO PositionArguments
//PositionalArguments.Add(underlyingClass.Name + "." + field.Name);
goto namefound;
}
} catch {}
}
}
// if the value cannot be found
// TODO PositionArguments
//PositionalArguments.Add(argValue.ToString());
namefound: ;
} else {
// TODO PositionArguments
//PositionalArguments.Add(GetFixedArg(argBlob, binaryReader, rettypename).ToString());
}
}
ushort numnamed = binaryReader.ReadUInt16();
for (int i = 0; i < numnamed; ++i) {
byte field_or_prop = binaryReader.ReadByte();
byte type = binaryReader.ReadByte();
string typename = "";
if (type == 0x50) {
typename = "Type";
} else {
DataType dt = (DataType)type;
typename = dt.ToString();
}
string argname = GetSerString(argBlob, binaryReader.BaseStream);
// TODO NamedArgs
//NamedArguments.Add(argname, GetFixedArg(argBlob, binaryReader, typename).ToString());
}
binaryReader.Close();
} catch (Exception ex) {
LoggingService.Error("SharpAssemblyAttribute: Error loading arguments. " + ex.ToString());
}
}
object GetFixedArg(byte[] argBlob, BinaryReader binaryReader, string name)
{
switch (name) {
case "Boolean":
return binaryReader.ReadBoolean();
case "Char":
return binaryReader.ReadChar();
case "SByte":
return binaryReader.ReadSByte();
case "Byte":
return binaryReader.ReadByte();
case "Int16":
return binaryReader.ReadInt16();
case "UInt16":
return binaryReader.ReadUInt16();
case "Int32":
return binaryReader.ReadInt32();
case "UInt32":
return binaryReader.ReadUInt32();
case "Int64":
return binaryReader.ReadInt64();
case "UInt64":
return binaryReader.ReadUInt64();
case "Single":
return binaryReader.ReadSingle();
case "Double":
return binaryReader.ReadDouble();
case "String":
case "Type":
return '"' + GetSerString(argBlob, binaryReader.BaseStream) + '"';
default:
return "";
}
}
string GetSerString(byte[] blob, Stream stream)
{
uint pos2 = (uint)stream.Position;
int size = SA.AssemblyReader.GetCompressedInt(blob, ref pos2);
string str;
try {
str = System.Text.Encoding.UTF8.GetString(blob, (int)pos2, size);
} catch {
str = "<error with string>";
}
stream.Position = pos2 + size;
return str;
}
public override string ToString()
{
string ret = Name + " (";
foreach (AttributeArgument arg in PositionalArguments) {
ret += arg.Type.FullyQualifiedName + ", ";
}
// TODO NamedArguments
foreach (KeyValuePair<string, AttributeArgument> item in NamedArguments) {
try {
ret += item.Key + " = " + item.Value.Type.FullyQualifiedName + ", ";
} catch {
LoggingService.Error("Error in NamedArguments.");
}
}
// delete last bracket
if (ret.EndsWith(", ")) ret = ret.Substring(0, ret.Length - 2);
return ret + ")";
}
public static List<IAttribute> GetAssemblyAttributes(SA.SharpAssembly assembly)
{
List<IAttribute> attributes = new List<IAttribute>();
foreach (ArrayList al in assembly.Attributes.Assembly.Values) {
foreach (SA.SharpCustomAttribute attr in al) {
attributes.Add(new SharpAssemblyAttribute(assembly, attr));
}
}
return attributes;
}
}
}

484
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyClass.cs

@ -0,0 +1,484 @@ @@ -0,0 +1,484 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections.Specialized;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpAssembly.Metadata.Rows;
using ICSharpCode.SharpAssembly.Metadata;
using ICSharpCode.SharpAssembly.PE;
using ICSharpCode.SharpAssembly.Assembly;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
[Serializable]
public class SharpAssemblyClass : DefaultClass
{
List<IClass> baseTypeCollection = new List<IClass>();
object declaredIn;
public object DeclaredIn {
get {
return declaredIn;
}
}
public override string DocumentationTag {
get {
return null;
}
}
public List<IClass> BaseTypeCollection {
get {
if (baseTypeCollection == null) baseTypeCollection = new List<IClass>();
return baseTypeCollection;
}
}
public static string GetNestedName(SA.SharpAssembly asm, TypeRef[] typeRefTable, uint index)
{
uint val = typeRefTable[index].ResolutionScope;
int table = asm.Reader.GetCodedIndexTable(CodedIndex.ResolutionScope, ref val);
switch (table) {
case 2: // AssemblyRef
return asm.Reader.GetStringFromHeap(typeRefTable[index].Nspace) + "." + asm.Reader.GetStringFromHeap(typeRefTable[index].Name);
case 3: // TypeRef -- nested type
return GetNestedName(asm, typeRefTable, val) + "+" + asm.Reader.GetStringFromHeap(typeRefTable[index].Name);
default: // other token - not supported
Console.WriteLine("GetNestedName: Unsupported resolution scope!");
goto case 3;
}
}
public static string GetNestedName(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index)
{
uint nestedParent = asm.GetNestedTypeParent(index);
if (nestedParent == 0) {
return asm.Reader.GetStringFromHeap(typeDefTable[index].NSpace) + "." + asm.Reader.GetStringFromHeap(typeDefTable[index].Name);
}
return GetNestedName(asm, typeDefTable, nestedParent) + "+" + asm.Reader.GetStringFromHeap(typeDefTable[index].Name);
}
/// <summary>
/// Constructs a SharpAssemblyClass from an entry in the assembly's TypeRef table
/// by looking in the referencing assembly's TypeDef table
/// </summary>
public static SharpAssemblyClass FromTypeRef(SA.SharpAssembly referencingAssembly, uint index)
{
if (referencingAssembly.TypeRefObjects[index] as SharpAssemblyClass != null) {
return (SharpAssemblyClass)referencingAssembly.TypeRefObjects[index];
}
TypeRef[] typeRefTable = referencingAssembly.Tables.TypeRef;
string name = referencingAssembly.Reader.GetStringFromHeap(typeRefTable[index].Name);
SA.SharpAssembly declaringAssembly = referencingAssembly.GetRefAssemblyFor(index);
if (declaringAssembly == null) {
Console.Write("FromTypeRef failed for: " + name + " declared in assembly " + referencingAssembly.Name);
Console.WriteLine(": Declaring assembly not found.");
return null;
}
TypeDef[] typeDefTable = declaringAssembly.Tables.TypeDef;
if (typeDefTable == null) {
return null;
}
string nestedName = GetNestedName(referencingAssembly, typeRefTable, index);
for (uint i = 1; i <= typeDefTable.GetUpperBound(0); ++i) {
if (declaringAssembly.Reader.GetStringFromHeap(typeDefTable[i].Name) == name) {
if (GetNestedName(declaringAssembly, typeDefTable, i) == nestedName) {
SharpAssemblyClass newclass = FromTypeDef(declaringAssembly, i);
// store new class object in assembly's cache
if (newclass != null) referencingAssembly.TypeRefObjects[index] = newclass;
return newclass;
}
}
}
Console.Write("FromTypeRef failed for: " + name + " declared in assembly " + referencingAssembly.Name);
Console.WriteLine(": Matching type not found for nested name: " + nestedName);
return null;
}
/// <summary>
/// Constructs a SharpAssemblyClass from an entry in the assembly's TypeDef table
/// Looks in the class cache for the assembly first
/// </summary>
public static SharpAssemblyClass FromTypeDef(SA.SharpAssembly assembly, uint index)
{
if (assembly.TypeDefObjects[index] as SharpAssemblyClass != null) {
SharpAssemblyClass exclass = (SharpAssemblyClass)assembly.TypeDefObjects[index];
return exclass;
}
return new SharpAssemblyClass(assembly, assembly.Tables.TypeDef, index);
}
/// <summary>
/// The constructor is private because the only way to construct SharpAssemblyClass objects
/// is to call FromTypeRef/Def to make us of the cache
/// </summary>
SharpAssemblyClass(SA.SharpAssembly assembly, TypeDef[] typeDefTable, uint index) : base(null, String.Empty)
{
if (assembly == null) {
throw new System.ArgumentNullException("assembly");
}
if (typeDefTable == null) {
throw new System.ArgumentNullException("typeDefTable");
}
if (index > typeDefTable.GetUpperBound(0) || index < 1) {
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", typeDefTable.GetUpperBound(0)));
}
TypeDef typeDef = typeDefTable[index];
typeDefIndex = index; // store index for use in LoadMembers()
declaredIn = assembly;
FullyQualifiedName = GetNestedName(assembly, typeDefTable, index);
// store in assembly's cache
assembly.TypeDefObjects[index] = this;
if (typeDef.IsFlagSet(TypeDef.FLAG_INTERFACE)) {
ClassType = ClassType.Interface;
} else if (typeDef.IsFlagSet(TypeDef.FLAG_CLASS)) {
ClassType = ClassType.Class;
}
if (typeDef.Extends == 0) goto noext;
SharpAssemblyClass extend = GetTypeRefOrDefClass(assembly, typeDef.Extends);
if (extend == null) goto noext;
if (extend.FullyQualifiedName == "System.Enum") {
ClassType = ClassType.Enum;
} else if (extend.FullyQualifiedName == "System.ValueType") {
ClassType = ClassType.Struct;
}
baseTypeCollection.Add(extend);
if (IsSubclassOf("System.Delegate")) ClassType = ClassType.Delegate;
noext:
InterfaceImpl[] ifaces = assembly.Tables.InterfaceImpl;
if (ifaces == null) goto nointerfaces;
for (int i = 1; i <= ifaces.GetUpperBound(0); ++i) {
if (ifaces[i].Class == index) {
SharpAssemblyClass impl = GetTypeRefOrDefClass(assembly, ifaces[i].Interface);
if (impl != null) {
baseTypeCollection.Add(impl);
}
}
}
nointerfaces:
NestedClass[] nestedClasses = assembly.Tables.NestedClass;
if (nestedClasses == null) goto nonested;
for (int i = 1; i <= nestedClasses.GetUpperBound(0); ++i) {
if (nestedClasses[i].EnclosingClass == index) {
IClass newclass = FromTypeDef(assembly, nestedClasses[i].NestedClassIndex);
InnerClasses.Add(newclass);
}
}
nonested:
// Attributes
ArrayList attrib = assembly.Attributes.TypeDef[index] as ArrayList;
if (attrib == null) goto modifiers;
foreach(SharpCustomAttribute customattribute in attrib) {
Attributes.Add(new SharpAssemblyAttribute(assembly, customattribute));
}
modifiers:
Modifiers = ModifierEnum.None;
if (typeDef.IsFlagSet(TypeDef.FLAG_SEALED)) {
Modifiers |= ModifierEnum.Sealed;
}
if (typeDef.IsFlagSet(TypeDef.FLAG_ABSTRACT)) {
Modifiers |= ModifierEnum.Abstract;
}
if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDPRIVATE, TypeDef.FLAG_VISIBILITYMASK)) {
Modifiers |= ModifierEnum.Private;
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDPUBLIC, TypeDef.FLAG_VISIBILITYMASK) || typeDef.IsMaskedFlagSet(TypeDef.FLAG_PUBLIC, TypeDef.FLAG_VISIBILITYMASK)) {
Modifiers |= ModifierEnum.Public;
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDASSEMBLY, TypeDef.FLAG_VISIBILITYMASK) ||
typeDef.IsMaskedFlagSet(TypeDef.FLAG_NOTPUBLIC, TypeDef.FLAG_VISIBILITYMASK)) {
Modifiers |= ModifierEnum.Internal;
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDFAMILY, TypeDef.FLAG_VISIBILITYMASK)) {
Modifiers |= ModifierEnum.Protected;
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDFAMORASSEM, TypeDef.FLAG_VISIBILITYMASK)) {
Modifiers |= ModifierEnum.ProtectedOrInternal;
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDFAMANDASSEM, TypeDef.FLAG_VISIBILITYMASK)) {
Modifiers |= ModifierEnum.Protected;
Modifiers |= ModifierEnum.Internal;
}
if (typeDef.IsFlagSet(TypeDef.FLAG_SPECIALNAME)) {
Modifiers |= ModifierEnum.Volatile | ModifierEnum.Unsafe | ModifierEnum.Extern;
}
/* members are loaded on demand now
if (classType != ClassType.Delegate && loadMembers) {
AddMethods(assembly, typeDefTable, index);
AddFields(assembly, typeDefTable, index);
AddProperties(assembly, typeDefTable, index);
AddEvents(assembly, typeDefTable, index);
membersLoaded = true;
}
*/
}
uint typeDefIndex = 0;
bool membersLoaded = false;
void LoadMembers()
{
if (membersLoaded) return;
membersLoaded = true;
SA.SharpAssembly assembly = (SA.SharpAssembly)declaredIn;
TypeDef[] typeDefTable = assembly.Tables.TypeDef;
AddMethods(assembly, typeDefTable, typeDefIndex);
AddFields(assembly, typeDefTable, typeDefIndex);
AddProperties(assembly, typeDefTable, typeDefIndex);
AddEvents(assembly, typeDefTable, typeDefIndex);
}
public bool IsSubclassOf(string FullName)
{
foreach (SharpAssemblyClass basetype in baseTypeCollection) {
if (basetype.FullyQualifiedName == FullName) return true;
if (basetype.IsSubclassOf(FullName)) return true;
}
return false;
}
private static SharpAssemblyClass GetTypeRefOrDefClass(SA.SharpAssembly assembly, uint cind) {
uint nTable = cind & 0x03;
uint nIndex = cind >> 2;
switch (nTable) {
case 0: // TypeDef
return FromTypeDef(assembly, nIndex);
case 1: // TypeRef
return FromTypeRef(assembly, nIndex);
default:
Console.WriteLine("GetTypeRefOrDefClass: Wrong TypeDefOrRef coded index!");
return null;
}
}
void AddEvents(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index)
{
EventMap[] eventMapTable = asm.Tables.EventMap;
Event[] eventTable = asm.Tables.Event;
if (eventMapTable == null || eventTable == null) {
return;
}
for (int i = 1; i <= eventMapTable.GetUpperBound(0); ++i) {
EventMap eventMap = eventMapTable[i];
if (eventMap.Parent == index) {
uint eventIndexStart = eventMap.EventList;
// 0 means no events
if (eventIndexStart == 0) {
return;
}
uint eventIndexEnd = (uint)eventTable.GetUpperBound(0) + 1;
if (i < eventMapTable.GetUpperBound(0)) {
eventIndexEnd = eventMapTable[i + 1].EventList;
}
for (uint j = eventIndexStart; j < eventIndexEnd; ++j) {
IEvent newEvent = new SharpAssemblyEvent(asm, eventTable, this, j);
Events.Add(newEvent);
}
break;
}
}
}
void AddProperties(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index)
{
PropertyMap[] propertyMapTable = asm.Tables.PropertyMap;
Property[] propertyTable = asm.Tables.Property;
if (propertyMapTable == null || propertyTable == null) {
return;
}
for (int i = 1; i <= propertyMapTable.GetUpperBound(0); ++i) {
PropertyMap propertyMap = propertyMapTable[i];
if (propertyMap.Parent == index) {
uint propertyIndexStart = propertyMap.PropertyList;
// 0 means no properties
if (propertyIndexStart == 0) {
return;
}
uint propertyIndexEnd = (uint)propertyTable.GetUpperBound(0) + 1;
if (i < propertyMapTable.GetUpperBound(0)) {
propertyIndexEnd = propertyMapTable[i + 1].PropertyList;
}
for (uint j = propertyIndexStart; j < propertyIndexEnd; ++j) {
IProperty newProperty = new SharpAssemblyProperty(asm, propertyTable, this, j);
Properties.Add(newProperty);
}
break;
}
}
}
void AddFields(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index)
{
Field[] fieldTable = asm.Tables.Field;
if (fieldTable == null) {
return;
}
uint fieldIndexStart = typeDefTable[index].FieldList;
// 0 means no fields
if (fieldIndexStart == 0) {
return;
}
uint fieldIndexEnd = (uint)fieldTable.GetUpperBound(0) + 1;
if (index < typeDefTable.GetUpperBound(0)) {
fieldIndexEnd = typeDefTable[index + 1].FieldList;
}
for (uint i = fieldIndexStart; i < fieldIndexEnd; ++i) {
IField newField = new SharpAssemblyField(asm, fieldTable, this, i);
Fields.Add(newField);
}
}
void AddMethods(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index)
{
Method[] methodDefTable = asm.Tables.Method;
if (methodDefTable == null) {
return;
}
uint methodIndexStart = typeDefTable[index].MethodList;
// 0 means no methods
if (methodIndexStart == 0) {
return;
}
uint methodIndexEnd = (uint)methodDefTable.GetUpperBound(0) + 1;
if (index < typeDefTable.GetUpperBound(0)) {
methodIndexEnd = typeDefTable[index + 1].MethodList;
}
for (uint i = methodIndexStart; i < methodIndexEnd; ++i) {
IMethod newMethod = new SharpAssemblyMethod(asm, methodDefTable, this, i);
Methods.Add(newMethod);
}
}
public static SharpAssemblyClass[] GetAssemblyTypes(SA.SharpAssembly assembly)
{
TypeDef[] typeDefTable = assembly.Tables.TypeDef;
if (typeDefTable == null) return new SharpAssemblyClass[0];
ArrayList classes = new ArrayList();
for (uint i = 1; i <= typeDefTable.GetUpperBound(0); ++i) {
try {
IClass newclass = new SharpAssemblyClass(assembly, typeDefTable, i);
classes.Add(newclass);
} catch {
Console.WriteLine("GetAssemblyTypes: Error loading class " + i);
}
}
return (SharpAssemblyClass[])classes.ToArray(typeof(SharpAssemblyClass));
}
public override string ToString()
{
return FullyQualifiedName;
}
public override List<IField> Fields {
get {
if (!membersLoaded) LoadMembers();
return base.Fields;
}
}
public override List<IProperty> Properties {
get {
if (!membersLoaded) LoadMembers();
return base.Properties;
}
}
public override List<IMethod> Methods {
get {
if (!membersLoaded) LoadMembers();
return base.Methods;
}
}
public override List<IEvent> Events {
get {
if (!membersLoaded) LoadMembers();
return base.Events;
}
}
}
}

135
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyEvent.cs

@ -0,0 +1,135 @@ @@ -0,0 +1,135 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections;
using System.Text;
using System.Reflection;
using System.Xml;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpAssembly.Metadata.Rows;
using ICSharpCode.SharpAssembly.Metadata;
using ICSharpCode.SharpAssembly.PE;
using ICSharpCode.SharpAssembly.Assembly;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
[Serializable]
public class SharpAssemblyEvent : DefaultEvent
{
public override string DocumentationTag {
get {
return null;
}
}
public SharpAssemblyEvent(SA.SharpAssembly asm, Event[] eventTable, SharpAssemblyClass declaringType, uint index) : base(declaringType, null)
{
if (asm == null) {
throw new System.ArgumentNullException("asm");
}
if (eventTable == null) {
throw new System.ArgumentNullException("eventTable");
}
if (declaringType == null) {
throw new System.ArgumentNullException("declaringtype");
}
if (index > eventTable.GetUpperBound(0) || index < 1) {
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", eventTable.GetUpperBound(0)));
}
AssemblyReader assembly = asm.Reader;
Event evt = eventTable[index];
string name = assembly.GetStringFromHeap(evt.Name);
FullyQualifiedName = String.Concat(DeclaringType.FullyQualifiedName, ".", name);
MethodSemantics[] sem = asm.Tables.MethodSemantics;
Method[] method = asm.Tables.Method;
if (sem == null) goto nosem;
for (int i = 1; i <= sem.GetUpperBound(0); ++i) {
uint table = sem[i].Association & 1;
uint ident = sem[i].Association >> 1;
if (table == 0 && ident == index) { // table: Event
Modifiers = ModifierEnum.None;
Method methodDef = method[sem[i].Method];
if (methodDef.IsFlagSet(Method.FLAG_STATIC)) {
Modifiers |= ModifierEnum.Static;
}
if (methodDef.IsMaskedFlagSet(Method.FLAG_PRIVATE, Method.FLAG_MEMBERACCESSMASK)) { // I assume that private is used most and public last (at least should be)
Modifiers |= ModifierEnum.Private;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMILY, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Protected;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_PUBLIC, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Public;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_ASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Internal;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMORASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.ProtectedOrInternal;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMANDASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Protected;
Modifiers |= ModifierEnum.Internal;
}
if ((sem[i].Semantics & MethodSemantics.SEM_ADDON) == MethodSemantics.SEM_ADDON) {
addMethod = new SharpAssemblyMethod(asm, method, declaringType, sem[i].Method);
}
if ((sem[i].Semantics & MethodSemantics.SEM_REMOVEON) == MethodSemantics.SEM_REMOVEON) {
removeMethod = new SharpAssemblyMethod(asm, method, declaringType, sem[i].Method);
}
if ((sem[i].Semantics & MethodSemantics.SEM_FIRE) == MethodSemantics.SEM_FIRE) {
raiseMethod = new SharpAssemblyMethod(asm, method, declaringType, sem[i].Method);
}
}
}
nosem:
// Attributes
ArrayList attrib = asm.Attributes.Event[index] as ArrayList;
if (attrib == null) goto noatt;
foreach(SharpCustomAttribute customattribute in attrib) {
Attributes.Add(new SharpAssemblyAttribute(asm, customattribute));
}
noatt:
if ((evt.EventFlags & Event.FLAG_SPECIALNAME) == Event.FLAG_SPECIALNAME) Modifiers |= ModifierEnum.Extern | ModifierEnum.Volatile | ModifierEnum.Unsafe;
uint typtab = evt.EventType & 0x03;
uint typid = evt.EventType >> 2;
if (typtab == 0) { // TypeDef
TypeDef[] typedef = (TypeDef[])assembly.MetadataTable.Tables[TypeDef.TABLE_ID];
ReturnType = SharpAssemblyReturnType.Create(asm, typedef, typid);
} else if (typtab == 1) { // TypeRef
TypeRef[] typeref = (TypeRef[])assembly.MetadataTable.Tables[TypeRef.TABLE_ID];
ReturnType = SharpAssemblyReturnType.Create(asm, typeref, typid);
} else { // TypeSpec
ReturnType = SharpAssemblyReturnType.Create("NOT_SUPPORTED");
Console.WriteLine("SharpAssemblyEvent: TypeSpec -- not supported");
}
}
public override string ToString()
{
return FullyQualifiedName;
}
}
}

161
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyField.cs

@ -0,0 +1,161 @@ @@ -0,0 +1,161 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections;
using System.Text;
using System.IO;
using System.Xml;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpAssembly.Metadata.Rows;
using ICSharpCode.SharpAssembly.Metadata;
using ICSharpCode.SharpAssembly.PE;
using ICSharpCode.SharpAssembly.Assembly;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
[Serializable]
public class SharpAssemblyField : DefaultField
{
public override string DocumentationTag {
get {
return null;
}
}
public SharpAssemblyField(SA.SharpAssembly assembly, Field[] fieldTable, SharpAssemblyClass declaringType, uint index) : base(declaringType, null)
{
if (assembly == null) {
throw new System.ArgumentNullException("assembly");
}
if (fieldTable == null) {
throw new System.ArgumentNullException("fieldTable");
}
if (declaringType == null) {
throw new System.ArgumentNullException("declaringType");
}
if (index > fieldTable.GetUpperBound(0) || index < 0) {
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", fieldTable.GetUpperBound(0)));
}
Field field = fieldTable[index];
string name = assembly.Reader.GetStringFromHeap(field.Name);
FullyQualifiedName = String.Concat(DeclaringType.FullyQualifiedName, ".", name);
// Attributes
ArrayList attrib = assembly.Attributes.Field[index] as ArrayList;
if (attrib == null) goto noatt;
foreach(SharpCustomAttribute customattribute in attrib) {
Attributes.Add(new SharpAssemblyAttribute(assembly, customattribute));
}
noatt:
if (field.IsFlagSet(Field.FLAG_INITONLY)) {
Modifiers |= ModifierEnum.Readonly;
}
if (field.IsFlagSet(Field.FLAG_STATIC)) {
Modifiers |= ModifierEnum.Static;
}
if (field.IsMaskedFlagSet(Field.FLAG_PRIVATE, Field.FLAG_FIELDACCESSMASK)) { // I assume that private is used most and public last (at least should be)
Modifiers |= ModifierEnum.Private;
} else if (field.IsMaskedFlagSet(Field.FLAG_FAMILY, Field.FLAG_FIELDACCESSMASK)) {
Modifiers |= ModifierEnum.Protected;
} else if (field.IsMaskedFlagSet(Field.FLAG_PUBLIC, Field.FLAG_FIELDACCESSMASK)) {
Modifiers |= ModifierEnum.Public;
} else if (field.IsMaskedFlagSet(Field.FLAG_ASSEMBLY, Field.FLAG_FIELDACCESSMASK)) {
Modifiers |= ModifierEnum.Internal;
} else if (field.IsMaskedFlagSet(Field.FLAG_FAMORASSEM, Field.FLAG_FIELDACCESSMASK)) {
Modifiers |= ModifierEnum.ProtectedOrInternal;
} else if (field.IsMaskedFlagSet(Field.FLAG_FAMANDASSEM, Field.FLAG_FIELDACCESSMASK)) {
Modifiers |= ModifierEnum.Protected;
Modifiers |= ModifierEnum.Internal;
}
if (field.IsFlagSet(Field.FLAG_LITERAL)) {
Modifiers |= ModifierEnum.Const;
}
if (field.IsFlagSet(Field.FLAG_SPECIALNAME)) {
Modifiers |= ModifierEnum.Extern | ModifierEnum.Unsafe | ModifierEnum.Volatile;
}
// field return type
uint sigOffset = field.Signature;
int sigSize = assembly.Reader.LoadBlob(ref sigOffset);
sigOffset++; // skip field id
ReturnType = SharpAssemblyReturnType.Create(assembly, ref sigOffset);
// field constant value -- for enums
Constant cst = (Constant)assembly.FieldConstantTable[index];
if (declaringType.ClassType == ClassType.Enum && cst != null) {
try {
DataType dt = (DataType)cst.Type;
byte[] blob = assembly.Reader.GetBlobFromHeap(cst.Val);
BinaryReader binReader = new BinaryReader(new MemoryStream(blob));
switch (dt) {
case DataType.Byte:
initialValue = binReader.ReadByte();
break;
case DataType.Int16:
initialValue = binReader.ReadInt16();
break;
case DataType.Int32:
initialValue = binReader.ReadInt32();
break;
case DataType.Int64:
initialValue = binReader.ReadInt64();
break;
case DataType.SByte:
initialValue = binReader.ReadSByte();
break;
case DataType.UInt16:
initialValue = binReader.ReadUInt16();
break;
case DataType.UInt32:
initialValue = binReader.ReadUInt32();
break;
case DataType.UInt64:
initialValue = binReader.ReadUInt64();
break;
default: // not supported
break;
}
binReader.Close();
} catch {
Console.WriteLine("SharpAssemblyField: Error reading constant value");
}
}
}
public override string ToString()
{
return FullyQualifiedName;
}
object initialValue;
public object InitialValue {
get {
return initialValue;
}
}
public static bool IsSpecial(IField field)
{
return ((field.Modifiers & ModifierEnum.Extern) == ModifierEnum.Extern) ||
((field.Modifiers & ModifierEnum.Volatile) == ModifierEnum.Volatile) ||
((field.Modifiers & ModifierEnum.Unsafe) == ModifierEnum.Unsafe);
}
}
}

158
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyMethod.cs

@ -0,0 +1,158 @@ @@ -0,0 +1,158 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Diagnostics;
using System.Collections;
using System.Text;
using System.Reflection;
using System.Xml;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpAssembly.Metadata.Rows;
using ICSharpCode.SharpAssembly.Metadata;
using ICSharpCode.SharpAssembly.PE;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
[Serializable]
public class SharpAssemblyMethod : DefaultMethod
{
public override string DocumentationTag {
get {
return null;
}
}
public SharpAssemblyMethod(SA.SharpAssembly asm, Method[] methodTable, SharpAssemblyClass declaringType, uint index) : base(declaringType, null)
{
if (asm == null) {
throw new System.ArgumentNullException("asm");
}
if (methodTable == null) {
throw new System.ArgumentNullException("methodTable");
}
if (declaringType == null) {
throw new System.ArgumentNullException("declaringType");
}
if (index > methodTable.GetUpperBound(0) || index < 1) {
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", methodTable.GetUpperBound(0)));
}
SA.AssemblyReader assembly = asm.Reader;
Method methodDef = methodTable[index];
string name = assembly.GetStringFromHeap(methodDef.Name);
FullyQualifiedName = String.Concat(DeclaringType.FullyQualifiedName, ".", name);
// Attributes
ArrayList attrib = asm.Attributes.Method[index] as ArrayList;
if (attrib == null) goto noatt;
foreach(SA.SharpCustomAttribute customattribute in attrib) {
Attributes.Add(new SharpAssemblyAttribute(asm, customattribute));
}
noatt:
Modifiers = ModifierEnum.None;
if (methodDef.IsFlagSet(Method.FLAG_STATIC)) {
Modifiers |= ModifierEnum.Static;
}
if (methodDef.IsMaskedFlagSet(Method.FLAG_PRIVATE, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Private;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_PUBLIC, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Public;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMILY, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Protected;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_ASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Internal;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMORASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.ProtectedOrInternal;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMANDASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Protected;
Modifiers |= ModifierEnum.Internal;
}
if (methodDef.IsFlagSet(Method.FLAG_VIRTUAL)) {
Modifiers |= ModifierEnum.Virtual;
}
if (methodDef.IsFlagSet(Method.FLAG_FINAL)) {
Modifiers |= ModifierEnum.Default;
}
if (methodDef.IsFlagSet(Method.FLAG_ABSTRACT)) {
Modifiers |= ModifierEnum.Abstract;
}
if (methodDef.IsFlagSet(Method.FLAG_SPECIALNAME)) {
Modifiers |= ModifierEnum.Extern | ModifierEnum.Volatile | ModifierEnum.Unsafe;
}
uint offset = methodDef.Signature;
int size = assembly.LoadBlob(ref offset);
offset += 1; // skip calling convention
int numReturnTypes = assembly.LoadBlob(ref offset);
ReturnType = SharpAssemblyReturnType.Create(asm, ref offset);
IReturnType[] returnTypes = new IReturnType[numReturnTypes];
for (int i = 0; i < returnTypes.Length; ++i) {
returnTypes[i] = SharpAssemblyReturnType.Create(asm, ref offset);
}
AddParameters(asm, methodTable, index, returnTypes);
}
public static bool IsSpecial(IMethod method)
{
return ((method.Modifiers & ModifierEnum.Extern) == ModifierEnum.Extern) ||
((method.Modifiers & ModifierEnum.Volatile) == ModifierEnum.Volatile) ||
((method.Modifiers & ModifierEnum.Unsafe) == ModifierEnum.Unsafe);
}
void AddParameters(SA.SharpAssembly asm, Method[] methodDefTable, uint index, IReturnType[] returnTypes)
{
Param[] paramTable = asm.Tables.Param;
if (paramTable == null) return;
uint paramIndexStart = methodDefTable[index].ParamList;
// 0 means no parameters
if (paramIndexStart > paramTable.GetUpperBound(0) || paramIndexStart == 0) {
return;
}
uint paramIndexEnd = (uint)paramTable.GetUpperBound(0);
if (index < methodDefTable.GetUpperBound(0)) {
paramIndexEnd = methodDefTable[index + 1].ParamList;
}
if (paramTable[paramIndexStart].Sequence == 0) paramIndexStart++;
for (uint i = paramIndexStart; i < paramIndexEnd; ++i) {
uint j = (i - paramIndexStart);
Parameters.Add(new SharpAssemblyParameter(asm, paramTable, i, j < returnTypes.Length ? returnTypes[j] : null));
}
}
public override bool IsConstructor {
get {
return FullyQualifiedName.IndexOf("..") != -1;
}
}
public override string ToString()
{
return FullyQualifiedName;
}
}
}

83
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyParameter.cs

@ -0,0 +1,83 @@ @@ -0,0 +1,83 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections;
using System.Text;
using System.Reflection;
using System.Xml;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpAssembly.Metadata.Rows;
using ICSharpCode.SharpAssembly.Metadata;
using ICSharpCode.SharpAssembly.PE;
using ICSharpCode.SharpAssembly.Assembly;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
[Serializable]
public class SharpAssemblyParameter : DefaultParameter
{
public SharpAssemblyParameter(SA.SharpAssembly asm, Param[] paramTable, uint index, IReturnType type) : base(String.Empty)
{
if (asm == null) {
throw new System.ArgumentNullException("asm");
}
if (paramTable == null) {
throw new System.ArgumentNullException("paramTable");
}
if (index > paramTable.GetUpperBound(0) || index < 1) {
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", paramTable.GetUpperBound(0)));
}
AssemblyReader assembly = asm.Reader;
Param param = asm.Tables.Param[index];
Name = assembly.GetStringFromHeap(param.Name);
if (param.IsFlagSet(Param.FLAG_OUT)) {
Modifiers |= ParameterModifiers.Out;
}
// Attributes
ArrayList attrib = asm.Attributes.Param[index] as ArrayList;
if (attrib == null) goto noatt;
foreach(SharpCustomAttribute customattribute in attrib) {
SharpAssemblyAttribute newatt = new SharpAssemblyAttribute(asm, customattribute);
if (newatt.Name == "System.ParamArrayAttribute") Modifiers |= ParameterModifiers.Params;
Attributes.Add(newatt);
}
noatt:
if (type == null) {
returnType = SharpAssemblyReturnType.Create("PARAMETER_UNKNOWN");
} else {
if (type.Name.EndsWith("&")) {
Modifiers |= ParameterModifiers.Ref;
}
returnType = type;
}
}
public SharpAssemblyParameter(SA.SharpAssembly asm, string paramName, IReturnType type) : base(String.Empty)
{
Name = paramName;
if (type.Name.EndsWith("&")) {
Modifiers |= ParameterModifiers.Ref;
}
returnType = type;
}
public override string ToString()
{
return "Parameter : " + returnType.FullyQualifiedName;
}
}
}

184
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyProperty.cs

@ -0,0 +1,184 @@ @@ -0,0 +1,184 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections;
using System.Text;
using System.Reflection;
using System.Xml;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpAssembly.Metadata.Rows;
using ICSharpCode.SharpAssembly.Metadata;
using ICSharpCode.SharpAssembly.PE;
using ICSharpCode.SharpAssembly.Assembly;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
[Serializable]
public class SharpAssemblyProperty : DefaultProperty
{
public override string DocumentationTag {
get {
return null;
}
}
public SharpAssemblyProperty(SA.SharpAssembly asm, Property[] propertyTable, SharpAssemblyClass declaringType, uint index) : base(declaringType, String.Empty)
{
if (asm == null) {
throw new System.ArgumentNullException("asm");
}
if (propertyTable == null) {
throw new System.ArgumentNullException("propertyTable");
}
if (declaringType == null) {
throw new System.ArgumentNullException("declaringType");
}
if (index > propertyTable.GetUpperBound(0) || index < 1) {
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", propertyTable.GetUpperBound(0)));
}
AssemblyReader assembly = asm.Reader;
Property property = asm.Tables.Property[index];
string name = assembly.GetStringFromHeap(property.Name);
FullyQualifiedName = String.Concat(DeclaringType.FullyQualifiedName, ".", name);
MethodSemantics[] sem = (MethodSemantics[])assembly.MetadataTable.Tables[MethodSemantics.TABLE_ID];
Method[] method = (Method[])assembly.MetadataTable.Tables[Method.TABLE_ID];
uint getterMethodIndex = 0; // used later for parameters
if (sem == null) goto nosem;
for (int i = 1; i <= sem.GetUpperBound(0); ++i) {
uint table = sem[i].Association & 1;
uint ident = sem[i].Association >> 1;
if (table == 1 && ident == index) { // table: Property
Modifiers = ModifierEnum.None;
Method methodDef = method[sem[i].Method];
if (methodDef.IsFlagSet(Method.FLAG_STATIC)) {
Modifiers |= ModifierEnum.Static;
}
if (methodDef.IsFlagSet(Method.FLAG_ABSTRACT)) {
Modifiers |= ModifierEnum.Abstract;
}
if (methodDef.IsFlagSet(Method.FLAG_VIRTUAL)) {
Modifiers |= ModifierEnum.Virtual;
}
if (methodDef.IsFlagSet(Method.FLAG_FINAL)) {
Modifiers |= ModifierEnum.Default;
}
if (methodDef.IsMaskedFlagSet(Method.FLAG_PRIVATE, Method.FLAG_MEMBERACCESSMASK)) { // I assume that private is used most and public last (at least should be)
Modifiers |= ModifierEnum.Private;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMILY, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Protected;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_PUBLIC, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Public;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_ASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Internal;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMORASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.ProtectedOrInternal;
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMANDASSEM, Method.FLAG_MEMBERACCESSMASK)) {
Modifiers |= ModifierEnum.Protected;
Modifiers |= ModifierEnum.Internal;
}
if ((sem[i].Semantics & MethodSemantics.SEM_GETTER) == MethodSemantics.SEM_GETTER) {
GetterRegion = new DomRegion(0, 0, 0, 0);
// TODO GetterMethod missing.
// GetterMethod = new SharpAssemblyMethod(asm, method, declaringtype, sem[i].Method);
// GetterMethodIndex = sem[i].Method;
}
if ((sem[i].Semantics & MethodSemantics.SEM_SETTER) == MethodSemantics.SEM_SETTER) {
SetterRegion = new DomRegion(0, 0, 0, 0);
// TODO SetterMethod missing.
// SetterMethod = new SharpAssemblyMethod(asm, method, declaringtype, sem[i].Method);
}
}
}
nosem:
// Attributes
ArrayList attrib = asm.Attributes.Property[index] as ArrayList;
if (attrib == null) goto noatt;
foreach(SA.SharpCustomAttribute customattribute in attrib) {
Attributes.Add(new SharpAssemblyAttribute(asm, customattribute));
}
noatt:
if ((property.Flags & Property.FLAG_SPECIALNAME) == Property.FLAG_SPECIALNAME) Modifiers |= ModifierEnum.Extern | ModifierEnum.Volatile | ModifierEnum.Unsafe;
uint offset = property.Type;
int sigSize = assembly.LoadBlob(ref offset);
offset += 1; // skip calling convention
int paramCount = assembly.LoadBlob(ref offset);
ReturnType = SharpAssemblyReturnType.Create(asm, ref offset);
IReturnType[] returnTypes = new IReturnType[paramCount];
for (int i = 0; i < returnTypes.Length; ++i) {
returnTypes[i] = SharpAssemblyReturnType.Create(asm, ref offset);
}
if (getterMethodIndex != 0) {
AddParameters(asm, asm.Tables.Method, getterMethodIndex, returnTypes);
} else {
AddParameters(asm, returnTypes);
}
}
void AddParameters(SA.SharpAssembly asm, Method[] methodTable, uint index, IReturnType[] returnTypes)
{
Param[] paramTable = asm.Tables.Param;
if (paramTable == null) return;
uint paramIndexStart = methodTable[index].ParamList;
// 0 means no parameters
if (paramIndexStart > paramTable.GetUpperBound(0) || paramIndexStart == 0) {
return;
}
uint paramIndexEnd = (uint)paramTable.GetUpperBound(0);
if (index < methodTable.GetUpperBound(0)) {
paramIndexEnd = methodTable[index + 1].ParamList;
}
if (paramTable[paramIndexStart].Sequence == 0) paramIndexStart++;
for (uint i = paramIndexStart; i < paramIndexEnd; ++i) {
uint j = (i - paramIndexStart);
Parameters.Add(new SharpAssemblyParameter(asm, paramTable, i, j < returnTypes.Length ? returnTypes[j] : null));
}
}
void AddParameters(SA.SharpAssembly asm, IReturnType[] returnTypes)
{
for (uint i = 0; i < returnTypes.GetUpperBound(0); ++i) {
Parameters.Add(new SharpAssemblyParameter(asm, "param_" + i, returnTypes[i]));
}
}
public override string ToString()
{
return FullyQualifiedName;
}
}
}

225
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SharpAssemblyLayer/SharpAssemblyReturnType.cs

@ -0,0 +1,225 @@ @@ -0,0 +1,225 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections;
using System.Text;
using System.Reflection;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpAssembly.Metadata.Rows;
using ICSharpCode.SharpAssembly.Metadata;
using ICSharpCode.SharpAssembly.PE;
using ICSharpCode.SharpAssembly.Assembly;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
[Serializable]
public class SharpAssemblyReturnType : DefaultReturnType
{
object declaredIn;
SharpAssemblyClass underlyingClass;
public SharpAssemblyClass UnderlyingClass {
get {
return underlyingClass;
}
}
public object DeclaredIn {
get {
return declaredIn;
}
}
public override string ToString()
{
return FullyQualifiedName;
}
public static SharpAssemblyReturnType Create(string name)
{
return new SharpAssemblyReturnType(name);
}
public static SharpAssemblyReturnType Create(SA.SharpAssembly assembly, TypeRef[] typeRefTable, uint index)
{
string fullyQualifiedName = String.Empty;
SharpAssemblyClass underlyingClass = SharpAssemblyClass.FromTypeRef(assembly, index);
if (underlyingClass != null) {
fullyQualifiedName = underlyingClass.FullyQualifiedName;
} else {
fullyQualifiedName = assembly.Reader.GetStringFromHeap(typeRefTable[index].Nspace) + "." +
assembly.Reader.GetStringFromHeap(typeRefTable[index].Name);
LoggingService.Warn("SharpAssemblyReturnType from TypeRef: TypeRef not resolved!");
}
return new SharpAssemblyReturnType(fullyQualifiedName, underlyingClass, assembly.GetRefAssemblyFor(index));
}
public static SharpAssemblyReturnType Create(SA.SharpAssembly assembly, TypeDef[] typeDefTable, uint index)
{
string fullyQualifiedName = String.Empty;
SharpAssemblyClass underlyingClass = SharpAssemblyClass.FromTypeDef(assembly, index);
if (underlyingClass != null) {
fullyQualifiedName = underlyingClass.FullyQualifiedName;
} else {
fullyQualifiedName = assembly.Reader.GetStringFromHeap(typeDefTable[index].NSpace) + "." +
assembly.Reader.GetStringFromHeap(typeDefTable[index].Name);
}
return new SharpAssemblyReturnType(fullyQualifiedName, underlyingClass, assembly);
}
public static SharpAssemblyReturnType Create(SA.SharpAssembly assembly, ref uint blobSignatureIndex)
{
ArrayList arrayRanks = new ArrayList();
string fullyQualifiedName = String.Empty;
SA.SharpAssembly declaredIn = null;
SharpAssemblyClass underlyingClass = null;
try {
GetDataType(assembly, ref blobSignatureIndex, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn);
} catch (Exception e) {
LoggingService.Error("Got exception in ReturnType creation: " + e.ToString());
fullyQualifiedName = "GOT_EXCEPTION";
}
// if (this.arrayRanks.Count > 0) {
// arrayDimensions = new int[arrayRanks.Count];
// arrayRanks.CopyTo(arrayDimensions, 0);
// } else {
// arrayRanks = null;
// }
return new SharpAssemblyReturnType(fullyQualifiedName, underlyingClass, declaredIn);
}
SharpAssemblyReturnType(string name) : base(new DefaultClass(null, name))
{
}
SharpAssemblyReturnType(string name, SharpAssemblyClass underlyingClass, SA.SharpAssembly declaredIn) : this(name)
{
this.declaredIn = declaredIn;
this.underlyingClass = underlyingClass;
}
static void GetDataType(SA.SharpAssembly asm, ref uint offset, ref ArrayList arrayRanks, ref string fullyQualifiedName, ref SharpAssemblyClass underlyingClass, ref SA.SharpAssembly declaredIn)
{
AssemblyReader assembly = asm.Reader;
DataType dt = (DataType)assembly.LoadBlob(ref offset);
switch (dt) {
case DataType.Void:
case DataType.Boolean:
case DataType.Char:
case DataType.SByte:
case DataType.Byte:
case DataType.Int16:
case DataType.UInt16:
case DataType.Int32:
case DataType.UInt32:
case DataType.Int64:
case DataType.UInt64:
case DataType.Single:
case DataType.Double:
case DataType.String:
case DataType.Object:
case DataType.IntPtr:
case DataType.UIntPtr:
fullyQualifiedName = "System." + dt.ToString();
declaredIn = asm.GetReference("mscorlib");
break;
case DataType.SZArray:
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn);
arrayRanks.Add(0);
break;
case DataType.Array:
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn);
int rank = assembly.LoadBlob(ref offset);
int num_sizes = assembly.LoadBlob(ref offset);
int[] sizes = new int[num_sizes];
for (int i = 0; i < num_sizes; ++i) {
sizes[i] = assembly.LoadBlob(ref offset);
}
int num_lowerBounds = assembly.LoadBlob(ref offset);
int[] lowerBounds = new int[num_lowerBounds];
for (int i = 0; i < num_lowerBounds; ++i) {
lowerBounds[i] = assembly.LoadBlob(ref offset);
}
arrayRanks.Add(rank - 1);
break;
case DataType.ValueType:
case DataType.Class:
uint idx = (uint)assembly.LoadBlob(ref offset);
bool isTypeRef = (idx & 1) == 1;
uint index = (idx >> 2);
TypeDef[] typeDefTable = asm.Tables.TypeDef;
TypeRef[] typeRefTable = asm.Tables.TypeRef;
if (isTypeRef) {
underlyingClass = SharpAssemblyClass.FromTypeRef(asm, index);
if (underlyingClass != null) {
fullyQualifiedName = underlyingClass.FullyQualifiedName;
} else {
fullyQualifiedName = assembly.GetStringFromHeap(typeRefTable[index].Nspace) + "." +
assembly.GetStringFromHeap(typeRefTable[index].Name);
LoggingService.Warn("GetDataType: TypeRef not resolved!");
}
declaredIn = asm.GetRefAssemblyFor(index);
} else {
underlyingClass = SharpAssemblyClass.FromTypeDef(asm, index);
if (underlyingClass != null) {
fullyQualifiedName = underlyingClass.FullyQualifiedName;
} else {
fullyQualifiedName = assembly.GetStringFromHeap(typeDefTable[index].NSpace) + "." +
assembly.GetStringFromHeap(typeDefTable[index].Name);
}
declaredIn = asm;
}
break;
case DataType.Ptr:
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn);
break;
case DataType.ByRef:
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn);
fullyQualifiedName += "&";
break;
case DataType.TypeReference:
fullyQualifiedName = "typedref";
break;
case DataType.Pinned:
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn);
//fullyQualifiedName += " pinned";
break;
case DataType.CModOpt:
case DataType.CModReq:
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn);
break;
default:
//Console.WriteLine("NOT supported: " + dt.ToString());
fullyQualifiedName += " NOT_SUPPORTED [" + dt.ToString() + "]";
break;
}
}
}
}

24
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/SourceView.cs

@ -8,11 +8,14 @@ @@ -8,11 +8,14 @@
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using SA = ICSharpCode.SharpAssembly.Assembly;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
@ -34,9 +37,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -34,9 +37,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
rtb = new RichTextBox();
rtb.ReadOnly = true;
ambience = AmbienceService.CurrentAmbience;
rtb.Font = ResourceService.LoadFont("Courier New", 10);
@ -58,7 +58,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -58,7 +58,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
chk = new CheckBox();
chk.Location = new Point(0, 0);
chk.Size = new Size(250, 16);
chk.Text = tree.ress.GetString("ObjectBrowser.SourceView.Enable");
chk.Text = StringParser.Parse("${res:ObjectBrowser.SourceView.Enable}");
chk.FlatStyle = FlatStyle.System;
chk.CheckedChanged += new EventHandler(Check);
Check(null, null);
@ -83,7 +83,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -83,7 +83,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
if (member.Attributes.Count == 0) {
return String.Empty;
}
return GetAttributes(indent, member.Attributes[0].Attributes);
return GetAttributes(indent, member.Attributes);
}
string GetAttributes(int indent, IClass type)
@ -91,7 +91,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -91,7 +91,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
if (type.Attributes.Count == 0) {
return String.Empty;
}
return GetAttributes(indent, type.Attributes[0].Attributes);
return GetAttributes(indent, type.Attributes);
}
string GetAttributes(int indent, SA.SharpAssembly assembly)
@ -99,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -99,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
return GetAttributes(indent, SharpAssemblyAttribute.GetAssemblyAttributes(assembly));
}
string GetAttributes(int indent, AttributeCollection ca)
string GetAttributes(int indent, IList<IAttribute> ca)
{
StringBuilder text = new StringBuilder();
try {
@ -117,7 +117,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -117,7 +117,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
StringBuilder rt = new StringBuilder();
{
string attr2 = GetAttributes(0, (SA.SharpAssembly)type.DeclaredIn);
string attr2 = GetAttributes(0, (SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn);
rt.Append(ambience.WrapComment("assembly attributes\n") + attr2 + "\n" + ambience.WrapComment("declaration\n"));
}
string attr = GetAttributes(0, type);
@ -137,7 +137,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -137,7 +137,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
rt.Append("\t" + ambience.WrapComment("methods\n"));
foreach (IMethod methodinfo in type.Methods) {
if (methodinfo.IsSpecialName) {
if (SharpAssemblyMethod.IsSpecial(methodinfo)) {
continue;
}
ambience.ConversionFlags |= ConversionFlags.ShowReturnType;
@ -164,8 +164,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -164,8 +164,8 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
rt.Append("\t" + ambience.Convert(eventinfo) + "\n");
}
} else { // Enum
foreach (IField fieldinfo in type.Fields) {
if (fieldinfo.IsLiteral) {
foreach (IField fieldinfo in type.Fields) {
if (fieldinfo.IsConst) {
attr = GetAttributes(1, fieldinfo);
rt.Append(attr);
rt.Append("\t" + fieldinfo.Name);
@ -209,7 +209,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -209,7 +209,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
nsContents.Append("\n}");
return nsContents.ToString();
default:
return tree.ress.GetString("ObjectBrowser.SourceView.NoView");
return StringParser.Parse("${res:ObjectBrowser.SourceView.NoView}");
}
}
// return String.Empty;

209
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/TempProject.cs

@ -8,19 +8,17 @@ @@ -8,19 +8,17 @@
using System;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Reflection;
using System.Diagnostics;
using System.CodeDom.Compiler;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Internal.Project;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Internal.Project.Collections;
using UI = WeifenLuo.WinFormsUI;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
@ -35,11 +33,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -35,11 +33,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
get { return System.IO.Path.GetTempPath(); }
}
public bool IsDirty {
get { return false; }
set {}
}
public string Name {
get { return "Temp"; }
set {}
@ -55,39 +48,180 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -55,39 +48,180 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
set {}
}
public IConfiguration ActiveConfiguration {
get { return null; }
set {}
public List<ProjectItem> Items {
get {
return null;
}
}
public IConfiguration GetConfiguration(int index) {
return null;
public bool IsDirty {
get {
return false;
}
set {
throw new NotImplementedException();
}
}
public void AddConfiguration(IConfiguration c)
{
public string Language {
get {
return String.Empty;
}
}
public void RemoveConfiguration(IConfiguration c)
{
public LanguageProperties LanguageProperties {
get {
return null;
}
}
public ConfigurationCollection Configurations
{
get { return null; }
public IAmbience Ambience {
get {
return null;
}
}
public ProjectFileCollection ProjectFiles {
get { return null; }
public string FileName {
get {
return String.Empty;
}
}
public ProjectReferenceCollection ProjectReferences {
get { return new ProjectReferenceCollection(); }
public string Directory {
get {
return String.Empty;
}
}
public NewFileSearch NewFileSearch {
get { return 0; }
set {}
public string Configuration {
get {
return String.Empty;
}
}
public string Platform {
get {
return String.Empty;
}
}
public string OutputAssemblyFullPath {
get {
return String.Empty;
}
}
public OutputType OutputType {
get {
return OutputType.Library;
}
set {
throw new NotImplementedException();
}
}
public string RootNamespace {
get {
return String.Empty;
}
set {
throw new NotImplementedException();
}
}
public string AppDesignerFolder {
get {
return String.Empty;
}
set {
throw new NotImplementedException();
}
}
public bool IsStartable {
get {
return false;
}
}
public ISolutionFolderContainer Parent {
get {
return null;
}
set {
throw new NotImplementedException();
}
}
public string TypeGuid {
get {
return String.Empty;
}
set {
throw new NotImplementedException();
}
}
public string IdGuid {
get {
return String.Empty;
}
set {
throw new NotImplementedException();
}
}
public string Location {
get {
return String.Empty;
}
set {
throw new NotImplementedException();
}
}
public bool CanCompile(string fileName) {
throw new NotImplementedException();
}
public void Save() {
throw new NotImplementedException();
}
public void Save(string fileName) {
throw new NotImplementedException();
}
public void Start(bool withDebugging) {
throw new NotImplementedException();
}
public ParseProjectContent CreateProjectContent() {
throw new NotImplementedException();
}
public CompilerResults Build() {
throw new NotImplementedException();
}
public CompilerResults Rebuild() {
throw new NotImplementedException();
}
public CompilerResults Clean() {
throw new NotImplementedException();
}
public CompilerResults Publish() {
throw new NotImplementedException();
}
public Properties CreateMemento() {
throw new NotImplementedException();
}
public void SetMemento(Properties memento) {
throw new NotImplementedException();
}
public bool EnableViewState {
@ -99,9 +233,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -99,9 +233,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
return String.Empty;
}
public DeployInformation DeployInformation {
get { return null; }
}
public bool IsCompileable(string fileName) { return false; }
@ -113,11 +244,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -113,11 +244,11 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
public void CopyReferencesToPath(string destination, bool force, ArrayList alreadyCopiedReferences) {}
public bool IsFileInProject(string fileName) { return false; }
public IConfiguration CreateConfiguration(string name) { return null; }
public IConfiguration CreateConfiguration() { return null; }
public IConfiguration CloneConfiguration(IConfiguration configuration) { return null; }
// public IConfiguration CreateConfiguration(string name) { return null; }
//
// public IConfiguration CreateConfiguration() { return null; }
// public IConfiguration CloneConfiguration(IConfiguration configuration) { return null; }
//
protected virtual void OnNameChanged(EventArgs e)
{
if (NameChanged != null) {

20
src/AddIns/DisplayBindings/AssemblyScout/Project/Src/XmlView.cs

@ -14,6 +14,7 @@ using System.Windows.Forms; @@ -14,6 +14,7 @@ using System.Windows.Forms;
using SA = ICSharpCode.SharpAssembly.Assembly;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
{
@ -36,35 +37,35 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -36,35 +37,35 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
tree = _tree;
captionLabel.Location = new Point(5, 0);
captionLabel.Text = tree.ress.GetString("ObjectBrowser.XML.Desc");
captionLabel.Text = StringParser.Parse("${res:ObjectBrowser.XML.Desc}");
captionLabel.Size = new Size(300, 25);
captionLabel.FlatStyle = FlatStyle.System;
exportEvents.Location = new Point(15, 40);
exportEvents.Text = tree.ress.GetString("ObjectBrowser.XML.ExpEvt");
exportEvents.Text = StringParser.Parse("${res:ObjectBrowser.XML.ExpEvt}");
exportEvents.Checked = true;
exportEvents.Width = 300;
exportEvents.FlatStyle = FlatStyle.System;
exportFields.Location = new Point(15, 65);
exportFields.Text = tree.ress.GetString("ObjectBrowser.XML.ExpFld");
exportFields.Text = StringParser.Parse("${res:ObjectBrowser.XML.ExpFld}");
exportFields.Checked = true;
exportFields.Width = 300;
exportFields.FlatStyle = FlatStyle.System;
exportMethods.Location = new Point(15, 90);
exportMethods.Text = tree.ress.GetString("ObjectBrowser.XML.ExpMeth");
exportMethods.Text = StringParser.Parse("${res:ObjectBrowser.XML.ExpMeth}");
exportMethods.Checked = true;
exportMethods.Width = 300;
exportMethods.FlatStyle = FlatStyle.System;
exportProperties.Location = new Point(15, 115);
exportProperties.Width = 300;
exportProperties.Text = tree.ress.GetString("ObjectBrowser.XML.ExpProp");
exportProperties.Text = StringParser.Parse("${res:ObjectBrowser.XML.ExpProp}");
exportProperties.Checked = true;
exportProperties.FlatStyle = FlatStyle.System;
saveButton.Text = tree.ress.GetString("ObjectBrowser.XML.Save");
saveButton.Text = StringParser.Parse("${res:ObjectBrowser.XML.Save}");
saveButton.Location = new Point(5, 160);
saveButton.Enabled = false;
saveButton.Click += new EventHandler(saveButton_Clicked);
@ -85,13 +86,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -85,13 +86,13 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
void saveButton_Clicked(object sender, System.EventArgs e) {
SaveFileDialog fdialog = new SaveFileDialog();
fdialog.Filter = tree.ress.GetString("ObjectBrowser.Filters.XML") + "|*.xml";
fdialog.Filter = StringParser.Parse("${res:ObjectBrowser.Filters.XML}") + "|*.xml";
DialogResult result = fdialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
if(result != DialogResult.Cancel) {
if (SelectedNode.Attribute is IClass) {
writeStart(fdialog.FileName, ((SelectedNode.Attribute as IClass).DeclaredIn as SA.SharpAssembly).FullName);
writeStart(fdialog.FileName, ((SelectedNode.Attribute as IClass).DeclaringType as SA.SharpAssembly).FullName);
exportClass((IClass)SelectedNode.Attribute);
} else if (SelectedNode.Attribute is SA.SharpAssembly) {
writeStart(fdialog.FileName, ((SA.SharpAssembly)SelectedNode.Attribute).FullName);
@ -187,7 +188,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -187,7 +188,7 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
if(exportMethods.Checked) {
writer.WriteStartElement("methods");
foreach(IMethod method in type.Methods) {
if(! method.IsSpecialName) {
if(!SharpAssemblyMethod.IsSpecial(method)) {
if(method.DeclaringType == type) {
writer.WriteStartElement("method");
@ -233,7 +234,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout @@ -233,7 +234,6 @@ namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout
SelectedNode = (AssemblyTreeNode)e.Node;
saveButton.Enabled = (SelectedNode.Attribute is IClass || SelectedNode.Attribute is SA.SharpAssembly);
}
}
}

Loading…
Cancel
Save