Browse Source

Merge branch 'newNR' into newNRvisualizers

newNRvisualizers
Martin Konicek 13 years ago
parent
commit
a43d859016
  1. 73
      SharpDevelop.Tests.sln
  2. 40
      SharpDevelop.sln
  3. 20
      samples/PortSD4AddInToSD5/WorkbenchSingletonIssueProvider.cs
  4. 124
      src/AddIns/Analysis/CodeAnalysis/Src/SuppressMessageCommand.cs
  5. 26
      src/AddIns/Analysis/CodeCoverage/CodeCoverage.sln
  6. 21
      src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj
  7. 5
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs
  8. 6
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageHighlighter.cs
  9. 2
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageOptions.cs
  10. 3
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoveragePad.cs
  11. 47
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResultsReader.cs
  12. 22
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageService.cs
  13. 220
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunner.cs
  14. 80
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunnerContext.cs
  15. 32
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunnerFactory.cs
  16. 24
      src/AddIns/Analysis/CodeCoverage/Project/Src/ICodeCoverageTestRunnerFactory.cs
  17. 32
      src/AddIns/Analysis/CodeCoverage/Project/Src/OpenCoverApplication.cs
  18. 16
      src/AddIns/Analysis/CodeCoverage/Project/Src/RunAllTestsWithCodeCoverageCommand.cs
  19. 142
      src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs
  20. 12
      src/AddIns/Analysis/CodeCoverage/Project/Src/ShowDisplayOptionsDropDown.cs
  21. 14
      src/AddIns/Analysis/CodeCoverage/Test/CodeCoverage.Tests.csproj
  22. 2
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/CodeCoverageResultsMissingFileIdTestFixture.cs
  23. 6
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/OpenCoverSettingsFactoryTests.cs
  24. 9
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/OpenCoverSettingsTestFixture.cs
  25. 4
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/RemoveTaskMarkerTests.cs
  26. 6
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/SolutionCodeCoverageResultsTests.cs
  27. 9
      src/AddIns/Analysis/CodeCoverage/Test/Highlighting/AddCodeCoverageMarkersTestFixture.cs
  28. 21
      src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersCoverMultipleLinesTestFixture.cs
  29. 12
      src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersCoverTwoLinesTestFixture.cs
  30. 8
      src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersInvalidEndColumnTestFixture.cs
  31. 8
      src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersInvalidEndLineTestFixture.cs
  32. 8
      src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersInvalidStartColumnTestFixture.cs
  33. 8
      src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersInvalidStartLineTestFixture.cs
  34. 8
      src/AddIns/Analysis/CodeCoverage/Test/Highlighting/RemoveCodeCoverageMarkersTestFixture.cs
  35. 474
      src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs
  36. 66
      src/AddIns/Analysis/CodeCoverage/Test/Testing/OpenCoverApplicationTests.cs
  37. 544
      src/AddIns/Analysis/CodeCoverage/Test/Testing/RunTestWithCodeCoverageCommandTests.cs
  38. 82
      src/AddIns/Analysis/CodeCoverage/Test/Utils/DerivedCodeCoverageTestRunner.cs
  39. 118
      src/AddIns/Analysis/CodeCoverage/Test/Utils/DerivedRunTestWithCodeCoverageCommand.cs
  40. 80
      src/AddIns/Analysis/CodeCoverage/Test/Utils/MockCodeCoverageTestRunnerFactory.cs
  41. 2
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestProject.cs
  42. 7
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestRunner.cs
  43. 4
      src/AddIns/Analysis/UnitTesting/TestRunner/TestExecutionManager.cs
  44. 8
      src/AddIns/Analysis/UnitTesting/TestRunner/TestExecutionOptions.cs
  45. 10
      src/AddIns/Analysis/UnitTesting/TestRunner/TestProcessRunnerBase.cs
  46. 18
      src/AddIns/Analysis/UnitTesting/TestRunner/TestProcessRunnerBaseContext.cs
  47. 1
      src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj
  48. 3
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/AddMvcControllerToProjectViewModel.cs
  49. 9
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/AddMvcViewToProjectViewModel.cs
  50. 43
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/DelegateCommand.cs
  51. 81
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs
  52. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs
  53. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SearchForIssuesCommand.cs
  54. 1
      src/AddIns/BackendBindings/CSharpBinding/Tests/CSharpBinding.Tests.csproj
  55. 340
      src/AddIns/BackendBindings/CSharpBinding/Tests/CSharpCodeGeneratorTests.cs
  56. 8
      src/AddIns/BackendBindings/FSharpBinding/FSharpInteractive.cs
  57. 32
      src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj
  58. 40
      src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingDesignerGenerator.cs
  59. 1
      src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingWorkbench.cs
  60. 11
      src/AddIns/BackendBindings/Scripting/Project/Src/LineIndenter.cs
  61. 2
      src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleCompletionData.cs
  62. 2
      src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsolePad.cs
  63. 580
      src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingDesignerGenerator.cs
  64. 336
      src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingDesignerLoader.cs
  65. 1
      src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingFormattingStrategy.cs
  66. 94
      src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingNameCreationService.cs
  67. 5
      src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingTextEditorViewContent.cs
  68. 5
      src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingWorkbench.cs
  69. 6
      src/AddIns/BackendBindings/Scripting/Project/Src/SendLineToScriptingConsoleCommand.cs
  70. 3
      src/AddIns/BackendBindings/Scripting/Project/Src/TextEditorFactory.cs
  71. 88
      src/AddIns/BackendBindings/Scripting/Test/Designer/CallBeginInitOnLoadTests.cs
  72. 102
      src/AddIns/BackendBindings/Scripting/Test/Designer/GenerateAcceptButtonFormTestsBase.cs
  73. 28
      src/AddIns/BackendBindings/Scripting/Test/Designer/GenerateDesignerCodeTestsBase.cs
  74. 84
      src/AddIns/BackendBindings/Scripting/Test/Designer/GenerateEnabledUsingPropertyDescriptorTestsBase.cs
  75. 90
      src/AddIns/BackendBindings/Scripting/Test/Designer/GenerateUserControlWithNullPropertyValueTestsBase.cs
  76. 120
      src/AddIns/BackendBindings/Scripting/Test/Designer/LoadFormTestsBase.cs
  77. 204
      src/AddIns/BackendBindings/Scripting/Test/Designer/NameCreationServiceTests.cs
  78. 492
      src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerGeneratorTests.cs
  79. 254
      src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerLoaderGetResourcesTests.cs
  80. 800
      src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerLoaderTests.cs
  81. 20
      src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj
  82. 138
      src/AddIns/BackendBindings/Scripting/Test/Utils/AddInPathHelper.cs
  83. 70
      src/AddIns/BackendBindings/Scripting/Test/Utils/DerivedFormDesignerViewContent.cs
  84. 13
      src/AddIns/BackendBindings/Scripting/Test/Utils/FakeCaret.cs
  85. 116
      src/AddIns/BackendBindings/Scripting/Test/Utils/FakeDocument.cs
  86. 22
      src/AddIns/BackendBindings/Scripting/Test/Utils/FakeDocumentLine.cs
  87. 25
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockAttribute.cs
  88. 166
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockClass.cs
  89. 348
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockDebugger.cs
  90. 182
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockDesignerGenerator.cs
  91. 16
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockEditableViewContent.cs
  92. 60
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockMethod.cs
  93. 2
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockOpenedFile.cs
  94. 188
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockProject.cs
  95. 588
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockProjectContent.cs
  96. 7
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockTextEditor.cs
  97. 4
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockTextEditorViewContent.cs
  98. 7
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockViewContent.cs
  99. 8
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockWorkbench.cs
  100. 146
      src/AddIns/BackendBindings/Scripting/Test/Utils/TestableScriptingDesignerGenerator.cs
  101. Some files were not shown because too many files have changed in this diff Show More

73
SharpDevelop.Tests.sln

@ -87,6 +87,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Mvc.Tests", "src\Add @@ -87,6 +87,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Mvc.Tests", "src\Add
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Mvc", "src\AddIns\BackendBindings\AspNet.Mvc\Project\AspNet.Mvc.csproj", "{D781721F-C2A7-4E95-B76F-247170AC3B13}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding", "src\AddIns\BackendBindings\WixBinding\Project\WixBinding.csproj", "{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding.Tests", "src\AddIns\BackendBindings\WixBinding\Test\WixBinding.Tests.csproj", "{388E7B64-0393-4EB4-A3E3-5C474F141853}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -119,6 +123,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextTemplating.Tests", "src @@ -119,6 +123,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextTemplating.Tests", "src
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextTemplating", "src\AddIns\Misc\TextTemplating\Project\TextTemplating.csproj", "{B5D8C3E6-42EC-4D4B-AD05-3644B32563EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManagement", "PackageManagement", "{485A4CCF-55CF-49F4-BD6D-A22B788C67DA}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement", "src\AddIns\Misc\PackageManagement\Project\PackageManagement.csproj", "{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement.Tests", "src\AddIns\Misc\PackageManagement\Test\PackageManagement.Tests.csproj", "{56E98A01-8398-4A08-9578-C7337711A52B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -187,6 +199,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\ @@ -187,6 +199,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceAnalysis", "src\AddIns\Analysis\SourceAnalysis\SourceAnalysis.csproj", "DC88D67C-E6B5-4994-9FA9-D4AB0E162FB3"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "src\AddIns\Analysis\CodeCoverage\Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "src\AddIns\Analysis\CodeCoverage\Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortSD4AddInToSD5", "samples\PortSD4AddInToSD5\PortSD4AddInToSD5.csproj", "{E2FD63DA-8478-4066-934C-DA82A852C83A}"
EndProject
Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}"
@ -743,6 +759,54 @@ Global @@ -743,6 +759,54 @@ Global
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Release|x86.Build.0 = Release|Any CPU
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Release|x86.ActiveCfg = Release|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Debug|Any CPU.Build.0 = Debug|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Debug|x86.Build.0 = Debug|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Debug|x86.ActiveCfg = Debug|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Release|Any CPU.Build.0 = Release|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Release|Any CPU.ActiveCfg = Release|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Release|x86.Build.0 = Release|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Release|x86.ActiveCfg = Release|Any CPU
{388E7B64-0393-4EB4-A3E3-5C474F141853}.Debug|Any CPU.Build.0 = Debug|Any CPU
{388E7B64-0393-4EB4-A3E3-5C474F141853}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{388E7B64-0393-4EB4-A3E3-5C474F141853}.Debug|x86.Build.0 = Debug|Any CPU
{388E7B64-0393-4EB4-A3E3-5C474F141853}.Debug|x86.ActiveCfg = Debug|Any CPU
{388E7B64-0393-4EB4-A3E3-5C474F141853}.Release|Any CPU.Build.0 = Release|Any CPU
{388E7B64-0393-4EB4-A3E3-5C474F141853}.Release|Any CPU.ActiveCfg = Release|Any CPU
{388E7B64-0393-4EB4-A3E3-5C474F141853}.Release|x86.Build.0 = Release|Any CPU
{388E7B64-0393-4EB4-A3E3-5C474F141853}.Release|x86.ActiveCfg = Release|Any CPU
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Debug|Any CPU.Build.0 = Debug|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Debug|Any CPU.ActiveCfg = Debug|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Debug|x86.Build.0 = Debug|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Debug|x86.ActiveCfg = Debug|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|Any CPU.Build.0 = Release|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|Any CPU.ActiveCfg = Release|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|x86.Build.0 = Release|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|x86.ActiveCfg = Release|x86
{56E98A01-8398-4A08-9578-C7337711A52B}.Debug|Any CPU.Build.0 = Debug|x86
{56E98A01-8398-4A08-9578-C7337711A52B}.Debug|Any CPU.ActiveCfg = Debug|x86
{56E98A01-8398-4A08-9578-C7337711A52B}.Debug|x86.Build.0 = Debug|x86
{56E98A01-8398-4A08-9578-C7337711A52B}.Debug|x86.ActiveCfg = Debug|x86
{56E98A01-8398-4A08-9578-C7337711A52B}.Release|Any CPU.Build.0 = Release|x86
{56E98A01-8398-4A08-9578-C7337711A52B}.Release|Any CPU.ActiveCfg = Release|x86
{56E98A01-8398-4A08-9578-C7337711A52B}.Release|x86.Build.0 = Release|x86
{56E98A01-8398-4A08-9578-C7337711A52B}.Release|x86.ActiveCfg = Release|x86
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|x86.Build.0 = Debug|Any CPU
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|x86.ActiveCfg = Debug|Any CPU
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Release|Any CPU.Build.0 = Release|Any CPU
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Release|x86.Build.0 = Release|Any CPU
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Release|x86.ActiveCfg = Release|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|x86.Build.0 = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|x86.ActiveCfg = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|Any CPU.Build.0 = Release|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|x86.Build.0 = Release|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -786,6 +850,8 @@ Global @@ -786,6 +850,8 @@ Global
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {E0646C25-36F2-4524-969F-FA621353AB94}
{0B12A079-B2DB-42B9-8A8E-AA5CBC2B3225} = {E0646C25-36F2-4524-969F-FA621353AB94}
{D781721F-C2A7-4E95-B76F-247170AC3B13} = {E0646C25-36F2-4524-969F-FA621353AB94}
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e} = {E0646C25-36F2-4524-969F-FA621353AB94}
{388E7B64-0393-4EB4-A3E3-5C474F141853} = {E0646C25-36F2-4524-969F-FA621353AB94}
{80F76D10-0B44-4D55-B4BD-DAEB5464090C} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{9196DD8A-B4D4-4780-8742-C5762E547FC2} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
@ -797,8 +863,11 @@ Global @@ -797,8 +863,11 @@ Global
{A569DCC1-C608-45FD-B770-4F79335EF154} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{5186325C-DD7F-4246-9BE7-3F384EFBF5A6} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{B5D8C3E6-42EC-4D4B-AD05-3644B32563EF} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{485A4CCF-55CF-49F4-BD6D-A22B788C67DA} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B}
{0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B}
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1} = {485A4CCF-55CF-49F4-BD6D-A22B788C67DA}
{56E98A01-8398-4A08-9578-C7337711A52B} = {485A4CCF-55CF-49F4-BD6D-A22B788C67DA}
{0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{DCA2703D-250A-463E-A68A-07ED105AE6BD} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
@ -806,13 +875,13 @@ Global @@ -806,13 +875,13 @@ Global
{DFB936AD-90EE-4B4F-941E-4F4A636F0D92} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{8AA421C8-D7AF-4957-9F43-5135328ACB24} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{0F5192F2-0744-4BA9-A074-6BE82D111B8D} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{83BAB756-1010-4A2F-9B9D-7F9EBCB288F5} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{A9F12710-24E4-46D4-832C-6ECB395B9EAD} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{B7823AE9-4B43-4859-8796-2EBDC116FBB8} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{BAD94D6E-4159-4CB6-B991-486F412D9BB6} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{EEF5E054-4192-4A57-8FBF-E860D808A51D} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{83BAB756-1010-4A2F-9B9D-7F9EBCB288F5} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
@ -825,5 +894,7 @@ Global @@ -825,5 +894,7 @@ Global
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181} = {B3352C08-3CB4-4DD9-996F-B9DCE4356BB9}
{3EAA45A9-735C-4AC7-A799-947B93EA449D} = {B3352C08-3CB4-4DD9-996F-B9DCE4356BB9}
DC88D67C-E6B5-4994-9FA9-D4AB0E162FB3 = {B3352C08-3CB4-4DD9-996F-B9DCE4356BB9}
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B} = {B3352C08-3CB4-4DD9-996F-B9DCE4356BB9}
{08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {B3352C08-3CB4-4DD9-996F-B9DCE4356BB9}
EndGlobalSection
EndGlobal

40
SharpDevelop.sln

@ -75,6 +75,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding", "src\AddIns\B @@ -75,6 +75,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding", "src\AddIns\B
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Mvc", "src\AddIns\BackendBindings\AspNet.Mvc\Project\AspNet.Mvc.csproj", "{D781721F-C2A7-4E95-B76F-247170AC3B13}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding", "src\AddIns\BackendBindings\WixBinding\Project\WixBinding.csproj", "{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -105,6 +107,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortSD4AddInToSD5", "sample @@ -105,6 +107,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortSD4AddInToSD5", "sample
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextTemplating", "src\AddIns\Misc\TextTemplating\Project\TextTemplating.csproj", "{B5D8C3E6-42EC-4D4B-AD05-3644B32563EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManagement", "PackageManagement", "{87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement", "src\AddIns\Misc\PackageManagement\Project\PackageManagement.csproj", "{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -159,6 +167,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\ @@ -159,6 +167,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceAnalysis", "src\AddIns\Analysis\SourceAnalysis\SourceAnalysis.csproj", "44FA68C9-DAD1-4C3C-90BB-3435F0D1D128"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "src\AddIns\Analysis\CodeCoverage\Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -633,6 +643,30 @@ Global @@ -633,6 +643,30 @@ Global
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|x86.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|x86.ActiveCfg = Release|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Debug|Any CPU.Build.0 = Debug|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Debug|x86.Build.0 = Debug|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Debug|x86.ActiveCfg = Debug|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Release|Any CPU.Build.0 = Release|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Release|Any CPU.ActiveCfg = Release|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Release|x86.Build.0 = Release|Any CPU
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e}.Release|x86.ActiveCfg = Release|Any CPU
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Debug|Any CPU.Build.0 = Debug|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Debug|Any CPU.ActiveCfg = Debug|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Debug|x86.Build.0 = Debug|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Debug|x86.ActiveCfg = Debug|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|Any CPU.Build.0 = Release|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|Any CPU.ActiveCfg = Release|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|x86.Build.0 = Release|x86
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|x86.ActiveCfg = Release|x86
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|x86.Build.0 = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|x86.ActiveCfg = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|Any CPU.Build.0 = Release|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|x86.Build.0 = Release|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -669,6 +703,7 @@ Global @@ -669,6 +703,7 @@ Global
{70966F84-74C9-4067-A379-0C674A929233} = {E0646C25-36F2-4524-969F-FA621353AB94}
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {E0646C25-36F2-4524-969F-FA621353AB94}
{D781721F-C2A7-4E95-B76F-247170AC3B13} = {E0646C25-36F2-4524-969F-FA621353AB94}
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e} = {E0646C25-36F2-4524-969F-FA621353AB94}
{9196DD8A-B4D4-4780-8742-C5762E547FC2} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{4B8F0F98-8BE1-402B-AA8B-C8D548577B38} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
@ -679,8 +714,10 @@ Global @@ -679,8 +714,10 @@ Global
{64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{E2FD63DA-8478-4066-934C-DA82A852C83A} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{B5D8C3E6-42EC-4D4B-AD05-3644B32563EF} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {59A30AA6-D600-41AB-B7A1-9543469DBE36}
{0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {59A30AA6-D600-41AB-B7A1-9543469DBE36}
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1} = {87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D}
{0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{DCA2703D-250A-463E-A68A-07ED105AE6BD} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
@ -688,13 +725,13 @@ Global @@ -688,13 +725,13 @@ Global
{8AA421C8-D7AF-4957-9F43-5135328ACB24} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{5FB020B2-B64B-4016-999A-CB8FD9274D72} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{D54BEB89-8CBE-475C-8BB9-836D2FD71260} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{A9F12710-24E4-46D4-832C-6ECB395B9EAD} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{B7823AE9-4B43-4859-8796-2EBDC116FBB8} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{BAD94D6E-4159-4CB6-B991-486F412D9BB6} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{EEF5E054-4192-4A57-8FBF-E860D808A51D} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{D54BEB89-8CBE-475C-8BB9-836D2FD71260} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
@ -702,6 +739,7 @@ Global @@ -702,6 +739,7 @@ Global
{1F261725-6318-4434-A1B1-6C70CE4CD324} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{3EAA45A9-735C-4AC7-A799-947B93EA449D} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
44FA68C9-DAD1-4C3C-90BB-3435F0D1D128 = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}
{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}
EndGlobalSection

20
samples/PortSD4AddInToSD5/WorkbenchSingletonIssueProvider.cs

@ -11,6 +11,7 @@ using System.Collections.Generic; @@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.PatternMatching;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.SharpDevelop;
@ -102,8 +103,7 @@ namespace PortSD4AddInToSD5 @@ -102,8 +103,7 @@ namespace PortSD4AddInToSD5
script => {
script.Replace(invocationExpression,
new IdentifierExpression("SD").Member("MainThread")
.Invoke("InvokeAsync", arg)
.Invoke("FireAndForget"));
.Invoke("InvokeAsyncAndForget", arg));
});
break;
}
@ -122,6 +122,22 @@ namespace PortSD4AddInToSD5 @@ -122,6 +122,22 @@ namespace PortSD4AddInToSD5
});
break;
}
case "ICSharpCode.SharpDevelop.IMessageLoop.InvokeAsync":
// We used to recommend SD.MainThread.InvokeAsync(...).FireAndForget(),
// but it's better to use SD.MainThread.InvokeAsyncAndForget(...)
if (invocationExpression.Clone().Invoke("FireAndForget").IsMatch(invocationExpression.Parent.Parent)) {
var ident = invocationExpression.Parent.GetChildByRole(Roles.Identifier);
yield return new CodeIssue(
"Use InvokeAsyncAndForget() instead",
ident.StartLocation, ident.EndLocation,
new CodeAction("Use InvokeAsyncAndForget() instead",
script => {
var newInvocation = (InvocationExpression)invocationExpression.Clone();
((MemberReferenceExpression)newInvocation.Target).MemberName = "InvokeAsyncAndForget";
script.Replace(invocationExpression.Parent.Parent, newInvocation);
}));
}
break;
}
}
}

124
src/AddIns/Analysis/CodeAnalysis/Src/SuppressMessageCommand.cs

@ -7,8 +7,12 @@ using System.IO; @@ -7,8 +7,12 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Documents;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
@ -25,57 +29,42 @@ namespace ICSharpCode.CodeAnalysis @@ -25,57 +29,42 @@ namespace ICSharpCode.CodeAnalysis
FxCopTaskTag tag = t.Tag as FxCopTaskTag;
if (tag == null)
continue;
throw new NotImplementedException();
/*CodeGenerator codegen = tag.ProjectContent.Language.CodeGenerator;
if (codegen == null)
continue;
FilePosition p;
ICodeGenerator gen = tag.Project.CodeGenerator;
ICompilation compilation;
if (t.FileName != null)
compilation = SD.ParserService.GetCompilationForFile(t.FileName);
else
compilation = SD.ParserService.GetCompilation(tag.Project);
IAttribute attribute = CreateSuppressAttribute(compilation, tag);
if (tag.MemberName == null)
p = GetAssemblyAttributeInsertionPosition(tag.ProjectContent);
gen.AddAssemblyAttribute(attribute);
else
p = GetPosition(tag.ProjectContent, tag.TypeName, tag.MemberName);
if (p.CompilationUnit == null || p.FileName == null || p.Line <= 0)
continue;
IViewContent viewContent = FileService.OpenFile(p.FileName);
ITextEditorProvider provider = viewContent as ITextEditorProvider;
if (provider == null)
continue;
IDocument document = provider.TextEditor.Document;
if (p.Line >= document.TotalNumberOfLines)
continue;
IDocumentLine line = document.GetLine(p.Line);
StringBuilder indentation = new StringBuilder();
for (int i = line.Offset; i < document.TextLength; i++) {
char c = document.GetCharAt(i);
if (c == ' ' || c == '\t')
indentation.Append(c);
else
break;
}
string code = codegen.GenerateCode(CreateSuppressAttribute(p.CompilationUnit, tag), indentation.ToString());
if (!code.EndsWith("\n")) code += Environment.NewLine;
document.Insert(line.Offset, code);
provider.TextEditor.JumpTo(p.Line, p.Column);
TaskService.Remove(t);
ParserService.ParseViewContent(viewContent);*/
gen.AddAttribute(GetEntity(compilation, tag.TypeName, tag.MemberName), attribute);
}
}
internal static DomRegion GetPosition(ICompilation compilation, string className, string memberName)
{
IEntity entity = GetEntity(compilation, className, memberName);
return entity == null ? DomRegion.Empty : entity.Region;
}
static IEntity GetEntity(ICompilation compilation, string className, string memberName)
{
var typeName = new TopLevelTypeName(className);
ITypeDefinition type = compilation.MainAssembly.GetTypeDefinition(typeName);
if (type != null) {
if (string.IsNullOrEmpty(memberName))
return type.Region;
return type;
IMember m = GetMember(type, memberName);
if (m != null)
return m.Region;
return m;
return type.Region;
return type;
}
return DomRegion.Empty;
return null;
}
static IMember GetMember(ITypeDefinition type, string memberName)
@ -84,62 +73,25 @@ namespace ICSharpCode.CodeAnalysis @@ -84,62 +73,25 @@ namespace ICSharpCode.CodeAnalysis
return type.GetMembers(m => m.ReflectionName == fullName).FirstOrDefault();
}
/*
FilePosition GetAssemblyAttributeInsertionPosition(IProjectContent pc)
{
FilePosition best = FilePosition.Empty;
foreach (IAttribute attrib in pc.GetAssemblyAttributes()) {
ICompilationUnit cu = attrib.CompilationUnit;
if (cu != null && !attrib.Region.IsEmpty) {
var newPos = new FilePosition(cu, attrib.Region.BeginLine, attrib.Region.BeginColumn);
if (IsBetterAssemblyAttributeInsertionPosition(newPos, best)) {
best = newPos;
}
}
}
return best;
}
const string FullAttributeName = "System.Diagnostics.CodeAnalysis.SuppressMessageAttribute";
bool IsBetterAssemblyAttributeInsertionPosition(FilePosition a, FilePosition b)
static IAttribute CreateSuppressAttribute(ICompilation compilation, FxCopTaskTag tag)
{
if (b.IsEmpty)
return true;
bool aIsAssemblyInfo = "AssemblyInfo".Equals(Path.GetFileNameWithoutExtension(a.FileName), StringComparison.OrdinalIgnoreCase);
bool bIsAssemblyInfo = "AssemblyInfo".Equals(Path.GetFileNameWithoutExtension(b.FileName), StringComparison.OrdinalIgnoreCase);
if (aIsAssemblyInfo && !bIsAssemblyInfo)
return true;
if (!aIsAssemblyInfo && bIsAssemblyInfo)
return false;
return a.Line > b.Line;
}*/
const string NamespaceName = "System.Diagnostics.CodeAnalysis";
const string AttributeName = "SuppressMessage";
/*
static Ast.AbstractNode CreateSuppressAttribute(ICompilationUnit cu, FxCopTaskTag tag)
{
//System.Diagnostics.CodeAnalysis.SuppressMessageAttribute
bool importedCodeAnalysis = CheckImports(cu);
// [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId:="fileIdentifier"]
Ast.Attribute a = new Ast.Attribute {
Name = importedCodeAnalysis ? AttributeName : NamespaceName + "." + AttributeName,
PositionalArguments = {
new Ast.PrimitiveExpression(tag.Category, tag.Category),
new Ast.PrimitiveExpression(tag.CheckID, tag.CheckID)
}
};
IType attributeType = compilation.FindType(new FullTypeName(FullAttributeName));
IType stringType = compilation.FindType(KnownTypeCode.String);
KeyValuePair<IMember, ResolveResult>[] namedArgs = null;
if (tag.MessageID != null) {
a.NamedArguments.Add(new Ast.NamedArgumentExpression("MessageId",
new Ast.PrimitiveExpression(tag.MessageID, tag.MessageID)));
IMember messageId = attributeType.GetProperties(p => p.Name == "MessageId").FirstOrDefault();
namedArgs = new[] { new KeyValuePair<IMember, ResolveResult>(messageId, new ConstantResolveResult(stringType, tag.MessageID)) };
}
return new Ast.AttributeSection {
AttributeTarget = tag.MemberName == null ? "assembly" : null,
Attributes = { a }
};
}*/
return new DefaultAttribute(
attributeType, new[] {
new ConstantResolveResult(stringType, tag.Category),
new ConstantResolveResult(stringType, tag.CheckID)
}, namedArgs);
}
}
}

26
src/AddIns/Analysis/CodeCoverage/CodeCoverage.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.2.1.8805
# SharpDevelop 4.3
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}"
@ -10,20 +10,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\. @@ -10,20 +10,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "..\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "..\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "..\..\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Tests", "..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj", "{4980B743-B32F-4aba-AABD-45E2CAD3568D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -46,10 +46,6 @@ Global @@ -46,10 +46,6 @@ Global
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.Build.0 = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.Build.0 = Release|Any CPU
@ -58,10 +54,6 @@ Global @@ -58,10 +54,6 @@ Global
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|Any CPU
@ -74,5 +66,13 @@ Global @@ -74,5 +66,13 @@ Global
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.Build.0 = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.Build.0 = Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4980B743-B32F-4aba-AABD-45E2CAD3568D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4980B743-B32F-4aba-AABD-45E2CAD3568D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4980B743-B32F-4aba-AABD-45E2CAD3568D}.Release|Any CPU.Build.0 = Debug|Any CPU
{4980B743-B32F-4aba-AABD-45E2CAD3568D}.Release|Any CPU.ActiveCfg = Debug|Any CPU
EndGlobalSection
EndGlobal

21
src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj

@ -15,11 +15,13 @@ @@ -15,11 +15,13 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<RunCodeAnalysis>False</RunCodeAnalysis>
<NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\..\..\AddIns\Analysis\CodeCoverage\</OutputPath>
@ -28,6 +30,7 @@ @@ -28,6 +30,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\..\..\..\AddIns\Analysis\CodeCoverage\</OutputPath>
@ -37,6 +40,9 @@ @@ -37,6 +40,9 @@
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<Prefer32Bit>False</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
@ -81,6 +87,7 @@ @@ -81,6 +87,7 @@
<Compile Include="Src\CodeCoveragePropertyTreeNode.cs" />
<Compile Include="Src\CodeCoverageResults.cs" />
<Compile Include="Src\CodeCoverageMethod.cs" />
<Compile Include="Src\CodeCoverageResultsReader.cs" />
<Compile Include="Src\CodeCoverageSequencePoint.cs" />
<Compile Include="Src\CodeCoverageTestRunner.cs" />
<Compile Include="Src\CodeCoverageTestRunnerContext.cs" />
@ -130,6 +137,11 @@ @@ -130,6 +137,11 @@
<Name>ICSharpCode.AvalonEdit</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
@ -165,11 +177,6 @@ @@ -165,11 +177,6 @@
<Name>UnitTesting</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Src\CodeCoverageOptionsPanel.xaml" />

5
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs

@ -14,6 +14,7 @@ using ICSharpCode.AvalonEdit.Editing; @@ -14,6 +14,7 @@ using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
@ -74,7 +75,7 @@ namespace ICSharpCode.CodeCoverage @@ -74,7 +75,7 @@ namespace ICSharpCode.CodeCoverage
showSourceCodePanel = value;
OnShowSourceCodePanelChanged();
UpdateDisplay();
DisplaySelectedItem(treeView.SelectedNode as CodeCoverageTreeNode);
DisplaySelectedItem(treeView.SelectedNode as CodeCoverageTreeNode);
}
}
}
@ -192,7 +193,7 @@ namespace ICSharpCode.CodeCoverage @@ -192,7 +193,7 @@ namespace ICSharpCode.CodeCoverage
if (Controls.Contains(toolStrip)) {
Controls.Remove(toolStrip);
}
Controls.Add(toolStrip);
Controls.Add(toolStrip);
}
void CodeCoverageTreeViewAfterSelect(object sender, TreeViewEventArgs e)

6
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageHighlighter.cs

@ -5,8 +5,10 @@ using System; @@ -5,8 +5,10 @@ using System;
using System.Collections.Generic;
using System.Windows.Media;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.WinForms;
namespace ICSharpCode.CodeCoverage
{
@ -71,9 +73,9 @@ namespace ICSharpCode.CodeCoverage @@ -71,9 +73,9 @@ namespace ICSharpCode.CodeCoverage
{
if (sequencePoint.Line <= 0 || sequencePoint.EndLine <= 0 || sequencePoint.Column <= 0 || sequencePoint.EndColumn <= 0) {
return false;
} else if (sequencePoint.Line > document.TotalNumberOfLines) {
} else if (sequencePoint.Line > document.LineCount) {
return false;
} else if (sequencePoint.EndLine > document.TotalNumberOfLines) {
} else if (sequencePoint.EndLine > document.LineCount) {
return false;
} else if (sequencePoint.Line == sequencePoint.EndLine && sequencePoint.Column > sequencePoint.EndColumn) {
return false;

2
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageOptions.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.CodeCoverage @@ -27,7 +27,7 @@ namespace ICSharpCode.CodeCoverage
static CodeCoverageOptions()
{
properties = PropertyService.Get(OptionsProperty, new Properties());
properties = PropertyService.NestedProperties(OptionsProperty);
}
public static Properties Properties {

3
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoveragePad.cs

@ -2,9 +2,8 @@ @@ -2,9 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.CodeCoverage
{

47
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResultsReader.cs

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.IO;
namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageResultsReader
{
List<string> fileNames = new List<string>();
IFileSystem fileSystem = new FileSystem();
List<string> missingFileNames = new List<string>();
public CodeCoverageResultsReader()
{
}
public void AddResultsFile(string fileName)
{
fileNames.Add(fileName);
}
public IEnumerable<CodeCoverageResults> GetResults()
{
foreach (string fileName in fileNames) {
if (fileSystem.FileExists(fileName)) {
yield return ReadCodeCoverageResults(fileName);
} else {
missingFileNames.Add(fileName);
}
}
}
CodeCoverageResults ReadCodeCoverageResults(string fileName)
{
TextReader reader = fileSystem.CreateTextReader(fileName);
return new CodeCoverageResults(reader);
}
public IEnumerable<string> GetMissingResultsFiles()
{
return missingFileNames;
}
}
}

22
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageService.cs

@ -1,11 +1,13 @@ @@ -1,11 +1,13 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.CodeCoverage
{
@ -20,7 +22,7 @@ namespace ICSharpCode.CodeCoverage @@ -20,7 +22,7 @@ namespace ICSharpCode.CodeCoverage
static CodeCoverageService()
{
WorkbenchSingleton.Workbench.ViewOpened += ViewOpened;
SD.Workbench.ViewOpened += ViewOpened;
ProjectService.SolutionLoaded += SolutionLoaded;
}
@ -110,17 +112,17 @@ namespace ICSharpCode.CodeCoverage @@ -110,17 +112,17 @@ namespace ICSharpCode.CodeCoverage
static void ShowCodeCoverage()
{
// Highlight any open files.
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) {
foreach (IViewContent view in SD.Workbench.ViewContentCollection) {
ShowCodeCoverage(view);
}
}
static void HideCodeCoverage()
{
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) {
ITextEditorProvider editorProvider = view as ITextEditorProvider;
if (editorProvider != null) {
codeCoverageHighlighter.RemoveMarkers(editorProvider.TextEditor.Document);
foreach (IViewContent view in SD.Workbench.ViewContentCollection) {
ITextEditor textEditor = view.GetService<ITextEditor>();
if (textEditor != null) {
codeCoverageHighlighter.RemoveMarkers(textEditor.Document);
}
}
}
@ -134,9 +136,9 @@ namespace ICSharpCode.CodeCoverage @@ -134,9 +136,9 @@ namespace ICSharpCode.CodeCoverage
static void ShowCodeCoverage(IViewContent view)
{
ITextEditorProvider editorProvider = view as ITextEditorProvider;
if (editorProvider != null && view.PrimaryFileName != null) {
ShowCodeCoverage(editorProvider.TextEditor, view.PrimaryFileName);
ITextEditor textEditor = view.GetService<ITextEditor>();
if (textEditor != null && view.PrimaryFileName != null) {
ShowCodeCoverage(textEditor, view.PrimaryFileName);
}
}

220
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunner.cs

@ -1,110 +1,110 @@ @@ -1,110 +1,110 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageTestRunner : TestProcessRunnerBase
{
UnitTestingOptions options;
IFileSystem fileSystem;
OpenCoverApplication partCoverApplication;
OpenCoverSettingsFactory settingsFactory;
public CodeCoverageTestRunner()
: this(new CodeCoverageTestRunnerContext())
{
}
public CodeCoverageTestRunner(CodeCoverageTestRunnerContext context)
: base(context)
{
this.options = context.Options;
this.fileSystem = context.CodeCoverageFileSystem;
settingsFactory = new OpenCoverSettingsFactory(fileSystem);
}
public bool HasCodeCoverageResults()
{
return fileSystem.FileExists(CodeCoverageResultsFileName);
}
public CodeCoverageResults ReadCodeCoverageResults()
{
TextReader reader = fileSystem.CreateTextReader(CodeCoverageResultsFileName);
return new CodeCoverageResults(reader);
}
public string CodeCoverageResultsFileName {
get { return partCoverApplication.CodeCoverageResultsFileName; }
}
public override void Start(SelectedTests selectedTests)
{
AddProfilerEnvironmentVariableToProcessRunner();
CreatePartCoverApplication(selectedTests);
RemoveExistingCodeCoverageResultsFile();
CreateDirectoryForCodeCoverageResultsFile();
AppendRunningCodeCoverageMessage();
base.Start(selectedTests);
}
void AddProfilerEnvironmentVariableToProcessRunner()
{
ProcessRunner.EnvironmentVariables.Add("COMPLUS_ProfAPI_ProfilerCompatibilitySetting", "EnableV2Profiler");
}
void CreatePartCoverApplication(SelectedTests selectedTests)
{
NUnitConsoleApplication nunitConsoleApp = new NUnitConsoleApplication(selectedTests, options);
nunitConsoleApp.Results = base.TestResultsMonitor.FileName;
OpenCoverSettings settings = settingsFactory.CreateOpenCoverSettings(selectedTests.Project);
partCoverApplication = new OpenCoverApplication(nunitConsoleApp, settings);
}
void RemoveExistingCodeCoverageResultsFile()
{
string fileName = CodeCoverageResultsFileName;
if (fileSystem.FileExists(fileName)) {
fileSystem.DeleteFile(fileName);
}
}
void CreateDirectoryForCodeCoverageResultsFile()
{
string directory = Path.GetDirectoryName(CodeCoverageResultsFileName);
if (!fileSystem.DirectoryExists(directory)) {
fileSystem.CreateDirectory(directory);
}
}
void AppendRunningCodeCoverageMessage()
{
string message = ParseString("${res:ICSharpCode.CodeCoverage.RunningCodeCoverage}");
OnMessageReceived(message);
}
protected virtual string ParseString(string text)
{
return StringParser.Parse(text);
}
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
{
return partCoverApplication.GetProcessStartInfo();
}
protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
{
return new NUnitTestResult(testResult);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Diagnostics;
//using System.IO;
//using ICSharpCode.Core;
//using ICSharpCode.SharpDevelop.Project;
//using ICSharpCode.UnitTesting;
//
//namespace ICSharpCode.CodeCoverage
//{
// public class CodeCoverageTestRunner : TestProcessRunnerBase
// {
// UnitTestingOptions options;
// IFileSystem fileSystem;
// OpenCoverApplication partCoverApplication;
// OpenCoverSettingsFactory settingsFactory;
//
// public CodeCoverageTestRunner()
// : this(new CodeCoverageTestRunnerContext())
// {
// }
//
// public CodeCoverageTestRunner(CodeCoverageTestRunnerContext context)
// : base(context)
// {
// this.options = context.Options;
// this.fileSystem = context.CodeCoverageFileSystem;
// settingsFactory = new OpenCoverSettingsFactory(fileSystem);
// }
//
// public bool HasCodeCoverageResults()
// {
// return fileSystem.FileExists(CodeCoverageResultsFileName);
// }
//
// public CodeCoverageResults ReadCodeCoverageResults()
// {
// TextReader reader = fileSystem.CreateTextReader(CodeCoverageResultsFileName);
// return new CodeCoverageResults(reader);
// }
//
// public string CodeCoverageResultsFileName {
// get { return partCoverApplication.CodeCoverageResultsFileName; }
// }
//
// public override void Start(SelectedTests selectedTests)
// {
// AddProfilerEnvironmentVariableToProcessRunner();
// CreatePartCoverApplication(selectedTests);
// RemoveExistingCodeCoverageResultsFile();
// CreateDirectoryForCodeCoverageResultsFile();
// AppendRunningCodeCoverageMessage();
//
// base.Start(selectedTests);
// }
//
// void AddProfilerEnvironmentVariableToProcessRunner()
// {
// ProcessRunner.EnvironmentVariables.Add("COMPLUS_ProfAPI_ProfilerCompatibilitySetting", "EnableV2Profiler");
// }
//
// void CreatePartCoverApplication(SelectedTests selectedTests)
// {
// NUnitConsoleApplication nunitConsoleApp = new NUnitConsoleApplication(selectedTests, options);
// nunitConsoleApp.Results = base.TestResultsMonitor.FileName;
//
// OpenCoverSettings settings = settingsFactory.CreateOpenCoverSettings(selectedTests.Project);
// partCoverApplication = new OpenCoverApplication(nunitConsoleApp, settings);
// }
//
// void RemoveExistingCodeCoverageResultsFile()
// {
// string fileName = CodeCoverageResultsFileName;
// if (fileSystem.FileExists(fileName)) {
// fileSystem.DeleteFile(fileName);
// }
// }
//
// void CreateDirectoryForCodeCoverageResultsFile()
// {
// string directory = Path.GetDirectoryName(CodeCoverageResultsFileName);
// if (!fileSystem.DirectoryExists(directory)) {
// fileSystem.CreateDirectory(directory);
// }
// }
//
// void AppendRunningCodeCoverageMessage()
// {
// string message = ParseString("${res:ICSharpCode.CodeCoverage.RunningCodeCoverage}");
// OnMessageReceived(message);
// }
//
// protected virtual string ParseString(string text)
// {
// return StringParser.Parse(text);
// }
//
// protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
// {
// return partCoverApplication.GetProcessStartInfo();
// }
//
// protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
// {
// return new NUnitTestResult(testResult);
// }
// }
//}

80
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunnerContext.cs

@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageTestRunnerContext : TestProcessRunnerBaseContext
{
UnitTestingOptions options;
public CodeCoverageTestRunnerContext()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new FileSystem(),
new UnitTestMessageService(),
new UnitTestingOptions())
{
}
public CodeCoverageTestRunnerContext(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
ICSharpCode.CodeCoverage.IFileSystem fileSystem,
IUnitTestMessageService messageService,
UnitTestingOptions options)
: base(processRunner, testResultsMonitor, fileSystem, messageService)
{
this.options = options;
}
public UnitTestingOptions Options {
get { return options; }
}
public ICSharpCode.CodeCoverage.IFileSystem CodeCoverageFileSystem {
get { return base.FileSystem as ICSharpCode.CodeCoverage.IFileSystem; }
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.UnitTesting;
//
//namespace ICSharpCode.CodeCoverage
//{
// public class CodeCoverageTestRunnerContext : TestProcessRunnerBaseContext
// {
// UnitTestingOptions options;
//
// public CodeCoverageTestRunnerContext()
// : this(new UnitTestProcessRunner(),
// new TestResultsMonitor(),
// new FileSystem(),
// new UnitTestMessageService(),
// new UnitTestingOptions())
// {
// }
//
// public CodeCoverageTestRunnerContext(IUnitTestProcessRunner processRunner,
// ITestResultsMonitor testResultsMonitor,
// ICSharpCode.CodeCoverage.IFileSystem fileSystem,
// IUnitTestMessageService messageService,
// UnitTestingOptions options)
// : base(processRunner, testResultsMonitor, fileSystem, messageService)
// {
// this.options = options;
// }
//
// public UnitTestingOptions Options {
// get { return options; }
// }
//
// public ICSharpCode.CodeCoverage.IFileSystem CodeCoverageFileSystem {
// get { return base.FileSystem as ICSharpCode.CodeCoverage.IFileSystem; }
// }
// }
//}

32
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunnerFactory.cs

@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageTestRunnerFactory : ICodeCoverageTestRunnerFactory
{
public CodeCoverageTestRunner CreateCodeCoverageTestRunner()
{
return new CodeCoverageTestRunner();
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.UnitTesting;
//
//namespace ICSharpCode.CodeCoverage
//{
// public class CodeCoverageTestRunnerFactory : ICodeCoverageTestRunnerFactory
// {
// public CodeCoverageTestRunner CreateCodeCoverageTestRunner()
// {
// return new CodeCoverageTestRunner();
// }
// }
//}

24
src/AddIns/Analysis/CodeCoverage/Project/Src/ICodeCoverageTestRunnerFactory.cs

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.CodeCoverage
{
public interface ICodeCoverageTestRunnerFactory
{
CodeCoverageTestRunner CreateCodeCoverageTestRunner();
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//
//namespace ICSharpCode.CodeCoverage
//{
// public interface ICodeCoverageTestRunnerFactory
// {
// CodeCoverageTestRunner CreateCodeCoverageTestRunner();
// }
//}

32
src/AddIns/Analysis/CodeCoverage/Project/Src/OpenCoverApplication.cs

@ -15,27 +15,36 @@ namespace ICSharpCode.CodeCoverage @@ -15,27 +15,36 @@ namespace ICSharpCode.CodeCoverage
public class OpenCoverApplication
{
string fileName = String.Empty;
NUnitConsoleApplication nunitConsoleApp;
ProcessStartInfo targetProcessStartInfo;
OpenCoverSettings settings;
StringBuilder arguments;
IProject project;
public OpenCoverApplication(string fileName, NUnitConsoleApplication nunitConsoleApp, OpenCoverSettings settings)
public OpenCoverApplication(
string fileName,
ProcessStartInfo targetProcessStartInfo,
OpenCoverSettings settings,
IProject project)
{
this.fileName = fileName;
this.nunitConsoleApp = nunitConsoleApp;
this.targetProcessStartInfo = targetProcessStartInfo;
this.settings = settings;
this.project = project;
if (String.IsNullOrEmpty(fileName)) {
GetPartCoverApplicationFileName();
GetOpenCoverApplicationFileName();
}
}
public OpenCoverApplication(NUnitConsoleApplication nunitConsoleApp, OpenCoverSettings settings)
: this(null, nunitConsoleApp, settings)
public OpenCoverApplication(
ProcessStartInfo targetProcessStartInfo,
OpenCoverSettings settings,
IProject project)
: this(null, targetProcessStartInfo, settings, project)
{
}
void GetPartCoverApplicationFileName()
void GetOpenCoverApplicationFileName()
{
fileName = Path.Combine(FileUtility.ApplicationRootPath, @"bin\Tools\OpenCover\OpenCover.Console.exe");
fileName = Path.GetFullPath(fileName);
@ -51,26 +60,27 @@ namespace ICSharpCode.CodeCoverage @@ -51,26 +60,27 @@ namespace ICSharpCode.CodeCoverage
}
public string Target {
get { return nunitConsoleApp.FileName; }
get { return targetProcessStartInfo.FileName; }
}
public string GetTargetArguments()
{
return nunitConsoleApp.GetArguments();
return targetProcessStartInfo.Arguments;
}
public string GetTargetWorkingDirectory()
{
return Path.GetDirectoryName(nunitConsoleApp.Assemblies[0]);
return Path.GetDirectoryName(project.OutputAssemblyFullPath);
}
public string CodeCoverageResultsFileName {
get { return new ProjectCodeCoverageResultsFileName(nunitConsoleApp.Project).FileName; }
get { return new ProjectCodeCoverageResultsFileName(project).FileName; }
}
public ProcessStartInfo GetProcessStartInfo()
{
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.EnvironmentVariables.Add("COMPLUS_ProfAPI_ProfilerCompatibilitySetting", "EnableV2Profiler");
processStartInfo.FileName = FileName;
processStartInfo.Arguments = GetArguments();
return processStartInfo;

16
src/AddIns/Analysis/CodeCoverage/Project/Src/RunAllTestsWithCodeCoverageCommand.cs

@ -2,23 +2,25 @@ @@ -2,23 +2,25 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.CodeCoverage
{
public class RunAllTestsWithCodeCoverageCommand : RunTestWithCodeCoverageCommand
{
public RunAllTestsWithCodeCoverageCommand()
public override void Run()
{
ITestService testService = SD.GetRequiredService<ITestService>();
if (testService.OpenSolution != null) {
base.Run();
}
}
/// <summary>
/// Set Owner to null so all tests are run.
/// </summary>
public override void Run()
protected override IEnumerable<ITest> GetTests(ITestService testService)
{
Owner = null;
base.Run();
return new[] { testService.OpenSolution };
}
}
}

142
src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs

@ -2,14 +2,18 @@ @@ -2,14 +2,18 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Util;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.CodeCoverage
@ -18,121 +22,119 @@ namespace ICSharpCode.CodeCoverage @@ -18,121 +22,119 @@ namespace ICSharpCode.CodeCoverage
/// Menu command selected after right clicking a test method in the text editor
/// to run tests with code coverage.
/// </summary>
public class RunTestWithCodeCoverageCommand : AbstractRunTestCommand
public class RunTestWithCodeCoverageCommand : AbstractMenuCommand
{
static MessageViewCategory category;
ICodeCoverageTestRunnerFactory factory;
CodeCoverageTestRunner codeCoverageTestRunner;
OpenCoverSettingsFactory settingsFactory = new OpenCoverSettingsFactory();
IFileSystem fileSystem = new FileSystem();
public RunTestWithCodeCoverageCommand()
: this(new RunTestCommandContext(), new CodeCoverageTestRunnerFactory())
public override void Run()
{
ClearCodeCoverageResults();
var coverageResultsReader = new CodeCoverageResultsReader();
var options = new TestExecutionOptions {
ModifyProcessStartInfoBeforeTestRun = (startInfo, tests) => {
OpenCoverApplication app = CreateOpenCoverApplication(startInfo, tests);
coverageResultsReader.AddResultsFile(app.CodeCoverageResultsFileName);
return app.GetProcessStartInfo();
}
};
ITestService testService = SD.GetRequiredService<ITestService>();
IEnumerable<ITest> allTests = GetTests(testService);
testService.RunTestsAsync(allTests, options)
.ContinueWith(t => AfterTestsRunTask(t, coverageResultsReader))
.FireAndForget();
}
public RunTestWithCodeCoverageCommand(IRunTestCommandContext context,
ICodeCoverageTestRunnerFactory factory)
: base(context)
{
this.factory = factory;
}
protected override void OnBeforeRunTests()
protected virtual IEnumerable<ITest> GetTests(ITestService testService)
{
ClearCodeCoverageResults();
return TestableCondition.GetTests(testService.OpenSolution, Owner);
}
void ClearCodeCoverageResults()
{
Category.ClearText();
Context.Workbench.SafeThreadAsyncCall(CodeCoverageService.ClearResults);
SD.MainThread.InvokeIfRequired(() => CodeCoverageService.ClearResults());
}
/// <summary>
/// Gets the message view output window.
/// </summary>
protected MessageViewCategory Category {
get {
if (category == null) {
CreateCodeCoverageMessageViewCategory();
}
return category;
}
set { category = value; }
}
void CreateCodeCoverageMessageViewCategory()
OpenCoverApplication CreateOpenCoverApplication(ProcessStartInfo startInfo, IEnumerable<ITest> tests)
{
string displayCategory = StringParse("${res:ICSharpCode.UnitTesting.CodeCoverage}");
category = CreateMessageViewCategory("CodeCoverage", displayCategory);
IProject project = tests.First().ParentProject.Project;
OpenCoverSettings settings = settingsFactory.CreateOpenCoverSettings(project);
var application = new OpenCoverApplication(startInfo, settings, project);
RemoveExistingCodeCoverageResultsFile(application.CodeCoverageResultsFileName);
CreateDirectoryForCodeCoverageResultsFile(application.CodeCoverageResultsFileName);
return application;
}
protected virtual string StringParse(string text)
void RemoveExistingCodeCoverageResultsFile(string fileName)
{
return StringParser.Parse(text);
if (fileSystem.FileExists(fileName)) {
fileSystem.DeleteFile(fileName);
}
}
protected virtual MessageViewCategory CreateMessageViewCategory(string category, string displayCategory)
void CreateDirectoryForCodeCoverageResultsFile(string fileName)
{
MessageViewCategory view = null;
MessageViewCategory.Create(ref view, category, displayCategory);
return view;
string directory = Path.GetDirectoryName(fileName);
if (!fileSystem.DirectoryExists(directory)) {
fileSystem.CreateDirectory(directory);
}
}
protected override void OnAfterRunTests()
Task AfterTestsRunTask(Task task, CodeCoverageResultsReader coverageResultsReader)
{
ShowCodeCoverageResultsIfNoCriticalTestFailures();
if (task.Exception != null)
throw task.Exception;
ShowCodeCoverageResultsPadIfNoCriticalTestFailures();
DisplayCodeCoverageResults(coverageResultsReader);
return task;
}
void ShowCodeCoverageResultsIfNoCriticalTestFailures()
void ShowCodeCoverageResultsPadIfNoCriticalTestFailures()
{
if (!Context.TaskService.HasCriticalErrors(false)) {
ShowPad(Context.Workbench.GetPad(typeof(CodeCoveragePad)));
if (TaskService.HasCriticalErrors(false)) {
SD.MainThread.InvokeIfRequired(() => ShowCodeCoverageResultsPad());
}
}
protected override void TestRunnerMessageReceived(object source, MessageReceivedEventArgs e)
void ShowCodeCoverageResultsPad()
{
Category.AppendLine(e.Message);
}
protected override ITestRunner CreateTestRunner(IProject project)
{
codeCoverageTestRunner = factory.CreateCodeCoverageTestRunner();
codeCoverageTestRunner.AllTestsFinished += CodeCoverageRunFinished;
return codeCoverageTestRunner;
SD.Workbench.GetPad(typeof(CodeCoveragePad)).BringPadToFront();
}
void CodeCoverageRunFinished(object source, EventArgs e)
void DisplayCodeCoverageResults(CodeCoverageResultsReader coverageResultsReader)
{
if (codeCoverageTestRunner.HasCodeCoverageResults()) {
CodeCoverageResults results = codeCoverageTestRunner.ReadCodeCoverageResults();
DisplayCodeCoverageResults(results);
} else {
DisplayNoCodeCoverageResultsGeneratedMessage();
foreach (CodeCoverageResults result in coverageResultsReader.GetResults()) {
DisplayCodeCoverageResults(result);
}
foreach (string missingFile in coverageResultsReader.GetMissingResultsFiles()) {
DisplayNoCodeCoverageResultsGeneratedMessage(missingFile);
}
}
void DisplayCodeCoverageResults(CodeCoverageResults results)
{
Context.Workbench.SafeThreadAsyncCall(CodeCoverageService.ShowResults, results);
SD.MainThread.InvokeIfRequired(() => CodeCoverageService.ShowResults(results));
}
void DisplayNoCodeCoverageResultsGeneratedMessage()
void DisplayNoCodeCoverageResultsGeneratedMessage(string fileName)
{
Task task = CreateNoCodeCoverageResultsGeneratedTask();
Context.Workbench.SafeThreadAsyncCall(Context.TaskService.Add, task);
SDTask task = CreateNoCodeCoverageResultsGeneratedTask(fileName);
TaskService.Add(task);
}
Task CreateNoCodeCoverageResultsGeneratedTask()
SDTask CreateNoCodeCoverageResultsGeneratedTask(string fileName)
{
string description = GetNoCodeCoverageResultsGeneratedTaskDescription();
return new Task(null, description, 1, 1, TaskType.Error);
string description = GetNoCodeCoverageResultsGeneratedTaskDescription(fileName);
return new SDTask(null, description, 1, 1, TaskType.Error);
}
string GetNoCodeCoverageResultsGeneratedTaskDescription()
string GetNoCodeCoverageResultsGeneratedTaskDescription(string fileName)
{
string message = StringParse("${res:ICSharpCode.CodeCoverage.NoCodeCoverageResultsGenerated}");
return String.Format("{0} {1}", message, codeCoverageTestRunner.CodeCoverageResultsFileName);
string message = StringParser.Parse("${res:ICSharpCode.CodeCoverage.NoCodeCoverageResultsGenerated}");
return String.Format("{0} {1}", message, fileName);
}
}
}

12
src/AddIns/Analysis/CodeCoverage/Project/Src/ShowDisplayOptionsDropDown.cs

@ -16,11 +16,11 @@ namespace ICSharpCode.CodeCoverage @@ -16,11 +16,11 @@ namespace ICSharpCode.CodeCoverage
{
}
protected override void OnOwnerChanged(EventArgs e)
{
base.OnOwnerChanged(e);
dropDownButton = (ToolBarDropDownButton)Owner;
MenuService.AddItemsToMenu(dropDownButton.DropDownItems, this, "/SharpDevelop/Pads/CodeCoveragePad/Toolbar/CodeCoveragePadDisplayOptions");
}
// protected override void OnOwnerChanged(EventArgs e)
// {
// base.OnOwnerChanged(e);
// dropDownButton = (ToolBarDropDownButton)Owner;
// MenuService.AddItemsToMenu(dropDownButton.DropDownItems, this, "/SharpDevelop/Pads/CodeCoveragePad/Toolbar/CodeCoveragePadDisplayOptions");
// }
}
}

14
src/AddIns/Analysis/CodeCoverage/Test/CodeCoverage.Tests.csproj

@ -16,7 +16,8 @@ @@ -16,7 +16,8 @@
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath>
@ -110,9 +111,9 @@ @@ -110,9 +111,9 @@
<Compile Include="Utils\XElementExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
@ -121,7 +122,6 @@ @@ -121,7 +122,6 @@
<ProjectReference Include="..\..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj">
<Project>{4980B743-B32F-4aba-AABD-45E2CAD3568D}</Project>
<Name>ICSharpCode.SharpDevelop.Tests</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
@ -139,10 +139,6 @@ @@ -139,10 +139,6 @@
<Project>{1F261725-6318-4434-A1B1-6C70CE4CD324}</Project>
<Name>UnitTesting</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>

2
src/AddIns/Analysis/CodeCoverage/Test/Coverage/CodeCoverageResultsMissingFileIdTestFixture.cs

@ -9,7 +9,7 @@ using NUnit.Framework; @@ -9,7 +9,7 @@ using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests.Coverage
{
/// <summary>
/// PartCover does not always put a file id in the code
/// OpenCover does not always put a file id in the code
/// coverage report. This is typically for code that
/// has no source code. It can also be for code that
/// is in a method that is not covered at all.

6
src/AddIns/Analysis/CodeCoverage/Test/Coverage/OpenCoverSettingsFactoryTests.cs

@ -4,15 +4,17 @@ @@ -4,15 +4,17 @@
using System;
using System.IO;
using System.Text;
using ICSharpCode.CodeCoverage;
using ICSharpCode.CodeCoverage.Tests.Utils;
using ICSharpCode.SharpDevelop;
using NUnit.Framework;
using UnitTesting.Tests.Utils;
namespace ICSharpCode.CodeCoverage.Tests.Coverage
{
[TestFixture]
public class OpenCoverSettingsFactoryTests
public class OpenCoverSettingsFactoryTests : SDTestFixtureBase
{
OpenCoverSettingsFactory factory;
OpenCoverSettings openCoverSettings;
@ -28,7 +30,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -28,7 +30,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
}
[Test]
public void CreateOpenCoverSettingsWhenFileDoesNotExistCreatesSettingsWithNoPartCoverIncludes()
public void CreateOpenCoverSettingsWhenFileDoesNotExistCreatesSettingsWithNoOpenCoverIncludes()
{
fileSystem.FileExistsReturnValue = false;
CreateOpenCoverSettingsFromFactory();

9
src/AddIns/Analysis/CodeCoverage/Test/Coverage/OpenCoverSettingsTestFixture.cs

@ -8,6 +8,7 @@ using System.Xml; @@ -8,6 +8,7 @@ using System.Xml;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
@ -16,12 +17,12 @@ using UnitTesting.Tests.Utils; @@ -16,12 +17,12 @@ using UnitTesting.Tests.Utils;
namespace ICSharpCode.CodeCoverage.Tests.Coverage
{
/// <summary>
/// Tests the saving and loading of the PartCover settings file. This
/// Tests the saving and loading of the OpenCover settings file. This
/// file is used to stores the includes and excludes regular expressions
/// that PartCover uses.
/// that OpenCover uses.
/// </summary>
[TestFixture]
public class OpenCoverSettingsTestFixture
public class OpenCoverSettingsTestFixture : SDTestFixtureBase
{
OpenCoverSettings settings;
OpenCoverSettings savedSettings;
@ -62,7 +63,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -62,7 +63,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
MSBuildBasedProject project = new MSBuildBasedProject(
new ProjectCreateInformation {
Solution = new Solution(new MockProjectChangeWatcher()),
OutputProjectFileName = @"C:\temp\test.csproj",
OutputProjectFileName = new FileName(@"C:\temp\test.csproj"),
ProjectName = "test"
});

4
src/AddIns/Analysis/CodeCoverage/Test/Coverage/RemoveTaskMarkerTests.cs

@ -4,8 +4,10 @@ @@ -4,8 +4,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
@ -34,7 +36,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -34,7 +36,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
public void CodeCoverageHighlighterRemoveMarkersDoesNotThrowInvalidCastExceptionWhenOneMarkerTagIsTask()
{
ITextMarker textMarker = markerService.Create(0, 2);
textMarker.Tag = new Task(null, String.Empty, 1, 1, TaskType.Error);
textMarker.Tag = new SDTask(null, String.Empty, 1, 1, TaskType.Error);
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter();
Assert.DoesNotThrow(delegate { highlighter.RemoveMarkers(document); });

6
src/AddIns/Analysis/CodeCoverage/Test/Coverage/SolutionCodeCoverageResultsTests.cs

@ -7,6 +7,8 @@ using System.IO; @@ -7,6 +7,8 @@ using System.IO;
using System.Linq;
using ICSharpCode.CodeCoverage.Tests.Utils;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using Rhino.Mocks;
@ -15,7 +17,7 @@ using UnitTesting.Tests.Utils; @@ -15,7 +17,7 @@ using UnitTesting.Tests.Utils;
namespace ICSharpCode.CodeCoverage.Tests.Coverage
{
[TestFixture]
public class SolutionCodeCoverageResultsTests
public class SolutionCodeCoverageResultsTests : SDTestFixtureBase
{
SolutionCodeCoverageResults solutionCodeCoverageResults;
Solution solution;
@ -36,7 +38,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -36,7 +38,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
void AddProject(string fileName)
{
var project = new MockCSharpProject(solution, Path.GetFileNameWithoutExtension(fileName));
project.FileName = fileName;
project.FileName = new FileName(fileName);
solution.Folders.Add(project);
}

9
src/AddIns/Analysis/CodeCoverage/Test/Highlighting/AddCodeCoverageMarkersTestFixture.cs

@ -4,15 +4,17 @@ @@ -4,15 +4,17 @@
using System;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
using ICSharpCode.SharpDevelop.WinForms;
using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests.Highlighting
{
[TestFixture]
public class AddCodeCoverageMarkersTestFixture
public class AddCodeCoverageMarkersTestFixture : SDTestFixtureBase
{
ITextMarker markerOne;
ITextMarker markerTwo;
@ -23,10 +25,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -23,10 +25,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
[TestFixtureSetUp]
public void SetUpFixture()
{
try {
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {}
base.FixtureSetUp();
document = MockTextMarkerService.CreateDocumentWithMockService();
string code = "\t\t{\r\n" +

21
src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersCoverMultipleLinesTestFixture.cs

@ -1,12 +1,13 @@ @@ -1,12 +1,13 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.NRefactory;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
using NUnit.Framework;
@ -23,8 +24,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -23,8 +24,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
public void SetUpFixture()
{
try {
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
//string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
//PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {}
document = MockTextMarkerService.CreateDocumentWithMockService();
@ -90,22 +91,22 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -90,22 +91,22 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
[Test]
public void FirstMarkerPosition()
{
Assert.AreEqual(new Location(3, 1), document.OffsetToPosition(markers[0].StartOffset));
Assert.AreEqual(new Location(4, 1), document.OffsetToPosition(markers[0].EndOffset));
Assert.AreEqual(new TextLocation(1, 3), document.GetLocation(markers[0].StartOffset));
Assert.AreEqual(new TextLocation(1, 4), document.GetLocation(markers[0].EndOffset));
}
[Test]
public void SecondMarkerPosition()
{
Assert.AreEqual(new Location(4, 2), document.OffsetToPosition(markers[1].StartOffset));
Assert.AreEqual(new Location(20, 9), document.OffsetToPosition(markers[1].EndOffset));
Assert.AreEqual(new TextLocation(2, 4), document.GetLocation(markers[1].StartOffset));
Assert.AreEqual(new TextLocation(9, 20), document.GetLocation(markers[1].EndOffset));
}
[Test]
public void ThirdMarkerPosition()
{
Assert.AreEqual(new Location(3, 10), document.OffsetToPosition(markers[2].StartOffset));
Assert.AreEqual(new Location(4, 10), document.OffsetToPosition(markers[2].EndOffset));
Assert.AreEqual(new TextLocation(10, 3), document.GetLocation(markers[2].StartOffset));
Assert.AreEqual(new TextLocation(10, 4), document.GetLocation(markers[2].EndOffset));
}
}
}

12
src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersCoverTwoLinesTestFixture.cs

@ -1,19 +1,22 @@ @@ -1,19 +1,22 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Tests.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests.Highlighting
{
[TestFixture]
public class CodeCoverageMarkersCoverTwoLinesTestFixture
public class CodeCoverageMarkersCoverTwoLinesTestFixture : SDTestFixtureBase
{
ITextMarker markerOne;
ITextMarker markerTwo;
@ -22,11 +25,6 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -22,11 +25,6 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
[TestFixtureSetUp]
public void SetUpFixture()
{
try {
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {}
IDocument document = MockTextMarkerService.CreateDocumentWithMockService();
ITextMarkerService markerStrategy = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
string code = "\t\t{\r\n" +

8
src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersInvalidEndColumnTestFixture.cs

@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Tests.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests.Highlighting
@ -21,8 +23,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -21,8 +23,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
public void Init()
{
try {
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
//string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
//PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {}
IDocument document = MockTextMarkerService.CreateDocumentWithMockService();

8
src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersInvalidEndLineTestFixture.cs

@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Tests.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests.Highlighting
@ -21,8 +23,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -21,8 +23,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
public void Init()
{
try {
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
//string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
//PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {}
IDocument document = MockTextMarkerService.CreateDocumentWithMockService();

8
src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersInvalidStartColumnTestFixture.cs

@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Tests.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests.Highlighting
@ -21,8 +23,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -21,8 +23,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
public void Init()
{
try {
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
//string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
//PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {}
IDocument document = MockTextMarkerService.CreateDocumentWithMockService();

8
src/AddIns/Analysis/CodeCoverage/Test/Highlighting/CodeCoverageMarkersInvalidStartLineTestFixture.cs

@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Tests.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests.Highlighting
@ -21,8 +23,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -21,8 +23,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
public void Init()
{
try {
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
//string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
//PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {}
IDocument document = MockTextMarkerService.CreateDocumentWithMockService();

8
src/AddIns/Analysis/CodeCoverage/Test/Highlighting/RemoveCodeCoverageMarkersTestFixture.cs

@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Tests.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests.Highlighting
@ -22,8 +24,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting @@ -22,8 +24,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Highlighting
public void SetUpTestFixture()
{
try {
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
//string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
//PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {}
document = MockTextMarkerService.CreateDocumentWithMockService();

474
src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs

@ -1,237 +1,237 @@ @@ -1,237 +1,237 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.CodeCoverage;
using ICSharpCode.CodeCoverage.Tests.Utils;
using ICSharpCode.SharpDevelop;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using UnitTesting.Tests.Utils;
namespace ICSharpCode.CodeCoverage.Tests.Testing
{
[TestFixture]
public class CodeCoverageTestRunnerTests
{
MockProcessRunner processRunner;
MockTestResultsMonitor testResultsMonitor;
UnitTestingOptions options;
DerivedCodeCoverageTestRunner testRunner;
MockFileSystem fileSystem;
MockMessageService messageService;
[SetUp]
public void Init()
{
processRunner = new MockProcessRunner();
testResultsMonitor = new MockTestResultsMonitor();
options = new UnitTestingOptions(new Properties());
fileSystem = new MockFileSystem();
messageService = new MockMessageService();
testRunner = new DerivedCodeCoverageTestRunner(processRunner, testResultsMonitor, options, fileSystem, messageService);
}
[Test]
public void CreateTestResultForTestFrameworkReturnsNUnitTestResult()
{
TestResult testResult = new TestResult("abc");
Assert.IsInstanceOf(typeof(NUnitTestResult), testRunner.CallCreateTestResultForTestFramework(testResult));
}
[Test]
public void HasCodeCoverageResultsWhenCoverageFileExistsReturnsTrue()
{
StartTestRunner();
fileSystem.FileExistsReturnValue = true;
Assert.IsTrue(testRunner.HasCodeCoverageResults());
}
void StartTestRunner()
{
FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
MockCSharpProject project = new MockCSharpProject();
SelectedTests tests = new SelectedTests(project);
testRunner.Start(tests);
}
[Test]
public void HasCodeCoverageResultsWhenCoverageFileDoesNotExistsReturnsFalse()
{
fileSystem.FileExistsReturnValue = false;
StartTestRunner();
Assert.IsFalse(testRunner.HasCodeCoverageResults());
}
[Test]
public void HasCodeCoverageResultsAfterTestRunChecksPassesCodeCoverageFileToFileExistsMethod()
{
fileSystem.FileExistsReturnValue = false;
fileSystem.FileExistsPathParameter = null;
StartTestRunner();
testRunner.HasCodeCoverageResults();
string expectedFileName =
@"c:\projects\MyTests\OpenCover\coverage.xml";
Assert.AreEqual(expectedFileName, fileSystem.FileExistsPathParameter);
}
[Test]
public void ReadCodeCoverageResultsAfterTestRunChecksPassesCodeCoverageFileToCreateTextReaderMethod()
{
StartTestRunner();
fileSystem.FileExistsReturnValue = true;
fileSystem.CreateTextReaderPathParameter = null;
fileSystem.CreateTextReaderReturnValue = new StringReader("<abc/>");
testRunner.ReadCodeCoverageResults();
string expectedFileName =
@"c:\projects\MyTests\OpenCover\coverage.xml";
Assert.AreEqual(expectedFileName, fileSystem.CreateTextReaderPathParameter);
}
[Test]
public void GetProcessStartInfoWhenTestResultsFileNameSetReturnsCommandLineWithTestResultsFileName()
{
FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
testResultsMonitor.FileName = @"d:\temp\results.txt";
fileSystem.CreateTextReaderReturnValue = CreatePartCoverSettingsTextReader();
fileSystem.FileExistsReturnValue = true;
MockCSharpProject project = new MockCSharpProject();
SelectedTests tests = new SelectedTests(project);
testRunner.Start(tests);
ProcessStartInfo processStartInfo = testRunner.CallGetProcessStartInfo(tests);
string expectedCommandLine =
"-register:user -target:\"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " +
"-targetdir:\"c:\\projects\\MyTests\\bin\\Debug\" " +
"-targetargs:\"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml /results=\\\"d:\\temp\\results.txt\\\"\" " +
"-output:\"c:\\projects\\MyTests\\OpenCover\\coverage.xml\" " +
"-filter:\"+[MyTests]* \"";
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments);
}
TextReader CreatePartCoverSettingsTextReader()
{
OpenCoverSettings settings = new OpenCoverSettings();
settings.Include.Add("[MyTests]*");
StringBuilder text = new StringBuilder();
StringWriter writer = new StringWriter(text);
settings.Save(writer);
return new StringReader(text.ToString());
}
[Test]
public void StartSetsProfilerEnvironmentVariableInProcessRunner()
{
StartTestRunner();
string environmentVariableValue = processRunner.EnvironmentVariables["COMPLUS_ProfAPI_ProfilerCompatibilitySetting"];
Assert.AreEqual("EnableV2Profiler", environmentVariableValue);
}
[Test]
public void StartWhenCodeCoverageResultsFileExistsDeletesExistingCodeCoverageResultsFile()
{
fileSystem.FileExistsReturnValue = true;
fileSystem.CreateTextReaderReturnValue = new StringReader("<abc/>");
StartTestRunner();
string expectedFileName = @"c:\projects\MyTests\OpenCover\coverage.xml";
Assert.AreEqual(expectedFileName, fileSystem.DeleteFilePathParameter);
}
[Test]
public void StartWhenCodeCoverageResultsFileDoesNotExistsCodeCoverageResultsFileIsNotDeleted()
{
fileSystem.FileExistsReturnValue = false;
StartTestRunner();
Assert.IsNull(fileSystem.DeleteFilePathParameter);
}
[Test]
public void StartCreatesDirectoryCodeCoverageResultsFileIfDoesNotExist()
{
fileSystem.DirectoryExistsReturnValue = false;
StartTestRunner();
string expectedDirectory = @"c:\projects\MyTests\OpenCover";
Assert.AreEqual(expectedDirectory, fileSystem.CreateDirectoryPathParameter);
}
[Test]
public void StartChecksDirectoryForCodeCoverageResultsExists()
{
fileSystem.DirectoryExistsReturnValue = true;
StartTestRunner();
string expectedDirectory = @"c:\projects\MyTests\OpenCover";
Assert.AreEqual(expectedDirectory, fileSystem.DirectoryExistsPathParameter);
}
[Test]
public void StartDoesNotCreateDirectoryForCodeCoverageResultsFileIfItExists()
{
fileSystem.DirectoryExistsReturnValue = true;
StartTestRunner();
Assert.IsNull(fileSystem.CreateDirectoryPathParameter);
}
[Test]
public void StartFiresMessagesReceivedEventTwice()
{
List<string> messages = new List<string>();
testRunner.MessageReceived += delegate(object o, MessageReceivedEventArgs e) {
messages.Add(e.Message);
};
testRunner.ParseStringReturnValue = "Running code coverage";
StartTestRunner();
string[] expectedMessages = new string[] {
"Running code coverage",
GetCodeCoverageCommandLine()
};
Assert.AreEqual(expectedMessages, messages.ToArray());
}
string GetCodeCoverageCommandLine()
{
return
"\"d:\\sharpdevelop\\bin\\Tools\\OpenCover\\OpenCover.Console.exe\" -register:user " +
"-target:\"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " +
"-targetdir:\"c:\\projects\\MyTests\\bin\\Debug\" " +
"-targetargs:\"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " +
"-output:\"c:\\projects\\MyTests\\OpenCover\\coverage.xml\" " +
"-filter:\"+[*]* \"";
}
[Test]
public void StartParsesTextForRunningCodeCoverageMessages()
{
testRunner.ParseStringReturnValue = "Running code coverage";
StartTestRunner();
string expectedStringResource = "${res:ICSharpCode.CodeCoverage.RunningCodeCoverage}";
Assert.AreEqual(expectedStringResource, testRunner.ParseStringParameter);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections.Generic;
//using System.Diagnostics;
//using System.IO;
//using System.Text;
//using ICSharpCode.Core;
//using ICSharpCode.CodeCoverage;
//using ICSharpCode.CodeCoverage.Tests.Utils;
//using ICSharpCode.SharpDevelop;
//using ICSharpCode.UnitTesting;
//using NUnit.Framework;
//using UnitTesting.Tests.Utils;
//
//namespace ICSharpCode.CodeCoverage.Tests.Testing
//{
// [TestFixture]
// public class CodeCoverageTestRunnerTests
// {
// MockProcessRunner processRunner;
// MockTestResultsMonitor testResultsMonitor;
// UnitTestingOptions options;
// DerivedCodeCoverageTestRunner testRunner;
// MockFileSystem fileSystem;
// MockMessageService messageService;
//
// [SetUp]
// public void Init()
// {
// processRunner = new MockProcessRunner();
// testResultsMonitor = new MockTestResultsMonitor();
// options = new UnitTestingOptions(new Properties());
// fileSystem = new MockFileSystem();
// messageService = new MockMessageService();
// testRunner = new DerivedCodeCoverageTestRunner(processRunner, testResultsMonitor, options, fileSystem, messageService);
// }
//
// [Test]
// public void CreateTestResultForTestFrameworkReturnsNUnitTestResult()
// {
// TestResult testResult = new TestResult("abc");
// Assert.IsInstanceOf(typeof(NUnitTestResult), testRunner.CallCreateTestResultForTestFramework(testResult));
// }
//
// [Test]
// public void HasCodeCoverageResultsWhenCoverageFileExistsReturnsTrue()
// {
// StartTestRunner();
//
// fileSystem.FileExistsReturnValue = true;
//
// Assert.IsTrue(testRunner.HasCodeCoverageResults());
// }
//
// void StartTestRunner()
// {
// FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
// MockCSharpProject project = new MockCSharpProject();
// SelectedTests tests = new SelectedTests(project);
// testRunner.Start(tests);
// }
//
// [Test]
// public void HasCodeCoverageResultsWhenCoverageFileDoesNotExistsReturnsFalse()
// {
// fileSystem.FileExistsReturnValue = false;
// StartTestRunner();
// Assert.IsFalse(testRunner.HasCodeCoverageResults());
// }
//
// [Test]
// public void HasCodeCoverageResultsAfterTestRunChecksPassesCodeCoverageFileToFileExistsMethod()
// {
// fileSystem.FileExistsReturnValue = false;
// fileSystem.FileExistsPathParameter = null;
// StartTestRunner();
// testRunner.HasCodeCoverageResults();
//
// string expectedFileName =
// @"c:\projects\MyTests\OpenCover\coverage.xml";
//
// Assert.AreEqual(expectedFileName, fileSystem.FileExistsPathParameter);
// }
//
// [Test]
// public void ReadCodeCoverageResultsAfterTestRunChecksPassesCodeCoverageFileToCreateTextReaderMethod()
// {
// StartTestRunner();
//
// fileSystem.FileExistsReturnValue = true;
// fileSystem.CreateTextReaderPathParameter = null;
// fileSystem.CreateTextReaderReturnValue = new StringReader("<abc/>");
//
// testRunner.ReadCodeCoverageResults();
//
// string expectedFileName =
// @"c:\projects\MyTests\OpenCover\coverage.xml";
//
// Assert.AreEqual(expectedFileName, fileSystem.CreateTextReaderPathParameter);
// }
//
// [Test]
// public void GetProcessStartInfoWhenTestResultsFileNameSetReturnsCommandLineWithTestResultsFileName()
// {
// FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
// testResultsMonitor.FileName = @"d:\temp\results.txt";
//
// fileSystem.CreateTextReaderReturnValue = CreatePartCoverSettingsTextReader();
// fileSystem.FileExistsReturnValue = true;
//
// MockCSharpProject project = new MockCSharpProject();
// SelectedTests tests = new SelectedTests(project);
// testRunner.Start(tests);
// ProcessStartInfo processStartInfo = testRunner.CallGetProcessStartInfo(tests);
//
// string expectedCommandLine =
// "-register:user -target:\"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " +
// "-targetdir:\"c:\\projects\\MyTests\\bin\\Debug\" " +
// "-targetargs:\"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml /results=\\\"d:\\temp\\results.txt\\\"\" " +
// "-output:\"c:\\projects\\MyTests\\OpenCover\\coverage.xml\" " +
// "-filter:\"+[MyTests]* \"";
//
// Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments);
// }
//
// TextReader CreatePartCoverSettingsTextReader()
// {
// OpenCoverSettings settings = new OpenCoverSettings();
// settings.Include.Add("[MyTests]*");
// StringBuilder text = new StringBuilder();
// StringWriter writer = new StringWriter(text);
// settings.Save(writer);
//
// return new StringReader(text.ToString());
// }
//
// [Test]
// public void StartSetsProfilerEnvironmentVariableInProcessRunner()
// {
// StartTestRunner();
// string environmentVariableValue = processRunner.EnvironmentVariables["COMPLUS_ProfAPI_ProfilerCompatibilitySetting"];
// Assert.AreEqual("EnableV2Profiler", environmentVariableValue);
// }
//
// [Test]
// public void StartWhenCodeCoverageResultsFileExistsDeletesExistingCodeCoverageResultsFile()
// {
// fileSystem.FileExistsReturnValue = true;
// fileSystem.CreateTextReaderReturnValue = new StringReader("<abc/>");
// StartTestRunner();
//
// string expectedFileName = @"c:\projects\MyTests\OpenCover\coverage.xml";
// Assert.AreEqual(expectedFileName, fileSystem.DeleteFilePathParameter);
// }
//
// [Test]
// public void StartWhenCodeCoverageResultsFileDoesNotExistsCodeCoverageResultsFileIsNotDeleted()
// {
// fileSystem.FileExistsReturnValue = false;
// StartTestRunner();
//
// Assert.IsNull(fileSystem.DeleteFilePathParameter);
// }
//
// [Test]
// public void StartCreatesDirectoryCodeCoverageResultsFileIfDoesNotExist()
// {
// fileSystem.DirectoryExistsReturnValue = false;
// StartTestRunner();
//
// string expectedDirectory = @"c:\projects\MyTests\OpenCover";
// Assert.AreEqual(expectedDirectory, fileSystem.CreateDirectoryPathParameter);
// }
//
// [Test]
// public void StartChecksDirectoryForCodeCoverageResultsExists()
// {
// fileSystem.DirectoryExistsReturnValue = true;
// StartTestRunner();
//
// string expectedDirectory = @"c:\projects\MyTests\OpenCover";
// Assert.AreEqual(expectedDirectory, fileSystem.DirectoryExistsPathParameter);
// }
//
// [Test]
// public void StartDoesNotCreateDirectoryForCodeCoverageResultsFileIfItExists()
// {
// fileSystem.DirectoryExistsReturnValue = true;
// StartTestRunner();
//
// Assert.IsNull(fileSystem.CreateDirectoryPathParameter);
// }
//
// [Test]
// public void StartFiresMessagesReceivedEventTwice()
// {
// List<string> messages = new List<string>();
// testRunner.MessageReceived += delegate(object o, MessageReceivedEventArgs e) {
// messages.Add(e.Message);
// };
//
// testRunner.ParseStringReturnValue = "Running code coverage";
// StartTestRunner();
//
// string[] expectedMessages = new string[] {
// "Running code coverage",
// GetCodeCoverageCommandLine()
// };
//
// Assert.AreEqual(expectedMessages, messages.ToArray());
// }
//
// string GetCodeCoverageCommandLine()
// {
// return
// "\"d:\\sharpdevelop\\bin\\Tools\\OpenCover\\OpenCover.Console.exe\" -register:user " +
// "-target:\"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " +
// "-targetdir:\"c:\\projects\\MyTests\\bin\\Debug\" " +
// "-targetargs:\"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " +
// "-output:\"c:\\projects\\MyTests\\OpenCover\\coverage.xml\" " +
// "-filter:\"+[*]* \"";
// }
//
// [Test]
// public void StartParsesTextForRunningCodeCoverageMessages()
// {
// testRunner.ParseStringReturnValue = "Running code coverage";
// StartTestRunner();
//
// string expectedStringResource = "${res:ICSharpCode.CodeCoverage.RunningCodeCoverage}";
//
// Assert.AreEqual(expectedStringResource, testRunner.ParseStringParameter);
// }
// }
//}

66
src/AddIns/Analysis/CodeCoverage/Test/Testing/OpenCoverApplicationTests.cs

@ -2,9 +2,12 @@ @@ -2,9 +2,12 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using UnitTesting.Tests.Utils;
@ -12,18 +15,18 @@ using UnitTesting.Tests.Utils; @@ -12,18 +15,18 @@ using UnitTesting.Tests.Utils;
namespace ICSharpCode.CodeCoverage.Tests.Testing
{
[TestFixture]
public class OpenCoverApplicationTests
public class OpenCoverApplicationTests : SDTestFixtureBase
{
NUnitConsoleApplication nunitConsoleApp;
SelectedTests selectedTests;
UnitTestingOptions options;
OpenCoverApplication openCoverApp;
OpenCoverSettings openCoverSettings;
MockCSharpProject project;
[Test]
public void FileNameWhenPartCoverApplicationConstructedWithFileNameParameterMatchesFileNameParameter()
public void FileNameWhenOpenCoverApplicationConstructedWithFileNameParameterMatchesFileNameParameter()
{
string expectedFileName = @"d:\projects\PartCover.exe";
string expectedFileName = @"d:\projects\OpenCover.exe";
CreateOpenCoverApplication(expectedFileName);
Assert.AreEqual(expectedFileName, openCoverApp.FileName);
}
@ -32,38 +35,43 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing @@ -32,38 +35,43 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing
{
CreateNUnitConsoleApplication();
openCoverSettings = new OpenCoverSettings();
openCoverApp = new OpenCoverApplication(fileName, nunitConsoleApp, openCoverSettings);
openCoverApp = new OpenCoverApplication(
fileName,
nunitConsoleApp.GetProcessStartInfo(),
openCoverSettings,
project);
}
void CreateNUnitConsoleApplication()
{
MockCSharpProject project = new MockCSharpProject();
selectedTests = new SelectedTests(project);
project = new MockCSharpProject();
project.FileName = FileName.Create(@"c:\projects\MyTests\MyTests.csproj");
var testProject = new NUnitTestProject(project);
options = new UnitTestingOptions(new Properties());
nunitConsoleApp = new NUnitConsoleApplication(selectedTests, options);
nunitConsoleApp = new NUnitConsoleApplication(new [] { testProject }, options);
}
[Test]
public void FileNameWhenPartCoverApplicationConstructedWithNoParametersIsDeterminedFromFileUtilityAppRootPath()
public void FileNameWhenOpenCoverApplicationConstructedWithNoParametersIsDeterminedFromFileUtilityAppRootPath()
{
FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
CreatePartCoverApplicationWithoutFileName();
CreateOpenCoverApplicationWithoutFileName();
string expectedPath = @"d:\sharpdevelop\bin\Tools\OpenCover\OpenCover.Console.exe";
Assert.AreEqual(expectedPath, openCoverApp.FileName);
}
void CreatePartCoverApplicationWithoutFileName()
void CreateOpenCoverApplicationWithoutFileName()
{
CreateNUnitConsoleApplication();
openCoverApp = new OpenCoverApplication(nunitConsoleApp, new OpenCoverSettings());
openCoverApp = new OpenCoverApplication(nunitConsoleApp.GetProcessStartInfo(), new OpenCoverSettings(), project);
}
[Test]
public void FileNameWhenTakenFromFileUtilityAppRootPathRemovesDotDotCharacters()
{
FileUtility.ApplicationRootPath = @"d:\sharpdevelop\..\sharpdevelop";
CreatePartCoverApplicationWithoutFileName();
CreateOpenCoverApplicationWithoutFileName();
string expectedPath = @"d:\sharpdevelop\bin\Tools\OpenCover\OpenCover.Console.exe";
Assert.AreEqual(expectedPath, openCoverApp.FileName);
}
@ -71,35 +79,35 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing @@ -71,35 +79,35 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing
[Test]
public void TargetIsNUnitConsoleApplicationFileName()
{
CreatePartCoverApplication();
CreateOpenCoverApplication();
Assert.AreEqual(nunitConsoleApp.FileName, openCoverApp.Target);
}
void CreatePartCoverApplication()
void CreateOpenCoverApplication()
{
string fileName = @"d:\partcover\PartCover.exe";
string fileName = @"d:\openCover\OpenCover.exe";
CreateOpenCoverApplication(fileName);
}
[Test]
public void GetTargetArgumentsReturnsNUnitConsoleApplicationCommandLineArguments()
{
CreatePartCoverApplication();
CreateOpenCoverApplication();
Assert.AreEqual(nunitConsoleApp.GetArguments(), openCoverApp.GetTargetArguments());
}
[Test]
public void GetTargetWorkingDirectoryReturnsWorkingDirectoryForProjectOutput()
public void GetTargetWorkingDirectoryReturnsWorkingDirectorySpecifiedByNUnitConsoleApplication()
{
CreatePartCoverApplication();
CreateOpenCoverApplication();
string expectedTargetWorkingDirectory = @"c:\projects\MyTests\bin\Debug";
Assert.AreEqual(expectedTargetWorkingDirectory, openCoverApp.GetTargetWorkingDirectory());
}
[Test]
public void CodeCoverageResultsFileNameReturnsCoverageXmlFileInsidePartCoverDirectoryInsideProjectDirectory()
public void CodeCoverageResultsFileNameReturnsCoverageXmlFileInsideOpenCoverDirectoryInsideProjectDirectory()
{
CreatePartCoverApplication();
CreateOpenCoverApplication();
string expectedOutputDirectory =
@"c:\projects\MyTests\OpenCover\coverage.xml";
@ -107,27 +115,27 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing @@ -107,27 +115,27 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing
}
[Test]
public void SettingsReturnsPartCoverSettingsPassedToConstructor()
public void SettingsReturnsOpenCoverSettingsPassedToConstructor()
{
CreatePartCoverApplication();
CreateOpenCoverApplication();
Assert.AreEqual(openCoverSettings, openCoverApp.Settings);
}
[Test]
public void GetProcessStartInfoReturnsStartInfoWhereFileNameIsPartCoverAppFileName()
public void GetProcessStartInfoReturnsStartInfoWhereFileNameIsOpenCoverAppFileName()
{
string partCoverAppFileName = @"d:\projects\partcover.exe";
CreateOpenCoverApplication(partCoverAppFileName);
string openCoverAppFileName = @"d:\projects\OpenCover.exe";
CreateOpenCoverApplication(openCoverAppFileName);
ProcessStartInfo processStartInfo = openCoverApp.GetProcessStartInfo();
Assert.AreEqual(partCoverAppFileName, processStartInfo.FileName);
Assert.AreEqual(openCoverAppFileName, processStartInfo.FileName);
}
[Test]
public void GetProcessStartInfoWhenNoIncludedItemsReturnsCommandLineWithIncludeForAllAssemblies()
{
FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
CreatePartCoverApplication();
CreateOpenCoverApplication();
ProcessStartInfo processStartInfo = openCoverApp.GetProcessStartInfo();
string expectedCommandLine =
@ -144,7 +152,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing @@ -144,7 +152,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing
public void GetProcessStartInfoWhenHaveIncludedAndExcludedItemsReturnsCommandLineWithIncludeAndExcludeCommandLineArgs()
{
FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
CreatePartCoverApplication();
CreateOpenCoverApplication();
openCoverSettings.Include.Add("[MyTests]*");
openCoverSettings.Include.Add("[MoreTests]*");

544
src/AddIns/Analysis/CodeCoverage/Test/Testing/RunTestWithCodeCoverageCommandTests.cs

@ -1,272 +1,272 @@ @@ -1,272 +1,272 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using ICSharpCode.CodeCoverage.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace ICSharpCode.CodeCoverage.Tests.Testing
{
[TestFixture]
public class RunTestWithCodeCoverageCommandTests
{
DerivedRunTestWithCodeCoverageCommand command;
MockRunTestCommandContext context;
MockCodeCoverageTestRunnerFactory mockCodeCoverageTestRunnerFactory;
[SetUp]
public void Init()
{
context = new MockRunTestCommandContext();
mockCodeCoverageTestRunnerFactory = new MockCodeCoverageTestRunnerFactory();
command = new DerivedRunTestWithCodeCoverageCommand(context, mockCodeCoverageTestRunnerFactory);
}
[Test]
public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedCreatesNewMessageViewCategory()
{
command.CodeCoverageMessageViewCategory = null;
command.CallOnBeforeRunTests();
Assert.AreEqual("CodeCoverage", command.CodeCoverageMessageViewCategory.Category);
}
[Test]
public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedCreatesNewMessageViewCategoryWithCodeCoverageDisplayCategoryName()
{
command.CodeCoverageMessageViewCategory = null;
command.ParsedStringToReturn = "Code Coverage";
command.CallOnBeforeRunTests();
string expectedDisplayCategoryName = "Code Coverage";
Assert.AreEqual(expectedDisplayCategoryName, command.CodeCoverageMessageViewCategory.DisplayCategory);
}
[Test]
public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedPassedStringResourceToStringParser()
{
command.CodeCoverageMessageViewCategory = null;
command.ParsedString = null;
command.CallOnBeforeRunTests();
string expectedStringResourceName = "${res:ICSharpCode.UnitTesting.CodeCoverage}";
Assert.AreEqual(expectedStringResourceName, command.ParsedString);
}
[Test]
public void OnBeforeRunTestsWhenCodeCoverageMessageViewCreatedPreviouslyDoesNotCreateAnotherMessageView()
{
MessageViewCategory view = new MessageViewCategory("Test");
command.CodeCoverageMessageViewCategory = view;
command.CallOnBeforeRunTests();
Assert.AreEqual(view, command.CodeCoverageMessageViewCategory);
}
[Test]
public void OnBeforeRunTestsClearsCodeCoverageMessageViewTextWithSafeAsyncCall()
{
MessageViewCategory view = new MessageViewCategory("Test");
view.AppendText("abc");
command.CodeCoverageMessageViewCategory = view;
command.CallOnBeforeRunTests();
Assert.AreEqual(String.Empty, view.Text);
}
[Test]
public void OnBeforeRunTestsClearsCodeCoverageResults()
{
command.CallOnBeforeRunTests();
Action expectedAction = CodeCoverageService.ClearResults;
Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]);
}
[Test]
public void OnAfterRunTestsWhenNoCriticalTestErrorsCodeCoveragePadIsShown()
{
context.MockTaskService.HasCriticalErrorsReturnValue = false;
PadDescriptor padDescriptor = AddCodeCoveragePadToMockWorkbench();
command.CallOnAfterRunTests();
Action expectedAction = padDescriptor.BringPadToFront;
Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]);
}
PadDescriptor AddCodeCoveragePadToMockWorkbench()
{
PadDescriptor padDescriptor = new PadDescriptor(typeof(CodeCoveragePad), "Code Coverage", String.Empty);
context.MockUnitTestWorkbench.AddPadDescriptor(padDescriptor);
return padDescriptor;
}
[Test]
public void OnAfterRunTestsWhenCriticalErrorsCodeCoveragePadIsNotShown()
{
context.MockTaskService.HasCriticalErrorsReturnValue = true;
PadDescriptor padDescriptor = AddCodeCoveragePadToMockWorkbench();
command.CallOnAfterRunTests();
Assert.AreEqual(0, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Count);
}
[Test]
public void OnAfterRunTestsDoesNotTreatWarningsAsErrors()
{
context.MockTaskService.TreatWarningsAsErrorsParameterPassedToHasCriticalErrors = true;
AddCodeCoveragePadToMockWorkbench();
command.CallOnAfterRunTests();
Assert.IsFalse(context.MockTaskService.TreatWarningsAsErrorsParameterPassedToHasCriticalErrors);
}
[Test]
public void MessageReceivedFromTestRunnerIsAddedToCodeCoverageMessageViewNotUnitTestsMessageView()
{
command.CodeCoverageMessageViewCategory = null;
MessageReceivedEventArgs e = new MessageReceivedEventArgs("test");
command.CallTestRunnerMessageReceived(this, e);
string expectedText = "test\r\n";
Assert.AreEqual(expectedText, command.CodeCoverageMessageViewCategory.Text);
}
[Test]
public void CreateTestRunnerCreatesNewCodeCoverageTestRunner()
{
CodeCoverageTestRunner expectedTestRunner = mockCodeCoverageTestRunnerFactory.TestRunner;
Assert.AreEqual(expectedTestRunner, command.CallCreateTestRunner(null));
}
[Test]
public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeDisplayed()
{
ActionArguments<CodeCoverageResults> actionArgs =
CreateTestRunnerAndFireCodeCoverageProcessExitEvent();
Action<CodeCoverageResults> expectedAction = CodeCoverageService.ShowResults;
Assert.AreEqual(expectedAction, actionArgs.Action);
}
ActionArguments<CodeCoverageResults> CreateTestRunnerAndFireCodeCoverageProcessExitEvent()
{
command.CallCreateTestRunner(null);
MockCSharpProject project = new MockCSharpProject();
SelectedTests tests = new SelectedTests(project);
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>");
mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests);
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = CreateCodeCoverageResultsTextReader();
mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent();
object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0];
return (ActionArguments<CodeCoverageResults>)actionArgsAsObject;
}
[Test]
public void CodeCoverageResultsFromXmlHasModuleCalledMyTests()
{
CodeCoverageResults results = CreateCodeCoverageResults();
string expectedName = "MyTests";
Assert.AreEqual(expectedName, results.Modules[0].Name);
}
CodeCoverageResults CreateCodeCoverageResults()
{
TextReader reader = CreateCodeCoverageResultsTextReader();
return new CodeCoverageResults(reader);
}
TextReader CreateCodeCoverageResultsTextReader()
{
string xml =
"<CoverageSession xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" +
" <Modules>\r\n" +
" <Module hash=\"44-54-B6-13-97-49-45-F8-6A-74-9E-49-0C-77-87-C6-9C-54-47-7A\">\r\n" +
" <FullName>C:\\Projects\\MyTests\\bin\\MyTests.DLL</FullName>\r\n" +
" <ModuleName>MyTests</ModuleName>\r\n" +
" <Files>\r\n" +
" <File uid=\"1\" fullPath=\"c:\\Projects\\MyTests\\MyTestFixture.cs\" />\r\n" +
" </Files>\r\n" +
" <Classes>\r\n" +
" <Class>\r\n" +
" <FullName>MyTests.Tests.MyTestFixture</FullName>\r\n" +
" <Methods>\r\n" +
" <Method visited=\"true\" cyclomaticComplexity=\"1\" sequenceCoverage=\"100\" branchCoverage=\"100\" isConstructor=\"false\" isStatic=\"false\" isGetter=\"false\" isSetter=\"false\">\r\n" +
" <MetadataToken>100663297</MetadataToken>\r\n" +
" <Name>System.Void MyTests.Tests.MyTestFixture::SimpleTest1()</Name>\r\n" +
" <FileRef uid=\"1\" />\r\n" +
" <SequencePoints>\r\n" +
" <SequencePoint vc='12' sl='20' sc='3' el='20' ec='4'/>\r\n" +
" </SequencePoints>\r\n" +
" </Method>\r\n" +
" </Methods>\r\n" +
" </Class>\r\n" +
" </Classes>\r\n" +
" </Module>\r\n" +
" </Modules>\r\n" +
"</CoverageSession>";
return new StringReader(xml);
}
[Test]
public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeReadFromFile()
{
ActionArguments<CodeCoverageResults> actionArgs =
CreateTestRunnerAndFireCodeCoverageProcessExitEvent();
CodeCoverageResults result = actionArgs.Arg;
Assert.AreEqual("MyTests", result.Modules[0].Name);
}
[Test]
public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsTaskToTaskList()
{
ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced();
Action<Task> expectedAction = context.MockTaskService.Add;
Assert.AreEqual(expectedAction, args.Action);
}
ActionArguments<Task> CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced()
{
command.CallCreateTestRunner(null);
MockCSharpProject project = new MockCSharpProject();
SelectedTests tests = new SelectedTests(project);
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>");
mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests);
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = false;
mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent();
object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0];
return (ActionArguments<Task>)actionArgsAsObject;
}
[Test]
public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsErrorTaskToTaskList()
{
command.ParsedStringToReturn = "No code coverage results file generated.";
ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced();
Task task = args.Arg;
string description = @"No code coverage results file generated. c:\projects\MyTests\OpenCover\coverage.xml";
int column = 1;
int line = 1;
Task expectedTask = new Task(null, description, column, line, TaskType.Error);
TaskComparison comparison = new TaskComparison(expectedTask, task);
Assert.IsTrue(comparison.IsMatch, comparison.MismatchReason);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.IO;
//using ICSharpCode.SharpDevelop;
//using ICSharpCode.SharpDevelop.Gui;
//using ICSharpCode.UnitTesting;
//using NUnit.Framework;
//using ICSharpCode.CodeCoverage.Tests.Utils;
//using UnitTesting.Tests.Utils;
//
//namespace ICSharpCode.CodeCoverage.Tests.Testing
//{
// [TestFixture]
// public class RunTestWithCodeCoverageCommandTests
// {
// DerivedRunTestWithCodeCoverageCommand command;
// MockRunTestCommandContext context;
// MockCodeCoverageTestRunnerFactory mockCodeCoverageTestRunnerFactory;
//
// [SetUp]
// public void Init()
// {
// context = new MockRunTestCommandContext();
// mockCodeCoverageTestRunnerFactory = new MockCodeCoverageTestRunnerFactory();
// command = new DerivedRunTestWithCodeCoverageCommand(context, mockCodeCoverageTestRunnerFactory);
// }
//
// [Test]
// public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedCreatesNewMessageViewCategory()
// {
// command.CodeCoverageMessageViewCategory = null;
// command.CallOnBeforeRunTests();
//
// Assert.AreEqual("CodeCoverage", command.CodeCoverageMessageViewCategory.Category);
// }
//
// [Test]
// public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedCreatesNewMessageViewCategoryWithCodeCoverageDisplayCategoryName()
// {
// command.CodeCoverageMessageViewCategory = null;
// command.ParsedStringToReturn = "Code Coverage";
// command.CallOnBeforeRunTests();
//
// string expectedDisplayCategoryName = "Code Coverage";
// Assert.AreEqual(expectedDisplayCategoryName, command.CodeCoverageMessageViewCategory.DisplayCategory);
// }
//
// [Test]
// public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedPassedStringResourceToStringParser()
// {
// command.CodeCoverageMessageViewCategory = null;
// command.ParsedString = null;
// command.CallOnBeforeRunTests();
//
// string expectedStringResourceName = "${res:ICSharpCode.UnitTesting.CodeCoverage}";
// Assert.AreEqual(expectedStringResourceName, command.ParsedString);
// }
//
// [Test]
// public void OnBeforeRunTestsWhenCodeCoverageMessageViewCreatedPreviouslyDoesNotCreateAnotherMessageView()
// {
// MessageViewCategory view = new MessageViewCategory("Test");
// command.CodeCoverageMessageViewCategory = view;
// command.CallOnBeforeRunTests();
// Assert.AreEqual(view, command.CodeCoverageMessageViewCategory);
// }
//
// [Test]
// public void OnBeforeRunTestsClearsCodeCoverageMessageViewTextWithSafeAsyncCall()
// {
// MessageViewCategory view = new MessageViewCategory("Test");
// view.AppendText("abc");
// command.CodeCoverageMessageViewCategory = view;
// command.CallOnBeforeRunTests();
//
// Assert.AreEqual(String.Empty, view.Text);
// }
//
// [Test]
// public void OnBeforeRunTestsClearsCodeCoverageResults()
// {
// command.CallOnBeforeRunTests();
//
// Action expectedAction = CodeCoverageService.ClearResults;
// Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]);
// }
//
// [Test]
// public void OnAfterRunTestsWhenNoCriticalTestErrorsCodeCoveragePadIsShown()
// {
// context.MockTaskService.HasCriticalErrorsReturnValue = false;
// PadDescriptor padDescriptor = AddCodeCoveragePadToMockWorkbench();
// command.CallOnAfterRunTests();
//
// Action expectedAction = padDescriptor.BringPadToFront;
// Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]);
// }
//
// PadDescriptor AddCodeCoveragePadToMockWorkbench()
// {
// PadDescriptor padDescriptor = new PadDescriptor(typeof(CodeCoveragePad), "Code Coverage", String.Empty);
// context.MockUnitTestWorkbench.AddPadDescriptor(padDescriptor);
// return padDescriptor;
// }
//
// [Test]
// public void OnAfterRunTestsWhenCriticalErrorsCodeCoveragePadIsNotShown()
// {
// context.MockTaskService.HasCriticalErrorsReturnValue = true;
// PadDescriptor padDescriptor = AddCodeCoveragePadToMockWorkbench();
// command.CallOnAfterRunTests();
//
// Assert.AreEqual(0, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Count);
// }
//
// [Test]
// public void OnAfterRunTestsDoesNotTreatWarningsAsErrors()
// {
// context.MockTaskService.TreatWarningsAsErrorsParameterPassedToHasCriticalErrors = true;
// AddCodeCoveragePadToMockWorkbench();
// command.CallOnAfterRunTests();
//
// Assert.IsFalse(context.MockTaskService.TreatWarningsAsErrorsParameterPassedToHasCriticalErrors);
// }
//
// [Test]
// public void MessageReceivedFromTestRunnerIsAddedToCodeCoverageMessageViewNotUnitTestsMessageView()
// {
// command.CodeCoverageMessageViewCategory = null;
// MessageReceivedEventArgs e = new MessageReceivedEventArgs("test");
// command.CallTestRunnerMessageReceived(this, e);
// string expectedText = "test\r\n";
// Assert.AreEqual(expectedText, command.CodeCoverageMessageViewCategory.Text);
// }
//
// [Test]
// public void CreateTestRunnerCreatesNewCodeCoverageTestRunner()
// {
// CodeCoverageTestRunner expectedTestRunner = mockCodeCoverageTestRunnerFactory.TestRunner;
// Assert.AreEqual(expectedTestRunner, command.CallCreateTestRunner(null));
// }
//
// [Test]
// public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeDisplayed()
// {
// ActionArguments<CodeCoverageResults> actionArgs =
// CreateTestRunnerAndFireCodeCoverageProcessExitEvent();
//
// Action<CodeCoverageResults> expectedAction = CodeCoverageService.ShowResults;
// Assert.AreEqual(expectedAction, actionArgs.Action);
// }
//
// ActionArguments<CodeCoverageResults> CreateTestRunnerAndFireCodeCoverageProcessExitEvent()
// {
// command.CallCreateTestRunner(null);
// MockCSharpProject project = new MockCSharpProject();
// SelectedTests tests = new SelectedTests(project);
// mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
// mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>");
// mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests);
//
// mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = CreateCodeCoverageResultsTextReader();
//
// mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent();
//
// object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0];
// return (ActionArguments<CodeCoverageResults>)actionArgsAsObject;
// }
//
// [Test]
// public void CodeCoverageResultsFromXmlHasModuleCalledMyTests()
// {
// CodeCoverageResults results = CreateCodeCoverageResults();
// string expectedName = "MyTests";
// Assert.AreEqual(expectedName, results.Modules[0].Name);
// }
//
// CodeCoverageResults CreateCodeCoverageResults()
// {
// TextReader reader = CreateCodeCoverageResultsTextReader();
// return new CodeCoverageResults(reader);
// }
//
// TextReader CreateCodeCoverageResultsTextReader()
// {
// string xml =
// "<CoverageSession xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" +
// " <Modules>\r\n" +
// " <Module hash=\"44-54-B6-13-97-49-45-F8-6A-74-9E-49-0C-77-87-C6-9C-54-47-7A\">\r\n" +
// " <FullName>C:\\Projects\\MyTests\\bin\\MyTests.DLL</FullName>\r\n" +
// " <ModuleName>MyTests</ModuleName>\r\n" +
// " <Files>\r\n" +
// " <File uid=\"1\" fullPath=\"c:\\Projects\\MyTests\\MyTestFixture.cs\" />\r\n" +
// " </Files>\r\n" +
// " <Classes>\r\n" +
// " <Class>\r\n" +
// " <FullName>MyTests.Tests.MyTestFixture</FullName>\r\n" +
// " <Methods>\r\n" +
// " <Method visited=\"true\" cyclomaticComplexity=\"1\" sequenceCoverage=\"100\" branchCoverage=\"100\" isConstructor=\"false\" isStatic=\"false\" isGetter=\"false\" isSetter=\"false\">\r\n" +
// " <MetadataToken>100663297</MetadataToken>\r\n" +
// " <Name>System.Void MyTests.Tests.MyTestFixture::SimpleTest1()</Name>\r\n" +
// " <FileRef uid=\"1\" />\r\n" +
// " <SequencePoints>\r\n" +
// " <SequencePoint vc='12' sl='20' sc='3' el='20' ec='4'/>\r\n" +
// " </SequencePoints>\r\n" +
// " </Method>\r\n" +
// " </Methods>\r\n" +
// " </Class>\r\n" +
// " </Classes>\r\n" +
// " </Module>\r\n" +
// " </Modules>\r\n" +
// "</CoverageSession>";
//
// return new StringReader(xml);
// }
//
// [Test]
// public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeReadFromFile()
// {
// ActionArguments<CodeCoverageResults> actionArgs =
// CreateTestRunnerAndFireCodeCoverageProcessExitEvent();
//
// CodeCoverageResults result = actionArgs.Arg;
// Assert.AreEqual("MyTests", result.Modules[0].Name);
// }
//
// [Test]
// public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsTaskToTaskList()
// {
// ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced();
// Action<Task> expectedAction = context.MockTaskService.Add;
// Assert.AreEqual(expectedAction, args.Action);
// }
//
// ActionArguments<Task> CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced()
// {
// command.CallCreateTestRunner(null);
//
// MockCSharpProject project = new MockCSharpProject();
// SelectedTests tests = new SelectedTests(project);
//
// mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
// mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>");
// mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests);
//
// mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = false;
// mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent();
//
// object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0];
// return (ActionArguments<Task>)actionArgsAsObject;
// }
//
// [Test]
// public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsErrorTaskToTaskList()
// {
// command.ParsedStringToReturn = "No code coverage results file generated.";
// ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced();
// Task task = args.Arg;
//
// string description = @"No code coverage results file generated. c:\projects\MyTests\OpenCover\coverage.xml";
// int column = 1;
// int line = 1;
// Task expectedTask = new Task(null, description, column, line, TaskType.Error);
//
// TaskComparison comparison = new TaskComparison(expectedTask, task);
//
// Assert.IsTrue(comparison.IsMatch, comparison.MismatchReason);
// }
// }
//}

82
src/AddIns/Analysis/CodeCoverage/Test/Utils/DerivedCodeCoverageTestRunner.cs

@ -1,41 +1,41 @@ @@ -1,41 +1,41 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
using ICSharpCode.CodeCoverage;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.CodeCoverage.Tests.Utils
{
public class DerivedCodeCoverageTestRunner : CodeCoverageTestRunner
{
public string ParseStringReturnValue;
public string ParseStringParameter;
public DerivedCodeCoverageTestRunner(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options,
IFileSystem fileSystem,
IUnitTestMessageService messageService)
: base(new CodeCoverageTestRunnerContext(processRunner, testResultsMonitor, fileSystem, messageService, options))
{
}
public ProcessStartInfo CallGetProcessStartInfo(SelectedTests selectedTests)
{
return base.GetProcessStartInfo(selectedTests);
}
public TestResult CallCreateTestResultForTestFramework(TestResult testResult)
{
return base.CreateTestResultForTestFramework(testResult);
}
protected override string ParseString(string text)
{
ParseStringParameter = text;
return ParseStringReturnValue;
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Diagnostics;
//using ICSharpCode.CodeCoverage;
//using ICSharpCode.UnitTesting;
//
//namespace ICSharpCode.CodeCoverage.Tests.Utils
//{
// public class DerivedCodeCoverageTestRunner : CodeCoverageTestRunner
// {
// public string ParseStringReturnValue;
// public string ParseStringParameter;
//
// public DerivedCodeCoverageTestRunner(IUnitTestProcessRunner processRunner,
// ITestResultsMonitor testResultsMonitor,
// UnitTestingOptions options,
// IFileSystem fileSystem,
// IUnitTestMessageService messageService)
// : base(new CodeCoverageTestRunnerContext(processRunner, testResultsMonitor, fileSystem, messageService, options))
// {
// }
//
// public ProcessStartInfo CallGetProcessStartInfo(SelectedTests selectedTests)
// {
// return base.GetProcessStartInfo(selectedTests);
// }
//
// public TestResult CallCreateTestResultForTestFramework(TestResult testResult)
// {
// return base.CreateTestResultForTestFramework(testResult);
// }
//
// protected override string ParseString(string text)
// {
// ParseStringParameter = text;
// return ParseStringReturnValue;
// }
// }
//}

118
src/AddIns/Analysis/CodeCoverage/Test/Utils/DerivedRunTestWithCodeCoverageCommand.cs

@ -1,59 +1,59 @@ @@ -1,59 +1,59 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.CodeCoverage;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.CodeCoverage.Tests.Utils
{
public class DerivedRunTestWithCodeCoverageCommand : RunTestWithCodeCoverageCommand
{
public string ParsedStringToReturn = String.Empty;
public string ParsedString;
public DerivedRunTestWithCodeCoverageCommand(IRunTestCommandContext context,
ICodeCoverageTestRunnerFactory factory)
: base(context, factory)
{
}
public void CallOnBeforeRunTests()
{
base.OnBeforeRunTests();
}
public void CallOnAfterRunTests()
{
base.OnAfterRunTests();
}
protected override MessageViewCategory CreateMessageViewCategory(string category, string displayCategory)
{
return new MessageViewCategory(category, displayCategory);
}
public MessageViewCategory CodeCoverageMessageViewCategory {
get { return base.Category; }
set { base.Category = value;}
}
protected override string StringParse(string text)
{
ParsedString = text;
return ParsedStringToReturn;
}
public void CallTestRunnerMessageReceived(object source, MessageReceivedEventArgs e)
{
base.TestRunnerMessageReceived(source, e);
}
public ITestRunner CallCreateTestRunner(IProject project)
{
return base.CreateTestRunner(project);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.CodeCoverage;
//using ICSharpCode.SharpDevelop.Gui;
//using ICSharpCode.SharpDevelop.Project;
//using ICSharpCode.UnitTesting;
//
//namespace ICSharpCode.CodeCoverage.Tests.Utils
//{
// public class DerivedRunTestWithCodeCoverageCommand : RunTestWithCodeCoverageCommand
// {
// public string ParsedStringToReturn = String.Empty;
// public string ParsedString;
//
// public DerivedRunTestWithCodeCoverageCommand(IRunTestCommandContext context,
// ICodeCoverageTestRunnerFactory factory)
// : base(context, factory)
// {
// }
//
// public void CallOnBeforeRunTests()
// {
// base.OnBeforeRunTests();
// }
//
// public void CallOnAfterRunTests()
// {
// base.OnAfterRunTests();
// }
//
// protected override MessageViewCategory CreateMessageViewCategory(string category, string displayCategory)
// {
// return new MessageViewCategory(category, displayCategory);
// }
//
// public MessageViewCategory CodeCoverageMessageViewCategory {
// get { return base.Category; }
// set { base.Category = value;}
// }
//
// protected override string StringParse(string text)
// {
// ParsedString = text;
// return ParsedStringToReturn;
// }
//
// public void CallTestRunnerMessageReceived(object source, MessageReceivedEventArgs e)
// {
// base.TestRunnerMessageReceived(source, e);
// }
//
// public ITestRunner CallCreateTestRunner(IProject project)
// {
// return base.CreateTestRunner(project);
// }
// }
//}

80
src/AddIns/Analysis/CodeCoverage/Test/Utils/MockCodeCoverageTestRunnerFactory.cs

@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.CodeCoverage;
using ICSharpCode.Core;
using ICSharpCode.UnitTesting;
using UnitTesting.Tests.Utils;
namespace ICSharpCode.CodeCoverage.Tests.Utils
{
public class MockCodeCoverageTestRunnerFactory : ICodeCoverageTestRunnerFactory
{
public MockProcessRunner ProcessRunner;
public MockTestResultsMonitor TestResultsMonitor;
public UnitTestingOptions Options;
public CodeCoverageTestRunner TestRunner;
public MockFileSystem FileSystem;
public MockMessageService MessageService;
public MockCodeCoverageTestRunnerFactory()
{
ProcessRunner = new MockProcessRunner();
TestResultsMonitor = new MockTestResultsMonitor();
Options = new UnitTestingOptions(new Properties());
FileSystem = new MockFileSystem();
CodeCoverageTestRunnerContext context = new CodeCoverageTestRunnerContext(ProcessRunner,
TestResultsMonitor,
FileSystem,
MessageService,
Options);
TestRunner = new CodeCoverageTestRunner(context);
}
public CodeCoverageTestRunner CreateCodeCoverageTestRunner()
{
return TestRunner;
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.CodeCoverage;
//using ICSharpCode.Core;
//using ICSharpCode.UnitTesting;
//using UnitTesting.Tests.Utils;
//
//namespace ICSharpCode.CodeCoverage.Tests.Utils
//{
// public class MockCodeCoverageTestRunnerFactory : ICodeCoverageTestRunnerFactory
// {
// public MockProcessRunner ProcessRunner;
// public MockTestResultsMonitor TestResultsMonitor;
// public UnitTestingOptions Options;
// public CodeCoverageTestRunner TestRunner;
// public MockFileSystem FileSystem;
// public MockMessageService MessageService;
//
// public MockCodeCoverageTestRunnerFactory()
// {
// ProcessRunner = new MockProcessRunner();
// TestResultsMonitor = new MockTestResultsMonitor();
// Options = new UnitTestingOptions(new Properties());
// FileSystem = new MockFileSystem();
// CodeCoverageTestRunnerContext context = new CodeCoverageTestRunnerContext(ProcessRunner,
// TestResultsMonitor,
// FileSystem,
// MessageService,
// Options);
// TestRunner = new CodeCoverageTestRunner(context);
// }
//
// public CodeCoverageTestRunner CreateCodeCoverageTestRunner()
// {
// return TestRunner;
// }
// }
//}

2
src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestProject.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.UnitTesting @@ -27,7 +27,7 @@ namespace ICSharpCode.UnitTesting
if (options.UseDebugger)
return new NUnitTestDebugger();
else
return new NUnitTestRunner();
return new NUnitTestRunner(options);
}
protected override bool IsTestClass(ITypeDefinition typeDefinition)

7
src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestRunner.cs

@ -14,13 +14,14 @@ namespace ICSharpCode.UnitTesting @@ -14,13 +14,14 @@ namespace ICSharpCode.UnitTesting
{
UnitTestingOptions options;
public NUnitTestRunner()
: this(new TestProcessRunnerBaseContext(),
public NUnitTestRunner(TestExecutionOptions executionOptions)
: this(new TestProcessRunnerBaseContext(executionOptions),
UnitTestingOptions.Instance.Clone())
{
}
public NUnitTestRunner(TestProcessRunnerBaseContext context, UnitTestingOptions options)
public NUnitTestRunner(TestProcessRunnerBaseContext context,
UnitTestingOptions options)
: base(context)
{
this.options = options;

4
src/AddIns/Analysis/UnitTesting/TestRunner/TestExecutionManager.cs

@ -163,7 +163,9 @@ namespace ICSharpCode.UnitTesting.Frameworks @@ -163,7 +163,9 @@ namespace ICSharpCode.UnitTesting.Frameworks
void testRunner_TestFinished(object sender, TestFinishedEventArgs e)
{
mainThread.InvokeAsync(delegate { ShowResult(e.Result); }).FireAndForget();
mainThread.InvokeAsyncAndForget(delegate {
ShowResult(e.Result);
});
}
protected void ShowResult(TestResult result)

8
src/AddIns/Analysis/UnitTesting/TestRunner/TestExecutionOptions.cs

@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace ICSharpCode.UnitTesting
{
@ -15,5 +17,11 @@ namespace ICSharpCode.UnitTesting @@ -15,5 +17,11 @@ namespace ICSharpCode.UnitTesting
/// The default is <c>false</c>.
/// </summary>
public bool UseDebugger { get; set; }
/// <summary>
/// Modifies the ProcessStartInfo before the tests are run.
/// </summary>
public Func<ProcessStartInfo, IEnumerable<ITest>, ProcessStartInfo> ModifyProcessStartInfoBeforeTestRun
= (startInfo, tests) => startInfo;
}
}

10
src/AddIns/Analysis/UnitTesting/TestRunner/TestProcessRunnerBase.cs

@ -12,6 +12,7 @@ namespace ICSharpCode.UnitTesting @@ -12,6 +12,7 @@ namespace ICSharpCode.UnitTesting
{
public abstract class TestProcessRunnerBase : TestRunnerBase
{
TestExecutionOptions executionOptions;
IUnitTestProcessRunner processRunner;
ITestResultsReader testResultsReader;
IFileSystem fileSystem;
@ -19,6 +20,7 @@ namespace ICSharpCode.UnitTesting @@ -19,6 +20,7 @@ namespace ICSharpCode.UnitTesting
public TestProcessRunnerBase(TestProcessRunnerBaseContext context)
{
this.executionOptions = context.ExecutionOptions;
this.processRunner = context.TestProcessRunner;
this.testResultsReader = context.TestResultsReader;
this.fileSystem = context.FileSystem;
@ -47,7 +49,13 @@ namespace ICSharpCode.UnitTesting @@ -47,7 +49,13 @@ namespace ICSharpCode.UnitTesting
public override void Start(IEnumerable<ITest> selectedTests)
{
ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests);
Start(startInfo);
ProcessStartInfo modifiedStartInfo = ModifyProcessStartInfoBeforeRun(startInfo, selectedTests);
Start(modifiedStartInfo);
}
ProcessStartInfo ModifyProcessStartInfoBeforeRun(ProcessStartInfo startInfo, IEnumerable<ITest> selectedTests)
{
return executionOptions.ModifyProcessStartInfoBeforeTestRun(startInfo, selectedTests);
}
void Start(ProcessStartInfo processStartInfo)

18
src/AddIns/Analysis/UnitTesting/TestRunner/TestProcessRunnerBaseContext.cs

@ -8,31 +8,39 @@ using ICSharpCode.SharpDevelop; @@ -8,31 +8,39 @@ using ICSharpCode.SharpDevelop;
namespace ICSharpCode.UnitTesting
{
public class TestProcessRunnerBaseContext
{
{
TestExecutionOptions executionOptions;
IUnitTestProcessRunner processRunner;
ITestResultsReader testResultsReader;
IFileSystem fileSystem;
IMessageService messageService;
public TestProcessRunnerBaseContext()
: this(new UnitTestProcessRunner(),
public TestProcessRunnerBaseContext(TestExecutionOptions executionOptions)
: this(executionOptions,
new UnitTestProcessRunner(),
new TestResultsReader(),
new UnitTestFileService(),
SD.MessageService)
{
}
public TestProcessRunnerBaseContext(IUnitTestProcessRunner processRunner,
public TestProcessRunnerBaseContext(TestExecutionOptions executionOptions,
IUnitTestProcessRunner processRunner,
ITestResultsReader testResultsMonitor,
IFileSystem fileSystem,
IMessageService messageService)
{
this.executionOptions = executionOptions;
this.processRunner = processRunner;
this.testResultsReader = testResultsMonitor;
this.fileSystem = fileSystem;
this.messageService = messageService;
}
public TestExecutionOptions ExecutionOptions {
get { return executionOptions; }
}
public IUnitTestProcessRunner TestProcessRunner {
get { return processRunner; }
}

1
src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj

@ -133,7 +133,6 @@ @@ -133,7 +133,6 @@
<Compile Include="Src\Completion\RazorCSharpResolver.cs" />
<Compile Include="Src\CurrentAppDomain.cs" />
<Compile Include="Src\CurrentAppDomainFactory.cs" />
<Compile Include="Src\DelegateCommand.cs" />
<Compile Include="Src\FileSystem.cs" />
<Compile Include="Src\Folding\CharacterReader.cs" />
<Compile Include="Src\Folding\HtmlFoldParser.cs" />

3
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/AddMvcControllerToProjectViewModel.cs

@ -6,6 +6,7 @@ using System.Collections.Generic; @@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using ICSharpCode.SharpDevelop.Widgets;
using ICSharpCode.AspNet.Mvc;
namespace ICSharpCode.AspNet.Mvc
@ -56,7 +57,7 @@ namespace ICSharpCode.AspNet.Mvc @@ -56,7 +57,7 @@ namespace ICSharpCode.AspNet.Mvc
void CreateCommands()
{
AddMvcControllerCommand = new DelegateCommand(param => AddMvcController(), param => CanAddMvcController());
AddMvcControllerCommand = new RelayCommand(AddMvcController, CanAddMvcController);
}
public ICommand AddMvcControllerCommand { get; private set; }

9
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/AddMvcViewToProjectViewModel.cs

@ -7,6 +7,7 @@ using System.Collections.ObjectModel; @@ -7,6 +7,7 @@ using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Windows.Input;
using ICSharpCode.SharpDevelop.Widgets;
namespace ICSharpCode.AspNet.Mvc
{
@ -63,10 +64,10 @@ namespace ICSharpCode.AspNet.Mvc @@ -63,10 +64,10 @@ namespace ICSharpCode.AspNet.Mvc
void CreateCommands()
{
AddMvcViewCommand = new DelegateCommand(param => AddMvcView(), param => CanAddMvcView());
OpenSelectMasterPageViewCommand = new DelegateCommand(param => OpenSelectMasterPageView());
CloseSelectMasterPageViewCommand = new DelegateCommand(param => CloseSelectMasterPageView());
SelectMasterPageCommand = new DelegateCommand(param => SelectMasterPage(), param => CanSelectMasterPage());
AddMvcViewCommand = new RelayCommand(AddMvcView, CanAddMvcView);
OpenSelectMasterPageViewCommand = new RelayCommand(OpenSelectMasterPageView);
CloseSelectMasterPageViewCommand = new RelayCommand(CloseSelectMasterPageView);
SelectMasterPageCommand = new RelayCommand(SelectMasterPage, CanSelectMasterPage);
}
public ICommand AddMvcViewCommand { get; private set; }

43
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/DelegateCommand.cs

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Input;
namespace ICSharpCode.AspNet.Mvc
{
public class DelegateCommand : ICommand
{
Action<object> execute;
Predicate<object> canExecute;
public DelegateCommand(Action<object> execute, Predicate<object> canExecute)
{
this.execute = execute;
this.canExecute = canExecute;
}
public DelegateCommand(Action<object> execute)
: this(execute, null)
{
}
public event EventHandler CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter)
{
execute(parameter);
}
public bool CanExecute(object parameter)
{
if (canExecute != null) {
return canExecute(parameter);
}
return true;
}
}
}

81
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs

@ -7,6 +7,7 @@ using System.Linq; @@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Media.Animation;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory;
@ -29,10 +30,10 @@ namespace CSharpBinding.Refactoring @@ -29,10 +30,10 @@ namespace CSharpBinding.Refactoring
/// </summary>
public class CSharpCodeGenerator : ICodeGenerator
{
CSharpProject project;
IProject project;
ProjectEntityModelContext model;
public CSharpCodeGenerator(CSharpProject project)
public CSharpCodeGenerator(IProject project)
{
if (project == null)
throw new ArgumentNullException("project");
@ -42,15 +43,22 @@ namespace CSharpBinding.Refactoring @@ -42,15 +43,22 @@ namespace CSharpBinding.Refactoring
public void AddAttribute(IEntity target, IAttribute attribute)
{
var view = SD.FileService.OpenFile(new FileName(target.Region.FileName), false);
var editor = view.GetRequiredService<ITextEditor>();
var context = SDRefactoringContext.Create(editor, CancellationToken.None);
var node = context.RootNode.GetNodeAt<EntityDeclaration>(target.Region.Begin);
var resolver = context.GetResolverStateBefore(node);
var builder = new TypeSystemAstBuilder(resolver);
editor.Document.Insert(editor.Document.GetOffset(target.BodyRegion.Begin),
PrintAst(builder.ConvertAttribute(attribute)));
AddAttribute(target.Region, attribute);
}
public void AddAssemblyAttribute(IAttribute attribute)
{
// FIXME : will fail if there are no assembly attributes
ICompilation compilation = SD.ParserService.GetCompilation(project);
IAttribute target = compilation.MainAssembly.AssemblyAttributes.LastOrDefault();
if (target == null)
throw new InvalidOperationException("no assembly attributes found, cannot continue!");
AddAttribute(target.Region, attribute, "assembly");
}
public void AddReturnTypeAttribute(IMethod target, IAttribute attribute)
{
AddAttribute(target.Region, attribute, "return");
}
public void InsertEventHandler(ITypeDefinition target, string name, IEvent eventDefinition, bool jumpTo)
@ -69,25 +77,52 @@ namespace CSharpBinding.Refactoring @@ -69,25 +77,52 @@ namespace CSharpBinding.Refactoring
var view = SD.FileService.OpenFile(new FileName(match.Region.FileName), jumpTo);
var editor = view.GetRequiredService<ITextEditor>();
var context = SDRefactoringContext.Create(editor, CancellationToken.None);
var last = match.Members.LastOrDefault() ?? (IUnresolvedEntity)match;
var context = SDRefactoringContext.Create(editor.FileName, editor.Document, last.BodyRegion.End, CancellationToken.None);
IEntity last = (IEntity)target.GetMembers().LastOrDefault() ?? (IEntity)target;
var node = context.RootNode.GetNodeAt<EntityDeclaration>(last.Region.Begin);
var resolver = context.GetResolverStateAfter(node);
var builder = new TypeSystemAstBuilder(resolver);
var delegateDecl = builder.ConvertEntity(eventDefinition.ReturnType.GetDefinition()) as DelegateDeclaration;
if (delegateDecl == null) return;
var decl = new MethodDeclaration() {
ReturnType = delegateDecl.ReturnType.Clone(),
Name = name,
Body = new BlockStatement() {
new ThrowStatement(new ObjectCreateExpression(context.CreateShortType("System", "NotImplementedException")))
}
};
var param = delegateDecl.Parameters.Select(p => p.Clone()).OfType<ParameterDeclaration>().ToArray();
decl.Parameters.AddRange(param);
#warning implement code generation!
string eventHandler = "<generated code>";
editor.Document.Insert(editor.Document.GetOffset(target.Region.End), eventHandler);
using (Script script = context.StartScript()) {
// FIXME : will not work properly if there are no members.
if (last == match) {
throw new NotImplementedException();
// TODO InsertWithCursor not implemented!
//script.InsertWithCursor("Insert event handler", Script.InsertPosition.End, decl).RunSynchronously();
} else {
script.InsertAfter(node, decl);
}
}
}
string PrintAst(AstNode node)
void AddAttribute(DomRegion region, IAttribute attribute, string target = "")
{
StringBuilder sb = new StringBuilder();
CSharpOutputVisitor visitor = new CSharpOutputVisitor(new StringWriter(sb), FormattingOptionsFactory.CreateSharpDevelop());
node.AcceptVisitor(visitor);
return sb.ToString();
var view = SD.FileService.OpenFile(new FileName(region.FileName), false);
var editor = view.GetRequiredService<ITextEditor>();
var context = SDRefactoringContext.Create(editor.FileName, editor.Document, region.Begin, CancellationToken.None);
var node = context.RootNode.GetNodeAt<AstNode>(region.Begin);
if (node is ICSharpCode.NRefactory.CSharp.Attribute) node = node.Parent;
var resolver = context.GetResolverStateBefore(node);
var builder = new TypeSystemAstBuilder(resolver);
using (Script script = context.StartScript()) {
var attr = new AttributeSection();
attr.AttributeTarget = target;
attr.Attributes.Add(builder.ConvertAttribute(attribute));
script.InsertBefore(node, attr);
}
}
}
}

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs

@ -47,7 +47,7 @@ namespace CSharpBinding.Refactoring @@ -47,7 +47,7 @@ namespace CSharpBinding.Refactoring
// create dummy refactoring context
resolver = new CSharpAstResolver(compilation, new SyntaxTree());
}
var context = new SDRefactoringContext(textSource, resolver, new TextLocation(0, 0), 0, 0, cancellationToken);
var context = new SDRefactoringContext(textSource, resolver, location, 0, 0, cancellationToken);
return context;
}

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SearchForIssuesCommand.cs

@ -124,6 +124,8 @@ namespace CSharpBinding.Refactoring @@ -124,6 +124,8 @@ namespace CSharpBinding.Refactoring
if (resultForFile != null) {
callback(resultForFile);
}
} catch (IOException) {
// ignore IO exceptions (e.g. a file is missing)
} catch (OperationCanceledException) {
throw;
} catch (Exception ex) {

1
src/AddIns/BackendBindings/CSharpBinding/Tests/CSharpBinding.Tests.csproj

@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CSharpCodeGeneratorTests.cs" />
<Compile Include="CSharpFormattingTests.cs" />
<Compile Include="RegistrationTests.cs" />
<Compile Include="MockTextEditor.cs" />

340
src/AddIns/BackendBindings/CSharpBinding/Tests/CSharpCodeGeneratorTests.cs

@ -0,0 +1,340 @@ @@ -0,0 +1,340 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using CSharpBinding.Completion;
using CSharpBinding.Parser;
using CSharpBinding.Refactoring;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using System;
using System.Linq;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Workbench;
using NUnit.Framework;
using Rhino.Mocks;
namespace CSharpBinding.Tests
{
[TestFixture]
public class CSharpCodeGeneratorTests
{
string program = @"using System;
using System.Reflection;
[assembly: AssemblyTitle(""CSharpBinding.Tests"")]
class MySimpleAttribute : Attribute {}
class TargetClass
{
void TargetA()
{
}
public int TargetB { get; set; }
public int TargetC_ {
get {
return 0;
}
}
}
interface TargetInterface
{
}
";
MockTextEditor textEditor;
CSharpCodeGenerator gen;
static readonly IUnresolvedAssembly Corlib = new CecilLoader().LoadAssemblyFile(typeof(object).Assembly.Location);
[SetUp]
public void SetUp()
{
SD.InitializeForUnitTests();
textEditor = new MockTextEditor();
textEditor.Document.Text = program;
var parseInfo = textEditor.CreateParseInformation();
IProject project = MockRepository.GenerateStrictMock<IProject>();
var pc = new CSharpProjectContent().AddOrUpdateFiles(parseInfo.UnresolvedFile);
pc = pc.AddAssemblyReferences(new[] { Corlib });
var compilation = pc.CreateCompilation();
SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStrictMock<IParserService>());
SD.ParserService.Stub(p => p.GetCachedParseInformation(textEditor.FileName)).Return(parseInfo);
SD.ParserService.Stub(p => p.GetCompilation(project)).Return(compilation);
SD.ParserService.Stub(p => p.GetCompilationForFile(textEditor.FileName)).Return(compilation);
SD.ParserService.Stub(p => p.Parse(textEditor.FileName, textEditor.Document)).WhenCalled(
i => {
var syntaxTree = new CSharpParser().Parse(textEditor.Document, textEditor.FileName);
i.ReturnValue = new CSharpFullParseInformation(syntaxTree.ToTypeSystem(), null, syntaxTree);
}).Return(parseInfo); // fake Return to make it work
SD.Services.AddService(typeof(IFileService), MockRepository.GenerateStrictMock<IFileService>());
IViewContent view = MockRepository.GenerateStrictMock<IViewContent>();
view.Stub(v => v.GetService(typeof(ITextEditor))).Return(textEditor);
SD.FileService.Stub(f => f.OpenFile(textEditor.FileName, false)).Return(view);
gen = new CSharpCodeGenerator(project);
}
[TearDown]
public void TearDown()
{
SD.TearDownForUnitTests();
}
[Test]
public void AddSimpleAttributeToClass()
{
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName);
var entity = FindEntity<ITypeDefinition>("TargetClass");
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute"));
gen.AddAttribute(entity, new DefaultAttribute(attribute));
Assert.AreEqual(@"using System;
using System.Reflection;
[assembly: AssemblyTitle(""CSharpBinding.Tests"")]
class MySimpleAttribute : Attribute {}
[MySimple]
class TargetClass
{
void TargetA()
{
}
public int TargetB { get; set; }
public int TargetC_ {
get {
return 0;
}
}
}
interface TargetInterface
{
}
", textEditor.Document.Text);
}
[Test]
public void AddSimpleAttributeToMethod()
{
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName);
var entity = FindEntity<IMethod>("TargetA");
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute"));
gen.AddAttribute(entity, new DefaultAttribute(attribute));
Assert.AreEqual(@"using System;
using System.Reflection;
[assembly: AssemblyTitle(""CSharpBinding.Tests"")]
class MySimpleAttribute : Attribute {}
class TargetClass
{
[MySimple]
void TargetA()
{
}
public int TargetB { get; set; }
public int TargetC_ {
get {
return 0;
}
}
}
interface TargetInterface
{
}
", textEditor.Document.Text);
}
[Test]
public void AddSimpleAttributeToInterface()
{
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName);
var entity = FindEntity<ITypeDefinition>("TargetInterface");
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute"));
gen.AddAttribute(entity, new DefaultAttribute(attribute));
Assert.AreEqual(@"using System;
using System.Reflection;
[assembly: AssemblyTitle(""CSharpBinding.Tests"")]
class MySimpleAttribute : Attribute {}
class TargetClass
{
void TargetA()
{
}
public int TargetB { get; set; }
public int TargetC_ {
get {
return 0;
}
}
}
[MySimple]
interface TargetInterface
{
}
", textEditor.Document.Text);
}
[Test]
public void AddSimpleAttributeToProperty()
{
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName);
var entity = FindEntity<IProperty>("TargetB");
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute"));
gen.AddAttribute(entity, new DefaultAttribute(attribute));
Assert.AreEqual(@"using System;
using System.Reflection;
[assembly: AssemblyTitle(""CSharpBinding.Tests"")]
class MySimpleAttribute : Attribute {}
class TargetClass
{
void TargetA()
{
}
[MySimple]
public int TargetB { get; set; }
public int TargetC_ {
get {
return 0;
}
}
}
interface TargetInterface
{
}
", textEditor.Document.Text);
}
[Test]
public void AddSimpleAttributeToPropertyGetter()
{
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName);
var entity = FindEntity<IProperty>("TargetC_");
Assert.IsTrue(entity.CanGet);
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute"));
gen.AddAttribute(entity.Getter, new DefaultAttribute(attribute));
Assert.AreEqual(@"using System;
using System.Reflection;
[assembly: AssemblyTitle(""CSharpBinding.Tests"")]
class MySimpleAttribute : Attribute {}
class TargetClass
{
void TargetA()
{
}
public int TargetB { get; set; }
public int TargetC_ {
[MySimple]
get {
return 0;
}
}
}
interface TargetInterface
{
}
", textEditor.Document.Text);
}
[Test]
[Ignore("The C# parser provides empty location info for AttributeSections.")]
public void AddSimpleAssemblyAttribute()
{
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName);
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute"));
gen.AddAssemblyAttribute(new DefaultAttribute(attribute));
Assert.AreEqual(@"using System;
using System.Reflection;
[assembly: MySimple]
[assembly: AssemblyTitle(""CSharpBinding.Tests"")]
class MySimpleAttribute : Attribute {}
[MySimple]
class TargetClass
{
void TargetA()
{
}
public int TargetB { get; set; }
public int TargetC_ {
get {
return 0;
}
}
}
interface TargetInterface
{
}
", textEditor.Document.Text);
}
T FindEntity<T>(string targetClass) where T : IEntity
{
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName);
var parseInfo = SD.ParserService.Parse(textEditor.FileName, textEditor.Document);
int i = textEditor.Document.IndexOf(targetClass, 0, textEditor.Document.TextLength, StringComparison.Ordinal);
Assert.Greater(i, -1);
TextLocation location = textEditor.Document.GetLocation(i);
var member = parseInfo.UnresolvedFile.GetMember(location);
var type = parseInfo.UnresolvedFile.GetInnermostTypeDefinition(location);
var context = new SimpleTypeResolveContext(compilation.MainAssembly);
var rt = type.Resolve(context).GetDefinition();
if (member != null) {
return (T)member.CreateResolved(context.WithCurrentTypeDefinition(rt));
}
return (T)rt;
}
}
}

8
src/AddIns/BackendBindings/FSharpBinding/FSharpInteractive.cs

@ -71,21 +71,21 @@ namespace FSharpBinding @@ -71,21 +71,21 @@ namespace FSharpBinding
lock (outputQueue) {
outputQueue.Enqueue(e.Data);
}
SD.MainThread.InvokeAsync(ReadAll).FireAndForget();
SD.MainThread.InvokeAsyncAndForget(ReadAll);
};
fsiProcess.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) {
lock (outputQueue) {
outputQueue.Enqueue(e.Data);
}
SD.MainThread.InvokeAsync(ReadAll).FireAndForget();
SD.MainThread.InvokeAsyncAndForget(ReadAll);
};
fsiProcess.Exited += delegate(object sender, EventArgs e) {
lock (outputQueue) {
outputQueue.Enqueue("fsi.exe died");
outputQueue.Enqueue("restarting ...");
}
SD.MainThread.InvokeAsync(ReadAll).FireAndForget();
SD.MainThread.InvokeAsync(StartFSharp).FireAndForget();
SD.MainThread.InvokeAsyncAndForget(ReadAll);
SD.MainThread.InvokeAsyncAndForget(StartFSharp);
};
StartFSharp();
}

32
src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj

@ -7,20 +7,22 @@ @@ -7,20 +7,22 @@
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Scripting</RootNamespace>
<AssemblyName>ICSharpCode.Scripting</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<OutputPath>..\..\..\..\..\bin\</OutputPath>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@ -29,6 +31,7 @@ @@ -29,6 +31,7 @@
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>false</DebugSymbols>
@ -37,6 +40,14 @@ @@ -37,6 +40,14 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>False</Prefer32Bit>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
@ -117,6 +128,11 @@ @@ -117,6 +128,11 @@
<Name>ICSharpCode.AvalonEdit</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
@ -132,21 +148,11 @@ @@ -132,21 +148,11 @@
<Name>ICSharpCode.Core.WinForms</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Analysis\UnitTesting\UnitTesting.csproj">
<Project>{1F261725-6318-4434-A1B1-6C70CE4CD324}</Project>
<Name>UnitTesting</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj">
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project>
<Name>FormsDesigner</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

40
src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingDesignerGenerator.cs

@ -1,20 +1,20 @@ @@ -1,20 +1,20 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using ICSharpCode.FormsDesigner;
namespace ICSharpCode.Scripting
{
public interface IScriptingDesignerGenerator : IDesignerGenerator
{
/// <summary>
/// Updates the form or user control's InitializeComponent method with any
/// changes to the designed form or user control.
/// </summary>
void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager);
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//
//using ICSharpCode.FormsDesigner;
//
//namespace ICSharpCode.Scripting
//{
// public interface IScriptingDesignerGenerator : IDesignerGenerator
// {
// /// <summary>
// /// Updates the form or user control's InitializeComponent method with any
// /// changes to the designed form or user control.
// /// </summary>
// void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager);
// }
//}

1
src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingWorkbench.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.Scripting

11
src/AddIns/BackendBindings/Scripting/Project/Src/LineIndenter.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Text;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.Scripting
@ -48,8 +49,8 @@ namespace ICSharpCode.Scripting @@ -48,8 +49,8 @@ namespace ICSharpCode.Scripting
void GetPreviousLine()
{
int lineNumber = line.LineNumber - 1;
previousLine = document.GetLine(lineNumber);
previousLineText = previousLine.Text.Trim();
previousLine = document.GetLineByNumber(lineNumber);
previousLineText = document.GetText(previousLine).Trim();
}
protected string PreviousLine {
@ -80,7 +81,7 @@ namespace ICSharpCode.Scripting @@ -80,7 +81,7 @@ namespace ICSharpCode.Scripting
{
string previousLineIndentation = GetPreviousLineIndentation();
string indentation = GetNewLineIndentation(previousLineIndentation, increaseIndent);
string newLineText = indentation + line.Text;
string newLineText = indentation + document.GetText(line);
ReplaceLine(newLineText);
}
@ -91,8 +92,8 @@ namespace ICSharpCode.Scripting @@ -91,8 +92,8 @@ namespace ICSharpCode.Scripting
string GetIndentation(IDocumentLine documentLine)
{
StringBuilder whitespace = new StringBuilder();
foreach (char ch in documentLine.Text) {
StringBuilder whitespace = new StringBuilder();
foreach (char ch in document.GetText(documentLine)) {
if (Char.IsWhiteSpace(ch)) {
whitespace.Append(ch);
} else {

2
src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsoleCompletionData.cs

@ -4,8 +4,8 @@ @@ -4,8 +4,8 @@
using System;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.Scripting
{

2
src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingConsolePad.cs

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
using System;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Scripting
{

580
src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingDesignerGenerator.cs

@ -1,290 +1,290 @@ @@ -1,290 +1,290 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using ICSharpCode.FormsDesigner;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.Scripting
{
public abstract class ScriptingDesignerGenerator : IScriptingDesignerGenerator
{
FormsDesignerViewContent viewContent;
ITextEditorOptions textEditorOptions;
public ITextEditorOptions TextEditorOptions {
get { return textEditorOptions; }
}
public ScriptingDesignerGenerator(ITextEditorOptions textEditorOptions)
{
this.textEditorOptions = textEditorOptions;
}
public CodeDomProvider CodeDomProvider {
get { return null; }
}
public FormsDesignerViewContent ViewContent {
get { return viewContent; }
}
public void Attach(FormsDesignerViewContent viewContent)
{
this.viewContent = viewContent;
}
public void Detach()
{
this.viewContent = null;
}
public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
{
designerCodeFile = viewContent.PrimaryFile;
return new [] {designerCodeFile};
}
public void MergeFormChanges(CodeCompileUnit unit)
{
}
/// <summary>
/// Returns a list of method names that could be used as an
/// event handler with the specified event.
/// </summary>
public ICollection GetCompatibleMethods(EventDescriptor edesc)
{
ParseInformation parseInfo = ParseFile();
return GetCompatibleMethods(parseInfo);
}
/// <summary>
/// Parses the form or user control being designed.
/// </summary>
ParseInformation ParseFile()
{
string fileName = viewContent.DesignerCodeFile.FileName;
string textContent = viewContent.DesignerCodeFileContent;
return ParseFile(fileName, textContent);
}
/// <summary>
/// The default implementation calls the ParserService.ParseFile. This
/// method is overridable so the class can be easily tested without
/// the ParserService being required.
/// </summary>
protected virtual ParseInformation ParseFile(string fileName, string textContent)
{
return ParserService.ParseFile(fileName, new StringTextBuffer(textContent));
}
ICollection GetCompatibleMethods(ParseInformation parseInfo)
{
IClass c = GetClass(parseInfo.CompilationUnit);
return GetCompatibleMethods(c);
}
/// <summary>
/// Gets the form or user control class from the compilation unit.
/// </summary>
IClass GetClass(ICompilationUnit unit)
{
return unit.Classes[0];
}
ICollection GetCompatibleMethods(IClass c)
{
ArrayList methods = new ArrayList();
foreach (IMethod method in c.Methods) {
if (IsCompatibleMethod(method)) {
methods.Add(method.Name);
}
}
return methods;
}
bool IsCompatibleMethod(IMethod method)
{
return method.Parameters.Count == 2;
}
public void NotifyComponentRenamed(object component, string newName, string oldName)
{
}
/// <summary>
/// Updates the InitializeComponent method's body with the generated code.
/// </summary>
public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
{
ParseInformation parseInfo = ParseFile();
Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, serializationManager);
}
/// <summary>
/// Merges the generated code into the specified document.
/// </summary>
/// <param name="component">The designer host.</param>
/// <param name="document">The document that the generated code will be merged into.</param>
/// <param name="parseInfo">The current compilation unit for the <paramref name="document"/>.</param>
public void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, IDesignerSerializationManager serializationManager)
{
IMethod method = GetInitializeComponents(compilationUnit);
string methodBody = GenerateMethodBody(method, host, serializationManager);
UpdateMethodBody(document, method, methodBody);
}
public string GenerateMethodBody(IMethod method, IDesignerHost host, IDesignerSerializationManager serializationManager)
{
int indent = GetIndent(method);
string rootNamespace = GetProjectRootNamespace(method.CompilationUnit);
IScriptingCodeDomSerializer serializer = CreateCodeDomSerializer(textEditorOptions);
return serializer.GenerateInitializeComponentMethodBody(host, serializationManager, rootNamespace, indent);
}
public int GetIndent(IMethod method)
{
int indent = method.Region.BeginColumn;
if (textEditorOptions.ConvertTabsToSpaces) {
indent = (indent / textEditorOptions.IndentationSize);
if (textEditorOptions.IndentationSize > 1) {
indent += 1;
}
}
return indent;
}
public string GetProjectRootNamespace(ICompilationUnit compilationUnit)
{
IProject project = compilationUnit.ProjectContent.Project as IProject;
if (project != null) {
return project.RootNamespace;
}
return String.Empty;
}
public virtual IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
{
return null;
}
public void UpdateMethodBody(IDocument document, IMethod method, string methodBody)
{
DomRegion methodRegion = GetBodyRegionInDocument(method);
int startOffset = GetStartOffset(document, methodRegion);
int endOffset = GetEndOffset(document, methodRegion);
document.Replace(startOffset, endOffset - startOffset, methodBody);
}
public virtual DomRegion GetBodyRegionInDocument(IMethod method)
{
return DomRegion.Empty;
}
/// <summary>
/// Gets the non-generated InitializeComponents from parse info.
/// </summary>
public static IMethod GetInitializeComponents(ParseInformation parseInfo)
{
return GetInitializeComponents(parseInfo.CompilationUnit);
}
/// <summary>
/// Gets the non-generated InitializeComponents from the compilation unit.
/// </summary>
public static IMethod GetInitializeComponents(ICompilationUnit unit)
{
foreach (IClass c in unit.Classes) {
if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) {
IMethod method = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
if (method != null) {
return method;
}
}
}
return null;
}
/// <summary>
/// Gets the start offset of the region.
/// </summary>
static int GetStartOffset(IDocument document, DomRegion region)
{
return document.PositionToOffset(region.BeginLine, region.BeginColumn);
}
/// <summary>
/// Gets the end offset of the region.
/// </summary>
static int GetEndOffset(IDocument document, DomRegion region)
{
if (region.EndLine > document.TotalNumberOfLines) {
// At end of document.
return document.TextLength;
}
return document.PositionToOffset(region.EndLine, region.EndColumn);
}
/// <summary>
/// Inserts an event handler.
/// </summary>
public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
{
position = GetExistingEventHandler(eventMethodName);
if (position == -1) {
// Ensure the text editor has the latest version
// of the source code before we insert any new code.
viewContent.MergeFormChanges();
// Insert the event handler at the end of the class.
IDocument doc = ViewContent.DesignerCodeFileDocument;
string eventHandler = CreateEventHandler(eventMethodName, body, TextEditorOptions.IndentationString);
position = InsertEventHandler(doc, eventHandler);
}
// Set the filename so it refers to the form being designed.
file = ViewContent.DesignerCodeFile.FileName;
return true;
}
/// <summary>
/// Checks if the event handler already exists.
/// </summary>
/// <returns>The line position of the first line of the existing event handler.</returns>
int GetExistingEventHandler(string methodName)
{
ParseInformation parseInfo = ParseFile();
IClass c = GetClass(parseInfo.CompilationUnit);
foreach (IMethod method in c.Methods) {
if ((method.Name == methodName) && (method.Parameters.Count == 2)) {
return method.Region.BeginLine;
}
}
return -1;
}
public virtual string CreateEventHandler(string eventMethodName, string body, string indentation)
{
return String.Empty;
}
public virtual int InsertEventHandler(IDocument document, string eventHandler)
{
return 0;
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.CodeDom;
//using System.CodeDom.Compiler;
//using System.Collections;
//using System.Collections.Generic;
//using System.ComponentModel;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//
//using ICSharpCode.FormsDesigner;
//using ICSharpCode.SharpDevelop;
//using ICSharpCode.SharpDevelop.Dom;
//using ICSharpCode.SharpDevelop.Editor;
//using ICSharpCode.SharpDevelop.Project;
//
//namespace ICSharpCode.Scripting
//{
// public abstract class ScriptingDesignerGenerator : IScriptingDesignerGenerator
// {
// FormsDesignerViewContent viewContent;
// ITextEditorOptions textEditorOptions;
//
// public ITextEditorOptions TextEditorOptions {
// get { return textEditorOptions; }
// }
//
// public ScriptingDesignerGenerator(ITextEditorOptions textEditorOptions)
// {
// this.textEditorOptions = textEditorOptions;
// }
//
// public CodeDomProvider CodeDomProvider {
// get { return null; }
// }
//
// public FormsDesignerViewContent ViewContent {
// get { return viewContent; }
// }
//
// public void Attach(FormsDesignerViewContent viewContent)
// {
// this.viewContent = viewContent;
// }
//
// public void Detach()
// {
// this.viewContent = null;
// }
//
// public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
// {
// designerCodeFile = viewContent.PrimaryFile;
// return new [] {designerCodeFile};
// }
//
// public void MergeFormChanges(CodeCompileUnit unit)
// {
// }
//
// /// <summary>
// /// Returns a list of method names that could be used as an
// /// event handler with the specified event.
// /// </summary>
// public ICollection GetCompatibleMethods(EventDescriptor edesc)
// {
// ParseInformation parseInfo = ParseFile();
// return GetCompatibleMethods(parseInfo);
// }
//
// /// <summary>
// /// Parses the form or user control being designed.
// /// </summary>
// ParseInformation ParseFile()
// {
// string fileName = viewContent.DesignerCodeFile.FileName;
// string textContent = viewContent.DesignerCodeFileContent;
// return ParseFile(fileName, textContent);
// }
//
// /// <summary>
// /// The default implementation calls the ParserService.ParseFile. This
// /// method is overridable so the class can be easily tested without
// /// the ParserService being required.
// /// </summary>
// protected virtual ParseInformation ParseFile(string fileName, string textContent)
// {
// return ParserService.ParseFile(fileName, new StringTextBuffer(textContent));
// }
//
// ICollection GetCompatibleMethods(ParseInformation parseInfo)
// {
// IClass c = GetClass(parseInfo.CompilationUnit);
// return GetCompatibleMethods(c);
// }
//
// /// <summary>
// /// Gets the form or user control class from the compilation unit.
// /// </summary>
// IClass GetClass(ICompilationUnit unit)
// {
// return unit.Classes[0];
// }
//
// ICollection GetCompatibleMethods(IClass c)
// {
// ArrayList methods = new ArrayList();
// foreach (IMethod method in c.Methods) {
// if (IsCompatibleMethod(method)) {
// methods.Add(method.Name);
// }
// }
// return methods;
// }
//
// bool IsCompatibleMethod(IMethod method)
// {
// return method.Parameters.Count == 2;
// }
//
// public void NotifyComponentRenamed(object component, string newName, string oldName)
// {
// }
//
// /// <summary>
// /// Updates the InitializeComponent method's body with the generated code.
// /// </summary>
// public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
// {
// ParseInformation parseInfo = ParseFile();
// Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, serializationManager);
// }
//
// /// <summary>
// /// Merges the generated code into the specified document.
// /// </summary>
// /// <param name="component">The designer host.</param>
// /// <param name="document">The document that the generated code will be merged into.</param>
// /// <param name="parseInfo">The current compilation unit for the <paramref name="document"/>.</param>
// public void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, IDesignerSerializationManager serializationManager)
// {
// IMethod method = GetInitializeComponents(compilationUnit);
// string methodBody = GenerateMethodBody(method, host, serializationManager);
// UpdateMethodBody(document, method, methodBody);
// }
//
// public string GenerateMethodBody(IMethod method, IDesignerHost host, IDesignerSerializationManager serializationManager)
// {
// int indent = GetIndent(method);
// string rootNamespace = GetProjectRootNamespace(method.CompilationUnit);
// IScriptingCodeDomSerializer serializer = CreateCodeDomSerializer(textEditorOptions);
// return serializer.GenerateInitializeComponentMethodBody(host, serializationManager, rootNamespace, indent);
// }
//
// public int GetIndent(IMethod method)
// {
// int indent = method.Region.BeginColumn;
// if (textEditorOptions.ConvertTabsToSpaces) {
// indent = (indent / textEditorOptions.IndentationSize);
// if (textEditorOptions.IndentationSize > 1) {
// indent += 1;
// }
// }
// return indent;
// }
//
// public string GetProjectRootNamespace(ICompilationUnit compilationUnit)
// {
// IProject project = compilationUnit.ProjectContent.Project as IProject;
// if (project != null) {
// return project.RootNamespace;
// }
// return String.Empty;
// }
//
// public virtual IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
// {
// return null;
// }
//
// public void UpdateMethodBody(IDocument document, IMethod method, string methodBody)
// {
// DomRegion methodRegion = GetBodyRegionInDocument(method);
// int startOffset = GetStartOffset(document, methodRegion);
// int endOffset = GetEndOffset(document, methodRegion);
//
// document.Replace(startOffset, endOffset - startOffset, methodBody);
// }
//
// public virtual DomRegion GetBodyRegionInDocument(IMethod method)
// {
// return DomRegion.Empty;
// }
//
// /// <summary>
// /// Gets the non-generated InitializeComponents from parse info.
// /// </summary>
// public static IMethod GetInitializeComponents(ParseInformation parseInfo)
// {
// return GetInitializeComponents(parseInfo.CompilationUnit);
// }
//
// /// <summary>
// /// Gets the non-generated InitializeComponents from the compilation unit.
// /// </summary>
// public static IMethod GetInitializeComponents(ICompilationUnit unit)
// {
// foreach (IClass c in unit.Classes) {
// if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) {
// IMethod method = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
// if (method != null) {
// return method;
// }
// }
// }
// return null;
// }
//
// /// <summary>
// /// Gets the start offset of the region.
// /// </summary>
// static int GetStartOffset(IDocument document, DomRegion region)
// {
// return document.PositionToOffset(region.BeginLine, region.BeginColumn);
// }
//
// /// <summary>
// /// Gets the end offset of the region.
// /// </summary>
// static int GetEndOffset(IDocument document, DomRegion region)
// {
// if (region.EndLine > document.TotalNumberOfLines) {
// // At end of document.
// return document.TextLength;
// }
// return document.PositionToOffset(region.EndLine, region.EndColumn);
// }
//
// /// <summary>
// /// Inserts an event handler.
// /// </summary>
// public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
// {
// position = GetExistingEventHandler(eventMethodName);
// if (position == -1) {
// // Ensure the text editor has the latest version
// // of the source code before we insert any new code.
// viewContent.MergeFormChanges();
//
// // Insert the event handler at the end of the class.
// IDocument doc = ViewContent.DesignerCodeFileDocument;
// string eventHandler = CreateEventHandler(eventMethodName, body, TextEditorOptions.IndentationString);
// position = InsertEventHandler(doc, eventHandler);
// }
//
// // Set the filename so it refers to the form being designed.
// file = ViewContent.DesignerCodeFile.FileName;
//
// return true;
// }
//
// /// <summary>
// /// Checks if the event handler already exists.
// /// </summary>
// /// <returns>The line position of the first line of the existing event handler.</returns>
// int GetExistingEventHandler(string methodName)
// {
// ParseInformation parseInfo = ParseFile();
// IClass c = GetClass(parseInfo.CompilationUnit);
// foreach (IMethod method in c.Methods) {
// if ((method.Name == methodName) && (method.Parameters.Count == 2)) {
// return method.Region.BeginLine;
// }
// }
// return -1;
// }
//
// public virtual string CreateEventHandler(string eventMethodName, string body, string indentation)
// {
// return String.Empty;
// }
//
// public virtual int InsertEventHandler(IDocument document, string eventHandler)
// {
// return 0;
// }
// }
//}

336
src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingDesignerLoader.cs

@ -1,168 +1,168 @@ @@ -1,168 +1,168 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Resources;
using System.Security.Permissions;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.FormsDesigner.Services;
namespace ICSharpCode.Scripting
{
/// <summary>
/// Loads the form or control's code so the forms designer can
/// display it.
/// </summary>
[PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")]
[PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
public class ScriptingDesignerLoader : BasicDesignerLoader, IComponentCreator
{
IScriptingDesignerGenerator generator;
IDesignerSerializationManager serializationManager;
IResourceService resourceService;
Dictionary<string, IComponent> addedObjects = new Dictionary<string, IComponent>();
public ScriptingDesignerLoader(IScriptingDesignerGenerator generator)
{
if (generator == null) {
throw new ArgumentException("Generator cannot be null.", "generator");
}
this.generator = generator;
}
public override void BeginLoad(IDesignerLoaderHost host)
{
AddServices(host);
SetDesignerSupportsProjectResourcesToFalse(host);
base.BeginLoad(host);
}
void AddServices(IDesignerLoaderHost host)
{
host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
host.AddService(typeof(INameCreationService), new ScriptingNameCreationService(host));
host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host));
}
void SetDesignerSupportsProjectResourcesToFalse(IDesignerLoaderHost host)
{
ProjectResourceService projectResourceService = host.GetService(typeof(ProjectResourceService)) as ProjectResourceService;
if (projectResourceService != null) {
projectResourceService.DesignerSupportsProjectResources = false;
}
}
public IComponent CreateComponent(Type componentClass, string name)
{
return base.LoaderHost.CreateComponent(componentClass, name);
}
public void Add(IComponent component, string name)
{
base.LoaderHost.Container.Add(component, name);
}
/// <summary>
/// Gets a component that has been added to the loader.
/// </summary>
/// <returns>Null if the component cannot be found.</returns>
public IComponent GetComponent(string name)
{
return LoaderHost.Container.Components[name];
}
public IComponent RootComponent {
get { return base.LoaderHost.RootComponent; }
}
public object CreateInstance(Type type, ICollection arguments, string name, bool addToContainer)
{
return serializationManager.CreateInstance(type, arguments, name, addToContainer);
}
public object GetInstance(string name)
{
return serializationManager.GetInstance(name);
}
public Type GetType(string typeName)
{
return serializationManager.GetType(typeName);
}
/// <summary>
/// Gets the property descriptor associated with the event.
/// </summary>
public PropertyDescriptor GetEventProperty(EventDescriptor e)
{
IEventBindingService eventBindingService = GetService(typeof(IEventBindingService)) as IEventBindingService;
return eventBindingService.GetEventProperty(e);
}
public IResourceReader GetResourceReader(CultureInfo info)
{
if (GetResourceService()) {
return resourceService.GetResourceReader(info);
}
return null;
}
bool GetResourceService()
{
resourceService = (IResourceService)LoaderHost.GetService(typeof(IResourceService));
return resourceService != null;
}
public IResourceWriter GetResourceWriter(CultureInfo info)
{
if (GetResourceService()) {
return resourceService.GetResourceWriter(info);
}
return null;
}
/// <summary>
/// Passes the designer host's root component to the generator so it can update the
/// source code with changes made at design time.
/// </summary>
protected override void PerformFlush(IDesignerSerializationManager serializationManager)
{
generator.MergeRootComponentChanges(LoaderHost, serializationManager);
}
protected override void PerformLoad(IDesignerSerializationManager serializationManager)
{
this.serializationManager = serializationManager;
CreateComponents();
}
void CreateComponents()
{
IComponentWalker walker = CreateComponentWalker(this);
walker.CreateComponent(generator.ViewContent.DesignerCodeFileContent);
}
protected virtual IComponentWalker CreateComponentWalker(IComponentCreator componentCreator)
{
return null;
}
protected override void ReportFlushErrors(ICollection errors)
{
StringBuilder sb = new StringBuilder(StringParser.Parse("${res:ICSharpCode.SharpDevelop.FormDesigner.ReportFlushErrors}") + Environment.NewLine + Environment.NewLine);
foreach (var error in errors) {
sb.AppendLine(error.ToString());
sb.AppendLine();
}
MessageService.ShowError(sb.ToString());
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.ComponentModel;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//using System.Globalization;
//using System.Resources;
//using System.Security.Permissions;
//using System.Text;
//
//using ICSharpCode.Core;
//using ICSharpCode.FormsDesigner.Services;
//
//namespace ICSharpCode.Scripting
//{
// /// <summary>
// /// Loads the form or control's code so the forms designer can
// /// display it.
// /// </summary>
// [PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")]
// [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
// public class ScriptingDesignerLoader : BasicDesignerLoader, IComponentCreator
// {
// IScriptingDesignerGenerator generator;
// IDesignerSerializationManager serializationManager;
// IResourceService resourceService;
// Dictionary<string, IComponent> addedObjects = new Dictionary<string, IComponent>();
//
// public ScriptingDesignerLoader(IScriptingDesignerGenerator generator)
// {
// if (generator == null) {
// throw new ArgumentException("Generator cannot be null.", "generator");
// }
// this.generator = generator;
// }
//
// public override void BeginLoad(IDesignerLoaderHost host)
// {
// AddServices(host);
// SetDesignerSupportsProjectResourcesToFalse(host);
// base.BeginLoad(host);
// }
//
// void AddServices(IDesignerLoaderHost host)
// {
// host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
// host.AddService(typeof(INameCreationService), new ScriptingNameCreationService(host));
// host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host));
// }
//
// void SetDesignerSupportsProjectResourcesToFalse(IDesignerLoaderHost host)
// {
// ProjectResourceService projectResourceService = host.GetService(typeof(ProjectResourceService)) as ProjectResourceService;
// if (projectResourceService != null) {
// projectResourceService.DesignerSupportsProjectResources = false;
// }
// }
//
// public IComponent CreateComponent(Type componentClass, string name)
// {
// return base.LoaderHost.CreateComponent(componentClass, name);
// }
//
// public void Add(IComponent component, string name)
// {
// base.LoaderHost.Container.Add(component, name);
// }
//
// /// <summary>
// /// Gets a component that has been added to the loader.
// /// </summary>
// /// <returns>Null if the component cannot be found.</returns>
// public IComponent GetComponent(string name)
// {
// return LoaderHost.Container.Components[name];
// }
//
// public IComponent RootComponent {
// get { return base.LoaderHost.RootComponent; }
// }
//
// public object CreateInstance(Type type, ICollection arguments, string name, bool addToContainer)
// {
// return serializationManager.CreateInstance(type, arguments, name, addToContainer);
// }
//
// public object GetInstance(string name)
// {
// return serializationManager.GetInstance(name);
// }
//
// public Type GetType(string typeName)
// {
// return serializationManager.GetType(typeName);
// }
//
// /// <summary>
// /// Gets the property descriptor associated with the event.
// /// </summary>
// public PropertyDescriptor GetEventProperty(EventDescriptor e)
// {
// IEventBindingService eventBindingService = GetService(typeof(IEventBindingService)) as IEventBindingService;
// return eventBindingService.GetEventProperty(e);
// }
//
// public IResourceReader GetResourceReader(CultureInfo info)
// {
// if (GetResourceService()) {
// return resourceService.GetResourceReader(info);
// }
// return null;
// }
//
// bool GetResourceService()
// {
// resourceService = (IResourceService)LoaderHost.GetService(typeof(IResourceService));
// return resourceService != null;
// }
//
// public IResourceWriter GetResourceWriter(CultureInfo info)
// {
// if (GetResourceService()) {
// return resourceService.GetResourceWriter(info);
// }
// return null;
// }
//
// /// <summary>
// /// Passes the designer host's root component to the generator so it can update the
// /// source code with changes made at design time.
// /// </summary>
// protected override void PerformFlush(IDesignerSerializationManager serializationManager)
// {
// generator.MergeRootComponentChanges(LoaderHost, serializationManager);
// }
//
// protected override void PerformLoad(IDesignerSerializationManager serializationManager)
// {
// this.serializationManager = serializationManager;
// CreateComponents();
// }
//
// void CreateComponents()
// {
// IComponentWalker walker = CreateComponentWalker(this);
// walker.CreateComponent(generator.ViewContent.DesignerCodeFileContent);
// }
//
// protected virtual IComponentWalker CreateComponentWalker(IComponentCreator componentCreator)
// {
// return null;
// }
//
// protected override void ReportFlushErrors(ICollection errors)
// {
// StringBuilder sb = new StringBuilder(StringParser.Parse("${res:ICSharpCode.SharpDevelop.FormDesigner.ReportFlushErrors}") + Environment.NewLine + Environment.NewLine);
// foreach (var error in errors) {
// sb.AppendLine(error.ToString());
// sb.AppendLine();
// }
// MessageService.ShowError(sb.ToString());
// }
// }
//}

1
src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingFormattingStrategy.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.Scripting

94
src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingNameCreationService.cs

@ -1,47 +1,47 @@ @@ -1,47 +1,47 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using ICSharpCode.FormsDesigner;
namespace ICSharpCode.Scripting
{
public class ScriptingNameCreationService : INameCreationService
{
IDesignerHost host;
XmlDesignerNameCreationService nameCreationService;
public ScriptingNameCreationService(IDesignerHost host)
{
this.host = host;
nameCreationService = new XmlDesignerNameCreationService(host);
}
public string CreateName(IContainer container, Type dataType)
{
return nameCreationService.CreateName(container, dataType);
}
public bool IsValidName(string name)
{
if (!nameCreationService.IsValidName(name)) {
return false;
}
if (host.Container != null) {
return host.Container.Components[name] == null;
}
return true;
}
public void ValidateName(string name)
{
if (!IsValidName(name)) {
throw new Exception("Invalid name " + name);
}
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.ComponentModel;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//using ICSharpCode.FormsDesigner;
//
//namespace ICSharpCode.Scripting
//{
// public class ScriptingNameCreationService : INameCreationService
// {
// IDesignerHost host;
// XmlDesignerNameCreationService nameCreationService;
//
// public ScriptingNameCreationService(IDesignerHost host)
// {
// this.host = host;
// nameCreationService = new XmlDesignerNameCreationService(host);
// }
//
// public string CreateName(IContainer container, Type dataType)
// {
// return nameCreationService.CreateName(container, dataType);
// }
//
// public bool IsValidName(string name)
// {
// if (!nameCreationService.IsValidName(name)) {
// return false;
// }
//
// if (host.Container != null) {
// return host.Container.Components[name] == null;
// }
// return true;
// }
//
// public void ValidateName(string name)
// {
// if (!IsValidName(name)) {
// throw new Exception("Invalid name " + name);
// }
// }
// }
//}

5
src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingTextEditorViewContent.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
@ -12,7 +13,6 @@ namespace ICSharpCode.Scripting @@ -12,7 +13,6 @@ namespace ICSharpCode.Scripting
{
IViewContent view;
IEditable editable;
ITextEditorProvider textEditorProvider;
ITextEditor textEditor;
ITextEditorOptions textEditorOptions;
@ -30,8 +30,7 @@ namespace ICSharpCode.Scripting @@ -30,8 +30,7 @@ namespace ICSharpCode.Scripting
{
this.view = view;
editable = view as IEditable;
textEditorProvider = view as ITextEditorProvider;
textEditor = textEditorProvider.TextEditor;
textEditor = view.GetService(typeof(ITextEditor)) as ITextEditor;
textEditorOptions = textEditor.Options;
}

5
src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingWorkbench.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Scripting
{
@ -15,8 +16,8 @@ namespace ICSharpCode.Scripting @@ -15,8 +16,8 @@ namespace ICSharpCode.Scripting
public ScriptingWorkbench(Type consolePadType)
{
this.consolePadType = consolePadType;
workbench = WorkbenchSingleton.Workbench;
}
workbench = SD.Workbench;
}
public IViewContent ActiveViewContent {
get { return workbench.ActiveViewContent; }

6
src/AddIns/BackendBindings/Scripting/Project/Src/SendLineToScriptingConsoleCommand.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.Scripting
{
@ -26,8 +26,8 @@ namespace ICSharpCode.Scripting @@ -26,8 +26,8 @@ namespace ICSharpCode.Scripting
void GetLineFromActiveTextEditor()
{
int lineNumber = activeTextEditor.Caret.Line;
IDocumentLine documentLine = activeTextEditor.Document.GetLine(lineNumber);
lineFromActiveTextEditor = documentLine.Text;
IDocumentLine documentLine = activeTextEditor.Document.GetLineByNumber(lineNumber);
lineFromActiveTextEditor = activeTextEditor.Document.GetText(documentLine);
}
void AppendLineToScriptingConsole()

3
src/AddIns/BackendBindings/Scripting/Project/Src/TextEditorFactory.cs

@ -5,6 +5,7 @@ using System; @@ -5,6 +5,7 @@ using System;
using System.Windows.Media;
using ICSharpCode.AvalonEdit;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.Scripting
@ -14,7 +15,7 @@ namespace ICSharpCode.Scripting @@ -14,7 +15,7 @@ namespace ICSharpCode.Scripting
public static TextEditor CreateTextEditor()
{
object control;
EditorControlService.CreateEditor(out control);
SD.EditorControlService.CreateEditor(out control);
var textEditor = (TextEditor)control;
textEditor.Options = new TextEditorOptions();

88
src/AddIns/BackendBindings/Scripting/Test/Designer/CallBeginInitOnLoadTests.cs

@ -1,44 +1,44 @@ @@ -1,44 +1,44 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.Scripting.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Designer
{
public abstract class CallBeginInitOnLoadTestsBase : LoadFormTestsBase
{
public SupportInitCustomControl Control {
get { return Form.Controls[0] as SupportInitCustomControl; }
}
public SupportInitCustomControl LocalControl {
get { return base.ComponentCreator.GetInstance("localVariable") as SupportInitCustomControl; }
}
[Test]
public void BeginInitCalled()
{
Assert.IsTrue(Control.IsBeginInitCalled);
}
[Test]
public void EndInitCalled()
{
Assert.IsTrue(Control.IsEndInitCalled);
}
[Test]
public void BeginInitCalledOnLocalVariable()
{
Assert.IsTrue(LocalControl.IsBeginInitCalled);
}
[Test]
public void EndInitCalledOnLocalVariable()
{
Assert.IsTrue(LocalControl.IsEndInitCalled);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.Scripting.Tests.Utils;
//using NUnit.Framework;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// public abstract class CallBeginInitOnLoadTestsBase : LoadFormTestsBase
// {
// public SupportInitCustomControl Control {
// get { return Form.Controls[0] as SupportInitCustomControl; }
// }
//
// public SupportInitCustomControl LocalControl {
// get { return base.ComponentCreator.GetInstance("localVariable") as SupportInitCustomControl; }
// }
//
// [Test]
// public void BeginInitCalled()
// {
// Assert.IsTrue(Control.IsBeginInitCalled);
// }
//
// [Test]
// public void EndInitCalled()
// {
// Assert.IsTrue(Control.IsEndInitCalled);
// }
//
// [Test]
// public void BeginInitCalledOnLocalVariable()
// {
// Assert.IsTrue(LocalControl.IsBeginInitCalled);
// }
//
// [Test]
// public void EndInitCalledOnLocalVariable()
// {
// Assert.IsTrue(LocalControl.IsEndInitCalled);
// }
// }
//}

102
src/AddIns/BackendBindings/Scripting/Test/Designer/GenerateAcceptButtonFormTestsBase.cs

@ -1,51 +1,51 @@ @@ -1,51 +1,51 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
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.Scripting;
using ICSharpCode.Scripting.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Designer
{
public abstract class GenerateAcceptButtonFormTestsBase : GenerateDesignerCodeTestsBase
{
[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);
Button button = (Button)host.CreateComponent(typeof(Button), "button1");
button.Location = new Point(0, 0);
button.Size = new Size(10, 10);
button.Text = "button1";
button.UseCompatibleTextRendering = false;
form.Controls.Add(button);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor acceptButtonPropertyDescriptor = descriptors.Find("AcceptButton", false);
acceptButtonPropertyDescriptor.SetValue(form, button);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
IScriptingCodeDomSerializer serializer = CreateSerializer();
generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
}
}
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//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.Scripting;
//using ICSharpCode.Scripting.Tests.Utils;
//using NUnit.Framework;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// public abstract class GenerateAcceptButtonFormTestsBase : GenerateDesignerCodeTestsBase
// {
// [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);
//
// Button button = (Button)host.CreateComponent(typeof(Button), "button1");
// button.Location = new Point(0, 0);
// button.Size = new Size(10, 10);
// button.Text = "button1";
// button.UseCompatibleTextRendering = false;
// form.Controls.Add(button);
//
// PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
// PropertyDescriptor acceptButtonPropertyDescriptor = descriptors.Find("AcceptButton", false);
// acceptButtonPropertyDescriptor.SetValue(form, button);
//
// PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
// namePropertyDescriptor.SetValue(form, "MainForm");
//
// DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
// using (serializationManager.CreateSession()) {
// IScriptingCodeDomSerializer serializer = CreateSerializer();
// generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
// }
// }
// }
// }
//}

28
src/AddIns/BackendBindings/Scripting/Test/Designer/GenerateDesignerCodeTestsBase.cs

@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.Scripting.Tests.Designer
{
public abstract class GenerateDesignerCodeTestsBase
{
protected string generatedCode;
protected abstract IScriptingCodeDomSerializer CreateSerializer();
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// public abstract class GenerateDesignerCodeTestsBase
// {
// protected string generatedCode;
//
// protected abstract IScriptingCodeDomSerializer CreateSerializer();
// }
//}

84
src/AddIns/BackendBindings/Scripting/Test/Designer/GenerateEnabledUsingPropertyDescriptorTestsBase.cs

@ -1,42 +1,42 @@ @@ -1,42 +1,42 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Scripting;
using NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Designer
{
public abstract class GenerateEnabledUsingPropertyDescriptorTestsBase : GenerateDesignerCodeTestsBase
{
[TestFixtureSetUp]
public void SetUpFixture()
{
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
form.AllowDrop = false;
form.Enabled = false;
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
PropertyDescriptor enabledPropertyDescriptor = descriptors.Find("Enabled", false);
enabledPropertyDescriptor.SetValue(form, false);
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
IScriptingCodeDomSerializer serializer = CreateSerializer();
generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
}
}
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.ComponentModel;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//using System.Drawing;
//using System.Windows.Forms;
//using ICSharpCode.Scripting;
//using NUnit.Framework;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// public abstract class GenerateEnabledUsingPropertyDescriptorTestsBase : GenerateDesignerCodeTestsBase
// {
// [TestFixtureSetUp]
// public void SetUpFixture()
// {
// using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
// IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
// Form form = (Form)host.RootComponent;
// form.ClientSize = new Size(284, 264);
// form.AllowDrop = false;
// form.Enabled = false;
//
// PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
// PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
// namePropertyDescriptor.SetValue(form, "MainForm");
//
// PropertyDescriptor enabledPropertyDescriptor = descriptors.Find("Enabled", false);
// enabledPropertyDescriptor.SetValue(form, false);
//
// DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
// using (serializationManager.CreateSession()) {
// IScriptingCodeDomSerializer serializer = CreateSerializer();
// generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
// }
// }
// }
// }
//}

90
src/AddIns/BackendBindings/Scripting/Test/Designer/GenerateUserControlWithNullPropertyValueTestsBase.cs

@ -1,45 +1,45 @@ @@ -1,45 +1,45 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Scripting;
using ICSharpCode.Scripting.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Designer
{
public abstract class GenerateUserControlWithNullPropertyValueTestsBase : GenerateDesignerCodeTestsBase
{
[TestFixtureSetUp]
public void SetUpFixture()
{
using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
UserControl userControl = (UserControl)host.RootComponent;
userControl.ClientSize = new Size(200, 300);
NullPropertyUserControl control = (NullPropertyUserControl)host.CreateComponent(typeof(NullPropertyUserControl), "userControl1");
control.Location = new Point(0, 0);
control.Size = new Size(10, 10);
userControl.Controls.Add(control);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(userControl);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(userControl, "MainControl");
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
IScriptingCodeDomSerializer serializer = CreateSerializer();
generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
}
}
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.ComponentModel;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//using System.Drawing;
//using System.Windows.Forms;
//
//using ICSharpCode.Scripting;
//using ICSharpCode.Scripting.Tests.Utils;
//using NUnit.Framework;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// public abstract class GenerateUserControlWithNullPropertyValueTestsBase : GenerateDesignerCodeTestsBase
// {
// [TestFixtureSetUp]
// public void SetUpFixture()
// {
// using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
// IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
// IEventBindingService eventBindingService = new MockEventBindingService(host);
// UserControl userControl = (UserControl)host.RootComponent;
// userControl.ClientSize = new Size(200, 300);
//
// NullPropertyUserControl control = (NullPropertyUserControl)host.CreateComponent(typeof(NullPropertyUserControl), "userControl1");
// control.Location = new Point(0, 0);
// control.Size = new Size(10, 10);
// userControl.Controls.Add(control);
//
// PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(userControl);
// PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
// namePropertyDescriptor.SetValue(userControl, "MainControl");
//
// DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
// using (serializationManager.CreateSession()) {
// IScriptingCodeDomSerializer serializer = CreateSerializer();
// generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
// }
// }
// }
// }
//}

120
src/AddIns/BackendBindings/Scripting/Test/Designer/LoadFormTestsBase.cs

@ -1,60 +1,60 @@ @@ -1,60 +1,60 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Scripting;
using ICSharpCode.Scripting.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Designer
{
public abstract class LoadFormTestsBase
{
MockComponentCreator componentCreator = new MockComponentCreator();
Form form;
[TestFixtureSetUp]
public void SetUpFixture()
{
BeforeSetUpFixture();
IComponentWalker walker = CreateComponentWalker(componentCreator);
form = walker.CreateComponent(Code) as Form;
}
[TestFixtureTearDown]
public void TearDownFixture()
{
if (form != null) {
form.Dispose();
}
}
/// <summary>
/// Called at the start of SetUpFixture method before anything is setup.
/// </summary>
public virtual void BeforeSetUpFixture()
{
}
protected abstract IComponentWalker CreateComponentWalker(IComponentCreator componentCreator);
/// <summary>
/// Gets the code that will be loaded.
/// </summary>
public virtual string Code {
get { return String.Empty; }
}
protected MockComponentCreator ComponentCreator {
get { return componentCreator; }
}
protected Form Form {
get { return form; }
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Drawing;
//using System.Reflection;
//using System.Windows.Forms;
//
//using ICSharpCode.Scripting;
//using ICSharpCode.Scripting.Tests.Utils;
//using NUnit.Framework;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// public abstract class LoadFormTestsBase
// {
// MockComponentCreator componentCreator = new MockComponentCreator();
// Form form;
//
// [TestFixtureSetUp]
// public void SetUpFixture()
// {
// BeforeSetUpFixture();
// IComponentWalker walker = CreateComponentWalker(componentCreator);
// form = walker.CreateComponent(Code) as Form;
// }
//
// [TestFixtureTearDown]
// public void TearDownFixture()
// {
// if (form != null) {
// form.Dispose();
// }
// }
//
// /// <summary>
// /// Called at the start of SetUpFixture method before anything is setup.
// /// </summary>
// public virtual void BeforeSetUpFixture()
// {
// }
//
// protected abstract IComponentWalker CreateComponentWalker(IComponentCreator componentCreator);
//
// /// <summary>
// /// Gets the code that will be loaded.
// /// </summary>
// public virtual string Code {
// get { return String.Empty; }
// }
//
// protected MockComponentCreator ComponentCreator {
// get { return componentCreator; }
// }
//
// protected Form Form {
// get { return form; }
// }
// }
//}

204
src/AddIns/BackendBindings/Scripting/Test/Designer/NameCreationServiceTests.cs

@ -1,102 +1,102 @@ @@ -1,102 +1,102 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel.Design.Serialization;
using System.Windows.Forms;
using ICSharpCode.Scripting;
using ICSharpCode.Scripting.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Designer
{
[TestFixture]
public class NameCreationServiceTestFixture
{
ScriptingNameCreationService nameCreationService;
MockDesignerLoaderHost host;
[SetUp]
public void Init()
{
host = new MockDesignerLoaderHost();
host.Container.Add(new Button(), "button1");
nameCreationService = new ScriptingNameCreationService(host);
}
[Test]
public void IsValidNameReturnsFalseIfComponentInContainerAlreadyUsesName()
{
Assert.IsFalse(nameCreationService.IsValidName("button1"));
}
[Test]
public void IsValidNameReturnsTrueIfNameNotInUse()
{
Assert.IsTrue(nameCreationService.IsValidName("unknown"));
}
[Test]
public void NullReferenceNotThrownWhenHostContainerIsNull()
{
host.Container = null;
Assert.IsTrue(nameCreationService.IsValidName("button1"));
}
[Test]
public void CreateNameReturnsTypeNameFollowedByNumberOne()
{
Assert.AreEqual("button1", nameCreationService.CreateName(null, typeof(Button)));
}
[Test]
public void CreateNameReturnsTypeNameFollowedByNumberTwoIfNameExistsInContainer()
{
Assert.AreEqual("button2", nameCreationService.CreateName(host.Container, typeof(Button)));
}
[Test]
public void ValidateNameThrowsExceptionIfNameExistsInContainer()
{
Exception ex = Assert.Throws<Exception>(delegate { nameCreationService.ValidateName("button1"); });
Assert.AreEqual("Invalid name button1", ex.Message);
}
[Test]
public void ValidateNameDoesNotThrowExceptionIfNameDoesNotExistInContainer()
{
Assert.DoesNotThrow(delegate { nameCreationService.ValidateName("button2"); });
}
[Test]
public void IsValidReturnsFalseWhenNameIsNull()
{
Assert.IsFalse(nameCreationService.IsValidName(null));
}
[Test]
public void IsValidReturnsFalseWhenNameIsEmptyString()
{
Assert.IsFalse(nameCreationService.IsValidName(String.Empty));
}
[Test]
public void IsValidReturnsFalseWhenNameContainsNonLetterOrDigit()
{
Assert.IsFalse(nameCreationService.IsValidName("a%b"));
}
[Test]
public void IsValidReturnsFalseWhenFirstCharacterOfNameIsNumber()
{
Assert.IsFalse(nameCreationService.IsValidName("1abc"));
}
[Test]
public void IsValidReturnsTrueWhenFirstCharacterOfNameIsUnderscore()
{
Assert.IsTrue(nameCreationService.IsValidName("_abc"));
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.ComponentModel.Design.Serialization;
//using System.Windows.Forms;
//
//using ICSharpCode.Scripting;
//using ICSharpCode.Scripting.Tests.Utils;
//using NUnit.Framework;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// [TestFixture]
// public class NameCreationServiceTestFixture
// {
// ScriptingNameCreationService nameCreationService;
// MockDesignerLoaderHost host;
//
// [SetUp]
// public void Init()
// {
// host = new MockDesignerLoaderHost();
// host.Container.Add(new Button(), "button1");
// nameCreationService = new ScriptingNameCreationService(host);
// }
//
// [Test]
// public void IsValidNameReturnsFalseIfComponentInContainerAlreadyUsesName()
// {
// Assert.IsFalse(nameCreationService.IsValidName("button1"));
// }
//
// [Test]
// public void IsValidNameReturnsTrueIfNameNotInUse()
// {
// Assert.IsTrue(nameCreationService.IsValidName("unknown"));
// }
//
// [Test]
// public void NullReferenceNotThrownWhenHostContainerIsNull()
// {
// host.Container = null;
// Assert.IsTrue(nameCreationService.IsValidName("button1"));
// }
//
// [Test]
// public void CreateNameReturnsTypeNameFollowedByNumberOne()
// {
// Assert.AreEqual("button1", nameCreationService.CreateName(null, typeof(Button)));
// }
//
// [Test]
// public void CreateNameReturnsTypeNameFollowedByNumberTwoIfNameExistsInContainer()
// {
// Assert.AreEqual("button2", nameCreationService.CreateName(host.Container, typeof(Button)));
// }
//
// [Test]
// public void ValidateNameThrowsExceptionIfNameExistsInContainer()
// {
// Exception ex = Assert.Throws<Exception>(delegate { nameCreationService.ValidateName("button1"); });
// Assert.AreEqual("Invalid name button1", ex.Message);
// }
//
// [Test]
// public void ValidateNameDoesNotThrowExceptionIfNameDoesNotExistInContainer()
// {
// Assert.DoesNotThrow(delegate { nameCreationService.ValidateName("button2"); });
// }
//
// [Test]
// public void IsValidReturnsFalseWhenNameIsNull()
// {
// Assert.IsFalse(nameCreationService.IsValidName(null));
// }
//
// [Test]
// public void IsValidReturnsFalseWhenNameIsEmptyString()
// {
// Assert.IsFalse(nameCreationService.IsValidName(String.Empty));
// }
//
// [Test]
// public void IsValidReturnsFalseWhenNameContainsNonLetterOrDigit()
// {
// Assert.IsFalse(nameCreationService.IsValidName("a%b"));
// }
//
// [Test]
// public void IsValidReturnsFalseWhenFirstCharacterOfNameIsNumber()
// {
// Assert.IsFalse(nameCreationService.IsValidName("1abc"));
// }
//
// [Test]
// public void IsValidReturnsTrueWhenFirstCharacterOfNameIsUnderscore()
// {
// Assert.IsTrue(nameCreationService.IsValidName("_abc"));
// }
// }
//}

492
src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerGeneratorTests.cs

@ -1,246 +1,246 @@ @@ -1,246 +1,246 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.Collections.Generic;
using ICSharpCode.FormsDesigner;
using ICSharpCode.Scripting;
using ICSharpCode.Scripting.Tests.Utils;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using UnitTesting.Tests.Utils;
namespace ICSharpCode.Scripting.Tests.Designer
{
[TestFixture]
[RequiresSTA]
public class ScriptingDesignerGeneratorTests
{
MockTextEditorOptions textEditorOptions;
TestableScriptingDesignerGenerator generator;
FormsDesignerViewContent formsDesignerView;
MockTextEditorViewContent textEditorViewContent;
MockOpenedFile formsDesignerOpenedFile;
MockDesignerLoaderHost host;
FakeDesignerSerializationManager serializationManager;
FakeCodeDomSerializer serializer;
MockMethod method;
[Test]
public void GetSourceFiles_FormDesignerViewHasOpenFile_ReturnsOneFile()
{
CreateDesignerGenerator();
OpenedFile designerOpenedFile;
IEnumerable<OpenedFile> files = generator.GetSourceFiles(out designerOpenedFile);
int count = HowManyInCollection(files);
Assert.AreEqual(1, count);
}
void CreateDesignerGenerator()
{
textEditorViewContent = new MockTextEditorViewContent();
formsDesignerOpenedFile = new MockOpenedFile("test.py");
textEditorViewContent.PrimaryFile = formsDesignerOpenedFile;
formsDesignerView = new FormsDesignerViewContent(textEditorViewContent, formsDesignerOpenedFile);
textEditorOptions = new MockTextEditorOptions();
generator = new TestableScriptingDesignerGenerator(textEditorOptions);
generator.Attach(formsDesignerView);
generator.ParseInfoToReturnFromParseFile = generator.CreateParseInfoWithOneClass();
}
int HowManyInCollection(IEnumerable<OpenedFile> files)
{
int count = 0;
foreach (OpenedFile file in files) {
count++;
}
return count;
}
[Test]
public void GetSourceFiles_FormsDesignerHasOpenFile_DesignerOpenedFileParameterIsSetToFormsDesignerViewOpenedFile()
{
CreateDesignerGenerator();
OpenedFile designerOpenedFile;
generator.GetSourceFiles(out designerOpenedFile);
AssertAreEqual(formsDesignerOpenedFile, designerOpenedFile);
}
void AssertAreEqual(OpenedFile expectedOpenedFile, OpenedFile actualOpenedFile)
{
string fileName = actualOpenedFile.FileName.ToString();
string expectedFileName = expectedOpenedFile.FileName.ToString();
Assert.AreEqual(expectedFileName, fileName);
}
[Test]
public void GetSourceFiles_FormsDesignerHasOpenFile_FormsDesignerFileReturnedInFiles()
{
CreateDesignerGenerator();
OpenedFile designerOpenedFile;
IEnumerable<OpenedFile> files = generator.GetSourceFiles(out designerOpenedFile);
IEnumerator<OpenedFile> enumerator = files.GetEnumerator();
enumerator.MoveNext();
OpenedFile file = enumerator.Current;
AssertAreEqual(formsDesignerOpenedFile, file);
}
[Test]
public void GetCompatibleMethods_OneClassMethod_CallsParseFile()
{
CreateDesignerGenerator();
CallGetCompatibleMethods();
Assert.IsTrue(generator.IsParseFileCalled);
}
ICollection CallGetCompatibleMethods()
{
MockEventDescriptor descriptor = new MockEventDescriptor("Click");
return generator.GetCompatibleMethods(descriptor);
}
[Test]
public void GetCompatibleMethods_OneClassMethod_ParseFilePassedFileNameOpenInTextEditor()
{
CreateDesignerGenerator();
CallGetCompatibleMethods();
string fileName = generator.FileNamePassedToParseFile;
string expectedFileName = "test.py";
Assert.AreEqual(expectedFileName, fileName);
}
[Test]
public void GetCompatibleMethods_OneClassMethod_ParseFilePassedTextContentInTextEditor()
{
CreateDesignerGenerator();
formsDesignerView.DesignerCodeFileContent = "code";
CallGetCompatibleMethods();
string textContent = generator.TextContentPassedToParseFile;
string expectedTextContent = "code";
Assert.AreEqual(expectedTextContent, textContent);
}
[Test]
public void GetCompatibleMethods_OneMethodWithTwoParameters_MethodNameReturnedInCompatibleMethods()
{
CreateDesignerGenerator();
ParseInformation parseInfo = generator.CreateParseInfoWithOneMethodWithTwoParameters("button1_click");
generator.ParseInfoToReturnFromParseFile = parseInfo;
ICollection methods = CallGetCompatibleMethods();
string[] expectedMethods = new string[] { "button1_click" };
Assert.AreEqual(expectedMethods, methods);
}
[Test]
public void GetCompatibleMethods_OneMethodWithNoParameters_NoMethodsReturnedInCompatibleMethods()
{
CreateDesignerGenerator();
ParseInformation parseInfo = generator.CreateParseInfoWithOneMethod("button1_click");
generator.ParseInfoToReturnFromParseFile = parseInfo;
ICollection methods = CallGetCompatibleMethods();
Assert.AreEqual(0, methods.Count);
}
[Test]
public void Detach_FormsDesignerViewAlreadyAttached_SetsViewContentToNull()
{
CreateDesignerGenerator();
generator.Detach();
Assert.IsNull(generator.ViewContent);
}
[Test]
public void GenerateMethodBody_PassedDesignerHost_DesignerHostPassedToCodeDomSerializer()
{
CreateDesignerGenerator();
CreateParametersForGenerateMethodBodyCall();
CallGenerateMethodBody();
Assert.AreEqual(host, serializer.HostPassedToGenerateInitializeComponentMethodBody);
}
void CreateParametersForGenerateMethodBodyCall()
{
serializer = new FakeCodeDomSerializer();
generator.SerializerToReturnFromCreateCodeDomSerializer = serializer;
method = MockMethod.CreateMockMethodWithoutAnyAttributes();
host = new MockDesignerLoaderHost();
serializationManager = new FakeDesignerSerializationManager();
}
string CallGenerateMethodBody()
{
return generator.GenerateMethodBody(method, host, serializationManager);
}
[Test]
public void GenerateMethodBody_MethodBodyCreated_ReturnsMethodBodyFromCodeDomSerializer()
{
CreateDesignerGenerator();
CreateParametersForGenerateMethodBodyCall();
serializer.MethodBodyToReturnFromGenerateMethodBodyCall = "test";
string methodBody = CallGenerateMethodBody();
string expectedMethodBody = "test";
Assert.AreEqual(expectedMethodBody, methodBody);
}
[Test]
public void GenerateMethodBody_PassedDesignerSerializationManager_DesignerSerializationManagerPassedToCodeDomSerializer()
{
CreateDesignerGenerator();
CreateParametersForGenerateMethodBodyCall();
CallGenerateMethodBody();
Assert.AreEqual(serializationManager, serializer.SerializationManagerGenerateInitializeComponentMethodBody);
}
[Test]
public void GenerateMethodBody_TextEditorOptionsConvertTabsToSpacesIsFalse_MethodBeginColumnIsIndentPassedToGenerateMethodBody()
{
CreateDesignerGenerator();
CreateParametersForGenerateMethodBodyCall();
int beginLine = 1;
int beginColumn = 3;
int endLine = 2;
int endColumn = 1;
method.Region = new DomRegion(beginLine, beginColumn, endLine, endColumn);
textEditorOptions.ConvertTabsToSpaces = false;
CallGenerateMethodBody();
int expectedIndent = 3;
Assert.AreEqual(expectedIndent, serializer.InitialIndentPassedToGenerateInitializeComponentMethodBody);
}
[Test]
public void GenerateMethodBody_ProjectHasRootNamespace_RootNamespacePassedToCodeDomSerializer()
{
CreateDesignerGenerator();
CreateParametersForGenerateMethodBodyCall();
method.MockDeclaringType.MockProjectContent.ProjectAsIProject.RootNamespace = "Test";
CallGenerateMethodBody();
string expectedRootNamespace = "Test";
Assert.AreEqual(expectedRootNamespace, serializer.RootNamespacePassedToGenerateInitializeComponentMethodBody);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using ICSharpCode.FormsDesigner;
//using ICSharpCode.Scripting;
//using ICSharpCode.Scripting.Tests.Utils;
//using ICSharpCode.SharpDevelop;
//using ICSharpCode.SharpDevelop.Dom;
//using NUnit.Framework;
//using UnitTesting.Tests.Utils;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// [TestFixture]
// [RequiresSTA]
// public class ScriptingDesignerGeneratorTests
// {
// MockTextEditorOptions textEditorOptions;
// TestableScriptingDesignerGenerator generator;
// FormsDesignerViewContent formsDesignerView;
// MockTextEditorViewContent textEditorViewContent;
// MockOpenedFile formsDesignerOpenedFile;
// MockDesignerLoaderHost host;
// FakeDesignerSerializationManager serializationManager;
// FakeCodeDomSerializer serializer;
// MockMethod method;
//
// [Test]
// public void GetSourceFiles_FormDesignerViewHasOpenFile_ReturnsOneFile()
// {
// CreateDesignerGenerator();
// OpenedFile designerOpenedFile;
// IEnumerable<OpenedFile> files = generator.GetSourceFiles(out designerOpenedFile);
// int count = HowManyInCollection(files);
//
// Assert.AreEqual(1, count);
// }
//
// void CreateDesignerGenerator()
// {
// textEditorViewContent = new MockTextEditorViewContent();
// formsDesignerOpenedFile = new MockOpenedFile("test.py");
// textEditorViewContent.PrimaryFile = formsDesignerOpenedFile;
// formsDesignerView = new FormsDesignerViewContent(textEditorViewContent, formsDesignerOpenedFile);
// textEditorOptions = new MockTextEditorOptions();
// generator = new TestableScriptingDesignerGenerator(textEditorOptions);
// generator.Attach(formsDesignerView);
// generator.ParseInfoToReturnFromParseFile = generator.CreateParseInfoWithOneClass();
// }
//
// int HowManyInCollection(IEnumerable<OpenedFile> files)
// {
// int count = 0;
// foreach (OpenedFile file in files) {
// count++;
// }
// return count;
// }
//
// [Test]
// public void GetSourceFiles_FormsDesignerHasOpenFile_DesignerOpenedFileParameterIsSetToFormsDesignerViewOpenedFile()
// {
// CreateDesignerGenerator();
// OpenedFile designerOpenedFile;
// generator.GetSourceFiles(out designerOpenedFile);
//
// AssertAreEqual(formsDesignerOpenedFile, designerOpenedFile);
// }
//
// void AssertAreEqual(OpenedFile expectedOpenedFile, OpenedFile actualOpenedFile)
// {
// string fileName = actualOpenedFile.FileName.ToString();
// string expectedFileName = expectedOpenedFile.FileName.ToString();
//
// Assert.AreEqual(expectedFileName, fileName);
// }
//
// [Test]
// public void GetSourceFiles_FormsDesignerHasOpenFile_FormsDesignerFileReturnedInFiles()
// {
// CreateDesignerGenerator();
// OpenedFile designerOpenedFile;
// IEnumerable<OpenedFile> files = generator.GetSourceFiles(out designerOpenedFile);
// IEnumerator<OpenedFile> enumerator = files.GetEnumerator();
// enumerator.MoveNext();
// OpenedFile file = enumerator.Current;
//
// AssertAreEqual(formsDesignerOpenedFile, file);
// }
//
// [Test]
// public void GetCompatibleMethods_OneClassMethod_CallsParseFile()
// {
// CreateDesignerGenerator();
// CallGetCompatibleMethods();
// Assert.IsTrue(generator.IsParseFileCalled);
// }
//
// ICollection CallGetCompatibleMethods()
// {
// MockEventDescriptor descriptor = new MockEventDescriptor("Click");
// return generator.GetCompatibleMethods(descriptor);
// }
//
// [Test]
// public void GetCompatibleMethods_OneClassMethod_ParseFilePassedFileNameOpenInTextEditor()
// {
// CreateDesignerGenerator();
// CallGetCompatibleMethods();
//
// string fileName = generator.FileNamePassedToParseFile;
// string expectedFileName = "test.py";
//
// Assert.AreEqual(expectedFileName, fileName);
// }
//
// [Test]
// public void GetCompatibleMethods_OneClassMethod_ParseFilePassedTextContentInTextEditor()
// {
// CreateDesignerGenerator();
// formsDesignerView.DesignerCodeFileContent = "code";
// CallGetCompatibleMethods();
//
// string textContent = generator.TextContentPassedToParseFile;
// string expectedTextContent = "code";
//
// Assert.AreEqual(expectedTextContent, textContent);
// }
//
// [Test]
// public void GetCompatibleMethods_OneMethodWithTwoParameters_MethodNameReturnedInCompatibleMethods()
// {
// CreateDesignerGenerator();
// ParseInformation parseInfo = generator.CreateParseInfoWithOneMethodWithTwoParameters("button1_click");
// generator.ParseInfoToReturnFromParseFile = parseInfo;
// ICollection methods = CallGetCompatibleMethods();
//
// string[] expectedMethods = new string[] { "button1_click" };
//
// Assert.AreEqual(expectedMethods, methods);
// }
//
// [Test]
// public void GetCompatibleMethods_OneMethodWithNoParameters_NoMethodsReturnedInCompatibleMethods()
// {
// CreateDesignerGenerator();
// ParseInformation parseInfo = generator.CreateParseInfoWithOneMethod("button1_click");
// generator.ParseInfoToReturnFromParseFile = parseInfo;
// ICollection methods = CallGetCompatibleMethods();
//
// Assert.AreEqual(0, methods.Count);
// }
//
// [Test]
// public void Detach_FormsDesignerViewAlreadyAttached_SetsViewContentToNull()
// {
// CreateDesignerGenerator();
// generator.Detach();
// Assert.IsNull(generator.ViewContent);
// }
//
// [Test]
// public void GenerateMethodBody_PassedDesignerHost_DesignerHostPassedToCodeDomSerializer()
// {
// CreateDesignerGenerator();
// CreateParametersForGenerateMethodBodyCall();
// CallGenerateMethodBody();
//
// Assert.AreEqual(host, serializer.HostPassedToGenerateInitializeComponentMethodBody);
// }
//
// void CreateParametersForGenerateMethodBodyCall()
// {
// serializer = new FakeCodeDomSerializer();
// generator.SerializerToReturnFromCreateCodeDomSerializer = serializer;
// method = MockMethod.CreateMockMethodWithoutAnyAttributes();
// host = new MockDesignerLoaderHost();
// serializationManager = new FakeDesignerSerializationManager();
// }
//
// string CallGenerateMethodBody()
// {
// return generator.GenerateMethodBody(method, host, serializationManager);
// }
//
// [Test]
// public void GenerateMethodBody_MethodBodyCreated_ReturnsMethodBodyFromCodeDomSerializer()
// {
// CreateDesignerGenerator();
// CreateParametersForGenerateMethodBodyCall();
// serializer.MethodBodyToReturnFromGenerateMethodBodyCall = "test";
// string methodBody = CallGenerateMethodBody();
//
// string expectedMethodBody = "test";
// Assert.AreEqual(expectedMethodBody, methodBody);
// }
//
// [Test]
// public void GenerateMethodBody_PassedDesignerSerializationManager_DesignerSerializationManagerPassedToCodeDomSerializer()
// {
// CreateDesignerGenerator();
// CreateParametersForGenerateMethodBodyCall();
// CallGenerateMethodBody();
//
// Assert.AreEqual(serializationManager, serializer.SerializationManagerGenerateInitializeComponentMethodBody);
// }
//
// [Test]
// public void GenerateMethodBody_TextEditorOptionsConvertTabsToSpacesIsFalse_MethodBeginColumnIsIndentPassedToGenerateMethodBody()
// {
// CreateDesignerGenerator();
// CreateParametersForGenerateMethodBodyCall();
//
// int beginLine = 1;
// int beginColumn = 3;
// int endLine = 2;
// int endColumn = 1;
// method.Region = new DomRegion(beginLine, beginColumn, endLine, endColumn);
//
// textEditorOptions.ConvertTabsToSpaces = false;
//
// CallGenerateMethodBody();
//
// int expectedIndent = 3;
//
// Assert.AreEqual(expectedIndent, serializer.InitialIndentPassedToGenerateInitializeComponentMethodBody);
// }
//
// [Test]
// public void GenerateMethodBody_ProjectHasRootNamespace_RootNamespacePassedToCodeDomSerializer()
// {
// CreateDesignerGenerator();
// CreateParametersForGenerateMethodBodyCall();
//
// method.MockDeclaringType.MockProjectContent.ProjectAsIProject.RootNamespace = "Test";
//
// CallGenerateMethodBody();
//
// string expectedRootNamespace = "Test";
// Assert.AreEqual(expectedRootNamespace, serializer.RootNamespacePassedToGenerateInitializeComponentMethodBody);
// }
// }
//}

254
src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerLoaderGetResourcesTests.cs

@ -1,127 +1,127 @@ @@ -1,127 +1,127 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Resources;
using System.Windows.Forms;
using ICSharpCode.Scripting;
using ICSharpCode.Scripting.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Designer
{
[TestFixture]
public class ScriptingDesignerLoaderGetResourcesTests
{
ScriptingDesignerLoader loader;
MockDesignerLoaderHost host;
MockResourceService resourceService;
MockResourceReader fakeReader;
MockResourceWriter fakeWriter;
MockResourceWriter writer;
MockResourceReader reader;
[Test]
public void GetResourceReader_PassedInvariantCulture_ReturnsReaderFromResourceService()
{
BeginLoad();
GetResourceReader();
Assert.AreEqual(fakeReader, reader);
}
void BeginLoad()
{
CreateResourceService();
CreateDesignerLoaderHost();
host.AddService(typeof(IResourceService), resourceService);
BeginLoad(host);
}
void CreateResourceService()
{
fakeReader = new MockResourceReader();
fakeWriter = new MockResourceWriter();
resourceService = new MockResourceService();
resourceService.SetResourceReader(fakeReader);
resourceService.SetResourceWriter(fakeWriter);
}
void CreateDesignerLoaderHost()
{
host = new MockDesignerLoaderHost();
}
void BeginLoad(IDesignerLoaderHost host)
{
loader = new ScriptingDesignerLoader(new MockDesignerGenerator());
loader.BeginLoad(host);
}
void BeginLoadWithoutResourceService()
{
CreateDesignerLoaderHost();
BeginLoad(host);
}
void GetResourceReader()
{
reader = loader.GetResourceReader(CultureInfo.InvariantCulture) as MockResourceReader;
}
void GetResourceWriter()
{
writer = loader.GetResourceWriter(CultureInfo.InvariantCulture) as MockResourceWriter;
}
[Test]
public void GetResourceReader_PassedInvariantCulture_CultureInfoPassedToResourceServiceForReader()
{
BeginLoad();
GetResourceReader();
CultureInfo culture = resourceService.CultureInfoPassedToGetResourceReader;
CultureInfo expectedCulture = CultureInfo.InvariantCulture;
Assert.AreEqual(expectedCulture, culture);
}
[Test]
public void GetResourceReader_NoResourceService_ReturnsNull()
{
BeginLoadWithoutResourceService();
GetResourceReader();
Assert.IsNull(reader);
}
[Test]
public void GetResourceWriter_PassedInvariantCulture_ReturnsWriterFromResourceService()
{
BeginLoad();
GetResourceWriter();
Assert.AreEqual(fakeWriter, writer);
}
[Test]
public void GetResourceWriter_PassedInvariantCulture_CultureInfoPassedToResourceServiceForWriter()
{
BeginLoad();
GetResourceWriter();
CultureInfo culture = resourceService.CultureInfoPassedToGetResourceWriter;
CultureInfo expectedCulture = CultureInfo.InvariantCulture;
Assert.AreEqual(expectedCulture, culture);
}
[Test]
public void GetResourceWriter_NoResourceService_ReturnsNull()
{
BeginLoadWithoutResourceService();
GetResourceWriter();
Assert.IsNull(writer);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.ComponentModel;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//using System.Globalization;
//using System.Resources;
//using System.Windows.Forms;
//
//using ICSharpCode.Scripting;
//using ICSharpCode.Scripting.Tests.Utils;
//using NUnit.Framework;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// [TestFixture]
// public class ScriptingDesignerLoaderGetResourcesTests
// {
// ScriptingDesignerLoader loader;
// MockDesignerLoaderHost host;
// MockResourceService resourceService;
// MockResourceReader fakeReader;
// MockResourceWriter fakeWriter;
// MockResourceWriter writer;
// MockResourceReader reader;
//
// [Test]
// public void GetResourceReader_PassedInvariantCulture_ReturnsReaderFromResourceService()
// {
// BeginLoad();
// GetResourceReader();
// Assert.AreEqual(fakeReader, reader);
// }
//
// void BeginLoad()
// {
// CreateResourceService();
// CreateDesignerLoaderHost();
//
// host.AddService(typeof(IResourceService), resourceService);
//
// BeginLoad(host);
// }
//
// void CreateResourceService()
// {
// fakeReader = new MockResourceReader();
// fakeWriter = new MockResourceWriter();
// resourceService = new MockResourceService();
// resourceService.SetResourceReader(fakeReader);
// resourceService.SetResourceWriter(fakeWriter);
// }
//
// void CreateDesignerLoaderHost()
// {
// host = new MockDesignerLoaderHost();
// }
//
// void BeginLoad(IDesignerLoaderHost host)
// {
// loader = new ScriptingDesignerLoader(new MockDesignerGenerator());
// loader.BeginLoad(host);
// }
//
// void BeginLoadWithoutResourceService()
// {
// CreateDesignerLoaderHost();
// BeginLoad(host);
// }
//
// void GetResourceReader()
// {
// reader = loader.GetResourceReader(CultureInfo.InvariantCulture) as MockResourceReader;
// }
//
// void GetResourceWriter()
// {
// writer = loader.GetResourceWriter(CultureInfo.InvariantCulture) as MockResourceWriter;
// }
//
// [Test]
// public void GetResourceReader_PassedInvariantCulture_CultureInfoPassedToResourceServiceForReader()
// {
// BeginLoad();
// GetResourceReader();
// CultureInfo culture = resourceService.CultureInfoPassedToGetResourceReader;
// CultureInfo expectedCulture = CultureInfo.InvariantCulture;
// Assert.AreEqual(expectedCulture, culture);
// }
//
// [Test]
// public void GetResourceReader_NoResourceService_ReturnsNull()
// {
// BeginLoadWithoutResourceService();
// GetResourceReader();
// Assert.IsNull(reader);
// }
//
// [Test]
// public void GetResourceWriter_PassedInvariantCulture_ReturnsWriterFromResourceService()
// {
// BeginLoad();
// GetResourceWriter();
// Assert.AreEqual(fakeWriter, writer);
// }
//
// [Test]
// public void GetResourceWriter_PassedInvariantCulture_CultureInfoPassedToResourceServiceForWriter()
// {
// BeginLoad();
// GetResourceWriter();
// CultureInfo culture = resourceService.CultureInfoPassedToGetResourceWriter;
// CultureInfo expectedCulture = CultureInfo.InvariantCulture;
// Assert.AreEqual(expectedCulture, culture);
// }
//
// [Test]
// public void GetResourceWriter_NoResourceService_ReturnsNull()
// {
// BeginLoadWithoutResourceService();
// GetResourceWriter();
// Assert.IsNull(writer);
// }
// }
//}

800
src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerLoaderTests.cs

@ -1,400 +1,400 @@ @@ -1,400 +1,400 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Windows.Forms;
using ICSharpCode.FormsDesigner;
using ICSharpCode.FormsDesigner.Services;
using ICSharpCode.Scripting.Tests.Utils;
using NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Designer
{
[TestFixture]
[RequiresSTA]
public class ScriptingDesignerLoaderTests
{
MockDesignerGenerator fakeGenerator;
TestableScriptingDesignerLoader loader;
MockDesignerLoaderHost fakeDesignerLoaderHost;
MockEventBindingService fakeEventBindingService;
FormsDesignerViewContent formsDesignerView;
FakeDesignerSerializationManager fakeSerializationManager;
[SetUp]
public void Init()
{
CreateScriptingDesignerLoader();
}
void CreateScriptingDesignerLoader()
{
fakeGenerator = new MockDesignerGenerator();
loader = new TestableScriptingDesignerLoader(fakeGenerator);
formsDesignerView = new FormsDesignerViewContent(new MockViewContent(), new MockOpenedFile("Test.py"));
fakeGenerator.Attach(formsDesignerView);
}
[TearDown]
public void TearDown()
{
loader.Dispose();
}
[Test]
public void ScriptingDesignerLoaderClass_NewInstance_IsBasicDesignerLoader()
{
BasicDesignerLoader basicLoader = loader as BasicDesignerLoader;
Assert.IsNotNull(basicLoader);
}
[Test]
public void BeginLoad_PassedFakeDesignerLoaderHost_ComponentSerializationServiceAddedToDesignerLoaderHost()
{
BeginLoad();
CodeDomComponentSerializationService service = fakeDesignerLoaderHost.GetService(typeof(ComponentSerializationService)) as CodeDomComponentSerializationService;
Assert.IsNotNull(service);
}
void BeginLoad()
{
CreateDesignerLoaderHostWithoutProjectResourceService();
fakeDesignerLoaderHost.AddService(typeof(ProjectResourceService), new ProjectResourceService(new MockProjectContent()));
loader.BeginLoad(fakeDesignerLoaderHost);
}
void CreateDesignerLoaderHostWithoutProjectResourceService()
{
fakeDesignerLoaderHost = new MockDesignerLoaderHost();
fakeEventBindingService = new MockEventBindingService();
fakeDesignerLoaderHost.AddService(typeof(IEventBindingService), fakeEventBindingService);
}
[Test]
public void BeginLoad_PassedFakeDesignerLoaderHost_NameCreationServiceAddedToDesignerLoaderHost()
{
BeginLoad();
ScriptingNameCreationService service = fakeDesignerLoaderHost.GetService(typeof(INameCreationService)) as ScriptingNameCreationService;
Assert.IsNotNull(service);
}
[Test]
public void BeginLoad_PassedFakeDesignerLoaderHost_DesignerSerializationServiceAddedToDesignerLoaderHost()
{
BeginLoad();
DesignerSerializationService service = fakeDesignerLoaderHost.GetService(typeof(IDesignerSerializationService)) as DesignerSerializationService;
Assert.IsNotNull(service);
}
[Test]
public void BeginLoad_PassedFakeDesignerLoaderHost_ProjectResourceServiceDesignerAddedToDesignerLoaderHostDoesNotSupportProjectResources()
{
BeginLoad();
ProjectResourceService service = fakeDesignerLoaderHost.GetService(typeof(ProjectResourceService)) as ProjectResourceService;
Assert.IsFalse(service.DesignerSupportsProjectResources);
}
[Test]
public void GetEventProperty_PassedFormLoadEventDescriptor_ReturnsPropertyDescriptorFromEventBindingService()
{
BeginLoad();
IEventBindingService eventBindingService = (IEventBindingService)fakeEventBindingService;
EventDescriptor e = TypeDescriptor.GetEvents(typeof(Form)).Find("Load", true);
PropertyDescriptor propertyDescriptor = loader.GetEventProperty(e);
PropertyDescriptor expectedPropertyDescriptor = eventBindingService.GetEventProperty(e);
Assert.AreEqual(expectedPropertyDescriptor, propertyDescriptor);
}
[Test]
public void ScriptingDesignerLoaderConstructor_PassedNullGenerator_ThrowsArgumentException()
{
ArgumentException ex = Assert.Throws<ArgumentException>(delegate {
loader = new TestableScriptingDesignerLoader(null);
});
string paramName = ex.ParamName;
string expectedParamName = "generator";
Assert.AreEqual(expectedParamName, paramName);
}
[Test]
public void PerformFlush_PassedDesignerSerializationManager_DesignerLoaderHostPassedToMergeRootComponentChangesMethod()
{
BeginLoad();
DesignerSerializationManager serializationManager = new DesignerSerializationManager();
loader.CallPerformFlush(serializationManager);
IDesignerHost host = fakeGenerator.MergeChangesHost;
Assert.AreEqual(fakeDesignerLoaderHost, host);
}
[Test]
public void PerformFlush_PassedDesignerSerializationManager_SerializationManagerPassedToMergeRootComponentMethod()
{
BeginLoad();
DesignerSerializationManager expectedSerializationManager = new DesignerSerializationManager();
loader.CallPerformFlush(expectedSerializationManager);
IDesignerSerializationManager serializationManager = fakeGenerator.MergeChangesSerializationManager;
Assert.AreEqual(expectedSerializationManager, serializationManager);
}
[Test]
public void RootComponent_DesignerLoaderHostRootComponentIsForm_ReturnsDesignerLoaderHostRootComponent()
{
BeginLoad();
using (Form form = new Form()) {
fakeDesignerLoaderHost.RootComponent = form;
IComponent rootComponent = loader.RootComponent;
Assert.AreEqual(form, rootComponent);
}
}
[Test]
public void BeginLoad_PassedFakeDesignerLoaderHost_CallsCreatesComponentWalkerPassingNonNullComponentCreator()
{
BeginLoad();
IComponentCreator componentCreator = loader.ComponentCreatorPassedToCreateComponentWalker;
Assert.IsNotNull(componentCreator);
}
[Test]
public void BeginLoad_PassedFakeDesignerLoaderHost_CallsComponentWalkerCreateComponentMethodPassingFormCode()
{
string expectedCode =
"MyForm(Form):\r\n" +
" pass";
formsDesignerView.DesignerCodeFileContent = expectedCode;
BeginLoad();
string code = loader.FakeComponentWalker.CodePassedToCreateComponent;
Assert.AreEqual(expectedCode, code);
}
[Test]
public void BeginLoad_NoProjectResourceService_NullReferenceExceptionIsNotThrown()
{
CreateDesignerLoaderHostWithoutProjectResourceService();
Assert.DoesNotThrow(delegate { loader.BeginLoad(fakeDesignerLoaderHost); });
}
[Test]
public void CreateComponent_CreateTextBox_TextBoxTypePassedToDesignerLoaderHostCreateComponentMethod()
{
BeginLoad();
loader.CreateComponent(typeof(TextBox), "MyTextBox");
CreatedComponent createdComponent = fakeDesignerLoaderHost.CreatedComponents[0];
CreatedComponent expectedCreatedComponent = new CreatedComponent("System.Windows.Forms.TextBox", "MyTextBox");
Assert.AreEqual(expectedCreatedComponent, createdComponent);
}
[Test]
public void CreateComponent_CreateTextBox_TextBoxInstanceReturned()
{
BeginLoad();
IComponent component = loader.CreateComponent(typeof(TextBox), "MyTextBox");
bool result = component is TextBox;
Assert.IsTrue(result);
}
[Test]
public void Add_AddTextBox_AddsTextBoxToDesignerLoaderHostContainer()
{
BeginLoad();
using (TextBox textBox = new TextBox()) {
loader.Add(textBox, "MyTextBox");
IComponent component = fakeDesignerLoaderHost.Container.Components["MyTextBox"];
Assert.AreEqual(textBox, component);
}
}
[Test]
public void GetComponent_TextBoxAddedToLoader_ReturnsTextBox()
{
BeginLoad();
using (TextBox textBox = new TextBox()) {
loader.Add(textBox, "MyTextBox");
IComponent component = loader.GetComponent("MyTextBox");
Assert.AreEqual(textBox, component);
}
}
[Test]
public void GetComponent_NoComponentsAddedToLoader_ReturnsNull()
{
BeginLoad();
IComponent component = loader.GetComponent("MyTextBox");
Assert.IsNull(component);
}
[Test]
public void GetType_PassedTypeName_ReturnsTypeFromDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
Type expectedType = typeof(string);
fakeSerializationManager.TypeToReturnFromGetType = expectedType;
Type type = loader.GetType("string");
Assert.AreEqual(expectedType, type);
}
void CreateDesignerSerializationManager()
{
fakeSerializationManager = new FakeDesignerSerializationManager();
}
[Test]
public void GetType_PassedTypeName_TypeNamePassedToDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
string expectedTypeName = "test";
loader.GetType(expectedTypeName);
string typeName = fakeSerializationManager.TypeNamePassedToGetType;
Assert.AreEqual(expectedTypeName, typeName);
}
[Test]
public void GetInstance_PassedName_ReturnsInstanceFromDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
object expectedInstance = new object();
fakeSerializationManager.InstanceToReturnFromGetInstance = expectedInstance;
object instance = loader.GetInstance("test");
Assert.AreEqual(expectedInstance, instance);
}
[Test]
public void GetInstance_PassedName_InstanceNamePassedToDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
string expectedName = "test";
loader.GetInstance(expectedName);
string name = fakeSerializationManager.NamePassedToGetInstance;
Assert.AreEqual(expectedName, name);
}
[Test]
public void CreateInstance_PassedType_ReturnsInstanceFromDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
object expectedInstance = new object();
fakeSerializationManager.InstanceToReturnFromCreateInstance = expectedInstance;
object instance = LoaderCreateInstance(typeof(string));
Assert.AreEqual(expectedInstance, instance);
}
object LoaderCreateInstance(Type type)
{
return LoaderCreateInstance(type, null, null, false);
}
object LoaderCreateInstance(string name)
{
return LoaderCreateInstance(null, null, name, false);
}
object LoaderCreateInstance(ICollection arguments)
{
return LoaderCreateInstance(null, arguments, null, false);
}
object LoaderCreateInstance(bool addToContainer)
{
return LoaderCreateInstance(null, null, null, addToContainer);
}
object LoaderCreateInstance(Type type, ICollection arguments, string name, bool addToContainer)
{
return loader.CreateInstance(type, arguments, name, addToContainer);
}
[Test]
public void CreateInstance_PassedType_TypePassedToDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
Type expectedType = typeof(string);
LoaderCreateInstance(expectedType);
Type type = fakeSerializationManager.TypePassedToCreateInstance;
Assert.AreEqual(expectedType, type);
}
[Test]
public void CreateInstance_PassedName_NamePassedToDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
string expectedName = "test";
LoaderCreateInstance(expectedName);
string name = fakeSerializationManager.NamePassedToCreateInstance;
Assert.AreEqual(expectedName, name);
}
[Test]
public void CreateInstance_PassedTrueAddToContainer_AddToContainerPassedToDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
LoaderCreateInstance(true);
bool addToContainer = fakeSerializationManager.AddToContainerPassedToCreateInstance;
Assert.IsTrue(addToContainer);
}
[Test]
public void CreateInstance_PassedFalseAddToContainer_AddToContainerPassedToDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
LoaderCreateInstance(false);
bool addToContainer = fakeSerializationManager.AddToContainerPassedToCreateInstance;
Assert.IsFalse(addToContainer);
}
[Test]
public void CreateInstance_PassedArguments_ArgumentsPassedToDesignerSerializationManager()
{
CreateDesignerSerializationManager();
loader.CallPerformLoad(fakeSerializationManager);
string[] expectedArguments = new string[] { "a", "b" };
LoaderCreateInstance(expectedArguments);
ICollection arguments = fakeSerializationManager.ArgumentsPassedToCreateInstance;
Assert.AreEqual(expectedArguments, arguments);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections;
//using System.ComponentModel;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//using System.Windows.Forms;
//
//using ICSharpCode.FormsDesigner;
//using ICSharpCode.FormsDesigner.Services;
//using ICSharpCode.Scripting.Tests.Utils;
//using NUnit.Framework;
//
//namespace ICSharpCode.Scripting.Tests.Designer
//{
// [TestFixture]
// [RequiresSTA]
// public class ScriptingDesignerLoaderTests
// {
// MockDesignerGenerator fakeGenerator;
// TestableScriptingDesignerLoader loader;
// MockDesignerLoaderHost fakeDesignerLoaderHost;
// MockEventBindingService fakeEventBindingService;
// FormsDesignerViewContent formsDesignerView;
// FakeDesignerSerializationManager fakeSerializationManager;
//
// [SetUp]
// public void Init()
// {
// CreateScriptingDesignerLoader();
// }
//
// void CreateScriptingDesignerLoader()
// {
// fakeGenerator = new MockDesignerGenerator();
// loader = new TestableScriptingDesignerLoader(fakeGenerator);
//
// formsDesignerView = new FormsDesignerViewContent(new MockViewContent(), new MockOpenedFile("Test.py"));
// fakeGenerator.Attach(formsDesignerView);
// }
//
// [TearDown]
// public void TearDown()
// {
// loader.Dispose();
// }
//
// [Test]
// public void ScriptingDesignerLoaderClass_NewInstance_IsBasicDesignerLoader()
// {
// BasicDesignerLoader basicLoader = loader as BasicDesignerLoader;
// Assert.IsNotNull(basicLoader);
// }
//
// [Test]
// public void BeginLoad_PassedFakeDesignerLoaderHost_ComponentSerializationServiceAddedToDesignerLoaderHost()
// {
// BeginLoad();
// CodeDomComponentSerializationService service = fakeDesignerLoaderHost.GetService(typeof(ComponentSerializationService)) as CodeDomComponentSerializationService;
// Assert.IsNotNull(service);
// }
//
// void BeginLoad()
// {
// CreateDesignerLoaderHostWithoutProjectResourceService();
// fakeDesignerLoaderHost.AddService(typeof(ProjectResourceService), new ProjectResourceService(new MockProjectContent()));
// loader.BeginLoad(fakeDesignerLoaderHost);
// }
//
// void CreateDesignerLoaderHostWithoutProjectResourceService()
// {
// fakeDesignerLoaderHost = new MockDesignerLoaderHost();
// fakeEventBindingService = new MockEventBindingService();
// fakeDesignerLoaderHost.AddService(typeof(IEventBindingService), fakeEventBindingService);
// }
//
// [Test]
// public void BeginLoad_PassedFakeDesignerLoaderHost_NameCreationServiceAddedToDesignerLoaderHost()
// {
// BeginLoad();
// ScriptingNameCreationService service = fakeDesignerLoaderHost.GetService(typeof(INameCreationService)) as ScriptingNameCreationService;
// Assert.IsNotNull(service);
// }
//
// [Test]
// public void BeginLoad_PassedFakeDesignerLoaderHost_DesignerSerializationServiceAddedToDesignerLoaderHost()
// {
// BeginLoad();
// DesignerSerializationService service = fakeDesignerLoaderHost.GetService(typeof(IDesignerSerializationService)) as DesignerSerializationService;
// Assert.IsNotNull(service);
// }
//
// [Test]
// public void BeginLoad_PassedFakeDesignerLoaderHost_ProjectResourceServiceDesignerAddedToDesignerLoaderHostDoesNotSupportProjectResources()
// {
// BeginLoad();
// ProjectResourceService service = fakeDesignerLoaderHost.GetService(typeof(ProjectResourceService)) as ProjectResourceService;
// Assert.IsFalse(service.DesignerSupportsProjectResources);
// }
//
// [Test]
// public void GetEventProperty_PassedFormLoadEventDescriptor_ReturnsPropertyDescriptorFromEventBindingService()
// {
// BeginLoad();
// IEventBindingService eventBindingService = (IEventBindingService)fakeEventBindingService;
// EventDescriptor e = TypeDescriptor.GetEvents(typeof(Form)).Find("Load", true);
//
// PropertyDescriptor propertyDescriptor = loader.GetEventProperty(e);
// PropertyDescriptor expectedPropertyDescriptor = eventBindingService.GetEventProperty(e);
//
// Assert.AreEqual(expectedPropertyDescriptor, propertyDescriptor);
// }
//
// [Test]
// public void ScriptingDesignerLoaderConstructor_PassedNullGenerator_ThrowsArgumentException()
// {
// ArgumentException ex = Assert.Throws<ArgumentException>(delegate {
// loader = new TestableScriptingDesignerLoader(null);
// });
// string paramName = ex.ParamName;
// string expectedParamName = "generator";
// Assert.AreEqual(expectedParamName, paramName);
// }
//
// [Test]
// public void PerformFlush_PassedDesignerSerializationManager_DesignerLoaderHostPassedToMergeRootComponentChangesMethod()
// {
// BeginLoad();
// DesignerSerializationManager serializationManager = new DesignerSerializationManager();
// loader.CallPerformFlush(serializationManager);
//
// IDesignerHost host = fakeGenerator.MergeChangesHost;
// Assert.AreEqual(fakeDesignerLoaderHost, host);
// }
//
// [Test]
// public void PerformFlush_PassedDesignerSerializationManager_SerializationManagerPassedToMergeRootComponentMethod()
// {
// BeginLoad();
// DesignerSerializationManager expectedSerializationManager = new DesignerSerializationManager();
// loader.CallPerformFlush(expectedSerializationManager);
//
// IDesignerSerializationManager serializationManager = fakeGenerator.MergeChangesSerializationManager;
// Assert.AreEqual(expectedSerializationManager, serializationManager);
// }
//
// [Test]
// public void RootComponent_DesignerLoaderHostRootComponentIsForm_ReturnsDesignerLoaderHostRootComponent()
// {
// BeginLoad();
// using (Form form = new Form()) {
// fakeDesignerLoaderHost.RootComponent = form;
// IComponent rootComponent = loader.RootComponent;
// Assert.AreEqual(form, rootComponent);
// }
// }
//
//
// [Test]
// public void BeginLoad_PassedFakeDesignerLoaderHost_CallsCreatesComponentWalkerPassingNonNullComponentCreator()
// {
// BeginLoad();
// IComponentCreator componentCreator = loader.ComponentCreatorPassedToCreateComponentWalker;
// Assert.IsNotNull(componentCreator);
// }
//
// [Test]
// public void BeginLoad_PassedFakeDesignerLoaderHost_CallsComponentWalkerCreateComponentMethodPassingFormCode()
// {
// string expectedCode =
// "MyForm(Form):\r\n" +
// " pass";
//
// formsDesignerView.DesignerCodeFileContent = expectedCode;
//
// BeginLoad();
// string code = loader.FakeComponentWalker.CodePassedToCreateComponent;
// Assert.AreEqual(expectedCode, code);
// }
//
// [Test]
// public void BeginLoad_NoProjectResourceService_NullReferenceExceptionIsNotThrown()
// {
// CreateDesignerLoaderHostWithoutProjectResourceService();
//
// Assert.DoesNotThrow(delegate { loader.BeginLoad(fakeDesignerLoaderHost); });
// }
//
// [Test]
// public void CreateComponent_CreateTextBox_TextBoxTypePassedToDesignerLoaderHostCreateComponentMethod()
// {
// BeginLoad();
// loader.CreateComponent(typeof(TextBox), "MyTextBox");
// CreatedComponent createdComponent = fakeDesignerLoaderHost.CreatedComponents[0];
// CreatedComponent expectedCreatedComponent = new CreatedComponent("System.Windows.Forms.TextBox", "MyTextBox");
//
// Assert.AreEqual(expectedCreatedComponent, createdComponent);
// }
//
// [Test]
// public void CreateComponent_CreateTextBox_TextBoxInstanceReturned()
// {
// BeginLoad();
// IComponent component = loader.CreateComponent(typeof(TextBox), "MyTextBox");
// bool result = component is TextBox;
//
// Assert.IsTrue(result);
// }
//
// [Test]
// public void Add_AddTextBox_AddsTextBoxToDesignerLoaderHostContainer()
// {
// BeginLoad();
// using (TextBox textBox = new TextBox()) {
// loader.Add(textBox, "MyTextBox");
// IComponent component = fakeDesignerLoaderHost.Container.Components["MyTextBox"];
// Assert.AreEqual(textBox, component);
// }
// }
//
// [Test]
// public void GetComponent_TextBoxAddedToLoader_ReturnsTextBox()
// {
// BeginLoad();
// using (TextBox textBox = new TextBox()) {
// loader.Add(textBox, "MyTextBox");
// IComponent component = loader.GetComponent("MyTextBox");
// Assert.AreEqual(textBox, component);
// }
// }
//
// [Test]
// public void GetComponent_NoComponentsAddedToLoader_ReturnsNull()
// {
// BeginLoad();
// IComponent component = loader.GetComponent("MyTextBox");
// Assert.IsNull(component);
// }
//
// [Test]
// public void GetType_PassedTypeName_ReturnsTypeFromDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// Type expectedType = typeof(string);
// fakeSerializationManager.TypeToReturnFromGetType = expectedType;
// Type type = loader.GetType("string");
//
// Assert.AreEqual(expectedType, type);
// }
//
// void CreateDesignerSerializationManager()
// {
// fakeSerializationManager = new FakeDesignerSerializationManager();
// }
//
// [Test]
// public void GetType_PassedTypeName_TypeNamePassedToDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// string expectedTypeName = "test";
// loader.GetType(expectedTypeName);
//
// string typeName = fakeSerializationManager.TypeNamePassedToGetType;
// Assert.AreEqual(expectedTypeName, typeName);
// }
//
// [Test]
// public void GetInstance_PassedName_ReturnsInstanceFromDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// object expectedInstance = new object();
// fakeSerializationManager.InstanceToReturnFromGetInstance = expectedInstance;
// object instance = loader.GetInstance("test");
//
// Assert.AreEqual(expectedInstance, instance);
// }
//
// [Test]
// public void GetInstance_PassedName_InstanceNamePassedToDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// string expectedName = "test";
// loader.GetInstance(expectedName);
//
// string name = fakeSerializationManager.NamePassedToGetInstance;
// Assert.AreEqual(expectedName, name);
// }
//
// [Test]
// public void CreateInstance_PassedType_ReturnsInstanceFromDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// object expectedInstance = new object();
// fakeSerializationManager.InstanceToReturnFromCreateInstance = expectedInstance;
// object instance = LoaderCreateInstance(typeof(string));
//
// Assert.AreEqual(expectedInstance, instance);
// }
//
// object LoaderCreateInstance(Type type)
// {
// return LoaderCreateInstance(type, null, null, false);
// }
//
// object LoaderCreateInstance(string name)
// {
// return LoaderCreateInstance(null, null, name, false);
// }
//
// object LoaderCreateInstance(ICollection arguments)
// {
// return LoaderCreateInstance(null, arguments, null, false);
// }
//
// object LoaderCreateInstance(bool addToContainer)
// {
// return LoaderCreateInstance(null, null, null, addToContainer);
// }
//
// object LoaderCreateInstance(Type type, ICollection arguments, string name, bool addToContainer)
// {
// return loader.CreateInstance(type, arguments, name, addToContainer);
// }
//
// [Test]
// public void CreateInstance_PassedType_TypePassedToDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// Type expectedType = typeof(string);
// LoaderCreateInstance(expectedType);
// Type type = fakeSerializationManager.TypePassedToCreateInstance;
//
// Assert.AreEqual(expectedType, type);
// }
//
// [Test]
// public void CreateInstance_PassedName_NamePassedToDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// string expectedName = "test";
// LoaderCreateInstance(expectedName);
// string name = fakeSerializationManager.NamePassedToCreateInstance;
//
// Assert.AreEqual(expectedName, name);
// }
//
// [Test]
// public void CreateInstance_PassedTrueAddToContainer_AddToContainerPassedToDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// LoaderCreateInstance(true);
// bool addToContainer = fakeSerializationManager.AddToContainerPassedToCreateInstance;
//
// Assert.IsTrue(addToContainer);
// }
//
// [Test]
// public void CreateInstance_PassedFalseAddToContainer_AddToContainerPassedToDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// LoaderCreateInstance(false);
// bool addToContainer = fakeSerializationManager.AddToContainerPassedToCreateInstance;
//
// Assert.IsFalse(addToContainer);
// }
//
// [Test]
// public void CreateInstance_PassedArguments_ArgumentsPassedToDesignerSerializationManager()
// {
// CreateDesignerSerializationManager();
// loader.CallPerformLoad(fakeSerializationManager);
//
// string[] expectedArguments = new string[] { "a", "b" };
// LoaderCreateInstance(expectedArguments);
// ICollection arguments = fakeSerializationManager.ArgumentsPassedToCreateInstance;
//
// Assert.AreEqual(expectedArguments, arguments);
// }
// }
//}

20
src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj

@ -7,12 +7,13 @@ @@ -7,12 +7,13 @@
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Scripting.Tests</RootNamespace>
<AssemblyName>ICSharpCode.Scripting.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
@ -133,6 +134,8 @@ @@ -133,6 +134,8 @@
<Compile Include="Utils\FakeDocumentLine.cs" />
<Compile Include="Utils\FakeScriptingConsole.cs" />
<Compile Include="Utils\FooItemCollection.cs" />
<Compile Include="Utils\MockAttribute.cs" />
<Compile Include="Utils\MockClass.cs" />
<Compile Include="Utils\MockComponentCreator.cs" />
<Compile Include="Utils\FakeConsoleTextEditor.cs" />
<Compile Include="Utils\FakeConsoleTextEditorKeyEventArgs.cs" />
@ -145,6 +148,7 @@ @@ -145,6 +148,7 @@
<Compile Include="Utils\MockEventDescriptor.cs" />
<Compile Include="Utils\MockExtenderProviderService.cs" />
<Compile Include="Utils\MockMemberProvider.cs" />
<Compile Include="Utils\MockMethod.cs" />
<Compile Include="Utils\MockOpenedFile.cs" />
<Compile Include="Utils\MockProject.cs" />
<Compile Include="Utils\MockProjectContent.cs" />
@ -183,9 +187,9 @@ @@ -183,9 +187,9 @@
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
<Name>ICSharpCode.AvalonEdit</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
@ -195,10 +199,6 @@ @@ -195,10 +199,6 @@
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj">
<Project>{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}</Project>
<Name>UnitTesting.Tests</Name>
@ -207,10 +207,6 @@ @@ -207,10 +207,6 @@
<Project>{1F261725-6318-4434-A1B1-6C70CE4CD324}</Project>
<Name>UnitTesting</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj">
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project>
<Name>FormsDesigner</Name>
</ProjectReference>
<ProjectReference Include="..\Project\ICSharpCode.Scripting.csproj">
<Project>{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}</Project>
<Name>ICSharpCode.Scripting</Name>

138
src/AddIns/BackendBindings/Scripting/Test/Utils/AddInPathHelper.cs

@ -1,69 +1,69 @@ @@ -1,69 +1,69 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
using ICSharpCode.Core;
namespace ICSharpCode.Scripting.Tests.Utils
{
public class AddInPathHelper
{
string addInName;
string identity;
string fileName;
public AddInPathHelper(string addInName)
{
this.addInName = addInName;
identity = String.Format("ICSharpCode.{0}", addInName);
fileName = String.Format(@"C:\SharpDevelop\AddIns\{0}\{0}.addin", addInName);
}
public AddIn CreateDummyAddInInsideAddInTree()
{
RemoveOldAddIn();
AddIn addin = CreateAddIn();
AddInTree.InsertAddIn(addin);
return addin;
}
void RemoveOldAddIn()
{
AddIn oldAddin = FindOldAddIn();
if (oldAddin != null) {
AddInTree.RemoveAddIn(oldAddin);
}
}
AddIn FindOldAddIn()
{
foreach (AddIn addin in AddInTree.AddIns) {
if (addin.Manifest.PrimaryIdentity == identity) {
return addin;
}
}
return null;
}
AddIn CreateAddIn()
{
string xml = GetAddInXml();
AddIn addin = AddIn.Load(new StringReader(xml));
addin.FileName = fileName;
return addin;
}
string GetAddInXml()
{
string format =
"<AddIn name='{0}' author= '' copyright='' description=''>\r\n" +
" <Manifest>\r\n" +
" <Identity name='{1}'/>\r\n" +
" </Manifest>\r\n" +
"</AddIn>";
return String.Format(format, addInName, identity);
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.IO;
//using ICSharpCode.Core;
//
//namespace ICSharpCode.Scripting.Tests.Utils
//{
// public class AddInPathHelper
// {
// string addInName;
// string identity;
// string fileName;
//
// public AddInPathHelper(string addInName)
// {
// this.addInName = addInName;
// identity = String.Format("ICSharpCode.{0}", addInName);
// fileName = String.Format(@"C:\SharpDevelop\AddIns\{0}\{0}.addin", addInName);
// }
//
// public AddIn CreateDummyAddInInsideAddInTree()
// {
// RemoveOldAddIn();
// AddIn addin = CreateAddIn();
// AddInTree.InsertAddIn(addin);
// return addin;
// }
//
// void RemoveOldAddIn()
// {
// AddIn oldAddin = FindOldAddIn();
// if (oldAddin != null) {
// AddInTree.RemoveAddIn(oldAddin);
// }
// }
//
// AddIn FindOldAddIn()
// {
// foreach (AddIn addin in AddInTree.AddIns) {
// if (addin.Manifest.PrimaryIdentity == identity) {
// return addin;
// }
// }
// return null;
// }
//
// AddIn CreateAddIn()
// {
// string xml = GetAddInXml();
// AddIn addin = AddIn.Load(new StringReader(xml));
// addin.FileName = fileName;
// return addin;
// }
//
// string GetAddInXml()
// {
// string format =
// "<AddIn name='{0}' author= '' copyright='' description=''>\r\n" +
// " <Manifest>\r\n" +
// " <Identity name='{1}'/>\r\n" +
// " </Manifest>\r\n" +
// "</AddIn>";
//
// return String.Format(format, addInName, identity);
// }
// }
//}

70
src/AddIns/BackendBindings/Scripting/Test/Utils/DerivedFormDesignerViewContent.cs

@ -1,35 +1,35 @@ @@ -1,35 +1,35 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.FormsDesigner;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.Scripting.Tests.Utils
{
/// <summary>
/// Derived FormDesignerViewContent class that is used for
/// unit testing the PythonDesignerGenerator.
/// </summary>
public class DerivedFormDesignerViewContent : FormsDesignerViewContent
{
bool mergeFormChangesCalled;
public DerivedFormDesignerViewContent(IViewContent view, ICSharpCode.SharpDevelop.OpenedFile mockFile)
: base(view, mockFile)
{
}
public override void MergeFormChanges()
{
mergeFormChangesCalled = true;
}
/// <summary>
/// Gets whether the MergeFormChanges method was called.
/// </summary>
public bool MergeFormChangesCalled {
get { return mergeFormChangesCalled; }
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.FormsDesigner;
//using ICSharpCode.SharpDevelop.Gui;
//
//namespace ICSharpCode.Scripting.Tests.Utils
//{
// /// <summary>
// /// Derived FormDesignerViewContent class that is used for
// /// unit testing the PythonDesignerGenerator.
// /// </summary>
// public class DerivedFormDesignerViewContent : FormsDesignerViewContent
// {
// bool mergeFormChangesCalled;
//
// public DerivedFormDesignerViewContent(IViewContent view, ICSharpCode.SharpDevelop.OpenedFile mockFile)
// : base(view, mockFile)
// {
// }
//
// public override void MergeFormChanges()
// {
// mergeFormChangesCalled = true;
// }
//
// /// <summary>
// /// Gets whether the MergeFormChanges method was called.
// /// </summary>
// public bool MergeFormChangesCalled {
// get { return mergeFormChangesCalled; }
// }
// }
//}

13
src/AddIns/BackendBindings/Scripting/Test/Utils/FakeCaret.cs

@ -30,7 +30,18 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -30,7 +30,18 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public Location Position {
public TextLocation Position {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public event EventHandler LocationChanged { add {} remove {} }
public TextLocation Location {
get {
throw new NotImplementedException();
}

116
src/AddIns/BackendBindings/Scripting/Test/Utils/FakeDocument.cs

@ -3,19 +3,17 @@ @@ -3,19 +3,17 @@
using System;
using System.IO;
using System.Text;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.Scripting.Tests.Utils
{
public class FakeDocument : IDocument
{
{
#pragma warning disable 0067
public event EventHandler<TextChangeEventArgs> Changing;
public event EventHandler<TextChangeEventArgs> Changed;
public event EventHandler<TextChangeEventArgs> TextChanging;
public event EventHandler TextChanged;
public event EventHandler ChangeCompleted;
public event EventHandler FileNameChanged;
#pragma warning restore 0067
public FakeDocumentLine DocumentLineToReturnFromGetLine;
@ -23,13 +21,34 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -23,13 +21,34 @@ namespace ICSharpCode.Scripting.Tests.Utils
public string Text { get; set; }
public int TotalNumberOfLines {
public IDocumentLine GetLineByNumber(int lineNumber)
{
LineNumberPassedToGetLine = lineNumber;
return DocumentLineToReturnFromGetLine;
}
event EventHandler<TextChangeEventArgs> IDocument.TextChanged {
add {
throw new NotImplementedException();
}
remove {
throw new NotImplementedException();
}
}
public int LineCount {
get {
throw new NotImplementedException();
}
}
public string FileName {
get {
throw new NotImplementedException();
}
}
public ITextBufferVersion Version {
public ITextSourceVersion Version {
get {
throw new NotImplementedException();
}
@ -41,30 +60,39 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -41,30 +60,39 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public IDocumentLine GetLine(int lineNumber)
public IDocument CreateDocumentSnapshot()
{
LineNumberPassedToGetLine = lineNumber;
return DocumentLineToReturnFromGetLine;
throw new NotImplementedException();
}
public IDocumentLine GetLineForOffset(int offset)
public IDocumentLine GetLineByOffset(int offset)
{
throw new NotImplementedException();
}
public int PositionToOffset(int line, int column)
public int GetOffset(int line, int column)
{
throw new NotImplementedException();
}
public Location OffsetToPosition(int offset)
public int GetOffset(ICSharpCode.NRefactory.TextLocation location)
{
throw new NotImplementedException();
}
public ICSharpCode.NRefactory.TextLocation GetLocation(int offset)
{
throw new NotImplementedException();
}
public void Insert(int offset, string text)
{
throw new NotImplementedException();
throw new NotImplementedException();
}
public void Insert(int offset, ITextSource text)
{
throw new NotImplementedException();
}
public void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType)
@ -72,6 +100,11 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -72,6 +100,11 @@ namespace ICSharpCode.Scripting.Tests.Utils
throw new NotImplementedException();
}
public void Insert(int offset, ITextSource text, AnchorMovementType defaultAnchorMovementType)
{
throw new NotImplementedException();
}
public void Remove(int offset, int length)
{
throw new NotImplementedException();
@ -82,6 +115,11 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -82,6 +115,11 @@ namespace ICSharpCode.Scripting.Tests.Utils
throw new NotImplementedException();
}
public void Replace(int offset, int length, ITextSource newText)
{
throw new NotImplementedException();
}
public void StartUndoableAction()
{
throw new NotImplementedException();
@ -102,12 +140,12 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -102,12 +140,12 @@ namespace ICSharpCode.Scripting.Tests.Utils
throw new NotImplementedException();
}
public ITextBuffer CreateSnapshot()
public ITextSource CreateSnapshot()
{
throw new NotImplementedException();
}
public ITextBuffer CreateSnapshot(int offset, int length)
public ITextSource CreateSnapshot(int offset, int length)
{
throw new NotImplementedException();
}
@ -129,7 +167,47 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -129,7 +167,47 @@ namespace ICSharpCode.Scripting.Tests.Utils
public string GetText(int offset, int length)
{
return Text.Substring(offset, length);
throw new NotImplementedException();
}
public string GetText(ISegment segment)
{
return ((FakeDocumentLine)segment).Text;
}
public void WriteTextTo(TextWriter writer)
{
throw new NotImplementedException();
}
public void WriteTextTo(TextWriter writer, int offset, int length)
{
throw new NotImplementedException();
}
public int IndexOf(char c, int startIndex, int count)
{
throw new NotImplementedException();
}
public int IndexOfAny(char[] anyOf, int startIndex, int count)
{
throw new NotImplementedException();
}
public int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
{
throw new NotImplementedException();
}
public int LastIndexOf(char c, int startIndex, int count)
{
throw new NotImplementedException();
}
public int LastIndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
{
throw new NotImplementedException();
}
public object GetService(Type serviceType)

22
src/AddIns/BackendBindings/Scripting/Test/Utils/FakeDocumentLine.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.Scripting.Tests.Utils
{
@ -13,7 +13,25 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -13,7 +13,25 @@ namespace ICSharpCode.Scripting.Tests.Utils
public int EndOffset { get; set; }
public int TotalLength { get; set; }
public int DelimiterLength { get; set; }
public int LineNumber { get; set; }
public int LineNumber { get; set; }
public string Text { get; set; }
public IDocumentLine PreviousLine {
get {
throw new NotImplementedException();
}
}
public IDocumentLine NextLine {
get {
throw new NotImplementedException();
}
}
public bool IsDeleted {
get {
throw new NotImplementedException();
}
}
}
}

25
src/AddIns/BackendBindings/Scripting/Test/Utils/MockAttribute.cs

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.Scripting.Tests.Utils
{
// public class MockAttribute : IAttribute
// {
// IReturnType type;
//
// public MockAttribute(string name)
// {
// type = new DefaultReturnType(new MockClass(name));
// }
//
// public IReturnType AttributeType {
// get {
// return type;
// }
// }
//
// }
}

166
src/AddIns/BackendBindings/Scripting/Test/Utils/MockClass.cs

@ -0,0 +1,166 @@ @@ -0,0 +1,166 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using ICSharpCode.SharpDevelop.Dom;
//using ICSharpCode.SharpDevelop.Project;
//using System;
//using System.Collections.Generic;
//
//namespace ICSharpCode.Scripting.Tests.Utils
//{
// public class MockClass : DefaultClass
// {
// string dotNetName;
// IClass compoundClass;
//
// public MockClass()
// : this(String.Empty)
// {
// }
//
// public MockClass(IProjectContent projectContent)
// : this(projectContent, String.Empty)
// {
// }
//
// public MockClass(IProjectContent projectContent, string fullyQualifiedName)
// : this(projectContent, fullyQualifiedName, null)
// {
// }
//
// public MockClass(string fullyQualifiedName)
// : this(fullyQualifiedName, fullyQualifiedName)
// {
// }
//
// public MockClass(string fullyQualifiedName, string dotNetName)
// : this(fullyQualifiedName, dotNetName, null)
// {
// }
//
// public MockClass(string fullyQualifiedName, string dotNetName, IClass declaringType)
// : this(new MockProjectContent(), fullyQualifiedName, dotNetName, declaringType)
// {
// }
//
// public MockClass(IProjectContent projectContent, string fullyQualifiedName, IClass declaringType)
// : this(projectContent, fullyQualifiedName, fullyQualifiedName, declaringType)
// {
// }
//
// public MockClass(IProjectContent projectContent, string fullyQualifiedName, string dotNetName, IClass declaringType)
// : base(new DefaultCompilationUnit(projectContent), declaringType)
// {
// this.FullyQualifiedName = fullyQualifiedName;
// this.dotNetName = dotNetName;
//
// if (declaringType != null) {
// declaringType.InnerClasses.Add(this);
// }
// }
//
// public override string DotNetName {
// get { return dotNetName; }
// }
//
// public void SetDotNetName(string name)
// {
// dotNetName = name;
// }
//
// public MockProjectContent MockProjectContent {
// get { return ProjectContent as MockProjectContent; }
// }
//
// public IProject Project {
// get { return ProjectContent.Project as IProject; }
// }
//
// public static MockClass CreateMockClassWithoutAnyAttributes()
// {
// return CreateMockClassWithAttributes(new MockAttribute[0]);
// }
//
// public static MockClass CreateMockClassWithAttributes(IList<MockAttribute> attributes)
// {
// MockClass mockClass = new MockClass();
// mockClass.MockProjectContent.Project = new MockCSharpProject();
// mockClass.MockProjectContent.Classes.Add(mockClass);
//
// foreach (MockAttribute attribute in attributes) {
// mockClass.Attributes.Add(attribute);
// }
// return mockClass;
// }
//
// public static MockClass CreateMockClassWithAttribute(MockAttribute attribute)
// {
// List<MockAttribute> attributes = new List<MockAttribute>();
// attributes.Add(attribute);
//
// return CreateMockClassWithAttributes(attributes);
// }
//
// public static MockClass CreateClassWithBaseType(string baseTypeName)
// {
// MockClass baseType = MockClass.CreateMockClassWithoutAnyAttributes();
// baseType.FullyQualifiedName = baseTypeName;
// MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
// c.BaseTypes.Add(new DefaultReturnType(baseType));
// return c;
// }
//
// public void SetCompoundClass(IClass c)
// {
// this.compoundClass = c;
// }
//
// protected override IReturnType CreateDefaultReturnType()
// {
// if (compoundClass != null) {
// return new DefaultReturnType(compoundClass);
// }
// return base.CreateDefaultReturnType();
// }
//
// public void AddBaseClass(IClass baseClass)
// {
// DefaultReturnType returnType = new DefaultReturnType(baseClass);
// BaseTypes.Add(returnType);
// }
//
// public DefaultProperty AddProperty(string name)
// {
// DefaultProperty property = new DefaultProperty(this, name);
// Properties.Add(property);
// return property;
// }
//
// public void InsertPropertyAtStart(string name)
// {
// DefaultProperty property = new DefaultProperty(this, name);
// Properties.Insert(0, property);
// }
//
// public DefaultEvent AddEvent(string name)
// {
// DefaultEvent classEvent = new DefaultEvent(this, name);
// Events.Add(classEvent);
// return classEvent;
// }
//
// public DefaultField AddField(string name)
// {
// DefaultField field = new DefaultField(this, name);
// Fields.Add(field);
// return field;
// }
//
// public DefaultMethod AddMethod(string name)
// {
// DefaultMethod method = new DefaultMethod(this, name);
// Methods.Add(method);
// return method;
// }
// }
//}

348
src/AddIns/BackendBindings/Scripting/Test/Utils/MockDebugger.cs

@ -1,174 +1,174 @@ @@ -1,174 +1,174 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.Scripting.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 object GetTooltipControl(Location logicalPosition, string variable)
{
throw new NotImplementedException();
}
public bool SetInstructionPointer(string filename, int line, int column, bool dryRun)
{
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);
}
}
public bool BreakAtBeginning { get; set; }
public bool IsAttached { get; set; }
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Diagnostics;
//using ICSharpCode.NRefactory;
//using ICSharpCode.SharpDevelop.Debugging;
//using ICSharpCode.SharpDevelop.Project;
//
//namespace ICSharpCode.Scripting.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 object GetTooltipControl(TextLocation logicalPosition, string variable)
// {
// throw new NotImplementedException();
// }
//
// public bool SetInstructionPointer(string filename, int line, int column, bool dryRun)
// {
// 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);
// }
// }
//
// public bool BreakAtBeginning { get; set; }
//
// public bool IsAttached { get; set; }
// }
//}

182
src/AddIns/BackendBindings/Scripting/Test/Utils/MockDesignerGenerator.cs

@ -1,91 +1,91 @@ @@ -1,91 +1,91 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.FormsDesigner;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.Scripting.Tests.Utils
{
public class MockDesignerGenerator : IScriptingDesignerGenerator
{
FormsDesignerViewContent viewContent;
IDesignerHost mergeChangesHost;
IDesignerSerializationManager mergeChangesSerializationManager;
public MockDesignerGenerator()
{
}
public CodeDomProvider CodeDomProvider {
get { return null; }
}
public FormsDesignerViewContent ViewContent {
get { return this.viewContent; }
}
public void Attach(FormsDesignerViewContent viewContent)
{
this.viewContent = viewContent;
}
public void Detach()
{
this.viewContent = null;
}
public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
{
designerCodeFile = this.viewContent.DesignerCodeFile;
return new [] {designerCodeFile};
}
public void MergeFormChanges(CodeCompileUnit unit)
{
}
public void NotifyComponentRenamed(object component, string newName, string oldName)
{
}
public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
{
mergeChangesHost = host;
mergeChangesSerializationManager = serializationManager;
}
public IDesignerHost MergeChangesHost {
get { return mergeChangesHost; }
}
public IDesignerSerializationManager MergeChangesSerializationManager {
get { return mergeChangesSerializationManager; }
}
public bool InsertComponentEvent(IComponent component, System.ComponentModel.EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
{
throw new NotImplementedException();
}
public ICollection GetCompatibleMethods(EventDescriptor edesc)
{
throw new NotImplementedException();
}
public ICollection GetCompatibleMethods(EventInfo edesc)
{
throw new NotImplementedException();
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.CodeDom;
//using System.CodeDom.Compiler;
//using System.Collections;
//using System.Collections.Generic;
//using System.ComponentModel;
//using System.ComponentModel.Design;
//using System.ComponentModel.Design.Serialization;
//using System.Reflection;
//using System.Windows.Forms;
//
//using ICSharpCode.FormsDesigner;
//using ICSharpCode.SharpDevelop;
//
//namespace ICSharpCode.Scripting.Tests.Utils
//{
// public class MockDesignerGenerator : IScriptingDesignerGenerator
// {
// FormsDesignerViewContent viewContent;
// IDesignerHost mergeChangesHost;
// IDesignerSerializationManager mergeChangesSerializationManager;
//
// public MockDesignerGenerator()
// {
// }
//
// public CodeDomProvider CodeDomProvider {
// get { return null; }
// }
//
// public FormsDesignerViewContent ViewContent {
// get { return this.viewContent; }
// }
//
// public void Attach(FormsDesignerViewContent viewContent)
// {
// this.viewContent = viewContent;
// }
//
// public void Detach()
// {
// this.viewContent = null;
// }
//
// public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
// {
// designerCodeFile = this.viewContent.DesignerCodeFile;
// return new [] {designerCodeFile};
// }
//
// public void MergeFormChanges(CodeCompileUnit unit)
// {
// }
//
// public void NotifyComponentRenamed(object component, string newName, string oldName)
// {
// }
//
// public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
// {
// mergeChangesHost = host;
// mergeChangesSerializationManager = serializationManager;
// }
//
// public IDesignerHost MergeChangesHost {
// get { return mergeChangesHost; }
// }
//
// public IDesignerSerializationManager MergeChangesSerializationManager {
// get { return mergeChangesSerializationManager; }
// }
//
// public bool InsertComponentEvent(IComponent component, System.ComponentModel.EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
// {
// throw new NotImplementedException();
// }
//
// public ICollection GetCompatibleMethods(EventDescriptor edesc)
// {
// throw new NotImplementedException();
// }
//
// public ICollection GetCompatibleMethods(EventInfo edesc)
// {
// throw new NotImplementedException();
// }
// }
//}

16
src/AddIns/BackendBindings/Scripting/Test/Utils/MockEditableViewContent.cs

@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.AvalonEdit;
using ICSharpCode.SharpDevelop;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Scripting.Tests.Utils
{
@ -23,9 +23,9 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -23,9 +23,9 @@ namespace ICSharpCode.Scripting.Tests.Utils
public string Text { get; set; }
public ITextBuffer CreateSnapshot()
public ITextSource CreateSnapshot()
{
return new StringTextBuffer(Text);
return new StringTextSource(Text);
}
public ITextEditorOptions TextEditorOptions {
@ -45,5 +45,13 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -45,5 +45,13 @@ namespace ICSharpCode.Scripting.Tests.Utils
{
throw new NotImplementedException();
}
public override object GetService(Type serviceType)
{
if (serviceType == typeof(ITextEditor)) {
return MockTextEditor;
}
return null;
}
}
}

60
src/AddIns/BackendBindings/Scripting/Test/Utils/MockMethod.cs

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections.Generic;
//
//namespace ICSharpCode.Scripting.Tests.Utils
//{
// public class MockMethod : DefaultMethod
// {
// public MockMethod()
// : this(String.Empty)
// {
// }
//
// public MockMethod(string name)
// : this(null, name)
// {
// }
//
// public MockMethod(IClass declaringType)
// : this(declaringType, String.Empty)
// {
// }
//
// public MockMethod(IClass declaringType, string name)
// : base(declaringType, name)
// {
// }
//
// public static MockMethod CreateMockMethodWithoutAnyAttributes()
// {
// return CreateMockMethodWithAttributes(new MockAttribute[0]);
// }
//
// public static MockMethod CreateMockMethodWithAttributes(IList<MockAttribute> attributes)
// {
// MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes();
// MockMethod mockMethod = new MockMethod(mockClass);
//
// foreach (MockAttribute attribute in attributes) {
// mockMethod.Attributes.Add(attribute);
// }
//
// return mockMethod;
// }
//
// public static MockMethod CreateMockMethodWithAttribute(MockAttribute attribute)
// {
// List<MockAttribute> attributes = new List<MockAttribute>();
// attributes.Add(attribute);
//
// return CreateMockMethodWithAttributes(attributes);
// }
//
// public MockClass MockDeclaringType {
// get { return DeclaringType as MockClass; }
// }
// }
//}

2
src/AddIns/BackendBindings/Scripting/Test/Utils/MockOpenedFile.cs

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Scripting.Tests.Utils
{

188
src/AddIns/BackendBindings/Scripting/Test/Utils/MockProject.cs

@ -3,13 +3,10 @@ @@ -3,13 +3,10 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
using UnitTesting.Tests.Utils;
namespace ICSharpCode.Scripting.Tests.Utils
{
@ -23,50 +20,63 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -23,50 +20,63 @@ namespace ICSharpCode.Scripting.Tests.Utils
{
}
#region IProject
public event EventHandler DirtyChanged;
public bool ReadOnly {
get { return false; }
}
protected virtual void OnDirtyChanged(EventArgs e)
{
if (DirtyChanged != null) {
DirtyChanged(this, e);
}
public string Directory {
get { return directory; }
set { directory = value; }
}
public ReadOnlyCollection<ProjectItem> Items {
public string RootNamespace {
get { return rootNamespace; }
set { rootNamespace = value; }
}
string language = String.Empty;
public string Language {
get {
throw new NotImplementedException();
return language;
}
set {
language = value;
}
}
public bool ReadOnly {
get { return false; }
public event EventHandler ActiveConfigurationChanged { add {} remove {} }
public event EventHandler ActivePlatformChanged { add {} remove {} }
public object SyncRoot {
get { return syncRoot; }
}
public ICollection<ItemType> AvailableFileItemTypes {
public Solution ParentSolution {
get { return new Solution(new MockProjectChangeWatcher()); }
}
public event EventHandler<ICSharpCode.SharpDevelop.Parser.ParseInformationEventArgs> ParseInformationUpdated { add {} remove {} }
public IReadOnlyCollection<ProjectItem> Items {
get {
throw new NotImplementedException();
}
}
public System.Collections.Generic.List<ProjectSection> ProjectSections {
public IReadOnlyCollection<ItemType> AvailableFileItemTypes {
get {
throw new NotImplementedException();
}
}
public ICSharpCode.SharpDevelop.Dom.LanguageProperties LanguageProperties {
public List<ProjectSection> ProjectSections {
get {
throw new NotImplementedException();
}
}
public ICSharpCode.SharpDevelop.Dom.IAmbience GetAmbience()
{
throw new NotImplementedException();
}
public string FileName {
public FileName FileName {
get {
throw new NotImplementedException();
}
@ -75,12 +85,7 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -75,12 +85,7 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public string Directory {
get { return directory; }
set { directory = value; }
}
public string AssemblyName {
public string Name {
get {
throw new NotImplementedException();
}
@ -89,25 +94,18 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -89,25 +94,18 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public string RootNamespace {
get { return rootNamespace; }
set { rootNamespace = value; }
}
public string OutputAssemblyFullPath {
public string AssemblyName {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
string language = String.Empty;
public string Language {
public string OutputAssemblyFullPath {
get {
return language;
}
set {
language = value;
throw new NotImplementedException();
}
}
@ -135,17 +133,13 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -135,17 +133,13 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public event EventHandler ActiveConfigurationChanged { add {} remove {} }
public event EventHandler ActivePlatformChanged { add {} remove {} }
public ICollection<string> ConfigurationNames {
public IReadOnlyCollection<string> ConfigurationNames {
get {
throw new NotImplementedException();
}
}
public ICollection<string> PlatformNames {
public IReadOnlyCollection<string> PlatformNames {
get {
throw new NotImplementedException();
}
@ -157,33 +151,37 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -157,33 +151,37 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public object SyncRoot {
get { return syncRoot; }
}
public ISolutionFolderContainer Parent {
public Properties ProjectSpecificProperties {
get {
throw new NotImplementedException();
}
set {
}
public int MinimumSolutionVersion {
get {
throw new NotImplementedException();
}
}
public Solution ParentSolution {
get { return new Solution(new MockProjectChangeWatcher()); }
public IProjectContent ProjectContent {
get {
throw new NotImplementedException();
}
}
public string TypeGuid {
public ICSharpCode.SharpDevelop.Refactoring.ICodeGenerator CodeGenerator {
get {
throw new NotImplementedException();
}
set {
}
public ICSharpCode.SharpDevelop.Dom.ITypeDefinitionModelCollection TypeDefinitionModels {
get {
throw new NotImplementedException();
}
}
public string IdGuid {
public ISolutionFolderContainer Parent {
get {
throw new NotImplementedException();
}
@ -192,7 +190,7 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -192,7 +190,7 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public string Location {
public string TypeGuid {
get {
throw new NotImplementedException();
}
@ -201,13 +199,7 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -201,13 +199,7 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public string Name {
get { return String.Empty; }
set {
}
}
public bool IsDirty {
public string IdGuid {
get {
throw new NotImplementedException();
}
@ -216,10 +208,13 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -216,10 +208,13 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public Properties ProjectSpecificProperties {
public string Location {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public IEnumerable<ProjectItem> GetItemsOfType(ItemType type)
@ -252,48 +247,72 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -252,48 +247,72 @@ namespace ICSharpCode.Scripting.Tests.Utils
throw new NotImplementedException();
}
public ParseProjectContent CreateProjectContent()
public ProjectItem CreateProjectItem(IProjectItemBackendStore item)
{
throw new NotImplementedException();
}
public ProjectItem CreateProjectItem(IProjectItemBackendStore item)
public IEnumerable<ReferenceProjectItem> ResolveAssemblyReferences(System.Threading.CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public void Dispose()
public void ProjectCreationComplete()
{
throw new NotImplementedException();
}
public Properties CreateMemento()
public System.Xml.Linq.XElement LoadProjectExtensions(string name)
{
throw new NotImplementedException();
}
public void SetMemento(ICSharpCode.Core.Properties memento)
public void SaveProjectExtensions(string name, System.Xml.Linq.XElement element)
{
throw new NotImplementedException();
}
public int MinimumSolutionVersion {
get {
throw new NotImplementedException();
}
public bool HasProjectType(Guid projectTypeGuid)
{
throw new NotImplementedException();
}
public string GetDefaultNamespace(string fileName)
{
throw new NotImplementedException();
}
public System.CodeDom.Compiler.CodeDomProvider CreateCodeDomProvider()
{
throw new NotImplementedException();
}
public void ResolveAssemblyReferences()
public void GenerateCodeFromCodeDom(System.CodeDom.CodeCompileUnit compileUnit, System.IO.TextWriter writer)
{
throw new NotImplementedException();
}
public ICollection<IBuildable> GetBuildDependencies(ProjectBuildOptions buildOptions)
public IAmbience GetAmbience()
{
throw new NotImplementedException();
}
public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink)
public ICSharpCode.SharpDevelop.Refactoring.ISymbolSearch PrepareSymbolSearch(IEntity entity)
{
throw new NotImplementedException();
}
public void OnParseInformationUpdated(ICSharpCode.SharpDevelop.Parser.ParseInformationEventArgs args)
{
throw new NotImplementedException();
}
public IEnumerable<IBuildable> GetBuildDependencies(ProjectBuildOptions buildOptions)
{
throw new NotImplementedException();
}
public System.Threading.Tasks.Task<bool> BuildAsync(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, IProgressMonitor progressMonitor)
{
throw new NotImplementedException();
}
@ -303,20 +322,19 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -303,20 +322,19 @@ namespace ICSharpCode.Scripting.Tests.Utils
throw new NotImplementedException();
}
public void ProjectCreationComplete()
public void Dispose()
{
throw new NotImplementedException();
}
public System.Xml.Linq.XElement LoadProjectExtensions(string name)
public Properties CreateMemento()
{
throw new NotImplementedException();
}
public void SaveProjectExtensions(string name, System.Xml.Linq.XElement element)
public void SetMemento(Properties memento)
{
throw new NotImplementedException();
}
#endregion
}
}

588
src/AddIns/BackendBindings/Scripting/Test/Utils/MockProjectContent.cs

@ -1,294 +1,294 @@ @@ -1,294 +1,294 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.Scripting.Tests.Utils
{
public class MockProjectContent : IProjectContent
{
string namespacePassedToNamespaceExistsMethod;
List<string> namespacesToAdd = new List<string>();
SearchTypeResult searchTypeResult;
bool searchTypeCalled;
SearchTypeRequest searchTypeRequest;
IClass classToReturnFromGetClass;
string getClassName;
List<IClass> classesInProjectContent = new List<IClass>();
string namespacePassedToGetNamespaceContentsMethod;
string classNameForGetClass;
bool namespaceExistsCalled;
object project;
Dictionary<string, List<ICompletionEntry>> namespaceContents = new Dictionary<string, List<ICompletionEntry>>();
LanguageProperties language = LanguageProperties.CSharp;
List<IProjectContent> referencedContents = new List<IProjectContent>();
/// <summary>
/// Gets the namespaces that will be added when the
/// AddNamespaceContents method is called.
/// </summary>
public List<string> NamespacesToAdd {
get { return namespacesToAdd; }
}
/// <summary>
/// Gets whether the NamespaceExists method was called.
/// </summary>
public bool NamespaceExistsCalled {
get { return namespaceExistsCalled; }
}
public string NamespacePassedToNamespaceExistsMethod {
get { return namespacePassedToNamespaceExistsMethod; }
}
/// <summary>
/// Gets or sets the SearchTypeResult to return from the
/// SearchType method.
/// </summary>
public SearchTypeResult SearchTypeResultToReturn {
get { return searchTypeResult; }
set { searchTypeResult = value; }
}
/// <summary>
/// Gets whether the SearchType method was called.
/// </summary>
public bool SearchTypeCalled {
get { return searchTypeCalled; }
}
/// <summary>
/// Gets the search type request passed to the SearchType method.
/// </summary>
public SearchTypeRequest SearchTypeRequest {
get { return searchTypeRequest; }
}
public void SetClassToReturnFromGetClass(string className, IClass classToReturn)
{
classToReturnFromGetClass = classToReturn;
classNameForGetClass = className;
}
/// <summary>
/// Gets the name passed to the GetClass method.
/// </summary>
public string GetClassName {
get { return getClassName; }
}
public string NamespacePassedToGetNamespaceContentsMethod {
get { return namespacePassedToGetNamespaceContentsMethod; }
}
#region IProjectContent
public event EventHandler ReferencedContentsChanged;
public LanguageProperties Language {
get { return language; }
}
public XmlDoc XmlDoc {
get {
return null;
}
}
public bool IsUpToDate {
get {
return true;
}
}
public ICollection<IClass> Classes {
get {
throw new NotImplementedException();
}
}
public ICollection<string> NamespaceNames {
get {
List<string> names = new List<string>();
foreach (string existingNamespace in namespaceContents.Keys) {
names.Add(existingNamespace);
}
return names;
}
}
public ICollection<IProjectContent> ReferencedContents {
get { return this.referencedContents; }
}
public IUsing DefaultImports {
get { return null; }
}
public object Project {
get { return project; }
set { project = value; }
}
public SystemTypes SystemTypes {
get {
return new SystemTypes(this);
}
}
public string GetXmlDocumentation(string memberTag)
{
return null;
}
public void AddClassToNamespaceList(IClass addClass)
{
throw new NotImplementedException();
}
public void RemoveCompilationUnit(ICompilationUnit oldUnit)
{
throw new NotImplementedException();
}
public void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName)
{
throw new NotImplementedException();
}
public IClass GetClass(string typeName, int typeParameterCount)
{
getClassName = typeName;
// If a class name is specified then only return a class
// if we have a match.
if (classNameForGetClass != null) {
if (typeName == classNameForGetClass) {
return classToReturnFromGetClass;
} else {
return null;
}
}
return classToReturnFromGetClass;
}
public void AddExistingNamespaceContents(string namespaceName, List<ICompletionEntry> items)
{
namespaceContents.Add(namespaceName, items);
}
public bool NamespaceExists(string name)
{
namespaceExistsCalled = true;
namespacePassedToNamespaceExistsMethod = name;
return namespaceContents.ContainsKey(name);
}
public List<ICompletionEntry> GetNamespaceContents(string nameSpace)
{
namespacePassedToGetNamespaceContentsMethod = nameSpace;
List<ICompletionEntry> items;
if (namespaceContents.TryGetValue(nameSpace, out items)) {
return items;
}
return new List<ICompletionEntry>();
}
public IClass GetClass(string typeName, int typeParameterCount, LanguageProperties language, GetClassOptions options)
{
return GetClass(typeName, typeParameterCount);
}
public bool NamespaceExists(string name, LanguageProperties language, bool lookInReferences)
{
throw new NotImplementedException();
}
public void AddNamespaceContents(List<ICompletionEntry> list, string subNameSpace, LanguageProperties language, bool lookInReferences)
{
// Add the namespaces to the list.
foreach (string ns in namespacesToAdd) {
list.Add(new NamespaceEntry(ns));
}
// Add the classes in this project content.
foreach (IClass c in classesInProjectContent) {
list.Add(c);
}
}
/// <summary>
/// Gets the list of classes that will be added to the list
/// when the AddNamespaceContents is called.
/// </summary>
public List<IClass> ClassesInProjectContent {
get { return classesInProjectContent; }
}
public string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn)
{
throw new NotImplementedException();
}
public SearchTypeResult SearchType(SearchTypeRequest request)
{
searchTypeCalled = true;
searchTypeRequest = request;
return searchTypeResult;
}
public IClass GetClassByReflectionName(string fullMemberName, bool lookInReferences)
{
throw new NotImplementedException();
}
public FilePosition GetPosition(IEntity entity)
{
throw new NotImplementedException();
}
public void Dispose()
{
throw new NotImplementedException();
}
public IList<IAttribute> GetAssemblyAttributes()
{
throw new NotImplementedException();
}
public bool InternalsVisibleTo(IProjectContent otherProjectContent)
{
throw new NotImplementedException();
}
public string AssemblyName {
get {
throw new NotImplementedException();
}
}
public List<ICompletionEntry> GetAllContents()
{
throw new NotImplementedException();
}
public void AddAllContents(List<ICompletionEntry> list, LanguageProperties language, bool lookInReferences)
{
throw new NotImplementedException();
}
#endregion
protected virtual void OnReferencedContentsChanged(EventArgs e)
{
if (ReferencedContentsChanged != null) {
ReferencedContentsChanged(this, e);
}
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.Scripting.Tests.Utils
//{
// public class MockProjectContent : IProjectContent
// {
// string namespacePassedToNamespaceExistsMethod;
// List<string> namespacesToAdd = new List<string>();
// SearchTypeResult searchTypeResult;
// bool searchTypeCalled;
// SearchTypeRequest searchTypeRequest;
// IClass classToReturnFromGetClass;
// string getClassName;
// List<IClass> classesInProjectContent = new List<IClass>();
// string namespacePassedToGetNamespaceContentsMethod;
// string classNameForGetClass;
// bool namespaceExistsCalled;
// object project;
// Dictionary<string, List<ICompletionEntry>> namespaceContents = new Dictionary<string, List<ICompletionEntry>>();
// LanguageProperties language = LanguageProperties.CSharp;
// List<IProjectContent> referencedContents = new List<IProjectContent>();
//
// /// <summary>
// /// Gets the namespaces that will be added when the
// /// AddNamespaceContents method is called.
// /// </summary>
// public List<string> NamespacesToAdd {
// get { return namespacesToAdd; }
// }
//
// /// <summary>
// /// Gets whether the NamespaceExists method was called.
// /// </summary>
// public bool NamespaceExistsCalled {
// get { return namespaceExistsCalled; }
// }
//
// public string NamespacePassedToNamespaceExistsMethod {
// get { return namespacePassedToNamespaceExistsMethod; }
// }
//
// /// <summary>
// /// Gets or sets the SearchTypeResult to return from the
// /// SearchType method.
// /// </summary>
// public SearchTypeResult SearchTypeResultToReturn {
// get { return searchTypeResult; }
// set { searchTypeResult = value; }
// }
//
// /// <summary>
// /// Gets whether the SearchType method was called.
// /// </summary>
// public bool SearchTypeCalled {
// get { return searchTypeCalled; }
// }
//
// /// <summary>
// /// Gets the search type request passed to the SearchType method.
// /// </summary>
// public SearchTypeRequest SearchTypeRequest {
// get { return searchTypeRequest; }
// }
//
// public void SetClassToReturnFromGetClass(string className, IClass classToReturn)
// {
// classToReturnFromGetClass = classToReturn;
// classNameForGetClass = className;
// }
//
// /// <summary>
// /// Gets the name passed to the GetClass method.
// /// </summary>
// public string GetClassName {
// get { return getClassName; }
// }
//
// public string NamespacePassedToGetNamespaceContentsMethod {
// get { return namespacePassedToGetNamespaceContentsMethod; }
// }
//
// #region IProjectContent
// public event EventHandler ReferencedContentsChanged;
//
// public LanguageProperties Language {
// get { return language; }
// }
//
// public XmlDoc XmlDoc {
// get {
// return null;
// }
// }
//
// public bool IsUpToDate {
// get {
// return true;
// }
// }
//
// public ICollection<IClass> Classes {
// get {
// throw new NotImplementedException();
// }
// }
//
// public ICollection<string> NamespaceNames {
// get {
// List<string> names = new List<string>();
// foreach (string existingNamespace in namespaceContents.Keys) {
// names.Add(existingNamespace);
// }
// return names;
// }
// }
//
// public ICollection<IProjectContent> ReferencedContents {
// get { return this.referencedContents; }
// }
//
// public IUsing DefaultImports {
// get { return null; }
// }
//
// public object Project {
// get { return project; }
// set { project = value; }
// }
//
// public SystemTypes SystemTypes {
// get {
// return new SystemTypes(this);
// }
// }
//
// public string GetXmlDocumentation(string memberTag)
// {
// return null;
// }
//
// public void AddClassToNamespaceList(IClass addClass)
// {
// throw new NotImplementedException();
// }
//
// public void RemoveCompilationUnit(ICompilationUnit oldUnit)
// {
// throw new NotImplementedException();
// }
//
// public void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName)
// {
// throw new NotImplementedException();
// }
//
// public IClass GetClass(string typeName, int typeParameterCount)
// {
// getClassName = typeName;
//
// // If a class name is specified then only return a class
// // if we have a match.
// if (classNameForGetClass != null) {
// if (typeName == classNameForGetClass) {
// return classToReturnFromGetClass;
// } else {
// return null;
// }
// }
// return classToReturnFromGetClass;
// }
//
// public void AddExistingNamespaceContents(string namespaceName, List<ICompletionEntry> items)
// {
// namespaceContents.Add(namespaceName, items);
// }
//
// public bool NamespaceExists(string name)
// {
// namespaceExistsCalled = true;
// namespacePassedToNamespaceExistsMethod = name;
//
// return namespaceContents.ContainsKey(name);
// }
//
// public List<ICompletionEntry> GetNamespaceContents(string nameSpace)
// {
// namespacePassedToGetNamespaceContentsMethod = nameSpace;
//
// List<ICompletionEntry> items;
// if (namespaceContents.TryGetValue(nameSpace, out items)) {
// return items;
// }
// return new List<ICompletionEntry>();
// }
//
// public IClass GetClass(string typeName, int typeParameterCount, LanguageProperties language, GetClassOptions options)
// {
// return GetClass(typeName, typeParameterCount);
// }
//
// public bool NamespaceExists(string name, LanguageProperties language, bool lookInReferences)
// {
// throw new NotImplementedException();
// }
//
// public void AddNamespaceContents(List<ICompletionEntry> list, string subNameSpace, LanguageProperties language, bool lookInReferences)
// {
// // Add the namespaces to the list.
// foreach (string ns in namespacesToAdd) {
// list.Add(new NamespaceEntry(ns));
// }
//
// // Add the classes in this project content.
// foreach (IClass c in classesInProjectContent) {
// list.Add(c);
// }
// }
//
// /// <summary>
// /// Gets the list of classes that will be added to the list
// /// when the AddNamespaceContents is called.
// /// </summary>
// public List<IClass> ClassesInProjectContent {
// get { return classesInProjectContent; }
// }
//
// public string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn)
// {
// throw new NotImplementedException();
// }
//
// public SearchTypeResult SearchType(SearchTypeRequest request)
// {
// searchTypeCalled = true;
// searchTypeRequest = request;
// return searchTypeResult;
// }
//
// public IClass GetClassByReflectionName(string fullMemberName, bool lookInReferences)
// {
// throw new NotImplementedException();
// }
//
// public FilePosition GetPosition(IEntity entity)
// {
// throw new NotImplementedException();
// }
//
// public void Dispose()
// {
// throw new NotImplementedException();
// }
//
// public IList<IAttribute> GetAssemblyAttributes()
// {
// throw new NotImplementedException();
// }
//
// public bool InternalsVisibleTo(IProjectContent otherProjectContent)
// {
// throw new NotImplementedException();
// }
//
// public string AssemblyName {
// get {
// throw new NotImplementedException();
// }
// }
//
// public List<ICompletionEntry> GetAllContents()
// {
// throw new NotImplementedException();
// }
//
// public void AddAllContents(List<ICompletionEntry> list, LanguageProperties language, bool lookInReferences)
// {
// throw new NotImplementedException();
// }
// #endregion
//
// protected virtual void OnReferencedContentsChanged(EventArgs e)
// {
// if (ReferencedContentsChanged != null) {
// ReferencedContentsChanged(this, e);
// }
// }
// }
//}

7
src/AddIns/BackendBindings/Scripting/Test/Utils/MockTextEditor.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Windows.Input;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.Scripting.Tests.Utils
@ -113,5 +114,11 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -113,5 +114,11 @@ namespace ICSharpCode.Scripting.Tests.Utils
{
return null;
}
public System.Collections.Generic.IList<ICSharpCode.SharpDevelop.Refactoring.IContextActionProvider> ContextActionProviders {
get {
throw new NotImplementedException();
}
}
}
}

4
src/AddIns/BackendBindings/Scripting/Test/Utils/MockTextEditorViewContent.cs

@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
using System;
using ICSharpCode.AvalonEdit;
using ICSharpCode.SharpDevelop;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Scripting.Tests.Utils
{

7
src/AddIns/BackendBindings/Scripting/Test/Utils/MockViewContent.cs

@ -3,11 +3,10 @@ @@ -3,11 +3,10 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Scripting.Tests.Utils
{
@ -234,7 +233,7 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -234,7 +233,7 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
}
public object GetService(Type serviceType)
public virtual object GetService(Type serviceType)
{
return null;
}

8
src/AddIns/BackendBindings/Scripting/Test/Utils/MockWorkbench.cs

@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Gui; @@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.Scripting.Tests.Utils
{
public class MockWorkbench : IScriptingWorkbench
{
{
public FakeScriptingConsolePad FakeScriptingConsolePad = new FakeScriptingConsolePad();
public MockEditableViewContent ActiveMockEditableViewContent;
@ -22,7 +22,7 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -22,7 +22,7 @@ namespace ICSharpCode.Scripting.Tests.Utils
{
MockEditableViewContent viewContent = new MockEditableViewContent();
viewContent.PrimaryFileName = new FileName(fileName);
MockWorkbench workbench = new MockWorkbench();
workbench.ActiveMockEditableViewContent = viewContent;
@ -31,8 +31,8 @@ namespace ICSharpCode.Scripting.Tests.Utils @@ -31,8 +31,8 @@ namespace ICSharpCode.Scripting.Tests.Utils
public IViewContent ActiveViewContent {
get { return ActiveMockEditableViewContent; }
}
}
public IScriptingConsolePad GetScriptingConsolePad()
{
return FakeScriptingConsolePad;

146
src/AddIns/BackendBindings/Scripting/Test/Utils/TestableScriptingDesignerGenerator.cs

@ -1,73 +1,73 @@ @@ -1,73 +1,73 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using UnitTesting.Tests.Utils;
namespace ICSharpCode.Scripting.Tests.Utils
{
public class TestableScriptingDesignerGenerator : ScriptingDesignerGenerator
{
public bool IsParseFileCalled;
public ParseInformation ParseInfoToReturnFromParseFile;
public string FileNamePassedToParseFile;
public string TextContentPassedToParseFile;
public FakeCodeDomSerializer SerializerToReturnFromCreateCodeDomSerializer;
public TestableScriptingDesignerGenerator(ITextEditorOptions textEditorOptions)
: base(textEditorOptions)
{
}
public ParseInformation CreateParseInfoWithOneClass()
{
MockClass c = CreateClass();
return new ParseInformation(c.CompilationUnit);
}
MockClass CreateClass()
{
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
c.CompilationUnit.Classes.Add(c);
return c;
}
protected override ParseInformation ParseFile(string fileName, string textContent)
{
IsParseFileCalled = true;
FileNamePassedToParseFile = fileName;
TextContentPassedToParseFile = textContent;
return ParseInfoToReturnFromParseFile;
}
public ParseInformation CreateParseInfoWithOneMethod(string name)
{
MockMethod method = CreateMethod(name);
return new ParseInformation(method.CompilationUnit);
}
MockMethod CreateMethod(string name)
{
MockClass c = CreateClass();
MockMethod method = new MockMethod(c, name);
c.Methods.Add(method);
return method;
}
public ParseInformation CreateParseInfoWithOneMethodWithTwoParameters(string name)
{
MockMethod method = CreateMethod(name);
method.Parameters.Add(new MockParameter());
method.Parameters.Add(new MockParameter());
return new ParseInformation(method.CompilationUnit);
}
public override IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
{
return SerializerToReturnFromCreateCodeDomSerializer;
}
}
}
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.SharpDevelop.Dom;
//using ICSharpCode.SharpDevelop.Editor;
//using UnitTesting.Tests.Utils;
//
//namespace ICSharpCode.Scripting.Tests.Utils
//{
// public class TestableScriptingDesignerGenerator : ScriptingDesignerGenerator
// {
// public bool IsParseFileCalled;
// public ParseInformation ParseInfoToReturnFromParseFile;
// public string FileNamePassedToParseFile;
// public string TextContentPassedToParseFile;
// public FakeCodeDomSerializer SerializerToReturnFromCreateCodeDomSerializer;
//
// public TestableScriptingDesignerGenerator(ITextEditorOptions textEditorOptions)
// : base(textEditorOptions)
// {
// }
//
// public ParseInformation CreateParseInfoWithOneClass()
// {
// MockClass c = CreateClass();
// return new ParseInformation(c.CompilationUnit);
// }
//
// MockClass CreateClass()
// {
// MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
// c.CompilationUnit.Classes.Add(c);
// return c;
// }
//
// protected override ParseInformation ParseFile(string fileName, string textContent)
// {
// IsParseFileCalled = true;
// FileNamePassedToParseFile = fileName;
// TextContentPassedToParseFile = textContent;
//
// return ParseInfoToReturnFromParseFile;
// }
//
// public ParseInformation CreateParseInfoWithOneMethod(string name)
// {
// MockMethod method = CreateMethod(name);
// return new ParseInformation(method.CompilationUnit);
// }
//
// MockMethod CreateMethod(string name)
// {
// MockClass c = CreateClass();
// MockMethod method = new MockMethod(c, name);
// c.Methods.Add(method);
// return method;
// }
//
// public ParseInformation CreateParseInfoWithOneMethodWithTwoParameters(string name)
// {
// MockMethod method = CreateMethod(name);
// method.Parameters.Add(new MockParameter());
// method.Parameters.Add(new MockParameter());
// return new ParseInformation(method.CompilationUnit);
// }
//
// public override IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
// {
// return SerializerToReturnFromCreateCodeDomSerializer;
// }
// }
//}

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

Loading…
Cancel
Save