Browse Source

Start restructuring of SD Base:

- the static class "SD" is providing services
- service interfaces are defined in ICSharpCode.SharpDevelop.dll
- services are implemented in SharpDevelop.exe or in AddIns
- ICSharpCode.SharpDevelop.Sda is moved into SharpDevelop.exe

Also added XmlEditor.Tests to SharpDevelop.Tests.sln
newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
fbced09b89
  1. 2
      .gitignore
  2. 86
      SharpDevelop.Tests.sln
  3. 25
      SharpDevelop.sln
  4. 1
      src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/MockTextEditor.cs
  5. 11
      src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj
  6. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/Editor/DefaultXmlEditorOptionsTestFixture.cs
  7. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Editor/ElementEndAddedAfterGreaterThanCharTypedTestFixture.cs
  8. 17
      src/AddIns/DisplayBindings/XmlEditor/Test/Editor/IndentChildElementEndTagAfterNewLineTypedTestFixture.cs
  9. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Editor/IndentLinesTests.cs
  10. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Editor/NoElementEndAddedAfterGreaterThanCharTypedTests.cs
  11. 5
      src/AddIns/DisplayBindings/XmlEditor/Test/Editor/SurroundTextWithCommentBlockTestFixture.cs
  12. 1
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/AttributeTextInFoldIsXmlEncodedTestFixture.cs
  13. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/EmptyCommentDoesNotCreateFoldTestFixture.cs
  14. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/MultiLineCommentFoldTestFixture.cs
  15. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/QualifiedElementFoldTestFixture.cs
  16. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/QualifiedElementWithNoDefinedNamespaceFoldTestFixture.cs
  17. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/ShowElementAttributesInFoldTestFixture.cs
  18. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/SingleEmptyElementFoldTestFixture.cs
  19. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/SingleLineElementDoesNotCreateFoldTestFixture.cs
  20. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/SingleRootElementFoldTestFixture.cs
  21. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/TwoElementFoldsTestFixture.cs
  22. 27
      src/AddIns/DisplayBindings/XmlEditor/Test/Folding/XmlFoldingManagerTests.cs
  23. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/TreeControlViewStateTestFixture.cs
  24. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/FakeXmlFoldParser.cs
  25. 53
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockCaret.cs
  26. 87
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs
  27. 53
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocumentLine.cs
  28. 40
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockParserService.cs
  29. 74
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextBuffer.cs
  30. 10
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditor.cs
  31. 1
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditorProviderViewContent.cs
  32. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs
  33. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlViewContent.cs
  34. 49
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockCaretTests.cs
  35. 28
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockDocumentLineTests.cs
  36. 49
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockParserServiceTests.cs
  37. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockTextBufferTests.cs
  38. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/XmlFoldParserHelper.cs
  39. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespacePropertiesLoaded.cs
  40. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespacePropertiesSaved.cs
  41. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/RemoveXPathHighlightingCommandTestFixture.cs
  42. 1
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/SingleXPathQueryElementMarkedTestFixture.cs
  43. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathNodeTextMarkerTests.cs
  44. 5
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathQueryHistoryTestFixture.cs
  45. 23
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
  46. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj.user
  47. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/app.config
  48. 8
      src/AddIns/Misc/SearchAndReplace/Test/SearchAndReplace.Tests.csproj
  49. 13
      src/Main/Base/Project/Configuration/AssemblyInfo.cs
  50. 3
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  51. 24
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  52. 27
      src/Main/Base/Project/Src/Gui/IWorkbench.cs
  53. 3
      src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs
  54. 27
      src/Main/Base/Project/Src/Gui/Workbench/ViewContentEventHandler.cs
  55. 3
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  56. 7
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  57. 6
      src/Main/Base/Project/Src/Services/SD.cs
  58. 95
      src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs
  59. 24
      src/Main/Base/Test/ConsoleApp/ConsoleApp.csproj
  60. 6
      src/Main/Base/Test/ConsoleApp/ConsoleApp.sln
  61. 6
      src/Main/Base/Test/ConsoleApp/app.config
  62. BIN
      src/Main/Base/Test/ConsoleApp/bin/ConsoleApp.exe
  63. 7
      src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj
  64. 127
      src/Main/Base/Test/Utils/MockTextMarkerService.cs
  65. 1
      src/Main/Core/Project/ICSharpCode.Core.csproj
  66. 45
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/ServiceDoozer.cs
  67. 1
      src/Main/Core/Project/Src/AddInTree/AddInTree.cs
  68. 12
      src/Main/Core/Project/Src/Services/ServiceManager.cs
  69. 18
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Configuration/AssemblyInfo.cs
  70. 216
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj
  71. 242
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Ambience.cs
  72. 52
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/BusyManager.cs
  73. 606
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/CSharpAmbience.cs
  74. 55
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/CSharpExpressionContext.cs
  75. 1057
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/ExpressionFinder.cs
  76. 340
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/OverloadResolution.cs
  77. 480
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/TypeInference.cs
  78. 564
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs
  79. 130
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ClassFinder.cs
  80. 285
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs
  81. 129
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/DiffUtility.cs
  82. 41
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/DomCache.cs
  83. 382
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/EasyCodeDom.cs
  84. 486
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExpressionContext.cs
  85. 104
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExtensionMethods.cs
  86. 114
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/FilePosition.cs
  87. 31
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/FoldingRegion.cs
  88. 275
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/FusionNative.cs
  89. 198
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/GacInterop.cs
  90. 62
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/HostCallback.cs
  91. 24
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/IComment.cs
  92. 66
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/IExpressionFinder.cs
  93. 22
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/IResolver.cs
  94. 358
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AbstractEntity.cs
  95. 108
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AbstractMember.cs
  96. 136
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AbstractReturnType.cs
  97. 190
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AnonymousMethodReturnType.cs
  98. 157
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/ArrayReturnType.cs
  99. 47
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AttributeReturnType.cs
  100. 91
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/BoundTypeParameter.cs
  101. Some files were not shown because too many files have changed in this diff Show More

2
.gitignore vendored

@ -15,7 +15,7 @@ bin/
/src/Tools/UpdateAssemblyInfo/bin /src/Tools/UpdateAssemblyInfo/bin
/src/Setup/SharpDevelop.Setup.wixproj.user /src/Setup/SharpDevelop.Setup.wixproj.user
/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.dll.config /src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.dll.config
/src/Main/StartUp/Project/SharpDevelop.exe.config /src/Main/SharpDevelop/SharpDevelop.exe.config
/src/Main/GlobalAssemblyInfo.cs /src/Main/GlobalAssemblyInfo.cs
/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.cs /src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.cs

86
SharpDevelop.Tests.sln

@ -20,13 +20,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentati
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "src\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "src\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "src\Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "src\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "src\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "src\Main\StartUp\Project\StartUp.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDevelop", "src\Main\SharpDevelop\SharpDevelop.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{2A232EF1-EB95-41C6-B63A-C106E0C95D3C}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{2A232EF1-EB95-41C6-B63A-C106E0C95D3C}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
@ -38,6 +36,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit.Test
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NRefactory", "NRefactory", "{E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NRefactory", "NRefactory", "{E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
TODOnewNR.txt = TODOnewNR.txt
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "src\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "src\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}"
@ -80,6 +79,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppBinding", "src\AddIns\Ba
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding.Tests", "src\AddIns\BackendBindings\CSharpBinding\Tests\CSharpBinding.Tests.csproj", "{52006F3F-3156-45DE-89D8-C4813694FBA4}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding.Tests", "src\AddIns\BackendBindings\CSharpBinding\Tests\CSharpBinding.Tests.csproj", "{52006F3F-3156-45DE-89D8-C4813694FBA4}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding", "src\AddIns\BackendBindings\XamlBinding\XamlBinding\XamlBinding.csproj", "{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
@ -106,6 +107,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector", "src\A
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector.AddIn", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector.AddIn\UsageDataCollector.AddIn.csproj", "{0008FCE9-9EB4-4E2E-979B-553278E5BBA6}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector.AddIn", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector.AddIn\UsageDataCollector.AddIn.csproj", "{0008FCE9-9EB4-4E2E-979B-553278E5BBA6}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchAndReplace.Tests", "src\AddIns\Misc\SearchAndReplace\Test\SearchAndReplace.Tests.csproj", "{A569DCC1-C608-45FD-B770-4F79335EF154}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
@ -114,6 +117,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\Add
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexEditor", "src\AddIns\DisplayBindings\HexEditor\Project\HexEditor.csproj", "{E618A9CD-A39F-4925-A538-E8A3FEF24E54}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexEditor", "src\AddIns\DisplayBindings\HexEditor\Project\HexEditor.csproj", "{E618A9CD-A39F-4925-A538-E8A3FEF24E54}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "src\AddIns\DisplayBindings\XmlEditor\Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor.Tests", "src\AddIns\DisplayBindings\XmlEditor\Test\XmlEditor.Tests.csproj", "{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}"
EndProject
Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}" Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}"
EndProject EndProject
Global Global
@ -138,10 +145,6 @@ Global
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.Build.0 = Debug|Any CPU {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.Build.0 = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.ActiveCfg = Release|Any CPU {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.ActiveCfg = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.Build.0 = Release|Any CPU {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.Build.0 = Release|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.Build.0 = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -150,10 +153,6 @@ Global
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.Build.0 = Debug|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.Build.0 = Release|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.ActiveCfg = Release|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -386,6 +385,66 @@ Global
{52006F3F-3156-45DE-89D8-C4813694FBA4}.Release|Win32.ActiveCfg = Release|Any CPU {52006F3F-3156-45DE-89D8-C4813694FBA4}.Release|Win32.ActiveCfg = Release|Any CPU
{52006F3F-3156-45DE-89D8-C4813694FBA4}.Release|x86.Build.0 = Release|Any CPU {52006F3F-3156-45DE-89D8-C4813694FBA4}.Release|x86.Build.0 = Release|Any CPU
{52006F3F-3156-45DE-89D8-C4813694FBA4}.Release|x86.ActiveCfg = Release|Any CPU {52006F3F-3156-45DE-89D8-C4813694FBA4}.Release|x86.ActiveCfg = Release|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Debug|Win32.Build.0 = Debug|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Debug|Win32.ActiveCfg = Debug|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Debug|x86.Build.0 = Debug|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Debug|x86.ActiveCfg = Debug|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Release|Any CPU.Build.0 = Release|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Release|Win32.Build.0 = Release|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Release|Win32.ActiveCfg = Release|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Release|x86.Build.0 = Release|Any CPU
{DCA2703D-250A-463E-A68A-07ED105AE6BD}.Release|x86.ActiveCfg = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Debug|Win32.Build.0 = Debug|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Debug|Win32.ActiveCfg = Debug|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Debug|x86.Build.0 = Debug|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Debug|x86.ActiveCfg = Debug|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|Any CPU.Build.0 = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|Win32.Build.0 = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|Win32.ActiveCfg = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|x86.Build.0 = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|x86.ActiveCfg = Release|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Debug|Win32.Build.0 = Debug|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Debug|Win32.ActiveCfg = Debug|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Debug|x86.Build.0 = Debug|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Debug|x86.ActiveCfg = Debug|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Release|Any CPU.Build.0 = Release|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Release|Win32.Build.0 = Release|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Release|Win32.ActiveCfg = Release|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Release|x86.Build.0 = Release|Any CPU
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}.Release|x86.ActiveCfg = Release|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Debug|Win32.Build.0 = Debug|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Debug|Win32.ActiveCfg = Debug|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Debug|x86.Build.0 = Debug|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Debug|x86.ActiveCfg = Debug|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Release|Any CPU.Build.0 = Release|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Release|Win32.Build.0 = Release|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Release|Win32.ActiveCfg = Release|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Release|x86.Build.0 = Release|Any CPU
{A569DCC1-C608-45FD-B770-4F79335EF154}.Release|x86.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Win32.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|x86.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|x86.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Win32.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Win32.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|x86.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -398,7 +457,6 @@ Global
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {7E4A7172-7FF5-48D0-B719-7CD959DD1AC9} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{80318B5F-A25D-45AB-8A95-EF31D2370A4C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
@ -423,6 +481,7 @@ Global
{E954F3CB-A446-492F-A664-2B376EBC86E8} = {E0646C25-36F2-4524-969F-FA621353AB94} {E954F3CB-A446-492F-A664-2B376EBC86E8} = {E0646C25-36F2-4524-969F-FA621353AB94}
{70966F84-74C9-4067-A379-0C674A929233} = {E0646C25-36F2-4524-969F-FA621353AB94} {70966F84-74C9-4067-A379-0C674A929233} = {E0646C25-36F2-4524-969F-FA621353AB94}
{52006F3F-3156-45DE-89D8-C4813694FBA4} = {E0646C25-36F2-4524-969F-FA621353AB94} {52006F3F-3156-45DE-89D8-C4813694FBA4} = {E0646C25-36F2-4524-969F-FA621353AB94}
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {E0646C25-36F2-4524-969F-FA621353AB94}
{80F76D10-0B44-4D55-B4BD-DAEB5464090C} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} {80F76D10-0B44-4D55-B4BD-DAEB5464090C} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{9196DD8A-B4D4-4780-8742-C5762E547FC2} = {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} {7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
@ -431,9 +490,12 @@ Global
{D022A6CE-7438-41E8-AC64-F2DE18EC54C6} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} {D022A6CE-7438-41E8-AC64-F2DE18EC54C6} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} {64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{DEFC8584-BEC3-4921-BD0F-40482E450B7B} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} {DEFC8584-BEC3-4921-BD0F-40482E450B7B} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{A569DCC1-C608-45FD-B770-4F79335EF154} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} {6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B}
{0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} {0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B}
{0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} {0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {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}
{FC0FE702-A87D-4D70-A9B6-1ECCD611125F} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

25
SharpDevelop.sln

@ -16,13 +16,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentati
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "src\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "src\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "src\Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "src\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "src\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "src\Main\StartUp\Project\StartUp.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDevelop", "src\Main\SharpDevelop\SharpDevelop.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{2A232EF1-EB95-41C6-B63A-C106E0C95D3C}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{2A232EF1-EB95-41C6-B63A-C106E0C95D3C}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
@ -133,10 +131,6 @@ Global
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.Build.0 = Debug|Any CPU {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.Build.0 = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.ActiveCfg = Release|Any CPU {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.ActiveCfg = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.Build.0 = Release|Any CPU {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.Build.0 = Release|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.Build.0 = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -145,10 +139,6 @@ Global
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.Build.0 = Debug|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.Build.0 = Release|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.ActiveCfg = Release|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -417,6 +407,18 @@ Global
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|Win32.ActiveCfg = Release|Any CPU {7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|Win32.ActiveCfg = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|x86.Build.0 = Release|Any CPU {7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|x86.Build.0 = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|x86.ActiveCfg = Release|Any CPU {7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|x86.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Win32.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|x86.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|x86.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Win32.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Win32.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|x86.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -427,7 +429,6 @@ Global
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {7E4A7172-7FF5-48D0-B719-7CD959DD1AC9} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{80318B5F-A25D-45AB-8A95-EF31D2370A4C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}

1
src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/MockTextEditor.cs

@ -7,7 +7,6 @@ using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using ICSharpCode.SharpDevelop.Editor.CodeCompletion;

11
src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj

@ -7,13 +7,14 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.XamlBinding.Tests</RootNamespace> <RootNamespace>ICSharpCode.XamlBinding.Tests</RootNamespace>
<AssemblyName>ICSharpCode.XamlBinding.Tests</AssemblyName> <AssemblyName>ICSharpCode.XamlBinding.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath> <OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -92,10 +93,6 @@
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project> <Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
<Name>ICSharpCode.AvalonEdit</Name> <Name>ICSharpCode.AvalonEdit</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> <Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name> <Name>ICSharpCode.SharpDevelop</Name>
@ -108,10 +105,6 @@
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project> <Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project>
<Name>ICSharpCode.Core.Presentation</Name> <Name>ICSharpCode.Core.Presentation</Name>
</ProjectReference> </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="..\..\..\DisplayBindings\XmlEditor\Project\XmlEditor.csproj"> <ProjectReference Include="..\..\..\DisplayBindings\XmlEditor\Project\XmlEditor.csproj">
<Project>{DCA2703D-250A-463E-A68A-07ED105AE6BD}</Project> <Project>{DCA2703D-250A-463E-A68A-07ED105AE6BD}</Project>
<Name>XmlEditor</Name> <Name>XmlEditor</Name>

4
src/AddIns/DisplayBindings/XmlEditor/Test/Editor/DefaultXmlEditorOptionsTestFixture.cs

@ -2,8 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.ComponentModel;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
@ -104,7 +106,7 @@ namespace XmlEditor.Tests.Editor
{ {
options.PropertyChanged += OptionsPropertyChanged; options.PropertyChanged += OptionsPropertyChanged;
properties.Set(XmlEditorOptions.ShowAttributesWhenFoldedPropertyName, true); properties.Set(XmlEditorOptions.ShowAttributesWhenFoldedPropertyName, true);
Assert.AreEqual(XmlEditorOptions.ShowAttributesWhenFoldedPropertyName, propertyChangedEventArgs.Key); Assert.AreEqual(XmlEditorOptions.ShowAttributesWhenFoldedPropertyName, propertyChangedEventArgs.PropertyName);
} }
void OptionsPropertyChanged(object source, PropertyChangedEventArgs e) void OptionsPropertyChanged(object source, PropertyChangedEventArgs e)

6
src/AddIns/DisplayBindings/XmlEditor/Test/Editor/ElementEndAddedAfterGreaterThanCharTypedTestFixture.cs

@ -2,9 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
@ -18,7 +18,7 @@ namespace XmlEditor.Tests.Editor
XmlFormattingStrategy formattingStrategy; XmlFormattingStrategy formattingStrategy;
MockTextEditor textEditor; MockTextEditor textEditor;
MockTextEditorOptions options; MockTextEditorOptions options;
AvalonEditDocumentAdapter document; IDocument document;
TextDocument textDocument; TextDocument textDocument;
[SetUp] [SetUp]
@ -31,7 +31,7 @@ namespace XmlEditor.Tests.Editor
textEditor.Options = options; textEditor.Options = options;
textDocument = new TextDocument(); textDocument = new TextDocument();
document = new AvalonEditDocumentAdapter(textDocument, null); document = textDocument;
textEditor.SetDocument(document); textEditor.SetDocument(document);
document.Text = document.Text =

17
src/AddIns/DisplayBindings/XmlEditor/Test/Editor/IndentChildElementEndTagAfterNewLineTypedTestFixture.cs

@ -2,12 +2,13 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
using Rhino.Mocks;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Editor namespace XmlEditor.Tests.Editor
@ -18,8 +19,8 @@ namespace XmlEditor.Tests.Editor
XmlFormattingStrategy formattingStrategy; XmlFormattingStrategy formattingStrategy;
MockTextEditor textEditor; MockTextEditor textEditor;
MockTextEditorOptions options; MockTextEditorOptions options;
MockDocumentLine docLine; IDocumentLine docLine;
AvalonEditDocumentAdapter document; IDocument document;
TextDocument textDocument; TextDocument textDocument;
[SetUp] [SetUp]
@ -32,7 +33,7 @@ namespace XmlEditor.Tests.Editor
textEditor.Options = options; textEditor.Options = options;
textDocument = new TextDocument(); textDocument = new TextDocument();
document = new AvalonEditDocumentAdapter(textDocument, null); document = textDocument;
textEditor.SetDocument(document); textEditor.SetDocument(document);
document.Text = document.Text =
@ -41,8 +42,8 @@ namespace XmlEditor.Tests.Editor
"</child>\r\n" + "</child>\r\n" +
"</root>\r\n"; "</root>\r\n";
docLine = new MockDocumentLine(); docLine = MockRepository.GenerateStub<IDocumentLine>();
docLine.LineNumber = 3; docLine.Stub(l => l.LineNumber).Return(3);
formattingStrategy.IndentLine(textEditor, docLine); formattingStrategy.IndentLine(textEditor, docLine);
} }
@ -77,8 +78,8 @@ namespace XmlEditor.Tests.Editor
{ {
int line = 3; int line = 3;
int column = 2; int column = 2;
Location expectedLocation = new Location(column, line); var expectedLocation = new TextLocation(line, column);
Assert.AreEqual(expectedLocation, textEditor.Caret.Position); Assert.AreEqual(expectedLocation, textEditor.Caret.Location);
} }
} }
} }

6
src/AddIns/DisplayBindings/XmlEditor/Test/Editor/IndentLinesTests.cs

@ -2,9 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
@ -18,7 +18,7 @@ namespace XmlEditor.Tests.Editor
XmlFormattingStrategy formattingStrategy; XmlFormattingStrategy formattingStrategy;
MockTextEditor textEditor; MockTextEditor textEditor;
MockTextEditorOptions options; MockTextEditorOptions options;
AvalonEditDocumentAdapter document; IDocument document;
TextDocument textDocument; TextDocument textDocument;
[SetUp] [SetUp]
@ -31,7 +31,7 @@ namespace XmlEditor.Tests.Editor
textEditor.Options = options; textEditor.Options = options;
textDocument = new TextDocument(); textDocument = new TextDocument();
document = new AvalonEditDocumentAdapter(textDocument, null); document = textDocument;
textEditor.SetDocument(document); textEditor.SetDocument(document);
} }

6
src/AddIns/DisplayBindings/XmlEditor/Test/Editor/NoElementEndAddedAfterGreaterThanCharTypedTests.cs

@ -2,9 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
@ -18,7 +18,7 @@ namespace XmlEditor.Tests.Editor
XmlFormattingStrategy formattingStrategy; XmlFormattingStrategy formattingStrategy;
MockTextEditor textEditor; MockTextEditor textEditor;
MockTextEditorOptions options; MockTextEditorOptions options;
AvalonEditDocumentAdapter document; IDocument document;
TextDocument textDocument; TextDocument textDocument;
[SetUp] [SetUp]
@ -31,7 +31,7 @@ namespace XmlEditor.Tests.Editor
textEditor.Options = options; textEditor.Options = options;
textDocument = new TextDocument(); textDocument = new TextDocument();
document = new AvalonEditDocumentAdapter(textDocument, null); document = textDocument;
textEditor.SetDocument(document); textEditor.SetDocument(document);
} }

5
src/AddIns/DisplayBindings/XmlEditor/Test/Editor/SurroundTextWithCommentBlockTestFixture.cs

@ -3,6 +3,7 @@
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
@ -16,7 +17,7 @@ namespace XmlEditor.Tests.Editor
XmlFormattingStrategy formattingStrategy; XmlFormattingStrategy formattingStrategy;
MockTextEditor textEditor; MockTextEditor textEditor;
MockTextEditorOptions options; MockTextEditorOptions options;
AvalonEditDocumentAdapter document; IDocument document;
TextDocument textDocument; TextDocument textDocument;
[SetUp] [SetUp]
@ -29,7 +30,7 @@ namespace XmlEditor.Tests.Editor
textEditor.Options = options; textEditor.Options = options;
textDocument = new TextDocument(); textDocument = new TextDocument();
document = new AvalonEditDocumentAdapter(textDocument, null); document = textDocument;
textEditor.SetDocument(document); textEditor.SetDocument(document);
textDocument.Text = textDocument.Text =

1
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/AttributeTextInFoldIsXmlEncodedTestFixture.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/EmptyCommentDoesNotCreateFoldTestFixture.cs

@ -3,7 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/MultiLineCommentFoldTestFixture.cs

@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/QualifiedElementFoldTestFixture.cs

@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/QualifiedElementWithNoDefinedNamespaceFoldTestFixture.cs

@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/ShowElementAttributesInFoldTestFixture.cs

@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/SingleEmptyElementFoldTestFixture.cs

@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/SingleLineElementDoesNotCreateFoldTestFixture.cs

@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/SingleRootElementFoldTestFixture.cs

@ -3,7 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

2
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/TwoElementFoldsTestFixture.cs

@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;

27
src/AddIns/DisplayBindings/XmlEditor/Test/Folding/XmlFoldingManagerTests.cs

@ -4,8 +4,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Folding; using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;
@ -55,7 +56,7 @@ namespace XmlEditor.Tests.Folding
MockDocument expectedSnapshot = new MockDocument(); MockDocument expectedSnapshot = new MockDocument();
fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot); fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot);
ITextBuffer snapshot = xmlFoldingManager.CreateTextEditorSnapshot(); ITextSource snapshot = xmlFoldingManager.CreateTextEditorSnapshot();
Assert.AreEqual(expectedSnapshot, snapshot); Assert.AreEqual(expectedSnapshot, snapshot);
} }
@ -81,7 +82,7 @@ namespace XmlEditor.Tests.Folding
MockDocument expectedSnapshot = new MockDocument(); MockDocument expectedSnapshot = new MockDocument();
fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot); fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot);
ITextBuffer snapshot = xmlFoldingManager.CreateTextEditorSnapshot(); ITextSource snapshot = xmlFoldingManager.CreateTextEditorSnapshot();
IList<FoldingRegion> folds = xmlFoldingManager.GetFolds(snapshot); IList<FoldingRegion> folds = xmlFoldingManager.GetFolds(snapshot);
@ -94,26 +95,6 @@ namespace XmlEditor.Tests.Folding
return new FoldingRegion("a", region); return new FoldingRegion("a", region);
} }
[Test]
public void UpdateFolds_FakeFoldingManagerUsed_FoldsPassedToFakeFoldingManager()
{
CreateXmlFoldingManager();
List<NewFolding> folds = NewFoldingHelper.CreateFoldListWithOneFold();
xmlFoldingManager.UpdateFolds(folds);
NewFoldingHelper.AssertAreEqual(folds, fakeFoldingManager.NewFoldsPassedToUpdateFoldings);
}
[Test]
public void UpdateFolds_FakeFoldingManagerUsed_FirstErrorOffsetPassedToFakeFoldingManagerIsMinusOne()
{
CreateXmlFoldingManager();
List<NewFolding> folds = NewFoldingHelper.CreateFoldListWithOneFold();
xmlFoldingManager.UpdateFolds(folds);
Assert.AreEqual(-1, fakeFoldingManager.FirstErrorOffset);
}
[Test] [Test]
public void UpdateFolds_NoParameterPassedToMethod_FakeXmlFoldParserFoldsUsedToUpdateFakeFoldingManager() public void UpdateFolds_NoParameterPassedToMethod_FakeXmlFoldParserFoldsUsedToUpdateFakeFoldingManager()
{ {

4
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/TreeControlViewStateTestFixture.cs

@ -44,14 +44,14 @@ namespace XmlEditor.Tests.Tree
[Test] [Test]
public void ViewStateSaved() public void ViewStateSaved()
{ {
string savedViewState = (string)savedProperties.Get("XmlTreeViewControl.ViewState"); string savedViewState = savedProperties.Get("XmlTreeViewControl.ViewState", string.Empty);
Assert.AreEqual(expectedSavedViewState, savedViewState); Assert.AreEqual(expectedSavedViewState, savedViewState);
} }
[Test] [Test]
public void ViewStateLoaded() public void ViewStateLoaded()
{ {
Assert.AreEqual(String.Empty, restoredProperties.Get("XmlTreeViewControl.ViewState")); Assert.AreEqual(String.Empty, restoredProperties.Get("XmlTreeViewControl.ViewState", string.Empty));
} }
} }
} }

6
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/FakeXmlFoldParser.cs

@ -4,8 +4,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Folding; using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
@ -14,9 +14,9 @@ namespace XmlEditor.Tests.Utils
public class FakeXmlFoldParser : IXmlFoldParser public class FakeXmlFoldParser : IXmlFoldParser
{ {
public List<FoldingRegion> Folds = new List<FoldingRegion>(); public List<FoldingRegion> Folds = new List<FoldingRegion>();
public ITextBuffer TextBufferPassedToGetFolds; public ITextSource TextBufferPassedToGetFolds;
public IList<FoldingRegion> GetFolds(ITextBuffer textBuffer) public IList<FoldingRegion> GetFolds(ITextSource textBuffer)
{ {
TextBufferPassedToGetFolds = textBuffer; TextBufferPassedToGetFolds = textBuffer;
return Folds; return Folds;

53
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockCaret.cs

@ -1,53 +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 ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop.Editor;
namespace XmlEditor.Tests.Utils
{
public class MockCaret : ITextEditorCaret
{
int offset = -1;
public MockCaret()
{
Position = Location.Empty;
}
public event EventHandler PositionChanged;
protected virtual void OnPositionChanged(EventArgs e)
{
if (PositionChanged != null) {
PositionChanged(this, e);
}
}
public int Offset {
get { return offset; }
set { offset = value; }
}
public int Line {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public int Column {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public Location Position { get; set; }
}
}

87
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs

@ -4,7 +4,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
@ -14,7 +16,7 @@ namespace XmlEditor.Tests.Utils
{ {
string text = String.Empty; string text = String.Empty;
TextSection textSectionUsedWithGetTextMethod; TextSection textSectionUsedWithGetTextMethod;
ITextBuffer snapshot; ITextSource snapshot;
public List<int> PositionToOffsetReturnValues = new List<int>(); public List<int> PositionToOffsetReturnValues = new List<int>();
@ -22,27 +24,18 @@ namespace XmlEditor.Tests.Utils
{ {
} }
public event EventHandler TextChanged;
protected virtual void OnTextChanged(EventArgs e)
{
if (TextChanged != null) {
TextChanged(this, e);
}
}
public string Text { public string Text {
get { return text; } get { return text; }
set { text = value; } set { text = value; }
} }
public int TotalNumberOfLines { public int LineCount {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public ITextBufferVersion Version { public ITextSourceVersion Version {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -62,14 +55,19 @@ namespace XmlEditor.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
public int PositionToOffset(int line, int column) public int GetOffset(int line, int column)
{ {
int offset = PositionToOffsetReturnValues[0]; int offset = PositionToOffsetReturnValues[0];
PositionToOffsetReturnValues.RemoveAt(0); PositionToOffsetReturnValues.RemoveAt(0);
return offset; return offset;
} }
public Location OffsetToPosition(int offset) public int GetOffset(TextLocation location)
{
return GetOffset(location.Line, location.Column);
}
public TextLocation GetLocation(int offset)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -114,17 +112,17 @@ namespace XmlEditor.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SetSnapshot(ITextBuffer snapshot) public void SetSnapshot(ITextSource snapshot)
{ {
this.snapshot = snapshot; this.snapshot = snapshot;
} }
public ITextBuffer CreateSnapshot() public ITextSource CreateSnapshot()
{ {
return snapshot; return snapshot;
} }
public ITextBuffer CreateSnapshot(int offset, int length) public ITextSource CreateSnapshot(int offset, int length)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -155,18 +153,18 @@ namespace XmlEditor.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
public event EventHandler<TextChangeEventArgs> Changing { public event EventHandler<TextChangeEventArgs> TextChanging {
add { throw new NotImplementedException(); } add { throw new NotImplementedException(); }
remove { throw new NotImplementedException(); } remove { throw new NotImplementedException(); }
} }
public event EventHandler<TextChangeEventArgs> Changed; public event EventHandler<TextChangeEventArgs> TextChanged;
public void RaiseChangedEvent() public void RaiseChangedEvent()
{ {
TextChangeEventArgs e = new TextChangeEventArgs(0, "", "a"); TextChangeEventArgs e = new TextChangeEventArgs(0, "", "a");
if (Changed != null) { if (TextChanged != null) {
Changed(this, e); TextChanged(this, e);
} }
} }
@ -174,5 +172,52 @@ namespace XmlEditor.Tests.Utils
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public event EventHandler ChangeCompleted;
public IDocument CreateDocumentSnapshot()
{
throw new NotImplementedException();
}
public IDocumentLine GetLineByNumber(int lineNumber)
{
throw new NotImplementedException();
}
public IDocumentLine GetLineByOffset(int offset)
{
throw new NotImplementedException();
}
public string GetText(ISegment segment)
{
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();
}
} }
} }

53
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocumentLine.cs

@ -1,53 +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 ICSharpCode.SharpDevelop.Editor;
namespace XmlEditor.Tests.Utils
{
public class MockDocumentLine : IDocumentLine
{
public MockDocumentLine()
{
}
public int Offset {
get {
throw new NotImplementedException();
}
}
public int Length {
get {
throw new NotImplementedException();
}
}
public int EndOffset {
get {
throw new NotImplementedException();
}
}
public int TotalLength {
get {
throw new NotImplementedException();
}
}
public int DelimiterLength {
get {
throw new NotImplementedException();
}
}
public int LineNumber { get; set; }
public string Text {
get {
throw new NotImplementedException();
}
}
}
}

40
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockParserService.cs

@ -1,40 +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.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.XmlEditor;
namespace XmlEditor.Tests.Utils
{
public class MockParserService : IParserService
{
IProjectContent projectContentPassedToGetExistingParseInfoMethod;
Dictionary<string, ParseInformation> parseInfoDictionary = new Dictionary<string, ParseInformation>();
public MockParserService()
{
}
public ParseInformation GetExistingParseInformation(IProjectContent content, string fileName)
{
projectContentPassedToGetExistingParseInfoMethod = content;
ParseInformation parseInfo;
if (parseInfoDictionary.TryGetValue(fileName, out parseInfo)) {
return parseInfo;
}
return null;
}
public void SetExistingParseInformation(string fileName, ParseInformation parseInfo)
{
parseInfoDictionary.Add(fileName, parseInfo);
}
public IProjectContent ProjectContentPassedToGetExistingParseInforMethod {
get { return projectContentPassedToGetExistingParseInfoMethod; }
}
}
}

74
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextBuffer.cs

@ -1,74 +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.IO;
using ICSharpCode.SharpDevelop;
namespace XmlEditor.Tests.Utils
{
public class MockTextBuffer : ITextBuffer
{
string text = String.Empty;
public MockTextBuffer(string text)
{
this.text = text;
}
public event EventHandler TextChanged;
protected virtual void OnTextChanged(EventArgs e)
{
if (TextChanged != null) {
TextChanged(this, e);
}
}
public ITextBufferVersion Version {
get {
throw new NotImplementedException();
}
}
public int TextLength {
get {
throw new NotImplementedException();
}
}
public string Text {
get { return text; }
}
public ITextBuffer CreateSnapshot()
{
throw new NotImplementedException();
}
public ITextBuffer CreateSnapshot(int offset, int length)
{
throw new NotImplementedException();
}
public TextReader CreateReader()
{
return new StringReader(text);
}
public TextReader CreateReader(int offset, int length)
{
return new StringReader(text);
}
public char GetCharAt(int offset)
{
throw new NotImplementedException();
}
public string GetText(int offset, int length)
{
throw new NotImplementedException();
}
}
}

10
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditor.cs

@ -5,9 +5,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using Rhino.Mocks;
namespace XmlEditor.Tests.Utils namespace XmlEditor.Tests.Utils
{ {
@ -15,7 +17,7 @@ namespace XmlEditor.Tests.Utils
{ {
MockCompletionListWindow completionWindowDisplayed; MockCompletionListWindow completionWindowDisplayed;
ICompletionItemList completionItemsDisplayed; ICompletionItemList completionItemsDisplayed;
MockCaret caret = new MockCaret(); ITextEditorCaret caret = MockRepository.GenerateStub<ITextEditorCaret>();
IDocument document = new MockDocument(); IDocument document = new MockDocument();
ITextEditorOptions options = new MockTextEditorOptions(); ITextEditorOptions options = new MockTextEditorOptions();
FileName fileName; FileName fileName;
@ -178,5 +180,11 @@ namespace XmlEditor.Tests.Utils
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public IList<ICSharpCode.SharpDevelop.Refactoring.IContextActionProvider> ContextActionProviders {
get {
throw new NotImplementedException();
}
}
} }
} }

1
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditorProviderViewContent.cs

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

4
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs

@ -42,7 +42,7 @@ namespace XmlEditor.Tests.Utils
} }
} }
public event ViewContentEventHandler ViewOpened; public event EventHandler<ViewContentEventArgs> ViewOpened;
protected virtual void OnViewOpened(ViewContentEventArgs e) protected virtual void OnViewOpened(ViewContentEventArgs e)
{ {
@ -51,7 +51,7 @@ namespace XmlEditor.Tests.Utils
} }
} }
public event ViewContentEventHandler ViewClosed; public event EventHandler<ViewContentEventArgs> ViewClosed;
protected virtual void OnViewClosed(ViewContentEventArgs e) protected virtual void OnViewClosed(ViewContentEventArgs e)
{ {

6
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlViewContent.cs

@ -2,6 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
@ -12,13 +14,13 @@ namespace XmlEditor.Tests.Utils
public class MockXmlViewContent : AbstractViewContent, IFileDocumentProvider public class MockXmlViewContent : AbstractViewContent, IFileDocumentProvider
{ {
OpenedFile file; OpenedFile file;
AvalonEditDocumentAdapter document; IDocument document;
public MockXmlViewContent(OpenedFile file) public MockXmlViewContent(OpenedFile file)
{ {
this.file = file; this.file = file;
this.Files.Add(file); this.Files.Add(file);
this.document = new AvalonEditDocumentAdapter(); this.document = new TextDocument();
} }
public override object Control { public override object Control {

49
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockCaretTests.cs

@ -1,49 +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 ICSharpCode.NRefactory;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Utils.Tests
{
[TestFixture]
public class MockCaretTests
{
MockCaret caret;
[SetUp]
public void Init()
{
caret = new MockCaret();
}
[Test]
public void CanSetAndGetCaretOffset()
{
caret.Offset = 3;
Assert.AreEqual(3, caret.Offset);
}
[Test]
public void InitialCaretOffsetIsMinusOne()
{
Assert.AreEqual(-1, caret.Offset);
}
[Test]
public void CanGetAndSetCaretPosition()
{
Location location = new Location(3, 2);
caret.Position = location;
Assert.AreEqual(location, caret.Position);
}
[Test]
public void DefaultCaretPostionIsEmpty()
{
Assert.AreEqual(Location.Empty, caret.Position);
}
}
}

28
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockDocumentLineTests.cs

@ -1,28 +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 NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Utils.Tests
{
[TestFixture]
public class MockDocumentLineTests
{
MockDocumentLine documentLine;
[SetUp]
public void Init()
{
documentLine = new MockDocumentLine();
}
[Test]
public void CanSetAndGetLineNumberProperty()
{
documentLine.LineNumber = 2;
Assert.AreEqual(2, documentLine.LineNumber);
}
}
}

49
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockParserServiceTests.cs

@ -1,49 +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 ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Utils.Tests
{
[TestFixture]
public class MockParserServiceTests
{
MockParserService parserService;
ParseInformation existingParseInfo;
[SetUp]
public void Init()
{
DefaultProjectContent projectContent = new DefaultProjectContent();
DefaultCompilationUnit unit = new DefaultCompilationUnit(projectContent);
existingParseInfo = new ParseInformation(unit);
parserService = new MockParserService();
parserService.SetExistingParseInformation(@"d:\projects\test.xml", existingParseInfo);
}
[Test]
public void CanGetProjectContentPassedToGetExistingParseInfoMethod()
{
DefaultProjectContent projectContent = new DefaultProjectContent();
parserService.GetExistingParseInformation(projectContent, "file.xml");
Assert.AreSame(projectContent, parserService.ProjectContentPassedToGetExistingParseInforMethod);
}
[Test]
public void GetExistingParseInfoReturnsParseInfoObjectForKnownFileName()
{
Assert.AreSame(existingParseInfo, parserService.GetExistingParseInformation(null, @"d:\projects\test.xml"));
}
[Test]
public void GetExistingParseInfoReturnsNullForKnownFileName()
{
Assert.IsNull(parserService.GetExistingParseInformation(null, @"d:\projects\unknown.xml"));
}
}
}

6
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockTextBufferTests.cs

@ -5,7 +5,7 @@ using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
using ICSharpCode.NRefactory.Editor;
using NUnit.Framework; using NUnit.Framework;
using XmlEditor.Tests.Utils; using XmlEditor.Tests.Utils;
@ -18,7 +18,7 @@ namespace XmlEditor.Tests.Utils.Tests
public void CanGetTextFromTextBufferTextProperty() public void CanGetTextFromTextBufferTextProperty()
{ {
string expectedText = "abc"; string expectedText = "abc";
MockTextBuffer textBuffer = new MockTextBuffer(expectedText); ITextSource textBuffer = new StringTextSource(expectedText);
Assert.AreEqual(expectedText, textBuffer.Text); Assert.AreEqual(expectedText, textBuffer.Text);
} }
@ -26,7 +26,7 @@ namespace XmlEditor.Tests.Utils.Tests
public void CanGetTextFromReaderReturnedFromTextBufferCreateReader() public void CanGetTextFromReaderReturnedFromTextBufferCreateReader()
{ {
string expectedText = "abc"; string expectedText = "abc";
MockTextBuffer textBuffer = new MockTextBuffer("abc"); ITextSource textBuffer = new StringTextSource("abc");
StringBuilder text = new StringBuilder(); StringBuilder text = new StringBuilder();
using (TextReader reader = textBuffer.CreateReader()) { using (TextReader reader = textBuffer.CreateReader()) {

9
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/XmlFoldParserHelper.cs

@ -4,7 +4,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
namespace XmlEditor.Tests.Utils namespace XmlEditor.Tests.Utils
@ -21,14 +22,14 @@ namespace XmlEditor.Tests.Utils
return Parser; return Parser;
} }
public MockTextBuffer CreateTextBuffer(string xml) public ITextSource CreateTextBuffer(string xml)
{ {
return new MockTextBuffer(xml); return new StringTextSource(xml);
} }
public IList<FoldingRegion> GetFolds(string xml) public IList<FoldingRegion> GetFolds(string xml)
{ {
MockTextBuffer textBuffer = new MockTextBuffer(xml); ITextSource textBuffer = new StringTextSource(xml);
Folds = Parser.GetFolds(textBuffer); Folds = Parser.GetFolds(textBuffer);
return Folds; return Folds;
} }

2
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespacePropertiesLoaded.cs

@ -30,7 +30,7 @@ namespace XmlEditor.Tests.XPath
foreach (XmlNamespace xmlNamespace in expectedNamespaces) { foreach (XmlNamespace xmlNamespace in expectedNamespaces) {
namespaces.Add(xmlNamespace.ToString()); namespaces.Add(xmlNamespace.ToString());
} }
p.Set("Namespaces", namespaces.ToArray()); p.SetList("Namespaces", namespaces);
queryControl.SetMemento(p); queryControl.SetMemento(p);
actualNamespaces = queryControl.GetNamespaces(); actualNamespaces = queryControl.GetNamespaces();
} }

3
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespacePropertiesSaved.cs

@ -1,6 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Linq;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
@ -35,7 +36,7 @@ namespace XmlEditor.Tests.XPath
queryControl.NamespacesDataGridView.Rows.Add(new object[] {null, null}); queryControl.NamespacesDataGridView.Rows.Add(new object[] {null, null});
Properties p = queryControl.CreateMemento(); Properties p = queryControl.CreateMemento();
actualNamespaces = p.Get("Namespaces", new string[0]); actualNamespaces = p.GetList<string>("Namespaces").ToArray();
} }
} }

4
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/RemoveXPathHighlightingCommandTestFixture.cs

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Design; using System.ComponentModel.Design;
using System.Xml.XPath; using System.Xml.XPath;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
@ -33,7 +33,7 @@ namespace XmlEditor.Tests.XPath
container.AddService(typeof(ITextMarkerService), markerService); container.AddService(typeof(ITextMarkerService), markerService);
// Add xpath marker to document. // Add xpath marker to document.
AvalonEditDocumentAdapter doc = new AvalonEditDocumentAdapter(new ICSharpCode.AvalonEdit.Document.TextDocument(), container); IDocument doc = new ICSharpCode.AvalonEdit.Document.TextDocument() { ServiceProvider = container };
doc.Text = "<Test/>"; doc.Text = "<Test/>";
XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc); XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
XPathNodeMatch nodeMatch = new XPathNodeMatch("Test", "<Test/>", 0, 1, XPathNodeType.Element); XPathNodeMatch nodeMatch = new XPathNodeMatch("Test", "<Test/>", 0, 1, XPathNodeType.Element);

1
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/SingleXPathQueryElementMarkedTestFixture.cs

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Design; using System.ComponentModel.Design;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Tests.Utils; using ICSharpCode.SharpDevelop.Tests.Utils;

6
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathNodeTextMarkerTests.cs

@ -4,7 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Design; using System.ComponentModel.Design;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Tests.Utils; using ICSharpCode.SharpDevelop.Tests.Utils;
@ -30,7 +30,7 @@ namespace XmlEditor.Tests.XPath
ServiceContainer container = new ServiceContainer(); ServiceContainer container = new ServiceContainer();
container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService()); container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService());
AvalonEditDocumentAdapter doc = new AvalonEditDocumentAdapter(new ICSharpCode.AvalonEdit.Document.TextDocument(), container); IDocument doc = new ICSharpCode.AvalonEdit.Document.TextDocument() { ServiceProvider = container };
doc.Text = xml; doc.Text = xml;
XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc); XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
xpathNodeMarker.AddMarkers(nodes); xpathNodeMarker.AddMarkers(nodes);
@ -60,7 +60,7 @@ namespace XmlEditor.Tests.XPath
ServiceContainer container = new ServiceContainer(); ServiceContainer container = new ServiceContainer();
container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService()); container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService());
AvalonEditDocumentAdapter doc = new AvalonEditDocumentAdapter(new ICSharpCode.AvalonEdit.Document.TextDocument(), container); IDocument doc = new ICSharpCode.AvalonEdit.Document.TextDocument() { ServiceProvider = container };
doc.Text = xml; doc.Text = xml;
XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc); XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
xpathNodeMarker.AddMarkers(nodes); xpathNodeMarker.AddMarkers(nodes);

5
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathQueryHistoryTestFixture.cs

@ -1,6 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Linq;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
using NUnit.Framework; using NUnit.Framework;
@ -31,7 +32,7 @@ namespace XmlEditor.Tests.XPath
Properties p = new Properties(); Properties p = new Properties();
p.Set("XPathQuery.LastQuery", "//w:Wix"); p.Set("XPathQuery.LastQuery", "//w:Wix");
expectedXPathsAfterLoad = new string[] {"//w:Fragment", "//w:Dialog"}; expectedXPathsAfterLoad = new string[] {"//w:Fragment", "//w:Dialog"};
p.Set("XPathQuery.History", expectedXPathsAfterLoad); p.SetList("XPathQuery.History", expectedXPathsAfterLoad);
queryControl.SetMemento(p); queryControl.SetMemento(p);
comboBoxTextAfterLoad = queryControl.XPathComboBox.Text; comboBoxTextAfterLoad = queryControl.XPathComboBox.Text;
@ -45,7 +46,7 @@ namespace XmlEditor.Tests.XPath
p = queryControl.CreateMemento(); p = queryControl.CreateMemento();
xpathQueryAfterSave = p.Get("XPathQuery.LastQuery", String.Empty); xpathQueryAfterSave = p.Get("XPathQuery.LastQuery", String.Empty);
xpathsAfterSave = p.Get("XPathQuery.History", new string[0]); xpathsAfterSave = p.GetList<string>("XPathQuery.History").ToArray();
} }
} }

23
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

@ -20,8 +20,9 @@
<Optimize>False</Optimize> <Optimize>False</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
@ -43,6 +44,9 @@
<Reference Include="PresentationFramework"> <Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework> <RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="Rhino.Mocks">
<HintPath>..\..\..\..\Libraries\RhinoMocks\Rhino.Mocks.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
@ -249,14 +253,10 @@
<Compile Include="Utils\ExceptionErrorMessage.cs" /> <Compile Include="Utils\ExceptionErrorMessage.cs" />
<Compile Include="Utils\FormattedErrorMessage.cs" /> <Compile Include="Utils\FormattedErrorMessage.cs" />
<Compile Include="Utils\MockAddXmlNodeDialog.cs" /> <Compile Include="Utils\MockAddXmlNodeDialog.cs" />
<Compile Include="Utils\MockCaret.cs" />
<Compile Include="Utils\MockCompletionListWindow.cs" /> <Compile Include="Utils\MockCompletionListWindow.cs" />
<Compile Include="Utils\MockDocument.cs" /> <Compile Include="Utils\MockDocument.cs" />
<Compile Include="Utils\MockDocumentLine.cs" />
<Compile Include="Utils\MockFileSystem.cs" /> <Compile Include="Utils\MockFileSystem.cs" />
<Compile Include="Utils\MockParserService.cs" />
<Compile Include="Utils\MockSelectXmlSchemaWindow.cs" /> <Compile Include="Utils\MockSelectXmlSchemaWindow.cs" />
<Compile Include="Utils\MockTextBuffer.cs" />
<Compile Include="Utils\MockTextEditor.cs" /> <Compile Include="Utils\MockTextEditor.cs" />
<Compile Include="Utils\MockTextEditorOptions.cs" /> <Compile Include="Utils\MockTextEditorOptions.cs" />
<Compile Include="Utils\MockXmlSchemaCompletionDataFactory.cs" /> <Compile Include="Utils\MockXmlSchemaCompletionDataFactory.cs" />
@ -267,11 +267,8 @@
<Compile Include="Utils\SchemaIncludeTestFixtureHelper.cs" /> <Compile Include="Utils\SchemaIncludeTestFixtureHelper.cs" />
<Compile Include="Utils\Tests\ExceptionErrorMessageAreEqualTests.cs" /> <Compile Include="Utils\Tests\ExceptionErrorMessageAreEqualTests.cs" />
<Compile Include="Utils\Tests\FormattedErrorMessageAreEqualTests.cs" /> <Compile Include="Utils\Tests\FormattedErrorMessageAreEqualTests.cs" />
<Compile Include="Utils\Tests\MockCaretTests.cs" />
<Compile Include="Utils\Tests\MockDocumentLineTests.cs" />
<Compile Include="Utils\Tests\MockDocumentTests.cs" /> <Compile Include="Utils\Tests\MockDocumentTests.cs" />
<Compile Include="Utils\Tests\MockFileSystemTests.cs" /> <Compile Include="Utils\Tests\MockFileSystemTests.cs" />
<Compile Include="Utils\Tests\MockParserServiceTests.cs" />
<Compile Include="Utils\Tests\MockSelectXmlSchemaWindowTests.cs" /> <Compile Include="Utils\Tests\MockSelectXmlSchemaWindowTests.cs" />
<Compile Include="Utils\Tests\MockTextBufferTests.cs" /> <Compile Include="Utils\Tests\MockTextBufferTests.cs" />
<Compile Include="Utils\Tests\MockTextEditorOptionsTests.cs" /> <Compile Include="Utils\Tests\MockTextEditorOptionsTests.cs" />
@ -349,9 +346,9 @@
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project> <Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
<Name>ICSharpCode.AvalonEdit</Name> <Name>ICSharpCode.AvalonEdit</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj"> <ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project> <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>NRefactory</Name> <Name>ICSharpCode.NRefactory</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj"> <ProjectReference Include="..\..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj">
<Project>{4980B743-B32F-4aba-AABD-45E2CAD3568D}</Project> <Project>{4980B743-B32F-4aba-AABD-45E2CAD3568D}</Project>
@ -362,10 +359,6 @@
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project> <Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project>
<Name>ICSharpCode.Core.WinForms</Name> <Name>ICSharpCode.Core.WinForms</Name>
</ProjectReference> </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="..\Project\XmlEditor.csproj"> <ProjectReference Include="..\Project\XmlEditor.csproj">
<Project>{DCA2703D-250A-463E-A68A-07ED105AE6BD}</Project> <Project>{DCA2703D-250A-463E-A68A-07ED105AE6BD}</Project>
<Name>XmlEditor</Name> <Name>XmlEditor</Name>

3
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj.user

@ -1 +1,2 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" /> <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" />

6
src/AddIns/DisplayBindings/XmlEditor/Test/app.config

@ -1,9 +1,11 @@
<configuration> <?xml version="1.0" encoding="utf-8"?><configuration>
<configSections> <configSections>
<sectionGroup name="NUnit"> <sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler" /> <section name="TestRunner" type="System.Configuration.NameValueSectionHandler" />
</sectionGroup> </sectionGroup>
</configSections> </configSections><startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<NUnit> <NUnit>
<TestRunner> <TestRunner>
<!-- Valid values are STA,MTA. Others ignored. --> <!-- Valid values are STA,MTA. Others ignored. -->

8
src/AddIns/Misc/SearchAndReplace/Test/SearchAndReplace.Tests.csproj

@ -12,7 +12,8 @@
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -59,11 +60,6 @@
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> <ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name> <Name>ICSharpCode.NRefactory</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> <Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>

13
src/Main/Base/Project/Configuration/AssemblyInfo.cs

@ -10,16 +10,9 @@ using System.Windows;
[assembly: CLSCompliant(false)] [assembly: CLSCompliant(false)]
[assembly: StringFreezing()] [assembly: StringFreezing()]
// Use hard-binding for ICSharpCode.SharpDevelop:
[assembly: Dependency("ICSharpCode.Core", LoadHint.Always)]
[assembly: Dependency("ICSharpCode.Core.WinForms", LoadHint.Always)]
[assembly: Dependency("ICSharpCode.Core.Presentation", LoadHint.Always)]
[assembly: Dependency("ICSharpCode.AvalonEdit", LoadHint.Always)]
[assembly: Dependency("ICSharpCode.NRefactory", LoadHint.Always)]
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.SourceAssembly, //where theme specific resource dictionaries are located ResourceDictionaryLocation.SourceAssembly, //where theme specific resource dictionaries are located
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
)] )]
[assembly: AssemblyTitle("SharpDevelopBase")] [assembly: AssemblyTitle("SharpDevelopBase")]
@ -27,3 +20,5 @@ using System.Windows;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: InternalsVisibleTo("SharpDevelop,PublicKey=002400000480000094000000060200000024000052534131000400000100010063d5db5957250f41969c79e88cbd8806165ca7d96d468a9d60f11704a8b0698684b5acc16fc82e6cede459e1d6ed7384b044c47a67d68bae1e08182473168e2ad92c6fabe32b9217ea59d05bb9a101318aeec9f767991d2ae8d987b60c591b6020d2816c395db7f3045a1c77c2b074c508c2b4f25dcd969688da94ebc83f5f9b")]

3
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -49,6 +49,7 @@
<Doozer name="TaskBoundAdditionalLogger" class="ICSharpCode.SharpDevelop.Project.TaskBoundAdditionalLoggerDoozer"/> <Doozer name="TaskBoundAdditionalLogger" class="ICSharpCode.SharpDevelop.Project.TaskBoundAdditionalLoggerDoozer"/>
<Doozer name="TaskBoundLoggerFilter" class="ICSharpCode.SharpDevelop.Project.TaskBoundLoggerFilterDoozer"/> <Doozer name="TaskBoundLoggerFilter" class="ICSharpCode.SharpDevelop.Project.TaskBoundLoggerFilterDoozer"/>
</Import> </Import>
<Import assembly=":SharpDevelop"/>
</Runtime> </Runtime>
<Path name = "/SharpDevelop/Workbench/Ambiences"> <Path name = "/SharpDevelop/Workbench/Ambiences">
@ -1065,7 +1066,7 @@
<ToolbarItem id = "ChooseLayout" <ToolbarItem id = "ChooseLayout"
type = "ComboBox" type = "ComboBox"
class = "ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand" /> class = "ICSharpCode.SharpDevelop.Gui.Workbench.ChooseLayoutCommand" />
<ToolbarItem id="NavigationSeparator" type="Separator"/> <ToolbarItem id="NavigationSeparator" type="Separator"/>
<Condition name="CanNavigateBack" action="Disable"> <Condition name="CanNavigateBack" action="Disable">

24
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -175,10 +175,6 @@
<Compile Include="Src\Gui\AbstractSecondaryViewContent.cs" /> <Compile Include="Src\Gui\AbstractSecondaryViewContent.cs" />
<Compile Include="Src\Gui\AbstractViewContentHandlingLoadErrors.cs" /> <Compile Include="Src\Gui\AbstractViewContentHandlingLoadErrors.cs" />
<Compile Include="Src\Gui\AbstractViewContentWithoutFile.cs" /> <Compile Include="Src\Gui\AbstractViewContentWithoutFile.cs" />
<Compile Include="Src\Gui\App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\BrowserDisplayBinding\BrowserDisplayBinding.cs" /> <Compile Include="Src\Gui\BrowserDisplayBinding\BrowserDisplayBinding.cs" />
<Compile Include="Src\Gui\Components\ColorPickerButton.xaml.cs"> <Compile Include="Src\Gui\Components\ColorPickerButton.xaml.cs">
<DependentUpon>ColorPickerButton.xaml</DependentUpon> <DependentUpon>ColorPickerButton.xaml</DependentUpon>
@ -301,12 +297,6 @@
<Compile Include="Src\Gui\Pads\ToolsPad.cs" /> <Compile Include="Src\Gui\Pads\ToolsPad.cs" />
<Compile Include="Src\Gui\ProgressCollector.cs" /> <Compile Include="Src\Gui\ProgressCollector.cs" />
<Compile Include="Src\Gui\SimpleViewContent.cs" /> <Compile Include="Src\Gui\SimpleViewContent.cs" />
<Compile Include="Src\Gui\Workbench\FullScreenEnabledWindow.cs" />
<Compile Include="Src\Gui\Workbench\Layouts\AvalonDockLayout.cs" />
<Compile Include="Src\Gui\Workbench\Layouts\AvalonPadContent.cs" />
<Compile Include="Src\Gui\Workbench\Layouts\AvalonWorkbenchWindow.cs" />
<Compile Include="Src\Gui\Workbench\SingleInstanceHelper.cs" />
<Compile Include="Src\Gui\Workbench\WpfWorkbench.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\ViewInBrowserConditionEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\ViewInBrowserConditionEvaluator.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\WriteableProjectEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\WriteableProjectEvaluator.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\WriteableSolutionEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\WriteableSolutionEvaluator.cs" />
@ -435,7 +425,6 @@
<Compile Include="Src\Gui\ContentInterfaces\IEditable.cs" /> <Compile Include="Src\Gui\ContentInterfaces\IEditable.cs" />
<Compile Include="Src\Gui\ContentInterfaces\IPositionable.cs" /> <Compile Include="Src\Gui\ContentInterfaces\IPositionable.cs" />
<Compile Include="Src\Gui\WorkbenchSingleton.cs" /> <Compile Include="Src\Gui\WorkbenchSingleton.cs" />
<Compile Include="Src\Commands\AutostartCommands.cs" />
<Compile Include="Src\Commands\EditCommands.cs" /> <Compile Include="Src\Commands\EditCommands.cs" />
<Compile Include="Src\Commands\FileCommands.cs" /> <Compile Include="Src\Commands\FileCommands.cs" />
<Compile Include="Src\Commands\FileTabStripCommands.cs" /> <Compile Include="Src\Commands\FileTabStripCommands.cs" />
@ -457,9 +446,6 @@
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Src\Gui\Components\SideBar\SharpDevelopSideTabItem.cs" /> <Compile Include="Src\Gui\Components\SideBar\SharpDevelopSideTabItem.cs" />
<Compile Include="Src\Gui\Components\StatusBar\SdStatusBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Src\Gui\ContentInterfaces\IPrintable.cs" /> <Compile Include="Src\Gui\ContentInterfaces\IPrintable.cs" />
<Compile Include="Src\Gui\Dialogs\AbstractOptionPanel.cs"> <Compile Include="Src\Gui\Dialogs\AbstractOptionPanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
@ -545,14 +531,11 @@
<Compile Include="Src\Internal\Doozers\PadDoozer.cs" /> <Compile Include="Src\Internal\Doozers\PadDoozer.cs" />
<Compile Include="Src\Gui\Pads\CompilerMessageView\MessageViewCategory.cs" /> <Compile Include="Src\Gui\Pads\CompilerMessageView\MessageViewCategory.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\ActiveContentExtensionEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\ActiveContentExtensionEvaluator.cs" />
<Compile Include="Src\Gui\Workbench\ViewContentEventHandler.cs" />
<Compile Include="Src\Services\Debugger\IDebugger.cs" /> <Compile Include="Src\Services\Debugger\IDebugger.cs" />
<Compile Include="Src\Services\Debugger\DefaultDebugger.cs" /> <Compile Include="Src\Services\Debugger\DefaultDebugger.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\ActiveWindowStateEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\ActiveWindowStateEvaluator.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\OpenWindowStateEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\OpenWindowStateEvaluator.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\DebuggerSupportsEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\DebuggerSupportsEvaluator.cs" />
<Compile Include="Src\Commands\ChooseLayoutCommand.cs" />
<Compile Include="Src\Gui\Workbench\Layouts\LayoutConfiguration.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\OutputWindowOptionsPanel.cs"> <Compile Include="Src\Gui\Dialogs\OptionPanels\OutputWindowOptionsPanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
@ -825,11 +808,6 @@
<Page Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\AddServiceReferenceDialog.xaml" /> <Page Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\AddServiceReferenceDialog.xaml" />
<Page Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\AdvancedServiceDialog.xaml" /> <Page Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\AdvancedServiceDialog.xaml" />
<Page Include="themes\generic.xaml" /> <Page Include="themes\generic.xaml" />
<ProjectReference Include="..\..\..\Libraries\AvalonDock\AvalonDock\AvalonDock.csproj">
<Project>{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}</Project>
<Name>AvalonDock</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj"> <ProjectReference Include="..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj">
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project> <Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
<Name>ICSharpCode.AvalonEdit</Name> <Name>ICSharpCode.AvalonEdit</Name>
@ -878,7 +856,6 @@
<Name>ICSharpCode.SharpDevelop.Widgets</Name> <Name>ICSharpCode.SharpDevelop.Widgets</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<Page Include="Src\Gui\App.xaml" />
<Page Include="Src\Gui\Components\ColorPickerButton.xaml" /> <Page Include="Src\Gui\Components\ColorPickerButton.xaml" />
<Page Include="Src\Gui\Dialogs\GotoDialog.xaml"> <Page Include="Src\Gui\Dialogs\GotoDialog.xaml">
<DependentUpon>GotoDialog.cs</DependentUpon> <DependentUpon>GotoDialog.cs</DependentUpon>
@ -888,7 +865,6 @@
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectCulturePanel.xaml" /> <Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectCulturePanel.xaml" />
<Page Include="Src\Gui\Dialogs\TabbedOptionsDialog.xaml" /> <Page Include="Src\Gui\Dialogs\TabbedOptionsDialog.xaml" />
<Page Include="Src\Gui\Dialogs\TreeViewOptionsDialog.xaml" /> <Page Include="Src\Gui\Dialogs\TreeViewOptionsDialog.xaml" />
<Page Include="Src\Gui\Workbench\WpfWorkbench.xaml" />
<Page Include="Src\Project\Converter\UpgradeView.xaml" /> <Page Include="Src\Project\Converter\UpgradeView.xaml" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />

27
src/Main/Base/Project/Src/Gui/IWorkbench.cs

@ -31,11 +31,6 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
Window MainWindow { get; } Window MainWindow { get; }
/// <summary>
/// Gets the status bar.
/// </summary>
IStatusBarService StatusBar { get; }
/// <summary> /// <summary>
/// Gets/Sets whether the window is displayed in full-screen mode. /// Gets/Sets whether the window is displayed in full-screen mode.
/// </summary> /// </summary>
@ -179,11 +174,29 @@ namespace ICSharpCode.SharpDevelop.Gui
/// WorkbenchSingleton.Workbench.ViewOpened += ...; /// WorkbenchSingleton.Workbench.ViewOpened += ...;
/// }; /// };
/// </example> /// </example>
event ViewContentEventHandler ViewOpened; event EventHandler<ViewContentEventArgs> ViewOpened;
/// <summary> /// <summary>
/// Is called, when a workbench view was closed /// Is called, when a workbench view was closed
/// </summary> /// </summary>
event ViewContentEventHandler ViewClosed; event EventHandler<ViewContentEventArgs> ViewClosed;
}
public class ViewContentEventArgs : EventArgs
{
IViewContent content;
public IViewContent Content {
get {
return content;
}
}
public ViewContentEventArgs(IViewContent content)
{
if (content == null)
throw new ArgumentNullException("content");
this.content = content;
}
} }
} }

3
src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs

@ -80,8 +80,9 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
IWorkbenchWindow ShowView(IViewContent content, bool switchToOpenedView); IWorkbenchWindow ShowView(IViewContent content, bool switchToOpenedView);
void LoadConfiguration(); void LoadConfiguration();
void StoreConfiguration(); void StoreConfiguration();
void SwitchLayout(string layoutName);
} }
} }

27
src/Main/Base/Project/Src/Gui/Workbench/ViewContentEventHandler.cs

@ -1,27 +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;
namespace ICSharpCode.SharpDevelop.Gui
{
public delegate void ViewContentEventHandler(object sender, ViewContentEventArgs e);
public class ViewContentEventArgs : EventArgs
{
IViewContent content;
public IViewContent Content {
get {
return content;
}
}
public ViewContentEventArgs(IViewContent content)
{
if (content == null)
throw new ArgumentNullException("content");
this.content = content;
}
}
}

3
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -57,7 +57,7 @@ namespace ICSharpCode.SharpDevelop.Gui
[Obsolete("Use SD.StatusBar instead")] [Obsolete("Use SD.StatusBar instead")]
public static IStatusBarService StatusBar { public static IStatusBarService StatusBar {
get { get {
return workbench != null ? workbench.StatusBar : null; return SD.StatusBar;
} }
} }
@ -68,7 +68,6 @@ namespace ICSharpCode.SharpDevelop.Gui
LanguageService.ValidateLanguage(); LanguageService.ValidateLanguage();
DisplayBindingService.InitializeService(); DisplayBindingService.InitializeService();
LayoutConfiguration.LoadLayoutConfiguration();
FileService.InitializeService(); FileService.InitializeService();
ParserService.InitializeParserService(); ParserService.InitializeParserService();
TaskService.Initialize(); TaskService.Initialize();

7
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -24,7 +24,6 @@ namespace ICSharpCode.SharpDevelop.Debugging
{ {
static IDebugger currentDebugger; static IDebugger currentDebugger;
static DebuggerDescriptor[] debuggers; static DebuggerDescriptor[] debuggers;
static string oldLayoutConfiguration = "Default";
static DebuggerService() static DebuggerService()
{ {
@ -112,8 +111,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
static void OnDebugStarting(object sender, EventArgs e) static void OnDebugStarting(object sender, EventArgs e)
{ {
WorkbenchSingleton.Workbench.WorkbenchLayout.StoreConfiguration(); WorkbenchSingleton.Workbench.WorkbenchLayout.SwitchLayout("Debug");
LayoutConfiguration.CurrentLayoutName = "Debug";
debugFeature = AnalyticsMonitorService.TrackFeature("Debugger"); debugFeature = AnalyticsMonitorService.TrackFeature("Debugger");
@ -137,8 +135,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
debugFeature.EndTracking(); debugFeature.EndTracking();
RemoveCurrentLineMarker(); RemoveCurrentLineMarker();
WorkbenchSingleton.Workbench.WorkbenchLayout.StoreConfiguration(); WorkbenchSingleton.Workbench.WorkbenchLayout.SwitchLayout("Default");
LayoutConfiguration.CurrentLayoutName = oldLayoutConfiguration;
if (DebugStopped != null) if (DebugStopped != null)
DebugStopped(null, e); DebugStopped(null, e);
} }

6
src/Main/Base/Project/Src/Services/SD.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.SharpDevelop
/// Gets the status bar. /// Gets the status bar.
/// </summary> /// </summary>
public static IStatusBarService StatusBar { public static IStatusBarService StatusBar {
get { return Workbench.StatusBar; } get { return GetRequiredService<IStatusBarService>(); }
} }
public static ILoggingService LoggingService { public static ILoggingService LoggingService {
@ -63,9 +63,5 @@ namespace ICSharpCode.SharpDevelop
public static IMessageService MessageService { public static IMessageService MessageService {
get { return GetRequiredService<IMessageService>(); } get { return GetRequiredService<IMessageService>(); }
} }
public static IAnalyticsMonitor AnalyticsMonitor {
get { return GetRequiredService<IAnalyticsMonitor>(); }
}
} }
} }

95
src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs

@ -47,99 +47,4 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
void AddProgress(ProgressCollector progress); void AddProgress(ProgressCollector progress);
} }
sealed class SdStatusBarService : IStatusBarService
{
readonly SdStatusBar statusBar;
public SdStatusBarService(SdStatusBar statusBar)
{
if (statusBar == null)
throw new ArgumentNullException("statusBar");
this.statusBar = statusBar;
}
public bool Visible {
get {
return statusBar.Visibility == Visibility.Visible;
}
set {
statusBar.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
}
}
public void SetCaretPosition(int x, int y, int charOffset)
{
statusBar.CursorStatusBarPanel.Content = StringParser.Parse(
"${res:StatusBarService.CursorStatusBarPanelText}",
new StringTagPair("Line", String.Format("{0,-10}", y)),
new StringTagPair("Column", String.Format("{0,-5}", x)),
new StringTagPair("Character", String.Format("{0,-5}", charOffset))
);
}
public void SetInsertMode(bool insertMode)
{
statusBar.ModeStatusBarPanel.Content = insertMode ? StringParser.Parse("${res:StatusBarService.CaretModes.Insert}") : StringParser.Parse("${res:StatusBarService.CaretModes.Overwrite}");
}
public void SetMessage(string message, bool highlighted, IImage icon)
{
statusBar.SetMessage(StringParser.Parse(message), highlighted);
}
#region Progress Monitor
Stack<ProgressCollector> waitingProgresses = new Stack<ProgressCollector>();
ProgressCollector currentProgress;
public IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken = default(CancellationToken))
{
ProgressCollector progress = new ProgressCollector(WorkbenchSingleton.Workbench.SynchronizingObject, cancellationToken);
AddProgress(progress);
return progress.ProgressMonitor;
}
public void AddProgress(ProgressCollector progress)
{
if (progress == null)
throw new ArgumentNullException("progress");
WorkbenchSingleton.AssertMainThread();
if (currentProgress != null) {
currentProgress.ProgressMonitorDisposed -= progress_ProgressMonitorDisposed;
currentProgress.PropertyChanged -= progress_PropertyChanged;
}
waitingProgresses.Push(currentProgress); // push even if currentProgress==null
SetActiveProgress(progress);
}
void SetActiveProgress(ProgressCollector progress)
{
WorkbenchSingleton.AssertMainThread();
currentProgress = progress;
if (progress == null) {
statusBar.HideProgress();
return;
}
progress.ProgressMonitorDisposed += progress_ProgressMonitorDisposed;
if (progress.ProgressMonitorIsDisposed) {
progress_ProgressMonitorDisposed(progress, null);
return;
}
progress.PropertyChanged += progress_PropertyChanged;
}
void progress_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Debug.Assert(sender == currentProgress);
statusBar.DisplayProgress(currentProgress.TaskName, currentProgress.Progress, currentProgress.Status);
}
void progress_ProgressMonitorDisposed(object sender, EventArgs e)
{
Debug.Assert(sender == currentProgress);
SetActiveProgress(waitingProgresses.Pop()); // stack is never empty: we push null as first element
}
#endregion
}
} }

24
src/Main/Base/Test/ConsoleApp/ConsoleApp.csproj

@ -1,4 +1,5 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" xmlns:Conversion="urn:Conversion"> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" xmlns:Conversion="urn:Conversion" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -7,15 +8,19 @@
<RootNamespace>ConsoleApp</RootNamespace> <RootNamespace>ConsoleApp</RootNamespace>
<AssemblyName>ConsoleApp</AssemblyName> <AssemblyName>ConsoleApp</AssemblyName>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<ApplicationIcon />
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn /> <NoWarn />
<StartupObject />
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<NoConfig>False</NoConfig> <NoConfig>False</NoConfig>
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> <RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
<PreBuildEvent /> <PreBuildEvent />
<PostBuildEvent /> <PostBuildEvent />
<TargetFrameworkProfile />
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
@ -37,16 +42,27 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ConsoleApp.cs" /> <Compile Include="ConsoleApp.cs" />
<Compile Include="AssemblyInfo.cs" /> <Compile Include="AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project> </Project>

6
src/Main/Base/Test/ConsoleApp/ConsoleApp.sln

@ -1,5 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 9.00 
# SharpDevelop 2.0.0.838 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.2.0.8695-Beta 2
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp.csproj", "{2829F840-FF43-4EF6-A23D-C244C765092C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp.csproj", "{2829F840-FF43-4EF6-A23D-C244C765092C}"
EndProject EndProject
Global Global

6
src/Main/Base/Test/ConsoleApp/app.config

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

BIN
src/Main/Base/Test/ConsoleApp/bin/ConsoleApp.exe

Binary file not shown.

7
src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj

@ -26,6 +26,9 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
@ -169,6 +172,10 @@
<Project>{AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5}</Project> <Project>{AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5}</Project>
<Name>ICSharpCode.Core.Tests</Name> <Name>ICSharpCode.Core.Tests</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\SharpDevelop\SharpDevelop.csproj">
<Project>{1152B71B-3C05-4598-B20D-823B5D40559E}</Project>
<Name>SharpDevelop</Name>
</ProjectReference>
<ProjectReference Include="..\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> <Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name> <Name>ICSharpCode.SharpDevelop</Name>

127
src/Main/Base/Test/Utils/MockTextMarkerService.cs

@ -1,60 +1,67 @@
#warning // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// 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)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
// using System;
//using System; using System.Collections.Generic;
//using System.Collections.Generic; using System.ComponentModel.Design;
//using System.ComponentModel.Design; using System.Linq;
// using ICSharpCode.AvalonEdit.Document;
//using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.NRefactory.Editor;
//using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor;
// using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
//namespace ICSharpCode.SharpDevelop.Tests.Utils
//{ namespace ICSharpCode.SharpDevelop.Tests.Utils
// /// <summary> {
// /// Description of MockTextEditor. /// <summary>
// /// </summary> /// Description of MockTextEditor.
// public class MockTextMarkerService : ITextMarkerService /// </summary>
// { public class MockTextMarkerService : ITextMarkerService
// public static IDocument CreateDocumentWithMockService() {
// { public static IDocument CreateDocumentWithMockService()
// ServiceContainer container = new ServiceContainer(); {
// container.AddService(typeof(ITextMarkerService), new MockTextMarkerService()); var document = new TextDocument();
// var container = (IServiceContainer)document.ServiceProvider.GetService(typeof(IServiceContainer));
// return new AvalonEditDocumentAdapter(new ICSharpCode.AvalonEdit.Document.TextDocument(), container); container.AddService(typeof(ITextMarkerService), new MockTextMarkerService());
// }
// return document;
// List<ITextMarker> markers; }
//
// public MockTextMarkerService() List<ITextMarker> markers;
// {
// this.markers = new List<ITextMarker>(); public MockTextMarkerService()
// } {
// this.markers = new List<ITextMarker>();
// public System.Collections.Generic.IEnumerable<ITextMarker> TextMarkers { }
// get {
// return this.markers; public System.Collections.Generic.IEnumerable<ITextMarker> TextMarkers {
// } get {
// } return this.markers;
// }
// public ITextMarker Create(int startOffset, int length) }
// {
// ITextMarker m = new MockTextMarker(this.markers, startOffset, startOffset + length, length); public ITextMarker Create(int startOffset, int length)
// this.markers.Add(m); {
// return m; ITextMarker m = new MockTextMarker(this.markers, startOffset, startOffset + length, length);
// } this.markers.Add(m);
// return m;
// public void Remove(ITextMarker marker) }
// {
// marker.Delete(); public void Remove(ITextMarker marker)
// } {
// marker.Delete();
// public void RemoveAll(Predicate<ITextMarker> predicate) }
// {
// foreach (ITextMarker m in markers.ToArray()) { public void RemoveAll(Predicate<ITextMarker> predicate)
// if (predicate(m)) {
// m.Delete(); foreach (ITextMarker m in markers.ToArray()) {
// } if (predicate(m))
// } m.Delete();
// } }
//} }
public IEnumerable<ITextMarker> GetMarkersAtOffset(int offset)
{
return markers.Where(m => m.StartOffset <= offset && offset <= m.EndOffset);
}
}
}

1
src/Main/Core/Project/ICSharpCode.Core.csproj

@ -74,6 +74,7 @@
<Compile Include="Src\AddInTree\AddIn\Codon.cs" /> <Compile Include="Src\AddInTree\AddIn\Codon.cs" />
<Compile Include="Src\AddInTree\AddIn\ComplexCondition.cs" /> <Compile Include="Src\AddInTree\AddIn\ComplexCondition.cs" />
<Compile Include="Src\AddInTree\AddIn\Condition.cs" /> <Compile Include="Src\AddInTree\AddIn\Condition.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\ServiceDoozer.cs" />
<Compile Include="Src\AddInTree\AddIn\ExtensionPath.cs" /> <Compile Include="Src\AddInTree\AddIn\ExtensionPath.cs" />
<Compile Include="Src\AddInTree\AddIn\IConditionEvaluator.cs" /> <Compile Include="Src\AddInTree\AddIn\IConditionEvaluator.cs" />
<Compile Include="Src\AddInTree\AddIn\ICondition.cs" /> <Compile Include="Src\AddInTree\AddIn\ICondition.cs" />

45
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/ServiceDoozer.cs

@ -0,0 +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.Design;
namespace ICSharpCode.Core
{
/// <summary>
/// Registers a service in a service container.
/// </summary>
/// <attribute name="id" use="required">
/// The service interface type.
/// </attribute>
/// <attribute name="class" use="required">
/// The implementing service class name.
/// </attribute>
/// <usage>Only in /SharpDevelop/Services</usage>
/// <returns>
/// <c>null</c>. The service is registered, but not returned.
/// </returns>
public class ServiceDoozer : IDoozer
{
public bool HandleConditions {
get { return false; }
}
public object BuildItem(BuildItemArgs args)
{
var container = (IServiceContainer)args.Caller;
if (container == null)
throw new InvalidOperationException("Expected the owner to be a service container");
Type interfaceType = args.AddIn.FindType(args.Codon.Id);
if (interfaceType != null) {
string className = args.Codon.Properties["class"];
// Use ServiceCreatorCallback to lazily create the service
container.AddService(
interfaceType, delegate {
return args.AddIn.CreateObject(className);
});
}
return null;
}
}
}

1
src/Main/Core/Project/Src/AddInTree/AddInTree.cs

@ -30,6 +30,7 @@ namespace ICSharpCode.Core
doozers.TryAdd("MenuItem", new MenuItemDoozer()); doozers.TryAdd("MenuItem", new MenuItemDoozer());
doozers.TryAdd("ToolbarItem", new ToolbarItemDoozer()); doozers.TryAdd("ToolbarItem", new ToolbarItemDoozer());
doozers.TryAdd("Include", new IncludeDoozer()); doozers.TryAdd("Include", new IncludeDoozer());
doozers.TryAdd("Service", new ServiceDoozer());
conditionEvaluators.TryAdd("Compare", new CompareConditionEvaluator()); conditionEvaluators.TryAdd("Compare", new CompareConditionEvaluator());
conditionEvaluators.TryAdd("Ownerstate", new OwnerStateConditionEvaluator()); conditionEvaluators.TryAdd("Ownerstate", new OwnerStateConditionEvaluator());

12
src/Main/Core/Project/Src/Services/ServiceManager.cs

@ -62,14 +62,14 @@ namespace ICSharpCode.Core.Services
/// <summary> /// <summary>
/// Gets the logging service. /// Gets the logging service.
/// </summary> /// </summary>
public virtual ILoggingService LoggingService { public ILoggingService LoggingService {
get { return (ILoggingService)GetRequiredService(typeof(ILoggingService)); } get { return (ILoggingService)GetRequiredService(typeof(ILoggingService)); }
} }
/// <summary> /// <summary>
/// Gets the message service. /// Gets the message service.
/// </summary> /// </summary>
public virtual IMessageService MessageService { public IMessageService MessageService {
get { return (IMessageService)GetRequiredService(typeof(IMessageService)); } get { return (IMessageService)GetRequiredService(typeof(IMessageService)); }
} }
} }
@ -79,14 +79,6 @@ namespace ICSharpCode.Core.Services
readonly ILoggingService loggingService = new TextWriterLoggingService(new DebugTextWriter()); readonly ILoggingService loggingService = new TextWriterLoggingService(new DebugTextWriter());
readonly IMessageService messageService = new TextWriterMessageService(Console.Out); readonly IMessageService messageService = new TextWriterMessageService(Console.Out);
public override ILoggingService LoggingService {
get { return loggingService; }
}
public override IMessageService MessageService {
get { return messageService; }
}
public override object GetService(Type serviceType) public override object GetService(Type serviceType)
{ {
if (serviceType == typeof(ILoggingService)) if (serviceType == typeof(ILoggingService))

18
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Configuration/AssemblyInfo.cs

@ -1,18 +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.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
[assembly: CLSCompliant(true)]
[assembly: StringFreezing()]
[assembly: Dependency("System.Core", LoadHint.Always)]
[assembly: AssemblyTitle("ICSharpCode.SharpDevelop.Dom")]
[assembly: AssemblyDescription("Code-completion library")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

216
src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj

@ -1,216 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.SharpDevelop.Dom</RootNamespace>
<AssemblyName>ICSharpCode.SharpDevelop.Dom</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</ProjectGuid>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<OutputPath>..\..\..\..\bin\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>132644864</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1002;-Microsoft.Design#CA1063;-Microsoft.Performance#CA1800;-Microsoft.Security#CA2104</CodeAnalysisRules>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\Libraries\log4net\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Core\Project\Src\Services\FileUtility\FileUtility.Minimal.cs">
<Link>Src\ProjectContent\FileUtility.Minimal.cs</Link>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="..\..\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Src\BusyManager.cs" />
<Compile Include="Src\CSharp\CSharpExpressionContext.cs" />
<Compile Include="Src\CSharp\OverloadResolution.cs" />
<Compile Include="Src\CSharp\TypeInference.cs" />
<Compile Include="Src\DomCache.cs" />
<Compile Include="Src\ExtensionMethods.cs" />
<Compile Include="Src\Implementations\AbstractEntity.cs" />
<Compile Include="Src\Implementations\AbstractMember.cs" />
<Compile Include="Src\Implementations\AbstractReturnType.cs" />
<Compile Include="Src\Implementations\AnonymousMethodReturnType.cs" />
<Compile Include="Src\Implementations\ArrayReturnType.cs" />
<Compile Include="Src\Implementations\AttributeReturnType.cs" />
<Compile Include="Src\Implementations\BoundTypeParameter.cs" />
<Compile Include="Src\Implementations\CombinedReturnType.cs" />
<Compile Include="Src\Implementations\CompoundClass.cs" />
<Compile Include="Src\Implementations\ConstructedReturnType.cs" />
<Compile Include="Src\Implementations\DecoratingReturnType.cs" />
<Compile Include="Src\Implementations\DefaultAttribute.cs" />
<Compile Include="Src\Implementations\DefaultClass.cs" />
<Compile Include="Src\Implementations\DefaultComment.cs" />
<Compile Include="Src\Implementations\DefaultCompilationUnit.cs" />
<Compile Include="Src\Implementations\DefaultEvent.cs" />
<Compile Include="Src\Implementations\DefaultField.cs" />
<Compile Include="Src\Implementations\DefaultMethod.cs" />
<Compile Include="Src\Implementations\DefaultParameter.cs" />
<Compile Include="Src\Implementations\DefaultProperty.cs" />
<Compile Include="Src\Implementations\DefaultReturnType.cs" />
<Compile Include="Src\Implementations\DefaultTypeParameter.cs" />
<Compile Include="Src\Implementations\DefaultUsing.cs" />
<Compile Include="Src\Implementations\DefaultUsingScope.cs" />
<Compile Include="Src\Implementations\DynamicReturnType.cs" />
<Compile Include="Src\Implementations\ElementReturnType.cs" />
<Compile Include="Src\Implementations\GenericReturnType.cs" />
<Compile Include="Src\Implementations\GetClassReturnType.cs" />
<Compile Include="Src\Implementations\MethodGroupReturnType.cs" />
<Compile Include="Src\Implementations\NullReturnType.cs" />
<Compile Include="Src\Implementations\PointerReturnType.cs" />
<Compile Include="Src\Implementations\ProxyReturnType.cs" />
<Compile Include="Src\Implementations\ReferenceReturnType.cs" />
<Compile Include="Src\Implementations\SearchClassReturnType.cs" />
<Compile Include="Src\Implementations\SystemTypes.cs" />
<Compile Include="Src\Implementations\UnknownReturnType.cs" />
<Compile Include="Src\Interfaces\ExplicitInterfaceImplementation.cs" />
<Compile Include="Src\Interfaces\ICompletionEntry.cs" />
<Compile Include="Src\Interfaces\IDomProgressMonitor.cs" />
<Compile Include="Src\Interfaces\IFreezable.cs" />
<Compile Include="Src\Interfaces\IUsingScope.cs" />
<Compile Include="Src\LazyList.cs" />
<Compile Include="Src\NRefactoryResolver\CodeSnippetConverter.cs" />
<Compile Include="Src\NRefactoryResolver\CSharpToVBNetConvertVisitor.cs" />
<Compile Include="Src\NRefactoryResolver\InferredReturnType.cs" />
<Compile Include="Src\NRefactoryResolver\LambdaParameterReturnType.cs" />
<Compile Include="Src\NRefactoryResolver\LambdaReturnType.cs" />
<Compile Include="Src\NRefactoryResolver\NRefactoryASTConvertVisitor.cs" />
<Compile Include="Src\NRefactoryResolver\NRefactoryInformationProvider.cs" />
<Compile Include="Src\NRefactoryResolver\NRefactoryResolver.cs" />
<Compile Include="Src\NRefactoryResolver\ResolveVisitor.cs" />
<Compile Include="Src\NRefactoryResolver\TypeVisitor.cs" />
<Compile Include="Src\NRefactoryResolver\VBNetToCSharpConvertVisitor.cs" />
<Compile Include="Src\ParameterListComparer.cs" />
<Compile Include="Src\ProjectContent\DomAssemblyName.cs" />
<Compile Include="Src\ReadOnlyDictionary.cs" />
<Compile Include="Src\Refactoring\CodeGeneratorOptions.cs" />
<Compile Include="Src\Refactoring\CSharpCodeGenerator.cs" />
<Compile Include="Src\Refactoring\TextFinder.cs" />
<Compile Include="Src\Refactoring\VBNetCodeGenerator.cs" />
<Compile Include="Src\ReflectionLayer\DomPersistence.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionClass.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionEvent.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionField.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionMethod.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionParameter.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionProperty.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionReturnType.cs" />
<Compile Include="Src\CecilReader.cs" />
<Compile Include="Src\ExpressionContext.cs" />
<Compile Include="Src\FilePosition.cs" />
<Compile Include="Src\FoldingRegion.cs" />
<Compile Include="Src\IComment.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionTypeNameSyntaxError.cs" />
<Compile Include="Src\SignatureComparer.cs" />
<Compile Include="Src\VBNet\IVBNetOptionProvider.cs" />
<Compile Include="Src\VBNet\VBNetCompilationUnit.cs" />
<Compile Include="Src\VBNet\VBNetExpressionFinder.cs" />
<Compile Include="Src\XmlDoc.cs" />
<Compile Include="Src\Tag.cs" />
<Compile Include="Src\ResolveResult.cs" />
<Compile Include="Src\MemberLookupHelper.cs" />
<Compile Include="Src\LanguageProperties.cs" />
<Compile Include="Src\IResolver.cs" />
<Compile Include="Src\IExpressionFinder.cs" />
<Compile Include="Src\Interfaces\ClassType.cs" />
<Compile Include="Src\Interfaces\IAttribute.cs" />
<Compile Include="Src\Interfaces\IClass.cs" />
<Compile Include="Src\Interfaces\ICompilationUnit.cs" />
<Compile Include="Src\Interfaces\IEntity.cs" />
<Compile Include="Src\Interfaces\IEvent.cs" />
<Compile Include="Src\Interfaces\IField.cs" />
<Compile Include="Src\Interfaces\IMember.cs" />
<Compile Include="Src\Interfaces\IMethod.cs" />
<Compile Include="Src\Interfaces\IParameter.cs" />
<Compile Include="Src\Interfaces\IProperty.cs" />
<Compile Include="Src\Interfaces\IReturnType.cs" />
<Compile Include="Src\Interfaces\IUsing.cs" />
<Compile Include="Src\Interfaces\ModifierEnum.cs" />
<Compile Include="Src\Interfaces\ParameterModifiers.cs" />
<Compile Include="Src\Interfaces\Region.cs" />
<Compile Include="Src\Interfaces\ITypeParameter.cs" />
<Compile Include="Src\ProjectContent\DefaultProjectContent.cs" />
<Compile Include="Src\ProjectContent\IProjectContent.cs" />
<Compile Include="Src\ProjectContent\ReflectionProjectContent.cs" />
<Compile Include="Src\LoggingService.cs" />
<Compile Include="Src\ProjectContent\ProjectContentRegistry.cs" />
<Compile Include="Src\FusionNative.cs" />
<Compile Include="Src\DiffUtility.cs" />
<Compile Include="Src\ProjectContent\ParseInformation.cs" />
<Compile Include="Src\HostCallback.cs" />
<Compile Include="Src\Refactoring\CodeGenerator.cs" />
<Compile Include="Src\Refactoring\IRefactoringDocument.cs" />
<Compile Include="Src\ClassFinder.cs" />
<Compile Include="Src\Refactoring\NRefactoryCodeGenerator.cs" />
<Compile Include="Src\Refactoring\RefactoringProvider.cs" />
<Compile Include="Src\Refactoring\NRefactoryRefactoringProvider.cs" />
<Compile Include="Src\GacInterop.cs" />
<Compile Include="Src\CtrlSpaceResolveHelper.cs" />
<Compile Include="Src\CSharp\CSharpAmbience.cs" />
<Compile Include="Src\Ambience.cs" />
<Compile Include="Src\CSharp\ExpressionFinder.cs" />
<Compile Include="Src\VBNet\VBNetAmbience.cs" />
<Compile Include="Src\EasyCodeDom.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Configuration" />
<Folder Include="Src" />
<ProjectReference Include="..\..\..\Libraries\Mono.Cecil\Mono.Cecil.csproj">
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference>
<Folder Include="Src\Implementations" />
<Folder Include="Src\NRefactoryResolver" />
<Folder Include="Src\ReflectionLayer" />
<Folder Include="Src\Interfaces" />
<Folder Include="Src\ProjectContent" />
<Folder Include="Src\Refactoring" />
<Folder Include="Src\CSharp" />
<Folder Include="Src\VBNet" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

242
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Ambience.cs

@ -1,242 +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;
namespace ICSharpCode.SharpDevelop.Dom
{
[Flags]
public enum ConversionFlags
{
/// <summary>
/// Convert only the name.
/// </summary>
None = 0,
/// <summary>
/// Show the parameter list
/// </summary>
ShowParameterList = 1,
/// <summary>
/// Show names for parameters
/// </summary>
ShowParameterNames = 2,
/// <summary>
/// Show the accessibility (private, public, etc.)
/// </summary>
ShowAccessibility = 4,
/// <summary>
/// Show the definition key word (class, struct, Sub, Function, etc.)
/// </summary>
ShowDefinitionKeyWord = 8,
/// <summary>
/// Show the fully qualified name for the member
/// </summary>
UseFullyQualifiedMemberNames = 0x10,
/// <summary>
/// Show modifiers (virtual, override, etc.)
/// </summary>
ShowModifiers = 0x20,
/// <summary>
/// Show the inheritance declaration
/// </summary>
ShowInheritanceList = 0x40,
IncludeHtmlMarkup = 0x80,
/// <summary>
/// Show the return type
/// </summary>
ShowReturnType = 0x100,
/// <summary>
/// Use fully qualified names for return type and parameters.
/// </summary>
UseFullyQualifiedTypeNames = 0x200,
/// <summary>
/// Include opening brace (or equivalent) for methods or classes;
/// or semicolon (or equivalent) for field, events.
/// For properties, a block indicating if there is a getter/setter is included.
/// </summary>
IncludeBody = 0x400,
/// <summary>
/// Show the list of type parameters on method and class declarations.
/// Type arguments for parameter/return types are always shown.
/// </summary>
ShowTypeParameterList = 0x800,
StandardConversionFlags = ShowParameterNames |
ShowAccessibility |
ShowParameterList |
ShowReturnType |
ShowModifiers |
ShowTypeParameterList |
ShowDefinitionKeyWord,
All = 0xfff,
}
public interface IAmbience
{
ConversionFlags ConversionFlags {
get;
set;
}
string Convert(IClass c);
string ConvertEnd(IClass c);
string Convert(IEntity e);
string Convert(IField field);
string Convert(IProperty property);
string Convert(IEvent e);
string Convert(IMethod m);
string ConvertEnd(IMethod m);
string Convert(IParameter param);
string Convert(IReturnType returnType);
string ConvertAccessibility(ModifierEnum accessibility);
string WrapAttribute(string attribute);
string WrapComment(string comment);
string GetIntrinsicTypeName(string dotNetTypeName);
}
public abstract class AbstractAmbience : IAmbience
{
#if DEBUG
int ownerThread = System.Threading.Thread.CurrentThread.ManagedThreadId;
#endif
[System.Diagnostics.Conditional("DEBUG")]
protected void CheckThread()
{
#if DEBUG
if (ownerThread != System.Threading.Thread.CurrentThread.ManagedThreadId)
throw new InvalidOperationException("Ambience may only be used by the thread that created it");
#endif
}
ConversionFlags conversionFlags = ConversionFlags.StandardConversionFlags;
public ConversionFlags ConversionFlags {
get {
return conversionFlags;
}
set {
CheckThread();
conversionFlags = value;
}
}
public bool ShowReturnType {
get {
return (conversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType;
}
}
public bool ShowAccessibility {
get {
return (conversionFlags & ConversionFlags.ShowAccessibility) == ConversionFlags.ShowAccessibility;
}
}
public bool ShowParameterNames {
get {
return (conversionFlags & ConversionFlags.ShowParameterNames) == ConversionFlags.ShowParameterNames;
}
}
public bool UseFullyQualifiedTypeNames {
get {
return (conversionFlags & ConversionFlags.UseFullyQualifiedTypeNames) == ConversionFlags.UseFullyQualifiedTypeNames;
}
}
public bool ShowDefinitionKeyWord {
get {
return (conversionFlags & ConversionFlags.ShowDefinitionKeyWord) == ConversionFlags.ShowDefinitionKeyWord;
}
}
public bool ShowParameterList {
get {
return (conversionFlags & ConversionFlags.ShowParameterList) == ConversionFlags.ShowParameterList;
}
}
public bool ShowModifiers {
get {
return (conversionFlags & ConversionFlags.ShowModifiers) == ConversionFlags.ShowModifiers;
}
}
public bool ShowInheritanceList {
get {
return (conversionFlags & ConversionFlags.ShowInheritanceList) == ConversionFlags.ShowInheritanceList;
}
}
public bool IncludeHtmlMarkup {
get {
return (conversionFlags & ConversionFlags.IncludeHtmlMarkup) == ConversionFlags.IncludeHtmlMarkup;
}
}
public bool UseFullyQualifiedMemberNames {
get {
return (conversionFlags & ConversionFlags.UseFullyQualifiedMemberNames) == ConversionFlags.UseFullyQualifiedMemberNames;
}
}
public bool IncludeBody {
get {
return (conversionFlags & ConversionFlags.IncludeBody) == ConversionFlags.IncludeBody;
}
}
public bool ShowTypeParameterList {
get {
return (conversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList;
}
}
public abstract string Convert(IClass c);
public abstract string ConvertEnd(IClass c);
public abstract string Convert(IField c);
public abstract string Convert(IProperty property);
public abstract string Convert(IEvent e);
public abstract string Convert(IMethod m);
public abstract string ConvertEnd(IMethod m);
public abstract string Convert(IParameter param);
public abstract string Convert(IReturnType returnType);
public virtual string Convert(IEntity entity)
{
if (entity == null)
throw new ArgumentNullException("entity");
IClass c = entity as IClass;
if (c != null)
return Convert(c);
IMethod m = entity as IMethod;
if (m != null)
return Convert(m);
IField f = entity as IField;
if (f != null)
return Convert(f);
IProperty p = entity as IProperty;
if (p != null)
return Convert(p);
IEvent e = entity as IEvent;
if (e != null)
return Convert(e);
return entity.ToString();
}
public abstract string WrapAttribute(string attribute);
public abstract string WrapComment(string comment);
public abstract string GetIntrinsicTypeName(string dotNetTypeName);
public abstract string ConvertAccessibility(ModifierEnum accessibility);
}
}

52
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/BusyManager.cs

@ -1,52 +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.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// This class is used to prevent stack overflows by representing a 'busy' flag
/// that prevents reentrance when another call is running.
/// However, using a simple 'bool busy' is not thread-safe, so we use a
/// thread-static BusyManager.
/// </summary>
sealed class BusyManager
{
public struct BusyLock : IDisposable
{
public static readonly BusyLock Failed = new BusyLock(null);
readonly BusyManager manager;
public BusyLock(BusyManager manager)
{
this.manager = manager;
}
public bool Success {
get { return manager != null; }
}
public void Dispose()
{
if (manager != null) {
manager.activeObjects.RemoveAt(manager.activeObjects.Count - 1);
}
}
}
readonly List<object> activeObjects = new List<object>();
public BusyLock Enter(object obj)
{
for (int i = 0; i < activeObjects.Count; i++) {
if (activeObjects[i] == obj)
return BusyLock.Failed;
}
activeObjects.Add(obj);
return new BusyLock(this);
}
}
}

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

@ -1,606 +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.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace ICSharpCode.SharpDevelop.Dom.CSharp
{
public class CSharpAmbience : AbstractAmbience
{
public static IDictionary<string, string> TypeConversionTable {
get { return ICSharpCode.NRefactory.Ast.TypeReference.PrimitiveTypesCSharpReverse; }
}
bool ModifierIsSet(ModifierEnum modifier, ModifierEnum query)
{
return (modifier & query) == query;
}
public override string ConvertAccessibility(ModifierEnum accessibility)
{
if (ShowAccessibility) {
if (ModifierIsSet(accessibility, ModifierEnum.Public)) {
return "public ";
} else if (ModifierIsSet(accessibility, ModifierEnum.Private)) {
return "private ";
} else if (ModifierIsSet(accessibility, ModifierEnum.ProtectedAndInternal)) {
return "protected internal ";
} else if (ModifierIsSet(accessibility, ModifierEnum.Internal)) {
return "internal ";
} else if (ModifierIsSet(accessibility, ModifierEnum.Protected)) {
return "protected ";
}
}
return string.Empty;
}
string GetModifier(IEntity decoration)
{
string ret = "";
if (IncludeHtmlMarkup) {
ret += "<i>";
}
if (decoration.IsStatic) {
ret += "static ";
} else if (decoration.IsSealed) {
ret += "sealed ";
} else if (decoration.IsVirtual) {
ret += "virtual ";
} else if (decoration.IsOverride) {
ret += "override ";
} else if (decoration.IsNew) {
ret += "new ";
}
if (IncludeHtmlMarkup) {
ret += "</i>";
}
return ret;
}
public override string Convert(IClass c)
{
CheckThread();
StringBuilder builder = new StringBuilder();
builder.Append(ConvertAccessibility(c.Modifiers));
if (IncludeHtmlMarkup) {
builder.Append("<i>");
}
if (ShowModifiers) {
if (c.IsStatic) {
builder.Append("static ");
} else if (c.IsSealed) {
switch (c.ClassType) {
case ClassType.Delegate:
case ClassType.Struct:
case ClassType.Enum:
break;
default:
builder.Append("sealed ");
break;
}
} else if (c.IsAbstract && c.ClassType != ClassType.Interface) {
builder.Append("abstract ");
}
#if DEBUG
if (c.HasCompoundClass)
builder.Append("multiple_parts ");
if (c is CompoundClass) {
builder.Append("compound{");
builder.Append(string.Join(",", (c as CompoundClass).Parts.Select(p => p.CompilationUnit.FileName).ToArray()));
builder.Append("} ");
}
#endif
}
if (IncludeHtmlMarkup) {
builder.Append("</i>");
}
if (ShowDefinitionKeyWord) {
switch (c.ClassType) {
case ClassType.Delegate:
builder.Append("delegate");
break;
case ClassType.Class:
case ClassType.Module:
builder.Append("class");
break;
case ClassType.Struct:
builder.Append("struct");
break;
case ClassType.Interface:
builder.Append("interface");
break;
case ClassType.Enum:
builder.Append("enum");
break;
}
builder.Append(' ');
}
if (ShowReturnType && c.ClassType == ClassType.Delegate) {
foreach(IMethod m in c.Methods) {
if (m.Name != "Invoke") continue;
builder.Append(Convert(m.ReturnType));
builder.Append(' ');
}
}
AppendClassNameWithTypeParameters(builder, c, UseFullyQualifiedMemberNames, true, null);
if (ShowParameterList && c.ClassType == ClassType.Delegate) {
builder.Append(" (");
if (IncludeHtmlMarkup) builder.Append("<br>");
foreach(IMethod m in c.Methods) {
if (m.Name != "Invoke") continue;
for (int i = 0; i < m.Parameters.Count; ++i) {
if (IncludeHtmlMarkup) builder.Append("&nbsp;&nbsp;&nbsp;");
builder.Append(Convert(m.Parameters[i]));
if (i + 1 < m.Parameters.Count) builder.Append(", ");
if (IncludeHtmlMarkup) builder.Append("<br>");
}
}
builder.Append(')');
} else if (ShowInheritanceList) {
if (c.BaseTypes.Count > 0) {
builder.Append(" : ");
for (int i = 0; i < c.BaseTypes.Count; ++i) {
builder.Append(c.BaseTypes[i]);
if (i + 1 < c.BaseTypes.Count) {
builder.Append(", ");
}
}
}
}
if (IncludeBody) {
builder.Append("\n{");
}
return builder.ToString();
}
void AppendClassNameWithTypeParameters(StringBuilder builder, IClass c, bool fullyQualified, bool isConvertingClassName, IList<IReturnType> typeArguments)
{
if (isConvertingClassName && IncludeHtmlMarkup) {
builder.Append("<b>");
}
if (fullyQualified) {
if (c.DeclaringType != null) {
AppendClassNameWithTypeParameters(builder, c.DeclaringType, fullyQualified, false, typeArguments);
builder.Append('.');
builder.Append(c.Name);
} else {
builder.Append(c.FullyQualifiedName);
}
} else {
builder.Append(c.Name);
}
if (isConvertingClassName && IncludeHtmlMarkup) {
builder.Append("</b>");
}
// skip type parameters that belong to declaring types (in DOM, inner classes repeat type parameters from outer classes)
int skippedTypeParameterCount = c.DeclaringType != null ? c.DeclaringType.TypeParameters.Count : 0;
// show type parameters for classes only if ShowTypeParameterList is set; but always show them in other cases.
if ((ShowTypeParameterList || !isConvertingClassName) && c.TypeParameters.Count > skippedTypeParameterCount) {
builder.Append('<');
for (int i = skippedTypeParameterCount; i < c.TypeParameters.Count; ++i) {
if (i > skippedTypeParameterCount)
builder.Append(", ");
if (typeArguments != null && i < typeArguments.Count)
AppendReturnType(builder, typeArguments[i], false);
else
builder.Append(ConvertTypeParameter(c.TypeParameters[i]));
}
builder.Append('>');
}
}
public override string ConvertEnd(IClass c)
{
return "}";
}
public override string Convert(IField field)
{
CheckThread();
StringBuilder builder = new StringBuilder();
builder.Append(ConvertAccessibility(field.Modifiers));
if (IncludeHtmlMarkup) {
builder.Append("<i>");
}
if (ShowModifiers) {
if (field.IsConst) {
builder.Append("const ");
} else if (field.IsStatic) {
builder.Append("static ");
}
if (field.IsNew) {
builder.Append("new ");
}
if (field.IsReadonly) {
builder.Append("readonly ");
}
if ((field.Modifiers & ModifierEnum.Volatile) == ModifierEnum.Volatile) {
builder.Append("volatile ");
}
}
if (IncludeHtmlMarkup) {
builder.Append("</i>");
}
if (field.ReturnType != null && ShowReturnType) {
builder.Append(Convert(field.ReturnType));
builder.Append(' ');
}
AppendTypeNameForFullyQualifiedMemberName(builder, field.DeclaringTypeReference);
if (IncludeHtmlMarkup) {
builder.Append("<b>");
}
builder.Append(field.Name);
if (IncludeHtmlMarkup) {
builder.Append("</b>");
}
if (IncludeBody) builder.Append(";");
return builder.ToString();
}
public override string Convert(IProperty property)
{
CheckThread();
StringBuilder builder = new StringBuilder();
builder.Append(ConvertAccessibility(property.Modifiers));
if (ShowModifiers) {
builder.Append(GetModifier(property));
}
if (property.ReturnType != null && ShowReturnType) {
builder.Append(Convert(property.ReturnType));
builder.Append(' ');
}
AppendTypeNameForFullyQualifiedMemberName(builder, property.DeclaringTypeReference);
if (property.IsIndexer) {
builder.Append("this");
} else {
if (IncludeHtmlMarkup) {
builder.Append("<b>");
}
builder.Append(property.Name);
if (IncludeHtmlMarkup) {
builder.Append("</b>");
}
}
if (property.Parameters.Count > 0 && ShowParameterList) {
builder.Append(property.IsIndexer ? '[' : '(');
if (IncludeHtmlMarkup) builder.Append("<br>");
for (int i = 0; i < property.Parameters.Count; ++i) {
if (IncludeHtmlMarkup) builder.Append("&nbsp;&nbsp;&nbsp;");
builder.Append(Convert(property.Parameters[i]));
if (i + 1 < property.Parameters.Count) {
builder.Append(", ");
}
if (IncludeHtmlMarkup) builder.Append("<br>");
}
builder.Append(property.IsIndexer ? ']' : ')');
}
if (IncludeBody) {
builder.Append(" { ");
if (property.CanGet) {
builder.Append("get; ");
}
if (property.CanSet) {
builder.Append("set; ");
}
builder.Append(" } ");
}
return builder.ToString();
}
public override string Convert(IEvent e)
{
CheckThread();
StringBuilder builder = new StringBuilder();
builder.Append(ConvertAccessibility(e.Modifiers));
if (ShowModifiers) {
builder.Append(GetModifier(e));
}
if (ShowDefinitionKeyWord) {
builder.Append("event ");
}
if (e.ReturnType != null && ShowReturnType) {
builder.Append(Convert(e.ReturnType));
builder.Append(' ');
}
AppendTypeNameForFullyQualifiedMemberName(builder, e.DeclaringTypeReference);
if (IncludeHtmlMarkup) {
builder.Append("<b>");
}
builder.Append(e.Name);
if (IncludeHtmlMarkup) {
builder.Append("</b>");
}
if (IncludeBody) builder.Append(";");
return builder.ToString();
}
public override string Convert(IMethod m)
{
CheckThread();
StringBuilder builder = new StringBuilder();
builder.Append(ConvertAccessibility(m.Modifiers));
if (ShowModifiers) {
builder.Append(GetModifier(m));
}
if (!m.IsConstructor && m.ReturnType != null && ShowReturnType) {
builder.Append(Convert(m.ReturnType));
builder.Append(' ');
}
AppendTypeNameForFullyQualifiedMemberName(builder, m.DeclaringTypeReference);
if (IncludeHtmlMarkup) {
builder.Append("<b>");
}
if (m.IsConstructor && m.DeclaringType != null) {
builder.Append(m.DeclaringType.Name);
} else {
builder.Append(m.Name);
}
if (IncludeHtmlMarkup) {
builder.Append("</b>");
}
if (ShowTypeParameterList && m.TypeParameters.Count > 0) {
builder.Append('<');
for (int i = 0; i < m.TypeParameters.Count; ++i) {
if (i > 0) builder.Append(", ");
builder.Append(ConvertTypeParameter(m.TypeParameters[i]));
}
builder.Append('>');
}
if (ShowParameterList) {
builder.Append("(");
if (IncludeHtmlMarkup) builder.Append("<br>");
if (m.IsExtensionMethod) builder.Append("this ");
for (int i = 0; i < m.Parameters.Count; ++i) {
if (IncludeHtmlMarkup) builder.Append("&nbsp;&nbsp;&nbsp;");
builder.Append(Convert(m.Parameters[i]));
if (i + 1 < m.Parameters.Count) {
builder.Append(", ");
}
if (IncludeHtmlMarkup) builder.Append("<br>");
}
builder.Append(')');
}
if (IncludeBody) {
if (m.DeclaringType != null) {
if (m.DeclaringType.ClassType == ClassType.Interface) {
builder.Append(";");
} else {
builder.Append(" {");
}
} else {
builder.Append(" {");
}
}
return builder.ToString();
}
void AppendTypeNameForFullyQualifiedMemberName(StringBuilder builder, IReturnType declaringType)
{
if (UseFullyQualifiedMemberNames && declaringType != null) {
AppendReturnType(builder, declaringType, true);
builder.Append('.');
}
}
string ConvertTypeParameter(ITypeParameter tp)
{
if (tp.BoundTo != null)
return Convert(tp.BoundTo);
else
return tp.Name;
}
public override string ConvertEnd(IMethod m)
{
return "}";
}
public override string Convert(IReturnType returnType)
{
CheckThread();
if (returnType == null) {
return String.Empty;
}
returnType = returnType.GetDirectReturnType();
StringBuilder builder = new StringBuilder();
AppendReturnType(builder, returnType, false);
return builder.ToString();
}
void AppendReturnType(StringBuilder builder, IReturnType returnType, bool forceFullyQualifiedName)
{
IReturnType arrayReturnType = returnType;
returnType = GetElementType(returnType);
if (returnType == null)
return;
string fullName = returnType.FullyQualifiedName;
string shortName;
bool isConstructedType = returnType.IsConstructedReturnType;
if (fullName != null && !isConstructedType && TypeConversionTable.TryGetValue(fullName, out shortName)) {
builder.Append(shortName);
} else {
IClass c = returnType.GetUnderlyingClass();
if (c != null) {
IList<IReturnType> ta = isConstructedType ? returnType.CastToConstructedReturnType().TypeArguments : null;
AppendClassNameWithTypeParameters(builder, c, forceFullyQualifiedName || UseFullyQualifiedTypeNames, false, ta);
} else {
if (UseFullyQualifiedTypeNames || forceFullyQualifiedName) {
builder.Append(fullName);
} else {
builder.Append(returnType.Name);
}
if (isConstructedType) {
builder.Append('<');
IList<IReturnType> ta = returnType.CastToConstructedReturnType().TypeArguments;
for (int i = 0; i < ta.Count; ++i) {
if (i > 0) builder.Append(", ");
AppendReturnType(builder, ta[i], false);
}
builder.Append('>');
}
}
}
UnpackArrayType(builder, arrayReturnType);
}
static IReturnType GetElementType(IReturnType potentialArrayType)
{
if (potentialArrayType == null)
return null;
ArrayReturnType result;
while ((result = potentialArrayType.CastToArrayReturnType()) != null) {
potentialArrayType = result.ArrayElementType;
}
return potentialArrayType;
}
static void UnpackArrayType(StringBuilder builder, IReturnType returnType)
{
if (returnType.IsArrayReturnType) {
builder.Append('[');
int dimensions = returnType.CastToArrayReturnType().ArrayDimensions;
for (int i = 1; i < dimensions; ++i) {
builder.Append(',');
}
builder.Append(']');
UnpackArrayType(builder, returnType.CastToArrayReturnType().ArrayElementType);
}
}
public override string Convert(IParameter param)
{
CheckThread();
StringBuilder builder = new StringBuilder();
if (IncludeHtmlMarkup) {
builder.Append("<i>");
}
if (param.IsRef) {
builder.Append("ref ");
} else if (param.IsOut) {
builder.Append("out ");
} else if (param.IsParams) {
builder.Append("params ");
}
if (IncludeHtmlMarkup) {
builder.Append("</i>");
}
builder.Append(Convert(param.ReturnType));
if (ShowParameterNames) {
builder.Append(' ');
builder.Append(param.Name);
}
return builder.ToString();
}
public override string WrapAttribute(string attribute)
{
return "[" + attribute + "]";
}
public override string WrapComment(string comment)
{
return "// " + comment;
}
public override string GetIntrinsicTypeName(string dotNetTypeName)
{
string shortName;
if (TypeConversionTable.TryGetValue(dotNetTypeName, out shortName)) {
return shortName;
}
return dotNetTypeName;
}
}
}

55
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/CSharpExpressionContext.cs

@ -1,55 +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 ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.SharpDevelop.Dom.CSharp
{
public static class CSharpExpressionContext
{
/// <summary>The context is the body of a property declaration.</summary>
/// <example>string Name { *expr* }</example>
public readonly static ExpressionContext PropertyDeclaration = new ExpressionContext.DefaultExpressionContext("PropertyDeclaration");
/// <summary>The context is the body of a property declaration inside an interface.</summary>
/// <example>string Name { *expr* }</example>
public readonly static ExpressionContext InterfacePropertyDeclaration = new ExpressionContext.DefaultExpressionContext("InterfacePropertyDeclaration");
/// <summary>The context is the body of a event declaration.</summary>
/// <example>event EventHandler NameChanged { *expr* }</example>
public readonly static ExpressionContext EventDeclaration = new ExpressionContext.DefaultExpressionContext("EventDeclaration");
/// <summary>The context is after the type parameters of a type/method declaration.
/// The only valid keyword is "where"</summary>
/// <example>class &lt;T&gt; *expr*</example>
public readonly static ExpressionContext ConstraintsStart = new ExpressionContext.DefaultExpressionContext("ConstraintsStart");
/// <summary>The context is after the 'where' of a constraints list.</summary>
/// <example>class &lt;T&gt; where *expr*</example>
public readonly static ExpressionContext Constraints = new ExpressionContext.NonStaticTypeExpressionContext("Constraints", false);
/// <summary>The context is the body of an interface declaration.</summary>
public readonly static ExpressionContext InterfaceDeclaration = new ExpressionContext.NonStaticTypeExpressionContext("InterfaceDeclaration", true);
/// <summary>Context expects "base" or "this".</summary>
/// <example>public ClassName() : *expr*</example>
public readonly static ExpressionContext BaseConstructorCall = new ExpressionContext.DefaultExpressionContext("BaseConstructorCall");
/// <summary>The first parameter</summary>
/// <example>void MethodName(*expr*)</example>
public readonly static ExpressionContext FirstParameterType = new ExpressionContext.NonStaticTypeExpressionContext("FirstParameterType", false);
/// <summary>Another parameter</summary>
/// <example>void MethodName(..., *expr*)</example>
public readonly static ExpressionContext ParameterType = new ExpressionContext.NonStaticTypeExpressionContext("ParameterType", false);
/// <summary>Context expects a fully qualified type name.</summary>
/// <example>using Alias = *expr*;</example>
public readonly static ExpressionContext FullyQualifiedType = new ExpressionContext.DefaultExpressionContext("FullyQualifiedType");
/// <summary>Context expects is a property name in an object initializer.</summary>
/// <example>new *type* [(args)] { *expr* = ... }</example>
public readonly static ExpressionContext ObjectInitializer = new ExpressionContext.DefaultExpressionContext("ObjectInitializer");
}
}

1057
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/ExpressionFinder.cs

File diff suppressed because it is too large Load Diff

340
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/OverloadResolution.cs

@ -1,340 +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.Linq;
using System.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom.CSharp
{
/// <summary>
/// Implements C# 3.0 overload resolution.
/// </summary>
public sealed class OverloadResolution
{
private OverloadResolution() {}
public static IMethodOrProperty FindOverload(IEnumerable<IMethodOrProperty> list,
IReturnType[] arguments,
bool allowAdditionalArguments,
bool substituteInferredTypes,
out bool acceptableMatch)
{
OverloadResolution or = new OverloadResolution();
or.candidates = list.Select(m => new Candidate(m)).ToList();
or.arguments = arguments;
or.allowAdditionalArguments = allowAdditionalArguments;
if (or.candidates.Count == 0)
throw new ArgumentException("at least one candidate is required");
MemberLookupHelper.Log("OverloadResolution");
MemberLookupHelper.Log(" arguments = ", arguments);
or.ConstructExpandedForms();
or.InferTypeArguments();
or.CheckApplicability();
Candidate result = or.FindBestCandidate();
MemberLookupHelper.Log("Overload resolution finished. Winning candidate = " + result);
acceptableMatch = result.Status == CandidateStatus.Success;
if (substituteInferredTypes)
return result.Method;
else
return result.OriginalMethod;
}
enum CandidateStatus
{
Success,
WrongParameterCount,
TypeInferenceFailed,
NotApplicable
}
sealed class Candidate
{
public bool IsExpanded;
public IMethodOrProperty Method;
public IMethodOrProperty OriginalMethod;
public CandidateStatus Status = CandidateStatus.Success;
public int ApplicableArgumentCount;
public IList<IParameter> Parameters {
get { return Method.Parameters; }
}
public int TypeParameterCount {
get {
IMethod m = Method as IMethod;
if (m != null)
return m.TypeParameters.Count;
else
return 0;
}
}
public Candidate(IMethodOrProperty method)
{
if (method == null)
throw new ArgumentNullException("method");
this.Method = method;
this.OriginalMethod = method;
}
public override string ToString()
{
return "[Candidate: " + Method + ", Status=" + Status + "]";
}
}
List<Candidate> candidates;
IList<IReturnType> arguments;
bool allowAdditionalArguments;
/// <summary>
/// For methods having a params-array as last parameter, expand the params array to
/// n parameters of the element type and add those as new candidates.
/// Mark candidates with the wrong parameter count as Status.WrongParameterCount.
/// </summary>
void ConstructExpandedForms()
{
LogStep("Step 1 (Construct expanded forms)");
foreach (Candidate candidate in candidates.ToArray()) {
if (candidate.Status == CandidateStatus.Success) {
if (candidate.Parameters.Count > 0 && arguments.Count >= candidate.Parameters.Count - 1) {
IParameter lastParameter = candidate.Parameters[candidate.Parameters.Count - 1];
if (lastParameter.IsParams && lastParameter.ReturnType != null && lastParameter.ReturnType.IsArrayReturnType) {
// try to construct an expanded form with the correct parameter count
IReturnType elementType = lastParameter.ReturnType.CastToArrayReturnType().ArrayElementType;
IMethodOrProperty expanded = (IMethodOrProperty)candidate.Method.CreateSpecializedMember();
expanded.Parameters.RemoveAt(candidate.Parameters.Count - 1);
int index = 0;
while (expanded.Parameters.Count < arguments.Count) {
expanded.Parameters.Add(new DefaultParameter(lastParameter.Name + (index++), elementType, lastParameter.Region));
}
candidates.Add(new Candidate(expanded) {
IsExpanded = true,
OriginalMethod = candidate.Method
});
}
}
if (allowAdditionalArguments) {
if (candidate.Parameters.Count < arguments.Count) {
candidate.Status = CandidateStatus.WrongParameterCount;
}
} else {
if (candidate.Parameters.Count != arguments.Count) {
candidate.Status = CandidateStatus.WrongParameterCount;
}
}
}
}
}
/// <summary>
/// Infer the type arguments for generic methods.
/// </summary>
void InferTypeArguments()
{
LogStep("Step 2 (Infer type arguments)");
foreach (Candidate candidate in candidates) {
IMethod method = candidate.Method as IMethod;
if (method != null && method.TypeParameters.Count > 0
&& candidate.Status == CandidateStatus.Success)
{
bool success;
IReturnType[] typeArguments = TypeInference.InferTypeArguments(method, arguments, out success);
if (!success) {
candidate.Status = CandidateStatus.TypeInferenceFailed;
}
candidate.Method = ApplyTypeArgumentsToMethod(method, typeArguments);
}
}
}
static IMethod ApplyTypeArgumentsToMethod(IMethod genericMethod, IList<IReturnType> typeArguments)
{
if (typeArguments != null && typeArguments.Count > 0) {
// apply inferred type arguments
IMethod method = (IMethod)genericMethod.CreateSpecializedMember();
method.ReturnType = ConstructedReturnType.TranslateType(method.ReturnType, typeArguments, true);
for (int i = 0; i < method.Parameters.Count; ++i) {
method.Parameters[i].ReturnType = ConstructedReturnType.TranslateType(method.Parameters[i].ReturnType, typeArguments, true);
}
for (int i = 0; i < Math.Min(typeArguments.Count, method.TypeParameters.Count); i++) {
var tp = new BoundTypeParameter(method.TypeParameters[i], method.DeclaringType, method);
tp.BoundTo = typeArguments[i];
method.TypeParameters[i] = tp;
}
return method;
} else {
return genericMethod;
}
}
void CheckApplicability()
{
LogStep("Step 3 (CheckApplicability)");
foreach (Candidate candidate in candidates) {
int c = Math.Min(arguments.Count, candidate.Parameters.Count);
for (int i = 0; i < c; i++) {
if (MemberLookupHelper.IsApplicable(arguments[i], candidate.Parameters[i], candidate.Method as IMethod))
candidate.ApplicableArgumentCount++;
}
if (candidate.Status == CandidateStatus.Success && candidate.ApplicableArgumentCount < arguments.Count) {
candidate.Status = CandidateStatus.NotApplicable;
}
}
}
Candidate FindBestCandidate()
{
LogStep("Step 4 (FindBestCandidate)");
// Find a candidate that is better than all other candidates
Candidate best = null;
foreach (Candidate candidate in candidates) {
if (candidate.Status == CandidateStatus.Success) {
if (best == null || GetBetterFunctionMember(best, candidate) == 2) {
best = candidate;
}
}
}
if (best != null)
return best;
// no successful candidate found:
// find the candidate that is nearest to being applicable
// first try only candidates with the correct parameter count
foreach (Candidate candidate in candidates) {
if (candidate.Status != CandidateStatus.WrongParameterCount) {
if (best == null || candidate.ApplicableArgumentCount > best.ApplicableArgumentCount)
best = candidate;
}
}
if (best != null)
return best;
// if all candidates have the wrong parameter count, return the candidate
// with the most applicable parameters.
best = candidates[0];
foreach (Candidate candidate in candidates) {
if (candidate.ApplicableArgumentCount > best.ApplicableArgumentCount)
best = candidate;
}
return best;
}
/// <summary>
/// Gets which function member is better. (§ 14.4.2.2)
/// </summary>
/// <returns>0 if neither method is better. 1 if c1 is better. 2 if c2 is better.</returns>
int GetBetterFunctionMember(Candidate c1, Candidate c2)
{
int length = Math.Min(Math.Min(c1.Parameters.Count, c2.Parameters.Count), arguments.Count);
bool foundBetterParamIn1 = false;
bool foundBetterParamIn2 = false;
for (int i = 0; i < length; i++) {
if (arguments[i] == null)
continue;
int res = MemberLookupHelper.GetBetterConversion(arguments[i], c1.Parameters[i].ReturnType, c2.Parameters[i].ReturnType);
if (res == 1) foundBetterParamIn1 = true;
if (res == 2) foundBetterParamIn2 = true;
}
if (foundBetterParamIn1 && !foundBetterParamIn2)
return 1;
if (foundBetterParamIn2 && !foundBetterParamIn1)
return 2;
if (foundBetterParamIn1 && foundBetterParamIn2)
return 0; // ambigous
// If none conversion is better than any other, it is possible that the
// expanded parameter lists are the same:
for (int i = 0; i < length; i++) {
if (!object.Equals(c1.Parameters[i].ReturnType, c2.Parameters[i].ReturnType)) {
// if expanded parameters are not the same, neither function member is better
return 0;
}
}
// the expanded parameters are the same, apply the tie-breaking rules from the spec:
// if one method is generic and the other non-generic, the non-generic is better
bool m1IsGeneric = c1.TypeParameterCount > 0;
bool m2IsGeneric = c2.TypeParameterCount > 0;
if (m1IsGeneric && !m2IsGeneric) return 2;
if (m2IsGeneric && !m1IsGeneric) return 1;
// for params parameters: non-expanded calls are better
if (c1.IsExpanded && !c2.IsExpanded) return 2;
if (c2.IsExpanded && !c1.IsExpanded) return 1;
// if the number of parameters is different, the one with more parameters is better
// this occurs when only when both methods are expanded
if (c1.OriginalMethod.Parameters.Count > c2.OriginalMethod.Parameters.Count) return 1;
if (c2.OriginalMethod.Parameters.Count > c1.OriginalMethod.Parameters.Count) return 2;
IReturnType[] m1ParamTypes = new IReturnType[c1.Parameters.Count];
IReturnType[] m2ParamTypes = new IReturnType[c2.Parameters.Count];
for (int i = 0; i < m1ParamTypes.Length; i++) {
m1ParamTypes[i] = c1.Parameters[i].ReturnType;
m2ParamTypes[i] = c2.Parameters[i].ReturnType;
}
return GetMoreSpecific(m1ParamTypes, m2ParamTypes);
}
/// <summary>
/// Gets which return type list is more specific.
/// § 14.4.2.2: types with generic arguments are less specific than types with fixed arguments
/// </summary>
/// <returns>0 if both are equally specific, 1 if <paramref name="r"/> is more specific,
/// 2 if <paramref name="s"/> is more specific.</returns>
static int GetMoreSpecific(IList<IReturnType> r, IList<IReturnType> s)
{
bool foundMoreSpecificParamIn1 = false;
bool foundMoreSpecificParamIn2 = false;
int length = Math.Min(r.Count, s.Count);
for (int i = 0; i < length; i++) {
int res = GetMoreSpecific(r[i], s[i]);
if (res == 1) foundMoreSpecificParamIn1 = true;
if (res == 2) foundMoreSpecificParamIn2 = true;
}
if (foundMoreSpecificParamIn1 && !foundMoreSpecificParamIn2)
return 1;
if (foundMoreSpecificParamIn2 && !foundMoreSpecificParamIn1)
return 2;
return 0;
}
static int GetMoreSpecific(IReturnType r, IReturnType s)
{
if (r == null && s == null) return 0;
if (r == null) return 2;
if (s == null) return 1;
if (r.IsGenericReturnType && !(s.IsGenericReturnType))
return 2;
if (s.IsGenericReturnType && !(r.IsGenericReturnType))
return 1;
if (r.IsArrayReturnType && s.IsArrayReturnType)
return GetMoreSpecific(r.CastToArrayReturnType().ArrayElementType, s.CastToArrayReturnType().ArrayElementType);
if (r.IsConstructedReturnType && s.IsConstructedReturnType)
return GetMoreSpecific(r.CastToConstructedReturnType().TypeArguments, s.CastToConstructedReturnType().TypeArguments);
return 0;
}
[System.Diagnostics.ConditionalAttribute("DEBUG")]
void LogStep(string title)
{
MemberLookupHelper.Log(" candidates = ", candidates);
MemberLookupHelper.Log("Overload resolution (" + title + ")");
}
[System.Diagnostics.ConditionalAttribute("DEBUG")]
void Log(string text)
{
MemberLookupHelper.Log(text);
}
}
}

480
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/TypeInference.cs

@ -1,480 +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.Collections.Generic;
using System.Linq;
namespace ICSharpCode.SharpDevelop.Dom.CSharp
{
/// <summary>
/// Implements C# 3.0 type inference.
/// </summary>
sealed class TypeInference
{
private TypeInference() {}
public static IReturnType[] InferTypeArguments(IMethod method, IList<IReturnType> arguments, out bool success)
{
TypeInference ti = new TypeInference();
Log("Doing type inference for " + new CSharpAmbience().Convert(method));
Log(" with arguments = ", arguments);
ti.typeParameters = method.TypeParameters.Select(tp => new TP(tp)).ToList();
ti.parameterTypes = method.Parameters.Select(p => p.ReturnType).Take(arguments.Count).ToList();
ti.arguments = arguments.Take(ti.parameterTypes.Count).ToArray();
ti.PhaseOne();
success = ti.PhaseTwo();
IReturnType[] result = ti.typeParameters.Select(tp => tp.FixedTo).ToArray();
Log("Type inference for " + method.DotNetName + " " + (success ? "succeeded" : "failed") + ": ", result);
return result;
}
List<TP> typeParameters;
List<IReturnType> parameterTypes;
IList<IReturnType> arguments;
sealed class TP {
public readonly ITypeParameter TypeParameter;
public IReturnType FixedTo;
public HashSet<IReturnType> Bounds = new HashSet<IReturnType>();
public bool Fixed {
get { return FixedTo != null; }
}
public TP(ITypeParameter typeParameter)
{
this.TypeParameter = typeParameter;
}
/// <summary>
/// Gets whether this type parameter occurs in the specified return type.
/// </summary>
public bool OccursIn(IReturnType rt)
{
ArrayReturnType art = rt.CastToArrayReturnType();
if (art != null) {
return OccursIn(art.ArrayElementType);
}
ConstructedReturnType crt = rt.CastToConstructedReturnType();
if (crt != null) {
return crt.TypeArguments.Any(ta => OccursIn(ta));
}
GenericReturnType grt = rt.CastToGenericReturnType();
if (grt != null) {
return this.TypeParameter.Equals(grt.TypeParameter);
}
return false;
}
public override string ToString()
{
return TypeParameter.Method.Name + "." + TypeParameter.Name;
}
}
void PhaseOne()
{
Log("Phase One");
for (int i = 0; i < arguments.Count; i++) {
IReturnType ei = arguments[i];
IReturnType Ti = parameterTypes[i];
if (ei is AnonymousMethodReturnType || ei is MethodGroupReturnType) {
Log("MakeExplicitParameterTypeInference for #" + i);
MakeExplicitParameterTypeInference(ei, Ti);
if (OutputTypeContainsUnfixed(ei, Ti) && !InputTypesContainsUnfixed(ei, Ti)) {
// an output type inference (§7.4.2.6) is made for ei with type Ti.
Log("MakeOutputTypeInference for #" + i);
MakeOutputTypeInference(ei, Ti);
}
} else {
Log("MakeOutputTypeInference for #" + i);
MakeOutputTypeInference(ei, Ti);
}
}
}
bool PhaseTwo()
{
Log("Phase Two");
// All unfixed type variables Xi which do not depend on any Xj are fixed.
List<TP> typeParametersToFix = new List<TP>();
foreach (TP Xi in typeParameters) {
if (Xi.Fixed == false) {
if (!typeParameters.Any((TP Xj) => DependsOn(Xi, Xj))) {
typeParametersToFix.Add(Xi);
}
}
}
// If no such type variables exist, all unfixed type variables Xi are fixed for which all of the following hold:
if (typeParametersToFix.Count == 0) {
foreach (TP Xi in typeParameters) {
// Xi has a non­empty set of bounds
if (Xi.Fixed == false && Xi.Bounds.Count > 0) {
// There is at least one type variable Xj that depends on Xi
if (typeParameters.Any((TP Xj) => DependsOn(Xj, Xi))) {
typeParametersToFix.Add(Xi);
}
}
}
}
// now fix 'em
bool errorDuringFix = false;
foreach (TP tp in typeParametersToFix) {
if (!Fix(tp))
errorDuringFix = true;
}
if (errorDuringFix)
return false;
bool unfixedTypeVariablesExist = typeParameters.Any((TP X) => X.Fixed == false);
if (typeParametersToFix.Count == 0 && unfixedTypeVariablesExist) {
// If no such type variables exist and there are still unfixed type variables, type inference fails.
return false;
} else if (!unfixedTypeVariablesExist) {
// Otherwise, if no further unfixed type variables exist, type inference succeeds.
return true;
} else {
// Otherwise, for all arguments ei with corresponding parameter type Ti
for (int i = 0; i < arguments.Count; i++) {
IReturnType ei = arguments[i];
IReturnType Ti = parameterTypes[i];
// where the output types (§7.4.2.4) contain unfixed type variables Xj
// but the input types (§7.4.2.3) do not
if (OutputTypeContainsUnfixed(ei, Ti) && !InputTypesContainsUnfixed(ei, Ti)) {
// an output type inference (§7.4.2.6) is made for ei with type Ti.
Log("MakeOutputTypeInference for #" + i);
MakeOutputTypeInference(ei, Ti);
}
}
// Then the second phase is repeated.
return PhaseTwo();
}
}
bool OutputTypeContainsUnfixed(IReturnType argumentType, IReturnType parameterType)
{
return OutputTypes(argumentType, parameterType).Any(t => TypeContainsUnfixedParameter(t));
}
bool InputTypesContainsUnfixed(IReturnType argumentType, IReturnType parameterType)
{
return InputTypes(argumentType, parameterType).Any(t => TypeContainsUnfixedParameter(t));
}
bool TypeContainsUnfixedParameter(IReturnType type)
{
return typeParameters.Where(tp => !tp.Fixed).Any(tp => tp.OccursIn(type));
}
IEnumerable<IReturnType> OutputTypes(IReturnType e, IReturnType T)
{
AnonymousMethodReturnType amrt = e as AnonymousMethodReturnType;
if (amrt != null || e is MethodGroupReturnType) {
IMethod m = GetDelegateOrExpressionTreeSignature(T, amrt != null && amrt.CanBeConvertedToExpressionTree);
if (m != null) {
return new[] { m.ReturnType };
}
}
return EmptyList<IReturnType>.Instance;
}
IEnumerable<IReturnType> InputTypes(IReturnType e, IReturnType T)
{
AnonymousMethodReturnType amrt = e as AnonymousMethodReturnType;
if (amrt != null && amrt.HasImplicitlyTypedParameters || e is MethodGroupReturnType) {
IMethod m = GetDelegateOrExpressionTreeSignature(T, amrt != null && amrt.CanBeConvertedToExpressionTree);
if (m != null) {
return m.Parameters.Select(p => p.ReturnType);
}
}
return EmptyList<IReturnType>.Instance;
}
internal static IMethod GetDelegateOrExpressionTreeSignature(IReturnType rt, bool allowExpressionTree)
{
if (rt == null)
return null;
IClass c = rt.GetUnderlyingClass();
if (allowExpressionTree && c != null && c.FullyQualifiedName == "System.Linq.Expressions.Expression") {
ConstructedReturnType crt = rt.CastToConstructedReturnType();
if (crt != null && crt.TypeArguments.Count == 1) {
// get delegate type from expression type
rt = crt.TypeArguments[0];
c = rt != null ? rt.GetUnderlyingClass() : null;
}
}
if (c != null && c.ClassType == ClassType.Delegate) {
return rt.GetMethods().FirstOrDefault((IMethod m) => m.Name == "Invoke");
}
return null;
}
bool DependsDirectlyOn(TP Xi, TP Xj)
{
if (Xj.Fixed)
return false;
for (int k = 0; k < arguments.Count; k++) {
if (InputTypes(arguments[k], parameterTypes[k]).Any(t => Xj.OccursIn(t))
&& OutputTypes(arguments[k], parameterTypes[k]).Any(t => Xi.OccursIn(t)))
{
return true;
}
}
return false;
}
void AddDependencies(HashSet<TP> hash, TP Xi)
{
foreach (TP Xj in typeParameters) {
if (DependsDirectlyOn(Xi, Xj)) {
if (hash.Add(Xj))
AddDependencies(hash, Xj);
}
}
}
HashSet<TP> GetDependencies(TP X)
{
HashSet<TP> hash = new HashSet<TP>();
AddDependencies(hash, X);
return hash;
}
bool DependsOn(TP Xi, TP Xj)
{
return GetDependencies(Xi).Contains(Xj);
}
void MakeOutputTypeInference(IReturnType e, IReturnType T)
{
//If e is an anonymous function with inferred return type  U (§7.4.2.11) and T is
// a delegate type or expression tree type with return type Tb, then a lower­bound
// inference (§7.4.2.9) is made from U for Tb.
AnonymousMethodReturnType amrt = e as AnonymousMethodReturnType;
if (amrt != null) {
IMethod m = GetDelegateOrExpressionTreeSignature(T, amrt.CanBeConvertedToExpressionTree);
if (m != null) {
IReturnType inferredReturnType;
if (amrt.HasParameterList && amrt.MethodParameters.Count == m.Parameters.Count) {
var inferredParameterTypes = m.Parameters.Select(p => SubstituteFixedTypes(p.ReturnType)).ToArray();
inferredReturnType = amrt.ResolveReturnType(inferredParameterTypes);
} else {
inferredReturnType = amrt.ResolveReturnType();
}
MakeLowerBoundInference(inferredReturnType, m.ReturnType);
return;
}
}
// Otherwise, if e is a method group and T is a delegate type or expression tree type
// return type Tb with parameter types T1…Tk and return type Tb, and overload resolution
// of e with the types T1…Tk yields a single method with return type U, then a lower­bound
// inference is made from U for Tb.
if (e is MethodGroupReturnType) {
// the MS C# doesn't seem to implement this rule, so we can safely skip this
return;
}
// Otherwise, if e is an expression with type U, then a lower­bound inference is made from
// U for T.
MakeLowerBoundInference(e, T);
}
IReturnType SubstituteFixedTypes(IReturnType rt)
{
return ConstructedReturnType.TranslateType(
rt, typeParameters.Select(tp => tp.FixedTo).ToList(), true);
}
void MakeExplicitParameterTypeInference(IReturnType e, IReturnType T)
{
// If e is an explicitly typed anonymous function with parameter types U1…Uk and T is a
// delegate type with parameter types V1…Vk then for each Ui an exact inference (§7.4.2.8)
// is made from Ui for the corresponding Vi.
AnonymousMethodReturnType amrt = e as AnonymousMethodReturnType;
if (amrt != null && amrt.HasParameterList) {
IMethod m = GetDelegateOrExpressionTreeSignature(T, amrt.CanBeConvertedToExpressionTree);
if (m != null && amrt.MethodParameters.Count == m.Parameters.Count) {
for (int i = 0; i < amrt.MethodParameters.Count; i++) {
MakeExactInference(amrt.MethodParameters[i].ReturnType, m.Parameters[i].ReturnType);
}
}
}
}
/// <summary>
/// Make exact inference from U for V.
/// </summary>
void MakeExactInference(IReturnType U, IReturnType V)
{
Log(" MakeExactInference from " + U + " for " + V);
if (U == null || V == null)
return;
// If V is one of the unfixed Xi then U is added to the set of bounds for Xi.
TP tp = GetTPForType(V);
if (tp != null && tp.Fixed == false) {
Log(" Add bound '" + U.DotNetName + "' to " + tp);
tp.Bounds.Add(U);
return;
}
// Otherwise if U is an array type Ue[…] and V is an array type Ve[…] of the same rank
// then an exact inference from Ue to Ve is made
ArrayReturnType arrU = U.CastToArrayReturnType();
ArrayReturnType arrV = V.CastToArrayReturnType();
if (arrU != null && arrV != null && arrU.ArrayDimensions == arrV.ArrayDimensions) {
MakeExactInference(arrU.ArrayElementType, arrV.ArrayElementType);
return;
}
// Otherwise if V is a constructed type C<V1…Vk> and U is a constructed
// type C<U1…Uk> then an exact inference is made from each Ui to the corresponding Vi.
ConstructedReturnType CU = U.CastToConstructedReturnType();
ConstructedReturnType CV = V.CastToConstructedReturnType();
if (CU != null && CV != null
&& object.Equals(CU.UnboundType, CV.UnboundType)
&& CU.TypeArgumentCount == CV.TypeArgumentCount
&& CU.TypeArguments.Count == CU.TypeArgumentCount
&& CV.TypeArguments.Count == CV.TypeArgumentCount)
{
for (int i = 0; i < CU.TypeArgumentCount; i++) {
MakeExactInference(CU.TypeArguments[i], CV.TypeArguments[i]);
}
return;
}
}
TP GetTPForType(IReturnType t)
{
if (t == null)
return null;
GenericReturnType grt = t.CastToGenericReturnType();
if (grt != null) {
return typeParameters.FirstOrDefault(tp => tp.TypeParameter.Equals(grt.TypeParameter));
}
return null;
}
/// <summary>
/// Make lower bound inference from U for V.
/// </summary>
void MakeLowerBoundInference(IReturnType U, IReturnType V)
{
Log(" MakeLowerBoundInference from " + U + " for " + V);
if (U == null || V == null)
return;
// If V is one of the unfixed Xi then U is added to the set of bounds for Xi.
TP tp = GetTPForType(V);
if (tp != null && tp.Fixed == false) {
Log(" Add bound '" + U.DotNetName + "' to " + tp);
tp.Bounds.Add(U);
return;
}
// Otherwise if U is an array type Ue[…] and V is either an array type Ve[…]of the
// same rank, or if U is a one­dimensional array type Ue[]and V is one of
// IEnumerable<Ve>, ICollection<Ve> or IList<Ve> then
ArrayReturnType arrU = U.CastToArrayReturnType();
ArrayReturnType arrV = V.CastToArrayReturnType();
ConstructedReturnType CV = V.CastToConstructedReturnType();
if (arrU != null &&
(arrV != null && arrU.ArrayDimensions == arrV.ArrayDimensions
|| (arrU.ArrayDimensions == 1 && IsIEnumerableCollectionOrList(CV))))
{
IReturnType Ue = arrU.ArrayElementType;
IReturnType Ve = arrV != null ? arrV.ArrayElementType : CV.TypeArguments[0];
// If Ue is known to be a reference type then a lower­bound inference from Ue to Ve is made
if (IsReferenceType(Ue) ?? false) {
MakeLowerBoundInference(Ue, Ve);
} else {
// Otherwise an exact inference from Ue to Ve is made
MakeExactInference(Ue, Ve);
}
return;
}
// Otherwise if V is a constructed type C<V1…Vk> and there is a unique set of
// types U1…Uk such that a standard implicit conversion exists from U to C<U1…Uk>
// then an exact inference is made from each Ui for the corresponding Vi.
if (CV != null) {
foreach (IReturnType U2 in MemberLookupHelper.GetTypeInheritanceTree(U)) {
ConstructedReturnType CU2 = U2.CastToConstructedReturnType();
if (CU2 != null &&
object.Equals(CU2.UnboundType, CV.UnboundType) &&
CU2.TypeArgumentCount == CV.TypeArgumentCount
&& CU2.TypeArguments.Count == CU2.TypeArgumentCount // unfortunately these might not be the same...
&& CV.TypeArguments.Count == CV.TypeArgumentCount)
{
for (int i = 0; i < CU2.TypeArgumentCount; i++) {
MakeExactInference(CU2.TypeArguments[i], CV.TypeArguments[i]);
}
return;
}
}
}
}
bool IsIEnumerableCollectionOrList(ConstructedReturnType rt)
{
if (rt == null || rt.TypeArgumentCount != 1)
return false;
switch (rt.UnboundType.FullyQualifiedName) {
case "System.Collections.Generic.IList":
case "System.Collections.Generic.ICollection":
case "System.Collections.Generic.IEnumerable":
return true;
default:
return false;
}
}
bool? IsReferenceType(IReturnType rt)
{
if (rt == null)
return null;
IClass c = rt.GetUnderlyingClass();
if (c == null)
return null;
switch (c.ClassType) {
case ClassType.Enum:
case ClassType.Struct:
return false;
default:
return true;
}
}
bool Fix(TP X)
{
Log("Trying to fix " + X);
Log(" bounds = ", X.Bounds);
List<IReturnType> candidates = new List<IReturnType>(X.Bounds);
foreach (IReturnType U in X.Bounds) {
candidates.RemoveAll((IReturnType candidate) => !MemberLookupHelper.ConversionExists(U, candidate));
}
Log(" candidates after removal round = ", candidates);
if (candidates.Count == 0)
return false;
var results = candidates.Where(
c1 => candidates.All(c2 => MemberLookupHelper.ConversionExists(c1, c2))
).ToList();
Log(" possible solutions (should be exactly one) = ", candidates);
if (results.Count == 1) {
X.FixedTo = results[0];
return true;
} else {
return false;
}
}
[System.Diagnostics.ConditionalAttribute("DEBUG")]
static void Log(string text)
{
MemberLookupHelper.Log(text);
}
[System.Diagnostics.ConditionalAttribute("DEBUG")]
static void Log(string text, IEnumerable<IReturnType> types)
{
MemberLookupHelper.Log(text, types);
}
}
}

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

@ -1,564 +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.Collections;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.SharpDevelop.Dom.ReflectionLayer;
using Mono.Cecil;
using Mono.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
public static class CecilReader
{
sealed class DummyAssemblyResolver : IAssemblyResolver
{
public AssemblyDefinition Resolve(AssemblyNameReference name)
{
return null;
}
public AssemblyDefinition Resolve(string fullName)
{
return null;
}
public AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters)
{
return null;
}
public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters)
{
return null;
}
}
public static ReflectionProjectContent LoadAssembly(string fileName, ProjectContentRegistry registry)
{
if (fileName == null)
throw new ArgumentNullException("fileName");
if (registry == null)
throw new ArgumentNullException("registry");
LoggingService.Info("Cecil: Load from " + fileName);
AssemblyDefinition asm = AssemblyDefinition.ReadAssembly(fileName, new ReaderParameters { AssemblyResolver = new DummyAssemblyResolver() });
List<DomAssemblyName> referencedAssemblies = new List<DomAssemblyName>();
foreach (ModuleDefinition module in asm.Modules) {
foreach (AssemblyNameReference anr in module.AssemblyReferences) {
referencedAssemblies.Add(new DomAssemblyName(anr.FullName));
}
}
return new CecilProjectContent(asm.Name.FullName, fileName, referencedAssemblies.ToArray(), asm, registry);
}
static void AddAttributes(IProjectContent pc, IEntity member, IList<IAttribute> list, ICustomAttributeProvider attributeProvider)
{
if (!attributeProvider.HasCustomAttributes)
return;
foreach (CustomAttribute att in attributeProvider.CustomAttributes) {
DefaultAttribute a = new DefaultAttribute(CreateType(pc, member, att.Constructor.DeclaringType));
// Currently Cecil returns string instead of TypeReference for typeof() arguments to attributes
try {
foreach (var argument in att.ConstructorArguments) {
a.PositionalArguments.Add(GetValue(pc, member, argument));
}
foreach (CustomAttributeNamedArgument entry in att.Properties) {
// some obfuscated assemblies may contain duplicate named arguments; we'll have to ignore those
if (!a.NamedArguments.ContainsKey(entry.Name))
a.NamedArguments.Add(entry.Name, GetValue(pc, member, entry.Argument));
}
} catch (InvalidOperationException) {
// Workaround for Cecil bug. (some types cannot be resolved)
}
list.Add(a);
}
}
static object GetValue(IProjectContent pc, IEntity member, CustomAttributeArgument argument)
{
if (argument.Value is TypeReference)
return CreateType(pc, member, (TypeReference)argument.Value);
else
return argument.Value;
}
static void AddConstraintsFromType(ITypeParameter tp, GenericParameter g)
{
foreach (TypeReference constraint in g.Constraints) {
if (tp.Method != null) {
tp.Constraints.Add(CreateType(tp.Class.ProjectContent, tp.Method, constraint));
} else {
tp.Constraints.Add(CreateType(tp.Class.ProjectContent, tp.Class, constraint));
}
}
}
/// <summary>
/// Create a SharpDevelop return type from a Cecil type reference.
/// </summary>
internal static IReturnType CreateType(IProjectContent pc, IEntity member, TypeReference type, ICustomAttributeProvider attributeProvider = null)
{
int typeIndex = 0;
return CreateType(pc, member, type, attributeProvider, ref typeIndex);
}
static IReturnType CreateType(IProjectContent pc, IEntity member, TypeReference type, ICustomAttributeProvider attributeProvider, ref int typeIndex)
{
while (type is OptionalModifierType || type is RequiredModifierType) {
type = ((TypeSpecification)type).ElementType;
}
if (type == null) {
LoggingService.Warn("CecilReader: Null type for: " + member);
return new VoidReturnType(pc);
}
if (type is ByReferenceType) {
// TODO: Use ByRefRefReturnType
return CreateType(pc, member, (type as ByReferenceType).ElementType, attributeProvider, ref typeIndex);
} else if (type is PointerType) {
typeIndex++;
return new PointerReturnType(CreateType(pc, member, (type as PointerType).ElementType, attributeProvider, ref typeIndex));
} else if (type is ArrayType) {
typeIndex++;
return new ArrayReturnType(pc, CreateType(pc, member, (type as ArrayType).ElementType, attributeProvider, ref typeIndex), (type as ArrayType).Rank);
} else if (type is GenericInstanceType) {
GenericInstanceType gType = (GenericInstanceType)type;
IReturnType baseType = CreateType(pc, member, gType.ElementType, attributeProvider, ref typeIndex);
IReturnType[] para = new IReturnType[gType.GenericArguments.Count];
for (int i = 0; i < para.Length; ++i) {
typeIndex++;
para[i] = CreateType(pc, member, gType.GenericArguments[i], attributeProvider, ref typeIndex);
}
return new ConstructedReturnType(baseType, para);
} else if (type is GenericParameter) {
GenericParameter typeGP = type as GenericParameter;
if (typeGP.Owner is MethodDefinition) {
IMethod method = member as IMethod;
if (method != null) {
if (typeGP.Position < method.TypeParameters.Count) {
return new GenericReturnType(method.TypeParameters[typeGP.Position]);
}
}
return new GenericReturnType(new DefaultTypeParameter(method, typeGP.Name, typeGP.Position));
} else {
IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null;
if (c != null && typeGP.Position < c.TypeParameters.Count) {
if (c.TypeParameters[typeGP.Position].Name == type.Name) {
return new GenericReturnType(c.TypeParameters[typeGP.Position]);
}
}
return new GenericReturnType(new DefaultTypeParameter(c, typeGP.Name, typeGP.Position));
}
} else {
string name = type.FullName;
if (name == null)
throw new ApplicationException("type.FullName returned null. Type: " + type.ToString());
int typeParameterCount;
if (name.IndexOf('/') > 0) {
typeParameterCount = 0;
StringBuilder newName = new StringBuilder();
foreach (string namepart in name.Split('/')) {
if (newName.Length > 0)
newName.Append('.');
int partTypeParameterCount;
newName.Append(ReflectionClass.SplitTypeParameterCountFromReflectionName(namepart, out partTypeParameterCount));
typeParameterCount += partTypeParameterCount;
}
name = newName.ToString();
} else {
name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name, out typeParameterCount);
}
if (typeParameterCount == 0 && name == "System.Object" && HasDynamicAttribute(attributeProvider, typeIndex))
return new DynamicReturnType(pc);
IClass c = pc.GetClass(name, typeParameterCount, LanguageProperties.CSharp, GetClassOptions.Default | GetClassOptions.ExactMatch);
if (c != null) {
return c.DefaultReturnType;
} else {
// example where name is not found: pointers like System.Char*
// or when the class is in a assembly that is not referenced
return new GetClassReturnType(pc, name, typeParameterCount);
}
}
}
static bool HasDynamicAttribute(ICustomAttributeProvider attributeProvider, int typeIndex)
{
if (attributeProvider == null || attributeProvider.HasCustomAttributes == false)
return false;
foreach (CustomAttribute a in attributeProvider.CustomAttributes) {
if (a.Constructor.DeclaringType.FullName == "System.Runtime.CompilerServices.DynamicAttribute") {
if (a.ConstructorArguments.Count == 1) {
CustomAttributeArgument[] values = a.ConstructorArguments[0].Value as CustomAttributeArgument[];
if (values != null && typeIndex < values.Length && values[typeIndex].Value is bool)
return (bool)values[typeIndex].Value;
}
return true;
}
}
return false;
}
private sealed class CecilProjectContent : ReflectionProjectContent
{
public CecilProjectContent(string fullName, string fileName, DomAssemblyName[] referencedAssemblies,
AssemblyDefinition assembly, ProjectContentRegistry registry)
: base(fullName, fileName, referencedAssemblies, registry)
{
foreach (ModuleDefinition module in assembly.Modules) {
AddTypes(module.Types);
}
AddAttributes(this, null, this.AssemblyCompilationUnit.Attributes, assembly);
InitializeSpecialClasses();
this.AssemblyCompilationUnit.Freeze();
}
void AddTypes(Collection<TypeDefinition> types)
{
foreach (TypeDefinition td in types) {
if ((td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public) {
string name = td.FullName;
if (name.Length == 0 || name[0] == '<')
continue;
name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name);
AddClassToNamespaceListInternal(new CecilClass(this.AssemblyCompilationUnit, null, td, name));
}
}
}
}
private sealed class CecilClass : DefaultClass
{
public static bool IsDelegate(TypeDefinition type)
{
if (type.BaseType == null)
return false;
else
return type.BaseType.FullName == "System.Delegate"
|| type.BaseType.FullName == "System.MulticastDelegate";
}
protected override bool KeepInheritanceTree {
get { return true; }
}
public CecilClass(ICompilationUnit compilationUnit, IClass declaringType,
TypeDefinition td, string fullName)
: base(compilationUnit, declaringType)
{
this.FullyQualifiedName = fullName;
AddAttributes(compilationUnit.ProjectContent, this, this.Attributes, td);
// set classtype
if (td.IsInterface) {
this.ClassType = ClassType.Interface;
} else if (td.IsEnum) {
this.ClassType = ClassType.Enum;
} else if (td.IsValueType) {
this.ClassType = ClassType.Struct;
} else if (IsDelegate(td)) {
this.ClassType = ClassType.Delegate;
} else {
this.ClassType = ClassType.Class;
}
if (td.GenericParameters.Count > 0) {
foreach (GenericParameter g in td.GenericParameters) {
this.TypeParameters.Add(new DefaultTypeParameter(this, g.Name, g.Position));
}
int i = 0;
foreach (GenericParameter g in td.GenericParameters) {
AddConstraintsFromType(this.TypeParameters[i++], g);
}
}
ModifierEnum modifiers = ModifierEnum.None;
if (td.IsSealed) {
modifiers |= ModifierEnum.Sealed;
}
if (td.IsAbstract) {
modifiers |= ModifierEnum.Abstract;
}
if (td.IsSealed && td.IsAbstract) {
modifiers |= ModifierEnum.Static;
}
if ((td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic) {
modifiers |= ModifierEnum.Public;
} else if ((td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamily) {
modifiers |= ModifierEnum.Protected;
} else if ((td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamORAssem) {
modifiers |= ModifierEnum.Protected;
} else {
modifiers |= ModifierEnum.Public;
}
this.Modifiers = modifiers;
// set base classes
if (td.BaseType != null) {
BaseTypes.Add(CreateType(this.ProjectContent, this, td.BaseType));
}
foreach (TypeReference iface in td.Interfaces) {
BaseTypes.Add(CreateType(this.ProjectContent, this, iface));
}
ReflectionClass.ApplySpecialsFromAttributes(this);
InitMembers(td);
}
void InitMembers(TypeDefinition type)
{
string defaultMemberName = null;
foreach (CustomAttribute att in type.CustomAttributes) {
if (att.Constructor.DeclaringType.FullName == "System.Reflection.DefaultMemberAttribute"
&& att.ConstructorArguments.Count == 1)
{
defaultMemberName = att.ConstructorArguments[0].Value as string;
}
}
foreach (TypeDefinition nestedType in type.NestedTypes) {
TypeAttributes visibility = nestedType.Attributes & TypeAttributes.VisibilityMask;
if (visibility == TypeAttributes.NestedPublic || visibility == TypeAttributes.NestedFamily
|| visibility == TypeAttributes.NestedFamORAssem)
{
string name = nestedType.Name;
int pos = name.LastIndexOf('/');
if (pos > 0)
name = name.Substring(pos + 1);
if (name.Length == 0 || name[0] == '<')
continue;
name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name);
name = this.FullyQualifiedName + "." + name;
InnerClasses.Add(new CecilClass(this.CompilationUnit, this, nestedType, name));
}
}
foreach (FieldDefinition field in type.Fields) {
if (IsVisible(field.Attributes) && !field.IsSpecialName) {
DefaultField f = new DefaultField(this, field.Name);
f.Modifiers = TranslateModifiers(field);
f.ReturnType = CreateType(this.ProjectContent, this, field.FieldType, field);
AddAttributes(CompilationUnit.ProjectContent, f, f.Attributes, field);
Fields.Add(f);
}
}
foreach (PropertyDefinition property in type.Properties) {
AddProperty(defaultMemberName, property);
}
foreach (EventDefinition eventDef in type.Events) {
if (eventDef.AddMethod != null && IsVisible(eventDef.AddMethod.Attributes)) {
DefaultEvent e = new DefaultEvent(this, eventDef.Name);
if (this.ClassType == ClassType.Interface) {
e.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract;
} else {
e.Modifiers = TranslateModifiers(eventDef);
}
e.ReturnType = CreateType(this.ProjectContent, this, eventDef.EventType, eventDef);
AddAttributes(CompilationUnit.ProjectContent, e, e.Attributes, eventDef);
Events.Add(e);
}
}
this.AddDefaultConstructorIfRequired = (this.ClassType == ClassType.Struct || this.ClassType == ClassType.Enum);
foreach (MethodDefinition method in type.Methods) {
if (method.IsConstructor || !method.IsSpecialName) {
AddMethod(method);
}
}
}
void AddProperty(string defaultMemberName, PropertyDefinition property)
{
if ((property.GetMethod != null && IsVisible(property.GetMethod.Attributes))
|| (property.SetMethod != null && IsVisible(property.SetMethod.Attributes)))
{
DefaultProperty p = new DefaultProperty(this, property.Name);
if (this.ClassType == ClassType.Interface) {
p.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract;
} else {
p.Modifiers = TranslateModifiers(property);
}
p.ReturnType = CreateType(this.ProjectContent, this, property.PropertyType, property);
p.CanGet = property.GetMethod != null && IsVisible(property.GetMethod.Attributes);
p.CanSet = property.SetMethod != null && IsVisible(property.SetMethod.Attributes);
if (p.CanGet)
p.GetterModifiers = GetAccessorVisibility(p, property.GetMethod);
if (p.CanSet)
p.SetterModifiers = GetAccessorVisibility(p, property.SetMethod);
if (p.Name == defaultMemberName) {
p.IsIndexer = true;
}
AddParameters(p, property.Parameters);
AddAttributes(CompilationUnit.ProjectContent, p, p.Attributes, property);
Properties.Add(p);
}
}
static ModifierEnum GetAccessorVisibility(IProperty p, MethodDefinition accessor)
{
ModifierEnum visibility = ModifierEnum.VisibilityMask & TranslateModifiers(accessor);
if (visibility == (p.Modifiers & ModifierEnum.VisibilityMask))
return ModifierEnum.None;
else
return visibility;
}
void AddMethod(MethodDefinition method)
{
if (IsVisible(method.Attributes)) {
DefaultMethod m = new DefaultMethod(this, method.IsConstructor ? "#ctor" : method.Name);
if (method.GenericParameters.Count > 0) {
foreach (GenericParameter g in method.GenericParameters) {
m.TypeParameters.Add(new DefaultTypeParameter(m, g.Name, g.Position));
}
int i = 0;
foreach (GenericParameter g in method.GenericParameters) {
AddConstraintsFromType(m.TypeParameters[i++], g);
}
}
if (method.IsConstructor)
m.ReturnType = this.DefaultReturnType;
else
m.ReturnType = CreateType(this.ProjectContent, m, method.ReturnType, method.MethodReturnType);
AddAttributes(CompilationUnit.ProjectContent, m, m.Attributes, method);
if (this.ClassType == ClassType.Interface) {
m.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract;
} else {
m.Modifiers = TranslateModifiers(method);
}
AddParameters(m, method.Parameters);
AddExplicitInterfaceImplementations(method.Overrides, m);
ReflectionLayer.ReflectionMethod.ApplySpecialsFromAttributes(m);
Methods.Add(m);
}
}
void AddExplicitInterfaceImplementations(Collection<MethodReference> overrides, IMember targetMember)
{
foreach (MethodReference overrideRef in overrides) {
if (overrideRef.Name == targetMember.Name && targetMember.IsPublic) {
continue; // is like implicit interface implementation / normal override
}
targetMember.InterfaceImplementations.Add(new ExplicitInterfaceImplementation(
CreateType(this.ProjectContent, targetMember, overrideRef.DeclaringType),
overrideRef.Name
));
}
}
void AddParameters(IMethodOrProperty target, Collection<ParameterDefinition> plist)
{
foreach (ParameterDefinition par in plist) {
IReturnType pReturnType = CreateType(this.ProjectContent, target, par.ParameterType, par);
DefaultParameter p = new DefaultParameter(par.Name, pReturnType, DomRegion.Empty);
if (par.ParameterType is ByReferenceType) {
if ((par.Attributes & ParameterAttributes.Out) == ParameterAttributes.Out) {
p.Modifiers = ParameterModifiers.Out;
} else {
p.Modifiers = ParameterModifiers.Ref;
}
} else {
p.Modifiers = ParameterModifiers.In;
}
if ((par.Attributes & ParameterAttributes.Optional) == ParameterAttributes.Optional) {
p.Modifiers |= ParameterModifiers.Optional;
}
if (p.ReturnType.IsArrayReturnType) {
foreach (CustomAttribute att in par.CustomAttributes) {
if (att.Constructor.DeclaringType.FullName == typeof(ParamArrayAttribute).FullName) {
p.Modifiers |= ParameterModifiers.Params;
}
}
}
target.Parameters.Add(p);
}
}
static bool IsVisible(MethodAttributes att)
{
return ((att & MethodAttributes.Public) == MethodAttributes.Public)
|| ((att & MethodAttributes.Family) == MethodAttributes.Family)
|| ((att & MethodAttributes.FamORAssem) == MethodAttributes.FamORAssem);
}
static bool IsVisible(FieldAttributes att)
{
return ((att & FieldAttributes.Public) == FieldAttributes.Public)
|| ((att & FieldAttributes.Family) == FieldAttributes.Family)
|| ((att & FieldAttributes.FamORAssem) == FieldAttributes.FamORAssem);
}
static ModifierEnum TranslateModifiers(MethodDefinition method)
{
ModifierEnum m = ModifierEnum.None;
if (method.IsStatic) {
m |= ModifierEnum.Static;
} else {
if (method.IsAbstract) {
m |= ModifierEnum.Abstract;
} else if (method.IsFinal) {
m |= ModifierEnum.Sealed;
} else if (method.Overrides.Count > 0) {
m |= ModifierEnum.Override;
} else if (method.IsVirtual) {
if (method.IsNewSlot)
m |= ModifierEnum.Virtual;
else
m |= ModifierEnum.Override;
}
}
if ((method.Attributes & MethodAttributes.Public) == MethodAttributes.Public)
m |= ModifierEnum.Public;
else
m |= ModifierEnum.Protected;
return m;
}
static ModifierEnum TranslateModifiers(PropertyDefinition property)
{
return TranslateModifiers(property.GetMethod ?? property.SetMethod);
}
static ModifierEnum TranslateModifiers(EventDefinition @event)
{
return TranslateModifiers(@event.AddMethod);
}
static ModifierEnum TranslateModifiers(FieldDefinition field)
{
ModifierEnum m = ModifierEnum.None;
if (field.IsStatic)
m |= ModifierEnum.Static;
if (field.IsLiteral)
m |= ModifierEnum.Const;
else if (field.IsInitOnly)
m |= ModifierEnum.Readonly;
if ((field.Attributes & FieldAttributes.Public) == FieldAttributes.Public)
m |= ModifierEnum.Public;
else
m |= ModifierEnum.Protected;
return m;
}
}
}
}

130
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ClassFinder.cs

@ -1,130 +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;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Class that stores a source code context and can resolve type names
/// in that context.
/// </summary>
public sealed class ClassFinder
{
int caretLine, caretColumn;
ICompilationUnit cu;
IClass callingClass;
IProjectContent projectContent;
public IClass CallingClass {
get {
return callingClass;
}
}
public IProjectContent ProjectContent {
get {
return projectContent;
}
}
public LanguageProperties Language {
get {
return projectContent.Language;
}
}
public int CaretLine {
get { return caretLine; }
}
public int CaretColumn {
get { return caretColumn; }
}
public ClassFinder(ParseInformation parseInfo, string fileContent, int offset)
{
caretLine = 0;
caretColumn = 0;
for (int i = 0; i < offset; i++) {
if (fileContent[i] == '\n') {
caretLine++;
caretColumn = 0;
} else {
caretColumn++;
}
}
Init(parseInfo);
}
public ClassFinder(ParseInformation parseInfo, int caretLineNumber, int caretColumn)
{
this.caretLine = caretLineNumber;
this.caretColumn = caretColumn;
Init(parseInfo);
}
public ClassFinder(IMember classMember)
: this(classMember.DeclaringType, classMember.Region.BeginLine, classMember.Region.BeginColumn)
{
}
public ClassFinder(IClass callingClass, int caretLine, int caretColumn)
{
if (callingClass == null)
throw new ArgumentNullException("callingClass");
if (callingClass is CompoundClass)
throw new ArgumentException("Cannot use compound class for ClassFinder - must pass a specific class part.");
this.caretLine = caretLine;
this.caretColumn = caretColumn;
this.callingClass = callingClass;
this.cu = callingClass.CompilationUnit;
this.projectContent = cu.ProjectContent;
if (projectContent == null)
throw new ArgumentException("callingClass must have a project content!");
}
// currently callingMember is not required
public ClassFinder(IClass callingClass, IMember callingMember, int caretLine, int caretColumn)
: this(callingClass, caretLine, caretColumn)
{
}
void Init(ParseInformation parseInfo)
{
if (parseInfo != null) {
cu = parseInfo.CompilationUnit;
}
if (cu != null) {
callingClass = cu.GetInnermostClass(caretLine, caretColumn);
projectContent = cu.ProjectContent;
} else {
projectContent = DefaultProjectContent.DummyProjectContent;
}
if (projectContent == null)
throw new ArgumentException("projectContent not found!");
}
public IClass GetClass(string fullName, int typeParameterCount)
{
return projectContent.GetClass(fullName, typeParameterCount);
}
public IReturnType SearchType(string name, int typeParameterCount)
{
return Search(name, typeParameterCount).Result;
}
public SearchTypeResult Search(string name, int typeParameterCount)
{
return projectContent.SearchType(new SearchTypeRequest(name, typeParameterCount, callingClass, cu, caretLine, caretColumn));
}
public string SearchNamespace(string name)
{
return Search(name, 0).NamespaceResult;
}
}
}

285
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs

@ -1,285 +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.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Provides static methods that fill a list of completion results with entries
/// reachable from a certain calling class/member or entries that introduced
/// by a certain Using statement.
/// </summary>
public class CtrlSpaceResolveHelper
{
static void AddTypeParametersForCtrlSpace(List<ICompletionEntry> result, IEnumerable<ITypeParameter> typeParameters)
{
foreach (ITypeParameter p in typeParameters) {
DefaultClass c = DefaultTypeParameter.GetDummyClassForTypeParameter(p);
if (p.Method != null) {
c.Documentation = "Type parameter of " + p.Method.Name;
} else {
c.Documentation = "Type parameter of " + p.Class.Name;
}
result.Add(c);
}
}
public static void AddContentsFromCalling(List<ICompletionEntry> result, IClass callingClass, IMember callingMember)
{
IMethodOrProperty methodOrProperty = callingMember as IMethodOrProperty;
if (methodOrProperty != null) {
foreach (IParameter p in methodOrProperty.Parameters) {
result.Add(new DefaultField.ParameterField(p.ReturnType, p.Name, methodOrProperty.Region, callingClass));
}
if (callingMember is IMethod) {
AddTypeParametersForCtrlSpace(result, ((IMethod)callingMember).TypeParameters);
}
}
bool inStatic = false;
if (callingMember != null)
inStatic = callingMember.IsStatic;
if (callingClass != null) {
AddTypeParametersForCtrlSpace(result, callingClass.TypeParameters);
List<ICompletionEntry> members = new List<ICompletionEntry>();
IReturnType t = callingClass.DefaultReturnType;
var language = callingClass.ProjectContent.Language;
foreach (IMember m in MemberLookupHelper.GetAccessibleMembers(t, callingClass, language, true)) {
if ((!inStatic || m.IsStatic) && language.ShowMember(m, m.IsStatic))
result.Add(m);
}
members.Clear();
IClass c = callingClass.DeclaringType;
while (c != null) {
t = c.DefaultReturnType;
foreach (IMember m in MemberLookupHelper.GetAccessibleMembers(t, c, language, true)) {
if (language.ShowMember(m, true))
result.Add(m);
}
c = c.DeclaringType;
}
}
}
/// <summary>
/// Adds contents of all assemblies referenced by <paramref name="cu" />'s project.
/// Also adds contents of <paramref name="callingClass" />.
/// </summary>
public static void AddReferencedProjectsContents(List<ICompletionEntry> result, ICompilationUnit cu, IClass callingClass)
{
IProjectContent projectContent = cu.ProjectContent;
projectContent.AddNamespaceContents(result, "", projectContent.Language, true);
var allContents = projectContent.GetAllContents();
result.Capacity = result.Count + allContents.Count;
foreach (var entry in allContents.Where(e => !(e is NamespaceEntry))) {
result.Add(entry);
}
AddUsing(result, projectContent.DefaultImports, projectContent);
AddContentsFromCallingClass(result, projectContent, callingClass);
}
/// <summary>
/// Adds contents of all namespaces that this <paramref name="callingClass" /> imports to the <paramref name="result" /> list.
/// Also adds contents of <paramref name="callingClass" />.
/// </summary>
public static void AddImportedNamespaceContents(List<ICompletionEntry> result, ICompilationUnit cu, IClass callingClass)
{
IProjectContent projectContent = cu.ProjectContent;
projectContent.AddNamespaceContents(result, "", projectContent.Language, true);
IUsingScope scope = (callingClass != null) ? callingClass.UsingScope : cu.UsingScope;
while (scope != null) {
foreach (IUsing u in scope.Usings)
AddUsing(result, u, projectContent);
scope = scope.Parent;
}
AddUsing(result, projectContent.DefaultImports, projectContent);
AddContentsFromCallingClass(result, projectContent, callingClass);
}
static void AddContentsFromCallingClass(List<ICompletionEntry> result, IProjectContent projectContent, IClass callingClass)
{
if (callingClass == null) {
return;
}
// use HashSet so that Contains lookups are possible in O(1).
HashSet<ICompletionEntry> existingResults = new HashSet<ICompletionEntry>(result);
string[] namespaceParts = callingClass.Namespace.Split('.');
for (int i = 1; i <= namespaceParts.Length; i++) {
foreach (ICompletionEntry member in projectContent.GetNamespaceContents(string.Join(".", namespaceParts, 0, i))) {
if (!existingResults.Contains(member))
result.Add(member);
}
}
IClass currentClass = callingClass;
do {
foreach (IClass innerClass in currentClass.GetCompoundClass().GetAccessibleTypes(currentClass)) {
if (!existingResults.Contains(innerClass))
result.Add(innerClass);
}
currentClass = currentClass.DeclaringType;
} while (currentClass != null);
}
public static void AddUsing(List<ICompletionEntry> result, IUsing u, IProjectContent projectContent)
{
if (u == null) {
return;
}
bool importNamespaces = projectContent.Language.ImportNamespaces;
bool importClasses = projectContent.Language.CanImportClasses;
foreach (string name in u.Usings) {
if (importClasses) {
IClass c = projectContent.GetClass(name, 0);
if (c != null) {
ArrayList members = new ArrayList();
IReturnType t = c.DefaultReturnType;
members.AddRange(t.GetMethods());
members.AddRange(t.GetFields());
members.AddRange(t.GetEvents());
members.AddRange(t.GetProperties());
foreach (IMember m in members) {
if (m.IsStatic && m.IsPublic) {
result.Add(m);
}
}
continue;
}
}
if (importNamespaces) {
string newName = null;
if (projectContent.DefaultImports != null) {
newName = projectContent.DefaultImports.SearchNamespace(name);
}
projectContent.AddNamespaceContents(result, newName ?? name, projectContent.Language, true);
} else {
foreach (ICompletionEntry o in projectContent.GetNamespaceContents(name)) {
if (!(o is NamespaceEntry))
result.Add(o);
}
}
}
if (u.HasAliases) {
foreach (string alias in u.Aliases.Keys) {
result.Add(new AliasEntry(alias));
}
}
}
public class AliasEntry : ICompletionEntry
{
public string Name { get; private set; }
public AliasEntry(string name)
{
if (name == null)
throw new ArgumentNullException("name");
this.Name = name;
}
public override int GetHashCode()
{
return Name.GetHashCode();
}
public override bool Equals(object obj)
{
AliasEntry e = obj as AliasEntry;
return e != null && e.Name == this.Name;
}
public override string ToString()
{
return Name;
}
}
public static ResolveResult GetResultFromDeclarationLine(IClass callingClass, IMethodOrProperty callingMember, int caretLine, int caretColumn, ExpressionResult expressionResult)
{
string expression = expressionResult.Expression;
if (expression == null) return null;
if (callingClass == null) return null;
int pos = expression.IndexOf('(');
if (pos >= 0) {
expression = expression.Substring(0, pos);
}
expression = expression.Trim();
// if (!callingClass.BodyRegion.IsInside(caretLine, caretColumn)
// && callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingClass.Name))
// {
// return new TypeResolveResult(callingClass, callingMember, callingClass);
// }
if (expressionResult.Context != ExpressionContext.Type) {
if (callingMember != null
&& !callingMember.BodyRegion.IsInside(caretLine, caretColumn)
&& (callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingMember.Name) ||
// For constructor definition, the expression is the constructor name (e.g. "MyClass") but the name of the member is "#ctor"
(callingMember.Name == "#ctor" && callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingClass.Name))
)
)
{
return new MemberResolveResult(callingClass, callingMember, callingMember);
}
}
return null;
}
public static IList<IMethodOrProperty> FindAllExtensions(LanguageProperties language, IClass callingClass, bool searchInAllNamespaces = false)
{
if (language == null)
throw new ArgumentNullException("language");
if (callingClass == null)
throw new ArgumentNullException("callingClass");
HashSet<IMethodOrProperty> res = new HashSet<IMethodOrProperty>();
bool supportsExtensionMethods = language.SupportsExtensionMethods;
bool supportsExtensionProperties = language.SupportsExtensionProperties;
if (supportsExtensionMethods || supportsExtensionProperties) {
List<ICompletionEntry> list = new List<ICompletionEntry>();
IMethod dummyMethod = new DefaultMethod("dummy", callingClass.ProjectContent.SystemTypes.Void,
ModifierEnum.Static, DomRegion.Empty, DomRegion.Empty, callingClass);
CtrlSpaceResolveHelper.AddContentsFromCalling(list, callingClass, dummyMethod);
if (searchInAllNamespaces) {
// search extension methods in all referenced projects, no matter the using section
CtrlSpaceResolveHelper.AddReferencedProjectsContents(list, callingClass.CompilationUnit, callingClass);
} else {
CtrlSpaceResolveHelper.AddImportedNamespaceContents(list, callingClass.CompilationUnit, callingClass);
}
bool searchExtensionsInClasses = language.SearchExtensionsInClasses;
foreach (object o in list) {
IMethodOrProperty mp = o as IMethodOrProperty;
if (mp != null && mp.IsExtensionMethod &&
(supportsExtensionMethods && o is IMethod || supportsExtensionProperties && o is IProperty))
{
res.Add(mp);
} else if (searchExtensionsInClasses && o is IClass) {
IClass c = o as IClass;
if (c.HasExtensionMethods) {
if (supportsExtensionProperties) {
foreach (IProperty p in c.Properties) {
if (p.IsExtensionMethod)
res.Add(p);
}
}
if (supportsExtensionMethods) {
foreach (IMethod m in c.Methods) {
if (m.IsExtensionMethod)
res.Add(m);
}
}
}
}
}
}
return res.ToList();
} // FindAllExtensions
} // CtrlSpaceResolveHelper class
}

129
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/DiffUtility.cs

@ -1,129 +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.Collections;
using System.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
public static class DiffUtility
{
public static int GetAddedItems(IList original, IList changed, IList result)
{
return GetAddedItems(original, changed, result, Comparer.Default);
}
public static int GetAddedItems(IList original, IList changed, IList result, IComparer comparer)
{
int count = 0;
if(changed != null && result != null) {
if(original == null) {
foreach(object item in changed) {
result.Add(item);
}
count = changed.Count;
}
else {
foreach(object item in changed) {
if(!Contains(original, item, comparer)) {
result.Add(item);
count++;
}
}
}
}
return count;
}
public static int GetRemovedItems(IList original, IList changed, IList result)
{
return GetRemovedItems(original, changed, result, Comparer.Default);
}
public static int GetRemovedItems(IList original, IList changed, IList result, IComparer comparer)
{
return GetAddedItems(changed, original, result, comparer);
}
static bool Contains(IList list, object value, IComparer comparer)
{
foreach(object item in list) {
if(0 == comparer.Compare(item, value)) {
return true;
}
}
return false;
}
static public int Compare(IList a, IList b)
{
return Compare(a, b, Comparer.Default);
}
static public int Compare<T>(IList<T> a, IList<T> b)
{
return Compare(a, b, Comparer.Default);
}
static public int Compare<T>(IList<T> a, IList<T> b, IComparer comparer)
{
if (a == null || b == null) {
return 1;
}
if (a.Count != b.Count) {
return Math.Sign(a.Count - b.Count);
}
int limit = (a.Count < b.Count) ? a.Count : b.Count;
for(int i=0; i < limit; i++) {
if (a[i] is IComparable && b[i] is IComparable) {
int cmp = comparer.Compare(a[i], b[i]);
if (cmp != 0) {
return cmp;
}
}
}
return a.Count - b.Count;
}
static public int Compare(IList a, IList b, IComparer comparer)
{
if (a == null || b == null) {
return 1;
}
if (a.Count != b.Count) {
return Math.Sign(a.Count - b.Count);
}
int limit = (a.Count < b.Count) ? a.Count : b.Count;
for(int i=0; i < limit; i++) {
if (a[i] is IComparable && b[i] is IComparable) {
int cmp = comparer.Compare(a[i], b[i]);
if (cmp != 0) {
return cmp;
}
}
}
return a.Count - b.Count;
}
static public int Compare(SortedList a, SortedList b)
{
return Compare(a, b, Comparer.Default);
}
static public int Compare(SortedList a, SortedList b, IComparer comparer)
{
if (a == null || b == null) {
return 1;
}
int cmp;
int limit = (a.Count < b.Count) ? a.Count : b.Count;
for(int i=0; i < limit; i++) {
if(0 != (cmp = comparer.Compare(a.GetByIndex(i), b.GetByIndex(i)))) {
return cmp;
}
}
return a.Count - b.Count;
}
}
}

41
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/DomCache.cs

@ -1,41 +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.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
static class DomCache
{
/// <summary>
/// Clear the static searchclass cache. You should call this method
/// whenever the DOM changes.
/// </summary>
/// <remarks>
/// automatically called by DefaultProjectContent.UpdateCompilationUnit
/// and DefaultProjectContent.OnReferencedContentsChanged.
/// </remarks>
public static void Clear()
{
List<Action> oldActions;
lock (lockObject) {
oldActions = actions;
actions = new List<Action>();
}
foreach (Action a in oldActions) {
a();
}
}
static readonly object lockObject = new Object();
static List<Action> actions = new List<Action>();
public static void RegisterForClear(Action action)
{
lock (lockObject) {
actions.Add(action);
}
}
}
}

382
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/EasyCodeDom.cs

@ -1,382 +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.CodeDom;
namespace ICSharpCode.EasyCodeDom
{
public static class Easy
{
public static CodeTypeReference TypeRef(Type type)
{
return new CodeTypeReference(type, CodeTypeReferenceOptions.GlobalReference);
}
public static CodeTypeReference TypeRef(CodeTypeDeclaration type)
{
return new CodeTypeReference(type.Name);
}
public static CodeTypeReference TypeRef(string typeName, params string[] typeArguments)
{
CodeTypeReference tr = new CodeTypeReference(typeName);
foreach (string ta in typeArguments) {
tr.TypeArguments.Add(ta);
}
return tr;
}
/// <summary>
/// Gets the CodeExpression for any primitive value that can be expressed as literal.
/// Also works for enumeration values.
/// </summary>
public static CodeExpression Prim(object literalValue)
{
if (literalValue is Enum) {
return Type(literalValue.GetType()).Field(literalValue.ToString());
} else {
return new CodePrimitiveExpression(literalValue);
}
}
public static CodeTypeReferenceExpression Type(Type type)
{
return Type(TypeRef(type));
}
public static CodeTypeReferenceExpression Type(CodeTypeReference type)
{
return new CodeTypeReferenceExpression(type);
}
public static CodeTypeReferenceExpression Type(string type)
{
return Type(new CodeTypeReference(type));
}
public static CodeTypeOfExpression TypeOf(Type type)
{
return TypeOf(TypeRef(type));
}
public static CodeTypeOfExpression TypeOf(CodeTypeReference type)
{
return new CodeTypeOfExpression(type);
}
public static CodeObjectCreateExpression New(Type type, params CodeExpression[] arguments)
{
return New(TypeRef(type), arguments);
}
public static CodeObjectCreateExpression New(CodeTypeReference type, params CodeExpression[] arguments)
{
return new CodeObjectCreateExpression(type, arguments);
}
public static CodeVariableReferenceExpression Var(string name)
{
return new CodeVariableReferenceExpression(name);
}
public static CodeBinaryOperatorExpression Binary(CodeExpression left,
CodeBinaryOperatorType op,
CodeExpression right)
{
return new CodeBinaryOperatorExpression(left, op, right);
}
public static CodeThisReferenceExpression This {
get {
return new CodeThisReferenceExpression();
}
}
public static CodeBaseReferenceExpression Base {
get {
return new CodeBaseReferenceExpression();
}
}
public static CodePropertySetValueReferenceExpression Value {
get {
return new CodePropertySetValueReferenceExpression();
}
}
public static CodePrimitiveExpression Null {
get {
return new CodePrimitiveExpression(null);
}
}
public static void AddSummary(CodeTypeMember member, string summary)
{
member.Comments.Add(new CodeCommentStatement("<summary>", true));
member.Comments.Add(new CodeCommentStatement(summary, true));
member.Comments.Add(new CodeCommentStatement("</summary>", true));
}
internal static CodeAttributeDeclaration AddAttribute(CodeAttributeDeclarationCollection col,
CodeTypeReference type,
CodeExpression[] arguments)
{
CodeAttributeArgument[] attributeArguments = new CodeAttributeArgument[arguments.Length];
for (int i = 0; i < arguments.Length; i++) {
attributeArguments[i] = new CodeAttributeArgument(arguments[i]);
}
CodeAttributeDeclaration cad = new CodeAttributeDeclaration(type, attributeArguments);
col.Add(cad);
return cad;
}
}
public static class ExtensionMethods
{
public static CodeMethodInvokeExpression InvokeMethod(this CodeExpression expr, string name, params CodeExpression[] arguments)
{
return new CodeMethodInvokeExpression(expr, name, arguments);
}
public static CodeCastExpression CastTo(this CodeExpression expr, Type type)
{
return expr.CastTo(Easy.TypeRef(type));
}
public static CodeCastExpression CastTo(this CodeExpression expr, CodeTypeReference type)
{
return new CodeCastExpression(type, expr);
}
public static CodeIndexerExpression Index(this CodeExpression expr, params CodeExpression[] indices)
{
return new CodeIndexerExpression(expr, indices);
}
public static CodeFieldReferenceExpression Field(this CodeExpression expr, string name)
{
return new CodeFieldReferenceExpression(expr, name);
}
public static CodePropertyReferenceExpression Property(this CodeExpression expr, string name)
{
return new CodePropertyReferenceExpression(expr, name);
}
public static CodeNamespace AddNamespace(this CodeCompileUnit ccu, string name)
{
CodeNamespace n = new CodeNamespace(name);
ccu.Namespaces.Add(n);
return n;
}
public static CodeTypeDeclaration AddType(this CodeNamespace ns, string name)
{
CodeTypeDeclaration n = new CodeTypeDeclaration(name);
ns.Types.Add(n);
return n;
}
public static CodeNamespaceImport AddImport(this CodeNamespace ns, string nameSpace)
{
CodeNamespaceImport cni = new CodeNamespaceImport(nameSpace);
ns.Imports.Add(cni);
return cni;
}
public static CodeMemberField AddField(this CodeTypeDeclaration typeDecl, Type type, string name)
{
return typeDecl.AddField(Easy.TypeRef(type), name);
}
public static CodeMemberField AddField(this CodeTypeDeclaration typeDecl, CodeTypeReference type, string name)
{
CodeMemberField f = new CodeMemberField(type, name);
typeDecl.Members.Add(f);
return f;
}
public static EasyProperty AddProperty(this CodeTypeDeclaration typeDecl, Type type, string name)
{
return AddProperty(typeDecl, Easy.TypeRef(type), name);
}
public static EasyProperty AddProperty(this CodeTypeDeclaration typeDecl, CodeTypeReference type, string name)
{
EasyProperty p = new EasyProperty(type, name);
typeDecl.Members.Add(p);
if (typeDecl.IsInterface == false) {
p.Attributes = MemberAttributes.Public | MemberAttributes.Final;
}
return p;
}
public static EasyProperty AddProperty(this CodeTypeDeclaration typeDecl, CodeMemberField field, string name)
{
EasyProperty p = AddProperty(typeDecl, field.Type, name);
p.Getter.Return(new CodeVariableReferenceExpression(field.Name));
p.Attributes |= field.Attributes & MemberAttributes.Static; // copy static flag
return p;
}
/// <summary>
/// Adds a method with return type <c>void</c> and attributes=Public|Final to this type.
/// </summary>
public static EasyMethod AddMethod(this CodeTypeDeclaration typeDecl, string name)
{
return AddMethod(typeDecl, Easy.TypeRef(typeof(void)), name);
}
/// <summary>
/// Adds a method with return type <paramref name="type"/> and attributes=Public|Final to this type.
/// </summary>
public static EasyMethod AddMethod(this CodeTypeDeclaration typeDecl, Type type, string name)
{
return AddMethod(typeDecl, Easy.TypeRef(type), name);
}
/// <summary>
/// Adds a method with return type <paramref name="type"/> and attributes=Public|Final to this type.
/// </summary>
public static EasyMethod AddMethod(this CodeTypeDeclaration typeDecl, CodeTypeReference type, string name)
{
EasyMethod p = new EasyMethod(type, name);
typeDecl.Members.Add(p);
if (typeDecl.IsInterface == false) {
p.Attributes = MemberAttributes.Public | MemberAttributes.Final;
}
return p;
}
public static CodeAttributeDeclaration AddAttribute(this CodeTypeMember typeMember, Type type, params CodeExpression[] arguments)
{
return Easy.AddAttribute(typeMember.CustomAttributes, Easy.TypeRef(type), arguments);
}
public static CodeAttributeDeclaration AddAttribute(this CodeTypeMember typeMember, CodeTypeReference type, params CodeExpression[] arguments)
{
return Easy.AddAttribute(typeMember.CustomAttributes, type, arguments);
}
}
public class EasyProperty : CodeMemberProperty
{
EasyBlock getter, setter;
public EasyProperty()
{
getter = new EasyBlock(this.GetStatements);
setter = new EasyBlock(this.SetStatements);
}
public EasyProperty(CodeTypeReference type, string name) : this()
{
this.Type = type;
this.Name = name;
}
public EasyBlock Getter {
get { return getter; }
}
public EasyBlock Setter {
get { return setter; }
}
}
public class EasyMethod : CodeMemberMethod
{
EasyBlock body;
public EasyMethod()
{
body = new EasyBlock(this.Statements);
}
public EasyMethod(CodeTypeReference type, string name) : this()
{
this.ReturnType = type;
this.Name = name;
}
public CodeParameterDeclarationExpression AddParameter(Type type, string name)
{
return AddParameter(Easy.TypeRef(type), name);
}
public CodeParameterDeclarationExpression AddParameter(CodeTypeReference type, string name)
{
CodeParameterDeclarationExpression cpde;
cpde = new CodeParameterDeclarationExpression(type, name);
this.Parameters.Add(cpde);
return cpde;
}
public EasyBlock Body {
get { return body; }
}
}
public sealed class EasyBlock
{
readonly CodeStatementCollection csc;
public EasyBlock(CodeStatementCollection csc)
{
this.csc = csc;
}
public CodeMethodReturnStatement Return(CodeExpression expr)
{
CodeMethodReturnStatement st = new CodeMethodReturnStatement(expr);
csc.Add(st);
return st;
}
public CodeThrowExceptionStatement Throw(CodeExpression expr)
{
CodeThrowExceptionStatement st = new CodeThrowExceptionStatement(expr);
csc.Add(st);
return st;
}
public CodeAssignStatement Assign(CodeExpression lhs, CodeExpression rhs)
{
CodeAssignStatement st = new CodeAssignStatement(lhs, rhs);
csc.Add(st);
return st;
}
/// <summary>
/// Execute one expression as statement.
/// </summary>
public CodeExpressionStatement Add(CodeExpression expr)
{
CodeExpressionStatement st = new CodeExpressionStatement(expr);
csc.Add(st);
return st;
}
/// <summary>
/// Adds the statement.
/// </summary>
public CodeStatement Add(CodeStatement st)
{
csc.Add(st);
return st;
}
/// <summary>
/// Invoke a method on target as statement.
/// </summary>
public CodeExpressionStatement InvokeMethod(CodeExpression target, string name, params CodeExpression[] arguments)
{
return Add(new CodeMethodInvokeExpression(target, name, arguments));
}
/// <summary>
/// Declares a local variable.
/// </summary>
public CodeVariableDeclarationStatement DeclareVariable(Type type, string name)
{
return DeclareVariable(Easy.TypeRef(type), name);
}
/// <summary>
/// Declares a local variable.
/// </summary>
public CodeVariableDeclarationStatement DeclareVariable(CodeTypeReference type, string name)
{
CodeVariableDeclarationStatement st = new CodeVariableDeclarationStatement(type, name);
csc.Add(st);
return st;
}
}
}

486
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExpressionContext.cs

@ -1,486 +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;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Class describing a context in which an expression can be.
/// Serves as filter for code completion results, but the contexts exposed as static fields
/// can also be used as a kind of enumeration for special behaviour in the resolver.
/// </summary>
public abstract class ExpressionContext
{
#region Instance members
public abstract bool ShowEntry(ICompletionEntry o);
protected bool readOnly = true;
object suggestedItem;
/// <summary>
/// Gets if the expression is in the context of an object creation.
/// </summary>
public virtual bool IsObjectCreation {
get {
return false;
}
set {
if (value)
throw new NotSupportedException();
}
}
/// <summary>
/// Gets/Sets the default item that should be included in a code completion popup
/// in this context and selected as default value.
/// </summary>
/// <example>
/// "List&lt;TypeName&gt; var = new *expr*();" has as suggested item the pseudo-class
/// "List&lt;TypeName&gt;".
/// </example>
public object SuggestedItem {
get {
return suggestedItem;
}
set {
if (readOnly)
throw new NotSupportedException();
suggestedItem = value;
}
}
public virtual bool IsTypeContext {
get { return false; }
}
#endregion
#region VB specific contexts (public static fields) * MOVE TO ANOTHER CLASS *
/// <summary>The context expects a new parameter declaration</summary>
/// <example>Function Test(*expr*, *expr*, ...)</example>
public static readonly ExpressionContext Parameter = new DefaultExpressionContext("Parameter");
#endregion
#region Default contexts (public static fields)
/// <summary>Default/unknown context</summary>
public readonly static ExpressionContext Default = new DefaultExpressionContext("Default");
/// <summary>The context expects the base type of an enum.</summary>
/// <example>enum Name : *expr* {}</example>
public readonly static ExpressionContext EnumBaseType = new EnumBaseTypeExpressionContext();
/// <summary>Context expects a non-sealed type or interface</summary>
/// <example>class C : *expr* {}</example>
public readonly static ExpressionContext InheritableType = new InheritableTypeExpressionContext();
/// <summary>Context expects a namespace name</summary>
/// <example>using *expr*;</example>
public readonly static ExpressionContext Namespace = new ImportableExpressionContext(false);
/// <summary>Context expects an importable type (namespace or class with public static members)</summary>
/// <example>Imports *expr*;</example>
public readonly static ExpressionContext Importable = new ImportableExpressionContext(true);
/// <summary>Context expects a type name</summary>
/// <example>typeof(*expr*)</example>
public readonly static ExpressionContext Type = new TypeExpressionContext(null, false, true);
/// <summary>Context expects the name of a non-static, non-void type</summary>
/// <example>is *expr*, *expr* variableName</example>
public readonly static ExpressionContext NonStaticNonVoidType = new NonStaticTypeExpressionContext("NonStaticType", false);
/// <summary>Context expects a non-abstract type that has accessible constructors</summary>
/// <example>new *expr*();</example>
/// <remarks>When using this context, a resolver should treat the expression as object creation,
/// even when the keyword "new" is not part of the expression.</remarks>
public readonly static ExpressionContext ObjectCreation = new TypeExpressionContext(null, true, true);
/// <summary>Context expects a type deriving from System.Attribute.</summary>
/// <example>[*expr*()]</example>
/// <remarks>When using this context, a resolver should try resolving typenames with an
/// appended "Attribute" suffix and treat "invocations" of the attribute type as
/// object creation.</remarks>
public readonly static ExpressionContext Attribute = new AttributeExpressionContext();
/// <summary>Context expects a type name which has special base type</summary>
/// <param name="baseClass">The class the expression must derive from.</param>
/// <param name="isObjectCreation">Specifies whether classes must be constructable.</param>
/// <example>catch(*expr* ...), using(*expr* ...), throw new *expr*();</example>
public static ExpressionContext TypeDerivingFrom(IReturnType baseType, bool isObjectCreation)
{
return new TypeExpressionContext(baseType, isObjectCreation, false);
}
/// <summary>Context expects an interface</summary>
/// <example>interface C : *expr* {}</example>
/// <example>Implements *expr*</example>
public readonly static ExpressionContext Interface = new ClassTypeExpressionContext(ClassType.Interface);
/// <summary>Context expects a delegate</summary>
/// <example>public event *expr*</example>
public readonly static ExpressionContext DelegateType = new ClassTypeExpressionContext(ClassType.Delegate);
/// <summary>The context expects a new identifier</summary>
/// <example>class *expr* {}; string *expr*;</example>
public readonly static ExpressionContext IdentifierExpected = new DefaultExpressionContext("IdentifierExpected");
/// <summary>The context is outside of any type declaration, expecting a global-level keyword.</summary>
public readonly static ExpressionContext Global = new DefaultExpressionContext("Global");
/// <summary>The context is the body of a type declaration.</summary>
public readonly static ExpressionContext TypeDeclaration = new ExpressionContext.NonStaticTypeExpressionContext("TypeDeclaration", true);
/// <summary>The context is the body of a method.</summary>
/// <example>void Main () { *expr* }</example>
public readonly static ExpressionContext MethodBody = new ExpressionContext.DefaultExpressionContext("MethodBody");
#endregion
#region DefaultExpressionContext
internal sealed class DefaultExpressionContext : ExpressionContext
{
string name;
public DefaultExpressionContext(string name)
{
this.name = name;
}
public override bool ShowEntry(ICompletionEntry o)
{
return true;
}
public override string ToString()
{
return "[" + GetType().Name + ": " + name + "]";
}
}
#endregion
#region NamespaceExpressionContext
sealed class ImportableExpressionContext : ExpressionContext
{
bool allowImportClasses;
public ImportableExpressionContext(bool allowImportClasses)
{
this.allowImportClasses = allowImportClasses;
}
public override bool ShowEntry(ICompletionEntry o)
{
if (!(o is IEntity))
return true;
IClass c = o as IClass;
if (allowImportClasses && c != null) {
return c.HasPublicOrInternalStaticMembers;
}
return false;
}
public override string ToString()
{
return "[" + GetType().Name + " AllowImportClasses=" + allowImportClasses.ToString() + "]";
}
}
#endregion
#region TypeExpressionContext
sealed class TypeExpressionContext : ExpressionContext
{
IClass baseClass;
bool isObjectCreation;
public TypeExpressionContext(IReturnType baseType, bool isObjectCreation, bool readOnly)
{
if (baseType != null)
baseClass = baseType.GetUnderlyingClass();
this.isObjectCreation = isObjectCreation;
this.readOnly = readOnly;
}
public override bool ShowEntry(ICompletionEntry o)
{
if (!(o is IEntity))
return true;
IClass c = o as IClass;
if (c == null)
return false;
if (isObjectCreation) {
if (c.IsAbstract || c.IsStatic) return false;
if (c.ClassType == ClassType.Enum || c.ClassType == ClassType.Interface)
return false;
}
if (baseClass == null)
return true;
return c.IsTypeInInheritanceTree(baseClass);
}
public override bool IsObjectCreation {
get {
return isObjectCreation;
}
set {
if (readOnly && value != isObjectCreation)
throw new NotSupportedException();
isObjectCreation = value;
}
}
public override bool IsTypeContext {
get { return true; }
}
public override string ToString()
{
if (baseClass != null)
return "[" + GetType().Name + ": " + baseClass.FullyQualifiedName
+ " IsObjectCreation=" + IsObjectCreation + "]";
else
return "[" + GetType().Name + " IsObjectCreation=" + IsObjectCreation + "]";
}
public override bool Equals(object obj)
{
TypeExpressionContext o = obj as TypeExpressionContext;
return o != null && object.Equals(baseClass, o.baseClass) && IsObjectCreation == o.IsObjectCreation;
}
public override int GetHashCode()
{
return ((baseClass != null) ? baseClass.GetHashCode() : 0)
^ isObjectCreation.GetHashCode();
}
}
#endregion
#region CombinedExpressionContext
public static ExpressionContext operator | (ExpressionContext a, ExpressionContext b)
{
return new CombinedExpressionContext(0, a, b);
}
public static ExpressionContext operator & (ExpressionContext a, ExpressionContext b)
{
return new CombinedExpressionContext(1, a, b);
}
public static ExpressionContext operator ^ (ExpressionContext a, ExpressionContext b)
{
return new CombinedExpressionContext(2, a, b);
}
sealed class CombinedExpressionContext : ExpressionContext
{
byte opType; // 0 = or ; 1 = and ; 2 = xor
ExpressionContext a;
ExpressionContext b;
public CombinedExpressionContext(byte opType, ExpressionContext a, ExpressionContext b)
{
if (a == null)
throw new ArgumentNullException("a");
if (b == null)
throw new ArgumentNullException("a");
this.opType = opType;
this.a = a;
this.b = b;
}
public override bool ShowEntry(ICompletionEntry o)
{
if (opType == 0)
return a.ShowEntry(o) || b.ShowEntry(o);
else if (opType == 1)
return a.ShowEntry(o) && b.ShowEntry(o);
else
return a.ShowEntry(o) ^ b.ShowEntry(o);
}
public override string ToString()
{
string op;
if (opType == 0)
op = " OR ";
else if (opType == 1)
op = " AND ";
else
op = " XOR ";
return "[" + GetType().Name + ": " + a + op + b + "]";
}
public override int GetHashCode()
{
int hashCode = 0;
unchecked {
hashCode += opType.GetHashCode();
if (a != null) hashCode += a.GetHashCode() * 3;
if (b != null) hashCode += b.GetHashCode() * 181247123;
}
return hashCode;
}
public override bool Equals(object obj)
{
CombinedExpressionContext cec = obj as CombinedExpressionContext;
return cec != null && this.opType == cec.opType && object.Equals(this.a, cec.a) && object.Equals(this.b, cec.b);
}
}
#endregion
#region EnumBaseTypeExpressionContext
sealed class EnumBaseTypeExpressionContext : ExpressionContext
{
public override bool ShowEntry(ICompletionEntry o)
{
IClass c = o as IClass;
if (c != null) {
// use this hack to show dummy classes like "short"
// (go from the dummy class to the real class)
if (c.Methods.Count > 0) {
c = c.Methods[0].DeclaringType;
}
switch (c.FullyQualifiedName) {
case "System.Byte":
case "System.SByte":
case "System.Int16":
case "System.UInt16":
case "System.Int32":
case "System.UInt32":
case "System.Int64":
case "System.UInt64":
return true;
default:
return false;
}
} else {
return false;
}
}
public override string ToString()
{
return "[" + GetType().Name + "]";
}
}
#endregion
#region AttributeExpressionContext
sealed class AttributeExpressionContext : ExpressionContext
{
public override bool ShowEntry(ICompletionEntry o)
{
if (!(o is IEntity))
return true;
IClass c = o as IClass;
if (c != null && !c.IsAbstract) {
return c.IsTypeInInheritanceTree(c.ProjectContent.SystemTypes.Attribute.GetUnderlyingClass());
} else {
return false;
}
}
public override bool IsTypeContext {
get { return true; }
}
public override string ToString()
{
return "[" + GetType().Name + "]";
}
}
#endregion
#region InheritableTypeExpressionContext
sealed class InheritableTypeExpressionContext : ExpressionContext
{
public override bool ShowEntry(ICompletionEntry o)
{
if (!(o is IEntity)) return true;
IClass c = o as IClass;
if (c != null) {
foreach (IClass innerClass in c.InnerClasses) {
if (ShowEntry(innerClass)) return true;
}
if (c.ClassType == ClassType.Interface) return true;
if (c.ClassType == ClassType.Class) {
if (!c.IsSealed && !c.IsStatic) return true;
}
}
return false;
}
public override string ToString()
{
return "[" + GetType().Name + "]";
}
}
#endregion
#region ClassTypeExpressionContext
sealed class ClassTypeExpressionContext : ExpressionContext
{
readonly ClassType expectedType;
public ClassTypeExpressionContext(ClassType expectedType)
{
this.expectedType = expectedType;
}
public override bool ShowEntry(ICompletionEntry o)
{
if (!(o is IEntity)) return true;
IClass c = o as IClass;
if (c != null) {
foreach (IClass innerClass in c.InnerClasses) {
if (ShowEntry(innerClass)) return true;
}
if (c.ClassType == expectedType) return true;
}
return false;
}
public override string ToString()
{
return "[" + GetType().Name + " expectedType=" + expectedType.ToString() + "]";
}
}
#endregion
#region NonStaticTypeExpressionContext
internal sealed class NonStaticTypeExpressionContext : ExpressionContext
{
string name;
bool allowVoid;
public NonStaticTypeExpressionContext(string name, bool allowVoid)
{
this.name = name;
this.allowVoid = allowVoid;
}
public override bool ShowEntry(ICompletionEntry o)
{
if (!(o is IEntity)) return true;
IClass c = o as IClass;
if (c != null) {
if (!allowVoid) {
if (c.FullyQualifiedName == "System.Void" || c.FullyQualifiedName == "void") return false;
}
foreach (IClass innerClass in c.InnerClasses) {
if (ShowEntry(innerClass)) return true;
}
if (!c.IsStatic && c.ClassType != ClassType.Module) return true;
}
return false;
}
public override string ToString()
{
return "[" + GetType().Name + " " + name + "]";
}
}
#endregion
}
}

104
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExtensionMethods.cs

@ -1,104 +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.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.SharpDevelop.Dom
{
static class ExtensionMethods
{
public static void AddRange(this ArrayList arrayList, IEnumerable elements)
{
foreach (object o in elements)
arrayList.Add(o);
}
public static void AddRange<T>(this ICollection<T> list, IEnumerable<T> elements)
{
foreach (T o in elements)
list.Add(o);
}
/// <summary>
/// Converts a recursive data structure into a flat list.
/// </summary>
/// <param name="input">The root elements of the recursive data structure.</param>
/// <param name="recursive">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in preorder.</returns>
public static IEnumerable<T> Flatten<T>(this IEnumerable<T> input, Func<T, IEnumerable<T>> recursion)
{
Stack<IEnumerator<T>> stack = new Stack<IEnumerator<T>>();
try {
stack.Push(input.GetEnumerator());
while (stack.Count > 0) {
while (stack.Peek().MoveNext()) {
T element = stack.Peek().Current;
yield return element;
IEnumerable<T> children = recursion(element);
if (children != null) {
stack.Push(children.GetEnumerator());
}
}
stack.Pop().Dispose();
}
} finally {
while (stack.Count > 0) {
stack.Pop().Dispose();
}
}
}
public static IEnumerable<IUsing> GetAllUsings(this ICompilationUnit cu)
{
return (new[]{cu.UsingScope}).Flatten(s=>s.ChildScopes).SelectMany(s=>s.Usings);
}
}
/// <summary>
/// Publicly visible helper methods.
/// </summary>
public static class ExtensionMethodsPublic
{
// the difference between IClass and IReturnType is that IClass only contains the members
// that are declared in this very class,
// and IReturnType contains also members from base classes (including System.Object) and default (undeclared) constructors
static SignatureComparer memberSignatureComparer = new SignatureComparer();
public static bool HasMember(this IClass containingClass, IMember member)
{
return containingClass.AllMembers.Any(m => memberSignatureComparer.Equals(member, m));
}
public static bool HasMember(this IReturnType containingClass, IMember member)
{
return containingClass.GetMembers().Any(m => memberSignatureComparer.Equals(member, m));
}
public static bool ImplementsInterface(this IClass targetClass, IClass requiredInterface)
{
var targetClassType = targetClass.GetCompoundClass().DefaultReturnType;
var requiredInterfaceType = requiredInterface.GetCompoundClass().DefaultReturnType;
// class.DefaultReturnType.GetMethods() returns also methods from base classes, default ctor, ToString() etc. etc.
return !requiredInterfaceType.GetMembers().Any(missingMember => !targetClassType.HasMember(missingMember));
}
public static bool ImplementsAbstractClass(this IClass targetClass, IClass abstractClass)
{
var requiredAbstractMembers = MemberLookupHelper.GetAccessibleMembers(abstractClass.DefaultReturnType, targetClass, LanguageProperties.CSharp, true).Where(m => m.IsAbstract);
return !requiredAbstractMembers.Any(missingMember => !targetClass.HasMember(missingMember));
}
public static IEnumerable<IMember> GetMembers(this IReturnType typeReference)
{
var properties = typeReference.GetProperties().Cast<IMember>();
var methods = typeReference.GetMethods().Cast<IMember>();
var fields = typeReference.GetFields().Cast<IMember>();
var events = typeReference.GetEvents().Cast<IMember>();
return properties.Concat(methods).Concat(fields).Concat(events);
}
}
}

114
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/FilePosition.cs

@ -1,114 +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 ICSharpCode.NRefactory;
namespace ICSharpCode.SharpDevelop.Dom
{
public struct FilePosition : IEquatable<FilePosition>
{
string filename;
Location position;
ICompilationUnit compilationUnit;
public static readonly FilePosition Empty = new FilePosition(null, Location.Empty);
public FilePosition(ICompilationUnit compilationUnit, int line, int column)
{
this.position = new Location(column, line);
this.compilationUnit = compilationUnit;
if (compilationUnit != null) {
this.filename = compilationUnit.FileName;
} else {
this.filename = null;
}
}
public FilePosition(string filename)
: this(filename, Location.Empty)
{
}
public FilePosition(string filename, int line, int column)
: this(filename, new Location(column, line))
{
}
public FilePosition(string filename, Location position)
{
this.compilationUnit = null;
this.filename = filename;
this.position = position;
}
public string FileName {
get {
return filename;
}
}
public ICompilationUnit CompilationUnit {
get {
return compilationUnit;
}
}
public Location Position {
get {
return position;
}
}
public override string ToString()
{
return String.Format("{0} : (line {1}, col {2})",
filename,
Line,
Column);
}
public int Line {
get {
return position.Y;
}
}
public int Column {
get {
return position.X;
}
}
public bool IsEmpty {
get {
return filename == null;
}
}
public override bool Equals(object obj)
{
return obj is FilePosition && Equals((FilePosition)obj);
}
public bool Equals(FilePosition other)
{
return this.FileName == other.FileName && this.Position == other.Position;
}
public override int GetHashCode()
{
return filename.GetHashCode() ^ position.GetHashCode();
}
public static bool operator ==(FilePosition lhs, FilePosition rhs)
{
return lhs.Equals(rhs);
}
public static bool operator !=(FilePosition lhs, FilePosition rhs)
{
return !lhs.Equals(rhs);
}
}
}

31
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/FoldingRegion.cs

@ -1,31 +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;
namespace ICSharpCode.SharpDevelop.Dom
{
public sealed class FoldingRegion : Immutable
{
string name;
DomRegion region;
public string Name {
get {
return name;
}
}
public DomRegion Region {
get {
return region;
}
}
public FoldingRegion(string name, DomRegion region)
{
this.name = name;
this.region = region;
}
}
}

275
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/FusionNative.cs

@ -1,275 +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.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
namespace MSjogren.GacTool.FusionNative
{
[ComImport(), Guid("E707DCDE-D1CD-11D2-BAB9-00C04F8ECEAE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAssemblyCache
{
[PreserveSig()]
int UninstallAssembly(uint dwFlags,
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName,
IntPtr pvReserved,
out uint pulDisposition);
[PreserveSig()]
int QueryAssemblyInfo(uint dwFlags,
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName,
IntPtr pAsmInfo);
[PreserveSig()]
int CreateAssemblyCacheItem(uint dwFlags,
IntPtr pvReserved,
out IAssemblyCacheItem ppAsmItem,
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName);
[PreserveSig()]
int CreateAssemblyScavenger(out object ppAsmScavenger);
[PreserveSig()]
int InstallAssembly(uint dwFlags,
[MarshalAs(UnmanagedType.LPWStr)] string pszManifestFilePath,
IntPtr pvReserved);
}
[ComImport(), Guid("9E3AAEB4-D1CD-11D2-BAB9-00C04F8ECEAE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAssemblyCacheItem
{
void CreateStream([MarshalAs(UnmanagedType.LPWStr)] string pszName,
uint dwFormat,
uint dwFlags,
uint dwMaxSize,
out IStream ppStream);
void IsNameEqual(IAssemblyName pName);
void Commit(uint dwFlags);
void MarkAssemblyVisible(uint dwFlags);
}
[ComImport(), Guid("CD193BC0-B4BC-11D2-9833-00C04FC31D2E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAssemblyName
{
//
// Assembly name properties
// 0 = PublicKey, byte[]* ; ???
// 1 = PublicKeyToken, byte[8]*
// 3 = Assembly Name, LPWSTR
// 4 = Major Version, ushort*
// 5 = Minor Version, ushort*
// 6 = Build Number, ushort*
// 7 = Revison Number, ushort*
// 8 = Culture, LPWSTR
// 9 = Processor Type, ??? ; ???
// 10 = OS Type, ??? ; ???
// 13 = Codebase, LPWSTR
// 14 = Modified Date, FILETIME* ; Only for Downloaded assemblies ?
// 17 = Custom, LPWSTR ; ZAP string, only for NGEN assemblies
// 19 = MVID, byte[16]* ; MVID value from __AssemblyInfo__.ini - what's this?
//
[PreserveSig()]
int Set(uint PropertyId,
IntPtr pvProperty,
uint cbProperty);
[PreserveSig()]
int Get(uint PropertyId,
IntPtr pvProperty,
ref uint pcbProperty);
[PreserveSig()]
int Finalize();
[PreserveSig()]
int GetDisplayName([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder szDisplayName,
ref uint pccDisplayName,
uint dwDisplayFlags);
[PreserveSig()]
int BindToObject(object refIID,
object pAsmBindSink,
IApplicationContext pApplicationContext,
[MarshalAs(UnmanagedType.LPWStr)] string szCodeBase,
long llFlags,
int pvReserved,
uint cbReserved,
out int ppv);
[PreserveSig()]
int GetName(ref uint lpcwBuffer,
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwzName);
[PreserveSig()]
int GetVersion(out uint pdwVersionHi,
out uint pdwVersionLow);
[PreserveSig()]
int IsEqual(IAssemblyName pName,
uint dwCmpFlags);
[PreserveSig()]
int Clone(out IAssemblyName pName);
}
[ComImport(), Guid("7C23FF90-33AF-11D3-95DA-00A024A85B51"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IApplicationContext
{
void SetContextNameObject(IAssemblyName pName);
void GetContextNameObject(out IAssemblyName ppName);
void Set([MarshalAs(UnmanagedType.LPWStr)] string szName,
int pvValue,
uint cbValue,
uint dwFlags);
void Get([MarshalAs(UnmanagedType.LPWStr)] string szName,
out int pvValue,
ref uint pcbValue,
uint dwFlags);
void GetDynamicDirectory(out int wzDynamicDir,
ref uint pdwSize);
}
[ComImport(), Guid("21B8916C-F28E-11D2-A473-00C04F8EF448"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAssemblyEnum
{
[PreserveSig()]
int GetNextAssembly(out IApplicationContext ppAppCtx,
out IAssemblyName ppName,
uint dwFlags);
[PreserveSig()]
int Reset();
[PreserveSig()]
int Clone(out IAssemblyEnum ppEnum);
}
[ComImport(), Guid("1D23DF4D-A1E2-4B8B-93D6-6EA3DC285A54"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IHistoryReader
{
[PreserveSig()]
int GetFilePath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFilePath,
ref uint pdwSize);
[PreserveSig()]
int GetApplicationName([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAppName,
ref uint pdwSize);
[PreserveSig()]
int GetEXEModulePath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzExePath,
ref uint pdwSize);
void GetNumActivations(out uint pdwNumActivations);
void GetActivationDate(uint dwIdx, // One-based!
out long /* FILETIME */ pftDate);
[PreserveSig()]
int GetRunTimeVersion(ref long /* FILETIME */ pftActivationDate,
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzRunTimeVersion,
ref uint pdwSize);
void GetNumAssemblies(ref long /* FILETIME */ pftActivationDate,
out uint pdwNumAsms);
void GetHistoryAssembly(ref long /* FILETIME */ pftActivationDate,
uint dwIdx, // One-based!
[MarshalAs(UnmanagedType.IUnknown)] out object ppHistAsm);
}
internal static class Fusion
{
[DllImport("fusion.dll", CharSet=CharSet.Auto)]
internal static extern int CreateAssemblyCache(out IAssemblyCache ppAsmCache,
uint dwReserved);
//
// dwFlags: 1 = Enumerate native image (NGEN) assemblies
// 2 = Enumerate GAC assemblies
// 4 = Enumerate Downloaded assemblies ???
//
[DllImport("fusion.dll", CharSet=CharSet.Auto)]
internal static extern int CreateAssemblyEnum(out IAssemblyEnum ppEnum,
IApplicationContext pAppCtx,
IAssemblyName pName,
uint dwFlags,
int pvReserved);
[DllImport("fusion.dll", CharSet=CharSet.Auto)]
internal static extern int CreateAssemblyNameObject(out IAssemblyName ppName,
string szAssemblyName,
uint dwFlags,
int pvReserved);
[DllImport("fusion.dll", CharSet=CharSet.Auto)]
internal static extern int CreateHistoryReader(string wzFilePath,
out IHistoryReader ppHistReader);
// Retrieves the path of the ApplicationHistory folder, typically
// Documents and Settings\<user>\Local Settings\Application Data\ApplicationHistory
// containing .ini files that can be read with IHistoryReader.
// pwdSize appears to be the offset of the last backslash in the returned
// string after the call.
// Returns S_OK on success, error HRESULT on failure.
//
[DllImport("fusion.dll", CharSet=CharSet.Unicode)]
internal static extern int GetHistoryFileDirectory([MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDir,
ref uint pdwSize);
[DllImport("fusion.dll")]
internal static extern int NukeDownloadedCache();
// ?????
[DllImport("fusion.dll")]
internal static extern int CreateApplicationContext(out IApplicationContext ppAppContext,
uint dw);
[DllImport("fusion.dll")]
internal static extern int GetCachePath(uint flags,
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDir,
ref uint pdwSize);
public static string GetGacPath(bool isCLRv4 = false)
{
const uint ASM_CACHE_ROOT = 0x08; // CLR V2.0
const uint ASM_CACHE_ROOT_EX = 0x80; // CLR V4.0
uint flags = isCLRv4 ? ASM_CACHE_ROOT_EX : ASM_CACHE_ROOT;
const int size = 260; // MAX_PATH
StringBuilder b = new StringBuilder(size);
uint tmp = size;
GetCachePath(flags, b, ref tmp);
return b.ToString();
}
// _InstallCustomAssembly@16
// _InstallCustomModule@8
// _LookupHistoryAssembly@28
// _PreBindAssembly@20
// _CreateInstallReferenceEnum@16
//
// Brings up the .NET Applicaion Restore wizard
// Returns S_OK, 0x80131075 (App not run) or 0x80131087 (Fix failed)
//
[DllImport("shfusion.dll", CharSet=CharSet.Unicode)]
internal static extern uint PolicyManager(IntPtr hWndParent,
string pwzFullyQualifiedAppPath,
string pwzAppName,
int dwFlags);
}
}

198
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/GacInterop.cs

@ -1,198 +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.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using MSjogren.GacTool.FusionNative;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Class with static members to access the content of the global assembly
/// cache.
/// </summary>
public static class GacInterop
{
static readonly string cachedGacPathV2 = Fusion.GetGacPath(false);
static readonly string cachedGacPathV4 = Fusion.GetGacPath(true);
public static string GacRootPathV2 {
get { return cachedGacPathV2; }
}
public static string GacRootPathV4 {
get { return cachedGacPathV4; }
}
public static bool IsWithinGac(string assemblyLocation)
{
return Core.FileUtility.IsBaseDirectory(GacRootPathV2, assemblyLocation)
|| Core.FileUtility.IsBaseDirectory(GacRootPathV4, assemblyLocation);
}
public static List<DomAssemblyName> GetAssemblyList()
{
IApplicationContext applicationContext = null;
IAssemblyEnum assemblyEnum = null;
IAssemblyName assemblyName = null;
List<DomAssemblyName> l = new List<DomAssemblyName>();
Fusion.CreateAssemblyEnum(out assemblyEnum, null, null, 2, 0);
while (assemblyEnum.GetNextAssembly(out applicationContext, out assemblyName, 0) == 0) {
uint nChars = 0;
assemblyName.GetDisplayName(null, ref nChars, 0);
StringBuilder sb = new StringBuilder((int)nChars);
assemblyName.GetDisplayName(sb, ref nChars, 0);
l.Add(new DomAssemblyName(sb.ToString()));
}
return l;
}
/// <summary>
/// Gets the full display name of the GAC assembly of the specified short name
/// </summary>
public static DomAssemblyName FindBestMatchingAssemblyName(string name)
{
return FindBestMatchingAssemblyName(new DomAssemblyName(name));
}
public static DomAssemblyName FindBestMatchingAssemblyName(DomAssemblyName name)
{
string[] info;
Version requiredVersion = name.Version;
string publicKey = name.PublicKeyToken;
IApplicationContext applicationContext = null;
IAssemblyEnum assemblyEnum = null;
IAssemblyName assemblyName;
Fusion.CreateAssemblyNameObject(out assemblyName, name.ShortName, 0, 0);
Fusion.CreateAssemblyEnum(out assemblyEnum, null, assemblyName, 2, 0);
List<string> names = new List<string>();
while (assemblyEnum.GetNextAssembly(out applicationContext, out assemblyName, 0) == 0) {
uint nChars = 0;
assemblyName.GetDisplayName(null, ref nChars, 0);
StringBuilder sb = new StringBuilder((int)nChars);
assemblyName.GetDisplayName(sb, ref nChars, 0);
string fullName = sb.ToString();
if (publicKey != null) {
info = fullName.Split(',');
if (publicKey != info[3].Substring(info[3].LastIndexOf('=') + 1)) {
// Assembly has wrong public key
continue;
}
}
names.Add(fullName);
}
if (names.Count == 0)
return null;
string best = null;
Version bestVersion = null;
Version currentVersion;
if (requiredVersion != null) {
// use assembly with lowest version higher or equal to required version
for (int i = 0; i < names.Count; i++) {
info = names[i].Split(',');
currentVersion = new Version(info[1].Substring(info[1].LastIndexOf('=') + 1));
if (currentVersion.CompareTo(requiredVersion) < 0)
continue; // version not good enough
if (best == null || currentVersion.CompareTo(bestVersion) < 0) {
bestVersion = currentVersion;
best = names[i];
}
}
if (best != null)
return new DomAssemblyName(best);
}
// use assembly with highest version
best = names[0];
info = names[0].Split(',');
bestVersion = new Version(info[1].Substring(info[1].LastIndexOf('=') + 1));
for (int i = 1; i < names.Count; i++) {
info = names[i].Split(',');
currentVersion = new Version(info[1].Substring(info[1].LastIndexOf('=') + 1));
if (currentVersion.CompareTo(bestVersion) > 0) {
bestVersion = currentVersion;
best = names[i];
}
}
return new DomAssemblyName(best);
}
#region FindAssemblyInGac
// This region is based on code from Mono.Cecil:
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
static readonly string[] gac_paths = { GacInterop.GacRootPathV2, GacInterop.GacRootPathV4 };
static readonly string[] gacs = { "GAC_MSIL", "GAC_32", "GAC" };
static readonly string[] prefixes = { string.Empty, "v4.0_" };
/// <summary>
/// Gets the file name for an assembly stored in the GAC.
/// </summary>
public static string FindAssemblyInNetGac (DomAssemblyName reference)
{
// without public key, it can't be in the GAC
if (reference.PublicKeyToken == null)
return null;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < gacs.Length; j++) {
var gac = Path.Combine (gac_paths [i], gacs [j]);
var file = GetAssemblyFile (reference, prefixes [i], gac);
if (File.Exists (file))
return file;
}
}
return null;
}
static string GetAssemblyFile (DomAssemblyName reference, string prefix, string gac)
{
var gac_folder = new StringBuilder ()
.Append (prefix)
.Append (reference.Version)
.Append ("__");
gac_folder.Append (reference.PublicKeyToken);
return Path.Combine (
Path.Combine (
Path.Combine (gac, reference.ShortName), gac_folder.ToString ()),
reference.ShortName + ".dll");
}
#endregion
}
}

62
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/HostCallback.cs

@ -1,62 +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 ICSharpCode.SharpDevelop.Dom.Refactoring;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// A class containing static actions that should be overridden by the
/// application using ICSharpCode.SharpDevelop.Dom.
/// </summary>
public static class HostCallback
{
/// <summary>
/// Show an error message. (string message, Exception ex)
/// </summary>
public static Action<string, Exception> ShowError = delegate(string message, Exception ex) {
LoggingService.Error(message, ex);
throw new Exception(message, ex);
};
public static Action<string> ShowMessage = delegate(string message) {
LoggingService.Info(message);
};
/// <summary>
/// Get the current project content.
/// </summary>
public static Func<IProjectContent> GetCurrentProjectContent = delegate {
throw new NotImplementedException("GetCurrentProjectContent was not implemented by the host.");
};
/// <summary>
/// Rename the member (first argument) to the new name (second argument).
/// Returns true on success, false on failure.
/// </summary>
public static Func<IMember, string, bool> RenameMember = delegate {
return false;
};
/// <summary>
/// Show error loading code-completion information.
/// The arguments are: string fileName, string include, string message
/// </summary>
public static Action<string, string, string> ShowAssemblyLoadError = delegate {};
internal static void ShowAssemblyLoadErrorInternal(string fileName, string include, string message)
{
LoggingService.Warn("Error loading code-completion information for "
+ include + " from " + fileName
+ ":\r\n" + message + "\r\n");
ShowAssemblyLoadError(fileName, include, message);
}
/// <summary>
/// Initialize the code generator options of the passed CodeGenerator.
/// Invoked exactly once for each created instance of a class derived from CodeGenerator.
/// </summary>
public static Action<CodeGenerator> InitializeCodeGeneratorOptions = delegate {};
}
}

24
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/IComment.cs

@ -1,24 +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)
namespace ICSharpCode.SharpDevelop.Dom
{
public interface IComment
{
bool IsBlockComment {
get;
}
string CommentTag {
get;
}
string CommentText {
get;
}
DomRegion Region {
get;
}
}
}

66
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/IExpressionFinder.cs

@ -1,66 +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;
namespace ICSharpCode.SharpDevelop.Dom
{
public interface IExpressionFinder
{
/// <summary>
/// Finds an expression before the current offset.
/// </summary>
ExpressionResult FindExpression(string text, int offset);
/// <summary>
/// Finds an expression around the current offset.
/// </summary>
ExpressionResult FindFullExpression(string text, int offset);
/// <summary>
/// Removed the last part of the expression.
/// </summary>
/// <example>
/// "arr[i]" => "arr"
/// "obj.Field" => "obj"
/// "obj.Method(args,...)" => "obj.Method"
/// </example>
string RemoveLastPart(string expression);
}
/// <summary>
/// Structure containing the result of a call to an expression finder.
/// </summary>
public struct ExpressionResult
{
public static readonly ExpressionResult Empty = new ExpressionResult(null);
/// <summary>The expression that has been found at the specified offset.</summary>
public string Expression;
/// <summary>The exact source code location of the expression.</summary>
public DomRegion Region;
/// <summary>Specifies the context in which the expression was found.</summary>
public ExpressionContext Context;
/// <summary>An object carrying additional language-dependend data.</summary>
public object Tag;
public ExpressionResult(string expression) : this(expression, DomRegion.Empty, ExpressionContext.Default, null) {}
public ExpressionResult(string expression, ExpressionContext context) : this(expression, DomRegion.Empty, context, null) {}
public ExpressionResult(string expression, DomRegion region, ExpressionContext context, object tag)
{
this.Expression = expression;
this.Region = region;
this.Context = context;
this.Tag = tag;
}
public override string ToString()
{
if (Context == ExpressionContext.Default)
return "<" + Expression + ">";
else
return "<" + Expression + "> (" + Context.ToString() + ")";
}
}
}

22
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/IResolver.cs

@ -1,22 +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.Collections;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Description of IResolver.
/// </summary>
public interface IResolver
{
/// <summary>
/// Resolves an expression.
/// The caretLineNumber and caretColumn is 1 based.
/// </summary>
ResolveResult Resolve(ExpressionResult expressionResult,
ParseInformation parseInfo,
string fileContent);
}
}

358
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AbstractEntity.cs

@ -1,358 +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.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
public abstract class AbstractEntity : AbstractFreezable, IEntity
{
ModifierEnum modifiers = ModifierEnum.None;
IList<IAttribute> attributes;
DomRegion bodyRegion;
IClass declaringType;
string fullyQualifiedName;
string name;
string nspace;
public AbstractEntity(IClass declaringType)
{
this.declaringType = declaringType;
}
public AbstractEntity(IClass declaringType, string name)
{
this.declaringType = declaringType;
this.name = name;
if (declaringType != null)
nspace = declaringType.FullyQualifiedName;
// lazy-computing the fully qualified name for class members saves ~7 MB RAM (when loading the SharpDevelop solution).
//fullyQualifiedName = nspace + '.' + name;
}
public override string ToString()
{
return String.Format("[{0}: {1}]", GetType().Name, FullyQualifiedName);
}
#region Naming
static readonly char[] nameDelimiters = { '.', '+' };
public string FullyQualifiedName {
get {
if (fullyQualifiedName == null) {
if (name != null && nspace != null) {
fullyQualifiedName = nspace + '.' + name;
} else {
return String.Empty;
}
}
return fullyQualifiedName;
}
set {
CheckBeforeMutation();
if (fullyQualifiedName == value)
return;
fullyQualifiedName = value;
name = null;
nspace = null;
OnFullyQualifiedNameChanged(EventArgs.Empty);
}
}
protected virtual void OnFullyQualifiedNameChanged(EventArgs e)
{
}
public virtual string DotNetName {
get {
if (this.DeclaringType != null) {
return this.DeclaringType.DotNetName + "." + this.Name;
} else {
return FullyQualifiedName;
}
}
}
public string Name {
get {
if (name == null && FullyQualifiedName != null) {
int lastIndex = FullyQualifiedName.LastIndexOfAny(nameDelimiters);
if (lastIndex < 0) {
name = FullyQualifiedName;
} else {
name = FullyQualifiedName.Substring(lastIndex + 1);
}
}
return name;
}
}
public string Namespace {
get {
if (nspace == null && FullyQualifiedName != null) {
int lastIndex = FullyQualifiedName.LastIndexOf('.');
if (lastIndex < 0) {
nspace = String.Empty;
} else {
nspace = FullyQualifiedName.Substring(0, lastIndex);
}
}
return nspace;
}
}
#endregion
protected override void FreezeInternal()
{
attributes = FreezeList(attributes);
base.FreezeInternal();
}
public IClass DeclaringType {
get {
return declaringType;
}
}
public virtual DomRegion BodyRegion {
get {
return bodyRegion;
}
set {
CheckBeforeMutation();
bodyRegion = value;
}
}
public object UserData { get; set; }
public IList<IAttribute> Attributes {
get {
if (attributes == null) {
attributes = new List<IAttribute>();
}
return attributes;
}
set {
CheckBeforeMutation();
attributes = value;
}
}
string documentation;
public virtual string Documentation {
get {
if (documentation == null) {
string documentationTag = this.DocumentationTag;
if (documentationTag != null) {
IProjectContent pc = null;
if (this is IClass) {
pc = ((IClass)this).ProjectContent;
} else if (declaringType != null) {
pc = declaringType.ProjectContent;
}
if (pc != null) {
return pc.GetXmlDocumentation(documentationTag);
}
}
}
return documentation;
}
set {
CheckBeforeMutation();
documentation = value;
}
}
protected void CopyDocumentationFrom(IEntity entity)
{
AbstractEntity ae = entity as AbstractEntity;
if (ae != null) {
this.Documentation = ae.documentation; // do not cause pc.GetXmlDocumentation call for documentation copy
} else {
this.Documentation = entity.Documentation;
}
}
public abstract string DocumentationTag {
get;
}
#region Modifiers
public ModifierEnum Modifiers {
get {
return modifiers;
}
set {
CheckBeforeMutation();
modifiers = value;
}
}
public bool IsAbstract {
get {
return (modifiers & ModifierEnum.Abstract) == ModifierEnum.Abstract;
}
}
public bool IsSealed {
get {
return (modifiers & ModifierEnum.Sealed) == ModifierEnum.Sealed;
}
}
public bool IsStatic {
get {
return ((modifiers & ModifierEnum.Static) == ModifierEnum.Static) || IsConst;
}
}
public bool IsConst {
get {
return (modifiers & ModifierEnum.Const) == ModifierEnum.Const;
}
}
public bool IsVirtual {
get {
return (modifiers & ModifierEnum.Virtual) == ModifierEnum.Virtual;
}
}
public bool IsPublic {
get {
return (modifiers & ModifierEnum.Public) == ModifierEnum.Public;
}
}
public bool IsProtected {
get {
return (modifiers & ModifierEnum.Protected) == ModifierEnum.Protected;
}
}
public bool IsPrivate {
get {
return (modifiers & ModifierEnum.Private) == ModifierEnum.Private;
}
}
public bool IsInternal {
get {
return (modifiers & ModifierEnum.Internal) == ModifierEnum.Internal;
}
}
[Obsolete("This property does not do what one would expect - it merely checks if protected+internal are set, it is not the equivalent of AssemblyAndFamily in Reflection!")]
public bool IsProtectedAndInternal {
get {
return (modifiers & (ModifierEnum.Internal | ModifierEnum.Protected)) == (ModifierEnum.Internal | ModifierEnum.Protected);
}
}
[Obsolete("This property does not do what one would expect - it merely checks if one of protected+internal is set, it is not the equivalent of AssemblyOrFamily in Reflection!")]
public bool IsProtectedOrInternal {
get {
return IsProtected || IsInternal;
}
}
public bool IsReadonly {
get {
return (modifiers & ModifierEnum.Readonly) == ModifierEnum.Readonly;
}
}
public bool IsOverride {
get {
return (modifiers & ModifierEnum.Override) == ModifierEnum.Override;
}
}
public bool IsOverridable {
get {
return (IsOverride || IsVirtual || IsAbstract ||
// Interface members have IsVirtual == IsAbstract == false. These properties are based on modifiers only.
(this.DeclaringType != null && this.DeclaringType.ClassType == ClassType.Interface))
&& !IsSealed;
}
}
public bool IsNew {
get {
return (modifiers & ModifierEnum.New) == ModifierEnum.New;
}
}
public bool IsSynthetic {
get {
return (modifiers & ModifierEnum.Synthetic) == ModifierEnum.Synthetic;
}
}
#endregion
public bool IsAccessible(IClass callingClass, bool isAccessThoughReferenceOfCurrentClass)
{
if (IsPublic) {
return true;
} else if (IsInternal) {
// members can be both internal and protected: in that case, we want to return true if it is visible
// through any of the modifiers
if (callingClass != null && this.DeclaringType.ProjectContent.InternalsVisibleTo(callingClass.ProjectContent))
return true;
}
// protected or private:
// search in callingClass and, if callingClass is a nested class, in its outer classes
while (callingClass != null) {
if (IsProtected) {
if (!isAccessThoughReferenceOfCurrentClass && !IsStatic)
return false;
return callingClass.IsTypeInInheritanceTree(this.DeclaringType);
} else {
// private
if (DeclaringType.FullyQualifiedName == callingClass.FullyQualifiedName
&& DeclaringType.TypeParameters.Count == callingClass.TypeParameters.Count)
{
return true;
}
}
callingClass = callingClass.DeclaringType;
}
return false;
}
public abstract ICompilationUnit CompilationUnit {
get;
}
public IProjectContent ProjectContent {
[System.Diagnostics.DebuggerStepThrough]
get {
return this.CompilationUnit.ProjectContent;
}
}
public virtual int CompareTo(IEntity value)
{
return this.Modifiers - value.Modifiers;
}
int IComparable.CompareTo(object value)
{
return CompareTo((IEntity)value);
}
public abstract EntityType EntityType {
get;
}
}
}

108
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AbstractMember.cs

@ -1,108 +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.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
public abstract class AbstractMember : AbstractEntity, IMember
{
IReturnType returnType;
DomRegion region;
IList<ExplicitInterfaceImplementation> interfaceImplementations;
IReturnType declaringTypeReference;
protected override void FreezeInternal()
{
interfaceImplementations = FreezeList(interfaceImplementations);
base.FreezeInternal();
}
public sealed override ICompilationUnit CompilationUnit {
[System.Diagnostics.DebuggerStepThrough]
get {
return this.DeclaringType.CompilationUnit;
}
}
public virtual DomRegion Region {
get {
return region;
}
set {
CheckBeforeMutation();
region = value;
}
}
public virtual IReturnType ReturnType {
get {
return returnType;
}
set {
CheckBeforeMutation();
returnType = value;
}
}
/// <summary>
/// Gets the declaring type reference (declaring type incl. type arguments)
/// </summary>
public virtual IReturnType DeclaringTypeReference {
get {
return declaringTypeReference ?? this.DeclaringType.DefaultReturnType;
}
set {
CheckBeforeMutation();
declaringTypeReference = value;
}
}
public IList<ExplicitInterfaceImplementation> InterfaceImplementations {
get {
return interfaceImplementations ?? (interfaceImplementations = new List<ExplicitInterfaceImplementation>());
}
}
public AbstractMember(IClass declaringType, string name) : base(declaringType, name)
{
// members must have a parent class
if (declaringType == null)
throw new ArgumentNullException("declaringType");
}
public abstract IMember Clone();
object ICloneable.Clone()
{
return this.Clone();
}
public override string Documentation {
get {
if (genericMember != null)
return genericMember.Documentation;
return base.Documentation;
}
set {
base.Documentation = value;
}
}
IMember genericMember;
public virtual IMember GenericMember {
get { return genericMember; }
}
public virtual IMember CreateSpecializedMember()
{
AbstractMember copy = Clone() as AbstractMember;
if (copy == null)
throw new Exception("Clone() must return an AbstractMember instance, or CreateSpecializedMember must also be overridden.");
copy.genericMember = this;
return copy;
}
}
}

136
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AbstractReturnType.cs

@ -1,136 +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.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Abstract return type for return types that are not a <see cref="ProxyReturnType"/>.
/// </summary>
public abstract class AbstractReturnType : IReturnType
{
public abstract IClass GetUnderlyingClass();
public abstract List<IMethod> GetMethods();
public abstract List<IProperty> GetProperties();
public abstract List<IField> GetFields();
public abstract List<IEvent> GetEvents();
public virtual int TypeArgumentCount {
get {
return 0;
}
}
public virtual bool Equals(IReturnType other)
{
if (other == null)
return false;
return other.IsDefaultReturnType && DefaultReturnType.Equals(this, other);
}
public sealed override bool Equals(object o)
{
return Equals(o as IReturnType);
}
public override int GetHashCode()
{
return DefaultReturnType.GetHashCode(this);
}
string fullyQualifiedName = null;
public virtual string FullyQualifiedName {
get {
if (fullyQualifiedName == null) {
return String.Empty;
}
return fullyQualifiedName;
}
set {
fullyQualifiedName = value;
}
}
public virtual string Name {
get {
if (FullyQualifiedName == null) {
return null;
}
int index = FullyQualifiedName.LastIndexOf('.');
return index < 0 ? FullyQualifiedName : FullyQualifiedName.Substring(index + 1);
}
}
public virtual string Namespace {
get {
if (FullyQualifiedName == null) {
return null;
}
int index = FullyQualifiedName.LastIndexOf('.');
return index < 0 ? String.Empty : FullyQualifiedName.Substring(0, index);
}
}
public virtual string DotNetName {
get {
return FullyQualifiedName;
}
}
public virtual bool IsDefaultReturnType {
get {
return true;
}
}
public virtual bool IsArrayReturnType {
get {
return false;
}
}
public virtual ArrayReturnType CastToArrayReturnType()
{
return null;
}
public virtual bool IsGenericReturnType {
get {
return false;
}
}
public virtual GenericReturnType CastToGenericReturnType()
{
return null;
}
public virtual bool IsConstructedReturnType {
get {
return false;
}
}
public virtual ConstructedReturnType CastToConstructedReturnType()
{
return null;
}
public bool IsDecoratingReturnType<T>() where T : DecoratingReturnType
{
return false;
}
public T CastToDecoratingReturnType<T>() where T : DecoratingReturnType
{
return null;
}
public virtual bool? IsReferenceType { get { return null; } }
public virtual IReturnType GetDirectReturnType()
{
return this;
}
}
}

190
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AnonymousMethodReturnType.cs

@ -1,190 +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.Collections.Generic;
using System.Text;
using System.Linq;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// The return type of anonymous method expressions or lambda expressions.
/// </summary>
public class AnonymousMethodReturnType : DecoratingReturnType
{
IReturnType returnType;
IList<IParameter> parameters;
ICompilationUnit cu;
public AnonymousMethodReturnType(ICompilationUnit cu)
{
this.cu = cu;
}
public override bool Equals(IReturnType other)
{
if (other == null) return false;
AnonymousMethodReturnType o = other.CastToDecoratingReturnType<AnonymousMethodReturnType>();
if (o == null) return false;
return this.FullyQualifiedName == o.FullyQualifiedName;
}
public override int GetHashCode()
{
return this.FullyQualifiedName.GetHashCode();
}
public override T CastToDecoratingReturnType<T>()
{
if (typeof(T) == typeof(AnonymousMethodReturnType)) {
return (T)(object)this;
} else {
return null;
}
}
public IReturnType ToDefaultDelegate()
{
IReturnType type = new GetClassReturnType(cu.ProjectContent, "System.Func", 0);
List<IReturnType> parameters = new List<IReturnType>();
if (this.HasParameterList)
parameters = MethodParameters.Select(p => p.ReturnType ?? new GetClassReturnType(cu.ProjectContent, "System.Object", 0)).ToList();
if (this.MethodReturnType != null && this.MethodReturnType.FullyQualifiedName == "System.Void")
type = new GetClassReturnType(cu.ProjectContent, "System.Action", 0);
else {
var rt = this.MethodReturnType;
if (rt == null)
rt = new GetClassReturnType(cu.ProjectContent, "System.Object", 0);
parameters.Add(rt);
}
return new ConstructedReturnType(type, parameters);
}
/// <summary>
/// Return type of the anonymous method. Can be null if inferred from context.
/// </summary>
public IReturnType MethodReturnType {
get { return returnType; }
set { returnType = value; }
}
public virtual IReturnType ResolveReturnType()
{
return returnType;
}
public virtual IReturnType ResolveReturnType(IReturnType[] parameterTypes)
{
return returnType;
}
/// <summary>
/// Gets the list of method parameters. Can be null if the anonymous method has no parameter list.
/// </summary>
public IList<IParameter> MethodParameters {
get { return parameters; }
set { parameters = value; }
}
public virtual bool CanBeConvertedToExpressionTree {
get { return false; }
}
public bool HasParameterList {
get { return parameters != null; }
}
public bool HasImplicitlyTypedParameters {
get {
if (parameters == null)
return false;
else
return parameters.Any(p => p.ReturnType == null);
}
}
DefaultClass cachedClass;
public override IClass GetUnderlyingClass()
{
if (cachedClass != null) return cachedClass;
DefaultClass c = new DefaultClass(cu, ClassType.Delegate, ModifierEnum.None, DomRegion.Empty, null);
c.BaseTypes.Add(cu.ProjectContent.SystemTypes.Delegate);
AddDefaultDelegateMethod(c, returnType ?? cu.ProjectContent.SystemTypes.Object, parameters ?? new IParameter[0]);
cachedClass = c;
return c;
}
internal static void AddDefaultDelegateMethod(DefaultClass c, IReturnType returnType, IList<IParameter> parameters)
{
ModifierEnum modifiers = ModifierEnum.Public | ModifierEnum.Synthetic;
DefaultMethod invokeMethod = new DefaultMethod("Invoke", returnType, modifiers, c.Region, DomRegion.Empty, c);
foreach (IParameter par in parameters) {
invokeMethod.Parameters.Add(par);
}
c.Methods.Add(invokeMethod);
invokeMethod = new DefaultMethod("BeginInvoke", c.ProjectContent.SystemTypes.IAsyncResult, modifiers, c.Region, DomRegion.Empty, c);
foreach (IParameter par in parameters) {
invokeMethod.Parameters.Add(par);
}
invokeMethod.Parameters.Add(new DefaultParameter("callback", c.ProjectContent.SystemTypes.AsyncCallback, DomRegion.Empty));
invokeMethod.Parameters.Add(new DefaultParameter("object", c.ProjectContent.SystemTypes.Object, DomRegion.Empty));
c.Methods.Add(invokeMethod);
invokeMethod = new DefaultMethod("EndInvoke", returnType, modifiers, c.Region, DomRegion.Empty, c);
invokeMethod.Parameters.Add(new DefaultParameter("result", c.ProjectContent.SystemTypes.IAsyncResult, DomRegion.Empty));
c.Methods.Add(invokeMethod);
}
public override IReturnType BaseType {
get {
return GetUnderlyingClass().DefaultReturnType;
}
}
public override string Name {
get {
return "delegate";
}
}
public override string FullyQualifiedName {
get {
StringBuilder b = new StringBuilder("delegate");
if (HasParameterList) {
bool first = true;
b.Append("(");
foreach (IParameter p in parameters) {
if (first) first = false; else b.Append(", ");
b.Append(p.Name);
if (p.ReturnType != null) {
b.Append(":");
b.Append(p.ReturnType.Name);
}
}
b.Append(")");
}
if (returnType != null) {
b.Append(":");
b.Append(returnType.Name);
}
return b.ToString();
}
}
public override string Namespace {
get {
return "";
}
}
public override string DotNetName {
get {
return Name;
}
}
}
}

157
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/ArrayReturnType.cs

@ -1,157 +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.Collections.Generic;
using System.Text;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// The ArrayReturnType wraps around another type, converting it into an array
/// with the specified number of dimensions.
/// The element type is only used as return type for the indexer; all methods and fields
/// are retrieved from System.Array.
/// </summary>
public sealed class ArrayReturnType : DecoratingReturnType
{
IReturnType elementType;
int dimensions;
IProjectContent pc;
internal IProjectContent ProjectContent {
get {
return pc;
}
}
public ArrayReturnType(IProjectContent pc, IReturnType elementType, int dimensions)
{
if (pc == null)
throw new ArgumentNullException("pc");
if (dimensions <= 0)
throw new ArgumentOutOfRangeException("dimensions", dimensions, "dimensions must be positive");
if (elementType == null)
throw new ArgumentNullException("elementType");
this.pc = pc;
this.elementType = elementType;
this.dimensions = dimensions;
}
public override IReturnType GetDirectReturnType()
{
IReturnType newElementType = elementType.GetDirectReturnType();
if (newElementType == elementType)
return this;
else
return new ArrayReturnType(pc, newElementType, dimensions);
}
public override bool Equals(IReturnType rt)
{
if (rt == null || !rt.IsArrayReturnType) return false;
ArrayReturnType art = rt.CastToArrayReturnType();
if (art.ArrayDimensions != dimensions) return false;
return elementType.Equals(art.ArrayElementType);
}
public override int GetHashCode()
{
unchecked {
return 2 * elementType.GetHashCode() + 27 * dimensions;
}
}
public override T CastToDecoratingReturnType<T>()
{
if (typeof(T) == typeof(ArrayReturnType)) {
return (T)(object)this;
} else {
return null;
}
}
public IReturnType ArrayElementType {
get {
return elementType;
}
}
public int ArrayDimensions {
get {
return dimensions;
}
}
public override string FullyQualifiedName {
get {
return elementType.FullyQualifiedName;
}
}
public override string Name {
get {
return elementType.Name;
}
}
public override string DotNetName {
get {
return AppendArrayString(elementType.DotNetName);
}
}
public override IReturnType BaseType {
get {
return pc.SystemTypes.Array;
}
}
/// <summary>
/// Indexer used exclusively for array return types
/// </summary>
public class ArrayIndexer : DefaultProperty
{
public ArrayIndexer(IReturnType elementType, IClass systemArray)
: base("Indexer", elementType, ModifierEnum.Public, DomRegion.Empty, DomRegion.Empty, systemArray)
{
IsIndexer = true;
}
}
public override List<IProperty> GetProperties()
{
List<IProperty> l = base.GetProperties();
IClass systemArray = this.BaseType.GetUnderlyingClass();
if (systemArray != null) {
ArrayIndexer property = new ArrayIndexer(elementType, systemArray);
IReturnType int32 = pc.SystemTypes.Int32;
for (int i = 0; i < dimensions; ++i) {
property.Parameters.Add(new DefaultParameter("index", int32, DomRegion.Empty));
}
property.Freeze();
l.Add(property);
}
return l;
}
/// <summary>
/// Appends the array characters ([,,,]) to the string <paramref name="a"/>.
/// </summary>
string AppendArrayString(string a)
{
StringBuilder b = new StringBuilder(a, a.Length + 1 + dimensions);
b.Append('[');
for (int i = 1; i < dimensions; ++i) {
b.Append(',');
}
b.Append(']');
return b.ToString();
}
public override string ToString()
{
return String.Format("[ArrayReturnType: {0}{1}]", elementType, AppendArrayString(""));
}
}
}

47
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AttributeReturnType.cs

@ -1,47 +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.Linq;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Like SearchClassReturnType, but tries both the specified name and name+"Attribute".
/// </summary>
public class AttributeReturnType : ProxyReturnType
{
string name;
SearchClassReturnType scrt1, scrt2;
public AttributeReturnType(ClassFinder context, string name)
{
if (context == null)
throw new ArgumentNullException("context");
if (name == null)
throw new ArgumentNullException("name");
this.name = name;
scrt1 = new SearchClassReturnType(context.ProjectContent, context.CallingClass,
context.CaretLine, context.CaretColumn, name, 0);
scrt2 = new SearchClassReturnType(context.ProjectContent, context.CallingClass,
context.CaretLine, context.CaretColumn, name + "Attribute", 0);
}
public override IReturnType BaseType {
get {
IClass class1 = scrt1.GetUnderlyingClass();
IClass class2 = scrt2.GetUnderlyingClass();
if (class1 != null && class2 != null) {
if (class1.ClassInheritanceTree.Any(c => c.FullyQualifiedName == "System.Attribute"))
return scrt1;
else
return scrt2;
} else if (class2 != null) {
return scrt2;
} else {
return scrt1;
}
}
}
}
}

91
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/BoundTypeParameter.cs

@ -1,91 +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.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// A type parameter that was bound to a concrete type.
/// </summary>
public sealed class BoundTypeParameter : AbstractFreezable, ITypeParameter
{
readonly ITypeParameter baseTypeParameter;
readonly IMethod owningMethod;
readonly IClass owningClass;
IReturnType boundTo;
public BoundTypeParameter(ITypeParameter baseTypeParameter, IClass owningClass)
: this(baseTypeParameter, owningClass, null)
{
}
public BoundTypeParameter(ITypeParameter baseTypeParameter, IClass owningClass, IMethod owningMethod)
{
if (owningClass == null)
throw new ArgumentNullException("owningClass");
if (baseTypeParameter == null)
throw new ArgumentNullException("baseTypeParameter");
this.baseTypeParameter = baseTypeParameter;
this.owningMethod = owningMethod;
this.owningClass = owningClass;
}
protected override void FreezeInternal()
{
base.FreezeInternal();
baseTypeParameter.Freeze();
owningMethod.Freeze();
owningClass.Freeze();
}
public string Name {
get { return baseTypeParameter.Name; }
}
public int Index {
get { return baseTypeParameter.Index; }
}
public IList<IAttribute> Attributes {
get { return baseTypeParameter.Attributes; }
}
public IMethod Method {
get { return owningMethod; }
}
public IClass Class {
get { return owningClass; }
}
public IList<IReturnType> Constraints {
get { return baseTypeParameter.Constraints; }
}
public bool HasConstructableConstraint {
get { return baseTypeParameter.HasConstructableConstraint; }
}
public bool HasReferenceTypeConstraint {
get { return baseTypeParameter.HasReferenceTypeConstraint; }
}
public bool HasValueTypeConstraint {
get { return baseTypeParameter.HasValueTypeConstraint; }
}
public IReturnType BoundTo {
get { return boundTo; }
set {
CheckBeforeMutation();
boundTo = value;
}
}
public ITypeParameter UnboundTypeParameter {
get { return baseTypeParameter.UnboundTypeParameter; }
}
}
}

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

Loading…
Cancel
Save