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. 20
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerSecondaryDisplayBinding.cs
  3. 14
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs
  4. 132
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/CustomComponentsSideTab.cs
  5. 90
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/SideTabDesigner.cs
  6. 28
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/TypeDiscoveryService.cs
  7. 2
      src/Libraries/ICSharpCode.TextEditor/ICSharpCode.TextEditor.sln
  8. 2
      src/Libraries/ICSharpCode.TextEditor/Test/DocumentTests.cs
  9. 4
      src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Tests.csproj
  10. 0
      src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Tests.csproj.user
  11. 70
      src/Libraries/NRefactory/Project/Src/Output/CodeDOM/CodeDOMOutputVisitor.cs
  12. 2
      src/SharpDevelop.Tests.sln

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

@ -112,7 +112,21 @@ namespace ICSharpCode.FormDesigner @@ -112,7 +112,21 @@ namespace ICSharpCode.FormDesigner
protected override void OnEndLoad(bool successful, ICollection errors)
{
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;
@ -192,7 +206,7 @@ namespace ICSharpCode.FormDesigner @@ -192,7 +206,7 @@ namespace ICSharpCode.FormDesigner
TypeDeclaration td = o as TypeDeclaration;
if (td != null && td.Name == formDecl.Name) {
foreach (INode node in td.Children)
formDecl.AddChild(node);
formDecl.AddChild(node);
formDecl.BaseTypes.AddRange(td.BaseTypes);
}
if (o is NamespaceDeclaration) {

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

@ -13,6 +13,8 @@ using ICSharpCode.SharpDevelop.Gui; @@ -13,6 +13,8 @@ using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.FormDesigner.Services;
using System.ComponentModel.Design;
namespace ICSharpCode.FormDesigner
{
@ -44,6 +46,13 @@ namespace ICSharpCode.FormDesigner @@ -44,6 +46,13 @@ namespace ICSharpCode.FormDesigner
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;
}
@ -52,13 +61,11 @@ namespace ICSharpCode.FormDesigner @@ -52,13 +61,11 @@ namespace ICSharpCode.FormDesigner
if (info != null) {
ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
foreach (IClass c in cu.Classes) {
if (BaseClassIsFormOrControl(c)) {
IMethod method = GetInitializeComponents(c);
if (method == null) {
return false;
}
return true;
IMethod method = GetInitializeComponents(c);
if (method == null) {
return false;
}
return BaseClassIsFormOrControl(c);
}
}
return false;
@ -79,6 +86,7 @@ namespace ICSharpCode.FormDesigner @@ -79,6 +86,7 @@ namespace ICSharpCode.FormDesigner
case ".cs":
case ".vb":
ParseInformation info = ParserService.ParseFile(fileName, textAreaControlProvider.TextEditorControl.Document.TextContent, false, true);
if (IsDesignable(info))
return true;
break;

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

@ -131,6 +131,7 @@ namespace ICSharpCode.FormDesigner @@ -131,6 +131,7 @@ namespace ICSharpCode.FormDesigner
serviceContainer.AddService(typeof(IHelpService), new HelpService());
serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService());
designerResourceService = new DesignerResourceService(viewContent.FileName, this.resources);
serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), designerResourceService);
AmbientProperties ambientProperties = new AmbientProperties();
@ -220,6 +221,19 @@ namespace ICSharpCode.FormDesigner @@ -220,6 +221,19 @@ namespace ICSharpCode.FormDesigner
errorText.Text = e.Message;
else
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;
p.Controls.Add(errorText);
Control title = new Label();

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

@ -10,6 +10,7 @@ using System.IO; @@ -10,6 +10,7 @@ using System.IO;
using System.Windows.Forms;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Design;
using System.ComponentModel;
@ -33,6 +34,8 @@ namespace ICSharpCode.FormDesigner.Gui @@ -33,6 +34,8 @@ namespace ICSharpCode.FormDesigner.Gui
{
ArrayList projectAssemblies = new ArrayList();
ArrayList referencedAssemblies = new ArrayList();
Dictionary<string, Assembly> loadedFiles = new Dictionary<string, Assembly>();
List<string> loadedProjects = new List<string>();
static bool loadReferencedAssemblies = true;
@ -73,69 +76,54 @@ namespace ICSharpCode.FormDesigner.Gui @@ -73,69 +76,54 @@ namespace ICSharpCode.FormDesigner.Gui
if (idx >= 0) {
file = file.Substring(0, idx);
}
try {
if (File.Exists(loadingPath + file + ".exe")) {
LoggingService.Debug("Form Designer: MyResolve: Load bytes from exe");
return Assembly.Load(GetBytes(loadingPath + file + ".exe"));
//search in other assemblies, this also help to avoid doubling of loaded assms
if (ProjectService.OpenSolution != null) {
foreach (IProject project in ProjectService.OpenSolution.Projects) {
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"));
}
//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;
}
LoggingService.Info("Form Designer: MyResolve: did not find " + args.Name);
} catch (Exception ex) {
LoggingService.Warn("Form Designer: MyResolve: Can't load assembly", ex);
}
if (lastAssembly != null) {
LoggingService.Info("ICSharpAssemblyResolver found..." + args.Name);
return lastAssembly;
}
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)
{
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)) {
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) {
loadedFiles[assemblyName] = asm;
BuildToolboxFromAssembly(asm);
}
return asm;
@ -143,11 +131,31 @@ namespace ICSharpCode.FormDesigner.Gui @@ -143,11 +131,31 @@ namespace ICSharpCode.FormDesigner.Gui
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()
{
projectAssemblies.Clear();
referencedAssemblies.Clear();
loadedFiles.Clear();
loadedProjects.Clear();
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
try {
@ -156,24 +164,8 @@ namespace ICSharpCode.FormDesigner.Gui @@ -156,24 +164,8 @@ namespace ICSharpCode.FormDesigner.Gui
ITypeResolutionService typeResolutionService = ToolboxProvider.TypeResolutionService;
if (ProjectService.OpenSolution != null) {
foreach (IProject project in ProjectService.OpenSolution.Projects) {
string assemblyName = project.OutputAssemblyFullPath;
projectAssemblies.Add(assemblyName);
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);
// }
// }
// }
}
LoadProject(project);
projectAssemblies.Add(project.OutputAssemblyFullPath);
}
}
} catch (Exception e) {

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

@ -126,63 +126,63 @@ namespace ICSharpCode.FormDesigner.Gui @@ -126,63 +126,63 @@ namespace ICSharpCode.FormDesigner.Gui
string[] imgNames = assembly.GetManifestResourceNames();
foreach (string im in imgNames) {
try {
Stream stream = assembly.GetManifestResourceStream(im);
if (stream != null) {
Bitmap b = new Bitmap(Image.FromStream(stream));
b.MakeTransparent();
images[im] = il.Images.Count;
il.Images.Add(b);
stream.Close();
if (!im.EndsWith(".resources")) //load resources only to avoid exception on debugging
{
try {
Stream stream = assembly.GetManifestResourceStream(im);
if (stream != null) {
Bitmap b = new Bitmap(Image.FromStream(stream, true, false));
b.MakeTransparent();
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);
foreach (Module m in ms) {
Type[] ts = m.GetTypes();
foreach (Type t in ts) {
if (t.IsPublic && !t.IsAbstract) {
if (t.IsDefined(typeof(ToolboxItemFilterAttribute), true) || t.IsDefined(typeof(ToolboxItemAttribute), true) || t.IsDefined(typeof(DesignTimeVisibleAttribute), true) || typeof(System.ComponentModel.IComponent).IsAssignableFrom(t)) {
object[] filterAttrs = t.GetCustomAttributes(typeof(DesignTimeVisibleAttribute), true);
foreach (DesignTimeVisibleAttribute visibleAttr in filterAttrs) {
if (!visibleAttr.Visible) {
goto skip;
}
Type[] ts = assembly.GetExportedTypes();
foreach (Type t in ts) {
if (t.IsPublic && !t.IsAbstract) {
if (t.IsDefined(typeof(ToolboxItemFilterAttribute), true) || t.IsDefined(typeof(ToolboxItemAttribute), true) || t.IsDefined(typeof(DesignTimeVisibleAttribute), true) || typeof(System.ComponentModel.IComponent).IsAssignableFrom(t)) {
object[] filterAttrs = t.GetCustomAttributes(typeof(DesignTimeVisibleAttribute), true);
foreach (DesignTimeVisibleAttribute visibleAttr in filterAttrs) {
if (!visibleAttr.Visible) {
goto skip;
}
string imageName = String.Concat(t.FullName, ".bmp");
if (images[imageName] == null) {
object[] attributes = t.GetCustomAttributes(false);
if (t.IsDefined(typeof(ToolboxBitmapAttribute), false)) {
foreach (object attr in attributes) {
if (attr is ToolboxBitmapAttribute) {
ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr;
Bitmap b = new Bitmap(toolboxBitmapAttribute.GetImage(t));
b.MakeTransparent();
il.Images.Add(b);
images[imageName] =b;
break;
}
}
string imageName = String.Concat(t.FullName, ".bmp");
if (images[imageName] == null) {
object[] attributes = t.GetCustomAttributes(false);
if (t.IsDefined(typeof(ToolboxBitmapAttribute), false)) {
foreach (object attr in attributes) {
if (attr is ToolboxBitmapAttribute) {
ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr;
Bitmap b = new Bitmap(toolboxBitmapAttribute.GetImage(t));
b.MakeTransparent();
il.Images.Add(b);
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];
} catch (Exception ex) {
MessageService.ShowError(ex, "Exception converting bitmap : " + images[imageName] + " : ");
}
} catch (Exception ex) {
MessageService.ShowError(ex, "Exception converting bitmap : " + images[imageName] + " : ");
}
toolBoxItems.Add(item);
skip:;
}
toolBoxItems.Add(item);
skip:;
}
}
}

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

@ -37,35 +37,31 @@ namespace ICSharpCode.FormDesigner.Services @@ -37,35 +37,31 @@ namespace ICSharpCode.FormDesigner.Services
if (baseType != null) {
LoggingService.Debug("TypeDiscoveryService.GetTypes baseType=" + baseType.FullName);
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
// as well as System.Windows.Forms.
types.AddRange(GetDerivedTypesFromWindowsForms(baseType));
}
return types;
}
/// <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>
IList<Type> GetDerivedTypesFromWindowsForms(Type baseType)
void AddDerivedTypes(Type baseType, Assembly assembly, IList<Type> list)
{
List<Type> types = new List<Type>();
Assembly asm = typeof(System.Windows.Forms.Control).Assembly;
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);
}
foreach (Type t in assembly.GetExportedTypes()) {
if (t.IsSubclassOf(baseType)) {
LoggingService.Debug("TypeDiscoveryService. Adding type=" + t.FullName);
list.Add(t);
}
}
return types;
}
}
}

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

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# 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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
EndProject

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

@ -9,7 +9,7 @@ using System; @@ -9,7 +9,7 @@ using System;
using NUnit.Framework;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.TextEditor.Test.Tests
namespace ICSharpCode.TextEditor.Tests
{
[TestFixture]
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 @@ @@ -5,8 +5,8 @@
<ProductVersion>8.0.41115</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6259D767-BA7C-484D-9472-68F350A20086}</ProjectGuid>
<RootNamespace>ICSharpCode.TextEditor.Test</RootNamespace>
<AssemblyName>ICSharpCode.TextEditor.Test</AssemblyName>
<RootNamespace>ICSharpCode.TextEditor.Tests</RootNamespace>
<AssemblyName>ICSharpCode.TextEditor.Tests</AssemblyName>
<OutputTarget>Library</OutputTarget>
<WarningLevel>4</WarningLevel>
<NoStdLib>False</NoStdLib>

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

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

@ -839,19 +839,13 @@ namespace ICSharpCode.NRefactory.Parser @@ -839,19 +839,13 @@ namespace ICSharpCode.NRefactory.Parser
bool IsFieldReferenceExpression(FieldReferenceExpression fieldReferenceExpression)
{
if (fieldReferenceExpression.TargetObject is ThisReferenceExpression) {
foreach (object o in this.currentTypeDeclaration.Children) {
if (o is FieldDeclaration) {
FieldDeclaration fd = (FieldDeclaration)o;
foreach (VariableDeclaration field in fd.Fields) {
if (fieldReferenceExpression.FieldName == field.Name) {
return true;
}
}
}
}
if (fieldReferenceExpression.TargetObject is ThisReferenceExpression
|| fieldReferenceExpression.TargetObject is BaseReferenceExpression)
{
//field detection for fields\props inherited from base classes
return IsField(fieldReferenceExpression.FieldName);
}
return false; //Char.IsLower(fieldReferenceExpression.FieldName[0]);
return false;
}
public override object Visit(FieldReferenceExpression fieldReferenceExpression, object data)
@ -917,11 +911,16 @@ namespace ICSharpCode.NRefactory.Parser @@ -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;
}
CodeTypeReferenceExpression ConvertToTypeReference(FieldReferenceExpression fieldReferenceExpression)
{
FieldReferenceExpression primaryReferenceExpression = fieldReferenceExpression;
StringBuilder type = new StringBuilder("");
while (fieldReferenceExpression.TargetObject is FieldReferenceExpression) {
@ -971,17 +970,48 @@ namespace ICSharpCode.NRefactory.Parser @@ -971,17 +970,48 @@ namespace ICSharpCode.NRefactory.Parser
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())
{
Type type = asm.GetType(typeName);
if (type != null)
{
return type;
bool throwOnError = false;
bool ignoreCase = false;
if (name == null || name.Length == 0) {
return null;
}
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 @@ -38,7 +38,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAntAddIn", "AddIns\Misc\NA
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}"
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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
EndProject

Loading…
Cancel
Save