Browse Source

Merge 3.0 to trunk.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4179 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts^2
Daniel Grunwald 16 years ago
parent
commit
0b92f024e5
  1. 112
      AddIns/ICSharpCode.SharpDevelop.addin
  2. BIN
      data/resources/StringResources.de.resources
  3. BIN
      data/resources/StringResources.es-mx.resources
  4. BIN
      data/resources/StringResources.es.resources
  5. BIN
      data/resources/StringResources.nl.resources
  6. 10
      data/templates/file/CSharp/CSharp.WPFFlowDocument.xft
  7. 43
      data/templates/file/CSharp/CSharp.WPFPage.xft
  8. 6
      data/templates/file/CSharp/CSharp.WPFResourceDictionary.xft
  9. 40
      data/templates/file/CSharp/CSharp.WPFUserControl.xft
  10. 44
      data/templates/file/CSharp/CSharp.WPFWindow.xft
  11. 14
      data/templates/file/Misc/EmptyHTMLFile.xft
  12. 18
      data/templates/project/CSharp/WPFApplication.xpt
  13. 24
      src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin
  14. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
  15. 71
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ConvertProjectToPythonProjectCommand.cs
  16. 5
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IComponentCreator.cs
  17. 23
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IsPythonRunningCondition.cs
  18. 108
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs
  19. 59
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeBuilder.cs
  20. 22
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDeserializer.cs
  21. 15
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs
  22. 30
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonContextMenuComponent.cs
  23. 23
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControl.cs
  24. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs
  25. 163
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponent.cs
  26. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponentFactory.cs
  27. 7
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerLoader.cs
  28. 72
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerRootComponent.cs
  29. 3
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonListViewComponent.cs
  30. 12
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonProject.cs
  31. 19
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs
  32. 117
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs
  33. 103
      src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInFileTestFixture.cs
  34. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ArrayCastConversionTestFixture.cs
  35. 42
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/BooleanConversionTestFixture.cs
  36. 22
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ConvertToPythonProjectCommandTestFixture.cs
  37. 53
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/GenericListConversionTestFixture.cs
  38. 120
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs
  39. 27
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/StaticMethodConversionTestFixture.cs
  40. 6
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/UsingStatementConversionTestFixture.cs
  41. 63
      src/AddIns/BackendBindings/Python/PythonBinding/Test/DebugPythonCommandTestFixture.cs
  42. 17
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateBackgroundWorkerTestFixture.cs
  43. 105
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateContextMenuStripTestFixture.cs
  44. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateEventLogTestFixture.cs
  45. 10
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateListViewItemTestFixture.cs
  46. 8
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMenuStripItemsTestFixture.cs
  47. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateNestedPanelFormTestFixture.cs
  48. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratePanelFormTestFixture.cs
  49. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateSimpleFormTestFixture.cs
  50. 17
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateTimerTestFixture.cs
  51. 65
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateToolTipFormTestFixture.cs
  52. 18
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratedControlOrderingTestFixture.cs
  53. 16
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GetInstanceFromDesignerLoaderTestFixture.cs
  54. 50
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadToolTipTestFixture.cs
  55. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/MissingInitializeComponentMethodTestFixture.cs
  56. 56
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonCodeBuilderTests.cs
  57. 13
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonControlFieldExpressionTests.cs
  58. 8
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs
  59. 77
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/RemoveMainMenuStripFromFormTestFixture.cs
  60. 15
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
  61. 82
      src/AddIns/BackendBindings/Python/PythonBinding/Test/RunPythonCommandTestFixture.cs
  62. 73
      src/AddIns/BackendBindings/Python/PythonBinding/Test/StopPythonCommandTestFixture.cs
  63. 7
      src/AddIns/BackendBindings/Python/PythonBinding/Test/TODO.txt
  64. 20
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedConvertProjectToPythonProjectCommand.cs
  65. 19
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedToolStripMenuItem.cs
  66. 11
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockComponentCreator.cs
  67. 178
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDebugger.cs
  68. 15
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  69. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs
  70. 52
      src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/IndentationTests.cs
  71. 2
      src/AddIns/Misc/CodeAnalysis/CodeAnalysis.addin
  72. 2
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin
  73. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  74. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Module.cs
  75. 11
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs
  76. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugEditAndContinueSnapshot.cs
  77. 25
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ISequentialStream.cs
  78. 43
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/IStream.cs
  79. 21
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_LARGE_INTEGER.cs
  80. 21
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_ULARGE_INTEGER.cs
  81. 33
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/tagSTATSTG.cs
  82. 11
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/ISequentialStream.cs
  83. 28
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/IStream.cs
  84. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedBinder.cs
  85. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs
  86. 4
      src/AddIns/Misc/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin
  87. 32
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfileProject.cs
  88. 2
      src/AddIns/Misc/SourceAnalysis/SourceAnalysis.addin
  89. 9
      src/AddIns/Misc/UnitTesting/Resources/UnitTestingOptionsPanel.xfrm
  90. 17
      src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs
  91. 29
      src/AddIns/Misc/UnitTesting/Src/TestResultsMonitor.cs
  92. 13
      src/AddIns/Misc/UnitTesting/Src/UnitTestingOptions.cs
  93. 5
      src/AddIns/Misc/UnitTesting/Src/UnitTestingOptionsPanel.cs
  94. 2
      src/AddIns/Misc/UnitTesting/Test/UnitTestCommandLineTests.cs
  95. 18
      src/AddIns/Misc/UnitTesting/Test/UnitTestingOptionsPanelTestFixture.cs
  96. 19
      src/AddIns/Misc/UnitTesting/Test/UnitTestingOptionsTestFixture.cs
  97. 72
      src/AddIns/Misc/UnitTesting/UnitTesting.addin
  98. BIN
      src/Libraries/Mono.Cecil/Mono.Cecil.dll
  99. 4
      src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs
  100. 2
      src/Main/Base/Project/Src/Editor/ITextEditor.cs
  101. Some files were not shown because too many files have changed in this diff Show More

112
AddIns/ICSharpCode.SharpDevelop.addin

@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
<Doozer name="EditAction" class="ICSharpCode.SharpDevelop.DefaultEditor.Codons.EditActionDoozer"/>
<Doozer name="SyntaxMode" class="ICSharpCode.SharpDevelop.DefaultEditor.Codons.SyntaxModeDoozer"/>
<Doozer name="BrowserSchemeExtension" class="ICSharpCode.SharpDevelop.BrowserDisplayBinding.SchemeExtensionDoozer"/>
<Doozer name="CodeCompletionBinding" class="ICSharpCode.SharpDevelop.Editor.CodeCompletionBindingDoozer"/>
<Doozer name="CodeCompletionBinding" class="ICSharpCode.SharpDevelop.Editor.CodeCompletion.CodeCompletionBindingDoozer"/>
<Doozer name="Debugger" class="ICSharpCode.SharpDevelop.Debugging.DebuggerDoozer"/>
<Doozer name="Directory" class="ICSharpCode.SharpDevelop.DirectoryDoozer"/>
<Doozer name="TaskBoundAdditionalLogger" class="ICSharpCode.SharpDevelop.Project.TaskBoundAdditionalLoggerDoozer"/>
@ -1675,6 +1675,53 @@ @@ -1675,6 +1675,53 @@
</ComplexCondition>
</MenuItem> <!-- end DEBUG menu -->
<MenuItem id = "Search" label = "${res:XML.MainMenu.SearchMenu}" type="Menu">
<MenuItem id = "SearchIncremental"
label = "${res:XML.MainMenu.SearchMenu.IncrementalSearch}"
shortcut = "Control|E"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.RunIncrementalSearch"/>
<MenuItem id = "SearchReverseIncremental"
label = "${res:XML.MainMenu.SearchMenu.ReverseIncrementalSearch}"
shortcut = "Control|Shift|E"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.RunReverseIncrementalSearch"/>
<MenuItem id = "SearchInFilesSeparator" type = "Separator" />
<!-- <Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.ITextEditorControlProvider" action="Disable"> -->
<MenuItem id = "ToggleBookmark"
label = "${res:XML.MainMenu.SearchMenu.ToggleBookmark}"
shortcut = "Control|F2"
icon = "Bookmarks.ToggleMark"
class = "ICSharpCode.SharpDevelop.Bookmarks.ToggleBookmark"/>
<MenuItem id = "PrevBookmark"
label = "${res:XML.MainMenu.SearchMenu.PrevBookmark}"
shortcut = "Alt|F2"
icon = "Bookmarks.GotoPrevInFile"
class = "ICSharpCode.SharpDevelop.Bookmarks.PrevBookmark"/>
<MenuItem id = "NextBookmark"
label = "${res:XML.MainMenu.SearchMenu.NextBookmark}"
shortcut = "F2"
icon = "Bookmarks.GotoNextInFile"
class = "ICSharpCode.SharpDevelop.Bookmarks.NextBookmark"/>
<MenuItem id = "ClearBookmarks"
label = "${res:XML.MainMenu.SearchMenu.ClrBookmark}"
icon = "Bookmarks.ClearAll"
class = "ICSharpCode.SharpDevelop.Bookmarks.ClearBookmarks"/>
<MenuItem id = "Separator2" type = "Separator" />
<MenuItem id = "GotoLineNr"
label = "${res:XML.MainMenu.SearchMenu.GotoLineNr}"
shortcut = "Control|G"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.GotoLineNumber"/>
<MenuItem id = "Separator3" type = "Separator" />
<MenuItem id = "GotoBrace"
label = "${res:XML.MainMenu.SearchMenu.GotoBrace}"
shortcut = "Control|B"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.GotoMatchingBrace"/>
<!-- </Condition> -->
</MenuItem>
<MenuItem id="Analysis" label="${res:XML.MainMenu.Analysis}" type="Menu">
<MenuItem id="Separator1" type="Separator" />
</MenuItem>
<MenuItem id = "Tools" label = "${res:XML.MainMenu.ToolMenu}" type="Menu">
<MenuItem id = "ToolBuilder" type="Builder" class = "ICSharpCode.SharpDevelop.Commands.ToolMenuBuilder" />
<MenuItem id = "Separator1" type = "Separator" />
@ -1796,6 +1843,8 @@ @@ -1796,6 +1843,8 @@
</MenuItem> <!-- end HELP menu -->
</Path> <!-- end Main Menu -->
<!-- create empty /Workspace/Tools path - it's included by the main menu -->
<Path name = "/Workspace/Tools"/>
<!-- TEXT EDITOR -->
@ -1942,59 +1991,6 @@ @@ -1942,59 +1991,6 @@
</Condition>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu">
<MenuItem id = "Search" insertafter ="View" insertbefore ="Tools" label = "${res:XML.MainMenu.SearchMenu}" type="Menu">
<MenuItem id = "SearchIncremental"
label = "${res:XML.MainMenu.SearchMenu.IncrementalSearch}"
shortcut = "Ctrl+E"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.RunIncrementalSearch"
/>
<MenuItem id = "SearchReverseIncremental"
label = "${res:XML.MainMenu.SearchMenu.ReverseIncrementalSearch}"
shortcut = "Ctrl+Shift+E"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.RunReverseIncrementalSearch" />
<MenuItem id = "SearchInFilesSeparator" type = "Separator" />
<!-- <Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.ITextEditorControlProvider" action="Disable"> -->
<MenuItem id = "ToggleBookmark"
label = "${res:XML.MainMenu.SearchMenu.ToggleBookmark}"
shortcut = "Ctrl+F2"
icon = "Bookmarks.ToggleMark"
class = "ICSharpCode.SharpDevelop.Bookmarks.ToggleBookmark"
command="SDSearchCommands.ToggleBookmark" />
<MenuItem id = "PrevBookmark"
label = "${res:XML.MainMenu.SearchMenu.PrevBookmark}"
shortcut = "Alt+F2"
icon = "Bookmarks.GotoPrevInFile"
class = "ICSharpCode.SharpDevelop.Bookmarks.PrevBookmark"
command="SDSearchCommands.PrevBookmark" />
<MenuItem id = "NextBookmark"
label = "${res:XML.MainMenu.SearchMenu.NextBookmark}"
shortcut = "F2"
icon = "Bookmarks.GotoNextInFile"
class = "ICSharpCode.SharpDevelop.Bookmarks.NextBookmark"
command="SDSearchCommands.NextBookmark" />
<MenuItem id = "ClearBookmarks"
label = "${res:XML.MainMenu.SearchMenu.ClrBookmark}"
icon = "Bookmarks.ClearAll"
class = "ICSharpCode.SharpDevelop.Bookmarks.ClearBookmarks"
command="SDSearchCommands.ClearBookmarks" />
<MenuItem id = "Separator2" type = "Separator" />
<MenuItem id = "GotoLineNr"
label = "${res:XML.MainMenu.SearchMenu.GotoLineNr}"
shortcut = "Ctrl+G"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.GotoLineNumber"
command="SDSearchCommands.GotoLineNumber" />
<MenuItem id = "Separator3" type = "Separator" />
<MenuItem id = "GotoBrace"
label = "${res:XML.MainMenu.SearchMenu.GotoBrace}"
shortcut = "Ctrl+B"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.GotoMatchingBrace"
command="SDSearchCommands.GotoBrace" />
<!-- </Condition> -->
</MenuItem>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Edit">
<MenuItem insertafter = "Delete" insertbefore = "SelectAll" id = "Separator2" type = "Separator" />
<MenuItem insertafter = "Separator2" insertbefore = "Separator3" id = "Format" label = "${res:XML.MainMenu.EditMenu.FormatMenu}" type="Menu">
@ -2288,14 +2284,6 @@ @@ -2288,14 +2284,6 @@
</MenuItem>
</Path>
<Path name="/SharpDevelop/Workbench/MainMenu">
<MenuItem id="QualityTools" label="Quality Tools" insertbefore="Tools" type="Menu">
<MenuItem id="Profiler" label="Profiler" type="Menu" />
<MenuItem id="Test" label="Test" type="Menu" />
<MenuItem id="Separator1" type="Separator" />
</MenuItem>
</Path>
<Path name = "/SharpDevelop/Views/ProjectBrowser/NodeBuilders">
<Class id = "DefaultBuilder"
class = "ICSharpCode.SharpDevelop.Project.DefaultDotNetNodeBuilder"/>

BIN
data/resources/StringResources.de.resources

Binary file not shown.

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

10
data/templates/file/CSharp/CSharp.WPFFlowDocument.xft

@ -22,11 +22,11 @@ @@ -22,11 +22,11 @@
-->
<Files>
<File name="${FullName}" language="XML" buildAction="Page"><![CDATA[<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
ColumnWidth="400" FontSize="14" FontFamily="Georgia"
>
<Paragraph>
</Paragraph>
ColumnWidth="400" FontSize="14" FontFamily="Georgia"
>
<Paragraph>
</Paragraph>
</FlowDocument>]]></File>
</Files>

43
data/templates/file/CSharp/CSharp.WPFPage.xft

@ -21,16 +21,16 @@ @@ -21,16 +21,16 @@
${Path} -> Full path of the file
-->
<Files>
<File name="${FullName}" language="XML" buildAction="Page"><![CDATA[<Page x:Class="${StandardNamespace}.${FileNameWithoutExtension}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="${FileNameWithoutExtension}"
>
<Grid>
</Grid>
<File name="${FullName}" language="XML" buildAction="Page"><![CDATA[<Page x:Class="${StandardNamespace}.${ClassName}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="${FileNameWithoutExtension}">
<Grid>
</Grid>
</Page>]]></File>
<File name="${FullName}.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[using System;
<File name="${FullName}.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[${StandardHeader.C#}
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
@ -39,24 +39,19 @@ using System.Windows.Data; @@ -39,24 +39,19 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ${StandardNamespace}
{
/// <summary>
/// Interaction logic for ${FileName}
/// </summary>
public partial class ${FileNameWithoutExtension} : Page
{
public ${FileNameWithoutExtension}()
{
InitializeComponent();
}
}
/// <summary>
/// Interaction logic for ${FileName}
/// </summary>
public partial class ${ClassName} : Page
{
public ${ClassName}()
{
InitializeComponent();
}
}
}]]></File>
</Files>

6
data/templates/file/CSharp/CSharp.WPFResourceDictionary.xft

@ -22,9 +22,9 @@ @@ -22,9 +22,9 @@
-->
<Files>
<File name="${FullName}" language="XML" buildAction="Page"><![CDATA[<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
</ResourceDictionary>]]></File>
</Files>

40
data/templates/file/CSharp/CSharp.WPFUserControl.xft

@ -21,14 +21,15 @@ @@ -21,14 +21,15 @@
${Path} -> Full path of the file
-->
<Files>
<File name="${FullName}" language="C#"><![CDATA[<UserControl x:Class="${StandardNamespace}.${FileNameWithoutExtension}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
</Grid>
<File name="${FullName}" language="C#"><![CDATA[<UserControl x:Class="${StandardNamespace}.${ClassName}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
</Grid>
</UserControl>]]></File>
<File name="${FullName}.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[using System;
<File name="${FullName}.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[${StandardHeader.C#}
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
@ -37,24 +38,19 @@ using System.Windows.Data; @@ -37,24 +38,19 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ${StandardNamespace}
{
/// <summary>
/// Interaction logic for ${FileName}
/// </summary>
public partial class ${FileNameWithoutExtension} : UserControl
{
public ${FileNameWithoutExtension}()
{
InitializeComponent();
}
}
/// <summary>
/// Interaction logic for ${FileName}
/// </summary>
public partial class ${ClassName} : UserControl
{
public ${ClassName}()
{
InitializeComponent();
}
}
}]]></File>
</Files>

44
data/templates/file/CSharp/CSharp.WPFWindow.xft

@ -21,16 +21,16 @@ @@ -21,16 +21,16 @@
${Path} -> Full path of the file
-->
<Files>
<File name="${FullName}" language="XML" buildAction="Page"><![CDATA[<Window x:Class="${StandardNamespace}.${FileNameWithoutExtension}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="${StandardNamespace}" Height="300" Width="300"
>
<Grid>
</Grid>
<File name="${FullName}" language="XML" buildAction="Page"><![CDATA[<Window x:Class="${StandardNamespace}.${ClassName}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="${StandardNamespace}" Height="300" Width="300">
<Grid>
</Grid>
</Window>]]></File>
<File name="${FullName}.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[using System;
<File name="${FullName}.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[${StandardHeader.C#}
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
@ -39,25 +39,19 @@ using System.Windows.Data; @@ -39,25 +39,19 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ${StandardNamespace}
{
/// <summary>
/// Interaction logic for ${FileName}
/// </summary>
public partial class ${FileNameWithoutExtension} : Window
{
public ${FileNameWithoutExtension}()
{
InitializeComponent();
}
}
/// <summary>
/// Interaction logic for ${FileName}
/// </summary>
public partial class ${ClassName} : Window
{
public ${ClassName}()
{
InitializeComponent();
}
}
}]]></File>
</Files>

14
data/templates/file/Misc/EmptyHTMLFile.xft

@ -12,13 +12,13 @@ @@ -12,13 +12,13 @@
<Files>
<File name="${FullName}" language="HTML"><![CDATA[
<Html>
<Head>
<Title></Title>
</Head>
<Body>
</Body>
</Html>]]>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>]]>
</File>
</Files>

18
data/templates/project/CSharp/WPFApplication.xpt

@ -43,13 +43,12 @@ @@ -43,13 +43,12 @@
<Files>
<File name="App.xaml" buildAction="ApplicationDefinition" language="XML"><![CDATA[<Application x:Class="${StandardNamespace}.App"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml"
>
<Application.Resources>
</Application.Resources>
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<Application.Resources>
</Application.Resources>
</Application>]]></File>
<File name="App.xaml.cs" SubType="Code" DependentUpon="App.xaml"><![CDATA[using System;
using System.Windows;
@ -79,7 +78,8 @@ namespace ${StandardNamespace} @@ -79,7 +78,8 @@ namespace ${StandardNamespace}
</Grid>
</Window>]]></File>
<File name="Window1.xaml.cs" SubType="Code" DependentUpon="Window1.xaml"><![CDATA[using System;
<File name="Window1.xaml.cs" SubType="Code" DependentUpon="Window1.xaml"><![CDATA[${StandardHeader.C#}
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
@ -88,8 +88,6 @@ using System.Windows.Data; @@ -88,8 +88,6 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ${StandardNamespace}
{

24
src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin

@ -55,21 +55,23 @@ @@ -55,21 +55,23 @@
insertbefore="Tools"
label="&amp;Python"
type="Menu">
<ComplexCondition action="Disable">
<Not>
<Condition name="IsPythonRunning"/>
</Not>
<Condition name="IsProcessRunning" isprocessrunning="False" isdebugging="False" action="Disable">
<MenuItem id="Run"
icon="Icons.16x16.RunProgramIcon"
class="ICSharpCode.PythonBinding.RunDebugPythonCommand"
label="${res:XML.MainMenu.RunMenu.Run}"
shortcut="Control|Shift|R"/>
<MenuItem id="RunWithoutDebugger"
icon="Icons.16x16.Debug.StartWithoutDebugging"
class="ICSharpCode.PythonBinding.RunPythonCommand"
label="&amp;Run"
shortcut="Ctrl+Shift+R"/>
</ComplexCondition>
<Condition name="IsPythonRunning" action="Disable">
label="${res:XML.MainMenu.DebugMenu.RunWithoutDebug}"
shortcut="Control|Shift|W"/>
</Condition>
<Condition name="IsProcessRunning" isdebugging="True" action="Disable">
<MenuItem id="Stop"
icon="Icons.16x16.Debug.StopProcess"
class="ICSharpCode.PythonBinding.StopPythonCommand"
label="&amp;Stop"/>
icon="Icons.16x16.StopProcess"
class="ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"
label="${res:XML.MainMenu.DebugMenu.Stop}"/>
</Condition>
</MenuItem>
</Condition>

4
src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj

@ -74,7 +74,6 @@ @@ -74,7 +74,6 @@
<Compile Include="Src\IMemberProvider.cs" />
<Compile Include="Src\IPadDescriptor.cs" />
<Compile Include="Src\IProcessRunner.cs" />
<Compile Include="Src\IsPythonRunningCondition.cs" />
<Compile Include="Src\ITextEditor.cs" />
<Compile Include="Src\NRefactoryToPythonConverter.cs" />
<Compile Include="Src\PythonAstWalker.cs" />
@ -87,6 +86,7 @@ @@ -87,6 +86,7 @@
<Compile Include="Src\PythonConsoleCompletionDataProvider.cs" />
<Compile Include="Src\PythonConsoleHost.cs" />
<Compile Include="Src\PythonConsolePad.cs" />
<Compile Include="Src\PythonContextMenuComponent.cs" />
<Compile Include="Src\PythonControlFieldExpression.cs" />
<Compile Include="Src\PythonDesignerComponent.cs" />
<Compile Include="Src\PythonDesignerComponentFactory.cs" />
@ -109,9 +109,9 @@ @@ -109,9 +109,9 @@
<Compile Include="Src\PythonProject.cs" />
<Compile Include="Src\PythonPropertyValueAssignment.cs" />
<Compile Include="Src\PythonResolver.cs" />
<Compile Include="Src\RunDebugPythonCommand.cs" />
<Compile Include="Src\RunPythonCommand.cs" />
<Compile Include="Src\StandardPythonModules.cs" />
<Compile Include="Src\StopPythonCommand.cs" />
<Compile Include="Src\PythonVariableResolver.cs" />
<Compile Include="Src\TextEditor.cs" />
<None Include="PythonBinding.addin">

71
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ConvertProjectToPythonProjectCommand.cs

@ -6,10 +6,14 @@ @@ -6,10 +6,14 @@
// </file>
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Converter;
using ICSharpCode.TextEditor.Document;
@ -42,9 +46,9 @@ namespace ICSharpCode.PythonBinding @@ -42,9 +46,9 @@ namespace ICSharpCode.PythonBinding
protected override IProject CreateProject(string targetProjectDirectory, IProject sourceProject)
{
// Add IronPython reference.
IProject targetProject = base.CreateProject(targetProjectDirectory, sourceProject);
PythonProject targetProject = (PythonProject)base.CreateProject(targetProjectDirectory, sourceProject);
IProjectItemListProvider targetProjectItems = targetProject as IProjectItemListProvider;
targetProjectItems.AddProjectItem(CreateIronPythonReference(targetProject));
targetProjectItems.AddProjectItem(CreateIronPythonReference(targetProject));
return targetProject;
}
@ -55,15 +59,31 @@ namespace ICSharpCode.PythonBinding @@ -55,15 +59,31 @@ namespace ICSharpCode.PythonBinding
{
NRefactoryToPythonConverter converter = NRefactoryToPythonConverter.Create(sourceItem.Include);
if (converter != null) {
targetItem.Include = Path.ChangeExtension(sourceItem.Include, ".py");
targetItem.Include = ChangeExtension(sourceItem.Include);
string code = GetParseableFileContent(sourceItem.FileName);
string pythonCode = converter.Convert(code);
PythonProject pythonTargetProject = (PythonProject)targetItem.Project;
if ((converter.EntryPointMethods.Count > 0) && !pythonTargetProject.HasMainFile) {
pythonTargetProject.AddMainFile(targetItem.Include);
}
SaveFile(targetItem.FileName, pythonCode, textEditorProperties.Encoding);
} else {
LanguageConverterConvertFile(sourceItem, targetItem);
}
}
/// <summary>
/// Adds the MainFile property since adding it in the CreateProject method would mean
/// it gets removed via the base class CopyProperties method.
/// </summary>
protected override void CopyProperties(IProject sourceProject, IProject targetProject)
{
base.CopyProperties(sourceProject, targetProject);
AddMainFile(sourceProject, (PythonProject)targetProject);
}
/// <summary>
/// Calls the LanguageConverter class method ConvertFile which copies the source file to the target
@ -90,11 +110,56 @@ namespace ICSharpCode.PythonBinding @@ -90,11 +110,56 @@ namespace ICSharpCode.PythonBinding
return ParserService.GetParseableFileContent(fileName);
}
/// <summary>
/// Gets the project content for the specified project.
/// </summary>
protected virtual IProjectContent GetProjectContent(IProject project)
{
return ParserService.GetProjectContent(project);
}
ReferenceProjectItem CreateIronPythonReference(IProject project)
{
ReferenceProjectItem reference = new ReferenceProjectItem(project, "IronPython");
reference.SetMetadata("HintPath", @"$(PythonBinPath)\IronPython.dll");
return reference;
}
/// <summary>
/// Adds a MainFile if the source project has a StartupObject.
/// </summary>
void AddMainFile(IProject sourceProject, PythonProject targetProject)
{
string startupObject = GetStartupObject(sourceProject);
if (startupObject != null) {
IClass c = FindClass(sourceProject, startupObject);
if (c != null) {
string fileName = FileUtility.GetRelativePath(sourceProject.Directory, c.CompilationUnit.FileName);
targetProject.AddMainFile(ChangeExtension(fileName));
}
}
}
string GetStartupObject(IProject project)
{
MSBuildBasedProject msbuildProject = project as MSBuildBasedProject;
if (msbuildProject != null) {
return msbuildProject.GetProperty(null, null, "StartupObject");
}
return null;
}
IClass FindClass(IProject project, string name)
{
return GetProjectContent(project).GetClass(name, 0);
}
/// <summary>
/// Changes the extension to ".py"
/// </summary>
static string ChangeExtension(string fileName)
{
return Path.ChangeExtension(fileName, ".py");
}
}
}

5
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IComponentCreator.cs

@ -41,6 +41,11 @@ namespace ICSharpCode.PythonBinding @@ -41,6 +41,11 @@ namespace ICSharpCode.PythonBinding
/// <returns>Null if the component cannot be found.</returns>
IComponent GetComponent(string name);
/// <summary>
/// Gets the RootComponent.
/// </summary>
IComponent RootComponent { get; }
/// <summary>
/// Creates a new instance of the object given its type.
/// </summary>

23
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IsPythonRunningCondition.cs

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
// <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 ICSharpCode.Core;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Indicates whether the python console is running.
/// </summary>
public class IsPythonRunningCondition : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
return RunPythonCommand.IsRunning;
}
}
}

108
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using ICSharpCode.NRefactory;
@ -33,6 +34,7 @@ namespace ICSharpCode.PythonBinding @@ -33,6 +34,7 @@ namespace ICSharpCode.PythonBinding
// references to fields or parameters.
List<ParameterDeclarationExpression> methodParameters = new List<ParameterDeclarationExpression>();
SupportedLanguage language;
List<MethodDeclaration> entryPointMethods;
public NRefactoryToPythonConverter(SupportedLanguage language)
{
@ -124,12 +126,21 @@ namespace ICSharpCode.PythonBinding @@ -124,12 +126,21 @@ namespace ICSharpCode.PythonBinding
// Convert to NRefactory code DOM.
CompilationUnit unit = GenerateCompilationUnit(source, language);
// Convert to Python code.
// Convert to Python code.3
entryPointMethods = new List<MethodDeclaration>();
codeBuilder = new StringBuilder();
unit.AcceptVisitor(this, null);
return codeBuilder.ToString().TrimEnd();
}
/// <summary>
/// Gets a list of possible entry point methods found when converting the
/// python source code.
/// </summary>
public ReadOnlyCollection<MethodDeclaration> EntryPointMethods {
get { return entryPointMethods.AsReadOnly(); }
}
/// <summary>
/// Converts from the NRefactory's binary operator type to a string.
@ -527,25 +538,6 @@ namespace ICSharpCode.PythonBinding @@ -527,25 +538,6 @@ namespace ICSharpCode.PythonBinding
return null;
}
/// <summary>
/// Saves the field information so it can be added to the
/// class constructor. This is done since python requires you
/// to initialize any class instance variables in the
/// __init__ method. For example, consider the equivalent
/// C# and Python code:
///
/// class Foo
/// {
/// private int i = 0;
/// }
///
/// class Foo:
/// def __init__(self):
/// i = 0
///
/// The only difference is that the initialization is moved to the
/// class constructor.
/// </summary>
public object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
return null;
@ -793,6 +785,9 @@ namespace ICSharpCode.PythonBinding @@ -793,6 +785,9 @@ namespace ICSharpCode.PythonBinding
if (IsStatic(methodDeclaration)) {
AppendIndentedLine(methodDeclaration.Name + " = staticmethod(" + methodDeclaration.Name + ")");
AppendNewLine();
// Save Main entry point method.
SaveMethodIfMainEntryPoint(methodDeclaration);
}
return null;
@ -820,7 +815,11 @@ namespace ICSharpCode.PythonBinding @@ -820,7 +815,11 @@ namespace ICSharpCode.PythonBinding
/// </summary>
public object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
{
Append(objectCreateExpression.CreateType.Type + "(");
Append(objectCreateExpression.CreateType.Type);
if (IsGenericType(objectCreateExpression)) {
AppendGenericTypes(objectCreateExpression);
}
Append("(");
// Add parameters.
bool firstParameter = true;
@ -891,8 +890,10 @@ namespace ICSharpCode.PythonBinding @@ -891,8 +890,10 @@ namespace ICSharpCode.PythonBinding
public object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
{
if (primitiveExpression.LiteralFormat == LiteralFormat.None) {
if (primitiveExpression.Value == null) {
Append("None");
} else if (primitiveExpression.Value is Boolean) {
Append(primitiveExpression.Value.ToString());
} else {
Append(primitiveExpression.StringValue);
}
@ -1169,7 +1170,7 @@ namespace ICSharpCode.PythonBinding @@ -1169,7 +1170,7 @@ namespace ICSharpCode.PythonBinding
{
// Add import statements for each using.
foreach (Using @using in usingDeclaration.Usings) {
AppendIndentedLine("import " + @using.Name);
AppendIndentedLine("from " + @using.Name + " import *");
}
return null;
}
@ -1476,25 +1477,7 @@ namespace ICSharpCode.PythonBinding @@ -1476,25 +1477,7 @@ namespace ICSharpCode.PythonBinding
return (assignmentExpression.Op == AssignmentOperatorType.Subtract) &&
(assignmentExpression.Left is MemberReferenceExpression);
}
/// <summary>
/// Creates an assign statement with the right hand side of the assignment using a binary operator.
/// </summary>
object CreateAssignmentStatementWithBinaryOperatorExpression(AssignmentExpression assignmentExpression, string binaryOperatorType)
{
// Create the left hand side of the assignment.
assignmentExpression.Left.AcceptVisitor(this, null);
Append(" = ");
// Create the right hand side of the assignment.
assignmentExpression.Left.AcceptVisitor(this, null);
Append(" " + binaryOperatorType + " ");
assignmentExpression.Right.AcceptVisitor(this, null);
return null;
}
void Append(string code)
{
codeBuilder.Append(code);
@ -1700,6 +1683,45 @@ namespace ICSharpCode.PythonBinding @@ -1700,6 +1683,45 @@ namespace ICSharpCode.PythonBinding
return SupportedLanguage.VBNet;
}
return SupportedLanguage.CSharp;
}
}
/// <summary>
/// Saves the method declaration if it is a main entry point.
/// </summary>
void SaveMethodIfMainEntryPoint(MethodDeclaration method)
{
if (method.Name == "Main") {
entryPointMethods.Add(method);
}
}
/// <summary>
/// Returns true if the object being created is a generic.
/// </summary>
static bool IsGenericType(ObjectCreateExpression expression)
{
return expression.CreateType.GenericTypes.Count > 0;
}
/// <summary>
/// Appends the types used when creating a generic surrounded by square brackets.
/// </summary>
void AppendGenericTypes(ObjectCreateExpression expression)
{
Append("[");
List<TypeReference> typeRefs = expression.CreateType.GenericTypes;
for (int i = 0; i < typeRefs.Count; ++i) {
if (i != 0) {
Append(", ");
}
TypeReference typeRef = typeRefs[i];
if (typeRef.IsArrayType) {
Append("System.Array[" + typeRef.Type + "]");
} else {
Append(typeRef.Type);
}
}
Append("]");
}
}
}

59
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeBuilder.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.ComponentModel;
using System.Text;
namespace ICSharpCode.PythonBinding
@ -15,11 +16,17 @@ namespace ICSharpCode.PythonBinding @@ -15,11 +16,17 @@ namespace ICSharpCode.PythonBinding
StringBuilder codeBuilder = new StringBuilder();
string indentString = "\t";
int indent;
bool insertedCreateComponentsContainer;
public PythonCodeBuilder()
{
}
public PythonCodeBuilder(int initialIndent)
{
indent = initialIndent;
}
/// <summary>
/// Gets or sets the string used for indenting.
/// </summary>
@ -57,12 +64,38 @@ namespace ICSharpCode.PythonBinding @@ -57,12 +64,38 @@ namespace ICSharpCode.PythonBinding
/// </summary>
public void AppendIndented(string text)
{
for (int i = 0; i < indent; ++i) {
codeBuilder.Append(indentString);
}
codeBuilder.Append(GetIndentString());
codeBuilder.Append(text);
}
/// <summary>
/// Inserts a new line at the start of the code before everything else.
/// </summary>
public void InsertIndentedLine(string text)
{
text = GetIndentString() + text + "\r\n";
codeBuilder.Insert(0, text, 1);
}
/// <summary>
/// Inserts the following line of code before all the other lines of code:
///
/// "self._components = System.ComponentModel.Container()"
///
/// This line will only be inserted once. Multiple calls to this method will only result in one
/// line of code being inserted.
/// </summary>
public void InsertCreateComponentsContainer()
{
if (!insertedCreateComponentsContainer) {
InsertIndentedLine("self._components = " + typeof(Container).FullName + "()");
insertedCreateComponentsContainer = true;
}
}
/// <summary>
/// Inserts the text with a carriage return and newline at the end.
/// </summary>
public void AppendIndentedLine(string text)
{
AppendIndented(text + "\r\n");
@ -77,5 +110,25 @@ namespace ICSharpCode.PythonBinding @@ -77,5 +110,25 @@ namespace ICSharpCode.PythonBinding
{
indent--;
}
public int Indent {
get { return indent; }
}
/// <summary>
/// Gets the length of the current code string.
/// </summary>
public int Length {
get { return codeBuilder.Length; }
}
string GetIndentString()
{
StringBuilder currentIndentString = new StringBuilder();
for (int i = 0; i < indent; ++i) {
currentIndentString.Append(indentString);
}
return currentIndentString.ToString();
}
}
}

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

@ -36,12 +36,15 @@ namespace ICSharpCode.PythonBinding @@ -36,12 +36,15 @@ namespace ICSharpCode.PythonBinding
ConstantExpression constantExpression = a.Expression as ConstantExpression;
MemberExpression memberExpression = a.Expression as MemberExpression;
CallExpression callExpression = a.Expression as CallExpression;
NameExpression nameExpression = a.Expression as NameExpression;
if (constantExpression != null) {
args.Add(constantExpression.Value);
} else if (memberExpression != null) {
args.Add(Deserialize(memberExpression));
} else if(callExpression != null) {
} else if (callExpression != null) {
args.Add(Deserialize(callExpression));
} else if (nameExpression != null) {
args.Add(Deserialize(nameExpression));
}
}
return args;
@ -71,7 +74,7 @@ namespace ICSharpCode.PythonBinding @@ -71,7 +74,7 @@ namespace ICSharpCode.PythonBinding
}
return null;
}
/// <summary>
/// Deserializes expressions of the form:
///
@ -85,7 +88,7 @@ namespace ICSharpCode.PythonBinding @@ -85,7 +88,7 @@ namespace ICSharpCode.PythonBinding
int value = Convert.ToInt32(lhs) | Convert.ToInt32(rhs);
return Enum.ToObject(lhs.GetType(), value);
}
/// <summary>
/// Deserializes expressions of the form:
///
@ -127,6 +130,19 @@ namespace ICSharpCode.PythonBinding @@ -127,6 +130,19 @@ namespace ICSharpCode.PythonBinding
return componentCreator.GetInstance(PythonControlFieldExpression.GetVariableName(field.MemberName));
}
/// <summary>
/// Deserializes expressions of the form:
///
/// 1) self
/// </summary>
object Deserialize(NameExpression nameExpression)
{
if ("self" == nameExpression.Name.ToString().ToLowerInvariant()) {
return componentCreator.RootComponent;
}
return null;
}
Type GetType(PythonControlFieldExpression field)
{
return componentCreator.GetType(PythonControlFieldExpression.GetPrefix(field.FullMemberName));

15
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs

@ -283,16 +283,7 @@ namespace ICSharpCode.PythonBinding @@ -283,16 +283,7 @@ namespace ICSharpCode.PythonBinding
/// </summary>
object GetPropertyValueFromAssignmentRhs(MemberExpression memberExpression)
{
object propertyValue = deserializer.Deserialize(memberExpression);
if (propertyValue == null) {
PythonControlFieldExpression field = PythonControlFieldExpression.Create(memberExpression);
if (field.MemberName.Length > 0) {
propertyValue = GetComponent(PythonControlFieldExpression.GetVariableName(field.MemberName));
} else {
propertyValue = field.FullMemberName;
}
}
return propertyValue;
return deserializer.Deserialize(memberExpression);
}
/// <summary>
@ -358,8 +349,8 @@ namespace ICSharpCode.PythonBinding @@ -358,8 +349,8 @@ namespace ICSharpCode.PythonBinding
// Execute the method on the object.
if (member != null) {
object parameter = deserializer.Deserialize(node.Args[0].Expression);
member.GetType().InvokeMember(field.MethodName, BindingFlags.InvokeMethod, Type.DefaultBinder, member, new object[] {parameter});
object[] args = deserializer.GetArguments(node).ToArray();
member.GetType().InvokeMember(field.MethodName, BindingFlags.InvokeMethod, Type.DefaultBinder, member, args);
}
}

30
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonContextMenuComponent.cs

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
// <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;
namespace ICSharpCode.PythonBinding
{
public class PythonContextMenuComponent : PythonDesignerComponent
{
public PythonContextMenuComponent(PythonDesignerComponent parent, IComponent component)
: base(parent, component)
{
}
/// <summary>
/// Always ignore the OwnerItem property. This is set if the context menu is open and displayed in
/// the designer when the user switches to the source tab. This method works around the problem by
/// ignoring the OwnerItem property when generating the form designer code.
/// </summary>
protected override bool IgnoreProperty(PropertyDescriptor property)
{
return property.Name == "OwnerItem";
}
}
}

23
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControl.cs

@ -43,15 +43,19 @@ namespace ICSharpCode.PythonBinding @@ -43,15 +43,19 @@ namespace ICSharpCode.PythonBinding
/// </summary>
public string GenerateInitializeComponentMethod(Control control)
{
PythonCodeBuilder methodCodeBuilder = new PythonCodeBuilder();
methodCodeBuilder.IndentString = indentString;
methodCodeBuilder.AppendIndentedLine("def InitializeComponent(self):");
codeBuilder = new PythonCodeBuilder();
codeBuilder.IndentString = indentString;
codeBuilder.AppendIndentedLine("def InitializeComponent(self):");
codeBuilder.IncreaseIndent();
GenerateInitializeComponentMethodBodyInternal(control);
return codeBuilder.ToString();
methodCodeBuilder.Append(codeBuilder.ToString());
return methodCodeBuilder.ToString();
}
/// <summary>
@ -73,20 +77,13 @@ namespace ICSharpCode.PythonBinding @@ -73,20 +77,13 @@ namespace ICSharpCode.PythonBinding
void GenerateInitializeComponentMethodBodyInternal(Control control)
{
PythonDesignerRootComponent rootDesignerComponent = PythonDesignerComponentFactory.CreateDesignerRootComponent(control);
if (rootDesignerComponent.HasNonVisualChildComponents()) {
rootDesignerComponent.AppendCreateComponentsContainer(codeBuilder);
rootDesignerComponent.AppendCreateNonVisualComponents(codeBuilder);
rootDesignerComponent.AppendNonVisualComponentsBeginInit(codeBuilder);
}
rootDesignerComponent.AppendCreateChildComponents(codeBuilder);
rootDesignerComponent.AppendCreateContainerComponents(codeBuilder);
rootDesignerComponent.AppendNonVisualComponentsBeginInit(codeBuilder);
rootDesignerComponent.AppendChildComponentsSuspendLayout(codeBuilder);
rootDesignerComponent.AppendSuspendLayout(codeBuilder);
rootDesignerComponent.AppendNonVisualComponents(codeBuilder);
rootDesignerComponent.AppendComponent(codeBuilder);
rootDesignerComponent.AppendChildComponentsResumeLayout(codeBuilder);
if (rootDesignerComponent.HasNonVisualChildComponents()) {
rootDesignerComponent.AppendNonVisualComponentsEndInit(codeBuilder);
}
rootDesignerComponent.AppendNonVisualComponentsEndInit(codeBuilder);
rootDesignerComponent.AppendResumeLayout(codeBuilder);
}
}

2
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs

@ -261,6 +261,8 @@ namespace ICSharpCode.PythonBinding @@ -261,6 +261,8 @@ namespace ICSharpCode.PythonBinding
int endIndex = name.IndexOf('.');
if (endIndex > 0) {
return GetVariableName(name.Substring(0, endIndex));
} else if (name.StartsWith("_")) {
return GetVariableName(name);
}
return String.Empty;
}

163
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponent.cs

@ -213,13 +213,18 @@ namespace ICSharpCode.PythonBinding @@ -213,13 +213,18 @@ namespace ICSharpCode.PythonBinding
}
return null;
}
/// <summary>
/// Appends code that creates an instance of the component.
/// </summary>
public virtual void AppendCreateInstance(PythonCodeBuilder codeBuilder)
{
AppendComponentCreation(codeBuilder, component);
if (HasIContainerConstructor()) {
codeBuilder.InsertCreateComponentsContainer();
AppendCreateInstance(codeBuilder, "self._components");
} else {
AppendComponentCreation(codeBuilder, component);
}
}
public void AppendCreateInstance(PythonCodeBuilder codeBuilder, string parameters)
@ -235,14 +240,34 @@ namespace ICSharpCode.PythonBinding @@ -235,14 +240,34 @@ namespace ICSharpCode.PythonBinding
AppendCreateChildComponents(codeBuilder, GetChildComponents());
}
/// <summary>
/// Adds all the components that have been added to the design surface container.
/// </summary>
public void AppendCreateContainerComponents(PythonCodeBuilder codeBuilder)
{
AppendCreateChildComponents(codeBuilder, GetContainerComponents());
}
/// <summary>
/// Gets all the components added to the design surface container excluding the
/// root component.
/// </summary>
public PythonDesignerComponent[] GetContainerComponents()
{
List<PythonDesignerComponent> components = new List<PythonDesignerComponent>();
ComponentCollection containerComponents = Component.Site.Container.Components;
for (int i = 1; i < containerComponents.Count; ++i) {
components.Add(PythonDesignerComponentFactory.CreateDesignerComponent(this, containerComponents[i]));
}
return components.ToArray();
}
/// <summary>
/// Appends the component's properties.
/// </summary>
public virtual void AppendComponent(PythonCodeBuilder codeBuilder)
{
AppendComment(codeBuilder);
AppendComponentProperties(codeBuilder);
AppendChildComponentProperties(codeBuilder);
}
/// <summary>
@ -366,37 +391,15 @@ namespace ICSharpCode.PythonBinding @@ -366,37 +391,15 @@ namespace ICSharpCode.PythonBinding
{
codeBuilder.AppendIndentedLine("self._" + component.Site.Name + " = " + component.GetType().FullName + "(" + parameters + ")");
}
/// <summary>
/// Generates the code for the component's properties.
/// </summary>
public void AppendComponentProperties(PythonCodeBuilder codeBuilder)
{
AppendComponentProperties(codeBuilder, true, false, false);
AppendComponentProperties(codeBuilder, true, true);
}
/// <summary>
/// Appends the properties of any component that is contained in a collection property that is
/// marked as DesignerSerializationVisibility.Content.
/// </summary>
public void AppendChildComponentProperties(PythonCodeBuilder codeBuilder)
{
foreach (PropertyDescriptor property in PythonDesignerComponent.GetSerializableContentProperties(component)) {
object propertyCollection = property.GetValue(component);
ICollection collection = propertyCollection as ICollection;
if (collection != null) {
foreach (object childObject in collection) {
IComponent childComponent = childObject as IComponent;
if (childComponent != null) {
PythonDesignerComponent designerComponent = PythonDesignerComponentFactory.CreateDesignerComponent(this, childComponent);
if (designerComponent.IsSited) {
designerComponent.AppendComponentProperties(codeBuilder, true, true, true);
}
}
}
}
}
}
/// <summary>
/// Generates python code for an object's properties when the object is not an IComponent.
/// </summary>
@ -444,6 +447,14 @@ namespace ICSharpCode.PythonBinding @@ -444,6 +447,14 @@ namespace ICSharpCode.PythonBinding
return typeName[0].ToString().ToLowerInvariant() + typeName.Substring(1) + count;
}
/// <summary>
/// Appends an array as a parameter and its associated method call.
/// </summary>
public virtual void AppendMethodCallWithArrayParameter(PythonCodeBuilder codeBuilder, string propertyOwnerName, object propertyOwner, PropertyDescriptor propertyDescriptor)
{
AppendMethodCallWithArrayParameter(codeBuilder, propertyOwnerName, propertyOwner, propertyDescriptor, false);
}
/// <summary>
/// Appends an array as a parameter and its associated method call.
/// </summary>
@ -451,7 +462,7 @@ namespace ICSharpCode.PythonBinding @@ -451,7 +462,7 @@ namespace ICSharpCode.PythonBinding
/// Looks for the AddRange method first. If that does not exist or is hidden from the designer the
/// Add method is looked for.
/// </remarks>
public static void AppendMethodCallWithArrayParameter(PythonCodeBuilder codeBuilder, string propertyOwnerName, object propertyOwner, PropertyDescriptor propertyDescriptor)
public static void AppendMethodCallWithArrayParameter(PythonCodeBuilder codeBuilder, string propertyOwnerName, object propertyOwner, PropertyDescriptor propertyDescriptor, bool reverse)
{
IComponent component = propertyOwner as IComponent;
ICollection collectionProperty = propertyDescriptor.GetValue(propertyOwner) as ICollection;
@ -463,6 +474,9 @@ namespace ICSharpCode.PythonBinding @@ -463,6 +474,9 @@ namespace ICSharpCode.PythonBinding
} else {
MethodInfo addMethod = GetAddSerializationMethod(collectionProperty);
ParameterInfo[] parameters = addMethod.GetParameters();
if (reverse) {
collectionProperty = ReverseCollection(collectionProperty);
}
foreach (object item in collectionProperty) {
IComponent collectionComponent = item as IComponent;
if (PythonDesignerComponent.IsSitedComponent(collectionComponent)) {
@ -478,16 +492,18 @@ namespace ICSharpCode.PythonBinding @@ -478,16 +492,18 @@ namespace ICSharpCode.PythonBinding
/// </summary>
public void AppendProperty(PythonCodeBuilder codeBuilder, string propertyOwnerName, object obj, PropertyDescriptor propertyDescriptor)
{
object propertyValue = propertyDescriptor.GetValue(obj);
if (propertyValue == null) {
return;
}
if (propertyDescriptor.SerializationVisibility == DesignerSerializationVisibility.Visible) {
object propertyValue = propertyDescriptor.GetValue(obj);
ExtenderProvidedPropertyAttribute extender = GetExtenderAttribute(propertyDescriptor);
if (extender != null) {
AppendExtenderProperty(codeBuilder, propertyOwnerName, extender, propertyDescriptor, propertyValue);
} else if (propertyDescriptor.SerializationVisibility == DesignerSerializationVisibility.Visible) {
string propertyName = propertyOwnerName + "." + propertyDescriptor.Name;
Control control = propertyValue as Control;
if (control != null) {
codeBuilder.AppendIndentedLine(propertyName + " = " + GetControlReference(control));
string controlRef = GetControlReference(control);
if (controlRef != null) {
codeBuilder.AppendIndentedLine(propertyName + " = " + controlRef);
}
} else {
codeBuilder.AppendIndentedLine(propertyName + " = " + PythonPropertyValueAssignment.ToString(propertyValue));
}
@ -496,6 +512,22 @@ namespace ICSharpCode.PythonBinding @@ -496,6 +512,22 @@ namespace ICSharpCode.PythonBinding
AppendMethodCallWithArrayParameter(codeBuilder, propertyOwnerName, obj, propertyDescriptor);
}
}
/// <summary>
/// Appends an extender provider property.
/// </summary>
public void AppendExtenderProperty(PythonCodeBuilder codeBuilder, string propertyOwnerName, ExtenderProvidedPropertyAttribute extender, PropertyDescriptor propertyDescriptor, object propertyValue)
{
IComponent component = extender.Provider as IComponent;
codeBuilder.AppendIndented("self._" + component.Site.Name);
codeBuilder.Append(".Set" + propertyDescriptor.Name);
codeBuilder.Append("(");
codeBuilder.Append(propertyOwnerName);
codeBuilder.Append(", ");
codeBuilder.Append(PythonPropertyValueAssignment.ToString(propertyValue));
codeBuilder.Append(")");
codeBuilder.AppendLine();
}
/// <summary>
/// Appends the properties of the object to the code builder.
@ -503,7 +535,9 @@ namespace ICSharpCode.PythonBinding @@ -503,7 +535,9 @@ namespace ICSharpCode.PythonBinding
public void AppendProperties(PythonCodeBuilder codeBuilder, string propertyOwnerName, object obj)
{
foreach (PropertyDescriptor property in GetSerializableProperties(obj)) {
AppendProperty(codeBuilder, propertyOwnerName, obj, property);
if (!IgnoreProperty(property)) {
AppendProperty(codeBuilder, propertyOwnerName, obj, property);
}
}
}
@ -518,18 +552,19 @@ namespace ICSharpCode.PythonBinding @@ -518,18 +552,19 @@ namespace ICSharpCode.PythonBinding
/// <summary>
/// Generates python code for the component.
/// </summary>
public void AppendComponentProperties(PythonCodeBuilder codeBuilder, bool addComponentNameToProperty, bool addChildComponentProperties, bool addComment)
public void AppendComponentProperties(PythonCodeBuilder codeBuilder, bool addComponentNameToProperty, bool addComment)
{
if (addComment) {
AppendComment(codeBuilder);
}
AppendProperties(codeBuilder);
AppendEventHandlers(codeBuilder, eventBindingService);
PythonCodeBuilder propertiesBuilder = new PythonCodeBuilder(codeBuilder.Indent);
propertiesBuilder.IndentString = codeBuilder.IndentString;
AppendProperties(propertiesBuilder);
AppendEventHandlers(propertiesBuilder, eventBindingService);
if (addChildComponentProperties) {
AppendChildComponentProperties(codeBuilder);
// Add comment if we have added some properties or event handlers.
if (addComment && propertiesBuilder.Length > 0) {
AppendComment(codeBuilder);
}
codeBuilder.Append(propertiesBuilder.ToString());
}
/// <summary>
@ -588,6 +623,14 @@ namespace ICSharpCode.PythonBinding @@ -588,6 +623,14 @@ namespace ICSharpCode.PythonBinding
get { return component; }
}
/// <summary>
/// Return true to prevent the property from being added to the generated code.
/// </summary>
protected virtual bool IgnoreProperty(PropertyDescriptor property)
{
return false;
}
static bool HasSitedComponents(PythonDesignerComponent[] components)
{
foreach (PythonDesignerComponent component in components) {
@ -603,7 +646,6 @@ namespace ICSharpCode.PythonBinding @@ -603,7 +646,6 @@ namespace ICSharpCode.PythonBinding
foreach (PythonDesignerComponent designerComponent in childComponents) {
if (designerComponent.IsSited) {
designerComponent.AppendCreateInstance(codeBuilder);
designerComponent.AppendCreateChildComponents(codeBuilder);
}
}
}
@ -687,8 +729,31 @@ namespace ICSharpCode.PythonBinding @@ -687,8 +729,31 @@ namespace ICSharpCode.PythonBinding
{
if (IsRootComponent(control)) {
return "self";
} else if (!String.IsNullOrEmpty(control.Name)) {
return "self._" + control.Name;
}
return null;
}
static ExtenderProvidedPropertyAttribute GetExtenderAttribute(PropertyDescriptor property)
{
foreach (Attribute attribute in property.Attributes) {
ExtenderProvidedPropertyAttribute extenderAttribute = attribute as ExtenderProvidedPropertyAttribute;
if (extenderAttribute != null) {
return extenderAttribute;
}
}
return null;
}
static ICollection ReverseCollection(ICollection collection)
{
List<object> reversedCollection = new List<object>();
foreach (object item in collection) {
reversedCollection.Add(item);
}
return "self._" + control.Name;
reversedCollection.Reverse();
return reversedCollection;
}
}
}

4
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponentFactory.cs

@ -31,7 +31,9 @@ namespace ICSharpCode.PythonBinding @@ -31,7 +31,9 @@ namespace ICSharpCode.PythonBinding
public static PythonDesignerComponent CreateDesignerComponent(PythonDesignerComponent parent, IComponent component)
{
if (component is ListView) {
return new PythonListViewComponent(parent,component);
return new PythonListViewComponent(parent, component);
} else if (component is ContextMenuStrip) {
return new PythonContextMenuComponent(parent, component);
}
return new PythonDesignerComponent(parent, component);
}

7
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerLoader.cs

@ -77,6 +77,13 @@ namespace ICSharpCode.PythonBinding @@ -77,6 +77,13 @@ namespace ICSharpCode.PythonBinding
return component;
}
/// <summary>
/// Gets the root component.
/// </summary>
public IComponent RootComponent {
get { return base.LoaderHost.RootComponent; }
}
/// <summary>
/// Creates a new instance of the specified type.
/// </summary>

72
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerRootComponent.cs

@ -41,37 +41,14 @@ namespace ICSharpCode.PythonBinding @@ -41,37 +41,14 @@ namespace ICSharpCode.PythonBinding
public override void AppendComponent(PythonCodeBuilder codeBuilder)
{
// Add the child components first.
foreach (PythonDesignerComponent component in GetChildComponents()) {
foreach (PythonDesignerComponent component in GetContainerComponents()) {
component.AppendComponent(codeBuilder);
}
// Add root component
AppendComponentProperties(codeBuilder, false, false, true);
AppendComponentProperties(codeBuilder, false, true);
}
/// <summary>
/// Gets the child components in reverse order since the forms designer has them reversed.
/// </summary>
public override PythonDesignerComponent[] GetChildComponents()
{
PythonDesignerComponent[] components = base.GetChildComponents();
Array.Reverse(components);
return components;
}
/// <summary>
/// Returns true if non-visual components (e.g. Timer) are associated with this root component.
/// </summary>
public bool HasNonVisualChildComponents()
{
foreach (IComponent containerComponent in Component.Site.Container.Components) {
if (IsNonVisualComponent(containerComponent)) {
return true;
}
}
return false;
}
public PythonDesignerComponent[] GetNonVisualChildComponents()
{
List<PythonDesignerComponent> components = new List<PythonDesignerComponent>();
@ -83,39 +60,7 @@ namespace ICSharpCode.PythonBinding @@ -83,39 +60,7 @@ namespace ICSharpCode.PythonBinding
}
return components.ToArray();
}
/// <summary>
/// Appends an expression that creates an instance of the Container to hold non-visual components
/// </summary>
public void AppendCreateComponentsContainer(PythonCodeBuilder codeBuilder)
{
codeBuilder.AppendIndentedLine("self._components = " + typeof(Container).FullName + "()");
}
/// <summary>
/// Appends code to create all the non-visual component.
/// </summary>
public void AppendCreateNonVisualComponents(PythonCodeBuilder codeBuilder)
{
foreach (PythonDesignerComponent component in GetNonVisualChildComponents()) {
if (component.HasIContainerConstructor()) {
component.AppendCreateInstance(codeBuilder, "self._components");
} else {
component.AppendCreateInstance(codeBuilder);
}
}
}
/// <summary>
/// Appends code to set all the non-visual component properties.
/// </summary>
public void AppendNonVisualComponents(PythonCodeBuilder codeBuilder)
{
foreach (PythonDesignerComponent component in GetNonVisualChildComponents()) {
component.AppendComponent(codeBuilder);
}
}
/// <summary>
/// Adds BeginInit method call for any non-visual components that implement the
/// System.ComponentModel.ISupportInitialize interface.
@ -142,5 +87,14 @@ namespace ICSharpCode.PythonBinding @@ -142,5 +87,14 @@ namespace ICSharpCode.PythonBinding
}
}
}
/// <summary>
/// Reverses the ordering when adding items to the Controls collection.
/// </summary>
public override void AppendMethodCallWithArrayParameter(PythonCodeBuilder codeBuilder, string propertyOwnerName, object propertyOwner, PropertyDescriptor propertyDescriptor)
{
bool reverse = propertyDescriptor.Name == "Controls";
AppendMethodCallWithArrayParameter(codeBuilder, propertyOwnerName, propertyOwner, propertyDescriptor, reverse);
}
}
}

3
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonListViewComponent.cs

@ -48,8 +48,7 @@ namespace ICSharpCode.PythonBinding @@ -48,8 +48,7 @@ namespace ICSharpCode.PythonBinding
{
AppendComment(codeBuilder);
AppendListViewItemProperties(codeBuilder);
AppendComponentProperties(codeBuilder);
AppendChildComponentProperties(codeBuilder);
AppendComponentProperties(codeBuilder, true, false);
}
/// <summary>

12
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonProject.cs

@ -61,6 +61,18 @@ namespace ICSharpCode.PythonBinding @@ -61,6 +61,18 @@ namespace ICSharpCode.PythonBinding
return base.GetDefaultItemType(fileName);
}
public void AddMainFile(string fileName)
{
SetProperty(null, null, "MainFile", fileName, PropertyStorageLocations.Base, true);
}
/// <summary>
/// Returns true if a main file is already defined for this project.
/// </summary>
public bool HasMainFile {
get { return GetProperty(null, null, "MainFile") != null; }
}
protected override void Create(ProjectCreateInformation information)
{
base.Create(information);

19
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/StopPythonCommand.cs → src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
@ -7,26 +7,23 @@ @@ -7,26 +7,23 @@
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Util;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Stops the Python console that is currently running.
/// </summary>
public class StopPythonCommand : AbstractMenuCommand
public class RunDebugPythonCommand : RunPythonCommand
{
public StopPythonCommand()
public RunDebugPythonCommand(IWorkbench workbench, AddInOptions options, IDebugger debugger)
: base(workbench, options, debugger)
{
Debug = true;
}
public override void Run()
public RunDebugPythonCommand()
: this(WorkbenchSingleton.Workbench, new AddInOptions(), DebuggerService.CurrentDebugger)
{
RunPythonCommand runCommand = RunPythonCommand.RunningCommand;
if (runCommand != null) {
runCommand.Stop();
}
}
}
}

117
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs

@ -6,7 +6,9 @@ @@ -6,7 +6,9 @@
// </file>
using System;
using System.Diagnostics;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Util;
@ -18,116 +20,55 @@ namespace ICSharpCode.PythonBinding @@ -18,116 +20,55 @@ namespace ICSharpCode.PythonBinding
/// </summary>
public class RunPythonCommand : AbstractMenuCommand
{
IProcessRunner processRunner;
IDebugger debugger;
AddInOptions options;
IWorkbench workbench;
MessageViewCategory category;
IPadDescriptor outputWindowPad;
static MessageViewCategory categorySingleton;
static RunPythonCommand runningCommand;
bool debug;
public RunPythonCommand()
: this(WorkbenchSingleton.Workbench, new AddInOptions(), new PythonProcessRunner(), PythonMessageViewCategory, new PythonOutputWindowPadDescriptor())
: this(WorkbenchSingleton.Workbench, new AddInOptions(), DebuggerService.CurrentDebugger)
{
}
public RunPythonCommand(IWorkbench workbench, AddInOptions options, IProcessRunner processRunner, MessageViewCategory category, IPadDescriptor outputWindowPad)
public RunPythonCommand(IWorkbench workbench, AddInOptions options, IDebugger debugger)
{
this.processRunner = processRunner;
this.options = options;
this.workbench = workbench;
this.category = category;
this.outputWindowPad = outputWindowPad;
processRunner.OutputLineReceived += OutputLineReceived;
processRunner.ProcessExited += ProcessExited;
this.debugger = debugger;
this.options = options;
}
/// <summary>
/// Indicates whether the command is still running.
/// </summary>
public static bool IsRunning {
get {
return runningCommand != null;
}
public bool Debug {
get { return debug; }
set { debug = value; }
}
/// <summary>
/// Gets the command that is currently running.
/// </summary>
public static RunPythonCommand RunningCommand {
get {
return runningCommand;
}
}
/// <summary>
/// Runs the python console passing the filename to the currently
/// active python script.
/// </summary>
public override void Run()
{
// Get the python script filename.
string fileName = workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName;
// Clear the output window.
outputWindowPad.BringPadToFront();
category.ClearText();
// Start the python console app passing the python script filename.
CategoryWriteLine("Running Python...");
string args = String.Concat('\"', fileName, '\"');
CategoryWriteLine(String.Concat(options.PythonFileName, " ", args));
processRunner.Start(options.PythonFileName, args);
runningCommand = this;
}
/// <summary>
/// Stops the python console.
/// </summary>
public void Stop()
{
if (runningCommand != null) {
runningCommand = null;
processRunner.Kill();
}
}
/// <summary>
/// Creates the single instance of the
/// </summary>
static MessageViewCategory PythonMessageViewCategory {
get {
if (categorySingleton == null) {
MessageViewCategory.Create(ref categorySingleton, "Python");
}
return categorySingleton;
if (debug) {
debugger.Start(CreateProcessStartInfo());
} else {
debugger.StartWithoutDebugging(CreateProcessStartInfo());
}
}
/// <summary>
/// Handler for the ProcessRunner's output line received event.
/// </summary>
void OutputLineReceived(object source, LineReceivedEventArgs e)
ProcessStartInfo CreateProcessStartInfo()
{
CategoryWriteLine(e.Line);
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = options.PythonFileName;
info.Arguments = GetArguments();
return info;
}
/// <summary>
/// Handler for the process exit event.
/// </summary>
void ProcessExited(object source, EventArgs e)
string GetArguments()
{
runningCommand = null;
// Get the python script filename.
string pythonScriptFileName = "\"" + workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName + "\"";
if (Debug) {
return "-D " + pythonScriptFileName;
}
return pythonScriptFileName;
}
/// <summary>
/// Writes a line of text to the output window.
/// </summary>
void CategoryWriteLine(string message)
{
category.AppendText(String.Concat(message, Environment.NewLine));
}
}
}

103
src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInFileTestFixture.cs

@ -28,6 +28,7 @@ namespace PythonBinding.Tests @@ -28,6 +28,7 @@ namespace PythonBinding.Tests
Codon fileFilterCodon;
Codon pythonMenuCodon;
Codon pythonRunMenuItemCodon;
Codon pythonWithoutDebuggerRunMenuItemCodon;
Codon pythonStopMenuItemCodon;
Codon fileTemplatesCodon;
Codon optionsPanelCodon;
@ -63,6 +64,7 @@ namespace PythonBinding.Tests @@ -63,6 +64,7 @@ namespace PythonBinding.Tests
const string runMenuExtensionPath = "/SharpDevelop/Workbench/MainMenu/Python";
pythonRunMenuItemCodon = GetCodon(runMenuExtensionPath, "Run");
pythonWithoutDebuggerRunMenuItemCodon = GetCodon(runMenuExtensionPath, "RunWithoutDebugger");
pythonStopMenuItemCodon = GetCodon(runMenuExtensionPath, "Stop");
fileTemplatesCodon = GetCodon("/SharpDevelop/BackendBindings/Templates", "Python");
@ -232,7 +234,7 @@ namespace PythonBinding.Tests @@ -232,7 +234,7 @@ namespace PythonBinding.Tests
[Test]
public void PythonStopMenuItemLabel()
{
Assert.AreEqual("&Stop", pythonStopMenuItemCodon["label"]);
Assert.AreEqual("${res:XML.MainMenu.DebugMenu.Stop}", pythonStopMenuItemCodon["label"]);
}
[Test]
@ -244,19 +246,19 @@ namespace PythonBinding.Tests @@ -244,19 +246,19 @@ namespace PythonBinding.Tests
[Test]
public void PythonStopMenuItemClass()
{
Assert.AreEqual("ICSharpCode.PythonBinding.StopPythonCommand", pythonStopMenuItemCodon["class"]);
Assert.AreEqual("ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand", pythonStopMenuItemCodon["class"]);
}
[Test]
public void PythonStopMenuItemIcon()
{
Assert.AreEqual("Icons.16x16.Debug.StopProcess", pythonStopMenuItemCodon["icon"]);
Assert.AreEqual("Icons.16x16.StopProcess", pythonStopMenuItemCodon["icon"]);
}
[Test]
public void PythonRunMenuItemLabel()
{
Assert.AreEqual("&Run", pythonRunMenuItemCodon["label"]);
Assert.AreEqual("${res:XML.MainMenu.RunMenu.Run}", pythonRunMenuItemCodon["label"]);
}
[Test]
@ -268,13 +270,13 @@ namespace PythonBinding.Tests @@ -268,13 +270,13 @@ namespace PythonBinding.Tests
[Test]
public void PythonRunMenuItemClass()
{
Assert.AreEqual("ICSharpCode.PythonBinding.RunPythonCommand", pythonRunMenuItemCodon["class"]);
Assert.AreEqual("ICSharpCode.PythonBinding.RunDebugPythonCommand", pythonRunMenuItemCodon["class"]);
}
[Test]
public void PythonRunMenuItemShortcut()
{
Assert.AreEqual("Ctrl+Shift+R", pythonRunMenuItemCodon["shortcut"]);
Assert.AreEqual("Control|Shift|R", pythonRunMenuItemCodon["shortcut"]);
}
[Test]
@ -290,26 +292,26 @@ namespace PythonBinding.Tests @@ -290,26 +292,26 @@ namespace PythonBinding.Tests
}
[Test]
public void PythonRunMenuNotConditionExists()
public void PythonRunMenuConditionName()
{
NegatedCondition notCondition = pythonRunMenuItemCodon.Conditions[0] as NegatedCondition;
Assert.IsNotNull(notCondition);
Condition condition = pythonRunMenuItemCodon.Conditions[0] as Condition;
Assert.IsNotNull("IsProcessRunning", condition.Name);
}
[Test]
public void PythonRunMenuNotCondition()
public void PythonRunMenuConditionIsDebuggingProperty()
{
NegatedCondition notCondition = pythonRunMenuItemCodon.Conditions[0] as NegatedCondition;
// Use reflection to get the ICondition associated with the not
// condition.
Type type = notCondition.GetType();
FieldInfo fieldInfo = type.GetField("condition", BindingFlags.NonPublic | BindingFlags.Instance);
ICondition condition = fieldInfo.GetValue(notCondition) as ICondition;
Assert.AreEqual("IsPythonRunning", condition.Name);
Condition condition = pythonRunMenuItemCodon.Conditions[0] as Condition;
Assert.AreEqual("False", condition["isdebugging"]);
}
[Test]
public void PythonRunMenuConditionIsProcessRunningProperty()
{
Condition condition = pythonRunMenuItemCodon.Conditions[0] as Condition;
Assert.AreEqual("False", condition["isprocessrunning"]);
}
[Test]
public void PythonRunMenuConditionAction()
{
@ -318,17 +320,30 @@ namespace PythonBinding.Tests @@ -318,17 +320,30 @@ namespace PythonBinding.Tests
}
[Test]
public void PythonStopMenuConditionAction()
public void PythonStopMenuHasSingleCondition()
{
ICondition condition = pythonStopMenuItemCodon.Conditions[0];
Assert.AreEqual(ConditionFailedAction.Disable, condition.Action);
Assert.AreEqual(1, pythonStopMenuItemCodon.Conditions.Length);
}
[Test]
public void PythonStopMenuConditionName()
{
Condition condition = pythonStopMenuItemCodon.Conditions[0] as Condition;
Assert.IsNotNull("IsProcessRunning", condition.Name);
}
[Test]
public void PythonStopMenuConditionIsDebuggingProperty()
{
Condition condition = pythonStopMenuItemCodon.Conditions[0] as Condition;
Assert.AreEqual("True", condition["isdebugging"]);
}
[Test]
public void PythonStopMenuConditionAction()
{
ICondition condition = pythonStopMenuItemCodon.Conditions[0];
Assert.AreEqual("IsPythonRunning", condition.Name);
Assert.AreEqual(ConditionFailedAction.Disable, condition.Action);
}
[Test]
@ -704,6 +719,48 @@ namespace PythonBinding.Tests @@ -704,6 +719,48 @@ namespace PythonBinding.Tests
Condition condition = convertVBNetProjectCodon.Conditions[0] as Condition;
Assert.AreEqual("VBNet", condition["activeproject"]);
}
[Test]
public void PythonRunWithoutDebuggerMenuItemLabel()
{
Assert.AreEqual("${res:XML.MainMenu.DebugMenu.RunWithoutDebug}", pythonWithoutDebuggerRunMenuItemCodon["label"]);
}
[Test]
public void PythonRunWithoutDebuggerMenuItemIsMenuItem()
{
Assert.AreEqual("MenuItem", pythonWithoutDebuggerRunMenuItemCodon.Name);
}
[Test]
public void PythonRunWithoutDebuggerMenuItemClass()
{
Assert.AreEqual("ICSharpCode.PythonBinding.RunPythonCommand", pythonWithoutDebuggerRunMenuItemCodon["class"]);
}
[Test]
public void PythonRunWithoutDebuggerMenuItemShortcut()
{
Assert.AreEqual("Control|Shift|W", pythonWithoutDebuggerRunMenuItemCodon["shortcut"]);
}
[Test]
public void PythonRunWithoutDebuggerMenuItemIcon()
{
Assert.AreEqual("Icons.16x16.Debug.StartWithoutDebugging", pythonWithoutDebuggerRunMenuItemCodon["icon"]);
}
[Test]
public void PythonDebugRunMenuHasSingleCondition()
{
Assert.AreEqual(1, pythonWithoutDebuggerRunMenuItemCodon.Conditions.Length);
}
[Test]
public void PythonDebugRunConditionIsSameAsPythonRunCondition()
{
Assert.AreEqual(pythonWithoutDebuggerRunMenuItemCodon.Conditions[0], pythonRunMenuItemCodon.Conditions[0]);
}
Codon GetCodon(string name, string extensionPath)
{

2
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ArrayCastConversionTestFixture.cs

@ -36,7 +36,7 @@ namespace PythonBinding.Tests.Converter @@ -36,7 +36,7 @@ namespace PythonBinding.Tests.Converter
string expectedPython = "class Foo(object):\r\n" +
"\tdef Assign(self):\r\n" +
"\t\telements = System.Array.CreateInstance(System.Int32, 10)\r\n" +
"\t\tlist = List()\r\n" +
"\t\tlist = List[System.Array[System.Int32]]()\r\n" +
"\t\tlist.Add(elements.Clone())";
Assert.AreEqual(expectedPython, python);

42
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/BooleanConversionTestFixture.cs

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
// <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.CodeDom;
using System.CodeDom.Compiler;
using ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Converter
{
[TestFixture]
public class BooleanVariableConversionTestFixture
{
string csharp = "class Foo\r\n" +
"{\r\n" +
"\tbool a;\r\n" +
"\r\n" +
"\tpublic Foo()\r\n" +
"\t{\r\n" +
"\t\ta = true;\r\n" +
"\t}\r\n" +
"}";
[Test]
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
"\tdef __init__(self):\r\n" +
"\t\tself._a = True";
Assert.AreEqual(expectedPython, python);
}
}
}

22
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ConvertToPythonProjectCommandTestFixture.cs

@ -27,13 +27,16 @@ namespace PythonBinding.Tests.Converter @@ -27,13 +27,16 @@ namespace PythonBinding.Tests.Converter
FileProjectItem source;
FileProjectItem target;
MockProject sourceProject;
IProject targetProject;
PythonProject targetProject;
FileProjectItem textFileSource;
FileProjectItem textFileTarget;
MockTextEditorProperties mockTextEditorProperties;
ReferenceProjectItem ironPythonReference;
string sourceCode = "class Foo\r\n" +
"{\r\n" +
" static void Main()\r\n" +
" {\r\n" +
" }\r\n" +
"}";
[TestFixtureSetUp]
@ -55,7 +58,7 @@ namespace PythonBinding.Tests.Converter @@ -55,7 +58,7 @@ namespace PythonBinding.Tests.Converter
sourceProject = new MockProject();
sourceProject.Directory = @"d:\projects\test";
source = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Program.cs");
targetProject = convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject);
targetProject = (PythonProject)convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject);
target = new FileProjectItem(targetProject, source.ItemType, source.Include);
source.CopyMetadataTo(target);
@ -125,5 +128,20 @@ namespace PythonBinding.Tests.Converter @@ -125,5 +128,20 @@ namespace PythonBinding.Tests.Converter
{
Assert.AreEqual(@"$(PythonBinPath)\IronPython.dll", ironPythonReference.GetMetadata("HintPath"));
}
[Test]
public void MainFileIsProgramPyFile()
{
PropertyStorageLocations location;
Assert.AreEqual(@"src\Program.py", targetProject.GetProperty(null, null, "MainFile", out location));
}
[Test]
public void PropertyStorageLocationForMainFilePropertyIsGlobal()
{
PropertyStorageLocations location;
targetProject.GetProperty(null, null, "MainFile", out location);
Assert.AreEqual(PropertyStorageLocations.Base, location);
}
}
}

53
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/GenericListConversionTestFixture.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
// <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 ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Converter
{
/// <summary>
/// Tests that the code to create an instance of a generic list is converted to python
/// correctly.
///
/// C#: List<string> list = new List<string>();
///
/// Python: list = List[str]()
/// </summary>
[TestFixture]
public class GenericListConversionTestFixture
{
string csharp = "using System.Collections.Generic;\r\n" +
"\r\n" +
"class Foo\r\n" +
"{\r\n" +
" public Foo()\r\n" +
" {\r\n" +
" List<string> list = new List<string>();\r\n" +
" Dictionary<string, int> dictionary = new Dictionary<string, int>();\r\n" +
" }\r\n" +
"}";
[Test]
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(csharp);
string expectedPython = "from System.Collections.Generic import *\r\n" +
"class Foo(object):\r\n" +
" def __init__(self):\r\n" +
" list = List[System.String]()\r\n" +
" dictionary = Dictionary[System.String, System.Int32]()";
Assert.AreEqual(expectedPython, python);
}
}
}

120
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
// <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.Collections.Generic;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Codons;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Converter
{
[TestFixture]
public class ProjectHasStartupObjectTestFixture
{
DerivedConvertProjectToPythonProjectCommand convertProjectCommand;
FileProjectItem mainFile;
FileProjectItem main2File;
FileProjectItem targetMainFile;
FileProjectItem targetMain2File;
MSBuildBasedProject sourceProject;
PythonProject targetProject;
MockTextEditorProperties mockTextEditorProperties;
MockProjectContent mockProjectContent;
string startupObject = "RootNamespace.Main";
string mainSource = "class Foo\r\n" +
"{\r\n" +
" static void Main()\r\n" +
" {\r\n" +
" }\r\n" +
"}";
string main2Source = "class Bar\r\n" +
"{\r\n" +
" static void Main()\r\n" +
" {\r\n" +
" }\r\n" +
"}";
[TestFixtureSetUp]
public void SetUpFixture()
{
MSBuildEngineHelper.InitMSBuildEngine();
List<LanguageBindingDescriptor> bindings = new List<LanguageBindingDescriptor>();
using (TextReader reader = PythonBindingAddInFile.ReadAddInFile()) {
AddIn addin = AddIn.Load(reader, String.Empty);
bindings.Add(new LanguageBindingDescriptor(AddInHelper.GetCodon(addin, "/SharpDevelop/Workbench/LanguageBindings", "Python")));
}
LanguageBindingService.SetBindings(bindings);
// Set up IProjectContent so the ConvertProjectToPythonProjectCommand can
// locate the startup object and determine it's filename.
mockProjectContent = new MockProjectContent();
MockClass mainClass = new MockClass(mockProjectContent, startupObject);
mainClass.CompilationUnit.FileName = @"d:\projects\test\src\Main2.cs";
mockProjectContent.ClassToReturnFromGetClass = mainClass;
mockTextEditorProperties = new MockTextEditorProperties();
convertProjectCommand = new DerivedConvertProjectToPythonProjectCommand(mockTextEditorProperties);
convertProjectCommand.ProjectContent = mockProjectContent;
mockTextEditorProperties.Encoding = Encoding.Unicode;
Solution solution = new Solution();
sourceProject = new MSBuildBasedProject(solution.BuildEngine);
sourceProject.Parent = solution;
sourceProject.FileName = @"d:\projects\test\source.csproj";
sourceProject.SetProperty(null, null, "StartupObject", startupObject, PropertyStorageLocations.Base, true);
mainFile = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Main.cs");
targetProject = (PythonProject)convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject);
convertProjectCommand.CallCopyProperties(sourceProject, targetProject);
targetMainFile = new FileProjectItem(targetProject, mainFile.ItemType, mainFile.Include);
mainFile.CopyMetadataTo(targetMainFile);
main2File = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Main2.cs");
targetMain2File = new FileProjectItem(targetProject, main2File.ItemType, main2File.Include);
main2File.CopyMetadataTo(targetMain2File);
convertProjectCommand.AddParseableFileContent(mainFile.FileName, mainSource);
convertProjectCommand.AddParseableFileContent(main2File.FileName, main2Source);
convertProjectCommand.CallConvertFile(mainFile, targetMainFile);
convertProjectCommand.CallConvertFile(main2File, targetMain2File);
}
[Test]
public void MainFileIsMain2PyFile()
{
PropertyStorageLocations location;
Assert.AreEqual(@"src\Main2.py", targetProject.GetProperty(null, null, "MainFile", out location));
}
[Test]
public void PropertyStorageLocationForMainFilePropertyIsGlobal()
{
PropertyStorageLocations location;
targetProject.GetProperty(null, null, "MainFile", out location);
Assert.AreEqual(PropertyStorageLocations.Base, location);
}
[Test]
public void ClassSearchedFor()
{
Assert.AreEqual(startupObject, mockProjectContent.GetClassName);
}
}
}

27
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/StaticMethodConversionTestFixture.cs

@ -35,12 +35,20 @@ namespace PythonBinding.Tests.Converter @@ -35,12 +35,20 @@ namespace PythonBinding.Tests.Converter
" }\r\n" +
"}";
string python;
NRefactoryToPythonConverter converter;
[SetUp]
public void Init()
{
converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
python = converter.Convert(csharp);
}
[Test]
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
" def Main(args):\r\n" +
" pass\r\n" +
@ -54,8 +62,19 @@ namespace PythonBinding.Tests.Converter @@ -54,8 +62,19 @@ namespace PythonBinding.Tests.Converter
"\r\n" +
" def Run(self):\r\n" +
" pass";
Assert.AreEqual(expectedPython, python);
}
[Test]
public void EntryPointMethodFound()
{
Assert.AreEqual(1, converter.EntryPointMethods.Count);
}
[Test]
public void MainEntryPointMethodNameIsMain()
{
Assert.AreEqual("Main", converter.EntryPointMethods[0].Name);
}
}
}

6
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/UsingStatementConversionTestFixture.cs

@ -25,7 +25,7 @@ namespace PythonBinding.Tests.Converter @@ -25,7 +25,7 @@ namespace PythonBinding.Tests.Converter
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "import System\r\n" +
string expectedPython = "from System import *\r\n" +
"class Foo(object):\r\n" +
"\tpass";
@ -43,8 +43,8 @@ namespace PythonBinding.Tests.Converter @@ -43,8 +43,8 @@ namespace PythonBinding.Tests.Converter
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "import System\r\n" +
"import System.Drawing\r\n" +
string expectedPython = "from System import *\r\n" +
"from System.Drawing import *\r\n" +
"class Foo(object):\r\n" +
"\tpass";

63
src/AddIns/BackendBindings/Python/PythonBinding/Test/DebugPythonCommandTestFixture.cs

@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
// <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.Diagnostics;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.PythonBinding;
using PythonBinding.Tests.Utils;
using NUnit.Framework;
namespace PythonBinding.Tests
{
[TestFixture]
public class DebugPythonCommandTestFixture
{
MockDebugger debugger;
RunDebugPythonCommand command;
[TestFixtureSetUp]
public void SetUpFixture()
{
// Create dummy view content with the Python script.
MockViewContent viewContent = new MockViewContent();
viewContent.PrimaryFileName = @"C:\Projects\test.py";
MockWorkbenchWindow workbenchWindow = new MockWorkbenchWindow();
workbenchWindow.ActiveViewContent = viewContent;
MockWorkbench workbench = new MockWorkbench();
workbench.ActiveWorkbenchWindow = workbenchWindow;
// Create the Python binding addin options.
Properties p = new Properties();
AddInOptions options = new AddInOptions(p);
options.PythonFileName = @"C:\IronPython\ipy.exe";
debugger = new MockDebugger();
command = new RunDebugPythonCommand(workbench, options, debugger);
command.Run();
}
[Test]
public void DebuggerStartMethodCalled()
{
Assert.IsTrue(debugger.StartMethodCalled);
}
[Test]
public void ProcessInfoFileName()
{
Assert.AreEqual(@"C:\IronPython\ipy.exe", debugger.ProcessStartInfo.FileName);
}
[Test]
public void ProcessInfoArgs()
{
Assert.AreEqual("-D \"C:\\Projects\\test.py\"", debugger.ProcessStartInfo.Arguments);
}
}
}

17
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateBackgroundWorkerTestFixture.cs

@ -20,7 +20,6 @@ namespace PythonBinding.Tests.Designer @@ -20,7 +20,6 @@ namespace PythonBinding.Tests.Designer
public class GenerateBackgroundWorkerTestFixture
{
string generatedPythonCode;
bool hasNonVisualChildComponents;
bool hasIContainerConstructor;
[TestFixtureSetUp]
@ -40,29 +39,19 @@ namespace PythonBinding.Tests.Designer @@ -40,29 +39,19 @@ namespace PythonBinding.Tests.Designer
propertyDescriptor = descriptors.Find("WorkerReportsProgress", false);
propertyDescriptor.SetValue(worker, true);
string indentString = " ";
PythonDesignerRootComponent designerRootComponent = new PythonDesignerRootComponent(form);
hasNonVisualChildComponents = designerRootComponent.HasNonVisualChildComponents();
PythonDesignerComponent component = new PythonDesignerComponent(worker);
hasIContainerConstructor = component.HasIContainerConstructor();
string indentString = " ";
PythonControl pythonControl = new PythonControl(indentString);
generatedPythonCode = pythonControl.GenerateInitializeComponentMethod(form);
}
}
[Test]
public void HasNonVisualChildComponents()
{
Assert.IsTrue(hasNonVisualChildComponents);
}
[Test]
public void GeneratedCode()
{
string expectedCode = "def InitializeComponent(self):\r\n" +
" self._components = System.ComponentModel.Container()\r\n" +
" self._backgroundWorker1 = System.ComponentModel.BackgroundWorker()\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +

105
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateContextMenuStripTestFixture.cs

@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
// <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.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
[TestFixture]
public class GenerateContextMenuStripTestFixture
{
string generatedPythonCode;
string createContextMenuStripCode;
Size menuStripSize;
PythonDesignerComponent contextMenuDesignerComponent;
[TestFixtureSetUp]
public void SetUpFixture()
{
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(200, 300);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
// Add timer. This checks that the components Container is only created once in the
// generated code.
Timer timer = (Timer)host.CreateComponent(typeof(Timer), "timer1");
// Add menu strip.
ContextMenuStrip menuStrip = (ContextMenuStrip)host.CreateComponent(typeof(ContextMenuStrip), "contextMenuStrip1");
// Set the context menu strip OwnerItem to simulate leaving the context menu
// open in the designer before generating the source code. We do not want the
// OwnerItem to be serialized.
menuStrip.OwnerItem = new DerivedToolStripMenuItem();
menuStrip.RightToLeft = RightToLeft.No;
menuStripSize = menuStrip.Size;
PythonControl pythonForm = new PythonControl(" ");
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
PythonCodeBuilder codeBuilder = new PythonCodeBuilder();
contextMenuDesignerComponent = PythonDesignerComponentFactory.CreateDesignerComponent(menuStrip);
contextMenuDesignerComponent.AppendCreateInstance(codeBuilder);
createContextMenuStripCode = codeBuilder.ToString();
}
}
[Test]
public void GeneratedCode()
{
string expectedCode = "def InitializeComponent(self):\r\n" +
" self._components = System.ComponentModel.Container()\r\n" +
" self._timer1 = System.Windows.Forms.Timer(self._components)\r\n" +
" self._contextMenuStrip1 = System.Windows.Forms.ContextMenuStrip(self._components)\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # contextMenuStrip1\r\n" +
" # \r\n" +
" self._contextMenuStrip1.Name = \"contextMenuStrip1\"\r\n" +
" self._contextMenuStrip1.Size = " + PythonPropertyValueAssignment.ToString(menuStripSize) + "\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System.Drawing.Size(200, 300)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode);
}
[Test]
public void CreateContextMenuStripCodeUsesIContainerConstructor()
{
string expectedCode = "self._components = System.ComponentModel.Container()\r\n" +
"self._contextMenuStrip1 = System.Windows.Forms.ContextMenuStrip(self._components)\r\n";
Assert.AreEqual(expectedCode, createContextMenuStripCode);
}
[Test]
public void ContextMenuDesignerComponentCreatedFromFactory()
{
Assert.IsInstanceOf(typeof(PythonContextMenuComponent), contextMenuDesignerComponent);
}
}
}

1
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateEventLogTestFixture.cs

@ -47,7 +47,6 @@ namespace PythonBinding.Tests.Designer @@ -47,7 +47,6 @@ namespace PythonBinding.Tests.Designer
public void GeneratedCode()
{
string expectedCode = "def InitializeComponent(self):\r\n" +
" self._components = System.ComponentModel.Container()\r\n" +
" self._eventLog1 = System.Diagnostics.EventLog()\r\n" +
" self._eventLog1.BeginInit()\r\n" +
" self.SuspendLayout()\r\n" +

10
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateListViewItemTestFixture.cs

@ -228,15 +228,7 @@ namespace PythonBinding.Tests.Designer @@ -228,15 +228,7 @@ namespace PythonBinding.Tests.Designer
" self._listView1.Name = \"listView1\"\r\n" +
" self._listView1.Size = System.Drawing.Size(204, 104)\r\n" +
" self._listView1.TabIndex = 0\r\n" +
" self._listView1.View = System.Windows.Forms.View.Details\r\n" +
" # \r\n" +
" # columnHeader1\r\n" +
" # \r\n" +
" self._columnHeader1.Text = \"columnHeader1\"\r\n" +
" # \r\n" +
" # columnHeader2\r\n" +
" # \r\n" +
" self._columnHeader2.Text = \"columnHeader2\"\r\n";
" self._listView1.View = System.Windows.Forms.View.Details\r\n";
Assert.AreEqual(expectedCode, listViewPropertiesCode);
}

8
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMenuStripItemsTestFixture.cs

@ -26,7 +26,6 @@ namespace PythonBinding.Tests.Designer @@ -26,7 +26,6 @@ namespace PythonBinding.Tests.Designer
Size openMenuItemSize;
Size exitMenuItemSize;
Size editMenuItemSize;
bool nonVisualComponents;
[TestFixtureSetUp]
public void SetUpFixture()
@ -77,7 +76,6 @@ namespace PythonBinding.Tests.Designer @@ -77,7 +76,6 @@ namespace PythonBinding.Tests.Designer
editMenuItemSize = editMenuItem.Size;
PythonDesignerRootComponent rootComponent = new PythonDesignerRootComponent(form);
nonVisualComponents = rootComponent.HasNonVisualChildComponents();
PythonControl pythonForm = new PythonControl(" ");
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
@ -146,12 +144,6 @@ namespace PythonBinding.Tests.Designer @@ -146,12 +144,6 @@ namespace PythonBinding.Tests.Designer
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode);
}
[Test]
public void NoNonVisualComponents()
{
Assert.IsFalse(nonVisualComponents);
}
string SizeToString(Size size)
{

2
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateNestedPanelFormTestFixture.cs

@ -107,7 +107,7 @@ namespace PythonBinding.Tests.Designer @@ -107,7 +107,7 @@ namespace PythonBinding.Tests.Designer
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
Assert.AreEqual(expectedCode, generatedPythonCode);
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode);
}
}
}

2
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratePanelFormTestFixture.cs

@ -94,7 +94,7 @@ namespace PythonBinding.Tests.Designer @@ -94,7 +94,7 @@ namespace PythonBinding.Tests.Designer
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
Assert.AreEqual(expectedCode, generatedPythonCode);
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode);
}
}
}

2
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateSimpleFormTestFixture.cs

@ -44,7 +44,7 @@ namespace PythonBinding.Tests.Designer @@ -44,7 +44,7 @@ namespace PythonBinding.Tests.Designer
codeBuilder.IncreaseIndent();
PythonDesignerRootComponent designerRootComponent = new PythonDesignerRootComponent(form);
propertyOwnerName = designerRootComponent.GetPropertyOwnerName();
designerRootComponent.AppendComponentProperties(codeBuilder);
designerRootComponent.AppendComponentProperties(codeBuilder, true, false);
formPropertiesCode = codeBuilder.ToString();
}
}

17
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateTimerTestFixture.cs

@ -20,8 +20,8 @@ namespace PythonBinding.Tests.Designer @@ -20,8 +20,8 @@ namespace PythonBinding.Tests.Designer
public class GenerateTimerTestFixture
{
string generatedPythonCode;
bool hasNonVisualChildComponents;
bool hasIContainerConstructor;
[TestFixtureSetUp]
public void SetUpFixture()
{
@ -38,25 +38,16 @@ namespace PythonBinding.Tests.Designer @@ -38,25 +38,16 @@ namespace PythonBinding.Tests.Designer
descriptors = TypeDescriptor.GetProperties(timer);
namePropertyDescriptor = descriptors.Find("Interval", false);
namePropertyDescriptor.SetValue(timer, 1000);
string indentString = " ";
PythonDesignerRootComponent designerRootComponent = new PythonDesignerRootComponent(form);
hasNonVisualChildComponents = designerRootComponent.HasNonVisualChildComponents();
PythonDesignerComponent component = new PythonDesignerComponent(timer);
hasIContainerConstructor = component.HasIContainerConstructor();
string indentString = " ";
PythonControl pythonControl = new PythonControl(indentString);
generatedPythonCode = pythonControl.GenerateInitializeComponentMethod(form);
}
}
[Test]
public void HasNonVisualChildComponents()
{
Assert.IsTrue(hasNonVisualChildComponents);
}
[Test]
public void GeneratedCode()
{

65
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateToolTipFormTestFixture.cs

@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
// <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.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
[TestFixture]
public class GenerateToolTipFormTestFixture
{
string generatedPythonCode;
[TestFixtureSetUp]
public void SetUpFixture()
{
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor descriptor = descriptors.Find("Name", false);
descriptor.SetValue(form, "MainForm");
ToolTip toolTip = (ToolTip)host.CreateComponent(typeof(ToolTip), "toolTip1");
toolTip.SetToolTip(form, "test");
string indentString = " ";
PythonControl pythonForm = new PythonControl(indentString);
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
}
}
[Test]
public void GeneratedCode()
{
string expectedCode = "def InitializeComponent(self):\r\n" +
" self._components = System.ComponentModel.Container()\r\n" +
" self._toolTip1 = System.Windows.Forms.ToolTip(self._components)\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self._toolTip1.SetToolTip(self, \"test\")\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode);
}
}
}

18
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratedControlOrderingTestFixture.cs

@ -36,17 +36,7 @@ namespace PythonBinding.Tests.Designer @@ -36,17 +36,7 @@ namespace PythonBinding.Tests.Designer
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
RadioButton radioButton = (RadioButton)host.CreateComponent(typeof(RadioButton), "radioButton1");
radioButton.Location = new Point(20, 0);
radioButton.Size = new Size(10, 10);
radioButton.Text = "radioButton1";
radioButton.TabIndex = 1;
radioButton.UseCompatibleTextRendering = false;
form.Controls.Add(radioButton);
// Add button after radio button to simulate the forms designer
// behaviour of adding the controls in reverse order to the Controls collection.
Button button = (Button)host.CreateComponent(typeof(Button), "button1");
button.Location = new Point(0, 0);
button.Size = new Size(10, 10);
@ -54,6 +44,14 @@ namespace PythonBinding.Tests.Designer @@ -54,6 +44,14 @@ namespace PythonBinding.Tests.Designer
button.TabIndex = 0;
button.UseCompatibleTextRendering = false;
form.Controls.Add(button);
RadioButton radioButton = (RadioButton)host.CreateComponent(typeof(RadioButton), "radioButton1");
radioButton.Location = new Point(20, 0);
radioButton.Size = new Size(10, 10);
radioButton.Text = "radioButton1";
radioButton.TabIndex = 1;
radioButton.UseCompatibleTextRendering = false;
form.Controls.Add(radioButton);
string indentString = " ";
PythonControl pythonForm = new PythonControl(indentString);

16
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GetInstanceFromDesignerLoaderTestFixture.cs

@ -25,6 +25,8 @@ namespace PythonBinding.Tests.Designer @@ -25,6 +25,8 @@ namespace PythonBinding.Tests.Designer
MockDesignerLoaderHost host;
ListViewItem listViewItem1;
object instance;
Type type;
string typeName;
[SetUp]
public void Init()
@ -37,6 +39,8 @@ namespace PythonBinding.Tests.Designer @@ -37,6 +39,8 @@ namespace PythonBinding.Tests.Designer
using (designerSerializationManager.CreateSession()) {
listViewItem1 = (ListViewItem)loader.CreateInstance(typeof(ListViewItem), new object[0], "listViewItem1", false);
instance = loader.GetInstance("listViewItem1");
typeName = typeof(Int32).FullName;
type = loader.GetType(typeName);
}
}
@ -46,5 +50,17 @@ namespace PythonBinding.Tests.Designer @@ -46,5 +50,17 @@ namespace PythonBinding.Tests.Designer
{
Assert.AreEqual(listViewItem1, instance);
}
[Test]
public void GetTypeFromLoader()
{
Assert.AreEqual(typeof(Int32), type);
}
[Test]
public void TypeNameUsed()
{
Assert.AreEqual(typeName, host.TypeResolutionService.LastTypeNameResolved);
}
}
}

50
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadToolTipTestFixture.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// <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.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
[TestFixture]
public class LoadToolTipTestFixture : LoadFormTestFixtureBase
{
public override string PythonCode {
get {
return "class TestForm(System.Windows.Forms.Form):\r\n" +
" def InitializeComponent(self):\r\n" +
" self._components = System.ComponentModel.Container()\r\n" +
" self._toolTip1 = System.Windows.Forms.ToolTip(self._components)\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self._toolTip1.SetToolTip(self, \"test\")\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
}
}
[Test]
public void FormHasToolTip()
{
ToolTip toolTip = (ToolTip)base.ComponentCreator.GetComponent("toolTip1");
Assert.AreEqual("test",toolTip.GetToolTip(Form));
}
}
}

4
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/MissingInitializeComponentMethodTestFixture.cs

@ -84,6 +84,10 @@ namespace PythonBinding.Tests.Designer @@ -84,6 +84,10 @@ namespace PythonBinding.Tests.Designer
return null;
}
public IComponent RootComponent {
get { return null; }
}
public object CreateInstance(Type type, ICollection arguments, string name, bool addToContainer)
{
throw new NotImplementedException();

56
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonCodeBuilderTests.cs

@ -72,5 +72,61 @@ namespace PythonBinding.Tests.Designer @@ -72,5 +72,61 @@ namespace PythonBinding.Tests.Designer
codeBuilder.AppendIndentedLine("abc");
Assert.AreEqual("\tabc\r\n", codeBuilder.ToString());
}
[Test]
public void InitialIndentWhenCodeBuilderCreatedIsZero()
{
Assert.AreEqual(0, codeBuilder.Indent);
}
[Test]
public void IncreaseIndentByOne()
{
codeBuilder.IncreaseIndent();
Assert.AreEqual(1, codeBuilder.Indent);
}
[Test]
public void LengthAfterAddingText()
{
codeBuilder.Append("abc");
Assert.AreEqual(3, codeBuilder.Length);
}
[Test]
public void IndentPassedToConstructor()
{
codeBuilder = new PythonCodeBuilder(2);
codeBuilder.AppendIndented("abc");
Assert.AreEqual("\t\tabc", codeBuilder.ToString());
}
[Test]
public void InsertIndentedLine()
{
codeBuilder.IncreaseIndent();
codeBuilder.AppendIndentedLine("def");
codeBuilder.InsertIndentedLine("abc");
Assert.AreEqual("\tabc\r\n\tdef\r\n", codeBuilder.ToString());
}
/// <summary>
/// Check that the "self._components = System.ComponentModel.Container()" line is generated
/// the once and before any other lines of code.
/// </summary>
[Test]
public void AppendCreateComponentsContainerTwice()
{
codeBuilder.IndentString = " ";
codeBuilder.IncreaseIndent();
codeBuilder.AppendIndentedLine("self._listView = System.Windows.Forms.ListView()");
codeBuilder.InsertCreateComponentsContainer();
codeBuilder.InsertCreateComponentsContainer();
string expectedCode = " self._components = System.ComponentModel.Container()\r\n" +
" self._listView = System.Windows.Forms.ListView()\r\n";
Assert.AreEqual(expectedCode, codeBuilder.ToString());
}
}
}

13
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonControlFieldExpressionTests.cs

@ -95,7 +95,16 @@ namespace PythonBinding.Tests.Designer @@ -95,7 +95,16 @@ namespace PythonBinding.Tests.Designer
CallExpression expression = PythonParserHelper.GetCallExpression(code);
PythonControlFieldExpression field = PythonControlFieldExpression.Create(expression);
AssertAreEqual(field, String.Empty, "Items", "Add", "self.Items");
}
}
[Test]
public void SetToolTipMethodCall()
{
string code = "self._toolTip1.SetToolTip(self, \"Test\")";
CallExpression expression = PythonParserHelper.GetCallExpression(code);
PythonControlFieldExpression field = PythonControlFieldExpression.Create(expression);
AssertAreEqual(field, "toolTip1", "_toolTip1", "SetToolTip", "self._toolTip1");
}
[Test]
public void GetMemberNames()
@ -182,7 +191,7 @@ namespace PythonBinding.Tests.Designer @@ -182,7 +191,7 @@ namespace PythonBinding.Tests.Designer
{
string expected = "Variable: " + variableName + " Member: " + memberName + " Method: " + methodName + " FullMemberName: " + fullMemberName;
string actual = "Variable: " + field.VariableName + " Member: " + field.MemberName + " Method: " + field.MethodName + " FullMemberName: " + field.FullMemberName;
Assert.AreEqual(expected, actual);
Assert.AreEqual(expected, actual, actual);
}
}
}

8
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs

@ -67,7 +67,7 @@ namespace PythonBinding.Tests.Designer @@ -67,7 +67,7 @@ namespace PythonBinding.Tests.Designer
designedForm = new Form();
designedForm.Name = "NewMainForm";
mockDesignerLoaderHost.RootComponent = designedForm;
mockDesignerLoaderHost.RootComponent = designedForm;
loader.CallPerformFlush();
}
@ -137,6 +137,12 @@ namespace PythonBinding.Tests.Designer @@ -137,6 +137,12 @@ namespace PythonBinding.Tests.Designer
Assert.AreEqual(expectedProperty, loader.GetEventProperty(e));
}
[Test]
public void GetRootComponentFromLoader()
{
Assert.AreEqual(designedForm, loader.RootComponent);
}
/// <summary>
/// The code that the designer loader will parse.
/// </summary>

77
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/RemoveMainMenuStripFromFormTestFixture.cs

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
// <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.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
/// <summary>
/// When a MenuStrip is added to a form and then removed the python designer generates code
/// for the form's MainMenuStrip property even though the MenuStrip has been removed.
/// </summary>
[TestFixture]
public class RemoveMainMenuStripFromFormTestFixture
{
string generatedPythonCode;
[TestFixtureSetUp]
public void SetUpFixture()
{
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(200, 300);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor descriptor = descriptors.Find("Name", false);
descriptor.SetValue(form, "MainForm");
// Add menu strip.
MenuStrip menuStrip = (MenuStrip)host.CreateComponent(typeof(MenuStrip), "menuStrip1");
menuStrip.Text = "menuStrip1";
menuStrip.TabIndex = 0;
menuStrip.Location = new Point(0, 0);
form.Controls.Add(menuStrip);
descriptor = descriptors.Find("MainMenuStrip", false);
descriptor.SetValue(form, menuStrip);
form.Controls.Remove(menuStrip);
host.Container.Remove(menuStrip);
PythonControl pythonForm = new PythonControl(" ");
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
}
}
[Test]
public void GeneratedCode()
{
string expectedCode = "def InitializeComponent(self):\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System.Drawing.Size(200, 300)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode);
}
}
}

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

@ -106,6 +106,7 @@ @@ -106,6 +106,7 @@
<Compile Include="Converter\ArrayConversionTestFixture.cs" />
<Compile Include="Converter\AssignmentOperatorConversionTestFixture.cs" />
<Compile Include="Converter\BitShiftConversionTestFixture.cs" />
<Compile Include="Converter\BooleanConversionTestFixture.cs" />
<Compile Include="Converter\BreakAndContinueConversionTestFixture.cs" />
<Compile Include="Converter\CallConstructorWithParametersConversionTestFixture.cs" />
<Compile Include="Converter\ClassDestructorConversionTestFixture.cs" />
@ -114,6 +115,7 @@ @@ -114,6 +115,7 @@
<Compile Include="Converter\ConvertToPythonProjectCommandTestFixture.cs" />
<Compile Include="Converter\EventHandlerWithObjectCreationTestFixture.cs" />
<Compile Include="Converter\ForeachConversionWithMethodCallTestFixture.cs" />
<Compile Include="Converter\GenericListConversionTestFixture.cs" />
<Compile Include="Converter\IntegerMethodParameterTestFixture.cs" />
<Compile Include="Converter\BaseClassReferenceTestFixture.cs" />
<Compile Include="Converter\BinaryOperatorConversionTests.cs" />
@ -141,6 +143,7 @@ @@ -141,6 +143,7 @@
<Compile Include="Converter\NullConversionTestFixture.cs" />
<Compile Include="Converter\ObjectCreationTestFixture.cs" />
<Compile Include="Converter\ObjectInitializerConversionTestFixture.cs" />
<Compile Include="Converter\ProjectHasStartupObjectTestFixture.cs" />
<Compile Include="Converter\PropertyConversionTestFixture.cs" />
<Compile Include="Converter\PropertyWithGetSetStatementsTestfixture.cs" />
<Compile Include="Converter\RemoveHandlerConversionTestFixture.cs" />
@ -159,6 +162,7 @@ @@ -159,6 +162,7 @@
<Compile Include="Converter\VBClassConversionTestFixture.cs" />
<Compile Include="Converter\VBStringConcatTestFixture.cs" />
<Compile Include="Converter\WhileLoopConversionTestFixture.cs" />
<Compile Include="DebugPythonCommandTestFixture.cs" />
<Compile Include="Designer\CreateDesignerComponentTests.cs" />
<Compile Include="Designer\CursorTypeResolutionTestFixture.cs" />
<Compile Include="Designer\DeserializeAssignmentTestFixtureBase.cs" />
@ -179,6 +183,7 @@ @@ -179,6 +183,7 @@
<Compile Include="Designer\GenerateAutoScrollFormTestFixture.cs" />
<Compile Include="Designer\GenerateBackgroundWorkerTestFixture.cs" />
<Compile Include="Designer\GenerateComboBoxItemsTestFixture.cs" />
<Compile Include="Designer\GenerateContextMenuStripTestFixture.cs" />
<Compile Include="Designer\GenerateCursorFormTestFixture.cs" />
<Compile Include="Designer\GeneratedControlOrderingTestFixture.cs" />
<Compile Include="Designer\GenerateDoubleBufferedFormTestFixture.cs" />
@ -199,6 +204,7 @@ @@ -199,6 +204,7 @@
<Compile Include="Designer\GenerateSimpleFormTestFixture.cs" />
<Compile Include="Designer\GenerateTextBoxFormTestFixture.cs" />
<Compile Include="Designer\GenerateTimerTestFixture.cs" />
<Compile Include="Designer\GenerateToolTipFormTestFixture.cs" />
<Compile Include="Designer\GeneratorMergeFindsInitializeComponentsTestFixture.cs" />
<Compile Include="Designer\GetComponentFromDesignerLoaderTestFixture.cs" />
<Compile Include="Designer\GetInstanceFromDesignerLoaderTestFixture.cs" />
@ -226,6 +232,7 @@ @@ -226,6 +232,7 @@
<Compile Include="Designer\LoadTextBoxOnPanelTestFixture.cs" />
<Compile Include="Designer\LoadTextBoxTestFixture.cs" />
<Compile Include="Designer\LoadTimerTestFixture.cs" />
<Compile Include="Designer\LoadToolTipTestFixture.cs" />
<Compile Include="Designer\MergeFormTestFixture.cs" />
<Compile Include="Designer\MissingInitializeComponentMethodTestFixture.cs" />
<Compile Include="Designer\NoNewLineAfterInitializeComponentTestFixture.cs" />
@ -240,6 +247,7 @@ @@ -240,6 +247,7 @@
<Compile Include="Designer\PythonDesignerLoaderProviderTestFixture.cs" />
<Compile Include="Designer\PythonDesignerLoaderTestFixture.cs" />
<Compile Include="Designer\PythonPropertyAssignmentToStringTests.cs" />
<Compile Include="Designer\RemoveMainMenuStripFromFormTestFixture.cs" />
<Compile Include="Designer\TextBoxNotAddedToFormTestFixture.cs" />
<Compile Include="Designer\TextEditorIndentPassedToGeneratorTestFixture.cs" />
<Compile Include="Designer\UnknownTypeTestFixture.cs" />
@ -281,7 +289,6 @@ @@ -281,7 +289,6 @@
<Compile Include="Resolver\ResolveSystemNamespaceTestFixture.cs" />
<Compile Include="Resolver\ResolveUnknownNamespaceTestFixture.cs" />
<Compile Include="RunPythonCommandTestFixture.cs" />
<Compile Include="StopPythonCommandTestFixture.cs" />
<Compile Include="Utils\AddedComponent.cs" />
<Compile Include="Utils\AddInHelper.cs" />
<Compile Include="Utils\BrowseButtonInfo.cs" />
@ -298,8 +305,10 @@ @@ -298,8 +305,10 @@
<Compile Include="Utils\DerivedPythonDesignerGenerator.cs" />
<Compile Include="Utils\DerivedPythonDesignerLoader.cs" />
<Compile Include="Utils\DerivedPythonFormsDesignerDisplayBinding.cs" />
<Compile Include="Utils\DerivedToolStripMenuItem.cs" />
<Compile Include="Utils\MockClass.cs" />
<Compile Include="Utils\MockComponentCreator.cs" />
<Compile Include="Utils\MockDebugger.cs" />
<Compile Include="Utils\MockDesignerGenerator.cs" />
<Compile Include="Utils\MockDesignerLoaderHost.cs" />
<Compile Include="Utils\MockEditableViewContent.cs" />
@ -352,6 +361,10 @@ @@ -352,6 +361,10 @@
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj">
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project>
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj">
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project>
<Name>FormsDesigner</Name>

82
src/AddIns/BackendBindings/Python/PythonBinding/Test/RunPythonCommandTestFixture.cs

@ -22,11 +22,8 @@ namespace PythonBinding.Tests @@ -22,11 +22,8 @@ namespace PythonBinding.Tests
[TestFixture]
public class RunPythonCommandTestFixture
{
MockProcessRunner processRunner;
MessageViewCategory messageViewCategory;
bool messageViewCategoryCleared;
MockPadDescriptor padDescriptor;
bool isRunning;
MockDebugger debugger;
RunPythonCommand command;
[TestFixtureSetUp]
public void SetUpFixture()
@ -38,90 +35,39 @@ namespace PythonBinding.Tests @@ -38,90 +35,39 @@ namespace PythonBinding.Tests
workbenchWindow.ActiveViewContent = viewContent;
MockWorkbench workbench = new MockWorkbench();
workbench.ActiveWorkbenchWindow = workbenchWindow;
// Create a dummy output window pad descriptor.
padDescriptor = new MockPadDescriptor();
// Create the Python binding addin options.
Properties p = new Properties();
AddInOptions options = new AddInOptions(p);
options.PythonFileName = @"C:\IronPython\ipy.exe";
// Create the process runner.
processRunner = new MockProcessRunner();
processRunner.OutputText = "Test\r\nOutput";
// Create the message view category.
messageViewCategory = new MessageViewCategory("Python");
messageViewCategory.TextSet += MessageViewCategoryCleared;
// Run the command.
RunPythonCommand command = new RunPythonCommand(workbench, options, processRunner, messageViewCategory, padDescriptor);
debugger = new MockDebugger();
command = new RunPythonCommand(workbench, options, debugger);
command.Run();
// Check that the IsPythonRunning thinks the command is still
// running.
IsPythonRunningCondition condition = new IsPythonRunningCondition();
isRunning = condition.IsValid(null, null);
// The python console process exits.
processRunner.RaiseExitEvent();
}
[Test]
public void CommandLine()
public void RunPythonCommandIsAbstractCommand()
{
// Check the correct filename was used to execute the command.
Assert.AreEqual("C:\\IronPython\\ipy.exe \"C:\\Projects\\test.py\"", processRunner.CommandLine);
Assert.IsNotNull(command as AbstractCommand);
}
[Test]
public void MessageViewCategoryClearTextCalled()
public void DebuggerStartWithoutDebuggingMethodCalled()
{
Assert.IsTrue(messageViewCategoryCleared);
Assert.IsTrue(debugger.StartWithoutDebuggingMethodCalled);
}
/// <summary>
/// Message view category should have the command line
/// used to start the python console and any output from it.
/// </summary>
[Test]
public void MessageViewCategoryText()
public void ProcessInfoFileName()
{
string expectedText = "Running Python...\r\n" +
"C:\\IronPython\\ipy.exe \"C:\\Projects\\test.py\"\r\n" +
"Test\r\n" +
"Output\r\n";
Assert.AreEqual(expectedText, messageViewCategory.Text);
Assert.AreEqual(@"C:\IronPython\ipy.exe", debugger.ProcessStartInfo.FileName);
}
[Test]
public void OutputWindowPadBroughtToFront()
{
Assert.IsTrue(padDescriptor.BringPadToFrontCalled);
}
/// <summary>
/// Until the ipy.exe process exits the RunPythonCommand
/// should return true from the IsRunning property.
/// </summary>
[Test]
public void IsPythonRunningBeforeExit()
{
Assert.IsTrue(isRunning);
}
[Test]
public void IsPythonRunningAfterExit()
{
IsPythonRunningCondition condition = new IsPythonRunningCondition();
Assert.IsFalse(condition.IsValid(null, null));
}
void MessageViewCategoryCleared(object sender, TextEventArgs e)
public void ProcessInfoArgs()
{
if (e.Text == "")
messageViewCategoryCleared = true;
Assert.AreEqual("\"C:\\Projects\\test.py\"", debugger.ProcessStartInfo.Arguments);
}
}
}

73
src/AddIns/BackendBindings/Python/PythonBinding/Test/StopPythonCommandTestFixture.cs

@ -1,73 +0,0 @@ @@ -1,73 +0,0 @@
// <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 ICSharpCode.Core;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests
{
/// <summary>
/// Tests that the StopPythonCommand kills the python console process.
/// </summary>
[TestFixture]
public class StopPythonCommandTestFixture
{
MockProcessRunner processRunner;
[TestFixtureSetUp]
public void SetUpFixture()
{
// Create dummy view content with the Python script.
MockViewContent viewContent = new MockViewContent();
viewContent.PrimaryFileName = @"C:\Projects\test.py";
MockWorkbenchWindow workbenchWindow = new MockWorkbenchWindow();
workbenchWindow.ActiveViewContent = viewContent;
MockWorkbench workbench = new MockWorkbench();
workbench.ActiveWorkbenchWindow = workbenchWindow;
// Create a dummy output window pad descriptor.
MockPadDescriptor padDescriptor = new MockPadDescriptor();
// Create the Python binding addin options.
Properties p = new Properties();
AddInOptions options = new AddInOptions(p);
options.PythonFileName = @"C:\IronPython\ipy.exe";
// Create the process runner.
processRunner = new MockProcessRunner();
// Create the message view category.
MessageViewCategory messageViewCategory = new MessageViewCategory("Python");
// Run the command.
RunPythonCommand command = new RunPythonCommand(workbench, options, processRunner, messageViewCategory, padDescriptor);
command.Run();
StopPythonCommand stopCommand = new StopPythonCommand();
stopCommand.Run();
}
[Test]
public void IsStopped()
{
// Check that the IsPythonRunning thinks the command has stopped
IsPythonRunningCondition condition = new IsPythonRunningCondition();
Assert.IsFalse(condition.IsValid(null, null));
}
[Test]
public void ProcessRunnerStopped()
{
Assert.IsTrue(processRunner.KillCalled);
}
}
}

7
src/AddIns/BackendBindings/Python/PythonBinding/Test/TODO.txt

@ -88,7 +88,12 @@ def main(args): @@ -88,7 +88,12 @@ def main(args):
Handle invalid event name.
Check that += operator used.
* ContextMenuStrip - designer does not generate the correct code.
* ContextMenuStrip
If the context menu is added for the first time and left open and displayed on the form when
switching to the source code you see an OwnerItem property added to the context menu variable:
self._contextMenuStrip1.OwnerItem = ContextMenuStrip
* Look at fixing the compiled exe so it can be run from a different folder.

20
src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedConvertProjectToPythonProjectCommand.cs

@ -10,6 +10,7 @@ using System.Collections.Generic; @@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Text;
using ICSharpCode.PythonBinding;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.TextEditor.Document;
@ -35,6 +36,7 @@ namespace PythonBinding.Tests.Utils @@ -35,6 +36,7 @@ namespace PythonBinding.Tests.Utils
List<SourceAndTargetFile> sourceAndTargetFilesPassedToBaseClass = new List<SourceAndTargetFile>();
List<ConvertedFile> savedFiles = new List<ConvertedFile>();
List<ConvertedFile> parseableFileContent = new List<ConvertedFile>();
IProjectContent projectContent;
public DerivedConvertProjectToPythonProjectCommand(ITextEditorProperties textEditorProperties)
: base(textEditorProperties)
@ -52,6 +54,14 @@ namespace PythonBinding.Tests.Utils @@ -52,6 +54,14 @@ namespace PythonBinding.Tests.Utils
get { return savedFiles; }
}
/// <summary>
/// Sets the project content to be returned from the GetProjectContent method.
/// </summary>
public IProjectContent ProjectContent {
get { return projectContent; }
set { projectContent = value; }
}
public void AddParseableFileContent(string fileName, string content)
{
parseableFileContent.Add(new ConvertedFile(fileName, content, null));
@ -67,6 +77,11 @@ namespace PythonBinding.Tests.Utils @@ -67,6 +77,11 @@ namespace PythonBinding.Tests.Utils
return base.CreateProject(directory, sourceProject);
}
public void CallCopyProperties(IProject source, IProject target)
{
base.CopyProperties(source, target);
}
protected override void LanguageConverterConvertFile(FileProjectItem source, FileProjectItem target)
{
sourceAndTargetFilesPassedToBaseClass.Add(new SourceAndTargetFile(source, target));
@ -86,5 +101,10 @@ namespace PythonBinding.Tests.Utils @@ -86,5 +101,10 @@ namespace PythonBinding.Tests.Utils
}
return null;
}
protected override IProjectContent GetProjectContent(IProject project)
{
return projectContent;
}
}
}

19
src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedToolStripMenuItem.cs

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
// <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.Windows.Forms;
namespace PythonBinding.Tests.Utils
{
public class DerivedToolStripMenuItem : ToolStripMenuItem
{
public DerivedToolStripMenuItem() : base()
{
}
}
}

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

@ -25,14 +25,23 @@ namespace PythonBinding.Tests.Utils @@ -25,14 +25,23 @@ namespace PythonBinding.Tests.Utils
List<string> typeNames = new List<string>();
PropertyDescriptor propertyDescriptor;
EventDescriptor eventDescriptor;
IComponent rootComponent;
public MockComponentCreator()
{
}
public IComponent RootComponent {
get { return rootComponent; }
}
public IComponent CreateComponent(Type componentClass, string name)
{
object instance = componentClass.Assembly.CreateInstance(componentClass.FullName);
if (rootComponent == null) {
rootComponent = instance as IComponent;
}
CreatedComponent c = new CreatedComponent(componentClass.FullName, name, (IComponent)instance);
createdComponents.Add(c);

178
src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDebugger.cs

@ -0,0 +1,178 @@ @@ -0,0 +1,178 @@
// <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.Diagnostics;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Project;
namespace PythonBinding.Tests.Utils
{
public class MockDebugger : IDebugger
{
ProcessStartInfo processStartInfo;
bool startMethodCalled;
bool startWithoutDebuggingMethodCalled;
bool stopMethodCalled;
public MockDebugger()
{
}
/// <summary>
/// Gets the ProcessStartInfo passed to the Start or StartWithoutDebugging methods.
/// </summary>
public ProcessStartInfo ProcessStartInfo {
get { return processStartInfo; }
}
public bool StartMethodCalled {
get { return startMethodCalled; }
}
public bool StartWithoutDebuggingMethodCalled {
get { return startWithoutDebuggingMethodCalled; }
}
public bool StopMethodCalled {
get { return stopMethodCalled; }
}
public event EventHandler DebugStarting;
public event EventHandler DebugStarted;
public event EventHandler IsProcessRunningChanged;
public event EventHandler DebugStopped;
public bool IsDebugging {
get {
throw new NotImplementedException();
}
}
public bool IsProcessRunning {
get {
throw new NotImplementedException();
}
}
public bool CanDebug(IProject project)
{
throw new NotImplementedException();
}
public void Start(ProcessStartInfo processStartInfo)
{
this.processStartInfo = processStartInfo;
startMethodCalled = true;
}
public void StartWithoutDebugging(ProcessStartInfo processStartInfo)
{
this.processStartInfo = processStartInfo;
startWithoutDebuggingMethodCalled = true;
}
public void Stop()
{
stopMethodCalled = true;
}
public void Break()
{
throw new NotImplementedException();
}
public void Continue()
{
throw new NotImplementedException();
}
public void StepInto()
{
throw new NotImplementedException();
}
public void StepOver()
{
throw new NotImplementedException();
}
public void StepOut()
{
throw new NotImplementedException();
}
public void ShowAttachDialog()
{
throw new NotImplementedException();
}
public void Attach(System.Diagnostics.Process process)
{
throw new NotImplementedException();
}
public void Detach()
{
throw new NotImplementedException();
}
public string GetValueAsString(string variable)
{
throw new NotImplementedException();
}
public DebuggerGridControl GetTooltipControl(string variable)
{
throw new NotImplementedException();
}
public bool CanSetInstructionPointer(string filename, int line, int column)
{
throw new NotImplementedException();
}
public bool SetInstructionPointer(string filename, int line, int column)
{
throw new NotImplementedException();
}
public void Dispose()
{
throw new NotImplementedException();
}
protected virtual void OnDebugStarting(EventArgs e)
{
if (DebugStarting != null) {
DebugStarting(this, e);
}
}
protected virtual void OnDebugStarted(EventArgs e)
{
if (DebugStarted != null) {
DebugStarted(this, e);
}
}
protected virtual void OnIsProcessRunningChanged(EventArgs e)
{
if (IsProcessRunningChanged != null) {
IsProcessRunningChanged(this, e);
}
}
protected virtual void OnDebugStopped(EventArgs e)
{
if (DebugStopped != null) {
DebugStopped(this, e);
}
}
}
}

15
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs

@ -608,7 +608,8 @@ namespace VBNetBinding.FormattingStrategy @@ -608,7 +608,8 @@ namespace VBNetBinding.FormattingStrategy
}
if (IsBlockStart(lexer, currentToken, prevToken)) {
ApplyToRange(textArea, indentation, oldLine, currentToken.Location.Line, begin, end);
int line = GetLastVisualLine(currentToken.Location.Line, textArea);
ApplyToRange(textArea, indentation, oldLine, line, begin, end);
if (!inInterface && !isMustOverride && !isDeclare && !isDelegate) {
Indent(textArea, indentation);
@ -620,7 +621,7 @@ namespace VBNetBinding.FormattingStrategy @@ -620,7 +621,7 @@ namespace VBNetBinding.FormattingStrategy
if (currentToken.Kind == Tokens.Interface)
inInterface = true;
oldLine = currentToken.Location.Line;
oldLine = line;
}
prevToken = currentToken;
@ -636,6 +637,16 @@ namespace VBNetBinding.FormattingStrategy @@ -636,6 +637,16 @@ namespace VBNetBinding.FormattingStrategy
return indentation.Peek().Length;
}
int GetLastVisualLine(int line, TextArea area)
{
string text = StripComment(area.Document.GetText(area.Document.GetLineSegment(line - 1)));
while (text.EndsWith("_", StringComparison.Ordinal)) {
line++;
text = StripComment(area.Document.GetText(area.Document.GetLineSegment(line - 1)));
}
return line;
}
void Unindent(Stack<string> indentation)
{

2
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs

@ -32,7 +32,7 @@ namespace VBNetBinding @@ -32,7 +32,7 @@ namespace VBNetBinding
public override CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
{
if(ch == '(' && EnableMethodInsight && CodeCompletionOptions.InsightEnabled) {
editor.ShowInsightWindow(new MethodInsightDataProvider());
editor.ShowInsightWindow(new MethodInsightProvider().ProvideInsight(editor));
return CodeCompletionKeyPressResult.Completed;
} else if(ch == ',' && CodeCompletionOptions.InsightRefreshOnComma && CodeCompletionOptions.InsightEnabled) {
if (InsightRefreshOnComma(editor, ch))

52
src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/IndentationTests.cs

@ -65,6 +65,58 @@ End Class"; @@ -65,6 +65,58 @@ End Class";
RunFormatTest(code, expected);
}
[Test]
public void IfLineContinuationTest()
{
string expected = @"Public Class Test
Private Sub Tester()
If True _
Then
test()
End If
End Sub
End Class";
string code = @"Public Class Test
Private Sub Tester()
If True _
Then
test()
End If
End Sub
End Class";
RunFormatTest(code, expected);
}
[Test]
public void IfMultiLineContinuationTest()
{
string expected = @"Public Class Test
Private Sub Tester()
If IsCorrect(i) _
And _
IsHIgherThan(i, 5) _
Then
test()
End If
End Sub
End Class";
string code = @"Public Class Test
Private Sub Tester()
If IsCorrect(i) _
And _
IsHIgherThan(i, 5) _
Then
test()
End If
End Sub
End Class";
RunFormatTest(code, expected);
}
void RunFormatTest(string code, string expectedCode)
{
using (TextEditorControl editor = new TextEditorControl()) {

2
src/AddIns/Misc/CodeAnalysis/CodeAnalysis.addin

@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
class = "ICSharpCode.CodeAnalysis.CheckCurrentProjectCommand"/>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/QualityTools">
<Path name = "/SharpDevelop/Workbench/MainMenu/Analysis">
<ComplexCondition action="Disable">
<And>
<Condition name = "ProjectActive" activeproject="*" />

2
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin

@ -88,7 +88,7 @@ @@ -88,7 +88,7 @@
</ComplexCondition>
</Path>
<Path name="/SharpDevelop/Workbench/MainMenu/QualityTools/Test">
<Path name="/SharpDevelop/Workbench/MainMenu/Analysis/Test">
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -184,15 +184,10 @@ @@ -184,15 +184,10 @@
<Compile Include="Src\Interop\CorDebug\ICorDebugValue2.cs" />
<Compile Include="Src\Interop\CorDebug\ICorDebugValueBreakpoint.cs" />
<Compile Include="Src\Interop\CorDebug\ICorDebugValueEnum.cs" />
<Compile Include="Src\Interop\CorDebug\ISequentialStream.cs" />
<Compile Include="Src\Interop\CorDebug\IStream.cs" />
<Compile Include="Src\Interop\CorDebug\tagSTATSTG.cs" />
<Compile Include="Src\Interop\CorDebug\_COR_IL_MAP.cs" />
<Compile Include="Src\Interop\CorDebug\_COR_VERSION.cs" />
<Compile Include="Src\Interop\CorDebug\_FILETIME.cs" />
<Compile Include="Src\Interop\CorDebug\_LARGE_INTEGER.cs" />
<Compile Include="Src\Interop\CorDebug\_SECURITY_ATTRIBUTES.cs" />
<Compile Include="Src\Interop\CorDebug\_ULARGE_INTEGER.cs" />
<Compile Include="Src\Interop\CorSym\CorSymAddrKind.cs" />
<Compile Include="Src\Interop\CorSym\CorSymBinder_deprecated.cs" />
<Compile Include="Src\Interop\CorSym\CorSymBinder_deprecatedClass.cs" />

12
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Module.cs

@ -190,6 +190,18 @@ namespace Debugger @@ -190,6 +190,18 @@ namespace Debugger
}
}
public void UpdateSymbolsFromStream(Debugger.Wrappers.CorDebug.IStream pSymbolStream)
{
if (symReader != null) {
symReader.As<ISymUnmanagedDispose>().Destroy();
}
symReader = metaData.GetSymReader(pSymbolStream);
if (symReader != null) {
OnSymbolsLoaded(new ModuleEventArgs(this));
}
}
/// <summary> Sets all code as being 'my code'. The code will be gradually
/// set to not-user-code as encountered acording to stepping options </summary>
public void ResetJustMyCodeStatus()

11
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs

@ -290,7 +290,16 @@ namespace Debugger @@ -290,7 +290,16 @@ namespace Debugger
public void UpdateModuleSymbols(ICorDebugAppDomain pAppDomain, ICorDebugModule pModule, IStream pSymbolStream)
{
EnterCallback(PausedReason.Other, "UpdateModuleSymbols", pAppDomain);
foreach (Module module in process.Modules) {
if (module.CorModule == pModule) {
process.TraceMessage("UpdateModuleSymbols: Found module: " + pModule.Name);
module.UpdateSymbolsFromStream(pSymbolStream);
process.Debugger.SetBreakpointsInModule(module);
break;
}
}
ExitCallback();
}

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugEditAndContinueSnapshot.cs

@ -12,6 +12,7 @@ namespace Debugger.Interop.CorDebug @@ -12,6 +12,7 @@ namespace Debugger.Interop.CorDebug
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Debugger.Interop.CorSym;
[ComImport, Guid("6DC3FA01-D7CB-11D2-8A95-0080C792E5D8"), InterfaceType((short) 1)]
public interface ICorDebugEditAndContinueSnapshot

25
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ISequentialStream.cs

@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
#pragma warning disable 108, 1591
namespace Debugger.Interop.CorDebug
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[ComImport, Guid("0C733A30-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType((short) 1)]
public interface ISequentialStream
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void RemoteRead(out byte pv, [In] uint cb, out uint pcbRead);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten);
}
}
#pragma warning restore 108, 1591

43
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/IStream.cs

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
#pragma warning disable 108, 1591
namespace Debugger.Interop.CorDebug
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[ComImport, InterfaceType((short) 1), Guid("0000000C-0000-0000-C000-000000000046")]
public interface IStream : ISequentialStream
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void RemoteRead(out byte pv, [In] uint cb, out uint pcbRead);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void RemoteSeek([In] _LARGE_INTEGER dlibMove, [In] uint dwOrigin, out _ULARGE_INTEGER plibNewPosition);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void SetSize([In] _ULARGE_INTEGER libNewSize);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void RemoteCopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In] _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Commit([In] uint grfCommitFlags);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Revert();
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void LockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void UnlockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Stat(out tagSTATSTG pstatstg, [In] uint grfStatFlag);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Clone([MarshalAs(UnmanagedType.Interface)] out IStream ppstm);
}
}
#pragma warning restore 108, 1591

21
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_LARGE_INTEGER.cs

@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
#pragma warning disable 108, 1591
namespace Debugger.Interop.CorDebug
{
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack=8)]
public struct _LARGE_INTEGER
{
public long QuadPart;
}
}
#pragma warning restore 108, 1591

21
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_ULARGE_INTEGER.cs

@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
#pragma warning disable 108, 1591
namespace Debugger.Interop.CorDebug
{
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack=8)]
public struct _ULARGE_INTEGER
{
public ulong QuadPart;
}
}
#pragma warning restore 108, 1591

33
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/tagSTATSTG.cs

@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
#pragma warning disable 108, 1591
namespace Debugger.Interop.CorDebug
{
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack=8)]
public struct tagSTATSTG
{
[MarshalAs(UnmanagedType.LPWStr)]
public string pwcsName;
public uint type;
public _ULARGE_INTEGER cbSize;
public _FILETIME mtime;
public _FILETIME ctime;
public _FILETIME atime;
public uint grfMode;
public uint grfLocksSupported;
public Guid clsid;
public uint grfStateBits;
public uint reserved;
}
}
#pragma warning restore 108, 1591

11
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/ISequentialStream.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
@ -16,10 +16,9 @@ namespace Debugger.Wrappers.CorDebug @@ -16,10 +16,9 @@ namespace Debugger.Wrappers.CorDebug
public partial class ISequentialStream
{
private Debugger.Interop.CorSym.ISequentialStream wrappedObject;
private Debugger.Interop.CorDebug.ISequentialStream wrappedObject;
internal Debugger.Interop.CorDebug.ISequentialStream WrappedObject
internal Debugger.Interop.CorSym.ISequentialStream WrappedObject
{
get
{
@ -27,13 +26,13 @@ namespace Debugger.Wrappers.CorDebug @@ -27,13 +26,13 @@ namespace Debugger.Wrappers.CorDebug
}
}
public ISequentialStream(Debugger.Interop.CorDebug.ISequentialStream wrappedObject)
public ISequentialStream(Debugger.Interop.CorSym.ISequentialStream wrappedObject)
{
this.wrappedObject = wrappedObject;
ResourceManager.TrackCOMObject(wrappedObject, typeof(ISequentialStream));
}
public static ISequentialStream Wrap(Debugger.Interop.CorDebug.ISequentialStream objectToWrap)
public static ISequentialStream Wrap(Debugger.Interop.CorSym.ISequentialStream objectToWrap)
{
if ((objectToWrap != null))
{

28
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/IStream.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
@ -17,9 +17,9 @@ namespace Debugger.Wrappers.CorDebug @@ -17,9 +17,9 @@ namespace Debugger.Wrappers.CorDebug
public partial class IStream
{
private Debugger.Interop.CorDebug.IStream wrappedObject;
private Debugger.Interop.CorSym.IStream wrappedObject;
internal Debugger.Interop.CorDebug.IStream WrappedObject
internal Debugger.Interop.CorSym.IStream WrappedObject
{
get
{
@ -27,13 +27,13 @@ namespace Debugger.Wrappers.CorDebug @@ -27,13 +27,13 @@ namespace Debugger.Wrappers.CorDebug
}
}
public IStream(Debugger.Interop.CorDebug.IStream wrappedObject)
public IStream(Debugger.Interop.CorSym.IStream wrappedObject)
{
this.wrappedObject = wrappedObject;
ResourceManager.TrackCOMObject(wrappedObject, typeof(IStream));
}
public static IStream Wrap(Debugger.Interop.CorDebug.IStream objectToWrap)
public static IStream Wrap(Debugger.Interop.CorSym.IStream objectToWrap)
{
if ((objectToWrap != null))
{
@ -109,21 +109,21 @@ namespace Debugger.Wrappers.CorDebug @@ -109,21 +109,21 @@ namespace Debugger.Wrappers.CorDebug
return pcbWritten;
}
public Debugger.Interop.CorDebug._ULARGE_INTEGER RemoteSeek(Debugger.Interop.CorDebug._LARGE_INTEGER dlibMove, uint dwOrigin)
public Debugger.Interop.CorSym._ULARGE_INTEGER RemoteSeek(Debugger.Interop.CorSym._LARGE_INTEGER dlibMove, uint dwOrigin)
{
Debugger.Interop.CorDebug._ULARGE_INTEGER plibNewPosition;
Debugger.Interop.CorSym._ULARGE_INTEGER plibNewPosition;
this.WrappedObject.RemoteSeek(dlibMove, dwOrigin, out plibNewPosition);
return plibNewPosition;
}
public void SetSize(Debugger.Interop.CorDebug._ULARGE_INTEGER libNewSize)
public void SetSize(Debugger.Interop.CorSym._ULARGE_INTEGER libNewSize)
{
this.WrappedObject.SetSize(libNewSize);
}
public Debugger.Interop.CorDebug._ULARGE_INTEGER RemoteCopyTo(IStream pstm, Debugger.Interop.CorDebug._ULARGE_INTEGER cb, out Debugger.Interop.CorDebug._ULARGE_INTEGER pcbRead)
public Debugger.Interop.CorSym._ULARGE_INTEGER RemoteCopyTo(IStream pstm, Debugger.Interop.CorSym._ULARGE_INTEGER cb, out Debugger.Interop.CorSym._ULARGE_INTEGER pcbRead)
{
Debugger.Interop.CorDebug._ULARGE_INTEGER pcbWritten;
Debugger.Interop.CorSym._ULARGE_INTEGER pcbWritten;
this.WrappedObject.RemoteCopyTo(pstm.WrappedObject, cb, out pcbRead, out pcbWritten);
return pcbWritten;
}
@ -138,17 +138,17 @@ namespace Debugger.Wrappers.CorDebug @@ -138,17 +138,17 @@ namespace Debugger.Wrappers.CorDebug
this.WrappedObject.Revert();
}
public void LockRegion(Debugger.Interop.CorDebug._ULARGE_INTEGER libOffset, Debugger.Interop.CorDebug._ULARGE_INTEGER cb, uint dwLockType)
public void LockRegion(Debugger.Interop.CorSym._ULARGE_INTEGER libOffset, Debugger.Interop.CorSym._ULARGE_INTEGER cb, uint dwLockType)
{
this.WrappedObject.LockRegion(libOffset, cb, dwLockType);
}
public void UnlockRegion(Debugger.Interop.CorDebug._ULARGE_INTEGER libOffset, Debugger.Interop.CorDebug._ULARGE_INTEGER cb, uint dwLockType)
public void UnlockRegion(Debugger.Interop.CorSym._ULARGE_INTEGER libOffset, Debugger.Interop.CorSym._ULARGE_INTEGER cb, uint dwLockType)
{
this.WrappedObject.UnlockRegion(libOffset, cb, dwLockType);
}
public void Stat(out Debugger.Interop.CorDebug.tagSTATSTG pstatstg, uint grfStatFlag)
public void Stat(out Debugger.Interop.CorSym.tagSTATSTG pstatstg, uint grfStatFlag)
{
this.WrappedObject.Stat(out pstatstg, grfStatFlag);
}
@ -156,7 +156,7 @@ namespace Debugger.Wrappers.CorDebug @@ -156,7 +156,7 @@ namespace Debugger.Wrappers.CorDebug
public IStream Clone()
{
IStream ppstm;
Debugger.Interop.CorDebug.IStream out_ppstm;
Debugger.Interop.CorSym.IStream out_ppstm;
this.WrappedObject.Clone(out out_ppstm);
ppstm = IStream.Wrap(out_ppstm);
return ppstm;

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedBinder.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
@ -100,7 +100,7 @@ namespace Debugger.Wrappers.CorSym @@ -100,7 +100,7 @@ namespace Debugger.Wrappers.CorSym
return ISymUnmanagedReader.Wrap(this.WrappedObject.GetReaderForFile(importer, filename, searchPath));
}
public ISymUnmanagedReader GetReaderFromStream(object importer, IStream pstream)
public ISymUnmanagedReader GetReaderFromStream(object importer, Debugger.Wrappers.CorDebug.IStream pstream)
{
return ISymUnmanagedReader.Wrap(this.WrappedObject.GetReaderFromStream(importer, pstream.WrappedObject));
}

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs

@ -41,6 +41,16 @@ namespace Debugger.Wrappers.MetaData @@ -41,6 +41,16 @@ namespace Debugger.Wrappers.MetaData
}
}
public ISymUnmanagedReader GetSymReader(Debugger.Wrappers.CorDebug.IStream stream)
{
try {
ISymUnmanagedBinder symBinder = new ISymUnmanagedBinder(new Debugger.Interop.CorSym.CorSymBinder_SxSClass());
return symBinder.GetReaderFromStream(metaData, stream);
} catch {
return null;
}
}
~MetaDataImport()
{
Dispose();

4
src/AddIns/Misc/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin

@ -8,7 +8,8 @@ @@ -8,7 +8,8 @@
<Import assembly="ICSharpCode.Profiler.AddIn.dll" />
</Runtime>
<Path name="/SharpDevelop/Workbench/MainMenu/QualityTools/Profiler">
<Path name="/SharpDevelop/Workbench/MainMenu/Analysis">
<MenuItem id="Profiler" label="Profiler" type="Menu" insertbefore="Separator1">
<ComplexCondition action="Disable">
<And>
<Condition name = "ProjectActive" activeproject="*" />
@ -24,6 +25,7 @@ @@ -24,6 +25,7 @@
class="ICSharpCode.Profiler.AddIn.Commands.ProfileExecutable"
label="Select executable to profile"
/>
</MenuItem>
</Path>
<Path name = "/SharpDevelop/Workbench/DisplayBindings">

32
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfileProject.cs

@ -6,17 +6,10 @@ @@ -6,17 +6,10 @@
// </file>
using System;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Views;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Profiling;
using ICSharpCode.SharpDevelop.Project;
using Microsoft.Build.BuildEngine;
namespace ICSharpCode.Profiler.AddIn.Commands
{
@ -32,32 +25,15 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -32,32 +25,15 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// </summary>
public override void Run()
{
AbstractProject currentProj = ProjectService.CurrentProject as AbstractProject;
string filePart = @"ProfilingSessions\Session" +
DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) +
".sdps";
string path = Path.Combine(currentProj.Directory, filePart);
IProject currentProj = ProjectService.CurrentProject;
string path = ProfilerService.GetSessionFileName(currentProj);
Directory.CreateDirectory(Path.GetDirectoryName(path));
IProfilingDataWriter writer = new ProfilingDataSQLiteWriter(path);
ProfilerRunner runner = WindowsProfiler.CreateRunner(writer);
if (runner != null) {
runner.RunFinished += delegate {
Action updater = () => {
FileService.OpenFile(path);
FileProjectItem file = new FileProjectItem(currentProj, ItemType.Content, "ProfilingSessions\\" + Path.GetFileName(path));
ProjectService.AddProjectItem(currentProj, file);
ProjectBrowserPad.Instance.ProjectBrowserControl.RefreshView();
currentProj.Save();
};
WorkbenchSingleton.SafeThreadCall(updater);
};
runner.RunFinished += delegate { ProfilerService.AddSessionToProject(currentProj, path); };
runner.Run();
}
}

2
src/AddIns/Misc/SourceAnalysis/SourceAnalysis.addin

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
class = "MattEverson.SourceAnalysis.CheckCurrentProjectCommand"/>
</Path>
<Path name="/SharpDevelop/Workbench/MainMenu/QualityTools">
<Path name="/SharpDevelop/Workbench/MainMenu/Analysis">
<ComplexCondition action="Disable">
<And>
<Condition name = "ProjectActive" activeproject="*" />

9
src/AddIns/Misc/UnitTesting/Resources/UnitTestingOptionsPanel.xfrm

@ -12,6 +12,15 @@ @@ -12,6 +12,15 @@
<Anchor value="Top, Left, Right" />
<TabIndex value="1" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="createXmlOutputFileCheckBox" />
<Location value="6, 179" />
<Text value="${res:ICSharpCode.UnitTesting.OptionsPanel.CreateXmlOutputFile}" />
<TabIndex value="6" />
<Size value="420, 24" />
<UseVisualStyleBackColor value="True" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="threadCheckBox" />
<Location value="6, 149" />

17
src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs

@ -5,17 +5,18 @@ @@ -5,17 +5,18 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Profiling;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Commands;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Profiling;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Commands;
using ICSharpCode.SharpDevelop.Util;
@ -309,6 +310,10 @@ namespace ICSharpCode.UnitTesting @@ -309,6 +310,10 @@ namespace ICSharpCode.UnitTesting
helper.Labels = options.Labels;
helper.ShadowCopy = !options.NoShadow;
if (options.CreateXmlOutputFile) {
helper.XmlOutputFile = Path.Combine(Path.GetDirectoryName(project.OutputAssemblyFullPath), project.AssemblyName + "-TestResult.xml");
}
helper.Initialize(project, namespaceFilter, fixture, test);
helper.Results = Path.GetTempFileName();
@ -525,15 +530,7 @@ namespace ICSharpCode.UnitTesting @@ -525,15 +530,7 @@ namespace ICSharpCode.UnitTesting
void AfterFinish(UnitTestApplicationStartHelper helper, string path)
{
Action updater = delegate {
FileService.OpenFile(path);
FileProjectItem file = new FileProjectItem(helper.Project, ItemType.Content, "ProfilingSessions\\" + Path.GetFileName(path));
ProjectService.AddProjectItem(helper.Project, file);
ProjectBrowserPad.Instance.ProjectBrowserControl.RefreshView();
helper.Project.Save();
};
WorkbenchSingleton.SafeThreadCall(updater);
ProfilerService.AddSessionToProject(helper.Project, path);
WorkbenchSingleton.SafeThreadAsyncCall(TestsFinished);
}

29
src/AddIns/Misc/UnitTesting/Src/TestResultsMonitor.cs

@ -138,19 +138,24 @@ namespace ICSharpCode.UnitTesting @@ -138,19 +138,24 @@ namespace ICSharpCode.UnitTesting
string ReadTextAdded()
{
StringBuilder text = null;
using (FileStream fs = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
if (fs.Length > 0) {
text = new StringBuilder();
int bytesRead = 0;
fs.Seek(filePosition, SeekOrigin.Begin);
do {
bytesRead = fs.Read(bytes, 0, BytesBufferLength);
if (bytesRead > 0) {
filePosition += bytesRead;
text.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytesRead));
}
} while (bytesRead > 0 && filePosition < fs.Length);
try {
using (FileStream fs = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
if (fs.Length > 0) {
text = new StringBuilder();
int bytesRead = 0;
fs.Seek(filePosition, SeekOrigin.Begin);
do {
bytesRead = fs.Read(bytes, 0, BytesBufferLength);
if (bytesRead > 0) {
filePosition += bytesRead;
text.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytesRead));
}
} while (bytesRead > 0 && filePosition < fs.Length);
}
}
} catch (FileNotFoundException) {
// Test was aborted before it even started execution
return null;
}
if (text != null) {
return text.ToString();

13
src/AddIns/Misc/UnitTesting/Src/UnitTestingOptions.cs

@ -42,6 +42,11 @@ namespace ICSharpCode.UnitTesting @@ -42,6 +42,11 @@ namespace ICSharpCode.UnitTesting
/// </summary>
public static readonly string LabelsProperty = "Labels";
/// <summary>
/// The name of the create xml file property stored in SharpDevelop's options.
/// </summary>
public static readonly string CreateXmlOutputFileProperty = "CreateXmlOutputFile";
Properties properties;
public UnitTestingOptions()
@ -92,6 +97,14 @@ namespace ICSharpCode.UnitTesting @@ -92,6 +97,14 @@ namespace ICSharpCode.UnitTesting
public bool Labels {
get { return properties.Get<bool>(LabelsProperty, false); }
set { properties.Set<bool>(LabelsProperty, value); }
}
/// <summary>
/// Creates an XML output file.
/// </summary>
public bool CreateXmlOutputFile {
get { return properties.Get<bool>(CreateXmlOutputFileProperty, false); }
set { properties.Set<bool>(CreateXmlOutputFileProperty, value); }
}
}
}

5
src/AddIns/Misc/UnitTesting/Src/UnitTestingOptionsPanel.cs

@ -22,6 +22,7 @@ namespace ICSharpCode.UnitTesting @@ -22,6 +22,7 @@ namespace ICSharpCode.UnitTesting
CheckBox showProgressCheckBox;
CheckBox threadCheckBox;
CheckBox shadowCopyCheckBox;
CheckBox createXmlOutputFileCheckBox;
public UnitTestingOptionsPanel() : this(new UnitTestingOptions())
{
@ -50,6 +51,9 @@ namespace ICSharpCode.UnitTesting @@ -50,6 +51,9 @@ namespace ICSharpCode.UnitTesting
threadCheckBox = (CheckBox)ControlDictionary["threadCheckBox"];
threadCheckBox.Checked = !options.NoThread;
createXmlOutputFileCheckBox = (CheckBox)ControlDictionary["createXmlOutputFileCheckBox"];
createXmlOutputFileCheckBox.Checked = options.CreateXmlOutputFile;
}
public override bool StorePanelContents()
@ -59,6 +63,7 @@ namespace ICSharpCode.UnitTesting @@ -59,6 +63,7 @@ namespace ICSharpCode.UnitTesting
options.NoDots = !showProgressCheckBox.Checked;
options.NoShadow = !shadowCopyCheckBox.Checked;
options.NoThread = !threadCheckBox.Checked;
options.CreateXmlOutputFile = createXmlOutputFileCheckBox.Checked;
return true;
}

2
src/AddIns/Misc/UnitTesting/Test/UnitTestCommandLineTests.cs

@ -221,6 +221,6 @@ namespace UnitTesting.Tests @@ -221,6 +221,6 @@ namespace UnitTesting.Tests
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"MyTests.TestFixture+InnerTest\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
}
}
}

18
src/AddIns/Misc/UnitTesting/Test/UnitTestingOptionsPanelTestFixture.cs

@ -29,6 +29,7 @@ namespace UnitTesting.Tests @@ -29,6 +29,7 @@ namespace UnitTesting.Tests
CheckBox showProgressCheckBox;
CheckBox threadCheckBox;
CheckBox shadowCopyCheckBox;
CheckBox createXmlOutputFileCheckBox;
[SetUp]
public void SetUp()
@ -39,6 +40,7 @@ namespace UnitTesting.Tests @@ -39,6 +40,7 @@ namespace UnitTesting.Tests
options.NoDots = false;
options.NoShadow = false;
options.NoThread = false;
options.CreateXmlOutputFile = false;
panel = new DerivedUnitTestingOptionsPanel(options);
panel.LoadPanelContents();
@ -48,6 +50,7 @@ namespace UnitTesting.Tests @@ -48,6 +50,7 @@ namespace UnitTesting.Tests
showProgressCheckBox = (CheckBox)panel.ControlDictionary["showProgressCheckBox"];
threadCheckBox = (CheckBox)panel.ControlDictionary["threadCheckBox"];
shadowCopyCheckBox = (CheckBox)panel.ControlDictionary["shadowCopyCheckBox"];
createXmlOutputFileCheckBox = (CheckBox)panel.ControlDictionary["createXmlOutputFileCheckBox"];
}
[TearDown]
@ -131,5 +134,20 @@ namespace UnitTesting.Tests @@ -131,5 +134,20 @@ namespace UnitTesting.Tests
panel.StorePanelContents();
Assert.IsTrue(options.NoThread);
}
[Test]
public void CreateXmlOutputFileCheckBoxIsChecked()
{
Assert.IsFalse(createXmlOutputFileCheckBox.Checked);
}
[Test]
public void CreateXmlOutputFileSettingSaved()
{
options.CreateXmlOutputFile = false;
createXmlOutputFileCheckBox.Checked = true;
panel.StorePanelContents();
Assert.IsTrue(options.CreateXmlOutputFile);
}
}
}

19
src/AddIns/Misc/UnitTesting/Test/UnitTestingOptionsTestFixture.cs

@ -141,6 +141,23 @@ namespace UnitTesting.Tests @@ -141,6 +141,23 @@ namespace UnitTesting.Tests
UnitTestingOptions options = new UnitTestingOptions(newProperties);
Assert.IsTrue(options.Labels);
}
}
[Test]
public void SetCreateXmlOutputFileProperty()
{
defaultOptions.CreateXmlOutputFile = true;
Assert.IsTrue(p.Get<bool>(UnitTestingOptions.CreateXmlOutputFileProperty, false));
}
[Test]
public void CreateXmlOutputFileSetToTrueInProperties()
{
Properties newProperties = new Properties();
newProperties.Set<bool>(UnitTestingOptions.CreateXmlOutputFileProperty, true);
UnitTestingOptions options = new UnitTestingOptions(newProperties);
Assert.IsTrue(options.CreateXmlOutputFile);
}
}
}

72
src/AddIns/Misc/UnitTesting/UnitTesting.addin

@ -167,42 +167,44 @@ @@ -167,42 +167,44 @@
class = "ICSharpCode.UnitTesting.CollapseAllCommand"/>-->
</Path>
<Path name="/SharpDevelop/Workbench/MainMenu/QualityTools/Test">
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Path name="/SharpDevelop/Workbench/MainMenu/Analysis">
<MenuItem id="Test" label="${res:ICSharpCode.UnitTesting.TestMenu}" type="Menu" insertbefore="Separator1">
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Condition name="RunningTests"/>
</Not>
</And>
<MenuItem id = "RunAll"
icon = "Icons.16x16.RunAllIcon"
label = "${res:NUnitPad.NUnitPadContent.RunAllTests}"
class = "ICSharpCode.UnitTesting.RunAllTestsInPadCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Condition name="RunningTests"/>
<Condition name="ProjectActive" activeproject="*"/>
</Not>
</And>
<MenuItem id = "RunProjectTests"
icon = "Icons.16x16.RunProgramIcon"
label = "${res:ICSharpCode.UnitTesting.RunProjectTests}"
class = "ICSharpCode.UnitTesting.RunProjectTestsInPadCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Condition name="RunningTests"/>
</Not>
</And>
<MenuItem id = "RunAll"
icon = "Icons.16x16.RunAllIcon"
label = "${res:NUnitPad.NUnitPadContent.RunAllTests}"
class = "ICSharpCode.UnitTesting.RunAllTestsInPadCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Condition name="RunningTests"/>
<Condition name="ProjectActive" activeproject="*"/>
</Not>
</And>
<MenuItem id = "RunProjectTests"
icon = "Icons.16x16.RunProgramIcon"
label = "${res:ICSharpCode.UnitTesting.RunProjectTests}"
class = "ICSharpCode.UnitTesting.RunProjectTestsInPadCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Condition name="RunningTests"/>
</And>
<MenuItem id = "Stop"
icon = "Icons.16x16.Debug.StopProcess"
label = "${res:NUnitPad.NUnitPadContent.StopTests}"
class = "ICSharpCode.UnitTesting.StopTestsCommand"/>
</ComplexCondition>
</And>
<MenuItem id = "Stop"
icon = "Icons.16x16.Debug.StopProcess"
label = "${res:NUnitPad.NUnitPadContent.StopTests}"
class = "ICSharpCode.UnitTesting.StopTestsCommand"/>
</ComplexCondition>
</MenuItem>
</Path>
<!-- Options panel -->

BIN
src/Libraries/Mono.Cecil/Mono.Cecil.dll

Binary file not shown.

4
src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs

@ -125,10 +125,6 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -125,10 +125,6 @@ namespace ICSharpCode.SharpDevelop.Editor
get { return null; }
}
void ITextEditor.ShowInsightWindow(ICSharpCode.TextEditor.Gui.InsightWindow.IInsightDataProvider provider)
{
}
void ITextEditor.ShowCompletionWindow(ICSharpCode.TextEditor.Gui.CompletionWindow.ICompletionDataProvider provider, char ch)
{
}

2
src/Main/Base/Project/Src/Editor/ITextEditor.cs

@ -77,8 +77,6 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -77,8 +77,6 @@ namespace ICSharpCode.SharpDevelop.Editor
/// </summary>
IInsightWindow ActiveInsightWindow { get; }
[Obsolete("Use the overload taking IEnumerable<IInsightItem>")]
void ShowInsightWindow(ICSharpCode.TextEditor.Gui.InsightWindow.IInsightDataProvider provider);
[Obsolete("Use the overload taking ICompletionItemList")]
void ShowCompletionWindow(ICSharpCode.TextEditor.Gui.CompletionWindow.ICompletionDataProvider provider, char ch);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save