Browse Source

Implemented designing forms and controls with Visual Inheritance (based on patch from Alex Prudkiy)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@837 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
5ada3ff483
  1. 18
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/NRefactoryDesignerLoader.cs
  2. 24
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerSecondaryDisplayBinding.cs
  3. 20
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs
  4. 152
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/CustomComponentsSideTab.cs
  5. 98
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/SideTabDesigner.cs
  6. 10
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/DesignerResourceService.cs
  7. 28
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/TypeDiscoveryService.cs
  8. 2
      src/Libraries/ICSharpCode.TextEditor/ICSharpCode.TextEditor.sln
  9. 2
      src/Libraries/ICSharpCode.TextEditor/Test/DocumentTests.cs
  10. 4
      src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Tests.csproj
  11. 0
      src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Tests.csproj.user
  12. 172
      src/Libraries/NRefactory/Project/Src/Output/CodeDOM/CodeDOMOutputVisitor.cs
  13. 2
      src/SharpDevelop.Tests.sln

18
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/NRefactoryDesignerLoader.cs

@ -112,7 +112,21 @@ namespace ICSharpCode.FormDesigner
protected override void OnEndLoad(bool successful, ICollection errors) protected override void OnEndLoad(bool successful, ICollection errors)
{ {
this.loading = false; this.loading = false;
base.OnEndLoad(successful, errors); //when control's Dispose() has a exception and on loading also raised exception
//then this is only place where this error can be logged, because after errors is
//catched internally in .net
try {
base.OnEndLoad(successful, errors);
} catch(ExceptionCollection e) {
LoggingService.Error("DesignerLoader.OnEndLoad error" + e.Message);
foreach(Exception ine in e.Exceptions) {
LoggingService.Error("DesignerLoader.OnEndLoad error" + ine.Message);
}
throw;
} catch(Exception e) {
LoggingService.Error("DesignerLoader.OnEndLoad error" + e.Message);
throw;
}
} }
string lastTextContent; string lastTextContent;
@ -192,7 +206,7 @@ namespace ICSharpCode.FormDesigner
TypeDeclaration td = o as TypeDeclaration; TypeDeclaration td = o as TypeDeclaration;
if (td != null && td.Name == formDecl.Name) { if (td != null && td.Name == formDecl.Name) {
foreach (INode node in td.Children) foreach (INode node in td.Children)
formDecl.AddChild(node); formDecl.AddChild(node);
formDecl.BaseTypes.AddRange(td.BaseTypes); formDecl.BaseTypes.AddRange(td.BaseTypes);
} }
if (o is NamespaceDeclaration) { if (o is NamespaceDeclaration) {

24
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerSecondaryDisplayBinding.cs

@ -13,6 +13,8 @@ using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.NRefactory.Parser; using ICSharpCode.NRefactory.Parser;
using ICSharpCode.FormDesigner.Services;
using System.ComponentModel.Design;
namespace ICSharpCode.FormDesigner namespace ICSharpCode.FormDesigner
{ {
@ -30,7 +32,7 @@ namespace ICSharpCode.FormDesigner
} }
return null; return null;
} }
public static bool BaseClassIsFormOrControl(IClass c) public static bool BaseClassIsFormOrControl(IClass c)
{ {
// Simple test for fully qualified name // Simple test for fully qualified name
@ -44,21 +46,26 @@ namespace ICSharpCode.FormDesigner
return true; return true;
} }
} }
IClass form = ProjectContentRegistry.WinForms.GetClass("System.Windows.Forms.Form");
IClass userControl = ProjectContentRegistry.WinForms.GetClass("System.Windows.Forms.UserControl");
if (form != null && c.IsTypeInInheritanceTree(form))
return true;
if (userControl != null && c.IsTypeInInheritanceTree(userControl))
return true;
return false; return false;
} }
public static bool IsDesignable(ParseInformation info) public static bool IsDesignable(ParseInformation info)
{ {
if (info != null) { if (info != null) {
ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit; ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
foreach (IClass c in cu.Classes) { foreach (IClass c in cu.Classes) {
if (BaseClassIsFormOrControl(c)) { IMethod method = GetInitializeComponents(c);
IMethod method = GetInitializeComponents(c); if (method == null) {
if (method == null) { return false;
return false;
}
return true;
} }
return BaseClassIsFormOrControl(c);
} }
} }
return false; return false;
@ -79,6 +86,7 @@ namespace ICSharpCode.FormDesigner
case ".cs": case ".cs":
case ".vb": case ".vb":
ParseInformation info = ParserService.ParseFile(fileName, textAreaControlProvider.TextEditorControl.Document.TextContent, false, true); ParseInformation info = ParserService.ParseFile(fileName, textAreaControlProvider.TextEditorControl.Document.TextContent, false, true);
if (IsDesignable(info)) if (IsDesignable(info))
return true; return true;
break; break;

20
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.FormDesigner
IDesignerGenerator generator; IDesignerGenerator generator;
DesignerResourceService designerResourceService; DesignerResourceService designerResourceService;
FormDesignerUndoEngine undoEngine; FormDesignerUndoEngine undoEngine;
public override Control Control { public override Control Control {
get { get {
return p; return p;
@ -131,6 +131,7 @@ namespace ICSharpCode.FormDesigner
serviceContainer.AddService(typeof(IHelpService), new HelpService()); serviceContainer.AddService(typeof(IHelpService), new HelpService());
serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService()); serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService());
designerResourceService = new DesignerResourceService(viewContent.FileName, this.resources); designerResourceService = new DesignerResourceService(viewContent.FileName, this.resources);
serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), designerResourceService); serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), designerResourceService);
AmbientProperties ambientProperties = new AmbientProperties(); AmbientProperties ambientProperties = new AmbientProperties();
@ -142,7 +143,7 @@ namespace ICSharpCode.FormDesigner
serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService()); serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());
designSurface = new DesignSurface(serviceContainer); designSurface = new DesignSurface(serviceContainer);
serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormDesigner.Services.MenuCommandService(p, designSurface, serviceContainer)); serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormDesigner.Services.MenuCommandService(p, designSurface, serviceContainer));
ICSharpCode.FormDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormDesigner.Services.EventBindingService(designSurface); ICSharpCode.FormDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormDesigner.Services.EventBindingService(designSurface);
serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService); serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService);
@ -220,6 +221,19 @@ namespace ICSharpCode.FormDesigner
errorText.Text = e.Message; errorText.Text = e.Message;
else else
errorText.Text = e.ToString(); errorText.Text = e.ToString();
//output loaderrors too
if(!designSurface.IsLoaded) {
errorText.Text += "\r\nDesignSurface not loaded :";
if(designSurface.LoadErrors != null) {
foreach(Exception le in designSurface.LoadErrors) {
errorText.Text += "\r\n";
errorText.Text += le.ToString();
errorText.Text += "\r\n";
errorText.Text += le.StackTrace;
}
}
}
errorText.Dock = DockStyle.Fill; errorText.Dock = DockStyle.Fill;
p.Controls.Add(errorText); p.Controls.Add(errorText);
Control title = new Label(); Control title = new Label();
@ -494,7 +508,7 @@ namespace ICSharpCode.FormDesigner
if (e.ChangedItem.GridItemType == GridItemType.Property) { if (e.ChangedItem.GridItemType == GridItemType.Property) {
if (e.ChangedItem.PropertyDescriptor.Name == "Language") { if (e.ChangedItem.PropertyDescriptor.Name == "Language") {
if (!e.OldValue.Equals(e.ChangedItem.Value)) { if (!e.OldValue.Equals(e.ChangedItem.Value)) {
LoggingService.Debug("Reloading designer due to language change."); LoggingService.Debug("Reloading designer due to language change.");
propertyContainer.Clear(); propertyContainer.Clear();
if (!failedDesignerInitialize) { if (!failedDesignerInitialize) {
MergeFormChanges(); MergeFormChanges();

152
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/CustomComponentsSideTab.cs

@ -10,6 +10,7 @@ using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Reflection; using System.Reflection;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Design; using System.Drawing.Design;
using System.ComponentModel; using System.ComponentModel;
@ -33,7 +34,9 @@ namespace ICSharpCode.FormDesigner.Gui
{ {
ArrayList projectAssemblies = new ArrayList(); ArrayList projectAssemblies = new ArrayList();
ArrayList referencedAssemblies = new ArrayList(); ArrayList referencedAssemblies = new ArrayList();
Dictionary<string, Assembly> loadedFiles = new Dictionary<string, Assembly>();
List<string> loadedProjects = new List<string>();
static bool loadReferencedAssemblies = true; static bool loadReferencedAssemblies = true;
///<summary>Load an assembly's controls</summary> ///<summary>Load an assembly's controls</summary>
@ -45,14 +48,14 @@ namespace ICSharpCode.FormDesigner.Gui
} }
public static bool LoadReferencedAssemblies { public static bool LoadReferencedAssemblies {
get { get {
return loadReferencedAssemblies; return loadReferencedAssemblies;
} }
set { set {
loadReferencedAssemblies = value; loadReferencedAssemblies = value;
} }
} }
string loadingPath = String.Empty; string loadingPath = String.Empty;
byte[] GetBytes(string fileName) byte[] GetBytes(string fileName)
@ -73,69 +76,54 @@ namespace ICSharpCode.FormDesigner.Gui
if (idx >= 0) { if (idx >= 0) {
file = file.Substring(0, idx); file = file.Substring(0, idx);
} }
try { //search in other assemblies, this also help to avoid doubling of loaded assms
if (File.Exists(loadingPath + file + ".exe")) { if (ProjectService.OpenSolution != null) {
LoggingService.Debug("Form Designer: MyResolve: Load bytes from exe"); foreach (IProject project in ProjectService.OpenSolution.Projects) {
return Assembly.Load(GetBytes(loadingPath + file + ".exe")); if (project.AssemblyName == file)
} return LoadAssemblyFile(project.OutputAssemblyFullPath, true);
if (File.Exists(loadingPath + file + ".dll")) { }
LoggingService.Debug("Form Designer: MyResolve: Load bytes from dll");
return Assembly.Load(GetBytes(loadingPath + file + ".dll"));
}
LoggingService.Info("Form Designer: MyResolve: did not find " + args.Name);
} catch (Exception ex) {
LoggingService.Warn("Form Designer: MyResolve: Can't load assembly", ex);
} }
//skip already loaded
Assembly lastAssembly = null;
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) {
//LoggingService.Info("Assembly..." + asm.FullName);
if (asm.FullName == args.Name) {
lastAssembly = asm;
}
}
if (lastAssembly != null) {
LoggingService.Info("ICSharpAssemblyResolver found..." + args.Name);
return lastAssembly;
}
return null; return null;
} }
// public void ReloadProjectAssemblies(object sender, EventArgs e)
// {
// ScanProjectAssemblies();
// AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
// try {
// Items.Clear();
// AddDefaultItem();
// foreach (string assemblyName in projectAssemblies) {
// if ((assemblyName.EndsWith("exe") || assemblyName.EndsWith("dll")) && File.Exists(assemblyName)) {
// loadingPath = Path.GetDirectoryName(assemblyName) + Path.DirectorySeparatorChar;
// try {
// if (loadReferencedAssemblies == true) {
// Assembly asm = Assembly.Load(Path.GetFileNameWithoutExtension(assemblyName));
// BuildToolboxFromAssembly(asm);
// }
// } catch (Exception ex) {
// Console.WriteLine("Error loading Assembly " + assemblyName + " : " + ex.ToString());
// }
// }
// }
// foreach (Assembly refAsm in referencedAssemblies) {
// try {
// BuildToolboxFromAssembly(refAsm);
// } catch (Exception ex) {
// Console.WriteLine("Error loading referenced Assembly " + refAsm + " : " + ex.ToString());
// }
// }
// } catch (Exception ex) {
// Console.WriteLine("GOT EXCEPTION : " + ex.ToString());
// } finally {
// AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(MyResolveEventHandler);
// }
//
// foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
// FormDesignerDisplayBindingBase formDesigner = content.WorkbenchWindow.ActiveViewContent as FormDesignerDisplayBindingBase;
// if (formDesigner != null) {
// formDesigner.Control.Invoke(new ThreadStart(formDesigner.ReloadAndSelect), null);
// }
// }
// }
Assembly LoadAssemblyFile(string assemblyName, bool nonLocking) Assembly LoadAssemblyFile(string assemblyName, bool nonLocking)
{ {
assemblyName = assemblyName.ToLower(); assemblyName = assemblyName.ToLower();
//skip already loaded over MyResolveEventHandler
if(loadedFiles.ContainsKey(assemblyName))
return loadedFiles[assemblyName];
if ((assemblyName.EndsWith("exe") || assemblyName.EndsWith("dll")) && File.Exists(assemblyName)) { if ((assemblyName.EndsWith("exe") || assemblyName.EndsWith("dll")) && File.Exists(assemblyName)) {
Assembly asm = nonLocking ? Assembly.Load(GetBytes(assemblyName)) : Assembly.LoadFrom(assemblyName); //Assembly.LoadFrom(assemblyName); string fileAsmName = AssemblyName.GetAssemblyName(assemblyName).ToString();
Assembly asm;
//skip already loaded
Assembly lastAssembly = null;
foreach (Assembly asmLoaded in AppDomain.CurrentDomain.GetAssemblies()) {
if (asmLoaded.FullName == fileAsmName) {
lastAssembly = asmLoaded;
}
}
if (lastAssembly != null) {
asm = lastAssembly;
} else {
asm = nonLocking ? Assembly.Load(GetBytes(assemblyName)) : Assembly.LoadFrom(assemblyName); //Assembly.LoadFrom(assemblyName);
}
if (asm != null) { if (asm != null) {
loadedFiles[assemblyName] = asm;
BuildToolboxFromAssembly(asm); BuildToolboxFromAssembly(asm);
} }
return asm; return asm;
@ -143,37 +131,41 @@ namespace ICSharpCode.FormDesigner.Gui
return null; return null;
} }
void LoadProject(IProject project)
{
string assemblyName = project.OutputAssemblyFullPath;
if(loadedProjects.Contains(assemblyName))
return;
loadedProjects.Add(assemblyName);
foreach (ProjectItem projectItem in project.Items) {
ProjectReferenceProjectItem projectReferenceProjectItem = projectItem as ProjectReferenceProjectItem;
if(projectReferenceProjectItem != null)
LoadProject(projectReferenceProjectItem.ReferencedProject);
}
loadingPath = Path.GetDirectoryName(assemblyName) + Path.DirectorySeparatorChar;
LoadAssemblyFile(assemblyName, true);
}
void ScanProjectAssemblies() void ScanProjectAssemblies()
{ {
projectAssemblies.Clear(); projectAssemblies.Clear();
referencedAssemblies.Clear(); referencedAssemblies.Clear();
loadedFiles.Clear();
loadedProjects.Clear();
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
try { try {
// custom user controls don't need custom images // custom user controls don't need custom images
loadImages = false; loadImages = false;
ITypeResolutionService typeResolutionService = ToolboxProvider.TypeResolutionService; ITypeResolutionService typeResolutionService = ToolboxProvider.TypeResolutionService;
if (ProjectService.OpenSolution != null) { if (ProjectService.OpenSolution != null) {
foreach (IProject project in ProjectService.OpenSolution.Projects) { foreach (IProject project in ProjectService.OpenSolution.Projects) {
string assemblyName = project.OutputAssemblyFullPath; LoadProject(project);
projectAssemblies.Add(assemblyName); projectAssemblies.Add(project.OutputAssemblyFullPath);
loadingPath = Path.GetDirectoryName(assemblyName) + Path.DirectorySeparatorChar;
LoadAssemblyFile(assemblyName, true);
if (loadReferencedAssemblies == true) {
// TODO: project system...
// foreach (ProjectReference reference in projectEntry.Project.ProjectReferences) {
// if (reference.ReferenceType != ReferenceType.Gac && reference.ReferenceType != ReferenceType.Project) {
// assemblyName = reference.GetReferencedFileName(projectEntry.Project);
// loadingPath = Path.GetDirectoryName(assemblyName) + Path.DirectorySeparatorChar;
// Assembly asm = LoadAssemblyFile(assemblyName, true);
// if (asm != null) {
// referencedAssemblies.Add(asm);
// }
// }
// }
}
} }
} }
} catch (Exception e) { } catch (Exception e) {

98
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/SideTabDesigner.cs

@ -10,7 +10,7 @@
* *
* Project : FormDesigner Loading Library Control. * Project : FormDesigner Loading Library Control.
* *
* Source code altering : A1 * Source code altering : A1
* *
* Description : Creation of the SideTabDesigner which load controls from an assembly * Description : Creation of the SideTabDesigner which load controls from an assembly
* Use for FromDesigner. * Use for FromDesigner.
@ -126,69 +126,69 @@ namespace ICSharpCode.FormDesigner.Gui
string[] imgNames = assembly.GetManifestResourceNames(); string[] imgNames = assembly.GetManifestResourceNames();
foreach (string im in imgNames) { foreach (string im in imgNames) {
try { if (!im.EndsWith(".resources")) //load resources only to avoid exception on debugging
Stream stream = assembly.GetManifestResourceStream(im); {
if (stream != null) { try {
Bitmap b = new Bitmap(Image.FromStream(stream)); Stream stream = assembly.GetManifestResourceStream(im);
b.MakeTransparent(); if (stream != null) {
images[im] = il.Images.Count; Bitmap b = new Bitmap(Image.FromStream(stream, true, false));
il.Images.Add(b); b.MakeTransparent();
stream.Close(); images[im] = il.Images.Count;
il.Images.Add(b);
stream.Close();
}
} catch (Exception e) {
LoggingService.Warn("Form Designer: GetToolboxItemsFromAssembly", e);
} }
} catch (Exception e) {
LoggingService.Warn("Form Designer: GetToolboxItemsFromAssembly", e);
} }
} }
Module[] ms = assembly.GetModules(false); Type[] ts = assembly.GetExportedTypes();
foreach (Module m in ms) { foreach (Type t in ts) {
if (t.IsPublic && !t.IsAbstract) {
Type[] ts = m.GetTypes(); if (t.IsDefined(typeof(ToolboxItemFilterAttribute), true) || t.IsDefined(typeof(ToolboxItemAttribute), true) || t.IsDefined(typeof(DesignTimeVisibleAttribute), true) || typeof(System.ComponentModel.IComponent).IsAssignableFrom(t)) {
foreach (Type t in ts) {
if (t.IsPublic && !t.IsAbstract) { object[] filterAttrs = t.GetCustomAttributes(typeof(DesignTimeVisibleAttribute), true);
if (t.IsDefined(typeof(ToolboxItemFilterAttribute), true) || t.IsDefined(typeof(ToolboxItemAttribute), true) || t.IsDefined(typeof(DesignTimeVisibleAttribute), true) || typeof(System.ComponentModel.IComponent).IsAssignableFrom(t)) { foreach (DesignTimeVisibleAttribute visibleAttr in filterAttrs) {
if (!visibleAttr.Visible) {
object[] filterAttrs = t.GetCustomAttributes(typeof(DesignTimeVisibleAttribute), true); goto skip;
foreach (DesignTimeVisibleAttribute visibleAttr in filterAttrs) {
if (!visibleAttr.Visible) {
goto skip;
}
} }
string imageName = String.Concat(t.FullName, ".bmp"); }
if (images[imageName] == null) { string imageName = String.Concat(t.FullName, ".bmp");
object[] attributes = t.GetCustomAttributes(false); if (images[imageName] == null) {
if (t.IsDefined(typeof(ToolboxBitmapAttribute), false)) { object[] attributes = t.GetCustomAttributes(false);
foreach (object attr in attributes) { if (t.IsDefined(typeof(ToolboxBitmapAttribute), false)) {
if (attr is ToolboxBitmapAttribute) { foreach (object attr in attributes) {
ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr; if (attr is ToolboxBitmapAttribute) {
Bitmap b = new Bitmap(toolboxBitmapAttribute.GetImage(t)); ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr;
b.MakeTransparent(); Bitmap b = new Bitmap(toolboxBitmapAttribute.GetImage(t));
il.Images.Add(b); b.MakeTransparent();
images[imageName] =b; il.Images.Add(b);
break; images[imageName] =b;
} break;
} }
} }
} }
}
ToolboxItem item = new ToolboxItem(t);
ToolboxItem item = new ToolboxItem(t);
if (images[imageName] != null) {
try { if (images[imageName] != null) {
try {
if(images[imageName] is Bitmap)
item.Bitmap = (Bitmap)images[imageName]; item.Bitmap = (Bitmap)images[imageName];
} catch (Exception ex) { } catch (Exception ex) {
MessageService.ShowError(ex, "Exception converting bitmap : " + images[imageName] + " : "); MessageService.ShowError(ex, "Exception converting bitmap : " + images[imageName] + " : ");
}
} }
toolBoxItems.Add(item);
skip:;
} }
toolBoxItems.Add(item);
skip:;
} }
} }
} }
return toolBoxItems; return toolBoxItems;
} }
void SelectedTabItemChanged(object sender, EventArgs e) void SelectedTabItemChanged(object sender, EventArgs e)
{ {
AxSideTabItem item = (sender as AxSideTab).ChoosedItem; AxSideTabItem item = (sender as AxSideTab).ChoosedItem;

10
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/DesignerResourceService.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.FormDesigner.Services
IDesignerHost host; IDesignerHost host;
string FileName = String.Empty; string FileName = String.Empty;
#region ResourceStorage #region ResourceStorage
public class ResourceStorage public class ResourceStorage
{ {
@ -129,7 +129,7 @@ namespace ICSharpCode.FormDesigner.Services
Resx = 0, Resx = 0,
Resources = 1 Resources = 1
}; };
// In ResourceMemoryStreams are stored: // In ResourceMemoryStreams are stored:
// Key: "true" file names from the project // Key: "true" file names from the project
// Value: ResourceStorage, where the resources are stored // Value: ResourceStorage, where the resources are stored
@ -157,13 +157,13 @@ namespace ICSharpCode.FormDesigner.Services
host = value; host = value;
} }
} }
public DesignerResourceService(string fileName, Dictionary<string, ResourceStorage> resources) public DesignerResourceService(string fileName, Dictionary<string, ResourceStorage> resources)
{ {
this.FileName = fileName; this.FileName = fileName;
this.resources = resources; this.resources = resources;
} }
IProject _project; IProject _project;
IProject GetProject() IProject GetProject()
@ -192,7 +192,7 @@ namespace ICSharpCode.FormDesigner.Services
return null; return null;
} }
} }
public System.Resources.IResourceReader GetResourceReader(System.Globalization.CultureInfo info) public System.Resources.IResourceReader GetResourceReader(System.Globalization.CultureInfo info)
{ {
try { try {

28
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/TypeDiscoveryService.cs

@ -37,35 +37,31 @@ namespace ICSharpCode.FormDesigner.Services
if (baseType != null) { if (baseType != null) {
LoggingService.Debug("TypeDiscoveryService.GetTypes baseType=" + baseType.FullName); LoggingService.Debug("TypeDiscoveryService.GetTypes baseType=" + baseType.FullName);
LoggingService.Debug("TypeDiscoveryService.GetTypes excludeGlobalTypes=" + excludeGlobalTypes.ToString()); LoggingService.Debug("TypeDiscoveryService.GetTypes excludeGlobalTypes=" + excludeGlobalTypes.ToString());
//seek in all assemblies
//allow to work designers like columns editor in datagridview
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) {
AddDerivedTypes(baseType, asm, types);
}
// TODO - Look in more than just System.Windows.Forms. // TODO - Don't look in all assemblies.
// Should use the current project and its referenced assemblies // Should use the current project and its referenced assemblies
// as well as System.Windows.Forms. // as well as System.Windows.Forms.
types.AddRange(GetDerivedTypesFromWindowsForms(baseType));
} }
return types; return types;
} }
/// <summary> /// <summary>
/// Gets the derived types from the System.Windows.Forms assembly. /// Gets the types derived from baseType from the assembly and adds them to the list.
/// </summary> /// </summary>
IList<Type> GetDerivedTypesFromWindowsForms(Type baseType) void AddDerivedTypes(Type baseType, Assembly assembly, IList<Type> list)
{ {
List<Type> types = new List<Type>(); foreach (Type t in assembly.GetExportedTypes()) {
if (t.IsSubclassOf(baseType)) {
Assembly asm = typeof(System.Windows.Forms.Control).Assembly; LoggingService.Debug("TypeDiscoveryService. Adding type=" + t.FullName);
list.Add(t);
foreach (Module m in asm.GetModules()) {
foreach (Type t in m.GetTypes()) {
if (t.IsSubclassOf(baseType)) {
LoggingService.Debug("TypeDiscoveryService. Adding type=" + t.FullName);
types.Add(t);
}
} }
} }
return types;
} }
} }
} }

2
src/Libraries/ICSharpCode.TextEditor/ICSharpCode.TextEditor.sln

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005 # Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor.Test", "Test\ICSharpCode.TextEditor.Test.csproj", "{6259D767-BA7C-484D-9472-68F350A20086}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor.Tests", "Test\ICSharpCode.TextEditor.Tests.csproj", "{6259D767-BA7C-484D-9472-68F350A20086}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
EndProject EndProject

2
src/Libraries/ICSharpCode.TextEditor/Test/DocumentTests.cs

@ -9,7 +9,7 @@ using System;
using NUnit.Framework; using NUnit.Framework;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.TextEditor.Test.Tests namespace ICSharpCode.TextEditor.Tests
{ {
[TestFixture] [TestFixture]
public class DocumentAggregatorTests public class DocumentAggregatorTests

4
src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Test.csproj → src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Tests.csproj

@ -5,8 +5,8 @@
<ProductVersion>8.0.41115</ProductVersion> <ProductVersion>8.0.41115</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6259D767-BA7C-484D-9472-68F350A20086}</ProjectGuid> <ProjectGuid>{6259D767-BA7C-484D-9472-68F350A20086}</ProjectGuid>
<RootNamespace>ICSharpCode.TextEditor.Test</RootNamespace> <RootNamespace>ICSharpCode.TextEditor.Tests</RootNamespace>
<AssemblyName>ICSharpCode.TextEditor.Test</AssemblyName> <AssemblyName>ICSharpCode.TextEditor.Tests</AssemblyName>
<OutputTarget>Library</OutputTarget> <OutputTarget>Library</OutputTarget>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>

0
src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Test.csproj.user → src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Tests.csproj.user

172
src/Libraries/NRefactory/Project/Src/Output/CodeDOM/CodeDOMOutputVisitor.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.NRefactory.Parser
List<CodeVariableDeclarationStatement> variables = new List<CodeVariableDeclarationStatement>(); List<CodeVariableDeclarationStatement> variables = new List<CodeVariableDeclarationStatement>();
TypeDeclaration currentTypeDeclaration = null; TypeDeclaration currentTypeDeclaration = null;
// dummy collection used to swallow statements // dummy collection used to swallow statements
CodeStatementCollection NullStmtCollection = new CodeStatementCollection(); CodeStatementCollection NullStmtCollection = new CodeStatementCollection();
@ -93,7 +93,7 @@ namespace ICSharpCode.NRefactory.Parser
} }
return type; return type;
} }
void AddStmt(CodeStatement stmt) void AddStmt(CodeStatement stmt)
{ {
if (codeStack.Count == 0) if (codeStack.Count == 0)
@ -103,7 +103,7 @@ namespace ICSharpCode.NRefactory.Parser
stmtCollection.Add(stmt); stmtCollection.Add(stmt);
} }
} }
void AddStmt(CodeExpression expr) void AddStmt(CodeExpression expr)
{ {
if (codeStack.Count == 0) if (codeStack.Count == 0)
@ -113,12 +113,12 @@ namespace ICSharpCode.NRefactory.Parser
stmtCollection.Add(expr); stmtCollection.Add(expr);
} }
} }
// FIXME: map all modifiers correctly // FIXME: map all modifiers correctly
MemberAttributes ConvMemberAttributes(Modifier modifier) MemberAttributes ConvMemberAttributes(Modifier modifier)
{ {
MemberAttributes attr = (MemberAttributes)0; MemberAttributes attr = (MemberAttributes)0;
if ((modifier & Modifier.Abstract) != 0) if ((modifier & Modifier.Abstract) != 0)
attr |= MemberAttributes.Abstract; attr |= MemberAttributes.Abstract;
if ((modifier & Modifier.Const) != 0) if ((modifier & Modifier.Const) != 0)
@ -147,7 +147,7 @@ namespace ICSharpCode.NRefactory.Parser
return attr; return attr;
} }
#region ICSharpCode.SharpRefactory.Parser.IASTVisitor interface implementation #region ICSharpCode.SharpRefactory.Parser.IASTVisitor interface implementation
public override object Visit(CompilationUnit compilationUnit, object data) public override object Visit(CompilationUnit compilationUnit, object data)
{ {
@ -266,9 +266,9 @@ namespace ICSharpCode.NRefactory.Parser
memberMethod.Attributes = ConvMemberAttributes(methodDeclaration.Modifier); memberMethod.Attributes = ConvMemberAttributes(methodDeclaration.Modifier);
codeStack.Push(memberMethod.Statements); codeStack.Push(memberMethod.Statements);
typeDeclarations.Peek().Members.Add(memberMethod); typeDeclarations.Peek().Members.Add(memberMethod);
// Add Method Parameters // Add Method Parameters
foreach (ParameterDeclarationExpression parameter in methodDeclaration.Parameters) foreach (ParameterDeclarationExpression parameter in methodDeclaration.Parameters)
{ {
@ -277,21 +277,21 @@ namespace ICSharpCode.NRefactory.Parser
variables.Clear(); variables.Clear();
methodDeclaration.Body.AcceptChildren(this, data); methodDeclaration.Body.AcceptChildren(this, data);
codeStack.Pop(); codeStack.Pop();
return null; return null;
} }
public override object Visit(ConstructorDeclaration constructorDeclaration, object data) public override object Visit(ConstructorDeclaration constructorDeclaration, object data)
{ {
CodeMemberMethod memberMethod = new CodeConstructor(); CodeMemberMethod memberMethod = new CodeConstructor();
codeStack.Push(memberMethod.Statements); codeStack.Push(memberMethod.Statements);
typeDeclarations.Peek().Members.Add(memberMethod); typeDeclarations.Peek().Members.Add(memberMethod);
constructorDeclaration.Body.AcceptChildren(this, data); constructorDeclaration.Body.AcceptChildren(this, data);
codeStack.Pop(); codeStack.Pop();
return null; return null;
} }
@ -335,7 +335,7 @@ namespace ICSharpCode.NRefactory.Parser
public override object Visit(LocalVariableDeclaration localVariableDeclaration, object data) public override object Visit(LocalVariableDeclaration localVariableDeclaration, object data)
{ {
CodeVariableDeclarationStatement declStmt = null; CodeVariableDeclarationStatement declStmt = null;
for (int i = 0; i < localVariableDeclaration.Variables.Count; ++i) { for (int i = 0; i < localVariableDeclaration.Variables.Count; ++i) {
CodeTypeReference type = new CodeTypeReference(Convert(localVariableDeclaration.GetTypeForVariable(i))); CodeTypeReference type = new CodeTypeReference(Convert(localVariableDeclaration.GetTypeForVariable(i)));
VariableDeclaration var = (VariableDeclaration)localVariableDeclaration.Variables[i]; VariableDeclaration var = (VariableDeclaration)localVariableDeclaration.Variables[i];
@ -350,16 +350,16 @@ namespace ICSharpCode.NRefactory.Parser
variables.Add(declStmt); variables.Add(declStmt);
AddStmt(declStmt); AddStmt(declStmt);
} }
return declStmt; return declStmt;
} }
public override object Visit(EmptyStatement emptyStatement, object data) public override object Visit(EmptyStatement emptyStatement, object data)
{ {
CodeSnippetStatement emptyStmt = new CodeSnippetStatement(); CodeSnippetStatement emptyStmt = new CodeSnippetStatement();
AddStmt(emptyStmt); AddStmt(emptyStmt);
return emptyStmt; return emptyStmt;
} }
@ -370,18 +370,18 @@ namespace ICSharpCode.NRefactory.Parser
returnStmt = new CodeMethodReturnStatement(); returnStmt = new CodeMethodReturnStatement();
else else
returnStmt = new CodeMethodReturnStatement((CodeExpression)returnStatement.Expression.AcceptVisitor(this,data)); returnStmt = new CodeMethodReturnStatement((CodeExpression)returnStatement.Expression.AcceptVisitor(this,data));
AddStmt(returnStmt); AddStmt(returnStmt);
return returnStmt; return returnStmt;
} }
public override object Visit(IfElseStatement ifElseStatement, object data) public override object Visit(IfElseStatement ifElseStatement, object data)
{ {
CodeConditionStatement ifStmt = new CodeConditionStatement(); CodeConditionStatement ifStmt = new CodeConditionStatement();
ifStmt.Condition = (CodeExpression)ifElseStatement.Condition.AcceptVisitor(this, data); ifStmt.Condition = (CodeExpression)ifElseStatement.Condition.AcceptVisitor(this, data);
codeStack.Push(ifStmt.TrueStatements); codeStack.Push(ifStmt.TrueStatements);
foreach (Statement stmt in ifElseStatement.TrueStatement) { foreach (Statement stmt in ifElseStatement.TrueStatement) {
if (stmt is BlockStatement) { if (stmt is BlockStatement) {
@ -391,7 +391,7 @@ namespace ICSharpCode.NRefactory.Parser
} }
} }
codeStack.Pop(); codeStack.Pop();
codeStack.Push(ifStmt.FalseStatements); codeStack.Push(ifStmt.FalseStatements);
foreach (Statement stmt in ifElseStatement.FalseStatement) { foreach (Statement stmt in ifElseStatement.FalseStatement) {
if (stmt is BlockStatement) { if (stmt is BlockStatement) {
@ -401,9 +401,9 @@ namespace ICSharpCode.NRefactory.Parser
} }
} }
codeStack.Pop(); codeStack.Pop();
AddStmt(ifStmt); AddStmt(ifStmt);
return ifStmt; return ifStmt;
} }
@ -415,7 +415,7 @@ namespace ICSharpCode.NRefactory.Parser
if (forStatement.Initializers.Count > 1) { if (forStatement.Initializers.Count > 1) {
throw new NotSupportedException("CodeDom does not support Multiple For-Loop Initializer Statements"); throw new NotSupportedException("CodeDom does not support Multiple For-Loop Initializer Statements");
} }
foreach (object o in forStatement.Initializers) { foreach (object o in forStatement.Initializers) {
if (o is Expression) { if (o is Expression) {
forLoop.InitStatement = new CodeExpressionStatement((CodeExpression)((Expression)o).AcceptVisitor(this,data)); forLoop.InitStatement = new CodeExpressionStatement((CodeExpression)((Expression)o).AcceptVisitor(this,data));
@ -433,43 +433,43 @@ namespace ICSharpCode.NRefactory.Parser
} else { } else {
forLoop.TestExpression = (CodeExpression)forStatement.Condition.AcceptVisitor(this, data); forLoop.TestExpression = (CodeExpression)forStatement.Condition.AcceptVisitor(this, data);
} }
codeStack.Push(forLoop.Statements); codeStack.Push(forLoop.Statements);
forStatement.EmbeddedStatement.AcceptVisitor(this, data); forStatement.EmbeddedStatement.AcceptVisitor(this, data);
codeStack.Pop(); codeStack.Pop();
if (forStatement.Iterator.Count > 0) { if (forStatement.Iterator.Count > 0) {
if (forStatement.Initializers.Count > 1) { if (forStatement.Initializers.Count > 1) {
throw new NotSupportedException("CodeDom does not support Multiple For-Loop Iterator Statements"); throw new NotSupportedException("CodeDom does not support Multiple For-Loop Iterator Statements");
} }
foreach (Statement stmt in forStatement.Iterator) { foreach (Statement stmt in forStatement.Iterator) {
forLoop.IncrementStatement = (CodeStatement)stmt.AcceptVisitor(this, data); forLoop.IncrementStatement = (CodeStatement)stmt.AcceptVisitor(this, data);
} }
} }
AddStmt(forLoop); AddStmt(forLoop);
return forLoop; return forLoop;
} }
public override object Visit(LabelStatement labelStatement, object data) public override object Visit(LabelStatement labelStatement, object data)
{ {
System.CodeDom.CodeLabeledStatement labelStmt = new CodeLabeledStatement(labelStatement.Label,(CodeStatement)labelStatement.AcceptVisitor(this, data)); System.CodeDom.CodeLabeledStatement labelStmt = new CodeLabeledStatement(labelStatement.Label,(CodeStatement)labelStatement.AcceptVisitor(this, data));
// Add Statement to Current Statement Collection // Add Statement to Current Statement Collection
AddStmt(labelStmt); AddStmt(labelStmt);
return labelStmt; return labelStmt;
} }
public override object Visit(GotoStatement gotoStatement, object data) public override object Visit(GotoStatement gotoStatement, object data)
{ {
System.CodeDom.CodeGotoStatement gotoStmt = new CodeGotoStatement(gotoStatement.Label); System.CodeDom.CodeGotoStatement gotoStmt = new CodeGotoStatement(gotoStatement.Label);
// Add Statement to Current Statement Collection // Add Statement to Current Statement Collection
AddStmt(gotoStmt); AddStmt(gotoStmt);
return gotoStmt; return gotoStmt;
} }
@ -482,44 +482,44 @@ namespace ICSharpCode.NRefactory.Parser
{ {
// add a try-catch-finally // add a try-catch-finally
CodeTryCatchFinallyStatement tryStmt = new CodeTryCatchFinallyStatement(); CodeTryCatchFinallyStatement tryStmt = new CodeTryCatchFinallyStatement();
codeStack.Push(tryStmt.TryStatements); codeStack.Push(tryStmt.TryStatements);
tryCatchStatement.StatementBlock.AcceptChildren(this, data); tryCatchStatement.StatementBlock.AcceptChildren(this, data);
codeStack.Pop(); codeStack.Pop();
if (!tryCatchStatement.FinallyBlock.IsNull) { if (!tryCatchStatement.FinallyBlock.IsNull) {
codeStack.Push(tryStmt.FinallyStatements); codeStack.Push(tryStmt.FinallyStatements);
tryCatchStatement.FinallyBlock.AcceptChildren(this,data); tryCatchStatement.FinallyBlock.AcceptChildren(this,data);
codeStack.Pop(); codeStack.Pop();
} }
foreach (CatchClause clause in tryCatchStatement.CatchClauses) foreach (CatchClause clause in tryCatchStatement.CatchClauses)
{ {
CodeCatchClause catchClause = new CodeCatchClause(clause.VariableName); CodeCatchClause catchClause = new CodeCatchClause(clause.VariableName);
catchClause.CatchExceptionType = new CodeTypeReference(clause.TypeReference.Type); catchClause.CatchExceptionType = new CodeTypeReference(clause.TypeReference.Type);
tryStmt.CatchClauses.Add(catchClause); tryStmt.CatchClauses.Add(catchClause);
codeStack.Push(catchClause.Statements); codeStack.Push(catchClause.Statements);
clause.StatementBlock.AcceptChildren(this, data); clause.StatementBlock.AcceptChildren(this, data);
codeStack.Pop(); codeStack.Pop();
} }
// Add Statement to Current Statement Collection // Add Statement to Current Statement Collection
AddStmt(tryStmt); AddStmt(tryStmt);
return tryStmt; return tryStmt;
} }
public override object Visit(ThrowStatement throwStatement, object data) public override object Visit(ThrowStatement throwStatement, object data)
{ {
CodeThrowExceptionStatement throwStmt = new CodeThrowExceptionStatement((CodeExpression)throwStatement.Expression.AcceptVisitor(this, data)); CodeThrowExceptionStatement throwStmt = new CodeThrowExceptionStatement((CodeExpression)throwStatement.Expression.AcceptVisitor(this, data));
// Add Statement to Current Statement Collection // Add Statement to Current Statement Collection
AddStmt(throwStmt); AddStmt(throwStmt);
return throwStmt; return throwStmt;
} }
@ -657,7 +657,7 @@ namespace ICSharpCode.NRefactory.Parser
public override object Visit(UnaryOperatorExpression unaryOperatorExpression, object data) public override object Visit(UnaryOperatorExpression unaryOperatorExpression, object data)
{ {
CodeExpression var; CodeExpression var;
switch (unaryOperatorExpression.Op) { switch (unaryOperatorExpression.Op) {
case UnaryOperatorType.Minus: case UnaryOperatorType.Minus:
if (unaryOperatorExpression.Expression is PrimitiveExpression) { if (unaryOperatorExpression.Expression is PrimitiveExpression) {
@ -685,43 +685,43 @@ namespace ICSharpCode.NRefactory.Parser
(CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data)); (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data));
case UnaryOperatorType.Plus: case UnaryOperatorType.Plus:
return unaryOperatorExpression.Expression.AcceptVisitor(this, data); return unaryOperatorExpression.Expression.AcceptVisitor(this, data);
case UnaryOperatorType.PostIncrement: case UnaryOperatorType.PostIncrement:
// emulate i++, with i = i + 1 // emulate i++, with i = i + 1
var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data); var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);
return new CodeAssignStatement(var, return new CodeAssignStatement(var,
new CodeBinaryOperatorExpression(var, new CodeBinaryOperatorExpression(var,
CodeBinaryOperatorType.Add, CodeBinaryOperatorType.Add,
new CodePrimitiveExpression(1))); new CodePrimitiveExpression(1)));
case UnaryOperatorType.PostDecrement: case UnaryOperatorType.PostDecrement:
// emulate i--, with i = i - 1 // emulate i--, with i = i - 1
var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data); var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);
return new CodeAssignStatement(var, return new CodeAssignStatement(var,
new CodeBinaryOperatorExpression(var, new CodeBinaryOperatorExpression(var,
CodeBinaryOperatorType.Subtract, CodeBinaryOperatorType.Subtract,
new CodePrimitiveExpression(1))); new CodePrimitiveExpression(1)));
case UnaryOperatorType.Decrement: case UnaryOperatorType.Decrement:
// emulate --i, with i = i - 1 // emulate --i, with i = i - 1
var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data); var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);
return new CodeAssignStatement(var, return new CodeAssignStatement(var,
new CodeBinaryOperatorExpression(var, new CodeBinaryOperatorExpression(var,
CodeBinaryOperatorType.Subtract, CodeBinaryOperatorType.Subtract,
new CodePrimitiveExpression(1))); new CodePrimitiveExpression(1)));
case UnaryOperatorType.Increment: case UnaryOperatorType.Increment:
// emulate ++i, with i = i + 1 // emulate ++i, with i = i + 1
var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data); var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);
return new CodeAssignStatement(var, return new CodeAssignStatement(var,
new CodeBinaryOperatorExpression(var, new CodeBinaryOperatorExpression(var,
CodeBinaryOperatorType.Add, CodeBinaryOperatorType.Add,
new CodePrimitiveExpression(1))); new CodePrimitiveExpression(1)));
} }
return null; return null;
} }
@ -839,19 +839,13 @@ namespace ICSharpCode.NRefactory.Parser
bool IsFieldReferenceExpression(FieldReferenceExpression fieldReferenceExpression) bool IsFieldReferenceExpression(FieldReferenceExpression fieldReferenceExpression)
{ {
if (fieldReferenceExpression.TargetObject is ThisReferenceExpression) { if (fieldReferenceExpression.TargetObject is ThisReferenceExpression
foreach (object o in this.currentTypeDeclaration.Children) { || fieldReferenceExpression.TargetObject is BaseReferenceExpression)
if (o is FieldDeclaration) { {
FieldDeclaration fd = (FieldDeclaration)o; //field detection for fields\props inherited from base classes
foreach (VariableDeclaration field in fd.Fields) { return IsField(fieldReferenceExpression.FieldName);
if (fieldReferenceExpression.FieldName == field.Name) {
return true;
}
}
}
}
} }
return false; //Char.IsLower(fieldReferenceExpression.FieldName[0]); return false;
} }
public override object Visit(FieldReferenceExpression fieldReferenceExpression, object data) public override object Visit(FieldReferenceExpression fieldReferenceExpression, object data)
@ -917,11 +911,16 @@ namespace ICSharpCode.NRefactory.Parser
} }
} }
} }
//field detection for fields\props inherited from base classes
if (currentTypeDeclaration.BaseTypes.Count > 0) {
return IsField(currentTypeDeclaration.BaseTypes[0].ToString(), identifier);
}
return false; return false;
} }
CodeTypeReferenceExpression ConvertToTypeReference(FieldReferenceExpression fieldReferenceExpression) CodeTypeReferenceExpression ConvertToTypeReference(FieldReferenceExpression fieldReferenceExpression)
{ {
FieldReferenceExpression primaryReferenceExpression = fieldReferenceExpression;
StringBuilder type = new StringBuilder(""); StringBuilder type = new StringBuilder("");
while (fieldReferenceExpression.TargetObject is FieldReferenceExpression) { while (fieldReferenceExpression.TargetObject is FieldReferenceExpression) {
@ -971,17 +970,48 @@ namespace ICSharpCode.NRefactory.Parser
return list; return list;
} }
Type GetType(string typeName) //copy from TypeResolutionService.cs because from this point impossible to access TypeResolutionService
//TODO create universal way for getting types
public Type GetType(string name)
{ {
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) bool throwOnError = false;
{ bool ignoreCase = false;
Type type = asm.GetType(typeName); if (name == null || name.Length == 0) {
if (type != null) return null;
{ }
return type; Assembly lastAssembly = null;
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) {
Type t = asm.GetType(name, throwOnError);
if (t != null) {
lastAssembly = asm;
} }
} }
return Type.GetType(typeName); if (lastAssembly != null) {
return lastAssembly.GetType(name, throwOnError, ignoreCase);
}
Type type = Type.GetType(name, throwOnError, ignoreCase);
// type lookup for typename, assembly, xyz style lookups
if (type == null) {
int idx = name.IndexOf(",");
if (idx > 0) {
string[] splitName = name.Split(',');
string typeName = splitName[0];
string assemblyName = splitName[1].Substring(1);
Assembly assembly = null;
try {
assembly = Assembly.Load(assemblyName);
} catch (Exception) {}
if (assembly != null) {
type = assembly.GetType(typeName, throwOnError, ignoreCase);
} else {
type = Type.GetType(typeName, throwOnError, ignoreCase);
}
}
}
return type;
} }
} }
} }

2
src/SharpDevelop.Tests.sln

@ -38,7 +38,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAntAddIn", "AddIns\Misc\NA
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks.Tests", "Libraries\ICSharpCode.Build.Tasks\Test\ICSharpCode.Build.Tasks.Tests.csproj", "{B7C2A664-B454-4920-AC6E-318F5274B2EF}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks.Tests", "Libraries\ICSharpCode.Build.Tasks\Test\ICSharpCode.Build.Tasks.Tests.csproj", "{B7C2A664-B454-4920-AC6E-318F5274B2EF}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor.Test", "Libraries\ICSharpCode.TextEditor\Test\ICSharpCode.TextEditor.Test.csproj", "{6259D767-BA7C-484D-9472-68F350A20086}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor.Tests", "Libraries\ICSharpCode.TextEditor\Test\ICSharpCode.TextEditor.Tests.csproj", "{6259D767-BA7C-484D-9472-68F350A20086}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
EndProject EndProject

Loading…
Cancel
Save