Browse Source

Merge 3.0 to trunk.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4961 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
631487884e
  1. 3
      samples/NRefactoryDemo/MainForm.cs
  2. 2
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ConvertVisitor.cs
  3. 2
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorTypeMembers.cs
  4. 102
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs
  5. 9
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
  6. 6
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonPropertyAssignmentToStringTests.cs
  7. 4
      src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Src/ClassCanvas.cs
  8. 18
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/FormKeyHandler.cs
  9. 5
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs
  10. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  11. 19
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Views/WpfViewer.cs
  12. 4
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/Ime.cs
  13. 2
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs
  14. 1222
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  15. 40
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  16. 14
      src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs
  17. 22
      src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs
  18. 12
      src/Main/Base/Project/Src/Services/HelpProvider.cs
  19. 40
      src/Main/Base/Test/NRefactoryResolverTests.cs
  20. 53
      src/Main/Base/Test/ReflectionLayerTests.cs
  21. 158
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/CSharpAmbience.cs
  22. 11
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs
  23. 13
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs
  24. 42
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryASTConvertVisitor.cs
  25. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/DomPersistence.cs
  26. 8
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionEvent.cs
  27. 11
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionMethod.cs
  28. 10
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionProperty.cs
  29. 152
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/VBNetAmbience.cs
  30. 52
      src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/CSharpAmbienceTests.cs
  31. 12
      src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/CodeSnippetConverterTests.cs
  32. 5
      src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/ICSharpCode.SharpDevelop.Dom.Tests.csproj
  33. 37
      src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/NRefactoryAstConverterTests.cs
  34. 53
      src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/VBNetAmbienceTests.cs
  35. BIN
      src/Tools/NUnit/lib/nunit-console-runner.dll
  36. BIN
      src/Tools/NUnit/lib/nunit-gui-runner.dll
  37. BIN
      src/Tools/NUnit/lib/nunit.core.dll
  38. BIN
      src/Tools/NUnit/lib/nunit.core.interfaces.dll
  39. BIN
      src/Tools/NUnit/lib/nunit.fixtures.dll
  40. BIN
      src/Tools/NUnit/lib/nunit.uiexception.dll
  41. BIN
      src/Tools/NUnit/lib/nunit.uikit.dll
  42. BIN
      src/Tools/NUnit/lib/nunit.util.dll
  43. BIN
      src/Tools/NUnit/nunit-console-dotnet2-x86.exe
  44. BIN
      src/Tools/NUnit/nunit-console-dotnet2.exe
  45. BIN
      src/Tools/NUnit/nunit-console-x86.exe
  46. BIN
      src/Tools/NUnit/nunit-console.exe
  47. 4
      src/Tools/NUnit/nunit-console/AssemblyInfo.cs
  48. BIN
      src/Tools/NUnit/nunit.framework.dll

3
samples/NRefactoryDemo/MainForm.cs

@ -108,7 +108,9 @@ namespace NRefactoryDemo
{ {
using (IParser parser = ParserFactory.CreateParser(language, new StringReader(text))) { using (IParser parser = ParserFactory.CreateParser(language, new StringReader(text))) {
parser.Parse(); parser.Parse();
// this allows retrieving comments, preprocessor directives, etc. (stuff that isn't part of the syntax)
SetSpecials(parser.Lexer.SpecialTracker.RetrieveSpecials()); SetSpecials(parser.Lexer.SpecialTracker.RetrieveSpecials());
// this retrieves the root node of the result AST
astView.Unit = parser.CompilationUnit; astView.Unit = parser.CompilationUnit;
if (parser.Errors.Count > 0) { if (parser.Errors.Count > 0) {
MessageBox.Show(parser.Errors.ErrorOutput, "Parse errors"); MessageBox.Show(parser.Errors.ErrorOutput, "Parse errors");
@ -128,6 +130,7 @@ namespace NRefactoryDemo
void GenerateCode(IOutputAstVisitor outputVisitor) void GenerateCode(IOutputAstVisitor outputVisitor)
{ {
// re-insert the comments we saved from the parser into the output
using (SpecialNodesInserter.Install(savedSpecialsList, outputVisitor)) { using (SpecialNodesInserter.Install(savedSpecialsList, outputVisitor)) {
astView.Unit.AcceptVisitor(outputVisitor, null); astView.Unit.AcceptVisitor(outputVisitor, null);
} }

2
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ConvertVisitor.cs

@ -223,7 +223,7 @@ namespace Grunwald.BooBinding.CodeCompletion
if (par.IsByRef) p.Modifiers |= ParameterModifiers.Ref; if (par.IsByRef) p.Modifiers |= ParameterModifiers.Ref;
output.Add(p); output.Add(p);
} }
if (parameters.VariableNumber) { if (parameters.HasParamArray) {
p.Modifiers |= ParameterModifiers.Params; p.Modifiers |= ParameterModifiers.Params;
} }
} }

2
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorTypeMembers.cs

@ -154,7 +154,7 @@ namespace NRefactoryToBooConverter
if (para != null) if (para != null)
output.Add(para); output.Add(para);
} }
output.VariableNumber = isParams; output.HasParamArray = isParams;
} }
B.ParameterDeclaration ConvertParameter(ParameterDeclarationExpression pde, out bool isParams) B.ParameterDeclaration ConvertParameter(ParameterDeclarationExpression pde, out bool isParams)

102
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs

@ -20,14 +20,63 @@ namespace CSharpBinding.FormattingStrategy
public sealed class IndentationReformatter public sealed class IndentationReformatter
{ {
/// <summary>
/// An indentation block. Tracks the state of the indentation.
/// </summary>
public struct Block public struct Block
{ {
/// <summary>
/// The indentation outside of the block.
/// </summary>
public string OuterIndent; public string OuterIndent;
/// <summary>
/// The indentation inside the block.
/// </summary>
public string InnerIndent; public string InnerIndent;
/// <summary>
/// The last word that was seen inside this block.
/// Because parenthesis open a sub-block and thus don't change their parent's LastWord,
/// this property can be used to identify the type of block statement (if, while, switch)
/// at the position of the '{'.
/// </summary>
public string LastWord; public string LastWord;
/// <summary>
/// The type of bracket that opened this block (, [ or {
/// </summary>
public char Bracket; public char Bracket;
/// <summary>
/// Gets whether there's currently a line continuation going on inside this block.
/// </summary>
public bool Continuation; public bool Continuation;
public bool OneLineBlock;
/// <summary>
/// Gets whether there's currently a 'one-line-block' going on. 'one-line-blocks' occur
/// with if statements that don't use '{}'. They are not represented by a Block instance on
/// the stack, but are instead handled similar to line continuations.
/// This property is an integer because there might be multiple nested one-line-blocks.
/// As soon as there is a finished statement, OneLineBlock is reset to 0.
/// </summary>
public int OneLineBlock;
/// <summary>
/// The previous value of one-line-block before it was reset.
/// Used to restore the indentation of 'else' to the correct level.
/// </summary>
public int PreviousOneLineBlock;
public void ResetOneLineBlock()
{
PreviousOneLineBlock = OneLineBlock;
OneLineBlock = 0;
}
/// <summary>
/// Gets the line number where this block started.
/// </summary>
public int StartLine; public int StartLine;
public void Indent(IndentationSettings set) public void Indent(IndentationSettings set)
@ -40,9 +89,15 @@ namespace CSharpBinding.FormattingStrategy
OuterIndent = InnerIndent; OuterIndent = InnerIndent;
InnerIndent += str; InnerIndent += str;
Continuation = false; Continuation = false;
OneLineBlock = false; ResetOneLineBlock();
LastWord = ""; LastWord = "";
} }
public override string ToString()
{
return string.Format("[Block StartLine={0}, LastWord='{1}', Continuation={2}, OneLineBlock={3}, PreviousOneLineBlock={4}]",
this.StartLine, this.LastWord, this.Continuation, this.OneLineBlock, this.PreviousOneLineBlock);
}
} }
StringBuilder wordBuilder; StringBuilder wordBuilder;
@ -78,7 +133,8 @@ namespace CSharpBinding.FormattingStrategy
block.Bracket = '{'; block.Bracket = '{';
block.Continuation = false; block.Continuation = false;
block.LastWord = ""; block.LastWord = "";
block.OneLineBlock = false; block.OneLineBlock = 0;
block.PreviousOneLineBlock = 0;
block.StartLine = 0; block.StartLine = 0;
inString = false; inString = false;
@ -104,8 +160,7 @@ namespace CSharpBinding.FormattingStrategy
if (blockComment || (inString && verbatim)) if (blockComment || (inString && verbatim))
return; return;
indent.Append(block.InnerIndent); indent.Append(block.InnerIndent);
if (block.OneLineBlock) indent.Append(Repeat(set.IndentString, block.OneLineBlock));
indent.Append(set.IndentString);
if (block.Continuation) if (block.Continuation)
indent.Append(set.IndentString); indent.Append(set.IndentString);
if (doc.Text != indent.ToString()) if (doc.Text != indent.ToString())
@ -212,7 +267,7 @@ namespace CSharpBinding.FormattingStrategy
#region Push/Pop the blocks #region Push/Pop the blocks
switch (c) { switch (c) {
case '{': case '{':
block.OneLineBlock = false; block.ResetOneLineBlock();
blocks.Push(block); blocks.Push(block);
block.StartLine = doc.LineNumber; block.StartLine = doc.LineNumber;
if (block.LastWord == "switch") { if (block.LastWord == "switch") {
@ -242,7 +297,7 @@ namespace CSharpBinding.FormattingStrategy
if (blocks.Count == 0) break; if (blocks.Count == 0) break;
block = blocks.Pop(); block = blocks.Pop();
block.Continuation = false; block.Continuation = false;
block.OneLineBlock = false; block.ResetOneLineBlock();
break; break;
case '(': case '(':
case '[': case '[':
@ -252,7 +307,7 @@ namespace CSharpBinding.FormattingStrategy
else else
block.StartLine = doc.LineNumber; block.StartLine = doc.LineNumber;
block.Indent(set, block.Indent(set,
(oldBlock.OneLineBlock ? set.IndentString : "") + Repeat(set.IndentString, oldBlock.OneLineBlock) +
(oldBlock.Continuation ? set.IndentString : "") + (oldBlock.Continuation ? set.IndentString : "") +
(i == line.Length - 1 ? set.IndentString : new String(' ', i + 1))); (i == line.Length - 1 ? set.IndentString : new String(' ', i + 1)));
block.Bracket = c; block.Bracket = c;
@ -273,12 +328,12 @@ namespace CSharpBinding.FormattingStrategy
case ';': case ';':
case ',': case ',':
block.Continuation = false; block.Continuation = false;
block.OneLineBlock = false; block.ResetOneLineBlock();
break; break;
case ':': case ':':
if (block.LastWord == "case" || line.StartsWith("case ") || line.StartsWith(block.LastWord + ":")) { if (block.LastWord == "case" || line.StartsWith("case ") || line.StartsWith(block.LastWord + ":")) {
block.Continuation = false; block.Continuation = false;
block.OneLineBlock = false; block.ResetOneLineBlock();
} }
break; break;
} }
@ -302,7 +357,7 @@ namespace CSharpBinding.FormattingStrategy
if (line[0] == '}') { if (line[0] == '}') {
indent.Append(oldBlock.OuterIndent); indent.Append(oldBlock.OuterIndent);
oldBlock.OneLineBlock = false; oldBlock.ResetOneLineBlock();
oldBlock.Continuation = false; oldBlock.Continuation = false;
} else { } else {
indent.Append(oldBlock.InnerIndent); indent.Append(oldBlock.InnerIndent);
@ -321,18 +376,19 @@ namespace CSharpBinding.FormattingStrategy
indent.Remove(indent.Length - set.IndentString.Length, set.IndentString.Length); indent.Remove(indent.Length - set.IndentString.Length, set.IndentString.Length);
} else if (lastRealChar == ')') { } else if (lastRealChar == ')') {
if (IsSingleStatementKeyword(block.LastWord)) { if (IsSingleStatementKeyword(block.LastWord)) {
block.OneLineBlock = true; block.OneLineBlock++;
} }
} else if (lastRealChar == 'e' && block.LastWord == "else") { } else if (lastRealChar == 'e' && block.LastWord == "else") {
block.OneLineBlock = true; block.OneLineBlock = Math.Max(1, block.PreviousOneLineBlock);
block.Continuation = false; block.Continuation = false;
oldBlock.OneLineBlock = block.OneLineBlock - 1;
} }
if (doc.ReadOnly) { if (doc.ReadOnly) {
// We can't change the current line, but we should accept the existing // We can't change the current line, but we should accept the existing
// indentation if possible (=if the current statement is not a multiline // indentation if possible (=if the current statement is not a multiline
// statement). // statement).
if (!oldBlock.Continuation && !oldBlock.OneLineBlock && if (!oldBlock.Continuation && oldBlock.OneLineBlock == 0 &&
oldBlock.StartLine == block.StartLine && oldBlock.StartLine == block.StartLine &&
block.StartLine < doc.LineNumber && lastRealChar != ':') block.StartLine < doc.LineNumber && lastRealChar != ':')
{ {
@ -357,8 +413,7 @@ namespace CSharpBinding.FormattingStrategy
if (line[0] != '{') { if (line[0] != '{') {
if (line[0] != ')' && oldBlock.Continuation && oldBlock.Bracket == '{') if (line[0] != ')' && oldBlock.Continuation && oldBlock.Bracket == '{')
indent.Append(set.IndentString); indent.Append(set.IndentString);
if (oldBlock.OneLineBlock) indent.Append(Repeat(set.IndentString, oldBlock.OneLineBlock));
indent.Append(set.IndentString);
} }
// this is only for blockcomment lines starting with *, // this is only for blockcomment lines starting with *,
@ -374,7 +429,20 @@ namespace CSharpBinding.FormattingStrategy
} }
} }
bool IsSingleStatementKeyword(string keyword) { static string Repeat(string text, int count)
{
if (count == 0)
return string.Empty;
if (count == 1)
return text;
StringBuilder b = new StringBuilder(text.Length * count);
for (int i = 0; i < count; i++)
b.Append(text);
return b.ToString();
}
bool IsSingleStatementKeyword(string keyword)
{
switch (keyword) { switch (keyword) {
case "if": case "if":
case "for": case "for":

9
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs

@ -32,9 +32,10 @@ namespace ICSharpCode.PythonBinding
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// 1) Strings are returned surrounded by double quotes. /// 1) Strings are returned surrounded by double quotes.
/// 2) Objects are returned with their full name (e.g. System.Windows.Forms.Size(100, 200)). /// 2) Characters are returned surrounded by double quotes.
/// 3) Enums are returned with their full name (e.g. System.Windows.Forms.AccessibleRole.None). /// 3) Objects are returned with their full name (e.g. System.Windows.Forms.Size(100, 200)).
/// 4) By default the ToString method is used on the property value. /// 4) Enums are returned with their full name (e.g. System.Windows.Forms.AccessibleRole.None).
/// 5) By default the ToString method is used on the property value.
/// </remarks> /// </remarks>
public static string ToString(object propertyValue) public static string ToString(object propertyValue)
{ {
@ -45,6 +46,8 @@ namespace ICSharpCode.PythonBinding
Type propertyType = propertyValue.GetType(); Type propertyType = propertyValue.GetType();
if (propertyType == typeof(String)) { if (propertyType == typeof(String)) {
return GetQuotedString((string)propertyValue); return GetQuotedString((string)propertyValue);
} else if (propertyType == typeof(Char)) {
return GetQuotedString(propertyValue.ToString());
} else if (propertyType == typeof(AnchorStyles)) { } else if (propertyType == typeof(AnchorStyles)) {
AnchorStyles anchor = (AnchorStyles)propertyValue; AnchorStyles anchor = (AnchorStyles)propertyValue;
return GetAnchorStyleAsString(anchor); return GetAnchorStyleAsString(anchor);

6
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonPropertyAssignmentToStringTests.cs

@ -111,5 +111,11 @@ namespace PythonBinding.Tests.Designer
{ {
Assert.AreEqual("None", PythonPropertyValueAssignment.ToString(null)); Assert.AreEqual("None", PythonPropertyValueAssignment.ToString(null));
} }
[Test]
public void CharConversion()
{
Assert.AreEqual("\"*\"", PythonPropertyValueAssignment.ToString('*'));
}
} }
} }

4
src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Src/ClassCanvas.cs

@ -204,8 +204,8 @@ namespace ClassDiagram
// System.Diagnostics.Debug.WriteLine("ClassCanvas.PictureBox1Paint"); // System.Diagnostics.Debug.WriteLine("ClassCanvas.PictureBox1Paint");
Size bbox = GetDiagramPixelSize(); Size bbox = GetDiagramPixelSize();
pictureBox1.Width = bbox.Width + 100; pictureBox1.Width = Math.Min(10000, bbox.Width + 100);
pictureBox1.Height = bbox.Height + 100; pictureBox1.Height = Math.Min(10000, bbox.Height + 100);
e.Graphics.PageScale = zoom; e.Graphics.PageScale = zoom;
SetRecommendedGraphicsAttributes(e.Graphics); SetRecommendedGraphicsAttributes(e.Graphics);

18
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/FormKeyHandler.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Design; using System.ComponentModel.Design;
using System.Reflection; using System.Reflection;
@ -18,12 +19,12 @@ using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.FormsDesigner namespace ICSharpCode.FormsDesigner
{ {
public class FormKeyHandler : IMessageFilter public sealed class FormKeyHandler : IMessageFilter
{ {
const int keyPressedMessage = 0x100; const int keyPressedMessage = 0x100;
const int leftMouseButtonDownMessage = 0x0202; const int leftMouseButtonDownMessage = 0x0202;
Hashtable keyTable = new Hashtable(); readonly Dictionary<Keys, CommandWrapper> keyTable = new Dictionary<Keys, CommandWrapper>();
public static bool inserted = false; public static bool inserted = false;
public static void Insert() public static void Insert()
{ {
@ -78,6 +79,13 @@ namespace ICSharpCode.FormsDesigner
if (!((Control)formDesigner.Control).ContainsFocus) if (!((Control)formDesigner.Control).ContainsFocus)
return false; return false;
Control originControl = Control.FromChildHandle(m.HWnd);
if (originControl != null && formDesigner.UserContent != null && !(formDesigner.UserContent == originControl || formDesigner.UserContent.Contains(originControl))) {
// Ignore if message origin not in forms designer
// (e.g. navigating the main menu)
return false;
}
Keys keyPressed = (Keys)m.WParam.ToInt32() | Control.ModifierKeys; Keys keyPressed = (Keys)m.WParam.ToInt32() | Control.ModifierKeys;
if (keyPressed == Keys.Escape) { if (keyPressed == Keys.Escape) {
@ -87,8 +95,8 @@ namespace ICSharpCode.FormsDesigner
} }
} }
CommandWrapper commandWrapper = (CommandWrapper)keyTable[keyPressed]; CommandWrapper commandWrapper;
if (commandWrapper != null) { if (keyTable.TryGetValue(keyPressed, out commandWrapper)) {
if (commandWrapper.CommandID == MenuCommands.Delete) { if (commandWrapper.CommandID == MenuCommands.Delete) {
// Check Delete menu is enabled. // Check Delete menu is enabled.
if (!formDesigner.EnableDelete) { if (!formDesigner.EnableDelete) {
@ -156,7 +164,7 @@ namespace ICSharpCode.FormsDesigner
return false; // invoke the CommandID return false; // invoke the CommandID
} }
class CommandWrapper sealed class CommandWrapper
{ {
CommandID commandID; CommandID commandID;
bool restoreSelection; bool restoreSelection;

5
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs

@ -512,10 +512,11 @@ namespace ICSharpCode.XmlEditor
void InitAutoCompleteMode() void InitAutoCompleteMode()
{ {
try { // Auto-completion disabled due to bug - see SD2-1049 - XPath query combo box is case insensitive
/*try {
xPathComboBox.AutoCompleteMode = AutoCompleteMode.Suggest; xPathComboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
xPathComboBox.AutoCompleteSource = AutoCompleteSource.ListItems; xPathComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
} catch (ThreadStateException) { } } catch (ThreadStateException) { }*/
} }
void XPathResultsListViewItemActivate(object sender, EventArgs e) void XPathResultsListViewItemActivate(object sender, EventArgs e)

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -574,7 +574,9 @@ namespace ICSharpCode.SharpDevelop.Services
else else
return false; return false;
} catch (GetValueException e) { } catch (GetValueException e) {
WorkbenchSingleton.SafeThreadAsyncCall(MessageService.ShowException, e); string errorMessage = "Error while evaluating breakpoint condition " + code + ":\n" + e.Message + "\n";
DebuggerService.PrintDebugMessage(errorMessage);
WorkbenchSingleton.SafeThreadAsyncCall(MessageService.ShowWarning, errorMessage);
return true; return true;
} }
} }

19
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Views/WpfViewer.cs

@ -5,11 +5,11 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using ICSharpCode.Core;
using System; using System;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Forms.Integration; using System.Windows.Forms.Integration;
using ICSharpCode.Core.Presentation; using ICSharpCode.Core.Presentation;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
@ -50,7 +50,15 @@ namespace ICSharpCode.Profiler.AddIn.Views
/// </summary> /// </summary>
public WpfViewer(OpenedFile file) public WpfViewer(OpenedFile file)
{ {
// HACK : OpenedFile architecture does not allow to keep files open
// but it is necessary for the ProfilerView to keep the session file open.
// We don't want to load all session data into memory.
// this.Files.Add(file); // this.Files.Add(file);
// HACK : The file is not recognised by the FileService for closing if it is deleted while open.
// (reason see above comment)
FileService.FileRemoving += FileServiceFileRemoving;
this.file = file; this.file = file;
this.provider = ProfilingDataSQLiteProvider.FromFile(file.FileName); this.provider = ProfilingDataSQLiteProvider.FromFile(file.FileName);
this.TabPageText = Path.GetFileName(file.FileName); this.TabPageText = Path.GetFileName(file.FileName);
@ -58,6 +66,13 @@ namespace ICSharpCode.Profiler.AddIn.Views
dataView = new ProfilerView(this.provider); dataView = new ProfilerView(this.provider);
} }
void FileServiceFileRemoving(object sender, FileCancelEventArgs e)
{
if (FileUtility.IsEqualFileName(e.FileName, file.FileName) ||
FileUtility.IsBaseDirectory(e.FileName, file.FileName))
this.WorkbenchWindow.CloseWindow(true);
}
/// <summary> /// <summary>
/// Cleans up all used resources /// Cleans up all used resources
/// </summary> /// </summary>
@ -65,6 +80,8 @@ namespace ICSharpCode.Profiler.AddIn.Views
{ {
this.dataView.SaveUserState(); this.dataView.SaveUserState();
this.provider.Close(); this.provider.Close();
FileService.FileRemoving -= FileServiceFileRemoving;
base.Dispose(); base.Dispose();
} }
} }

4
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/Ime.cs

@ -19,8 +19,10 @@ namespace ICSharpCode.TextEditor
{ {
public Ime(IntPtr hWnd, Font font) public Ime(IntPtr hWnd, Font font)
{ {
// For unknown reasons, the IME support is causing crashes when used in a WOW64 process
// or when used in .NET 4.0. We'll disable IME support in those cases.
string PROCESSOR_ARCHITEW6432 = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"); string PROCESSOR_ARCHITEW6432 = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432");
if (PROCESSOR_ARCHITEW6432 == "IA64" || PROCESSOR_ARCHITEW6432 == "AMD64" || Environment.OSVersion.Platform == PlatformID.Unix) { if (PROCESSOR_ARCHITEW6432 == "IA64" || PROCESSOR_ARCHITEW6432 == "AMD64" || Environment.OSVersion.Platform == PlatformID.Unix || Environment.Version >= new Version(4,0)) {
disableIME = true; disableIME = true;
} else { } else {
this.hIMEWnd = ImmGetDefaultIMEWnd(hWnd); this.hIMEWnd = ImmGetDefaultIMEWnd(hWnd);

2
src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs

@ -73,7 +73,9 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
// SEMICOLON HACK : without a trailing semicolon, parsing expressions does not work correctly // SEMICOLON HACK : without a trailing semicolon, parsing expressions does not work correctly
if (la.kind == Tokens.Semicolon) lexer.NextToken(); if (la.kind == Tokens.Semicolon) lexer.NextToken();
if (expr != null) { if (expr != null) {
if (expr.StartLocation.IsEmpty)
expr.StartLocation = startLocation; expr.StartLocation = startLocation;
if (expr.EndLocation.IsEmpty)
expr.EndLocation = t.EndLocation; expr.EndLocation = t.EndLocation;
expr.AcceptVisitor(new SetParentVisitor(), null); expr.AcceptVisitor(new SetParentVisitor(), null);
} }

1222
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

40
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -1483,8 +1483,6 @@ LocalVariableDeclarator<out VariableDeclaration var>
Statement Statement
(. (.
TypeReference type;
Expression expr;
Statement stmt = null; Statement stmt = null;
Location startPos = la.Location; Location startPos = la.Location;
.) .)
@ -1495,26 +1493,10 @@ Statement
IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .) IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .)
":" Statement ":" Statement
/*--- local constant declaration: */ /*--- local constant declaration: */
| "const" Type<out type> (. LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifiers.Const); string ident = null; var.StartLocation = t.Location; .) | "const"
Identifier (. ident = t.val; Location varStart = t.Location; .) LocalVariableDecl<out stmt>
"=" Expr<out expr> (. if (stmt != null) { ((LocalVariableDeclaration)stmt).Modifier |= Modifiers.Const; } .)
(. ";" (. compilationUnit.AddChild(stmt); .)
SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr) {
StartLocation = varStart,
EndLocation = t.EndLocation,
TypeReference = type
});
.)
{ "," Identifier (. ident = t.val; .) "=" Expr<out expr>
(.
SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr) {
StartLocation = varStart,
EndLocation = t.EndLocation,
TypeReference = type
});
.) }
";" (. var.EndLocation = t.EndLocation; compilationUnit.AddChild(var); .)
/*--- local variable declaration: */ /*--- local variable declaration: */
| IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .) | IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .)
@ -1800,7 +1782,9 @@ Expr<out Expression expr>
) )
) )
(. if (expr != null) { (. if (expr != null) {
if (expr.StartLocation.IsEmpty)
expr.StartLocation = startLocation; expr.StartLocation = startLocation;
if (expr.EndLocation.IsEmpty)
expr.EndLocation = t.EndLocation; expr.EndLocation = t.EndLocation;
} }
.) .)
@ -1956,8 +1940,8 @@ PrimaryExpr<out Expression pexpr>
(. startLocation = la.Location; .) (. startLocation = la.Location; .)
( (
"++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .) "++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .)
| "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .) |
) "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .)
/*--- member access */ /*--- member access */
| PointerMemberAccess<out pexpr, pexpr> | PointerMemberAccess<out pexpr, pexpr>
| MemberAccess<out pexpr, pexpr> | MemberAccess<out pexpr, pexpr>
@ -1979,9 +1963,11 @@ PrimaryExpr<out Expression pexpr>
"[" Expr<out expr> (. SafeAdd(pexpr, indices, expr); .) "[" Expr<out expr> (. SafeAdd(pexpr, indices, expr); .)
{ "," Expr<out expr> (. SafeAdd(pexpr, indices, expr); .) { "," Expr<out expr> (. SafeAdd(pexpr, indices, expr); .)
} "]" } "]"
)
(. if (pexpr != null) { (. if (pexpr != null) {
if (pexpr.StartLocation.IsEmpty)
pexpr.StartLocation = startLocation; pexpr.StartLocation = startLocation;
if (pexpr.EndLocation.IsEmpty)
pexpr.EndLocation = t.EndLocation; pexpr.EndLocation = t.EndLocation;
} }
.) .)
@ -1998,9 +1984,9 @@ MemberAccess<out Expression expr, Expression target>
} }
} }
.) .)
"." "." (. Location startLocation = t.Location; .)
Identifier Identifier
(. expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; .) (. expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; .)
[ IF (IsGenericInSimpleNameOrMemberAccess()) [ IF (IsGenericInSimpleNameOrMemberAccess())
TypeArgumentList<out typeList, false> TypeArgumentList<out typeList, false>
(. ((MemberReferenceExpression)expr).TypeArguments = typeList; .) (. ((MemberReferenceExpression)expr).TypeArguments = typeList; .)

14
src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs

@ -103,6 +103,20 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(expr.Arguments[0] is InvocationExpression); Assert.IsTrue(expr.Arguments[0] is InvocationExpression);
CheckSimpleInvoke((InvocationExpression)expr.Arguments[0]); CheckSimpleInvoke((InvocationExpression)expr.Arguments[0]);
} }
[Test]
public void NestedInvocationPositions()
{
InvocationExpression expr = ParseUtilCSharp.ParseExpression<InvocationExpression>("a.B().C(args)");
Assert.AreEqual(new Location(8, 1), expr.StartLocation);
Assert.AreEqual(new Location(14, 1), expr.EndLocation);
MemberReferenceExpression mre = (MemberReferenceExpression)expr.TargetObject;
Assert.AreEqual(new Location(6, 1), mre.StartLocation);
Assert.AreEqual(new Location(8, 1), mre.EndLocation);
Assert.AreEqual(new Location(4, 1), mre.TargetObject.StartLocation);
Assert.AreEqual(new Location(6, 1), mre.TargetObject.EndLocation);
}
#endregion #endregion
#region VB.NET #region VB.NET

22
src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs

@ -208,6 +208,28 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("System.Nullable", type.GenericTypes[0].GenericTypes[0].Type); Assert.AreEqual("System.Nullable", type.GenericTypes[0].GenericTypes[0].Type);
Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].GenericTypes[0].Type);
} }
[Test]
public void PositionTestWithoutModifier()
{
LocalVariableDeclaration lvd = ParseUtilCSharp.ParseStatement<LocalVariableDeclaration>("\ndouble w = 7;");
Assert.AreEqual(2, lvd.StartLocation.Line);
Assert.AreEqual(1, lvd.StartLocation.Column);
Assert.AreEqual(2, lvd.EndLocation.Line);
Assert.AreEqual(14, lvd.EndLocation.Column);
}
[Test]
public void PositionTestWithModifier()
{
LocalVariableDeclaration lvd = ParseUtilCSharp.ParseStatement<LocalVariableDeclaration>("\nconst double w = 7;");
Assert.AreEqual(Modifiers.Const, lvd.Modifier);
Assert.AreEqual(2, lvd.StartLocation.Line);
Assert.AreEqual(1, lvd.StartLocation.Column);
Assert.AreEqual(2, lvd.EndLocation.Line);
Assert.AreEqual(20, lvd.EndLocation.Column);
}
#endregion #endregion
#region VB.NET #region VB.NET

12
src/Main/Base/Project/Src/Services/HelpProvider.cs

@ -21,6 +21,8 @@ namespace ICSharpCode.SharpDevelop
public static void ShowHelp(IClass c) public static void ShowHelp(IClass c)
{ {
if (c == null)
throw new ArgumentNullException("c");
foreach (HelpProvider p in GetProviders()) { foreach (HelpProvider p in GetProviders()) {
if (p.TryShowHelp(c)) if (p.TryShowHelp(c))
return; return;
@ -35,6 +37,8 @@ namespace ICSharpCode.SharpDevelop
public static void ShowHelp(IMember m) public static void ShowHelp(IMember m)
{ {
if (m == null)
throw new ArgumentNullException("m");
foreach (HelpProvider p in GetProviders()) { foreach (HelpProvider p in GetProviders()) {
if (p.TryShowHelp(m)) if (p.TryShowHelp(m))
return; return;
@ -44,11 +48,17 @@ namespace ICSharpCode.SharpDevelop
public virtual bool TryShowHelp(IMember m) public virtual bool TryShowHelp(IMember m)
{ {
IMethod method = m as IMethod;
if (method != null && method.IsConstructor)
return TryShowHelp(m.DeclaringType.FullyQualifiedName + "." + m.DeclaringType.Name);
else
return TryShowHelp(m.FullyQualifiedName); return TryShowHelp(m.FullyQualifiedName);
} }
public static void ShowHelp(string fullTypeName) public static void ShowHelp(string fullTypeName)
{ {
if (fullTypeName == null)
throw new ArgumentNullException("fullTypeName");
foreach (HelpProvider p in GetProviders()) { foreach (HelpProvider p in GetProviders()) {
if (p.TryShowHelp(fullTypeName)) if (p.TryShowHelp(fullTypeName))
return; return;
@ -64,6 +74,8 @@ namespace ICSharpCode.SharpDevelop
public static void ShowHelpByKeyword(string keyword) public static void ShowHelpByKeyword(string keyword)
{ {
if (keyword == null)
throw new ArgumentNullException("keyword");
foreach (HelpProvider p in GetProviders()) { foreach (HelpProvider p in GetProviders()) {
if (p.TryShowHelpByKeyword(keyword)) if (p.TryShowHelpByKeyword(keyword))
return; return;

40
src/Main/Base/Test/NRefactoryResolverTests.cs

@ -2806,5 +2806,45 @@ class B
var completionData = rr.GetCompletionData(mrr.ResolvedMember.DeclaringType.ProjectContent); var completionData = rr.GetCompletionData(mrr.ResolvedMember.DeclaringType.ProjectContent);
Assert.IsTrue(completionData.OfType<IField>().Any(f => f.FullyQualifiedName == "B.x")); Assert.IsTrue(completionData.OfType<IField>().Any(f => f.FullyQualifiedName == "B.x"));
} }
[Test]
public void OverrideOnlyMethod()
{
// "override"s without corresponding "virtual"s can occur in code generated
// by the COM importer
string program = @"using System;
class Test {
void Test(A instance) {
}
}
class A {
public override void M1();
}";
var lrr = Resolve<LocalResolveResult>(program, "instance", 4);
Assert.AreEqual("instance", lrr.Field.Name);
var completionData = lrr.GetCompletionData(lrr.CallingClass.ProjectContent);
Assert.IsTrue(completionData.OfType<IMethod>().Any(m => m.FullyQualifiedName == "A.M1"));
}
[Test]
public void OverrideOnlyProperty()
{
// "override"s without corresponding "virtual"s can occur in code generated
// by the COM importer
string program = @"using System;
class Test {
void Test(A instance) {
}
}
class A {
public override int P1 { get; set; }
}";
var lrr = Resolve<LocalResolveResult>(program, "instance", 4);
Assert.AreEqual("instance", lrr.Field.Name);
var completionData = lrr.GetCompletionData(lrr.CallingClass.ProjectContent);
Assert.IsTrue(completionData.OfType<IProperty>().Any(m => m.FullyQualifiedName == "A.P1"));
}
} }
} }

53
src/Main/Base/Test/ReflectionLayerTests.cs

@ -255,6 +255,59 @@ namespace ICSharpCode.SharpDevelop.Tests
Assert.AreSame(valueCollection, valueProperty.ReturnType.GetUnderlyingClass()); Assert.AreSame(valueCollection, valueProperty.ReturnType.GetUnderlyingClass());
} }
[Test]
public void ValueCollectionCountModifiers()
{
IClass valueCollection = mscorlib.GetClass("System.Collections.Generic.Dictionary.ValueCollection", 2);
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Sealed, valueCollection.Modifiers);
IProperty count = valueCollection.Properties.Single(p => p.Name == "Count");
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Sealed, count.Modifiers);
}
[Test]
public void MathAcosModifiers()
{
IClass math = mscorlib.GetClass("System.Math", 0);
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Abstract | ModifierEnum.Sealed | ModifierEnum.Static, math.Modifiers);
IMethod acos = math.Methods.Single(p => p.Name == "Acos");
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Static, acos.Modifiers);
}
[Test]
public void EncodingModifiers()
{
IClass encoding = mscorlib.GetClass("System.Text.Encoding", 0);
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Abstract, encoding.Modifiers);
IMethod getDecoder = encoding.Methods.Single(p => p.Name == "GetDecoder");
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Virtual, getDecoder.Modifiers);
IMethod getMaxByteCount = encoding.Methods.Single(p => p.Name == "GetMaxByteCount");
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Abstract, getMaxByteCount.Modifiers);
IProperty encoderFallback = encoding.Properties.Single(p => p.Name == "EncoderFallback");
Assert.AreEqual(ModifierEnum.Public, encoderFallback.Modifiers);
}
[Test]
public void UnicodeEncodingModifiers()
{
IClass encoding = mscorlib.GetClass("System.Text.UnicodeEncoding", 0);
Assert.AreEqual(ModifierEnum.Public, encoding.Modifiers);
IMethod getDecoder = encoding.Methods.Single(p => p.Name == "GetDecoder");
// Should be override, but actually is 'virtual'. We cannot do better because 'override' is not encoded in the metadata
// (the .override directive is unrelated; it's meant for explicit interface implementations)
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Virtual, getDecoder.Modifiers);
}
[Test]
public void UTF32EncodingModifiers()
{
IClass encoding = mscorlib.GetClass("System.Text.UTF32Encoding", 0);
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Sealed, encoding.Modifiers);
IMethod getDecoder = encoding.Methods.Single(p => p.Name == "GetDecoder");
// Should be override, but actually is 'virtual'. We cannot do better because 'override' is not encoded in the metadata
// (the .override directive is unrelated; it's meant for explicit interface implementations)
Assert.AreEqual(ModifierEnum.Public | ModifierEnum.Virtual, getDecoder.Modifiers);
}
public class TestClass<A, B> where A : B { public class TestClass<A, B> where A : B {
public void TestMethod<K, V>(string param) where V: K where K: IComparable {} public void TestMethod<K, V>(string param) where V: K where K: IComparable {}

158
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/CSharpAmbience.cs

@ -144,27 +144,7 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
} }
} }
if (IncludeHtmlMarkup) { AppendClassNameWithTypeParameters(builder, c, UseFullyQualifiedMemberNames, true, null);
builder.Append("<b>");
}
if (UseFullyQualifiedMemberNames) {
builder.Append(c.FullyQualifiedName);
} else {
builder.Append(c.Name);
}
if (IncludeHtmlMarkup) {
builder.Append("</b>");
}
if (ShowTypeParameterList && c.TypeParameters.Count > 0) {
builder.Append('<');
for (int i = 0; i < c.TypeParameters.Count; ++i) {
if (i > 0) builder.Append(", ");
builder.Append(ConvertTypeParameter(c.TypeParameters[i]));
}
builder.Append('>');
}
if (ShowParameterList && c.ClassType == ClassType.Delegate) { if (ShowParameterList && c.ClassType == ClassType.Delegate) {
builder.Append(" ("); builder.Append(" (");
@ -203,6 +183,42 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
return builder.ToString(); return builder.ToString();
} }
void AppendClassNameWithTypeParameters(StringBuilder builder, IClass c, bool fullyQualified, bool isConvertingClassName, IList<IReturnType> typeArguments)
{
if (isConvertingClassName && IncludeHtmlMarkup) {
builder.Append("<b>");
}
if (fullyQualified) {
if (c.DeclaringType != null) {
AppendClassNameWithTypeParameters(builder, c.DeclaringType, fullyQualified, false, typeArguments);
builder.Append('.');
builder.Append(c.Name);
} else {
builder.Append(c.FullyQualifiedName);
}
} else {
builder.Append(c.Name);
}
if (isConvertingClassName && IncludeHtmlMarkup) {
builder.Append("</b>");
}
// skip type parameters that belong to declaring types (in DOM, inner classes repeat type parameters from outer classes)
int skippedTypeParameterCount = c.DeclaringType != null ? c.DeclaringType.TypeParameters.Count : 0;
// show type parameters for classes only if ShowTypeParameterList is set; but always show them in other cases.
if ((ShowTypeParameterList || !isConvertingClassName) && c.TypeParameters.Count > skippedTypeParameterCount) {
builder.Append('<');
for (int i = skippedTypeParameterCount; i < c.TypeParameters.Count; ++i) {
if (i > skippedTypeParameterCount)
builder.Append(", ");
if (typeArguments != null && i < typeArguments.Count)
AppendReturnType(builder, typeArguments[i], false);
else
builder.Append(ConvertTypeParameter(c.TypeParameters[i]));
}
builder.Append('>');
}
}
public override string ConvertEnd(IClass c) public override string ConvertEnd(IClass c)
{ {
return "}"; return "}";
@ -247,15 +263,13 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
builder.Append(' '); builder.Append(' ');
} }
AppendTypeNameForFullyQualifiedMemberName(builder, field.DeclaringTypeReference);
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("<b>"); builder.Append("<b>");
} }
if (UseFullyQualifiedMemberNames) {
builder.Append(field.FullyQualifiedName);
} else {
builder.Append(field.Name); builder.Append(field.Name);
}
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</b>"); builder.Append("</b>");
@ -283,21 +297,15 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
builder.Append(' '); builder.Append(' ');
} }
AppendTypeNameForFullyQualifiedMemberName(builder, property.DeclaringTypeReference);
if (property.IsIndexer) { if (property.IsIndexer) {
if (property.DeclaringType != null && UseFullyQualifiedMemberNames) {
builder.Append(property.DeclaringType.FullyQualifiedName);
builder.Append('.');
}
builder.Append("this"); builder.Append("this");
} else { } else {
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("<b>"); builder.Append("<b>");
} }
if (UseFullyQualifiedMemberNames) {
builder.Append(property.FullyQualifiedName);
} else {
builder.Append(property.Name); builder.Append(property.Name);
}
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</b>"); builder.Append("</b>");
} }
@ -356,15 +364,13 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
builder.Append(' '); builder.Append(' ');
} }
AppendTypeNameForFullyQualifiedMemberName(builder, e.DeclaringTypeReference);
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("<b>"); builder.Append("<b>");
} }
if (UseFullyQualifiedMemberNames) {
builder.Append(e.FullyQualifiedName);
} else {
builder.Append(e.Name); builder.Append(e.Name);
}
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</b>"); builder.Append("</b>");
@ -391,23 +397,17 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
builder.Append(' '); builder.Append(' ');
} }
AppendTypeNameForFullyQualifiedMemberName(builder, m.DeclaringTypeReference);
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("<b>"); builder.Append("<b>");
} }
if (m.IsConstructor) { if (m.IsConstructor && m.DeclaringType != null) {
if (m.DeclaringType != null) {
builder.Append(m.DeclaringType.Name); builder.Append(m.DeclaringType.Name);
} else { } else {
builder.Append(m.Name); builder.Append(m.Name);
} }
} else {
if (UseFullyQualifiedMemberNames) {
builder.Append(m.FullyQualifiedName);
} else {
builder.Append(m.Name);
}
}
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</b>"); builder.Append("</b>");
@ -454,6 +454,14 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
return builder.ToString(); return builder.ToString();
} }
void AppendTypeNameForFullyQualifiedMemberName(StringBuilder builder, IReturnType declaringType)
{
if (UseFullyQualifiedMemberNames && declaringType != null) {
AppendReturnType(builder, declaringType, true);
builder.Append('.');
}
}
string ConvertTypeParameter(ITypeParameter tp) string ConvertTypeParameter(ITypeParameter tp)
{ {
if (tp.BoundTo != null) if (tp.BoundTo != null)
@ -479,24 +487,61 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
AppendReturnType(builder, returnType, false);
return builder.ToString();
}
void AppendReturnType(StringBuilder builder, IReturnType returnType, bool forceFullyQualifiedName)
{
IReturnType arrayReturnType = returnType;
returnType = GetElementType(returnType);
if (returnType == null)
return;
string fullName = returnType.FullyQualifiedName; string fullName = returnType.FullyQualifiedName;
string shortName; string shortName;
if (fullName != null && TypeConversionTable.TryGetValue(fullName, out shortName)) { bool isConstructedType = returnType.IsConstructedReturnType;
if (fullName != null && !isConstructedType && TypeConversionTable.TryGetValue(fullName, out shortName)) {
builder.Append(shortName); builder.Append(shortName);
} else { } else {
if (UseFullyQualifiedTypeNames) { IClass c = returnType.GetUnderlyingClass();
if (c != null) {
IList<IReturnType> ta = isConstructedType ? returnType.CastToConstructedReturnType().TypeArguments : null;
AppendClassNameWithTypeParameters(builder, c, forceFullyQualifiedName || UseFullyQualifiedTypeNames, false, ta);
} else {
if (UseFullyQualifiedTypeNames || forceFullyQualifiedName) {
builder.Append(fullName); builder.Append(fullName);
} else { } else {
builder.Append(returnType.Name); builder.Append(returnType.Name);
} }
if (isConstructedType) {
builder.Append('<');
IList<IReturnType> ta = returnType.CastToConstructedReturnType().TypeArguments;
for (int i = 0; i < ta.Count; ++i) {
if (i > 0) builder.Append(", ");
AppendReturnType(builder, ta[i], false);
}
builder.Append('>');
}
}
} }
UnpackNestedType(builder, returnType); UnpackArrayType(builder, arrayReturnType);
}
return builder.ToString(); static IReturnType GetElementType(IReturnType potentialArrayType)
{
ArrayReturnType result;
while ((result = potentialArrayType.CastToArrayReturnType()) != null) {
potentialArrayType = result.ArrayElementType;
}
return potentialArrayType;
} }
void UnpackNestedType(StringBuilder builder, IReturnType returnType) static void UnpackArrayType(StringBuilder builder, IReturnType returnType)
{ {
if (returnType.IsArrayReturnType) { if (returnType.IsArrayReturnType) {
builder.Append('['); builder.Append('[');
@ -505,16 +550,7 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
builder.Append(','); builder.Append(',');
} }
builder.Append(']'); builder.Append(']');
UnpackNestedType(builder, returnType.CastToArrayReturnType().ArrayElementType); UnpackArrayType(builder, returnType.CastToArrayReturnType().ArrayElementType);
} else if (returnType.IsConstructedReturnType) {
UnpackNestedType(builder, returnType.CastToConstructedReturnType().UnboundType);
builder.Append('<');
IList<IReturnType> ta = returnType.CastToConstructedReturnType().TypeArguments;
for (int i = 0; i < ta.Count; ++i) {
if (i > 0) builder.Append(", ");
builder.Append(Convert(ta[i]));
}
builder.Append('>');
} }
} }

11
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs

@ -458,20 +458,19 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
ModifierEnum m = ModifierEnum.None; ModifierEnum m = ModifierEnum.None;
if (method.IsStatic) if (method.IsStatic) {
m |= ModifierEnum.Static; m |= ModifierEnum.Static;
} else {
if (method.IsAbstract) { if (method.IsAbstract) {
m |= ModifierEnum.Abstract; m |= ModifierEnum.Abstract;
} else if (method.Overrides.Count > 0) { } else if (method.IsFinal) {
if (method.IsFinal) {
m |= ModifierEnum.Sealed; m |= ModifierEnum.Sealed;
} else { } else if (method.Overrides.Count > 0) {
m |= ModifierEnum.Override; m |= ModifierEnum.Override;
}
} else if (method.IsVirtual) { } else if (method.IsVirtual) {
m |= ModifierEnum.Virtual; m |= ModifierEnum.Virtual;
} }
}
if ((method.Attributes & MethodAttributes.Public) == MethodAttributes.Public) if ((method.Attributes & MethodAttributes.Public) == MethodAttributes.Public)
m |= ModifierEnum.Public; m |= ModifierEnum.Public;

13
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs

@ -183,6 +183,19 @@ namespace ICSharpCode.SharpDevelop.Dom
results = new List<IMember>(); results = new List<IMember>();
} }
} }
// Sometimes there might be 'override's without corresponding 'virtual's.
// Ensure those get found, too.
if (nonMethodOverride != null && allResults.Count == 0) {
results.Add(nonMethodOverride);
}
foreach (IMethod method in overrideMethodDict.Values) {
if (handledMethods.Add(method)) {
results.Add(method);
}
}
if (results.Count > 0) {
allResults.Add(results);
}
return allResults; return allResults;
} }

42
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryASTConvertVisitor.cs

@ -377,10 +377,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
ConvertAttributes(typeDeclaration, c); ConvertAttributes(typeDeclaration, c);
c.Documentation = GetDocumentation(region.BeginLine, typeDeclaration.Attributes); c.Documentation = GetDocumentation(region.BeginLine, typeDeclaration.Attributes);
if (currentClass.Count > 0) { DefaultClass outerClass = GetCurrentClass();
DefaultClass cur = GetCurrentClass(); if (outerClass != null) {
cur.InnerClasses.Add(c); outerClass.InnerClasses.Add(c);
c.FullyQualifiedName = cur.FullyQualifiedName + '.' + typeDeclaration.Name; c.FullyQualifiedName = outerClass.FullyQualifiedName + '.' + typeDeclaration.Name;
} else { } else {
c.FullyQualifiedName = PrependCurrentNamespace(typeDeclaration.Name); c.FullyQualifiedName = PrependCurrentNamespace(typeDeclaration.Name);
cu.Classes.Add(c); cu.Classes.Add(c);
@ -388,7 +388,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
c.UsingScope = currentNamespace; c.UsingScope = currentNamespace;
currentClass.Push(c); currentClass.Push(c);
ConvertTemplates(typeDeclaration.Templates, c); // resolve constrains in context of the class ConvertTemplates(outerClass, typeDeclaration.Templates, c); // resolve constrains in context of the class
// templates must be converted before base types because base types may refer to generic types // templates must be converted before base types because base types may refer to generic types
if (c.ClassType != ClassType.Enum && typeDeclaration.BaseTypes != null) { if (c.ClassType != ClassType.Enum && typeDeclaration.BaseTypes != null) {
@ -421,19 +421,33 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
return ret; return ret;
} }
void ConvertTemplates(IList<AST.TemplateDefinition> templateList, DefaultClass c) void ConvertTemplates(DefaultClass outerClass, IList<AST.TemplateDefinition> templateList, DefaultClass c)
{ {
int index = 0; int outerClassTypeParameterCount = outerClass != null ? outerClass.TypeParameters.Count : 0;
if (templateList.Count == 0) { if (templateList.Count == 0 && outerClassTypeParameterCount == 0) {
c.TypeParameters = DefaultTypeParameter.EmptyTypeParameterList; c.TypeParameters = DefaultTypeParameter.EmptyTypeParameterList;
} else { } else {
Debug.Assert(c.TypeParameters.Count == 0); Debug.Assert(c.TypeParameters.Count == 0);
int index = 0;
if (outerClassTypeParameterCount > 0) {
foreach (DefaultTypeParameter outerTypeParamter in outerClass.TypeParameters) {
DefaultTypeParameter p = new DefaultTypeParameter(c, outerTypeParamter.Name, index++);
p.HasConstructableConstraint = outerTypeParamter.HasConstructableConstraint;
p.HasReferenceTypeConstraint = outerTypeParamter.HasReferenceTypeConstraint;
p.HasValueTypeConstraint = outerTypeParamter.HasValueTypeConstraint;
p.Attributes.AddRange(outerTypeParamter.Attributes);
p.Constraints.AddRange(outerTypeParamter.Constraints);
c.TypeParameters.Add(p);
}
}
foreach (AST.TemplateDefinition template in templateList) { foreach (AST.TemplateDefinition template in templateList) {
c.TypeParameters.Add(new DefaultTypeParameter(c, template.Name, index++)); c.TypeParameters.Add(new DefaultTypeParameter(c, template.Name, index++));
} }
// converting the constraints requires that the type parameters are already present // converting the constraints requires that the type parameters are already present
for (int i = 0; i < templateList.Count; i++) { for (int i = 0; i < templateList.Count; i++) {
ConvertConstraints(templateList[i], (DefaultTypeParameter)c.TypeParameters[i]); ConvertConstraints(templateList[i], (DefaultTypeParameter)c.TypeParameters[i + outerClassTypeParameterCount]);
} }
} }
} }
@ -487,17 +501,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
void CreateDelegate(DefaultClass c, string name, AST.TypeReference returnType, IList<AST.TemplateDefinition> templates, IList<AST.ParameterDeclarationExpression> parameters) void CreateDelegate(DefaultClass c, string name, AST.TypeReference returnType, IList<AST.TemplateDefinition> templates, IList<AST.ParameterDeclarationExpression> parameters)
{ {
c.BaseTypes.Add(c.ProjectContent.SystemTypes.MulticastDelegate); c.BaseTypes.Add(c.ProjectContent.SystemTypes.MulticastDelegate);
if (currentClass.Count > 0) { DefaultClass outerClass = GetCurrentClass();
DefaultClass cur = GetCurrentClass(); if (outerClass != null) {
cur.InnerClasses.Add(c); outerClass.InnerClasses.Add(c);
c.FullyQualifiedName = cur.FullyQualifiedName + '.' + name; c.FullyQualifiedName = outerClass.FullyQualifiedName + '.' + name;
} else { } else {
c.FullyQualifiedName = PrependCurrentNamespace(name); c.FullyQualifiedName = PrependCurrentNamespace(name);
cu.Classes.Add(c); cu.Classes.Add(c);
} }
c.UsingScope = currentNamespace; c.UsingScope = currentNamespace;
currentClass.Push(c); // necessary for CreateReturnType currentClass.Push(c); // necessary for CreateReturnType
ConvertTemplates(templates, c); ConvertTemplates(outerClass, templates, c);
List<IParameter> p = new List<IParameter>(); List<IParameter> p = new List<IParameter>();
if (parameters != null) { if (parameters != null) {

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/DomPersistence.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
public const long FileMagic = 0x11635233ED2F428C; public const long FileMagic = 0x11635233ED2F428C;
public const long IndexFileMagic = 0x11635233ED2F427D; public const long IndexFileMagic = 0x11635233ED2F427D;
public const short FileVersion = 23; public const short FileVersion = 24;
ProjectContentRegistry registry; ProjectContentRegistry registry;
string cacheDirectory; string cacheDirectory;

8
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionEvent.cs

@ -47,6 +47,14 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer
} else { } else {
modifiers |= ModifierEnum.Internal; modifiers |= ModifierEnum.Internal;
} }
if (methodBase.IsFinal) {
modifiers |= ModifierEnum.Sealed;
} else if (methodBase.IsAbstract) {
modifiers |= ModifierEnum.Abstract;
} else if (methodBase.IsVirtual) {
modifiers |= ModifierEnum.Virtual;
}
} else { } else {
// assume public property, if no methodBase could be get. // assume public property, if no methodBase could be get.
modifiers = ModifierEnum.Public; modifiers = ModifierEnum.Public;

11
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionMethod.cs

@ -63,15 +63,14 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer
modifiers |= ModifierEnum.Internal; modifiers |= ModifierEnum.Internal;
} }
if (methodBase.IsVirtual) {
modifiers |= ModifierEnum.Virtual;
}
if (methodBase.IsAbstract) {
modifiers |= ModifierEnum.Abstract;
}
if (methodBase.IsFinal) { if (methodBase.IsFinal) {
modifiers |= ModifierEnum.Sealed; modifiers |= ModifierEnum.Sealed;
} else if (methodBase.IsAbstract) {
modifiers |= ModifierEnum.Abstract;
} else if (methodBase.IsVirtual) {
modifiers |= ModifierEnum.Virtual;
} }
this.Modifiers = modifiers; this.Modifiers = modifiers;
ReflectionClass.AddAttributes(declaringType.ProjectContent, this.Attributes, CustomAttributeData.GetCustomAttributes(methodBase)); ReflectionClass.AddAttributes(declaringType.ProjectContent, this.Attributes, CustomAttributeData.GetCustomAttributes(methodBase));

10
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionProperty.cs

@ -66,14 +66,12 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer
modifiers |= ModifierEnum.Internal; modifiers |= ModifierEnum.Internal;
} }
if (methodBase.IsVirtual) {
modifiers |= ModifierEnum.Virtual;
}
if (methodBase.IsAbstract) {
modifiers |= ModifierEnum.Abstract;
}
if (methodBase.IsFinal) { if (methodBase.IsFinal) {
modifiers |= ModifierEnum.Sealed; modifiers |= ModifierEnum.Sealed;
} else if (methodBase.IsAbstract) {
modifiers |= ModifierEnum.Abstract;
} else if (methodBase.IsVirtual) {
modifiers |= ModifierEnum.Virtual;
} }
} else { // assume public property, if no methodBase could be get. } else { // assume public property, if no methodBase could be get.
modifiers = ModifierEnum.Public; modifiers = ModifierEnum.Public;

152
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/VBNetAmbience.cs

@ -133,28 +133,7 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
builder.Append(' '); builder.Append(' ');
} }
if (IncludeHtmlMarkup) { AppendClassNameWithTypeParameters(builder, c, UseFullyQualifiedMemberNames, true, null);
builder.Append("<b>");
}
if (UseFullyQualifiedMemberNames) {
builder.Append(c.FullyQualifiedName);
} else {
builder.Append(c.Name);
}
if (IncludeHtmlMarkup) {
builder.Append("</b>");
}
if (ShowTypeParameterList && c.TypeParameters.Count > 0) {
builder.Append("(Of ");
for (int i = 0; i < c.TypeParameters.Count; ++i) {
if (i > 0) builder.Append(", ");
builder.Append(ConvertTypeParameter(c.TypeParameters[i]));
}
builder.Append(')');
}
if (ShowParameterList && c.ClassType == ClassType.Delegate) { if (ShowParameterList && c.ClassType == ClassType.Delegate) {
builder.Append("("); builder.Append("(");
@ -202,6 +181,50 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
return builder.ToString(); return builder.ToString();
} }
void AppendTypeNameForFullyQualifiedMemberName(StringBuilder builder, IReturnType declaringType)
{
if (UseFullyQualifiedMemberNames && declaringType != null) {
AppendReturnType(builder, declaringType, true);
builder.Append('.');
}
}
void AppendClassNameWithTypeParameters(StringBuilder builder, IClass c, bool fullyQualified, bool isConvertingClassName, IList<IReturnType> typeArguments)
{
if (isConvertingClassName && IncludeHtmlMarkup) {
builder.Append("<b>");
}
if (fullyQualified) {
if (c.DeclaringType != null) {
AppendClassNameWithTypeParameters(builder, c.DeclaringType, fullyQualified, false, typeArguments);
builder.Append('.');
builder.Append(c.Name);
} else {
builder.Append(c.FullyQualifiedName);
}
} else {
builder.Append(c.Name);
}
if (isConvertingClassName && IncludeHtmlMarkup) {
builder.Append("</b>");
}
// skip type parameters that belong to declaring types (in DOM, inner classes repeat type parameters from outer classes)
int skippedTypeParameterCount = c.DeclaringType != null ? c.DeclaringType.TypeParameters.Count : 0;
// show type parameters for classes only if ShowTypeParameterList is set; but always show them in other cases.
if ((ShowTypeParameterList || !isConvertingClassName) && c.TypeParameters.Count > skippedTypeParameterCount) {
builder.Append("(Of ");
for (int i = skippedTypeParameterCount; i < c.TypeParameters.Count; ++i) {
if (i > skippedTypeParameterCount)
builder.Append(", ");
if (typeArguments != null && i < typeArguments.Count)
AppendReturnType(builder, typeArguments[i], false);
else
builder.Append(ConvertTypeParameter(c.TypeParameters[i]));
}
builder.Append(')');
}
}
public override string ConvertEnd(IClass c) public override string ConvertEnd(IClass c)
{ {
if (c == null) if (c == null)
@ -260,14 +283,15 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</i>"); builder.Append("</i>");
}
AppendTypeNameForFullyQualifiedMemberName(builder, field.DeclaringTypeReference);
if (IncludeHtmlMarkup) {
builder.Append("<b>"); builder.Append("<b>");
} }
if (UseFullyQualifiedMemberNames) {
builder.Append(field.FullyQualifiedName);
} else {
builder.Append(field.Name); builder.Append(field.Name);
}
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</b>"); builder.Append("</b>");
@ -308,15 +332,12 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
builder.Append("Property "); builder.Append("Property ");
} }
AppendTypeNameForFullyQualifiedMemberName(builder, property.DeclaringTypeReference);
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("<b>"); builder.Append("<b>");
} }
if (UseFullyQualifiedMemberNames) {
builder.Append(property.FullyQualifiedName);
} else {
builder.Append(property.Name); builder.Append(property.Name);
}
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</b>"); builder.Append("</b>");
@ -365,15 +386,13 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
builder.Append("Event "); builder.Append("Event ");
} }
AppendTypeNameForFullyQualifiedMemberName(builder, e.DeclaringTypeReference);
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("<b>"); builder.Append("<b>");
} }
if (UseFullyQualifiedMemberNames) {
builder.Append(e.FullyQualifiedName);
} else {
builder.Append(e.Name); builder.Append(e.Name);
}
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</b>"); builder.Append("</b>");
@ -409,16 +428,13 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
} }
} }
string dispName = UseFullyQualifiedMemberNames ? m.FullyQualifiedName : m.Name; AppendTypeNameForFullyQualifiedMemberName(builder, m.DeclaringTypeReference);
if (m.IsConstructor) {
dispName = "New";
}
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("<b>"); builder.Append("<b>");
} }
builder.Append(dispName); builder.Append(m.IsConstructor ? "New" : m.Name);
if (IncludeHtmlMarkup) { if (IncludeHtmlMarkup) {
builder.Append("</b>"); builder.Append("</b>");
@ -489,24 +505,61 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
AppendReturnType(builder, returnType, false);
return builder.ToString();
}
void AppendReturnType(StringBuilder builder, IReturnType returnType, bool forceFullyQualifiedName)
{
IReturnType arrayReturnType = returnType;
returnType = GetElementType(returnType);
if (returnType == null)
return;
string fullName = returnType.FullyQualifiedName; string fullName = returnType.FullyQualifiedName;
string shortName; string shortName;
if (fullName != null && TypeConversionTable.TryGetValue(fullName, out shortName)) { bool isConstructedType = returnType.IsConstructedReturnType;
if (fullName != null && !isConstructedType && TypeConversionTable.TryGetValue(fullName, out shortName)) {
builder.Append(shortName); builder.Append(shortName);
} else { } else {
if (UseFullyQualifiedTypeNames) { IClass c = returnType.GetUnderlyingClass();
if (c != null) {
IList<IReturnType> ta = isConstructedType ? returnType.CastToConstructedReturnType().TypeArguments : null;
AppendClassNameWithTypeParameters(builder, c, forceFullyQualifiedName || UseFullyQualifiedTypeNames, false, ta);
} else {
if (UseFullyQualifiedTypeNames || forceFullyQualifiedName) {
builder.Append(fullName); builder.Append(fullName);
} else { } else {
builder.Append(returnType.Name); builder.Append(returnType.Name);
} }
if (isConstructedType) {
builder.Append("(Of ");
IList<IReturnType> ta = returnType.CastToConstructedReturnType().TypeArguments;
for (int i = 0; i < ta.Count; ++i) {
if (i > 0) builder.Append(", ");
AppendReturnType(builder, ta[i], false);
}
builder.Append(')');
}
}
} }
UnpackNestedType(builder, returnType); UnpackArrayType(builder, arrayReturnType);
}
return builder.ToString(); static IReturnType GetElementType(IReturnType potentialArrayType)
{
ArrayReturnType result;
while ((result = potentialArrayType.CastToArrayReturnType()) != null) {
potentialArrayType = result.ArrayElementType;
}
return potentialArrayType;
} }
void UnpackNestedType(StringBuilder builder, IReturnType returnType) static void UnpackArrayType(StringBuilder builder, IReturnType returnType)
{ {
if (returnType.IsArrayReturnType) { if (returnType.IsArrayReturnType) {
builder.Append('('); builder.Append('(');
@ -515,16 +568,7 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
builder.Append(','); builder.Append(',');
} }
builder.Append(')'); builder.Append(')');
UnpackNestedType(builder, returnType.CastToArrayReturnType().ArrayElementType); UnpackArrayType(builder, returnType.CastToArrayReturnType().ArrayElementType);
} else if (returnType.IsConstructedReturnType) {
UnpackNestedType(builder, returnType.CastToConstructedReturnType().UnboundType);
builder.Append("(Of ");
IList<IReturnType> ta = returnType.CastToConstructedReturnType().TypeArguments;
for (int i = 0; i < ta.Count; ++i) {
if (i > 0) builder.Append(", ");
builder.Append(Convert(ta[i]));
}
builder.Append(')');
} }
} }

52
src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/CSharpAmbienceTests.cs

@ -0,0 +1,52 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Dom.CSharp;
using System;
using System.Linq;
using NUnit.Framework;
namespace ICSharpCode.SharpDevelop.Dom.Tests
{
[TestFixture]
public class CSharpAmbienceTests
{
CSharpAmbience fullMemberNameAmbience;
IClass valueCollection;
[TestFixtureSetUpAttribute]
public void FixtureSetUp()
{
valueCollection = SharedProjectContentRegistryForTests.Instance.Mscorlib.GetClass("System.Collections.Generic.Dictionary.ValueCollection", 2);
Assert.AreEqual(2, valueCollection.TypeParameters.Count);
Assert.AreEqual(2, valueCollection.DeclaringType.TypeParameters.Count);
fullMemberNameAmbience = new CSharpAmbience();
fullMemberNameAmbience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.UseFullyQualifiedMemberNames;
}
[TestAttribute]
public void TestFullClassNameOfClassInsideGenericClass()
{
Assert.AreEqual("public sealed class System.Collections.Generic.Dictionary<TKey, TValue>.ValueCollection", fullMemberNameAmbience.Convert(valueCollection));
}
[TestAttribute]
public void TestFullNameOfValueCollectionCountProperty()
{
IProperty count = valueCollection.Properties.Single(p => p.Name == "Count");
Assert.AreEqual("public sealed int System.Collections.Generic.Dictionary<TKey, TValue>.ValueCollection.Count", fullMemberNameAmbience.Convert(count));
}
[TestAttribute]
public void TestFullNameOfValueCollectionCopyToMethod()
{
IMethod copyTo = valueCollection.Methods.Single(m => m.Name == "CopyTo");
Assert.AreEqual("public sealed void System.Collections.Generic.Dictionary<TKey, TValue>.ValueCollection.CopyTo(TValue[] array, int index)", fullMemberNameAmbience.Convert(copyTo));
}
}
}

12
src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/CodeSnippetConverterTests.cs

@ -12,6 +12,13 @@ using NUnit.Framework;
namespace ICSharpCode.SharpDevelop.Dom.Tests namespace ICSharpCode.SharpDevelop.Dom.Tests
{ {
static class SharedProjectContentRegistryForTests
{
public static readonly ProjectContentRegistry Instance = new ProjectContentRegistry();
static SharedProjectContentRegistryForTests() {} // delay-initialize
}
[TestFixture] [TestFixture]
public class CodeSnippetConverterTests public class CodeSnippetConverterTests
{ {
@ -21,10 +28,9 @@ namespace ICSharpCode.SharpDevelop.Dom.Tests
public CodeSnippetConverterTests() public CodeSnippetConverterTests()
{ {
ProjectContentRegistry pcr = new ProjectContentRegistry();
referencedContents = new List<IProjectContent> { referencedContents = new List<IProjectContent> {
pcr.Mscorlib, SharedProjectContentRegistryForTests.Instance.Mscorlib,
pcr.GetProjectContentForReference("System", "System") SharedProjectContentRegistryForTests.Instance.GetProjectContentForReference("System", "System")
}; };
} }

5
src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/ICSharpCode.SharpDevelop.Dom.Tests.csproj

@ -40,17 +40,22 @@
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath> <HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AssemblyInfo.cs" /> <Compile Include="AssemblyInfo.cs" />
<Compile Include="ClassInheritanceTreeTests.cs" /> <Compile Include="ClassInheritanceTreeTests.cs" />
<Compile Include="CodeSnippetConverterTests.cs" /> <Compile Include="CodeSnippetConverterTests.cs" />
<Compile Include="CSharpAmbienceTests.cs" />
<Compile Include="NRefactoryAstConverterTests.cs" /> <Compile Include="NRefactoryAstConverterTests.cs" />
<Compile Include="NRefactoryRefactoringProviderTests.cs" /> <Compile Include="NRefactoryRefactoringProviderTests.cs" />
<Compile Include="NUnitHelpers\SyntaxHelpers.cs" /> <Compile Include="NUnitHelpers\SyntaxHelpers.cs" />
<Compile Include="NUnitHelpers\Constraints.cs" /> <Compile Include="NUnitHelpers\Constraints.cs" />
<Compile Include="ProjectContentClassManagementTest.cs" /> <Compile Include="ProjectContentClassManagementTest.cs" />
<Compile Include="VBNetAmbienceTests.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj"> <ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">

37
src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/NRefactoryAstConverterTests.cs

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using System.Linq;
using System.IO; using System.IO;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
@ -16,13 +17,11 @@ namespace ICSharpCode.SharpDevelop.Dom.Tests
[TestFixture] [TestFixture]
public class NRefactoryAstConverterTests public class NRefactoryAstConverterTests
{ {
readonly ProjectContentRegistry projectContentRegistry = new ProjectContentRegistry();
ICompilationUnit Parse(string code, SupportedLanguage language, bool referenceMscorlib) ICompilationUnit Parse(string code, SupportedLanguage language, bool referenceMscorlib)
{ {
DefaultProjectContent pc = new DefaultProjectContent(); DefaultProjectContent pc = new DefaultProjectContent();
if (referenceMscorlib) { if (referenceMscorlib) {
pc.AddReferencedContent(projectContentRegistry.Mscorlib); pc.AddReferencedContent(SharedProjectContentRegistryForTests.Instance.Mscorlib);
} }
NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc); NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc);
using (IParser p = ParserFactory.CreateParser(language, new StringReader(code))) { using (IParser p = ParserFactory.CreateParser(language, new StringReader(code))) {
@ -211,5 +210,37 @@ class X {
Assert.AreEqual("Foo", p.Name); Assert.AreEqual("Foo", p.Name);
Assert.AreEqual(1, p.Parameters.Count); Assert.AreEqual(1, p.Parameters.Count);
} }
[Test]
public void GenericInnerClassTest()
{
ICompilationUnit cu = Parse(@"
using System;
class Outer<T1> where T1 : IDisposable {
class Inner<T2> where T2 : T1 {
public static void Method<T3>(T1 p1, T2 p2, T3 p3) where T3 : T2 { }
}
}
");
IClass outer = cu.Classes[0];
Assert.AreEqual(1, outer.TypeParameters.Count);
IClass inner = outer.InnerClasses[0];
Assert.AreEqual(2, inner.TypeParameters.Count);
Assert.AreEqual("T1", inner.TypeParameters[0].Name);
Assert.AreSame(inner, inner.TypeParameters[0].Class);
Assert.AreEqual("T2", inner.TypeParameters[1].Name);
Assert.AreSame(inner.TypeParameters[0], inner.TypeParameters[1].Constraints[0].CastToGenericReturnType().TypeParameter);
Assert.AreEqual("IDisposable", inner.TypeParameters[0].Constraints[0].Name);
IMethod method = inner.Methods.Single(m => m.Name == "Method");
Assert.AreEqual(1, method.TypeParameters.Count);
Assert.AreSame(inner.TypeParameters[0], method.Parameters[0].ReturnType.CastToGenericReturnType().TypeParameter);
Assert.AreSame(inner.TypeParameters[1], method.Parameters[1].ReturnType.CastToGenericReturnType().TypeParameter);
Assert.AreSame(method.TypeParameters[0], method.Parameters[2].ReturnType.CastToGenericReturnType().TypeParameter);
Assert.AreSame(inner.TypeParameters[1], method.TypeParameters[0].Constraints[0].CastToGenericReturnType().TypeParameter);
}
} }
} }

53
src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/VBNetAmbienceTests.cs

@ -0,0 +1,53 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Dom.VBNet;
using System;
using System.Linq;
using NUnit.Framework;
namespace ICSharpCode.SharpDevelop.Dom.Tests
{
[TestFixture]
public class VBNetAmbienceTests
{
VBNetAmbience fullMemberNameAmbience;
IClass valueCollection;
[TestFixtureSetUpAttribute]
public void FixtureSetUp()
{
valueCollection = SharedProjectContentRegistryForTests.Instance.Mscorlib.GetClass("System.Collections.Generic.Dictionary.ValueCollection", 2);
Assert.AreEqual(2, valueCollection.TypeParameters.Count);
Assert.AreEqual(2, valueCollection.DeclaringType.TypeParameters.Count);
fullMemberNameAmbience = new VBNetAmbience();
fullMemberNameAmbience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.UseFullyQualifiedMemberNames;
}
[TestAttribute]
public void TestFullClassNameOfClassInsideGenericClass()
{
Assert.AreEqual("Public NotInheritable Class System.Collections.Generic.Dictionary(Of TKey, TValue).ValueCollection", fullMemberNameAmbience.Convert(valueCollection));
}
[TestAttribute]
public void TestFullNameOfValueCollectionCountProperty()
{
IProperty count = valueCollection.Properties.Single(p => p.Name == "Count");
Assert.AreEqual("Public NotOverridable ReadOnly Property System.Collections.Generic.Dictionary(Of TKey, TValue).ValueCollection.Count As Integer", fullMemberNameAmbience.Convert(count));
}
[TestAttribute]
public void TestFullNameOfValueCollectionCopyToMethod()
{
IMethod copyTo = valueCollection.Methods.Single(m => m.Name == "CopyTo");
Assert.AreEqual("Public NotOverridable Sub System.Collections.Generic.Dictionary(Of TKey, TValue).ValueCollection.CopyTo(array As TValue(), index As Integer)", fullMemberNameAmbience.Convert(copyTo));
}
}
}

BIN
src/Tools/NUnit/lib/nunit-console-runner.dll

Binary file not shown.

BIN
src/Tools/NUnit/lib/nunit-gui-runner.dll

Binary file not shown.

BIN
src/Tools/NUnit/lib/nunit.core.dll

Binary file not shown.

BIN
src/Tools/NUnit/lib/nunit.core.interfaces.dll

Binary file not shown.

BIN
src/Tools/NUnit/lib/nunit.fixtures.dll

Binary file not shown.

BIN
src/Tools/NUnit/lib/nunit.uiexception.dll

Binary file not shown.

BIN
src/Tools/NUnit/lib/nunit.uikit.dll

Binary file not shown.

BIN
src/Tools/NUnit/lib/nunit.util.dll

Binary file not shown.

BIN
src/Tools/NUnit/nunit-console-dotnet2-x86.exe

Binary file not shown.

BIN
src/Tools/NUnit/nunit-console-dotnet2.exe

Binary file not shown.

BIN
src/Tools/NUnit/nunit-console-x86.exe

Binary file not shown.

BIN
src/Tools/NUnit/nunit-console.exe

Binary file not shown.

4
src/Tools/NUnit/nunit-console/AssemblyInfo.cs

@ -36,5 +36,5 @@ using System.Reflection;
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("2.5.1")] [assembly: AssemblyVersion("2.5.2")]
[assembly: AssemblyInformationalVersion("2.5.1")] [assembly: AssemblyInformationalVersion("2.5.2")]

BIN
src/Tools/NUnit/nunit.framework.dll

Binary file not shown.
Loading…
Cancel
Save