Browse Source

Referenced assemblies are now loaded with Mono.Cecil.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1423 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
730def510e
  1. 156
      data/templates/project/CSharp/CompactFormsProject.xpt
  2. 4
      doc/AssemblyBaseAddresses.txt
  3. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpAmbience.cs
  4. 4
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/SecondaryDisplayBinding.cs
  5. 6
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  6. 417
      src/Main/Base/Project/Src/Dom/CecilReader.cs
  7. 23
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs
  8. 23
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/FusionNative.cs
  9. 2
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  10. 59
      src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs
  11. 2
      src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs
  12. 17
      src/Main/Base/Project/Src/TextEditor/Commands/FormatCommands.cs
  13. 15
      src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/SortOptionsDialog.cs
  14. 9
      src/Main/Core/Project/Src/Services/MessageService/MessageService.cs

156
data/templates/project/CSharp/CompactFormsProject.xpt

@ -0,0 +1,156 @@ @@ -0,0 +1,156 @@
<?xml version="1.0"?>
<Template originator = "Mike Krueger"
created = "06/10/2001"
lastModified = "14/01/2006">
<!-- Template Header -->
<TemplateConfiguration>
<Name>${res:Templates.Project.WindowsApplication.Name}</Name>
<Category>C#</Category>
<Subcategory>Compact Framework</Subcategory>
<Icon>C#.Project.Form</Icon>
<LanguageName>C#</LanguageName>
<Description>${res:Templates.Project.WindowsApplication.Description}</Description>
</TemplateConfiguration>
<!-- Actions -->
<Actions>
<Open filename = "MainForm.cs"/>
</Actions>
<Combine name = "${ProjectName}" directory = ".">
<Options>
<StartupProject>${ProjectName}</StartupProject>
</Options>
<Project name = "${ProjectName}" directory = ".">
<Options OutputType = "WinExe" />
<ProjectItems>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.WindowsCE.Forms.dll" />
</ProjectItems>
<PropertyGroup>
<PlatformFamilyName>PocketPC</PlatformFamilyName>
<PlatformID>WinCE</PlatformID>
</PropertyGroup>
<Imports clear="true">
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.Targets" />
</Imports>
<Files>
<File name="MainForm.cs" language="C#"><![CDATA[${StandardHeader.C#}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace ${StandardNamespace}
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm
{
[STAThread]
public static void Main(string[] args)
{
Application.Run(new MainForm());
}
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
}
}
]]></File>
<File name="MainForm.Designer.cs" dependentUpon="MainForm.cs" language="C#"><![CDATA[${StandardHeader.C#}
namespace ${StandardNamespace}
{
partial class MainForm : System.Windows.Forms.Form
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
//
// MainForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.ClientSize = new System.Drawing.Size(238, 295);
this.Text = "${ProjectName}";
this.Name = "MainForm";
}
}
}
]]></File>
<File name="AssemblyInfo.cs" language="C#">
<![CDATA[using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]
]]></File>
</Files>
</Project>
</Combine>
</Template>

4
doc/AssemblyBaseAddresses.txt

@ -54,8 +54,10 @@ SharpReportAddIn: 0x7800000 - 0x781e000 @@ -54,8 +54,10 @@ SharpReportAddIn: 0x7800000 - 0x781e000
ReportGenerator: 0x7880000 - 0x78a1000
StartPage: 0x7900000 - 0x791e000
UnitTesting: 0x7980000 - 0x799b000
Mono.Cecil: 0x7a00000 - 0x7b38000
Next free address: 0x7d80000
Next free address: 0x7a00000

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpAmbience.cs

@ -96,7 +96,7 @@ namespace ICSharpCode.Core @@ -96,7 +96,7 @@ namespace ICSharpCode.Core
if (decoration.IsStatic) {
ret += "static ";
} else if (decoration.IsSealed) {
ret += "final ";
ret += "sealed ";
} else if (decoration.IsVirtual) {
ret += "virtual ";
} else if (decoration.IsOverride) {

4
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/SecondaryDisplayBinding.cs

@ -61,8 +61,8 @@ namespace ICSharpCode.FormsDesigner @@ -61,8 +61,8 @@ namespace ICSharpCode.FormsDesigner
}
}
IClass form = ProjectContentRegistry.WinForms.GetClass("System.Windows.Forms.Form");
IClass userControl = ProjectContentRegistry.WinForms.GetClass("System.Windows.Forms.UserControl");
IClass form = c.ProjectContent.GetClass("System.Windows.Forms.Form");
IClass userControl = c.ProjectContent.GetClass("System.Windows.Forms.UserControl");
if (form != null && c.IsTypeInInheritanceTree(form))
return true;
if (userControl != null && c.IsTypeInInheritanceTree(userControl))

6
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -45,13 +45,16 @@ @@ -45,13 +45,16 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Engine" />
<Reference Include="Mono.Cecil">
<HintPath>..\..\..\Libraries\Mono.Cecil\Mono.Cecil.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Src\Internal\ExternalTool\ExternalTool.cs" />
@ -772,6 +775,7 @@ @@ -772,6 +775,7 @@
<Compile Include="Src\TextEditor\Gui\Editor\AdvancedHighlightingStrategy.cs" />
<Compile Include="Src\TextEditor\Gui\Editor\AdvancedHighlighter.cs" />
<Compile Include="Src\Dom\Implementations\SystemTypes.cs" />
<Compile Include="Src\Dom\CecilReader.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">

417
src/Main/Base/Project/Src/Dom/CecilReader.cs

@ -0,0 +1,417 @@ @@ -0,0 +1,417 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using Mono.Cecil;
using ICSharpCode.Core;
using AssemblyName = System.Reflection.AssemblyName;
namespace ICSharpCode.SharpDevelop.Dom
{
public static class CecilReader
{
public static ReflectionProjectContent LoadAssembly(string fileName)
{
LoggingService.Info("Cecil: Load from " + fileName);
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
AssemblyDefinition asm = AssemblyFactory.GetAssembly(fs);
List<AssemblyName> referencedAssemblies = new List<AssemblyName>();
foreach (AssemblyNameReference anr in asm.MainModule.AssemblyReferences) {
referencedAssemblies.Add(new AssemblyName(anr.FullName));
}
return new CecilProjectContent(asm.Name.FullName, fileName, referencedAssemblies.ToArray(), asm.MainModule.Types);
}
}
static void AddAttributes(IProjectContent pc, IList<IAttribute> list, CustomAttributeCollection attributes)
{
foreach (CustomAttribute att in attributes) {
DefaultAttribute a = new DefaultAttribute(att.Constructor.DeclaringType.FullName);
// TODO: attribute arguments
list.Add(a);
}
}
static void AddConstraintsFromType(ITypeParameter tp, GenericParameter g)
{
foreach (TypeReference constraint in g.Constraints) {
if (tp.Method != null) {
tp.Constraints.Add(CreateType(tp.Class.ProjectContent, tp.Method, constraint));
} else {
tp.Constraints.Add(CreateType(tp.Class.ProjectContent, tp.Class, constraint));
}
}
}
/// <summary>
/// Create a SharpDevelop return type from a Cecil type reference.
/// </summary>
public static IReturnType CreateType(IProjectContent pc, IDecoration member, TypeReference type)
{
while (type is ModType) {
type = (type as ModType).ElementType;
}
if (type is ReferenceType) {
// TODO: Use ByRefRefReturnType
return CreateType(pc, member, (type as ReferenceType).ElementType);
} else if (type is ArrayType) {
return new ArrayReturnType(pc, CreateType(pc, member, (type as ArrayType).ElementType), (type as ArrayType).Rank);
} else if (type is GenericInstanceType) {
GenericInstanceType gType = (GenericInstanceType)type;
IReturnType[] para = new IReturnType[gType.GenericArguments.Count];
for (int i = 0; i < para.Length; ++i) {
para[i] = CreateType(pc, member, gType.GenericArguments[i]);
}
return new ConstructedReturnType(CreateType(pc, member, gType.ElementType), para);
} else if (type is GenericParameter) {
GenericParameter typeGP = type as GenericParameter;
if (typeGP.Owner is MethodDefinition) {
IMethod method = member as IMethod;
if (method != null) {
if (typeGP.Position < method.TypeParameters.Count) {
return new GenericReturnType(method.TypeParameters[typeGP.Position]);
}
}
return new GenericReturnType(new DefaultTypeParameter(method, typeGP.Name, typeGP.Position));
} else {
IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null;
if (c != null && typeGP.Position < c.TypeParameters.Count) {
if (c.TypeParameters[typeGP.Position].Name == type.Name) {
return new GenericReturnType(c.TypeParameters[typeGP.Position]);
}
}
return new GenericReturnType(new DefaultTypeParameter(c, typeGP.Name, typeGP.Position));
}
} else {
string name = type.FullName;
if (name == null)
throw new ApplicationException("type.FullName returned null. Type: " + type.ToString());
if (name.IndexOf('/') > 0) {
name = name.Replace('/', '.');
}
int typeParameterCount = 0;
if (name.Length > 2 && name[name.Length - 2] == '`') {
typeParameterCount = name[name.Length - 1] - '0';
name = name.Substring(0, name.Length - 2);
}
IClass c = pc.GetClass(name, typeParameterCount);
if (c != null) {
return c.DefaultReturnType;
} else {
// example where name is not found: pointers like System.Char*
// or when the class is in a assembly that is not referenced
return new GetClassReturnType(pc, name, typeParameterCount);
}
}
}
private class CecilProjectContent : ReflectionProjectContent
{
public CecilProjectContent(string fullName, string fileName, AssemblyName[] referencedAssemblies,
TypeDefinitionCollection types)
: base(fullName, fileName, referencedAssemblies)
{
foreach (TypeDefinition td in types) {
if ((td.Attributes & TypeAttributes.Public) == TypeAttributes.Public) {
if ((td.Attributes & TypeAttributes.NestedAssembly) == TypeAttributes.NestedAssembly
|| (td.Attributes & TypeAttributes.NestedPrivate) == TypeAttributes.NestedPrivate
|| (td.Attributes & TypeAttributes.NestedFamANDAssem) == TypeAttributes.NestedFamANDAssem)
{
continue;
}
string name = td.FullName;
if (name.Length == 0 || name[0] == '<')
continue;
if (name.Length > 2 && name[name.Length - 2] == '`')
name = name.Substring(0, name.Length - 2);
AddClassToNamespaceListInternal(new CecilClass(assemblyCompilationUnit, null, td, name));
}
}
InitializeSpecialClasses();
}
}
private class CecilClass : DefaultClass
{
public static bool IsDelegate(TypeDefinition type)
{
if (type.BaseType == null)
return false;
else
return type.BaseType.FullName == "System.Delegate"
|| type.BaseType.FullName == "System.MulticastDelegate";
}
public CecilClass(ICompilationUnit compilationUnit, IClass declaringType,
TypeDefinition td, string fullName)
: base(compilationUnit, declaringType)
{
this.FullyQualifiedName = fullName;
this.UseInheritanceCache = true;
AddAttributes(compilationUnit.ProjectContent, this.Attributes, td.CustomAttributes);
// set classtype
if (td.IsInterface) {
this.ClassType = ClassType.Interface;
} else if (td.IsEnum) {
this.ClassType = ClassType.Enum;
} else if (td.IsValueType) {
this.ClassType = ClassType.Struct;
} else if (IsDelegate(td)) {
this.ClassType = ClassType.Delegate;
} else {
this.ClassType = ClassType.Class;
}
if (td.GenericParameters.Count > 0) {
foreach (GenericParameter g in td.GenericParameters) {
this.TypeParameters.Add(new DefaultTypeParameter(this, g.Name, g.Position));
}
int i = 0;
foreach (GenericParameter g in td.GenericParameters) {
AddConstraintsFromType(this.TypeParameters[i++], g);
}
}
ModifierEnum modifiers = ModifierEnum.None;
if (td.IsSealed) {
modifiers |= ModifierEnum.Sealed;
}
if (td.IsAbstract) {
modifiers |= ModifierEnum.Abstract;
}
if ((td.Attributes & TypeAttributes.NestedPublic) == TypeAttributes.NestedPublic) {
modifiers |= ModifierEnum.Public;
} else if ((td.Attributes & TypeAttributes.NestedFamily) == TypeAttributes.NestedFamily) {
modifiers |= ModifierEnum.Protected;
} else if ((td.Attributes & TypeAttributes.NestedFamORAssem) == TypeAttributes.NestedFamORAssem) {
modifiers |= ModifierEnum.Protected;
} else {
modifiers |= ModifierEnum.Public;
}
this.Modifiers = modifiers;
// set base classes
if (td.BaseType != null) {
BaseTypes.Add(CreateType(this.ProjectContent, this, td.BaseType));
}
foreach (TypeReference iface in td.Interfaces) {
BaseTypes.Add(CreateType(this.ProjectContent, this, iface));
}
ReflectionLayer.ReflectionClass.ApplySpecialsFromAttributes(this);
InitMembers(td);
}
void InitMembers(TypeDefinition type)
{
string defaultMemberName = null;
foreach (CustomAttribute att in type.CustomAttributes) {
if (att.Constructor.DeclaringType.FullName == "System.Reflection.DefaultMemberAttribute"
&& att.ConstructorParameters.Count == 1)
{
defaultMemberName = att.ConstructorParameters[0] as string;
}
}
foreach (TypeDefinition nestedType in type.NestedTypes) {
if ((nestedType.Attributes & TypeAttributes.NestedPublic) == TypeAttributes.NestedPublic)
{
// NestedFamily somehow also finds internal inner classes (e.g. Environment.ResourceHelper)
string name = nestedType.FullName;
int pos = name.LastIndexOf('/');
if (pos > 0)
name = name.Substring(pos + 1);
if (name.Length == 0 || name[0] == '<')
continue;
if (name.Length > 2 && name[name.Length - 2] == '`')
name = name.Substring(0, name.Length - 2);
InnerClasses.Add(new CecilClass(this.CompilationUnit, this, nestedType, name));
}
}
foreach (FieldDefinition field in type.Fields) {
if (IsVisible(field.Attributes)) {
DefaultField f = new DefaultField(this, field.Name);
f.Modifiers = TranslateModifiers(field);
f.ReturnType = CreateType(this.ProjectContent, this, field.FieldType);
Fields.Add(f);
}
}
foreach (PropertyDefinition property in type.Properties) {
if ((property.GetMethod != null && IsVisible(property.GetMethod.Attributes))
|| (property.SetMethod != null && IsVisible(property.SetMethod.Attributes)))
{
DefaultProperty p = new DefaultProperty(this, property.Name);
if (this.ClassType != ClassType.Interface) {
p.Modifiers = TranslateModifiers(property);
}
p.ReturnType = CreateType(this.ProjectContent, this, property.PropertyType);
p.CanGet = property.GetMethod != null;
p.CanSet = property.SetMethod != null;
if (p.Name == defaultMemberName) {
p.IsIndexer = true;
}
AddParameters(p, property.Parameters);
Properties.Add(p);
}
}
foreach (EventDefinition eventDef in type.Events) {
if (eventDef.AddMethod != null && IsVisible(eventDef.AddMethod.Attributes)) {
DefaultEvent e = new DefaultEvent(this, eventDef.Name);
if (this.ClassType != ClassType.Interface) {
e.Modifiers = TranslateModifiers(eventDef);
}
e.ReturnType = CreateType(this.ProjectContent, this, eventDef.EventType);
Events.Add(e);
}
}
foreach (MethodDefinition method in type.Constructors) {
AddMethod(method);
}
foreach (MethodDefinition method in type.Methods) {
if (!method.IsSpecialName) {
AddMethod(method);
}
}
}
void AddMethod(MethodDefinition method)
{
if (IsVisible(method.Attributes)) {
DefaultMethod m = new DefaultMethod(this, method.IsConstructor ? "#ctor" : method.Name);
if (method.GenericParameters.Count > 0) {
foreach (GenericParameter g in method.GenericParameters) {
m.TypeParameters.Add(new DefaultTypeParameter(m, g.Name, g.Position));
}
int i = 0;
foreach (GenericParameter g in method.GenericParameters) {
AddConstraintsFromType(m.TypeParameters[i++], g);
}
}
m.ReturnType = CreateType(this.ProjectContent, m, method.ReturnType.ReturnType);
if (this.ClassType != ClassType.Interface) {
m.Modifiers = TranslateModifiers(method);
}
AddParameters(m, method.Parameters);
Methods.Add(m);
}
}
void AddParameters(IMethodOrProperty target, ParameterDefinitionCollection plist)
{
foreach (ParameterDefinition par in plist) {
IReturnType pReturnType = CreateType(this.ProjectContent, target, par.ParameterType);
DefaultParameter p = new DefaultParameter(par.Name, pReturnType, DomRegion.Empty);
if ((par.Attributes & ParamAttributes.Out) == ParamAttributes.Out) {
p.Modifiers = ParameterModifiers.Out;
} else if (par.ParameterType is ReferenceType) {
p.Modifiers = ParameterModifiers.Ref;
} else {
p.Modifiers = ParameterModifiers.In;
}
if ((par.Attributes & ParamAttributes.Optional) == ParamAttributes.Optional) {
p.Modifiers |= ParameterModifiers.Optional;
}
if (p.ReturnType.IsArrayReturnType) {
foreach (CustomAttribute att in par.CustomAttributes) {
if (att.Constructor.DeclaringType.FullName == typeof(ParamArrayAttribute).FullName) {
p.Modifiers |= ParameterModifiers.Params;
}
}
}
target.Parameters.Add(p);
}
}
static bool IsVisible(MethodAttributes att)
{
return ((att & MethodAttributes.Public) == MethodAttributes.Public)
|| ((att & MethodAttributes.Family) == MethodAttributes.Family)
|| ((att & MethodAttributes.FamORAssem) == MethodAttributes.FamORAssem);
}
static bool IsVisible(FieldAttributes att)
{
return ((att & FieldAttributes.Public) == FieldAttributes.Public)
|| ((att & FieldAttributes.Family) == FieldAttributes.Family)
|| ((att & FieldAttributes.FamORAssem) == FieldAttributes.FamORAssem);
}
static ModifierEnum TranslateModifiers(MethodDefinition method)
{
ModifierEnum m = ModifierEnum.None;
if (method.IsStatic)
m |= ModifierEnum.Static;
if (method.IsAbstract) {
m |= ModifierEnum.Abstract;
} else if (method.Overrides.Count > 0) {
if (method.IsFinal) {
m |= ModifierEnum.Sealed;
} else {
m |= ModifierEnum.Override;
}
} else if (method.IsVirtual) {
m |= ModifierEnum.Virtual;
}
if ((method.Attributes & MethodAttributes.Public) == MethodAttributes.Public)
m |= ModifierEnum.Public;
else
m |= ModifierEnum.Protected;
return m;
}
static ModifierEnum TranslateModifiers(PropertyDefinition property)
{
return TranslateModifiers(property.GetMethod ?? property.SetMethod);
}
static ModifierEnum TranslateModifiers(EventDefinition @event)
{
return TranslateModifiers(@event.AddMethod);
}
static ModifierEnum TranslateModifiers(FieldDefinition field)
{
ModifierEnum m = ModifierEnum.None;
if (field.IsStatic)
m |= ModifierEnum.Static;
if (field.IsLiteral)
m |= ModifierEnum.Const;
else if (field.IsReadOnly)
m |= ModifierEnum.Readonly;
if ((field.Attributes & FieldAttributes.Public) == FieldAttributes.Public)
m |= ModifierEnum.Public;
else
m |= ModifierEnum.Protected;
return m;
}
}
}
}

23
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer @@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer
}
}
public static bool IsDelegate(Type type)
static bool IsDelegate(Type type)
{
return type.IsSubclassOf(typeof(Delegate)) && type != typeof(MulticastDelegate);
}
@ -81,6 +81,18 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer @@ -81,6 +81,18 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer
}
}
internal static void ApplySpecialsFromAttributes(DefaultClass c)
{
foreach (IAttribute att in c.Attributes) {
if (att.Name == "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute"
|| att.Name == "Boo.Lang.ModuleAttribute")
{
c.ClassType = ClassType.Module;
break;
}
}
}
public ReflectionClass(ICompilationUnit compilationUnit, Type type, string fullName, IClass declaringType) : base(compilationUnit, declaringType)
{
if (fullName.Length > 2 && fullName[fullName.Length - 2] == '`') {
@ -108,14 +120,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer @@ -108,14 +120,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer
this.ClassType = ClassType.Delegate;
} else {
this.ClassType = ClassType.Class;
foreach (IAttribute att in this.Attributes) {
if (att.Name == "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute"
|| att.Name == "Boo.Lang.ModuleAttribute")
{
this.ClassType = ClassType.Module;
break;
}
}
ApplySpecialsFromAttributes(this);
}
if (type.IsGenericTypeDefinition) {
foreach (Type g in type.GetGenericArguments()) {

23
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/FusionNative.cs

@ -79,13 +79,13 @@ namespace MSjogren.GacTool.FusionNative @@ -79,13 +79,13 @@ namespace MSjogren.GacTool.FusionNative
//
[PreserveSig()]
int Set(uint PropertyId,
IntPtr pvProperty,
uint cbProperty);
IntPtr pvProperty,
uint cbProperty);
[PreserveSig()]
int Get(uint PropertyId,
IntPtr pvProperty,
ref uint pcbProperty);
IntPtr pvProperty,
ref uint pcbProperty);
[PreserveSig()]
int Finalize();
@ -242,9 +242,18 @@ namespace MSjogren.GacTool.FusionNative @@ -242,9 +242,18 @@ namespace MSjogren.GacTool.FusionNative
uint dw);
[DllImport("fusion.dll")]
public static extern int GetCachePath([MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDir,
ref uint pdwSize,
uint dwreserved);
public static extern int GetCachePath(uint flags,
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDir,
ref uint pdwSize);
public static string GetGacPath()
{
const int size = 260;
StringBuilder b = new StringBuilder(size);
uint tmp = size;
GetCachePath(8, b, ref tmp); // flag 8 = GAC_ROOT_PATH
return b.ToString();
}
// _InstallCustomAssembly@16
// _InstallCustomModule@8

2
src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs

@ -329,7 +329,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -329,7 +329,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (gridItem != null) {
Type component = gridItem.PropertyDescriptor.ComponentType;
if (component != null) {
ICSharpCode.SharpDevelop.Dom.IClass c = ProjectContentRegistry.WinForms.GetClass(component.FullName);
ICSharpCode.SharpDevelop.Dom.IClass c = ParserService.CurrentProjectContent.GetClass(component.FullName);
if (c != null) {
foreach (ICSharpCode.SharpDevelop.Dom.IProperty p in c.DefaultReturnType.GetProperties()) {
if (gridItem.PropertyDescriptor.Name == p.Name) {

59
src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs

@ -43,11 +43,12 @@ namespace ICSharpCode.Core @@ -43,11 +43,12 @@ namespace ICSharpCode.Core
}
int time = LoggingService.IsDebugEnabled ? Environment.TickCount : 0;
LoggingService.Debug("Loading PC for mscorlib...");
mscorlibContent = DomPersistence.LoadProjectContentByAssemblyName(typeof(object).Assembly.FullName);
mscorlibContent = DomPersistence.LoadProjectContentByAssemblyName(MscorlibAssembly.FullName);
if (mscorlibContent == null) {
mscorlibContent = new ReflectionProjectContent(typeof(object).Assembly);
mscorlibContent = new ReflectionProjectContent(MscorlibAssembly);
//mscorlibContent = CecilReader.LoadAssembly(MscorlibAssembly.Location);
if (time != 0) {
LoggingService.Debug("Loaded mscorlib with reflection in " + (Environment.TickCount - time) + " ms");
LoggingService.Debug("Loaded mscorlib with Reflection in " + (Environment.TickCount - time) + " ms");
}
DomPersistence.SaveProjectContent(mscorlibContent);
LoggingService.Debug("Saved mscorlib to cache");
@ -68,17 +69,6 @@ namespace ICSharpCode.Core @@ -68,17 +69,6 @@ namespace ICSharpCode.Core
}
}
public static IProjectContent WinForms {
get {
lock (contents) {
if (contents.ContainsKey("System.Windows.Forms")) {
return contents["System.Windows.Forms"];
}
}
return GetProjectContentForReference(new ReferenceProjectItem(null, "System.Windows.Forms"));
}
}
public static IProjectContent GetExistingProjectContent(AssemblyName assembly)
{
lock (contents) {
@ -155,7 +145,31 @@ namespace ICSharpCode.Core @@ -155,7 +145,31 @@ namespace ICSharpCode.Core
DomPersistence.SaveProjectContent(pc);
}
} else {
pc = LoadProjectContent(itemFileName, itemInclude);
//pc = LoadProjectContent(itemFileName, itemInclude);
// find real file name for cecil:
if (File.Exists(itemFileName)) {
pc = CecilReader.LoadAssembly(itemFileName);
} else {
pc = null;
AssemblyName asmName = FindBestMatchingAssemblyName(itemInclude);
if (asmName != null) {
string subPath = FileUtility.Combine(asmName.Name,
GetVersion__Token(asmName),
asmName.Name + ".dll");
foreach (string dir in Directory.GetDirectories(Fusion.GetGacPath(), "GAC*")) {
itemFileName = Path.Combine(dir, subPath);
if (File.Exists(itemFileName)) {
pc = CecilReader.LoadAssembly(itemFileName);
break;
}
}
}
if (pc == null) {
WorkbenchSingleton.SafeThreadAsyncCall((Action3<string, string, string>)ShowErrorMessage,
new object[] { "?", itemInclude, "Could not find assembly file." });
}
}
}
if (pc != null) {
contents[item.Include] = pc;
@ -172,6 +186,19 @@ namespace ICSharpCode.Core @@ -172,6 +186,19 @@ namespace ICSharpCode.Core
}
}
static string GetVersion__Token(AssemblyName asmName)
{
StringBuilder b = new StringBuilder(asmName.Version.ToString());
b.Append("__");
foreach (byte by in asmName.GetPublicKeyToken()) {
b.Append(by.ToString("x2"));
}
return b.ToString();
}
/// <summary>
/// Load a project content using Reflection in a separate AppDomain.
/// </summary>
static ReflectionProjectContent LoadProjectContent(string filename, string include)
{
ReflectionProjectContent pc = DomPersistence.LoadProjectContentByAssemblyName(filename);
@ -243,8 +270,6 @@ namespace ICSharpCode.Core @@ -243,8 +270,6 @@ namespace ICSharpCode.Core
return typeof(System.Data.DataException).Assembly;
case "System.Design":
return typeof(System.ComponentModel.Design.DesignSurface).Assembly;
case "System.DirectoryServices":
return typeof(System.DirectoryServices.AuthenticationTypes).Assembly;
case "System.Drawing":
return typeof(System.Drawing.Color).Assembly;
case "System.Web.Services":

2
src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -24,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{
string assemblyFullName;
AssemblyName[] referencedAssemblies;
ICompilationUnit assemblyCompilationUnit;
protected ICompilationUnit assemblyCompilationUnit;
string assemblyLocation;
public string AssemblyLocation {

17
src/Main/Base/Project/Src/TextEditor/Commands/FormatCommands.cs

@ -6,24 +6,15 @@ @@ -6,24 +6,15 @@
// </file>
using System;
using System.IO;
using System.Threading;
using System.Drawing;
using System.Drawing.Printing;
using System.DirectoryServices; // for SortDirection
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Actions;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{
@ -153,6 +144,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -153,6 +144,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
/// </summary>
public class SortSelection : AbstractMenuCommand
{
internal enum SortDirection {
Ascending, Descending
}
class SortComparer : IComparer
{
SortDirection sortDirection;

15
src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/SortOptionsDialog.cs

@ -6,19 +6,10 @@ @@ -6,19 +6,10 @@
// </file>
using System;
using System.Drawing;
using System.DirectoryServices; // for SortDirection
using System.ComponentModel;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
using ICSharpCode.TextEditor;
using SortDirection = ICSharpCode.SharpDevelop.DefaultEditor.Commands.SortSelection.SortDirection;
namespace ICSharpCode.SharpDevelop.Gui
{
@ -39,8 +30,8 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -39,8 +30,8 @@ namespace ICSharpCode.SharpDevelop.Gui
((CheckBox)ControlDictionary["caseSensitiveCheckBox"]).Checked = PropertyService.Get(caseSensitiveOption, true);
((CheckBox)ControlDictionary["ignoreWhiteSpacesCheckBox"]).Checked = PropertyService.Get(ignoreWhiteSpacesOption, false);
((RadioButton)ControlDictionary["ascendingRadioButton"]).Checked = ((SortDirection)PropertyService.Get(sortDirectionOption, SortDirection.Ascending)) == SortDirection.Ascending;
((RadioButton)ControlDictionary["descendingRadioButton"]).Checked = ((SortDirection)PropertyService.Get(sortDirectionOption, SortDirection.Ascending)) == SortDirection.Descending;
((RadioButton)ControlDictionary["ascendingRadioButton"]).Checked = PropertyService.Get(sortDirectionOption, SortDirection.Ascending) == SortDirection.Ascending;
((RadioButton)ControlDictionary["descendingRadioButton"]).Checked = PropertyService.Get(sortDirectionOption, SortDirection.Ascending) == SortDirection.Descending;
// insert event handlers
ControlDictionary["okButton"].Click += new EventHandler(OkEvent);

9
src/Main/Core/Project/Src/Services/MessageService/MessageService.cs

@ -81,7 +81,14 @@ namespace ICSharpCode.Core @@ -81,7 +81,14 @@ namespace ICSharpCode.Core
msg += "Exception occurred: " + ex.ToString();
}
MessageBox.Show(MessageService.MainForm, StringParser.Parse(msg), StringParser.Parse("${res:Global.ErrorText}"), MessageBoxButtons.OK, MessageBoxIcon.Error);
MethodInvoker showError = delegate {
MessageBox.Show(MessageService.MainForm, StringParser.Parse(msg), StringParser.Parse("${res:Global.ErrorText}"), MessageBoxButtons.OK, MessageBoxIcon.Error);
};
if (MessageService.MainForm.InvokeRequired) {
MessageService.MainForm.BeginInvoke(showError);;
} else {
showError();
}
}
public static void ShowWarning(string message)

Loading…
Cancel
Save