Browse Source

Merge /branches/3.0 to /trunk.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5785 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 15 years ago
parent
commit
2b0a47d089
  1. 65
      data/templates/file/CSharp/CSharp.Web.WebHandler.xft
  2. 14
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDeserializer.cs
  3. 39
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/DeserializeConstraintArrayTestFixture.cs
  4. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
  5. 6
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockComponentCreator.cs
  6. 41
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockComponentCreatorTests.cs
  7. 5
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixPackageFilesControl.cs
  8. 2
      src/AddIns/BackendBindings/WixBinding/Project/Src/IWixPackageFilesView.cs
  9. 2
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesEditor.cs
  10. 6
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/AddDirectoryTestFixture.cs
  11. 6
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoRootDirectoryFoundTestFixture.cs
  12. 6
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoRootDirectoryInWixProductFileTestFixture.cs
  13. 6
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoWixProductFileTestFixture.cs
  14. 7
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoWixSourceFileInProjectTestFixture.cs
  15. 6
      src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWixPackageFilesView.cs
  16. 6
      src/AddIns/BackendBindings/WixBinding/WixBinding.sln
  17. 2
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ProjectResourceService.cs
  18. 9
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs
  19. 4
      src/Libraries/NRefactory/Project/Src/EnvironmentInformationProvider.cs
  20. 2
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs
  21. 26
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs
  22. 18
      src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs
  23. 29
      src/Libraries/NRefactory/Project/Src/Visitors/ConvertVisitorBase.cs
  24. 85
      src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs
  25. 2
      src/Libraries/NRefactory/Project/Src/Visitors/VBNetConstructsConvertVisitor.cs
  26. 95
      src/Libraries/NRefactory/Test/Output/CSharp/VBNetToCSharpConverterTest.cs
  27. 6
      src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs
  28. 12
      src/Libraries/NRefactory/Test/Parser/Statements/CheckedStatementTests.cs
  29. 13
      src/Libraries/NRefactory/Test/Parser/Statements/UncheckedStatementTests.cs
  30. 4
      src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
  31. 2
      src/Main/Base/Project/Src/Gui/Dialogs/SolutionConfiguration/EditAvailableConfigurationsDialog.cs
  32. 5
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs
  33. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/FileNode.cs
  34. 26
      src/Main/Base/Project/Src/Services/File/FileService.cs
  35. 14
      src/Main/Base/Project/Src/TextEditor/ClipboardHandling.cs
  36. 26
      src/Main/Base/Test/CodeConverterTests.cs
  37. 11
      src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs
  38. 4
      src/Main/Core/Project/Src/Services/PropertyService/Properties.cs
  39. 74
      src/Main/Core/Test/InvalidDirectoryNameTests.cs
  40. 2
      src/Main/Core/Test/TopologicalSortTest.cs
  41. 20
      src/Main/Core/Test/ValidDirectoryNameTests.cs
  42. 16
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/CodeSnippetConverter.cs
  43. 9
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryInformationProvider.cs
  44. 5
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs
  45. 54
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/VBNetToCSharpConvertVisitor.cs
  46. 45
      src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/CodeSnippetConverterTests.cs
  47. 1
      src/Setup/Files.wxs
  48. 2
      src/Tools/NUnit/NUnit Modification.txt
  49. BIN
      src/Tools/NUnit/lib/nunit-console-runner.dll
  50. BIN
      src/Tools/NUnit/lib/nunit-gui-runner.dll
  51. BIN
      src/Tools/NUnit/lib/nunit.core.dll
  52. BIN
      src/Tools/NUnit/lib/nunit.core.interfaces.dll
  53. BIN
      src/Tools/NUnit/lib/nunit.fixtures.dll
  54. BIN
      src/Tools/NUnit/lib/nunit.uiexception.dll
  55. BIN
      src/Tools/NUnit/lib/nunit.uikit.dll
  56. BIN
      src/Tools/NUnit/lib/nunit.util.dll
  57. BIN
      src/Tools/NUnit/nunit-console-dotnet2-x86.exe
  58. BIN
      src/Tools/NUnit/nunit-console-dotnet2.exe
  59. BIN
      src/Tools/NUnit/nunit-console-x86.exe
  60. BIN
      src/Tools/NUnit/nunit-console.exe
  61. 4
      src/Tools/NUnit/nunit-console/AssemblyInfo.cs
  62. 5
      src/Tools/NUnit/nunit-console/ExtendedConsoleUi.cs
  63. BIN
      src/Tools/NUnit/nunit.framework.dll

65
data/templates/file/CSharp/CSharp.Web.WebHandler.xft

@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
<?xml version="1.0"?>
<Template author="Justin Dearing" version="1.0">
<Config
name = "${res:Templates.File.WebHandler.Name}"
icon = "C#.File.NewClass"
category = "C#"
subcategory = "ASP.NET"
defaultname = "WebHandler${Number}.ashx"
language = "C#"
/>
<Description>${res:Templates.File.WebHandler.Description}</Description>
<!--
Special new file templates:
${StandardNamespace} -> Standardnamespace of the current project or FileNameWithoutExtension
${FullName} -> Full generated path name
${FileName} -> File name with extension
${FileNameWithoutExtension} -> File name without extension
${Extension} -> Extension in the form ".cs"
${Path} -> Full path of the file
-->
<Files>
<File name="${Path}/${FileName}.cs" DependentUpon="${FileName}" language="C#"><![CDATA[${StandardHeader.C#}
using System;
using System.Web;
namespace ${StandardNamespace}
{
/// <summary>
/// Description of ${ClassName}
/// </summary>
public class ${ClassName} : IHttpHandler
{
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#region Process Request
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write(@"Hello #Develop.");
context.Response.Flush();
context.Response.Close();
}
#endregion
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
public bool IsReusable
{
get { return true; }
}
}
}
]]></File>
<File name="${FullName}" language="HTML"><![CDATA[<%@ WebHandler
Language = "C#"
Class = "${StandardNamespace}.${ClassName}"
%>
]]> </File>
</Files>
<AdditionalOptions/>
</Template>

14
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDeserializer.cs

@ -155,8 +155,7 @@ namespace ICSharpCode.PythonBinding @@ -155,8 +155,7 @@ namespace ICSharpCode.PythonBinding
object DeserializeCreateArrayExpression(CallExpression callExpression, IndexExpression target)
{
ListExpression list = callExpression.Args[0].Expression as ListExpression;
MemberExpression arrayTypeMemberExpression = target.Index as MemberExpression;
Type arrayType = componentCreator.GetType(PythonControlFieldExpression.GetMemberName(arrayTypeMemberExpression));
Type arrayType = GetType(target.Index as MemberExpression);
Array array = Array.CreateInstance(arrayType, list.Items.Count);
for (int i = 0; i < list.Items.Count; ++i) {
Expression listItemExpression = list.Items[i];
@ -172,11 +171,18 @@ namespace ICSharpCode.PythonBinding @@ -172,11 +171,18 @@ namespace ICSharpCode.PythonBinding
} else if (nameExpression != null) {
array.SetValue(componentCreator.GetInstance(nameExpression.Name), i);
} else if (listItemCallExpression != null) {
object instance = componentCreator.CreateInstance(arrayType, GetArguments(listItemCallExpression), null, false);
Type arrayInstanceType = GetType(listItemCallExpression.Target as MemberExpression);
object instance = componentCreator.CreateInstance(arrayInstanceType, GetArguments(listItemCallExpression), null, false);
array.SetValue(instance, i);
}
}
return array;
return array;
}
Type GetType(MemberExpression memberExpression)
{
string typeName = PythonControlFieldExpression.GetMemberName(memberExpression);
return componentCreator.GetType(typeName);
}
/// <summary>

39
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/DeserializeConstraintArrayTestFixture.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using IronPython.Compiler.Ast;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
[TestFixture]
public class DeserializeConstraintArrayTestFixture : DeserializeAssignmentTestFixtureBase
{
public override string GetPythonCode()
{
return "self.Items = System.Array[System.Data.Constraint](\r\n" +
" [System.Data.UniqueConstraint(\"Constraint1\", System.Array[System.String](\r\n" +
" [\"Column1\"]), False)]))";
}
[Test]
public void DeserializedObjectIsExpectedArray()
{
UniqueConstraint constraint = new UniqueConstraint("Constraint1", new string[] { "Column1" }, false);
Constraint[] expectedArray = new Constraint[] { constraint };
Assert.AreEqual(expectedArray, deserializedObject);
}
}
}

2
src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

@ -207,6 +207,7 @@ @@ -207,6 +207,7 @@
<Compile Include="Designer\DeserializeAssignmentTestFixtureBase.cs" />
<Compile Include="Designer\DeserializeColorFromArgbTestFixture.cs" />
<Compile Include="Designer\DeserializeComponentAssignmentTestFixture.cs" />
<Compile Include="Designer\DeserializeConstraintArrayTestFixture.cs" />
<Compile Include="Designer\DeserializeDateTimeArrayTestFixture.cs" />
<Compile Include="Designer\DeserializeLocalVariableTestFixture.cs" />
<Compile Include="Designer\DeserializeMethodParametersTestFixture.cs" />
@ -474,6 +475,7 @@ @@ -474,6 +475,7 @@
<Compile Include="Utils\PythonCompletionItemsHelper.cs" />
<Compile Include="Utils\PythonParserHelper.cs" />
<Compile Include="Utils\SupportInitCustomControl.cs" />
<Compile Include="Utils\Tests\MockComponentCreatorTests.cs" />
<Compile Include="Utils\Tests\MockProjectContentTests.cs" />
<Compile Include="Utils\Tests\PythonCompletionItemsHelperTests.cs" />
<Compile Include="Utils\Tests\PythonParserHelperTests.cs" />

6
src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockComponentCreator.cs

@ -10,8 +10,9 @@ using System.Collections; @@ -10,8 +10,9 @@ using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
@ -134,6 +135,9 @@ namespace PythonBinding.Tests.Utils @@ -134,6 +135,9 @@ namespace PythonBinding.Tests.Utils
if (type == null) {
type = typeof(Component).Assembly.GetType(typeName);
}
if (type == null) {
type = typeof(DataTable).Assembly.GetType(typeName);
}
if (type == null) {
types.TryGetValue(typeName, out type);
}

41
src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockComponentCreatorTests.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Data;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Utils.Tests
{
[TestFixture]
public class MockComponentCreatorTests
{
MockComponentCreator componentCreator;
[SetUp]
public void Init()
{
componentCreator = new MockComponentCreator();
}
[Test]
public void GetTypeReturnsConstraintTypeWhenPassedSystemDataConstraintString()
{
Type type = componentCreator.GetType(typeof(Constraint).FullName);
Assert.AreEqual(typeof(Constraint), type);
}
[Test]
public void GetTypeReturnsUniqueConstraintTypeWhenPassedSystemDataUniqueConstraintString()
{
Type type = componentCreator.GetType(typeof(UniqueConstraint).FullName);
Assert.AreEqual(typeof(UniqueConstraint), type);
}
}
}

5
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixPackageFilesControl.cs

@ -37,6 +37,11 @@ namespace ICSharpCode.WixBinding @@ -37,6 +37,11 @@ namespace ICSharpCode.WixBinding
/// Raised when the files are changed and require saving.
/// </summary>
public event EventHandler DirtyChanged;
public bool ContextMenuEnabled {
get { return packageFilesTreeView.ContextMenuStrip.Enabled; }
set { packageFilesTreeView.ContextMenuStrip.Enabled = value; }
}
/// <summary>
/// Gets or sets the error message that will be displayed instead of the

2
src/AddIns/BackendBindings/WixBinding/Project/Src/IWixPackageFilesView.cs

@ -16,6 +16,8 @@ namespace ICSharpCode.WixBinding @@ -16,6 +16,8 @@ namespace ICSharpCode.WixBinding
/// </summary>
public interface IWixPackageFilesView
{
bool ContextMenuEnabled { get; set; }
/// <summary>
/// Displays the message in the view that no WiX source file is contained
/// in the project.

2
src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesEditor.cs

@ -63,6 +63,7 @@ namespace ICSharpCode.WixBinding @@ -63,6 +63,7 @@ namespace ICSharpCode.WixBinding
{
// Look for Wix document containing root directory.
document = null;
view.ContextMenuEnabled = false;
if (project.WixSourceFiles.Count > 0) {
bool errors = false;
WixDocument currentDocument = null;
@ -83,6 +84,7 @@ namespace ICSharpCode.WixBinding @@ -83,6 +84,7 @@ namespace ICSharpCode.WixBinding
} else if (document == null) {
view.ShowNoRootDirectoryFoundMessage();
} else {
view.ContextMenuEnabled = true;
SelectedElementChanged();
}
} else {

6
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/AddDirectoryTestFixture.cs

@ -124,6 +124,12 @@ namespace WixBinding.Tests.PackageFiles @@ -124,6 +124,12 @@ namespace WixBinding.Tests.PackageFiles
Assert.AreEqual(3, view.ElementsAdded.Length);
}
[Test]
public void ContextMenuIsEnabled()
{
Assert.IsTrue(view.ContextMenuEnabled);
}
protected override string GetWixXml()
{
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +

6
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoRootDirectoryFoundTestFixture.cs

@ -40,6 +40,12 @@ namespace WixBinding.Tests.PackageFiles @@ -40,6 +40,12 @@ namespace WixBinding.Tests.PackageFiles
Assert.IsTrue(view.IsNoRootDirectoryFoundMessageDisplayed);
}
[Test]
public void ContextMenuIsDisabled()
{
Assert.IsFalse(view.ContextMenuEnabled);
}
/// <summary>
/// Deliberately use WiX 2.0's namespace so the test fixture will not find any
/// target directory element.

6
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoRootDirectoryInWixProductFileTestFixture.cs

@ -46,6 +46,12 @@ namespace WixBinding.Tests.PackageFiles @@ -46,6 +46,12 @@ namespace WixBinding.Tests.PackageFiles
Assert.IsTrue(view.IsNoDifferencesFoundMessageDisplayed);
}
[Test]
public void ContextMenuIsEnabled()
{
Assert.IsTrue(view.ContextMenuEnabled);
}
protected override string GetWixXml()
{
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +

6
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoWixProductFileTestFixture.cs

@ -39,6 +39,12 @@ namespace WixBinding.Tests.PackageFiles @@ -39,6 +39,12 @@ namespace WixBinding.Tests.PackageFiles
Assert.IsTrue(view.IsNoRootDirectoryFoundMessageDisplayed);
}
[Test]
public void ContextMenuIsDisabled()
{
Assert.IsFalse(view.ContextMenuEnabled);
}
protected override string GetWixXml()
{
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +

7
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoWixSourceFileInProjectTestFixture.cs

@ -25,6 +25,7 @@ namespace WixBinding.Tests.PackageFiles @@ -25,6 +25,7 @@ namespace WixBinding.Tests.PackageFiles
WixProject p = WixBindingTestsHelper.CreateEmptyWixProject();
p.Name = "MySetup";
view = new MockWixPackageFilesView();
view.ContextMenuEnabled = true;
WixPackageFilesEditor editor = new WixPackageFilesEditor(view, this, this);
editor.ShowFiles(p);
}
@ -55,5 +56,11 @@ namespace WixBinding.Tests.PackageFiles @@ -55,5 +56,11 @@ namespace WixBinding.Tests.PackageFiles
public void Write(WixDocument document)
{
}
[Test]
public void ContextMenuDisabledInPackageFilesView()
{
Assert.IsFalse(view.ContextMenuEnabled);
}
}
}

6
src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWixPackageFilesView.cs

@ -33,6 +33,7 @@ namespace WixBinding.Tests.Utils @@ -33,6 +33,7 @@ namespace WixBinding.Tests.Utils
List<XmlElement> directoriesAdded = new List<XmlElement>();
bool clearDirectoriesCalled;
WixPackageFilesDiffResult[] diffResults;
bool contextMenuEnabled;
public MockWixPackageFilesView()
{
@ -178,5 +179,10 @@ namespace WixBinding.Tests.Utils @@ -178,5 +179,10 @@ namespace WixBinding.Tests.Utils
public WixPackageFilesDiffResult[] DiffResults {
get { return diffResults; }
}
public bool ContextMenuEnabled {
get { return contextMenuEnabled; }
set { contextMenuEnabled = value; }
}
}
}

6
src/AddIns/BackendBindings/WixBinding/WixBinding.sln

@ -24,6 +24,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Wi @@ -24,6 +24,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Wi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "..\..\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}"
EndProject
Global
@ -80,5 +82,9 @@ Global @@ -80,5 +82,9 @@ Global
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.Build.0 = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.Build.0 = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.Build.0 = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

2
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ProjectResourceService.cs

@ -79,7 +79,7 @@ namespace ICSharpCode.FormsDesigner.Services @@ -79,7 +79,7 @@ namespace ICSharpCode.FormsDesigner.Services
}
// Get the (generated) class where the resource is defined.
IClass resourceClass = this.projectContent.GetClass(typeRef.Type.BaseType, 0);
IClass resourceClass = this.projectContent.GetClassByReflectionName(typeRef.Type.BaseType, true);
if (resourceClass == null) {
throw new InvalidOperationException("Could not find class for project resources: '" + typeRef.Type.BaseType + "'.");
}

9
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs

@ -139,7 +139,14 @@ namespace ICSharpCode.Profiler.AddIn @@ -139,7 +139,14 @@ namespace ICSharpCode.Profiler.AddIn
return null;
}
ProfilerRunner runner = new ProfilerRunner(currentProj.CreateStartInfo(), true, writer);
ProcessStartInfo startInfo;
try {
startInfo = currentProj.CreateStartInfo();
} catch (ProjectStartException ex) {
MessageService.ShowError(ex.Message);
return null;
}
ProfilerRunner runner = new ProfilerRunner(startInfo, true, writer);
return runner;
}

4
src/Libraries/NRefactory/Project/Src/EnvironmentInformationProvider.cs

@ -11,14 +11,14 @@ namespace ICSharpCode.NRefactory @@ -11,14 +11,14 @@ namespace ICSharpCode.NRefactory
{
public interface IEnvironmentInformationProvider
{
bool HasField(string fullTypeName, int typeParameterCount, string fieldName);
bool HasField(string reflectionTypeName, int typeParameterCount, string fieldName);
}
sealed class DummyEnvironmentInformationProvider : IEnvironmentInformationProvider
{
internal static readonly IEnvironmentInformationProvider Instance = new DummyEnvironmentInformationProvider();
public bool HasField(string fullTypeName, int typeParameterCount, string fieldName)
public bool HasField(string reflectionTypeName, int typeParameterCount, string fieldName)
{
return false;
}

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

@ -381,7 +381,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -381,7 +381,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
/* True, if "checked" or "unchecked" are followed by "{" */
bool UnCheckedAndLBrace () {
return la.kind == Tokens.Checked || la.kind == Tokens.Unchecked &&
return (la.kind == Tokens.Checked || la.kind == Tokens.Unchecked) &&
Peek(1).kind == Tokens.OpenCurlyBrace;
}

26
src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

@ -317,7 +317,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -317,7 +317,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VisitAttributes(typeDeclaration.Attributes, data);
outputFormatter.Indent();
OutputModifier(typeDeclaration.Modifier, true);
OutputModifier(typeDeclaration.Modifier, true, false);
int typeToken = GetTypeToken(typeDeclaration);
outputFormatter.PrintToken(typeToken);
@ -424,7 +424,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -424,7 +424,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VisitAttributes(delegateDeclaration.Attributes, data);
outputFormatter.Indent();
OutputModifier(delegateDeclaration.Modifier, true);
OutputModifier(delegateDeclaration.Modifier, true, false);
outputFormatter.PrintToken(Tokens.Delegate);
outputFormatter.Space();
@ -501,11 +501,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -501,11 +501,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (fieldDeclaration.Modifier == Modifiers.None) {
outputFormatter.PrintToken(Tokens.Private);
outputFormatter.Space();
} else if (fieldDeclaration.Modifier == Modifiers.Dim) {
outputFormatter.PrintToken(Tokens.Dim);
outputFormatter.Space();
} else {
OutputModifier(fieldDeclaration.Modifier);
OutputModifier(fieldDeclaration.Modifier, false, true);
}
currentVariableType = fieldDeclaration.TypeReference;
AppendCommaSeparatedList(fieldDeclaration.Fields);
@ -1355,7 +1352,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1355,7 +1352,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
{
if (localVariableDeclaration.Modifier != Modifiers.None) {
OutputModifier(localVariableDeclaration.Modifier);
OutputModifier(localVariableDeclaration.Modifier & ~Modifiers.Dim);
}
if (!isUsingResourceAcquisition) {
if ((localVariableDeclaration.Modifier & Modifiers.Const) == 0) {
@ -2761,10 +2758,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2761,10 +2758,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
void OutputModifier(Modifiers modifier)
{
OutputModifier(modifier, false);
OutputModifier(modifier, false, false);
}
void OutputModifier(Modifiers modifier, bool forTypeDecl)
void OutputModifier(Modifiers modifier, bool forTypeDecl, bool forFieldDecl)
{
if ((modifier & Modifiers.Public) == Modifiers.Public) {
outputFormatter.PrintToken(Tokens.Public);
@ -2794,7 +2791,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2794,7 +2791,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
if ((modifier & Modifiers.Abstract) == Modifiers.Abstract) {
outputFormatter.PrintToken(forTypeDecl ? Tokens.MustInherit : Tokens.MustOverride);
if (forFieldDecl)
outputFormatter.PrintToken(Tokens.Dim);
else if (forTypeDecl)
outputFormatter.PrintToken(Tokens.MustInherit);
else
outputFormatter.PrintToken(Tokens.MustOverride);
outputFormatter.Space();
}
if ((modifier & Modifiers.Overloads) == Modifiers.Overloads) {
@ -2827,6 +2829,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2827,6 +2829,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Const);
outputFormatter.Space();
}
if ((modifier & Modifiers.WithEvents) == Modifiers.WithEvents) {
outputFormatter.PrintToken(Tokens.WithEvents);
outputFormatter.Space();
}
if ((modifier & Modifiers.Partial) == Modifiers.Partial) {
outputFormatter.PrintToken(Tokens.Partial);
outputFormatter.Space();

18
src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs

@ -1533,19 +1533,9 @@ namespace ICSharpCode.NRefactory.Visitors @@ -1533,19 +1533,9 @@ namespace ICSharpCode.NRefactory.Visitors
return continueStmt;
}
bool IsField(string type, int typeParameterCount, string fieldName)
bool IsField(string reflectionTypeName, string fieldName)
{
bool isField = environmentInformationProvider.HasField(type, typeParameterCount, fieldName);
if (!isField) {
int idx = type.LastIndexOf('.');
if (idx >= 0) {
type = type.Substring(0, idx) + "+" + type.Substring(idx + 1);
isField = IsField(type, typeParameterCount, fieldName);
}
}
return isField;
return environmentInformationProvider.HasField(reflectionTypeName, 0, fieldName);
}
bool IsFieldReferenceExpression(MemberReferenceExpression fieldReferenceExpression)
@ -1572,7 +1562,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -1572,7 +1562,7 @@ namespace ICSharpCode.NRefactory.Visitors
if (fieldReferenceExpression.TargetObject is MemberReferenceExpression) {
if (IsPossibleTypeReference((MemberReferenceExpression)fieldReferenceExpression.TargetObject)) {
CodeTypeReferenceExpression typeRef = ConvertToTypeReference((MemberReferenceExpression)fieldReferenceExpression.TargetObject);
if (IsField(typeRef.Type.BaseType, typeRef.Type.TypeArguments.Count, fieldReferenceExpression.MemberName)) {
if (IsField(typeRef.Type.BaseType, fieldReferenceExpression.MemberName)) {
return new CodeFieldReferenceExpression(typeRef,
fieldReferenceExpression.MemberName);
} else {
@ -1635,7 +1625,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -1635,7 +1625,7 @@ namespace ICSharpCode.NRefactory.Visitors
}
//field detection for fields\props inherited from base classes
if (currentTypeDeclaration.BaseTypes.Count > 0) {
return IsField(currentTypeDeclaration.BaseTypes[0].Type, currentTypeDeclaration.BaseTypes[0].GenericTypes.Count, identifier);
return environmentInformationProvider.HasField(currentTypeDeclaration.BaseTypes[0].Type, currentTypeDeclaration.BaseTypes[0].GenericTypes.Count, identifier);
}
return false;
}

29
src/Libraries/NRefactory/Project/Src/Visitors/ConvertVisitorBase.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.Ast;
namespace ICSharpCode.NRefactory.Visitors
@ -24,5 +25,33 @@ namespace ICSharpCode.NRefactory.Visitors @@ -24,5 +25,33 @@ namespace ICSharpCode.NRefactory.Visitors
sibling.Parent.Children.Insert(index + 1, newNode);
newNode.Parent = sibling.Parent;
}
List<KeyValuePair<INode, INode>> insertions = new List<KeyValuePair<INode, INode>>();
protected void InsertBeforeSibling(INode sibling, INode newNode)
{
if (sibling == null) return;
if (!(sibling.Parent is TypeDeclaration))
throw new NotSupportedException();
insertions.Add(new KeyValuePair<INode, INode>(sibling, newNode));
}
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
object result = base.VisitTypeDeclaration(typeDeclaration, data);
for (int i = 0; i < insertions.Count; i++) {
if (insertions[i].Key.Parent == typeDeclaration) {
INode sibling = insertions[i].Key;
INode newNode = insertions[i].Value;
int index = sibling.Parent.Children.IndexOf(sibling);
sibling.Parent.Children.Insert(index, newNode);
newNode.Parent = sibling.Parent;
insertions.RemoveAt(i--);
}
}
return result;
}
}
}

85
src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs

@ -5,9 +5,10 @@ @@ -5,9 +5,10 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.NRefactory.AstBuilder;
using System;
using System.Linq;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.AstBuilder;
namespace ICSharpCode.NRefactory.Visitors
{
@ -147,24 +148,81 @@ namespace ICSharpCode.NRefactory.Visitors @@ -147,24 +148,81 @@ namespace ICSharpCode.NRefactory.Visitors
parent = parent.Parent;
}
if (parent != null) {
INode type = parent.Parent;
if (type != null) {
int pos = type.Children.IndexOf(parent);
if (pos >= 0) {
FieldDeclaration field = new FieldDeclaration(null);
field.TypeReference = localVariableDeclaration.TypeReference;
field.Modifier = Modifiers.Static;
field.Fields = localVariableDeclaration.Variables;
new PrefixFieldsVisitor(field.Fields, "static_" + GetTypeLevelEntityName(parent) + "_").Run(parent);
type.Children.Insert(pos + 1, field);
RemoveCurrentNode();
string fieldPrefix = "static_" + GetTypeLevelEntityName(parent) + "_";
foreach (VariableDeclaration v in localVariableDeclaration.Variables) {
if (!v.Initializer.IsNull) {
string initFieldName = fieldPrefix + v.Name + "_Init";
FieldDeclaration initField = new FieldDeclaration(null);
initField.TypeReference = new TypeReference("Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag");
initField.Modifier = (((AttributedNode)parent).Modifier & Modifiers.Static) | Modifiers.ReadOnly;
Expression initializer = initField.TypeReference.New();
initField.Fields.Add(new VariableDeclaration(initFieldName, initializer));
InsertBeforeSibling(parent, initField);
InsertAfterSibling(localVariableDeclaration, InitStaticVariable(initFieldName, v.Name, v.Initializer, parent.Parent as TypeDeclaration));
}
FieldDeclaration field = new FieldDeclaration(null);
field.TypeReference = localVariableDeclaration.TypeReference;
field.Modifier = ((AttributedNode)parent).Modifier & Modifiers.Static;
field.Fields.Add(new VariableDeclaration(fieldPrefix + v.Name) { TypeReference = v.TypeReference });
InsertBeforeSibling(parent, field);
}
new PrefixFieldsVisitor(localVariableDeclaration.Variables, fieldPrefix).Run(parent);
RemoveCurrentNode();
}
}
return null;
}
INode InitStaticVariable(string initFieldName, string variableName, Expression initializer, TypeDeclaration typeDeclaration)
{
const string helperMethodName = "InitStaticVariableHelper";
if (typeDeclaration != null) {
if (!typeDeclaration.Children.OfType<MethodDeclaration>().Any(m => m.Name == helperMethodName)) {
// add helper method
var helperMethod = new MethodDeclaration {
Name = helperMethodName,
Modifier = Modifiers.Static,
TypeReference = new TypeReference("System.Boolean", true),
Parameters = {
new ParameterDeclarationExpression(new TypeReference("Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag"), "flag")
},
Body = new BlockStatement()
};
BlockStatement trueBlock = new BlockStatement();
BlockStatement elseIfBlock = new BlockStatement();
BlockStatement falseBlock = new BlockStatement();
helperMethod.Body.AddStatement(
new IfElseStatement(ExpressionBuilder.Identifier("flag").Member("State").Operator(BinaryOperatorType.Equality, new PrimitiveExpression(0))) {
TrueStatement = { trueBlock },
ElseIfSections = {
new ElseIfSection(ExpressionBuilder.Identifier("flag").Member("State").Operator(BinaryOperatorType.Equality, new PrimitiveExpression(2)), elseIfBlock)
},
FalseStatement = { falseBlock }
});
trueBlock.Assign(ExpressionBuilder.Identifier("flag").Member("State"), new PrimitiveExpression(2));
trueBlock.Return(new PrimitiveExpression(true));
elseIfBlock.Throw(new TypeReference("Microsoft.VisualBasic.CompilerServices.IncompleteInitialization").New());
falseBlock.Return(new PrimitiveExpression(false));
typeDeclaration.AddChild(helperMethod);
}
}
BlockStatement tryBlock = new BlockStatement();
BlockStatement ifTrueBlock = new BlockStatement();
tryBlock.AddStatement(new IfElseStatement(ExpressionBuilder.Identifier(helperMethodName).Call(ExpressionBuilder.Identifier(initFieldName)), ifTrueBlock));
ifTrueBlock.Assign(ExpressionBuilder.Identifier(variableName), initializer);
BlockStatement finallyBlock = new BlockStatement();
finallyBlock.Assign(ExpressionBuilder.Identifier(initFieldName).Member("State"), new PrimitiveExpression(1));
BlockStatement lockBlock = new BlockStatement();
lockBlock.AddStatement(new TryCatchStatement(tryBlock, null, finallyBlock));
return new LockStatement(ExpressionBuilder.Identifier(initFieldName), lockBlock);
}
public override object VisitWithStatement(WithStatement withStatement, object data)
{
withStatement.Body.AcceptVisitor(new ReplaceWithAccessTransformer(withStatement.Expression), data);
@ -201,8 +259,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -201,8 +259,7 @@ namespace ICSharpCode.NRefactory.Visitors
static bool IsTypeLevel(INode node)
{
return node is MethodDeclaration || node is PropertyDeclaration || node is EventDeclaration
|| node is OperatorDeclaration || node is FieldDeclaration;
return node.Parent is TypeDeclaration;
}
static string GetTypeLevelEntityName(INode node)

2
src/Libraries/NRefactory/Project/Src/Visitors/VBNetConstructsConvertVisitor.cs

@ -492,7 +492,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -492,7 +492,7 @@ namespace ICSharpCode.NRefactory.Visitors
public override object VisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
{
if (AddDefaultValueInitializerToLocalVariableDeclarations) {
if (AddDefaultValueInitializerToLocalVariableDeclarations && (localVariableDeclaration.Modifier & Modifiers.Static) == 0) {
for (int i = 0; i < localVariableDeclaration.Variables.Count; i++) {
VariableDeclaration decl = localVariableDeclaration.Variables[i];
if (decl.FixedArrayInitialization.IsNull && decl.Initializer.IsNull) {

95
src/Libraries/NRefactory/Test/Output/CSharp/VBNetToCSharpConverterTest.cs

@ -507,37 +507,112 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -507,37 +507,112 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
public void StaticMethodVariable()
{
TestMember(@"Private Sub Test
Static j As Integer = 0
Static j As Integer
j += 1
End Sub
Private Shared Sub Test2
Static j As Integer
j += 2
End Sub",
@"private void Test()
@"int static_Test_j;
private void Test()
{
static_Test_j += 1;
}
static int static_Test_j = 0;");
static int static_Test2_j;
private static void Test2()
{
static_Test2_j += 2;
}");
}
[Test]
public void StaticMethodVariable2()
public void StaticMethodVariableWithInitialization()
{
TestMember(@"Private Sub Test
Static j As Integer = 0
j += 1
End Sub",
@"readonly Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag static_Test_j_Init = new Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag();
int static_Test_j;
private void Test()
{
lock (static_Test_j_Init) {
try {
if (InitStaticVariableHelper(static_Test_j_Init)) {
static_Test_j = 0;
}
} finally {
static_Test_j_Init.State = 1;
}
}
static_Test_j += 1;
}
static bool InitStaticVariableHelper(Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag flag)
{
if (flag.State == 0) {
flag.State = 2;
return true;
} else if (flag.State == 2) {
throw new Microsoft.VisualBasic.CompilerServices.IncompleteInitialization();
} else {
return false;
}
}");
}
[Test]
public void StaticMethodVariableWithInitialization2()
{
TestMember(@"Private Sub Test
Static j As Integer = 10
j += 1
End Sub
Private Sub Test2
Static j As Integer = 0
Private Shared Sub Test2
Static j As Integer = 20
j += 2
End Sub",
@"private void Test()
@"readonly Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag static_Test_j_Init = new Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag();
int static_Test_j;
private void Test()
{
lock (static_Test_j_Init) {
try {
if (InitStaticVariableHelper(static_Test_j_Init)) {
static_Test_j = 10;
}
} finally {
static_Test_j_Init.State = 1;
}
}
static_Test_j += 1;
}
static int static_Test_j = 0;
private void Test2()
static readonly Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag static_Test2_j_Init = new Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag();
static int static_Test2_j;
private static void Test2()
{
lock (static_Test2_j_Init) {
try {
if (InitStaticVariableHelper(static_Test2_j_Init)) {
static_Test2_j = 20;
}
} finally {
static_Test2_j_Init.State = 1;
}
}
static_Test2_j += 2;
}
static int static_Test2_j = 0;");
static bool InitStaticVariableHelper(Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag flag)
{
if (flag.State == 0) {
flag.State = 2;
return true;
} else if (flag.State == 2) {
throw new Microsoft.VisualBasic.CompilerServices.IncompleteInitialization();
} else {
return false;
}
}");
}
[Test]

6
src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

@ -532,5 +532,11 @@ End Using"); @@ -532,5 +532,11 @@ End Using");
" End Sub\n" +
"End Module");
}
[Test]
public void WithEvents()
{
TestTypeMember("Dim WithEvents a As Button");
}
}
}

12
src/Libraries/NRefactory/Test/Parser/Statements/CheckedStatementTests.cs

@ -23,10 +23,20 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -23,10 +23,20 @@ namespace ICSharpCode.NRefactory.Tests.Ast
CheckedStatement checkedStatement = ParseUtilCSharp.ParseStatement<CheckedStatement>("checked { }");
Assert.IsFalse(checkedStatement.Block.IsNull);
}
[Test]
public void CSharpCheckedStatementAndExpressionTest()
{
CheckedStatement checkedStatement = ParseUtilCSharp.ParseStatement<CheckedStatement>("checked { checked(++i); }");
Assert.IsFalse(checkedStatement.Block.IsNull);
ExpressionStatement es = (ExpressionStatement)checkedStatement.Block.Children[0];
CheckedExpression ce = (CheckedExpression)es.Expression;
Assert.IsInstanceOf<UnaryOperatorExpression>(ce.Expression);
}
#endregion
#region VB.NET
// No VB.NET representation
// No VB.NET representation
#endregion
}
}

13
src/Libraries/NRefactory/Test/Parser/Statements/UncheckedStatementTests.cs

@ -23,10 +23,21 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -23,10 +23,21 @@ namespace ICSharpCode.NRefactory.Tests.Ast
UncheckedStatement uncheckedStatement = ParseUtilCSharp.ParseStatement<UncheckedStatement>("unchecked { }");
Assert.IsFalse(uncheckedStatement.Block.IsNull);
}
[Test]
public void CSharpUncheckedStatementAndExpressionTest()
{
UncheckedStatement uncheckedStatement = ParseUtilCSharp.ParseStatement<UncheckedStatement>("unchecked { unchecked(++i); }");
Assert.IsFalse(uncheckedStatement.Block.IsNull);
ExpressionStatement es = (ExpressionStatement)uncheckedStatement.Block.Children[0];
UncheckedExpression ce = (UncheckedExpression)es.Expression;
Assert.IsInstanceOf<UnaryOperatorExpression>(ce.Expression);
}
#endregion
#region VB.NET
// No VB.NET representation
// No VB.NET representation
#endregion
}
}

4
src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs

@ -288,8 +288,8 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -288,8 +288,8 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
if (name.Length == 0 || !char.IsLetter(name[0]) && name[0] != '_') {
return "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.ProjectNameMustStartWithLetter}";
}
if (!FileUtility.IsValidDirectoryName(solution)
|| !FileUtility.IsValidDirectoryName(name))
if (!FileUtility.IsValidDirectoryEntryName(solution)
|| !FileUtility.IsValidDirectoryEntryName(name))
{
return "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.IllegalProjectNameError}";
}

2
src/Main/Base/Project/Src/Gui/Dialogs/SolutionConfiguration/EditAvailableConfigurationsDialog.cs

@ -182,7 +182,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -182,7 +182,7 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
if (MSBuildInternals.Escape(newName) != newName
|| !FileUtility.IsValidDirectoryName(newName)
|| !FileUtility.IsValidDirectoryEntryName(newName)
|| newName.Contains("'"))
{
MessageService.ShowMessage("${res:Dialog.EditAvailableConfigurationsDialog.InvalidName}");

5
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs

@ -478,10 +478,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -478,10 +478,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (newName == null) {
return;
}
if (!FileService.CheckFileName(newName)) {
return;
}
if (!FileService.CheckDirectoryName(newName)) {
if (!FileService.CheckDirectoryEntryName(newName)) {
return;
}
if (String.Compare(Text, newName, true) == 0) {

2
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/FileNode.cs

@ -139,7 +139,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -139,7 +139,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (newName == null) {
return;
}
if (!FileService.CheckFileName(newName)) {
if (!FileService.CheckDirectoryEntryName(newName)) {
return;
}
string oldFileName = FileName;

26
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -169,29 +169,39 @@ namespace ICSharpCode.SharpDevelop @@ -169,29 +169,39 @@ namespace ICSharpCode.SharpDevelop
#endregion
/// <summary>
/// Checks if the file name is valid <b>and shows a MessageBox if it is not valid</b>.
/// Checks if the path is valid <b>and shows a MessageBox if it is not valid</b>.
/// Do not use in non-UI methods.
/// </summary>
public static bool CheckFileName(string fileName)
public static bool CheckFileName(string path)
{
if (FileUtility.IsValidPath(fileName))
if (FileUtility.IsValidPath(path))
return true;
MessageService.ShowMessage(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.SaveFile.InvalidFileNameError}", new string[,] {{"FileName", fileName}}));
MessageService.ShowMessage(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.SaveFile.InvalidFileNameError}", new string[,] {{"FileName", path}}));
return false;
}
/// <summary>
/// Checks that a single directory name is valid.
/// Checks that a single directory entry (file or subdirectory) name is valid.
/// </summary>
/// <param name="name">A single directory name not the full path</param>
public static bool CheckDirectoryName(string name)
/// <param name="name">A single file name not the full path</param>
public static bool CheckDirectoryEntryName(string name)
{
if (FileUtility.IsValidDirectoryName(name))
if (FileUtility.IsValidDirectoryEntryName(name))
return true;
MessageService.ShowMessage(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.SaveFile.InvalidFileNameError}", new string[,] {{"FileName", name}}));
return false;
}
/// <summary>
/// Checks that a single directory name is valid.
/// </summary>
/// <param name="name">A single directory name not the full path</param>
[Obsolete("Use CheckDirectoryEntryName instead")]
public static bool CheckDirectoryName(string name)
{
return CheckDirectoryEntryName(name);
}
internal sealed class LoadFileWrapper
{
readonly IDisplayBinding binding;

14
src/Main/Base/Project/Src/TextEditor/ClipboardHandling.cs

@ -5,11 +5,14 @@ @@ -5,11 +5,14 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Util;
using System;
using System.Runtime.InteropServices;
using System.Threading;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Util;
using Microsoft.Win32.SafeHandles;
namespace ICSharpCode.SharpDevelop.DefaultEditor
{
@ -66,9 +69,16 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor @@ -66,9 +69,16 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor
}
currentWorker = workerThread.Enqueue(DoUpdate);
// wait a few ms in case the clipboard can be accessed without problems
currentWorker.AsyncWaitHandle.WaitOne(50);
WaitForSingleObject(currentWorker.AsyncWaitHandle.SafeWaitHandle, 50);
// Using WaitHandle.WaitOne() pumps some Win32 messages.
// To avoid unintended reentrancy, we need to avoid pumping messages,
// so we directly call the Win32 WaitForSingleObject function.
// See SD2-1638 for details.
}
[DllImport("kernel32", SetLastError=true, ExactSpelling=true)]
static extern Int32 WaitForSingleObject(SafeWaitHandle handle, Int32 milliseconds);
static void DoUpdate()
{
clipboardContainsText = ClipboardWrapper.ContainsText;

26
src/Main/Base/Test/CodeConverterTests.cs

@ -380,6 +380,20 @@ namespace ICSharpCode.SharpDevelop.Tests @@ -380,6 +380,20 @@ namespace ICSharpCode.SharpDevelop.Tests
}
#endregion
[Test]
public void FullyQualifyNamespaceReferencesInIdentifiers()
{
TestStatementsVB2CS("IO.Path.GetTempPath",
"System.IO.Path.GetTempPath();");
}
[Test]
public void FullyQualifyNamespaceReferencesInTypeName()
{
TestStatementsVB2CS("Dim a As Collections.ICollection = New Collections.ArrayList",
"System.Collections.ICollection a = new System.Collections.ArrayList();");
}
[Test]
public void AutomaticInitializeComponentCall()
{
@ -501,7 +515,7 @@ namespace ICSharpCode.SharpDevelop.Tests @@ -501,7 +515,7 @@ namespace ICSharpCode.SharpDevelop.Tests
" End Sub\n" +
" Public Field As Integer\n" +
"End Module",
DefaultUsingsCSharp +
DefaultUsingsCSharp +
"class Test\n" +
"{\n" +
" public void A()\n" +
@ -757,11 +771,11 @@ namespace ICSharpCode.SharpDevelop.Tests @@ -757,11 +771,11 @@ namespace ICSharpCode.SharpDevelop.Tests
TestProgramCS2VB("class Test : System.Collections.Generic.List<int> {" +
" public void RemoveAt(string strangeIndex) {}" +
"}",
"Class Test\n" +
" Inherits System.Collections.Generic.List(Of Integer)\n" +
" Public Overloads Sub RemoveAt(strangeIndex As String)\n" +
" End Sub\n" +
"End Class");
"Class Test\n" +
" Inherits System.Collections.Generic.List(Of Integer)\n" +
" Public Overloads Sub RemoveAt(strangeIndex As String)\n" +
" End Sub\n" +
"End Class");
}
}
}

11
src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs

@ -426,12 +426,21 @@ namespace ICSharpCode.Core @@ -426,12 +426,21 @@ namespace ICSharpCode.Core
/// <summary>
/// Checks that a single directory name (not the full path) is valid.
/// </summary>
[ObsoleteAttribute("Use IsValidDirectoryEntryName instead")]
public static bool IsValidDirectoryName(string name)
{
return IsValidDirectoryEntryName(name);
}
/// <summary>
/// Checks that a single directory name (not the full path) is valid.
/// </summary>
public static bool IsValidDirectoryEntryName(string name)
{
if (!IsValidPath(name)) {
return false;
}
if (name.IndexOfAny(new char[]{Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar}) >= 0) {
if (name.IndexOfAny(new char[]{Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar,Path.VolumeSeparatorChar}) >= 0) {
return false;
}
if (name.Trim(' ').Length == 0) {

4
src/Main/Core/Project/Src/Services/PropertyService/Properties.cs

@ -95,6 +95,10 @@ namespace ICSharpCode.Core @@ -95,6 +95,10 @@ namespace ICSharpCode.Core
public void Set<T>(string property, T value)
{
if (property == null)
throw new ArgumentNullException("property");
if (value == null)
throw new ArgumentNullException("value");
T oldValue = default(T);
lock (properties) {
if (!properties.ContainsKey(property)) {

74
src/Main/Core/Test/InvalidDirectoryNameTests.cs

@ -16,67 +16,67 @@ namespace ICSharpCode.Core.Tests @@ -16,67 +16,67 @@ namespace ICSharpCode.Core.Tests
[Test]
public void ContainsBackslash()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName(@"project\test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName(@"project\test"));
}
[Test]
public void ContainsForwardSlash()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName(@"project/test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName(@"project/test"));
}
[Test]
public void IsPRN()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("PRN"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("PRN"));
}
[Test]
public void IsEmptySpace()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName(" "));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName(" "));
}
[Test]
public void ContainsLessThan()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("project<test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("project<test"));
}
[Test]
public void ContainsGreaterThan()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("project>test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("project>test"));
}
[Test]
public void ContainsColon()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("project:test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("project:test"));
}
[Test]
public void ContainsDoubleQuote()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName(@"project""test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName(@"project""test"));
}
[Test]
public void ContainsPipe()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("project|test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("project|test"));
}
[Test]
public void ContainsQuestionMark()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("project?test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("project?test"));
}
[Test]
public void ContainsStar()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("project*test"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("project*test"));
}
[Test]
@ -86,152 +86,152 @@ namespace ICSharpCode.Core.Tests @@ -86,152 +86,152 @@ namespace ICSharpCode.Core.Tests
{
char testChar = (char)i;
string testString = string.Format("project{0}test", testChar);
Assert.IsFalse(FileUtility.IsValidDirectoryName(testString));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName(testString));
}
}
[Test]
public void ReservedDeviceNameCON()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("CON"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("CON"));
}
[Test]
public void ReservedDeviceNamePRN()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("PRN"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("PRN"));
}
[Test]
public void ReservedDeviceNameAUX()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("AUX"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("AUX"));
}
[Test]
public void ReservedDeviceNameNUL()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("NUL"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("NUL"));
}
[Test]
public void ReservedDeviceNameCOM1()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM1"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM1"));
}
[Test]
public void ReservedDeviceNameCOM2()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM2"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM2"));
}
[Test]
public void ReservedDeviceNameCOM3()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM3"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM3"));
}
[Test]
public void ReservedDeviceNameCOM4()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM4"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM4"));
}
[Test]
public void ReservedDeviceNameCOM5()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM5"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM5"));
}
[Test]
public void ReservedDeviceNameCOM6()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM6"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM6"));
}
[Test]
public void ReservedDeviceNameCOM7()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM7"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM7"));
}
[Test]
public void ReservedDeviceNameCOM8()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM8"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM8"));
}
[Test]
public void ReservedDeviceNameCOM9()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("COM9"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("COM9"));
}
[Test]
public void ReservedDeviceNameLPT1()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT1"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT1"));
}
[Test]
public void ReservedDeviceNameLPT2()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT2"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT2"));
}
[Test]
public void ReservedDeviceNameLPT3()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT3"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT3"));
}
[Test]
public void ReservedDeviceNameLPT4()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT4"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT4"));
}
[Test]
public void ReservedDeviceNameLPT5()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT5"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT5"));
}
[Test]
public void ReservedDeviceNameLPT6()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT6"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT6"));
}
[Test]
public void ReservedDeviceNameLPT7()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT7"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT7"));
}
[Test]
public void ReservedDeviceNameLPT8()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT8"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT8"));
}
[Test]
public void ReservedDeviceNameLPT9()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("LPT9"));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("LPT9"));
}
[Test]
public void EndWithSpace()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("projecttest "));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("projecttest "));
}
[Test]
public void EndWithPeriod()
{
Assert.IsFalse(FileUtility.IsValidDirectoryName("projecttest."));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName("projecttest."));
}
/// <summary>
@ -250,7 +250,7 @@ namespace ICSharpCode.Core.Tests @@ -250,7 +250,7 @@ namespace ICSharpCode.Core.Tests
tempString.Append('a');
}
Assert.IsTrue(tempString.Length == MAX_LENGTH, "Failed to build a test directory string of {0} length.", MAX_LENGTH);
Assert.IsFalse(FileUtility.IsValidDirectoryName(tempString.ToString()));
Assert.IsFalse(FileUtility.IsValidDirectoryEntryName(tempString.ToString()));
}
}
}

2
src/Main/Core/Test/TopologicalSortTest.cs

@ -40,7 +40,7 @@ namespace ICSharpCode.Core.Tests @@ -40,7 +40,7 @@ namespace ICSharpCode.Core.Tests
TopologicalSort.Sort(input).ConvertAll(c => c.Id).ToArray());
}
Codon CreateCodon(string id, string insertBefore = null, string insertAfter = null)
Codon CreateCodon(string id, string insertBefore = "", string insertAfter = "")
{
Properties p = new Properties();
p["id"] = id;

20
src/Main/Core/Test/ValidDirectoryNameTests.cs

@ -16,55 +16,55 @@ namespace ICSharpCode.Core.Tests @@ -16,55 +16,55 @@ namespace ICSharpCode.Core.Tests
[Test]
public void ValidDirectoryNameProjectTest()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("projecttest"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("projecttest"));
}
[Test]
public void ValidDirectoryNameWithPeriod()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("project.test"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("project.test"));
}
[Test]
public void ValidDirectoryNameWithTwoPeriodAtStart()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("..projecttest"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("..projecttest"));
}
[Test]
public void ValidDirectoryNameCOM()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("COM"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("COM"));
}
[Test]
public void ValidDirectoryNameCOM10()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("COM10"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("COM10"));
}
[Test]
public void ValidDirectoryNameLPT()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("LPT"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("LPT"));
}
[Test]
public void ValidDirectoryNameLPT10()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("LPT10"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("LPT10"));
}
[Test]
public void ValidEightThreeDirectoryName()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("projec~1.est"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("projec~1.est"));
}
[Test]
public void SmallestDirectoryNameLength()
{
Assert.IsTrue(FileUtility.IsValidDirectoryName("a"));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName("a"));
}
[Test]
@ -77,7 +77,7 @@ namespace ICSharpCode.Core.Tests @@ -77,7 +77,7 @@ namespace ICSharpCode.Core.Tests
{
tempString.Append('a');
}
Assert.IsTrue(FileUtility.IsValidDirectoryName(tempString.ToString()));
Assert.IsTrue(FileUtility.IsValidDirectoryEntryName(tempString.ToString()));
}
}
}

16
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/CodeSnippetConverter.cs

@ -47,8 +47,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -47,8 +47,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
project = new DefaultProjectContent();
project.ReferencedContents.AddRange(ReferencedContents);
if (sourceLanguage == SupportedLanguage.VBNet) {
project.Language = LanguageProperties.VBNet;
project.DefaultImports = new DefaultUsing(project);
project.DefaultImports.Usings.AddRange(DefaultImportsToAdd);
} else {
project.Language = LanguageProperties.CSharp;
}
SnippetParser parser = new SnippetParser(sourceLanguage);
INode result = parser.Parse(sourceCode);
@ -142,7 +145,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -142,7 +145,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
TypeDeclaration type = new TypeDeclaration(Modifiers.None, null) {
Name = "DummyTypeForConversion",
StartLocation = members[0].StartLocation,
EndLocation = members[members.Count - 1].EndLocation
EndLocation = GetEndLocation(members[members.Count - 1])
};
type.Children.AddRange(members);
return new CompilationUnit {
@ -151,6 +154,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -151,6 +154,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
};
}
Location GetEndLocation(INode node)
{
// workaround: MethodDeclaration.EndLocation is the end of the method header,
// but for the end of the dummy class we need the body end
MethodDeclaration method = node as MethodDeclaration;
if (method != null && !method.Body.IsNull)
return method.Body.EndLocation;
else
return node.EndLocation;
}
#endregion
public string CSharpToVB(string input, out string errors)

9
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryInformationProvider.cs

@ -22,9 +22,14 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -22,9 +22,14 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
_projectContent = projectContent;
}
public bool HasField(string fullTypeName, int typeParameterCount, string fieldName)
public bool HasField(string reflectionTypeName, int typeParameterCount, string fieldName)
{
IClass c = _projectContent.GetClass(fullTypeName, typeParameterCount);
IClass c;
if (typeParameterCount > 0) {
c = _projectContent.GetClass(reflectionTypeName, typeParameterCount);
} else {
c = _projectContent.GetClassByReflectionName(reflectionTypeName, true);
}
if (c == null)
return false;
foreach (IField field in c.DefaultReturnType.GetFields()) {

5
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

@ -685,6 +685,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -685,6 +685,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
List<TypeReference> typeArguments, bool isInvocation,
bool allowExtensionMethods, bool? isAccessThoughReferenceOfCurrentClass)
{
// in VB everything can be used with invocation syntax (because the same syntax also accesses indexers),
// do don't use 'isInvocation'.
if (language == NR.SupportedLanguage.VBNet)
isInvocation = false;
List<IList<IMember>> members = MemberLookupHelper.LookupMember(declaringType, memberName, callingClass, languageProperties, isInvocation, isAccessThoughReferenceOfCurrentClass);
List<IReturnType> typeArgs = null;
if (members != null && typeArguments != null && typeArguments.Count != 0) {

54
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/VBNetToCSharpConvertVisitor.cs

@ -344,6 +344,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -344,6 +344,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (ReplaceWithInvocation(identifierExpression, rr)) {}
else if (FullyQualifyModuleMemberReference(identifierExpression, rr)) {}
else if (FullyQualifyNamespaceReference(identifierExpression, rr)) {}
return null;
}
@ -428,6 +429,20 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -428,6 +429,20 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
return true;
}
bool FullyQualifyNamespaceReference(IdentifierExpression ident, ResolveResult rr)
{
NamespaceResolveResult nrr = rr as NamespaceResolveResult;
if (nrr == null)
return false;
if (nrr.Name.IndexOf('.') >= 0) {
// simple identifier points to complex namespace
ReplaceCurrentNode(MakeFieldReferenceExpression(nrr.Name));
} else {
ident.Identifier = nrr.Name;
}
return true;
}
TypeReference ConvertType(IReturnType type)
{
return Refactoring.CodeGenerator.ConvertType(type, CreateContext());
@ -482,7 +497,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -482,7 +497,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
MemberReferenceExpression targetObjectFre = targetObject as MemberReferenceExpression;
if (p.IsIndexer && targetObjectFre != null) {
MemberResolveResult rr2 = Resolve(targetObjectFre) as MemberResolveResult;
if (rr2 != null && rr2.ResolvedMember == rr.ResolvedMember) {
if (rr2 != null && rr2.ResolvedMember.FullyQualifiedName == rr.ResolvedMember.FullyQualifiedName) {
// remove ".Items"
targetObject = targetObjectFre.TargetObject;
}
@ -588,34 +603,51 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -588,34 +603,51 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
// default(TypeReference).
// MyType m = null; looks nicer than MyType m = default(MyType))
// so we replace default(ReferenceType) with null
if (type != null && (type.IsDefaultReturnType || type.IsConstructedReturnType)) {
IClass c = type.GetUnderlyingClass();
if (c != null && (c.ClassType == ClassType.Class || c.ClassType == ClassType.Interface || c.ClassType == ClassType.Delegate)) {
ReplaceCurrentNode(new PrimitiveExpression(null, "null"));
}
if (type != null && type.IsReferenceType == true) {
ReplaceCurrentNode(new PrimitiveExpression(null, "null"));
}
return null;
}
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
FixTypeReferenceCasing(variableDeclaration.TypeReference, variableDeclaration.StartLocation);
return base.VisitVariableDeclaration(variableDeclaration, data);
}
public override object VisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data)
{
FixTypeReferenceCasing(parameterDeclarationExpression.TypeReference, parameterDeclarationExpression.StartLocation);
return base.VisitParameterDeclarationExpression(parameterDeclarationExpression, data);
}
public override object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
{
FixTypeReferenceCasing(objectCreateExpression.CreateType, objectCreateExpression.StartLocation);
return base.VisitObjectCreateExpression(objectCreateExpression, data);
}
IReturnType FixTypeReferenceCasing(TypeReference tr, Location loc)
{
if (resolver.CompilationUnit == null) return null;
if (tr.IsNull) return null;
IReturnType rt = resolver.SearchType(tr.Type, tr.GenericTypes.Count, loc).Result;
var searchTypeResult = resolver.SearchType(tr.Type, tr.GenericTypes.Count, loc);
IReturnType rt = searchTypeResult.Result;
if (rt != null) {
IClass c = rt.GetUnderlyingClass();
if (c != null) {
if (string.Equals(tr.Type, c.Name, StringComparison.InvariantCultureIgnoreCase)) {
if (string.Equals(tr.Type, c.Name, StringComparison.OrdinalIgnoreCase)) {
tr.Type = c.Name;
} else if (string.Equals(tr.Type, c.FullyQualifiedName, StringComparison.OrdinalIgnoreCase)) {
tr.Type = c.FullyQualifiedName;
} else if (searchTypeResult.UsedUsing != null && !searchTypeResult.UsedUsing.HasAliases) {
tr.Type = c.FullyQualifiedName;
}
}
}
foreach (TypeReference arg in tr.GenericTypes) {
FixTypeReferenceCasing(arg, loc);
}
return rt;
}
@ -640,6 +672,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -640,6 +672,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
{
base.VisitForeachStatement(foreachStatement, data);
FixTypeReferenceCasing(foreachStatement.TypeReference, foreachStatement.StartLocation);
if (resolver.CompilationUnit == null)
return null;

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

@ -127,6 +127,51 @@ namespace ICSharpCode.SharpDevelop.Dom.Tests @@ -127,6 +127,51 @@ namespace ICSharpCode.SharpDevelop.Dom.Tests
Assert.AreEqual("ChrW(CByte(65))", converter.CSharpToVB("(char)(byte)65", out errors));
}
[Test]
public void FixItemAccess()
{
Assert.AreEqual("public void A(System.Collections.Generic.List<string> l)\n" +
"{\n" +
" l[0].ToString();\n" +
"}",
Normalize(converter.VBToCSharp("Sub A(l As Generic.List(Of String))\n" +
" l.Item(0).ToString()\n" +
"End Sub",
out errors)));
}
[Test]
public void ListAccessWithinForNextLoop()
{
Assert.AreEqual("public void A(System.Collections.Generic.List<string> l)\n" +
"{\n" +
" for (int i = 0; i <= l.Count - 1; i++) {\n" +
" sum += l[i].Length;\n" +
" }\n" +
"}",
Normalize(converter.VBToCSharp("Sub A(l As Generic.List(Of String))\n" +
" For i As Integer = 0 To l.Count - 1\n" +
" sum += l(i).Length\n" +
" Next\n" +
"End Sub",
out errors)));
}
[Test]
public void ListAccessOnField()
{
Assert.AreEqual("private System.Collections.Generic.List<System.Collections.Generic.List<string>> ParsedText = new System.Collections.Generic.List<System.Collections.Generic.List<string>>();\n" +
"public void A()\n" +
"{\n" +
" ParsedText[0].ToString();\n" +
"}",
Normalize(converter.VBToCSharp("Private ParsedText As New Generic.List(Of Generic.List(Of String))\n" +
"Sub A()\n" +
" ParsedText(0).ToString()\n" +
"End Sub",
out errors)));
}
string Normalize(string text)
{
return text.Replace("\t", " ").Replace("\r", "").Trim();

1
src/Setup/Files.wxs

@ -664,6 +664,7 @@ @@ -664,6 +664,7 @@
<File Source="..\..\data\templates\file\CSharp\CSharp.Web.WebControl.xft" Id="CSharp.Web.WebControl.xft" Name="CSharp.Web.WebControl.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.Web.WebForm.xft" Id="CSharp.Web.WebForm.xft" Name="CSharp.Web.WebForm.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.Web.WebService.xft" Id="CSharp.Web.WebService.xft" Name="CSharp.Web.WebService.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.Web.WebHandler.xft" Id="CSharp.Web.WebHandler.xft" Name="CSharp.Web.WebHandler.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.WPFFlowDocument.xft" Id="CSharp.WPFFlowDocument.xft" Name="CSharp.WPFFlowDocument.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.WPFPage.xft" Id="CSharp.WPFPage.xft" Name="CSharp.WPFPage.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.WPFPageFunction.xft" Id="CSharp.WPFPageFunction.xft" Name="CSharp.WPFPageFunction.xft" />

2
src/Tools/NUnit/NUnit Modification.txt

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
SharpDevelop is currently using a slighly modified version of NUnit 2.5.4.10098:
nunit.util.dll is modified: the hardcoded .NET version "4.0.21006" (.NET 4 Beta 2) was replaced with "4.0.30319" (.NET 4 RTM).

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; @@ -36,5 +36,5 @@ using System.Reflection;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.5.4")]
[assembly: AssemblyInformationalVersion("2.5.4")]
[assembly: AssemblyVersion("2.5.5")]
[assembly: AssemblyInformationalVersion("2.5.5")]

5
src/Tools/NUnit/nunit-console/ExtendedConsoleUi.cs

@ -224,8 +224,9 @@ namespace NUnit.ConsoleRunner @@ -224,8 +224,9 @@ namespace NUnit.ConsoleRunner
}
else
{
// TODO: Figure out a better way to handle "anonymous" packages
package = new TestPackage((string)options.Parameters[0], options.Parameters);
// TODO: Figure out a better way to handle "anonymous" packages
package = new TestPackage(null, options.Parameters);
package.AutoBinPath = true;
domainUsage = DomainUsage.Multiple;
}

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

Binary file not shown.
Loading…
Cancel
Save