Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikayla Hutchinson <m.j.hutchinson@gmail.com>2017-03-18 01:36:33 +0300
committerMikayla Hutchinson <m.j.hutchinson@gmail.com>2017-03-18 01:36:33 +0300
commitf84a4368b156875300e7a3206e73a28e2436033c (patch)
tree2355731ce6ad49f58a7ebc7f287d5a34518e526d
parent191a296fa05886f8286a9123a14913b6a53a99c6 (diff)
parente316531c1336cd290aa32b0cf06146535fff68ea (diff)
Merge remote-tracking branch 'origin/master' into roslyn-ivt
-rw-r--r--main/Main.sln61
-rw-r--r--main/build/MacOSX/monostub-utils.h3
-rw-r--r--main/configure.ac3
m---------main/external/debugger-libs0
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompletionTests.fs1
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs10
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs2
m---------main/external/mono-addins0
m---------main/external/nuget-binary0
m---------main/external/xwt0
-rw-r--r--main/src/addins/AspNet/MonoDevelop.AspNet.csproj9
-rw-r--r--main/src/addins/AspNet/packages.config3
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.NonUserCodeTestLib/NonUserCodeClass.cs48
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/AdvancedEvaluation.cs194
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/AssemblyInfo.cs51
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/BreakpointsAndStepping.cs712
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/Main.cs42
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/MonoDevelop.Debugger.Tests.TestApp.csproj58
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/TestEvaluation.cs784
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/AdvancedEvaluationTests.cs204
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/BreakpointsAndSteppingTests.cs1157
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorBreakpointsAndSteppingTests.cs39
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorEvaluationTests.cs49
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorStackFrameTests.cs47
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/DebugTests.MonoDevelop.cs136
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/DebugTests.cs466
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/EvaluationTests.cs2459
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj20
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbEvaluationTests.cs46
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbStackFrameTests.cs46
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/StackFrameTests.cs120
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/TextFile.cs77
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs15
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdkPaths.cs5
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs2
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/ActionGroup.xft.xml1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/ActionGroupPartial.xft.xml1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/Dialog.xft.xml1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/DialogPartial.xft.xml1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/DrawingArea.xft.xml3
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/Widget.xft.xml1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/WidgetPartial.xft.xml7
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/Window.xft.xml1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/templates/WindowPartial.xft.xml1
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs4
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSpecCreatorTests.cs71
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs10
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSpecCreator.cs35
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectPackageReference.cs8
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs169
-rw-r--r--main/src/addins/TextTemplating/Makefile.am5
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs113
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/EngineTests.cs72
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerateIndentedClassCodeTests.cs108
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs205
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Makefile.am1
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj61
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs191
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs636
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs72
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TextTemplatingSessionTests.cs57
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/AssemblyInfo.cs37
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Makefile.am1
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs79
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs56
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs40
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Engine.cs58
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Interfaces.cs104
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs211
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs196
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs83
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTransformation.cs216
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs69
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.csproj83
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.nuspec21
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs145
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs59
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/FileUtil.cs132
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/ParsedTemplate.cs337
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/RecyclableAppDomain.cs215
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs466
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateSettings.cs79
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs1169
-rw-r--r--main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/Tokeniser.cs293
-rw-r--r--main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj13
-rw-r--r--main/src/addins/TextTemplating/MonoDevelop.TextTemplating/packages.config4
-rw-r--r--main/src/addins/TextTemplating/TextTransform/AssemblyInfo.cs39
-rw-r--r--main/src/addins/TextTemplating/TextTransform/Makefile.am1
-rw-r--r--main/src/addins/TextTemplating/TextTransform/Options.cs1099
-rw-r--r--main/src/addins/TextTemplating/TextTransform/TextTransform.cs171
-rw-r--r--main/src/addins/TextTemplating/TextTransform/TextTransform.csproj55
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs12
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml6
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj1
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ImportSearchPathExtensionNode.cs (renamed from main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbBreakpointsAndSteppingTests.cs)91
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild.Conditions/ConditionRelationalExpression.cs53
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs74
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs85
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs64
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs299
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/RemoteProjectBuilder.cs51
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs40
-rw-r--r--main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/HasReferenceFileTemplateCondition.cs64
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj1
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.cs2
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs4
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs16
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/BuildEngine.Shared.cs2
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/Main.cs19
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/RemoteBuildEngineMessages.cs3
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.config9
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/MSBuildGlobTests.cs81
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/MSBuildProjectTests.cs377
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/MSBuildSearchPathTests.cs198
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs353
-rw-r--r--main/tests/UnitTests/UnitTests.csproj6
-rwxr-xr-xmain/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.csproj45
-rwxr-xr-xmain/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.csproj.saved153
-rwxr-xr-xmain/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.targets9
-rwxr-xr-xmain/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved357
-rwxr-xr-xmain/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved459
-rwxr-xr-xmain/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved558
-rwxr-xr-xmain/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved656
-rwxr-xr-xmain/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/Sdk.props6
-rwxr-xr-xmain/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/Sdk.targets3
-rw-r--r--main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/test-import.targets5
-rwxr-xr-xmain/tests/test-projects/dotnetcore-console/Sdks/Test.Sdk/Sdk/Sdk.props9
-rwxr-xr-xmain/tests/test-projects/dotnetcore-console/Sdks/Test.Sdk/Sdk/Sdk.targets3
-rwxr-xr-xmain/tests/test-projects/dotnetcore-console/dotnetcore-console/dotnetcore-disable-default-items.csproj12
-rwxr-xr-xmain/tests/test-projects/dotnetcore-console/dotnetcore-console/dotnetcore-msbuildsdkspath-import.csproj8
-rwxr-xr-xmain/tests/test-projects/dotnetcore-console/dotnetcore-disable-default-items.sln22
-rwxr-xr-xmain/tests/test-projects/dotnetcore-console/dotnetcore-msbuildsdkspath-import.sln22
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-test-saved1.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-test-saved5.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update1-test-saved.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update1-test.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved2.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update2-test.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved.csproj4
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved2.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved3.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update3-test.csproj4
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update4-test-saved.csproj2
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-update4-test.csproj2
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/ConsoleProject.csproj42
-rwxr-xr-x[-rw-r--r--]main/tests/test-projects/msbuild-search-paths/ProjectUsingMultiSdk.csproj (renamed from main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.NonUserCodeTestLib/MonoDevelop.Debugger.Tests.NonUserCodeTestLib.csproj)37
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/ProjectUsingSdk.csproj41
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/ProjectUsingSdk2.csproj41
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/extensions-path/15.0/Microsoft.Common.targets/ImportAfter/injected-target.targets6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/extensions-path/simple.props6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/sdk-path-2/Bar.Sdk/Sdk/Sdk.props6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/sdk-path-2/Bar.Sdk/Sdk/Sdk.targets6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/sdk-path-all/Bar.Sdk/Sdk/Sdk.props6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/sdk-path-all/Bar.Sdk/Sdk/Sdk.targets6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/sdk-path-all/Foo.Sdk/Sdk/Sdk.props6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/sdk-path-all/Foo.Sdk/Sdk/Sdk.targets6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/sdk-path/Foo.Sdk/Sdk/Sdk.props6
-rwxr-xr-xmain/tests/test-projects/msbuild-search-paths/sdk-path/Foo.Sdk/Sdk/Sdk.targets6
161 files changed, 2830 insertions, 14004 deletions
diff --git a/main/Main.sln b/main/Main.sln
index baa5c1677d..b382083c9b 100644
--- a/main/Main.sln
+++ b/main/Main.sln
@@ -125,14 +125,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.AspNet.Tests",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TextTemplating", "TextTemplating", "{68F63ACB-A9B2-468F-B365-0F41F0D5F1DA}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.TextTemplating", "src\addins\TextTemplating\Mono.TextTemplating\Mono.TextTemplating.csproj", "{A2364D6A-00EF-417C-80A6-815726C70032}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextTransform", "src\addins\TextTemplating\TextTransform\TextTransform.csproj", "{D1D35409-C814-47F6-B038-B9B5BF0FE490}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.TextTemplating", "src\addins\TextTemplating\MonoDevelop.TextTemplating\MonoDevelop.TextTemplating.csproj", "{8CCA39DD-8412-4547-BE7F-0C3D3ACC6FAC}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.TextTemplating.Tests", "src\addins\TextTemplating\Mono.TextTemplating.Tests\Mono.TextTemplating.Tests.csproj", "{CB590106-8331-4CBE-8131-B154E7BF79E1}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MonoDevelop.Debugger.Soft", "MonoDevelop.Debugger.Soft", "{33248236-FF84-4336-A73B-65E6B1090D15}"
ProjectSection(MonoDevelopProperties) = preProject
BaseDirectory = src\addins\MonoDevelop.Debugger.Soft
@@ -152,11 +146,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Debugger", "src
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Debugger.Tests", "src\addins\MonoDevelop.Debugger\MonoDevelop.Debugger.Tests\MonoDevelop.Debugger.Tests.csproj", "{174E6044-DD3A-49AB-9A5C-2A1F341B7B4F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Debugger.Tests.TestApp", "src\addins\MonoDevelop.Debugger\MonoDevelop.Debugger.Tests.TestApp\MonoDevelop.Debugger.Tests.TestApp.csproj", "{05EDFE55-C8D1-47E4-BB61-0BC809CD82E2}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Debugger.Tests.TestApp", "external\debugger-libs\UnitTests\MonoDevelop.Debugger.Tests.TestApp\MonoDevelop.Debugger.Tests.TestApp.csproj", "{05EDFE55-C8D1-47E4-BB61-0BC809CD82E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Debugger.Gdb", "src\addins\MonoDevelop.Debugger.Gdb\MonoDevelop.Debugger.Gdb.csproj", "{FA15FC26-A7E7-4932-93B7-65FAE6D5DD33}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Debugger.Tests.NonUserCodeTestLib", "src\addins\MonoDevelop.Debugger\MonoDevelop.Debugger.Tests.NonUserCodeTestLib\MonoDevelop.Debugger.Tests.NonUserCodeTestLib.csproj", "{8AFA4FB4-BD2D-478F-942B-7AE3451535BB}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Debugger.Tests.NonUserCodeTestLib", "external\debugger-libs\UnitTests\MonoDevelop.Debugger.Tests.NonUserCodeTestLib\MonoDevelop.Debugger.Tests.NonUserCodeTestLib.csproj", "{8AFA4FB4-BD2D-478F-942B-7AE3451535BB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MonoDevelop.Debugger.Win32", "MonoDevelop.Debugger.Win32", "{8F47F5EC-2F57-4030-B658-7B1002DA90C2}"
ProjectSection(SolutionItems) = preProject
@@ -1199,22 +1193,6 @@ Global
{9FBCC262-10DC-4E84-A5C4-17230BBF8862}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
{9FBCC262-10DC-4E84-A5C4-17230BBF8862}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
{9FBCC262-10DC-4E84-A5C4-17230BBF8862}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.DebugGnome|Any CPU.Build.0 = Debug|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.DebugMac|Any CPU.Build.0 = Debug|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.DebugWin32|Any CPU.ActiveCfg = Debug|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.DebugWin32|Any CPU.Build.0 = Debug|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.Release|Any CPU.Build.0 = Release|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.ReleaseGnome|Any CPU.ActiveCfg = Release|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.ReleaseGnome|Any CPU.Build.0 = Release|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
- {A2364D6A-00EF-417C-80A6-815726C70032}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
{A437F1A3-78DF-4F00-8053-D32A8B1EB679}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A437F1A3-78DF-4F00-8053-D32A8B1EB679}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A437F1A3-78DF-4F00-8053-D32A8B1EB679}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
@@ -1448,22 +1426,6 @@ Global
{C93D746E-1586-4D4F-B411-BF5A966E6A08}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
{C93D746E-1586-4D4F-B411-BF5A966E6A08}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
{C93D746E-1586-4D4F-B411-BF5A966E6A08}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.DebugGnome|Any CPU.Build.0 = Debug|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.DebugMac|Any CPU.Build.0 = Debug|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.DebugWin32|Any CPU.ActiveCfg = Debug|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.DebugWin32|Any CPU.Build.0 = Debug|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.Release|Any CPU.Build.0 = Release|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.ReleaseGnome|Any CPU.ActiveCfg = Release|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.ReleaseGnome|Any CPU.Build.0 = Release|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
- {CB590106-8331-4CBE-8131-B154E7BF79E1}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
{CFC02FEC-BDF4-40B9-94D6-35E73F76A92E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFC02FEC-BDF4-40B9-94D6-35E73F76A92E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFC02FEC-BDF4-40B9-94D6-35E73F76A92E}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
@@ -1512,22 +1474,6 @@ Global
{D12F0F7B-8DE3-43EC-BA49-41052D065A9B}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
{D12F0F7B-8DE3-43EC-BA49-41052D065A9B}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
{D12F0F7B-8DE3-43EC-BA49-41052D065A9B}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.DebugGnome|Any CPU.Build.0 = Debug|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.DebugMac|Any CPU.Build.0 = Debug|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.DebugWin32|Any CPU.ActiveCfg = Debug|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.DebugWin32|Any CPU.Build.0 = Debug|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.Release|Any CPU.Build.0 = Release|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.ReleaseGnome|Any CPU.ActiveCfg = Release|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.ReleaseGnome|Any CPU.Build.0 = Release|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
- {D1D35409-C814-47F6-B038-B9B5BF0FE490}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.DebugGnome|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU
@@ -2209,10 +2155,7 @@ Global
{0AF16AF1-0876-413E-9803-08BD33C19E00} = {DE462010-393D-4655-A42C-2C78BB14D2FA}
{1CF94D07-5480-4D10-A3CD-2EBD5E87B02E} = {0ADCD824-2506-4A61-9B88-ABF1D5267CE8}
{BEFADF93-EE92-4806-9C0B-937B25311C95} = {0ADCD824-2506-4A61-9B88-ABF1D5267CE8}
- {A2364D6A-00EF-417C-80A6-815726C70032} = {68F63ACB-A9B2-468F-B365-0F41F0D5F1DA}
- {D1D35409-C814-47F6-B038-B9B5BF0FE490} = {68F63ACB-A9B2-468F-B365-0F41F0D5F1DA}
{8CCA39DD-8412-4547-BE7F-0C3D3ACC6FAC} = {68F63ACB-A9B2-468F-B365-0F41F0D5F1DA}
- {CB590106-8331-4CBE-8131-B154E7BF79E1} = {68F63ACB-A9B2-468F-B365-0F41F0D5F1DA}
{3D363F0C-5731-42AA-9022-B7F4657F298A} = {33248236-FF84-4336-A73B-65E6B1090D15}
{F5390DA4-08B7-47E3-B6F3-D50683316AB4} = {33248236-FF84-4336-A73B-65E6B1090D15}
{DE40756E-57F6-4AF2-B155-55E3A88CCED8} = {33248236-FF84-4336-A73B-65E6B1090D15}
diff --git a/main/build/MacOSX/monostub-utils.h b/main/build/MacOSX/monostub-utils.h
index b259041a58..11d07f5759 100644
--- a/main/build/MacOSX/monostub-utils.h
+++ b/main/build/MacOSX/monostub-utils.h
@@ -262,6 +262,9 @@ update_environment (const char *contentsDir, bool need64Bit)
if (push_env_to_start ("PATH", "/Library/Frameworks/Mono.framework/Commands"))
updated = YES;
+ if (push_env_to_end ("PATH", "/usr/local/bin"))
+ updated = YES;
+
if (need64Bit) {
if (push_env_to_start ("MONODEVELOP_64BIT_SAFE", "yes")) {
updated = YES;
diff --git a/main/configure.ac b/main/configure.ac
index 0762dfed70..4d6ee39a30 100644
--- a/main/configure.ac
+++ b/main/configure.ac
@@ -328,10 +328,7 @@ src/addins/MonoDevelop.GtkCore/Makefile
src/addins/MonoDevelop.GtkCore/libstetic/Makefile
src/addins/MonoDevelop.GtkCore/libsteticui/Makefile
src/addins/TextTemplating/Makefile
-src/addins/TextTemplating/Mono.TextTemplating/Makefile
-src/addins/TextTemplating/TextTransform/Makefile
src/addins/TextTemplating/MonoDevelop.TextTemplating/Makefile
-src/addins/TextTemplating/Mono.TextTemplating.Tests/Makefile
src/addins/AspNet/Makefile
src/addins/MonoDevelop.Autotools/Makefile
src/addins/MonoDevelop.DesignerSupport/Makefile
diff --git a/main/external/debugger-libs b/main/external/debugger-libs
-Subproject 916a1ec85e3559ab0cdb81e4d78a8060747822e
+Subproject 64e5a5e9e297e78304de73c987a0cfd96a3cba2
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompletionTests.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompletionTests.fs
index 0d7a2e576e..108fe7d2f0 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompletionTests.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompletionTests.fs
@@ -69,6 +69,7 @@ type ``Completion Tests``() =
results |> should contain "completeme"
[<TestCase("let x|")>]
+ [<TestCase("let (x|")>]
[<TestCase("let! x|")>]
[<TestCase("let in|")>]
[<TestCase("let x |")>]
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs
index 30c2c130ab..13f289fd9f 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs
@@ -16,6 +16,7 @@ open MonoDevelop.Ide.Projects
open MonoDevelop.Ide.Templates
open MonoDevelop.PackageManagement.Tests.Helpers
open MonoDevelop.Projects
+open MonoDevelop.Projects.MSBuild
open NUnit.Framework
[<TestFixture>]
@@ -72,6 +73,10 @@ type ``Template tests``() =
solutionTemplates
|> Seq.map (fun t -> t.Id)
|> Seq.filter (fun id -> ProjectTemplate.ProjectTemplates |> Seq.exists(fun t -> t.Id = id))
+ // The tutorial project fails because of a bug in msbuild in mono 4.8.0
+ // but fixed in mono 4.9.3. However, it builds just fine from the IDE.
+ // Remove this filter when we get a mono bump
+ |> Seq.filter(fun id -> not (id = "MonoDevelop.FSharp.TutorialProject"))
[<Test>]
member x.``FSharp portable project``() =
@@ -137,7 +142,10 @@ type ``Template tests``() =
do! sln.SaveAsync(monitor) |> Async.AwaitTask
let getErrorsForProject (projects: DotNetProject list) =
asyncSeq {
- let! result = sln.Build(monitor, sln.DefaultConfigurationSelector, null) |> Async.AwaitTask
+ //let context = new Operation
+ let ctx = TargetEvaluationContext ()
+ ctx.LogVerbosity <- MSBuildVerbosity.Diagnostic
+ let! result = sln.Build(monitor, sln.DefaultConfigurationSelector, ctx) |> Async.AwaitTask
match tt, result.HasWarnings, result.HasErrors with
| "Xamarin.tvOS.FSharp.SingleViewApp", _, false //MTOUCH : warning MT0094: Both profiling (--profiling) and incremental builds (--fastdev) is not supported when building for tvOS. Incremental builds have ben disabled.]
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs
index baa902efd0..3f1b0d3db1 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs
@@ -187,7 +187,7 @@ module Completion =
None
let (|LetIdentifier|_|) context =
- if Regex.IsMatch(context.lineToCaret, "\s?(let!?|override|member|for)\s+[^=(]+$", RegexOptions.Compiled) then
+ if Regex.IsMatch(context.lineToCaret, "\s?(let!?|override|member|for)\s+[^=:]+$", RegexOptions.Compiled) then
Some LetIdentifier
else
None
diff --git a/main/external/mono-addins b/main/external/mono-addins
-Subproject 3e4cc1d252a17d7b126a622abd3b2d4c383f4fb
+Subproject 57ac1d89790ed9678c08c9b90b54c843a3880e5
diff --git a/main/external/nuget-binary b/main/external/nuget-binary
-Subproject f0f35435140cb849337caf6ddc1ae50594bdaf0
+Subproject fb441016aa5d878e34da79665c3e677c9fef8a0
diff --git a/main/external/xwt b/main/external/xwt
-Subproject f981e414c3bfee29f5dc508cd099be9b67e0bc9
+Subproject 6948e605e2e620ffb505b3d25b3d8f2dbf2e721
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
index 6320930cff..7e7e39268d 100644
--- a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
+++ b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
@@ -92,11 +92,6 @@
<Name>MonoDevelop.TextTemplating</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\TextTemplating\Mono.TextTemplating\Mono.TextTemplating.csproj">
- <Project>{A2364D6A-00EF-417C-80A6-815726C70032}</Project>
- <Name>Mono.TextTemplating</Name>
- <Private>False</Private>
- </ProjectReference>
<ProjectReference Include="..\Xml\MonoDevelop.Xml.csproj">
<Project>{86DFC74A-B0B6-4C73-9E05-9098DA8FA5F1}</Project>
<Name>MonoDevelop.Xml</Name>
@@ -159,6 +154,10 @@
<HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
+ <Reference Include="Mono.TextTemplating">
+ <HintPath>..\..\..\packages\Mono.TextTemplating.1.3.0\lib\net45\Mono.TextTemplating.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
diff --git a/main/src/addins/AspNet/packages.config b/main/src/addins/AspNet/packages.config
index cdf928d566..6cf090c272 100644
--- a/main/src/addins/AspNet/packages.config
+++ b/main/src/addins/AspNet/packages.config
@@ -1,7 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
+ <package id="Mono.TextTemplating" version="1.3.0" targetFramework="net45" />
</packages>
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.NonUserCodeTestLib/NonUserCodeClass.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.NonUserCodeTestLib/NonUserCodeClass.cs
deleted file mode 100644
index 89c1f30614..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.NonUserCodeTestLib/NonUserCodeClass.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// MyClass.cs
-//
-// Author:
-// David Karlaš <david.karlas@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com)
-//
-// 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.
-using System;
-using System.Threading.Tasks;
-
-namespace MonoDevelop.Debugger.Tests.NonUserCodeTestLib
-{
- public class NonUserCodeClass
- {
- // Trick with NonUserCode is that we are referencing output.dll instead of project
- // in MonoDevelop.Debugger.Tests.TestApp.
-
- //We must delay exception so stacktrace is not getting back to user code(in TestApp)
- public static void ThrowDelayedHandledException ()
- {
- Task.Delay (100).ContinueWith ((obj) => {
- try {
- throw new Exception ("3913936e-3f89-4f07-a863-7275aaaa5fc9");
- } catch {
- }
- });
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/AdvancedEvaluation.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/AdvancedEvaluation.cs
deleted file mode 100644
index cd22e61ecb..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/AdvancedEvaluation.cs
+++ /dev/null
@@ -1,194 +0,0 @@
-//
-// AdvancedEvaluation.cs
-//
-// Author:
-// David Karlaš <david.karlas@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// 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.
-using System;
-using System.Threading.Tasks;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace MonoDevelop.Debugger.Tests.TestApp
-{
- public class AdvancedEvaluation
- {
- public static void RunTest ()
- {
- var obj = new AdvancedEvaluation ();
- obj.Test ();
- }
-
- public static string NextMethodToCall = "";
-
- public void Test ()
- {
- while (true) {
- Console.Write ("");/*break*/
- try {
- typeof(AdvancedEvaluation).GetMethod (NextMethodToCall).Invoke (this, null);
- } catch {
- }
- }
- }
-
- public void YieldMethodTest ()
- {
- YieldMethod ().ToList ();
- }
-
- public IEnumerable<string> YieldMethod ()
- {
- var someVariable = new ArrayList ();
- yield return "1";/*0b1212f8-9035-43dc-bf01-73efd078d680*/
- someField = "das1";
- someVariable.Add (1);
- yield return "2";/*e96b28bb-59bf-445d-b71f-316726ba4c52*/
- someField = "das2";
- someVariable.Add (2);
- yield return "3";/*760feb92-176a-43d7-b5c9-116c4a3c6a6c*/
- yield return "4";/*a9a9aa9d-6b8b-4724-9741-2a3e1fb435e8*/
- }
-
- public void Bug24998Test ()
- {
- Bug24998 ().Wait ();
- }
-
- string someField;
- public async Task Bug24998 ()
- {
- someField = "das";
- var someVariable = new ArrayList ();
- var action = new Action (() => someVariable.Add (1));
- await Task.Delay (100);
- action ();
- someVariable.Add (someField);/*cc622137-a162-4b91-a85c-88241e68c3ea*/
- }
-
-
- public void InvocationsCountDuringExpandingTest ()
- {
- var mutableFieldClass = new MutableFieldClass ();
- Console.WriteLine("InvocationsCountDuringExpandingTest breakpoint");/*8865cace-6b57-42cc-ad55-68a2c12dd3d7*/
- }
-
- class MutableFieldClass
- {
- int sharedX = 0;
-
- public MutableField Prop1
- {
- get { return new MutableField(sharedX++); }
- }
-
- public MutableField Prop2
- {
- get { return new MutableField(sharedX++); }
- }
- }
-
-
- class MutableField
- {
- int x;
-
- public MutableField(int x)
- {
- this.x = x;
- }
- }
-
- public void MethodWithTypeGenericArgsEval ()
- {
- var a = new A("Just A");
- var wrappedA = new Wrapper<A>(new A("wrappedA"));
- var genericClass = new GenericClass<A>(new A("Constructor arg A"));
- //genericClass.BaseMethodWithClassTArg (wrappedA);
- //genericClass.RetMethodWithClassTArg (a)
- Console.WriteLine("Break for MethodWithTypeGenericArgsEval");/*ba6350e5-7149-4cc2-a4cf-8a54c635eb38*/
- }
-
- class A
- {
- public A(string myProp)
- {
- MyProp = myProp;
- }
-
- public string MyProp { get; set; }
-
- public override string ToString()
- {
- return MyProp;
- }
- }
-
- class GenericBaseClass<TBaseClassArg>
- {
- public readonly TBaseClassArg myArg;
-
- public GenericBaseClass(TBaseClassArg arg)
- {
- myArg = arg;
- }
-
- public TBaseClassArg BaseMethodWithClassTArg(TBaseClassArg arg)
- {
- return arg;
- }
-
-
- }
-
- class Wrapper<TObj>
- {
- public TObj obj;
-
- public Wrapper(TObj obj)
- {
- this.obj = obj;
- }
-
- public override string ToString()
- {
- return string.Format("Wrapper({0})", obj);
- }
- }
-
- class GenericClass<TOfClass> : GenericBaseClass<Wrapper<TOfClass>>
- {
- public GenericClass(TOfClass arg) : base(new Wrapper<TOfClass>(arg))
- {
- }
-
- public void VoidMethodWithClassTArg(TOfClass tOfClass) {}
- public TOfClass RetMethodWithClassTArg(TOfClass tOfClass) {return tOfClass;}
-
- public void VoidMethodWithMethodTArg<TOfMethod>(TOfMethod tOfMethod) { }
- public void VoidMethodWithMethodAndClassTArg<TOfMethod>(TOfMethod tOfMethod, TOfClass tOfClass) { }
-
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/AssemblyInfo.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/AssemblyInfo.cs
deleted file mode 100644
index b1adad19b6..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/AssemblyInfo.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// AssemblyInfo.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// 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.
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-// Information about this assembly is defined by the following attributes.
-// Change them to the values specific to your project.
-
-[assembly: AssemblyTitle("MonoDevelop.Debugger.Tests.TestApp")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
-// The form "{Major}.{Minor}.*" will automatically update the build and revision,
-// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-
-[assembly: AssemblyVersion("1.0.0.0")]
-
-// The following attributes are used to specify the signing key for the assembly,
-// if desired. See the Mono documentation for more information about signing.
-
-//[assembly: AssemblyDelaySign(false)]
-//[assembly: AssemblyKeyFile("")]
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/BreakpointsAndStepping.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/BreakpointsAndStepping.cs
deleted file mode 100644
index 03788c701c..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/BreakpointsAndStepping.cs
+++ /dev/null
@@ -1,712 +0,0 @@
-//
-// BreakpointsAndStepping.cs
-//
-// Author:
-// David Karlaš <david.karlas@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
-//
-// 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.
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Net.Sockets;
-using System.Diagnostics;
-using MonoDevelop.Debugger.Tests.NonUserCodeTestLib;
-
-namespace MonoDevelop.Debugger.Tests.TestApp
-{
- public class BreakpointsAndStepping
- {
- public static void RunTest ()
- {
- var obj = new BreakpointsAndStepping ();
- obj.Test ();
- }
-
- public static string NextMethodToCall = "";
-
- public void Test ()
- {
- while (true) {
- Console.Write ("");/*break*/
- try {
- typeof(BreakpointsAndStepping).GetMethod (NextMethodToCall).Invoke (this, null);
- } catch {
- }
- }
- }
-
- public void OutputAndDebugWriter ()
- {
- Console.Write ("NormalText");
- Debug.Write ("DebugText");
- Debug.Write ("");
- System.Diagnostics.Debugger.Log (3, "SomeCategory", "DebugText2");
- Console.Error.Write ("ErrorText");
- Console.Write ("");
- Console.Write ("");/*5070ed1c-593d-4cbe-b4fa-b2b0c7b25289*/
- }
-
- public void OneLineProperty ()
- {
- var testClass = new TestClass ();
- var a = testClass.OneLineProperty;/*8e7787ed-699f-4512-b52a-5a0629a0b9eb*/
- var b = a;/*36c0a44a-44ac-4676-b99b-9a58b73bae9d*/
- }
-
- public void StaticConstructorStepping ()
- {
- var test = new DontUseThisClassInOtherTests ();
- }
-
- public void IfPropertyStepping ()
- {
- var test = new TestClass ();
- if (test.OneLineProperty == "someInvalidValue6049e709-7271-41a1-bc0a-f1f1b80d4125")/*0c64d51c-40b3-4d20-b7e3-4e3e641ec52a*/
- return;
- Console.Write ("");/*ac7625ef-ebbd-4543-b7ff-c9c5d26fd8b4*/
- }
-
- public void SteppingInsidePropertyWhenStepInPropertyDisabled ()
- {
- var testClass = new TestClass ();
- var a = testClass.MultiLineProperty;
- var b = a;
- }
-
- public void CheckIfNull ()
- {
- var testClass = new TestClass ();
- testClass.TestMethod (null);/*d42a19ec-98db-4166-a3b4-fc102ebd7905*/
- testClass.TestMethod ("notNull");/*f633d197-cb92-418a-860c-4d8eadbe2342*/
- Console.Write ("");/*6d50c480-1cd1-49a9-9758-05f65c07c037*/
- }
-
- public void TestOperators ()
- {
- var testClass = new TestClass ();
- var output = testClass == testClass;/*6049ea77-e04a-43ba-907a-5d198727c448*/
- var a = output;/*49737db6-e62b-4c5e-8758-1a9d655be11a*/
- }
-
- public void DebuggerHiddenMethod ()
- {
- var testClass = new TestClass ();
- testClass.DebuggerHiddenMethod (true);/*b0abae8d-fbd0-4bde-b586-bb511b954d8a*/
- testClass.DebuggerHiddenMethod (true, 3);
- testClass.DebuggerHiddenMethod (false);
- }
-
- public void DebuggerNonUserCodeMethod ()
- {
- var testClass = new TestClass ();
- testClass.DebuggerNonUserCodeMethod (true);/*02757896-0e76-40b8-8235-d09d2110da78*/
- testClass.DebuggerNonUserCodeMethod (true, 3);
- testClass.DebuggerNonUserCodeMethod (false);
- }
-
- public void DebuggerStepperBoundaryMethod ()
- {
- var testClass = new TestClass ();
- testClass.DebuggerStepperBoundaryMethod (true);/*0b7eef17-af79-4b34-b4fc-cede110f20fe*/
- var a = testClass;
- var b = testClass;/*806c13f8-8a59-4ae0-83a2-33191368af47*/
- testClass.DebuggerStepperBoundaryMethod (false);/*d105feb1-2cc1-49a5-a01e-f199c29ca7b7*/
- a = testClass;
- b = testClass;/*f86fa865-ed31-4c9f-8280-a54c3f06ee29*/
- }
-
- public void DebuggerStepperBoundaryMethod2 ()
- {
- var a = new TestStepperBoundary ();
- a.Test1 ();/*f3a22b38-596a-4463-a562-20b342fdec12*/
- a.Test3 ();
- a.Test3 ();/*4721f27a-a268-4529-b327-c39f208c08c5*/
- }
-
- [DebuggerNonUserCode]
- class TestStepperBoundary
- {
- public void Test1 ()
- {
- Test2 ();/*d110546f-a622-4ec3-9564-1c51bfec28f9*/
- }
-
- [DebuggerStepperBoundary]
- public void Test2 ()
- {
- Test3 ();
- }
-
- public void Test3 ()
- {
- }
- }
-
- public void DebuggerStepThroughMethod ()
- {
- var testClass = new TestClass ();
- testClass.DebuggerStepThroughMethod (true);/*707ccd6c-3464-4700-8487-a83c948aa0c3*/
- testClass.DebuggerStepThroughMethod (true, 3);
- testClass.DebuggerStepThroughMethod (false);
- }
-
- public void BreakpointInsideDelegate ()
- {
- var action = new Action (delegate {
- int i = 0;/*ffde3c82-4310-43d3-93d1-4c39e9cf615e*/
- });
- action ();/*f3b6862d-732b-4f68-81f5-f362d5a092e2*/
- }
-
- public static void BreakpointInsideOneLineDelegateNoDisplayClass ()
- {
- var button = new Button ();
- button.Clicked += (sender, e) => Console.WriteLine (); /*e72a2fa6-2d95-4f96-b3d0-ba321da3cb55*/
- button.MakeClick ();/*e0a96c37-577f-43e3-9a20-2cdd8bf7824e*/
- }
-
- public void BreakpointInsideOneLineDelegate ()
- {
- var button = new Button ();
- int numClicks = 0;
- button.Clicked += (object sender, EventArgs e) => button.SetTitle (String.Format ("clicked {0} times", numClicks++));/*22af08d6-dafc-47f1-b8d1-bee1526840fd*/
- button.MakeClick ();/*67ae4cce-22b3-49d8-8221-7e5b26a5e79b*/
- }
-
- public void BreakpointInsideOneLineDelegateAsync ()
- {
- var button = new Button ();
- int numClicks = 0;
- button.Clicked += async (sender, e) => button.SetTitle (String.Format ("clicked {0} times", numClicks++));/*b6a65e9e-5db2-4850-969a-b3747b2459af*/
- button.MakeClick ();
- }
-
- public class Button
- {
- public event EventHandler Clicked;
-
- public void MakeClick ()
- {
- Clicked (null, EventArgs.Empty);/*3be64647-76c1-455b-a4a7-a21b37383dcb*/
- }
-
- public void SetTitle (string message)
- {
-
- }
- }
-
- public void ForeachEnumerable ()
- {
- var testClass = new TestClass ();/*b73bec88-2c43-4157-8574-ad517730bc74*/
- foreach (var a in testClass.Iter_1()) {
- /*69dba3ab-0941-47e9-99fa-10222a2e894d*/
- }
- /*e01a5428-b067-4ca3-ac8c-a19d5d800228*/
- }
-
- public void SimpleConstrutor ()
- {
- var obj = new EmptyClassWithConstructor ();/*d62ff7ab-02fa-4205-a432-b4569709eab6*/
- }
-
- public void NoConstructor ()
- {
- var obj = new EmptyClassWithoutConstructor ();/*84fc04b2-ede2-4d8b-acc4-28441e1c5f55*/
- }
-
- static async Task<string> AsyncBug13401 ()
- {
- return "Hello from Bar";
- }
-
- public static async Task Bug13401 ()
- {
- string s = await AsyncBug13401 ();
- Console.Write ("");/*977ee8ce-ee61-4de0-9fc1-138fa164870b*/
- }
-
- public PListScheme PListSchemeTest ()
- {
- string value = "<xml></xml>";
- using (var reader = System.Xml.XmlReader.Create (new StringReader (value)))
- return PListScheme.Load (reader);/*41eb3a30-3b19-4ea5-a7dc-e4c76871f391*/
- }
-
- public class Key
- {
- }
-
- public partial class PListScheme
- {
- public static readonly PListScheme Empty = new PListScheme () { keys = new Key [0] };
-
- IList<Key> keys = new List<Key> ();
-
- public IList<Key> Keys {
- get {
- return keys;
- }
- }
-
- public static PListScheme Load (System.Xml.XmlReader reader)
- {
- /*c9b18785-1348-42e3-a479-9cac1e7c5360*/
- var result = new PListScheme ();
- var doc = new System.Xml.XmlDocument ();
- doc.Load (reader);
- return result;
- }
- }
-
- public void Bug4433Test ()
- {
- Bug4433.Method ();
- }
-
- public class Bug4433
- {
- void Test ()
- {
- return;/*ad9b8803-eef0-438c-bf2b-9156782f4027*/
- }
-
- static Bug4433 Instance { get; set; }
-
- public static void Method ()
- {
- Instance = new Bug4433 ();
- Instance.Test ();/*a062e69c-e3f7-4fd7-8985-fc7abd5c27d2*/
- }
- }
-
- public void EmptyForLoopTest ()
- {
- Thread t = new Thread (new ThreadStart (delegate {
- try {
- EmptyForLoop ();
- } catch {
- }
- }));
- t.Start ();
- Thread.Sleep (1000);//This migth need to be increased
- t.Abort ();
- t.Join ();
- }
-
- private void EmptyForLoop ()
- {
- /*946d5781-a162-4cd9-a7b6-c320564cc594*/
- for (; ;) {
- /*a2ff92da-3796-47e3-886a-4bd786a07547*/
- }
- }
-
- public void ForLoop10 ()
- {
- /*c35046f7-e87d-4b8f-b260-43e181a0a07c*/
- for (int i = 0; i < 10; i++) {
- Console.Write ("");/*eef5bea2-aaa6-4718-b26f-b35be6a6a13e*/
- }
- var a = 0;/*3e2e4759-f6d9-4839-98e6-4fa96b227458*/
- var b = 1;
- var c = a + b;
- Console.Write (c);
- }
-
- public void CallMethodWithPropertyAsArgument ()
- {
- var obj = new TestClass ();
- obj.CallMethodWithPropertyAsArgument ();
- }
-
- public void TestBug7901 ()
- {
- var obj = new TestClass ();
- obj.Bug7901 ();
- }
-
- public void TestBug10782 ()
- {
- DoStuff (new EmptyClassWithConstructor ());/*cdcabe93-4f55-4dbb-821e-912097c4f727*/
- }
-
- private void DoStuff (EmptyClassWithConstructor asdf)
- {
- string bar = asdf.ToString ();/*3bda6643-6d06-4504-a4da-91bc8c5eb887*/
- }
-
- public async void TestAwaitCall ()
- {
- int a = 0;
- await Task.Delay (100);/*a221c9d4-6d00-4fce-99e6-d712e9a23c02*/
- int b = 0;
- }
-
- public async void StepInsideAwaitTaskRun ()
- {
- int a = 0;
- await Task.Run (() => EmptyMethod ());/*a221c9d4-6d00-4fce-99e6-d712e9a23c02*/
- int b = 0;
- }
-
- private void EmptyMethod ()
- {
- /*3c27f60f-fdfa-44c0-b58f-552ecaaa77f1*/
- }
-
- public void ConitionalBreakpointEnum ()
- {
- SomeMethod (BooleanEnum.True);
- SomeMethod (BooleanEnum.False);
- }
-
- private void SomeMethod (BooleanEnum en)
- {
- int i = 0;/*ecf764bf-9182-48d6-adb0-0ba36e2653a7*/
- }
-
- public void ConditionalBreakpointString ()
- {
- SomeMethod ("aaa");
- SomeMethod ("bbb");
- SomeMethod ("ccc");
- }
-
- private void SomeMethod (string str)
- {
- int i = 0;/*033dd01d-6cb4-4e1a-b445-de6d7fa0d2a7*/
- }
-
- public void Catchpoint1 ()
- {
- try {
- throw new NotImplementedException ();/*526795d3-ee9e-44a7-8423-df0b406e9e8d*/
- } catch {
- }
- var a = 0;/*fcdc2412-c00e-4c95-b2ea-e3cf5d5bf856*/
- }
-
- public void Catchpoint2 ()
- {
- try {
- //If you wonder why I didn't use just simple File.Open("unexistingFile.txt") is
- //that FrameStack inside Mono and .Net are different and same goes for 10+ other calls I tried...
- new Socket (AddressFamily.InterNetwork, SocketType.Unknown, ProtocolType.Ggp);/*d24b1c9d-3944-4f0d-be31-5556251fbdf5*/
- } catch {
-
- }
- }
-
- /// <summary>
- /// Bug 9615
- /// </summary>
- public void CatchpointIgnoreExceptionsInNonUserCode ()
- {
- NonUserCodeClass.ThrowDelayedHandledException ();
- Thread.Sleep (200);
- var a = 0;/*999b8a83-8c32-4640-a8e1-f74309cda79c*/
- }
-
- public void SimpleMethod ()
- {
- /*f4e3a214-229e-44dd-9da2-db82ddfbec11*/
- int a = 1;
- int b = 2;
- int c = a + b;
- Console.Write (c);
- }
-
- public void Bug13640 ()
- {
- var l = new List<int> ();/*b64e6497-e976-4125-9741-801909e5eeb1*/
- foreach (var x in l)
- foreach (var y in l) // XS hits this line if it should not
- Console.Write (y);
- return;/*a90ba766-0891-4837-9b1d-e5458f6b8e07*/
- }
-
- class EmptyClassWithConstructor
- {
- /*1f37aea1-77a1-40c1-9ea5-797db48a14f9*/
- public EmptyClassWithConstructor ()
- {
- int i = 0;/*494fddfb-85f1-4ad0-b5b3-9b2f990bb6d0*/
- }
- }
-
- class EmptyClassWithoutConstructor
- {
- }
-
- class DontUseThisClassInOtherTests
- {
- //Or StaticConstructorStepping will fail because
- //static constructor could be invoked in other test
- static DontUseThisClassInOtherTests ()
- {
- int a = 1;/*6c42f31b-ca4f-4963-bca1-7d7c163087f1*/
- int b = 2;/*7e6862cd-bf31-486c-94fe-19933ae46094*/
- }
- }
-
- public class TestClass
- {
- private string oneLineProperty = "";
-
- public string OneLineProperty {
- get{ return oneLineProperty; }/*3722cad3-7da1-4c86-a398-bb2cf6cc65a9*/
- set{ oneLineProperty = value; }
- }
-
- private string multiLineProperty = "";
-
- public string MultiLineProperty {
- get {
- var b = multiLineProperty;/*e0082b9a-26d7-4279-8749-31cd13866abf*/
- return multiLineProperty;/*04f1ce38-121a-4ce7-b4ba-14fb3f6184a2*/
- }
- set {
- multiLineProperty = value;
- }
- }
-
- /// <summary>
- /// This is used only for test so don't use for compering
- /// </summary>
- public static bool operator == (TestClass a, TestClass b)
- {/*5a3eb8d5-88f5-49c0-913f-65018e5a1c5c*/
- return a.oneLineProperty == b.oneLineProperty &&
- a.multiLineProperty == b.multiLineProperty;
- }
-
- /// <summary>
- /// This is used only for test so don't use for compering
- /// </summary>
- public static bool operator != (TestClass a, TestClass b)
- {
- return !(a == b);
- }
-
- public object TestMethod (object obj)
- {/*c5361deb-aff5-468f-9293-0d2e50fc62fd*/
- if (obj == null)/*10e0f5c7-4c77-4897-8324-deef9aae0192*/
- return null;/*40f0acc2-2de2-44c8-8e18-3867151ba8da*/
- return null;/*ae71a41d-0c90-433d-b925-0b236b8119a9*/
- /*3c0316e9-eace-48e8-b9ed-03a8c6306c66*/
- }
-
- public void EmptyTestMethod ()
- {
- /*49326780-f51b-4510-a52c-03e7af442dda*/
- }
-
- [System.Diagnostics.DebuggerHidden]
- public void DebuggerHiddenMethod (bool callEmptyMethod, int resursive = 0)
- {
- if (resursive > 0) {
- Console.Write ("");
- DebuggerHiddenMethod (callEmptyMethod, resursive - 1);
- Console.Write ("");
- }
- Console.Write ("");
- if (callEmptyMethod)
- EmptyTestMethod ();
- Console.Write ("");
- }
-
- [System.Diagnostics.DebuggerNonUserCode]
- public void DebuggerNonUserCodeMethod (bool callEmptyMethod, int resursive = 0)
- {
- /*5b9b96b6-ce24-413f-8660-715fccfc412f*/
- if (resursive > 0) {
- Console.Write ("");
- DebuggerNonUserCodeMethod (callEmptyMethod, resursive - 1);/*6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7*/
- Console.Write ("");
- }
- Console.Write ("");
- if (callEmptyMethod)
- EmptyTestMethod ();/*754272b8-a14b-4de0-9075-6a911c37e6ce*/
- Console.Write ("");
- }
-
- [System.Diagnostics.DebuggerStepperBoundary]
- public void DebuggerStepperBoundaryMethod (bool callEmptyMethod, int resursive = 0)
- {
- if (resursive > 0) {
- Console.Write ("");
- DebuggerStepThroughMethod (callEmptyMethod, resursive - 1);
- Console.Write ("");
- }
- Console.Write ("");
- if (callEmptyMethod)
- EmptyTestMethod ();
- Console.Write ("");
- }
-
- [System.Diagnostics.DebuggerStepThrough]
- public void DebuggerStepThroughMethod (bool callEmptyMethod, int resursive = 0)
- {
- if (resursive > 0) {
- Console.Write ("");
- DebuggerStepThroughMethod (callEmptyMethod, resursive - 1);
- Console.Write ("");
- }
- Console.Write ("");
- if (callEmptyMethod)
- EmptyTestMethod ();
- Console.Write ("");
- }
-
- public IEnumerable<int> Iter_1 ()
- {
- yield return 1;/*1463a77d-f27e-4bcd-8f92-89a682faa1c7*/
- yield return 2;
- }
-
- public void CallMethodWithPropertyAsArgument ()
- {
- ConsoleWriteline ("hello");/*1c3e65ca-3201-42ba-9c6e-6f9a45ddac44*/
- ConsoleWriteline (OneLineProperty);
- }
-
- private void ConsoleWriteline (string arg)
- {
- Console.WriteLine (arg);/*c25be44e-ead3-4891-ab42-0e4cf8450f7a*/
- }
-
- private class ScrollView
- {
- public string VisbleContentRect{ get; set; }
-
- public string ZoomScale{ get; set; }
- }
-
- private ScrollView myScrollView = new ScrollView ();
-
- string curRect;
-
- string curZoom;
-
- bool EventsNeedRefresh {
- get;
- set;
- }
-
- DateTime CurrentDate {
- get;
- set;
- }
-
- DateTime FirstDayOfWeek {
- get;
- set;
- }
-
- public void Bug7901 ()
- {
- SetDayOfWeek (DateTime.UtcNow);/*956bd9fd-39fe-4587-9d9e-a2a817d76286*/
- }
-
- public void SetDayOfWeek (DateTime date)
- {
- /*f456a9b0-9c1a-4b34-bef4-d80b8541ebdb*/
- if (myScrollView != null) {
- curRect = myScrollView.VisbleContentRect;/*11259de1-944d-4052-b970-62662e21876a*/
- curZoom = myScrollView.ZoomScale;
- }
- EventsNeedRefresh = true;/*4863ebb7-8c90-4704-af8b-66a9f53657b9*/
- CurrentDate = date;
- FirstDayOfWeek = date.AddDays (-1 * (int)date.DayOfWeek);
- }
- }
-
- public void TestBug25358 ()
- {
- try {
- throw new Exception ("2b2c4423-accf-4c2c-af31-7d8dcee31c32");
- } catch (IOException e) {
- Console.WriteLine (e);
- } catch (Exception e) {
- Console.WriteLine (e);/*4b30f826-2ba0-4b53-ab36-85b2cdde1069*/
- }
- }
-
- public void TestBug21410 ()
- {
- Bug21410.Test ();
- }
-
- class Bug21410
- {
-
- interface willy
- {
- }
-
- class snarf
- {
- }
-
- class flap : snarf, willy
- {
- }
-
- class point
- {
- public string Acme = "";
- public snarf Lst = new flap ();
- }
-
- class zork
- {
- public point Point = new point ();
- }
-
- class narf
- {
- public zork Zork = new zork ();
- }
-
- static narf _narf = new narf ();
-
- public static void Test ()
- {
- doStuff (_narf.Zork.Point.Acme, _narf.Zork.Point.Acme, (willy)_narf.Zork.Point.Lst, _narf.Zork.Point.Acme, (willy)_narf.Zork.Point.Lst);/*5e6663d0-9088-40ad-914d-0fcc05b2d0d5*/
- doStuff (_narf.Zork.Point.Acme, _narf.Zork.Point.Acme, (willy)_narf.Zork.Point.Lst, _narf.Zork.Point.Acme, (willy)_narf.Zork.Point.Lst);
- }
-
- static void doStuff (string str, string str2, willy lst, string str3,
- willy lst2)
- {
- }
- }
- }
-}
-
-public enum BooleanEnum
-{
- False,
- True
-}
-/*invalidBreakpointAtEndOfFile*/ \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/Main.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/Main.cs
deleted file mode 100644
index 6ebb0c56e5..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/Main.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Main.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace MonoDevelop.Debugger.Tests.TestApp
-{
- class MainClass
- {
- public static void Main (string[] args)
- {
- var test = Activator.CreateInstance (Type.GetType ("MonoDevelop.Debugger.Tests.TestApp." + args [0]));
- test.GetType().GetMethod ("RunTest").Invoke (null, null);
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/MonoDevelop.Debugger.Tests.TestApp.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/MonoDevelop.Debugger.Tests.TestApp.csproj
deleted file mode 100644
index 811da424a7..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/MonoDevelop.Debugger.Tests.TestApp.csproj
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{05EDFE55-C8D1-47E4-BB61-0BC809CD82E2}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <RootNamespace>MonoDevelop.Debugger.Tests.TestApp</RootNamespace>
- <AssemblyName>MonoDevelop.Debugger.Tests.TestApp</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <DebugSymbols>True</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>False</Optimize>
- <OutputPath>..\..\..\..\build\tests</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- <NoWarn>1591;1573</NoWarn>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\..\build\tests</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- <NoWarn>1591;1573</NoWarn>
- <DebugSymbols>true</DebugSymbols>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Xml" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="MonoDevelop.Debugger.Tests.NonUserCodeTestLib">
- <HintPath>..\MonoDevelop.Debugger.Tests.NonUserCodeTestLib\bin\Debug\MonoDevelop.Debugger.Tests.NonUserCodeTestLib.dll</HintPath>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Main.cs" />
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="TestEvaluation.cs" />
- <Compile Include="BreakpointsAndStepping.cs" />
- <Compile Include="AdvancedEvaluation.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <ProjectReference Include="..\MonoDevelop.Debugger.Tests.NonUserCodeTestLib\MonoDevelop.Debugger.Tests.NonUserCodeTestLib.csproj">
- <Project>{8AFA4FB4-BD2D-478F-942B-7AE3451535BB}</Project>
- <Name>MonoDevelop.Debugger.Tests.NonUserCodeTestLib</Name>
- <Private>False</Private>
- </ProjectReference>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/TestEvaluation.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/TestEvaluation.cs
deleted file mode 100644
index d227d6dc48..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.TestApp/TestEvaluation.cs
+++ /dev/null
@@ -1,784 +0,0 @@
-//
-// TestEvaluation.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-// David Karlaš <david.karlas@xamarin.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
-//
-// 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.
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Dynamic;
-using System.Threading.Tasks;
-
-namespace MonoDevelop.Debugger.Tests.TestApp
-{
- interface IFoo
- {
- int this[int index] { get; }
- int Prop { get; }
- }
- interface IBar
- {
- int this[int index] { get; }
- int Prop { get; }
- }
- class Bo
- {
- public int Prop { get { return 4; } }
- }
- class FooBar : Bo, IFoo, IBar
- {
- int IBar.Prop { get { return 1; } }
- int IFoo.Prop { get { return 2; } }
- public int Prop { get { return 3; } }
-
- int IFoo.this[int index]
- {
- get
- {
- return index;
- }
- }
-
- int IBar.this[int index]
- {
- get
- {
- return -index;
- }
- }
- }
-
- class TestEvaluationParent
- {
- public int TestMethodBase ()
- {
- float c = 4;
- return 2;
- }
-
- protected string ProtectedStringProperty{ get; set; }
-
- public virtual int TestMethodBase (string a)
- {
- return int.Parse (a) + 2;
- }
-
- protected int TestMethodBase (int a)
- {
- return a + 1;
- }
-
- public int TestMethodBaseNotOverrided ()
- {
- float c = 4;
- return 1;
- }
-
- public class ParentNestedClass
- {
-
- }
- }
-
- class TestEvaluationChild : TestEvaluation
- {
- public int HiddenField = 6;
- public int HiddenProperty {
- get {
- return 6;
- }
- }
- public int HiddenMethod ()
- {
- return 6;
- }
-
- public override int OverridenMethodInt ()
- {
- return 6;
- }
-
- public override int OverridenPropertyInt {
- get {
- return 6;
- }
- }
-
- public override string OverridenMethodString ()
- {
- return "6";
- }
-
- public override string OverridenPropertyString {
- get {
- return "6";
- }
- }
- }
-
- class TestEvaluation : TestEvaluationParent
- {
- static string staticString = "some static";
- string someString = "hi";
- string[] numbers = { "one", "two", "three" };
-
- public static void RunTest ()
- {
- var obj = new TestEvaluationChild ();
- obj.Test ("testString", 55);
- }
-
- public void Test (string stringParam, int intParam = 22, int intParam2 = 66)
- {
- int intZero = 0, intOne = 1;
- int n = 32;
- decimal dec = 123.456m;
- var stringList = new List<string> ();
- stringList.Add ("aaa");
- stringList.Add ("bbb");
- stringList.Add ("ccc");
-
- var alist = new ArrayList ();
- alist.Add (1);
- alist.Add ("two");
- alist.Add (3);
- string modifyInLamda = "";
-
- var debugDisplayMethodTest = new DebuggerDisplayMethodTest ();
-
- A c = new C ();
- A b = new B ();
- A a = new A ();
-
- var withDisplayString = new WithDisplayString ();
- var withProxy = new WithProxy ();
- var withToString = new WithToString ();
-
- var numbersArrays = new int [2][];
- numbersArrays [0] = new int [10];
- numbersArrays [0] [7] = 24;
- var numbersMulti = new int [3, 4, 5];
-
- var ops1 = new BinaryOperatorOverrides (1);
- var ops2 = new BinaryOperatorOverrides (2);
- var ops3 = new BinaryOperatorOverrides (2);
-
- var dict = new Dictionary<int, string[]> ();
- dict.Add (5, new string[]{ "a", "b" });
- var dictArray = new Dictionary<int, string[]> [2, 3];
- var thing = new Thing<string> ();
- var done = new Thing<string>.Done<int> ();
- done.Property = 54;
-
- SimpleStruct simpleStruct = new SimpleStruct ();
- simpleStruct.IntField = 45;
- simpleStruct.StringField = "str";
- SimpleStruct? nulledSimpleStruct;
- var action = new Action (() => {
- modifyInLamda = "modified";
- });
- action ();
-
- dynamic dynObj = new ExpandoObject ();
- dynObj.someInt = 53;
- dynObj.someString = "Hello dynamic objects!";
-
- var objWithMethodA = new ClassWithMethodA ();
-
- bool? nullableBool = null;
- nullableBool = true;
-
- var richObject = new RichClass ();
- byte[] nulledByteArray = null;
-
- var arrayWithLowerBounds = Array.CreateInstance (typeof(int), new int[] { 3, 4, 5 }, new int[] { 5, 4, 3 });
- int m = 100;
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 4; j++) {
- for (int k = 0; k < 5; k++) {
- numbersMulti.SetValue (m, i, j, k);
- arrayWithLowerBounds.SetValue (m++, i + 5, j + 4, k + 3);
- }
- }
- }
-
- FooBar = new FooBar ();
- Foo = new FooBar ();
- Bar = new FooBar ();
-
- var testEvaluationChild = new TestEvaluationChild ();
-
- Console.WriteLine (n); /*break*/
- }
-
- public FooBar FooBar { get; set; }
- public IBar Bar { get; set; }
- public IFoo Foo { get; set; }
-
- public string TestCastingArgument (myNint nint)
- {
- return nint.v.ToString ();
- }
-
- public int TestMethod ()
- {
- float c = 4;
- return 1;
- }
-
- public int TestMethod (string a)
- {
- return int.Parse (a) + 1;
- }
-
- public int TestMethod (int a)
- {
- return a + 1;
- }
-
- public int TestMethodBase ()
- {
- float c = 4;
- return 1;
- }
-
- public override int TestMethodBase (string a)
- {
- return int.Parse (a) + 1;
- }
-
- protected new int TestMethodBase (int a)
- {
- return a + 1;
- }
-
- public static int TestMethod (bool b)
- {
- return b ? 1 : 2;
- }
-
- public T ReturnSame<T> (T t)
- {
- return t;
- }
-
- public T ReturnNew<T> () where T:new()
- {
- return new T ();
- }
-
- public string BoxingTestMethod (object a)
- {
- return a.ToString ();
- }
-
- public string EscapedStrings {
- get { return " \" \\ \a \b \f \v \n \r \t"; }
- }
-
- public static void Swap<T> (ref T a, ref T b)
- {
- T temp = a;
- a = b;
- b = temp;
- }
-
- public static List<T> GenerateList<T> (T value, int count)
- {
- var list = new List<T> ();
- for (int i = 0; i < count; i++) {
- list.Add (value);
- }
- return list;
- }
-
- class NestedClass
- {
- public class DoubleNestedClass
- {
-
- }
- }
-
- class NestedGenericClass<T1,T2>
- {
-
- }
-
- public int HiddenField = 5;
- public virtual int HiddenProperty {
- get {
- return 5;
- }
- }
- public virtual int HiddenMethod ()
- {
- return 5;
- }
-
- public virtual int OverridenMethodInt ()
- {
- return 5;
- }
-
- public virtual int OverridenPropertyInt {
- get {
- return 5;
- }
- }
-
- public virtual string OverridenMethodString ()
- {
- return "5";
- }
-
- public virtual string OverridenPropertyString {
- get {
- return "5";
- }
- }
- }
-
- public class SomeClassInNamespace
- {
-
- }
-}
-
-class RichClass
-{
- public int publicInt1 = 1;
- public int publicInt2 = 2;
- public int publicInt3 = 3;
-
- public string publicStringA = "stringA";
- public string publicStringB = "stringB";
- public string publicStringC = "stringC";
-
- private int privateInt1 = 1;
- private int privateInt2 = 2;
- private int privateInt3 = 3;
-
- private string privateStringA = "stringA";
- private string privateStringB = "stringB";
- private string privateStringC = "stringC";
-
- public int publicPropInt1 { get; set; }
-
- public int publicPropInt2 { get; set; }
-
- public int publicPropInt3 { get; set; }
-
- public string publicPropStringA { get; set; }
-
- public string publicPropStringB { get; set; }
-
- public string publicPropStringC { get; set; }
-
- private int privatePropInt1 { get; set; }
-
- private int privatePropInt2 { get; set; }
-
- private int privatePropInt3 { get; set; }
-
- private string privatePropStringA { get; set; }
-
- private string privatePropStringB { get; set; }
-
- private string privatePropStringC { get; set; }
-
- public RichClass ()
- {
- publicPropInt1 = 1;
- publicPropInt2 = 2;
- publicPropInt3 = 3;
-
- publicPropStringA = "stringA";
- publicPropStringB = "stringB";
- publicPropStringC = "stringC";
-
- privatePropInt1 = 1;
- privatePropInt2 = 2;
- privatePropInt3 = 3;
-
- privatePropStringA = "stringA";
- privatePropStringB = "stringB";
- privatePropStringC = "stringC";
- }
-
- public RichClass (myNint i)
- {
- publicPropInt1 = i;
- }
-}
-
-interface IInterfaceWithMethodA
-{
- string MethodA ();
-}
-
-abstract class AbstractClassWithMethodA
-{
- public abstract string MethodA ();
-}
-
-class ClassWithMethodA : AbstractClassWithMethodA, IInterfaceWithMethodA
-{
- public override string MethodA ()
- {
- return "AbstractImplementation";
- }
-
- string IInterfaceWithMethodA.MethodA ()
- {
- return "InterfaceImplementation";
- }
-}
-
-class A
-{
- public string ConstructedBy { get; private set; }
-
- public A ()
- {
- ConstructedBy = "NoArg";
- }
-
- public A (int i)
- {
- ConstructedBy = "IntArg";
- }
-
- public A (string str)
- {
- ConstructedBy = "StringArg";
- }
-
- public virtual int Prop { get { return 1; } }
-
- public int PropNoVirt1 { get { return 1; } }
-
- public virtual int PropNoVirt2 { get { return 1; } }
-
- public int IntField = 1;
-
- public int TestMethod ()
- {
- float c = 4;
- return 1;
- }
-
- public virtual int TestMethod (string a)
- {
- return int.Parse (a) + 1;
- }
-
- public int TestMethod (int a)
- {
- return a + 1;
- }
-}
-
-class B: A
-{
- public override int Prop { get { return 2; } }
-
- public new int PropNoVirt1 { get { return 2; } }
-
- public new int PropNoVirt2 { get { return 2; } }
-
- public new int IntField = 2;
-
- public int TestMethod ()
- {
- float c = 4;
- return 2;
- }
-
- public override int TestMethod (string a)
- {
- return int.Parse (a) + 2;
- }
-
- public new int TestMethod (int a)
- {
- return a + 2;
- }
-}
-
-class C: B
-{
-
-}
-
-[DebuggerDisplay ("Some {Val1} Value {Val2} End")]
-class WithDisplayString
-{
- internal string Val1 = "one";
-
- public int Val2 { get { return 2; } }
-}
-
-class WithToString
-{
- public override string ToString ()
- {
- return "SomeString";
- }
-}
-
-[DebuggerTypeProxy (typeof(TheProxy))]
-class WithProxy
-{
- public string Val1 {
- get { return "one"; }
- }
-}
-
-class TheProxy
-{
- WithProxy wp;
-
- public TheProxy (WithProxy wp)
- {
- this.wp = wp;
- }
-
- public string Val1 {
- get { return wp.Val1; }
- }
-}
-
-[DebuggerDisplay ("{GetDebuggerDisplay(), nq}")]
-class DebuggerDisplayMethodTest
-{
- int someInt = 32;
- int someInt2 = 43;
-
- string GetDebuggerDisplay ()
- {
- return "First Int:" + someInt + " Second Int:" + someInt2;
- }
-}
-
-class Thing<T>
-{
- public class Done<U>
- {
- private U property;
-
- public U Property {
- get {
- return property;
- }
- set {
- property = value;
- }
- }
-
-
- public int ReturnInt5 ()
- {
- return 5;
- }
-
- public U ReturnSame (U obj)
- {
- return obj;
- }
-
- public T ReturnSame (T obj)
- {
- return obj;
- }
-
- public U GetDefault ()
- {
- return default(U);
- }
-
- public T GetParentDefault ()
- {
- return default(T);
- }
- }
-
- public Done<int>[] done = new Done<int> [1];
-}
-
-[Flags]
-enum SomeEnum
-{
- none = 0,
- one = 1,
- two = 2,
- four = 4
-}
-
-struct SimpleStruct
-{
- public int IntField;
- public string StringField;
- public int? NulledIntField;
-
- public override string ToString ()
- {
- return StringField + " " + IntField + " " + NulledIntField;
- }
-}
-
-class ClassWithCompilerGeneratedNestedClass
-{
- async Task TestMethodAsync()
- {
- await Task.Delay (1);
- }
-
- public class NestedClass
- {
-
- }
-}
-
-struct myNint
-{
- public long v;
-
- public static implicit operator myNint (int v)
- {
- return new myNint (v);
- }
-
- public static implicit operator int (myNint v)
- {
- return (int)v.v;
- }
-
- public override string ToString ()
- {
- return v.ToString ();
- }
-
- myNint (int v)
- {
- this.v = v;
- }
-}
-
-class BinaryOperatorOverrides
-{
- int value;
-
- public BinaryOperatorOverrides (int num)
- {
- value = num;
- }
-
- public override string ToString ()
- {
- return string.Format ("[BinaryOperatorOverrides {0}]", value);
- }
-
- public static bool operator== (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return ops1.value == ops2.value;
- }
-
- public static bool operator!= (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return ops1.value != ops2.value;
- }
-
- public static bool operator>= (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return ops1.value >= ops2.value;
- }
-
- public static bool operator> (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return ops1.value > ops2.value;
- }
-
- public static bool operator<= (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return ops1.value <= ops2.value;
- }
-
- public static bool operator< (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return ops1.value < ops2.value;
- }
-
- public static BinaryOperatorOverrides operator+ (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return new BinaryOperatorOverrides (ops1.value + ops2.value);
- }
-
- public static BinaryOperatorOverrides operator- (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return new BinaryOperatorOverrides (ops1.value - ops2.value);
- }
-
- public static BinaryOperatorOverrides operator* (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return new BinaryOperatorOverrides (ops1.value * ops2.value);
- }
-
- public static BinaryOperatorOverrides operator/ (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return new BinaryOperatorOverrides (ops1.value / ops2.value);
- }
-
- public static BinaryOperatorOverrides operator% (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return new BinaryOperatorOverrides (ops1.value % ops2.value);
- }
-
- public static BinaryOperatorOverrides operator& (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return new BinaryOperatorOverrides (ops1.value & ops2.value);
- }
-
- public static BinaryOperatorOverrides operator| (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return new BinaryOperatorOverrides (ops1.value | ops2.value);
- }
-
- public static BinaryOperatorOverrides operator^ (BinaryOperatorOverrides ops1, BinaryOperatorOverrides ops2)
- {
- return new BinaryOperatorOverrides (ops1.value ^ ops2.value);
- }
-
- public static BinaryOperatorOverrides operator<< (BinaryOperatorOverrides ops1, int shift)
- {
- return new BinaryOperatorOverrides (ops1.value << shift);
- }
-
- public static BinaryOperatorOverrides operator>> (BinaryOperatorOverrides ops1, int shift)
- {
- return new BinaryOperatorOverrides (ops1.value >> shift);
- }
-} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/AdvancedEvaluationTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/AdvancedEvaluationTests.cs
deleted file mode 100644
index 8266af66c9..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/AdvancedEvaluationTests.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-//
-// AdvancedEvaluationTests.cs
-//
-// Author:
-// David Karlaš <david.karlas@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// 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.
-using System;
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests
-{
- namespace Soft
- {
- [TestFixture]
- public class SdbAdvancedEvaluationAllowTargetInvokesTests : AdvancedEvaluationTests
- {
- public SdbAdvancedEvaluationAllowTargetInvokesTests () : base ("Mono.Debugger.Soft", true)
- {
- }
- }
-
- [TestFixture]
- public class SdbAdvancedEvaluationNoTargetInvokesTests : AdvancedEvaluationTests
- {
- public SdbAdvancedEvaluationNoTargetInvokesTests () : base ("Mono.Debugger.Soft", false)
- {
- }
- }
- }
-
- namespace Win32
- {
- [TestFixture]
- [Platform(Include = "Win")]
- public class CorAdvancedEvaluationAllowTargetInvokesTests : AdvancedEvaluationTests
- {
- public CorAdvancedEvaluationAllowTargetInvokesTests () : base ("MonoDevelop.Debugger.Win32", true)
- {
- }
- }
-
- [TestFixture]
- [Platform(Include = "Win")]
- public class CorAdvancedEvaluationNoTargetInvokesTests : AdvancedEvaluationTests
- {
- public CorAdvancedEvaluationNoTargetInvokesTests () : base ("MonoDevelop.Debugger.Win32", false)
- {
- }
- }
- }
-
- [TestFixture]
- public abstract class AdvancedEvaluationTests : DebugTests
- {
- protected AdvancedEvaluationTests (string de, bool allowTargetInvokes) : base (de)
- {
- AllowTargetInvokes = allowTargetInvokes;
- }
-
- [TestFixtureSetUp]
- public override void SetUp ()
- {
- base.SetUp ();
- Start ("AdvancedEvaluation");
- }
-
- [Test]
- public void Bug24998 ()
- {
- InitializeTest ();
- AddBreakpoint ("cc622137-a162-4b91-a85c-88241e68c3ea");
- StartTest ("Bug24998Test");
- CheckPosition ("cc622137-a162-4b91-a85c-88241e68c3ea");
- var val = Eval ("someField");
- Assert.AreEqual ("\"das\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("someVariable");
- Assert.AreEqual ("System.Collections.ArrayList", val.TypeName);
- var children = val.GetAllChildrenSync ();
- Assert.AreEqual (2, children.Length);
- Assert.AreEqual ("[0]", children [0].ChildSelector);
- Assert.AreEqual ("1", children [0].Value);
- Assert.AreEqual ("int", children [0].TypeName);
-
- val = Eval ("action");
- Assert.AreEqual ("System.Action", val.TypeName);
- }
-
-
- [Test]
- public void YieldMethodTest ()
- {
- InitializeTest ();
- AddBreakpoint ("0b1212f8-9035-43dc-bf01-73efd078d680");
- StartTest ("YieldMethodTest");
- CheckPosition ("0b1212f8-9035-43dc-bf01-73efd078d680");
-
- var val = Eval ("someVariable");
- Assert.AreEqual ("System.Collections.ArrayList", val.TypeName);
- Assert.AreEqual (1, val.GetAllChildrenSync ().Length);
-
- AddBreakpoint ("e96b28bb-59bf-445d-b71f-316726ba4c52");
- Continue ("e96b28bb-59bf-445d-b71f-316726ba4c52");
-
- val = Eval ("someField");
- Assert.AreEqual ("\"das1\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
- val = Eval ("someVariable");
- Assert.AreEqual ("System.Collections.ArrayList", val.TypeName);
- Assert.AreEqual (2, val.GetAllChildrenSync ().Length);
-
- AddBreakpoint ("760feb92-176a-43d7-b5c9-116c4a3c6a6c");
- Continue ("760feb92-176a-43d7-b5c9-116c4a3c6a6c");
-
- val = Eval ("someField");
- Assert.AreEqual ("\"das2\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
- val = Eval ("someVariable");
- Assert.AreEqual ("System.Collections.ArrayList", val.TypeName);
- Assert.AreEqual (3, val.GetAllChildrenSync ().Length);
-
- AddBreakpoint ("a9a9aa9d-6b8b-4724-9741-2a3e1fb435e8");
- Continue ("a9a9aa9d-6b8b-4724-9741-2a3e1fb435e8");
-
- val = Eval ("someField");
- Assert.AreEqual ("\"das2\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
- val = Eval ("someVariable");
- Assert.AreEqual ("System.Collections.ArrayList", val.TypeName);
- Assert.AreEqual (3, val.GetAllChildrenSync ().Length);
-
- }
-
- [Test]
- public void InvocationsCountDuringExpandingTest ()
- {
- InitializeTest ();
- AddBreakpoint ("8865cace-6b57-42cc-ad55-68a2c12dd3d7");
- StartTest ("InvocationsCountDuringExpandingTest");
- CheckPosition ("8865cace-6b57-42cc-ad55-68a2c12dd3d7");
- var options = Session.EvaluationOptions.Clone ();
- options.GroupPrivateMembers = false; // to access private fields (else there are in Private subgroup)
- var value = Eval ("mutableFieldClass");
- var sharedX = value.GetChildSync ("sharedX", options);
- Assert.NotNull (sharedX);
-
- var prop1 = value.GetChildSync("Prop1", options);
- Assert.NotNull (prop1);
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.AdvancedEvaluation.MutableField", prop1.TypeName);
- var prop1X = prop1.GetChildSync ("x", options);
- Assert.NotNull (prop1X);
- Assert.AreEqual ("0", prop1X.Value); // before CorValRef optimization this field evaluated to 2,
- // because every value to the root object was recalculated - this was wrong behavior
-
- var prop2 = value.GetChildSync ("Prop2", options);
- Assert.NotNull (prop2);
- var prop2X = prop2.GetChildSync("x", options);
- Assert.NotNull (prop2X);
- Assert.AreEqual ("1", prop2X.Value);
-
- Assert.AreEqual ("2", sharedX.Value);
- }
-
- [Test]
- public void MethodWithTypeGenericArgsEval ()
- {
- InitializeTest ();
- AddBreakpoint ("ba6350e5-7149-4cc2-a4cf-8a54c635eb38");
- StartTest ("MethodWithTypeGenericArgsEval");
- CheckPosition ("ba6350e5-7149-4cc2-a4cf-8a54c635eb38");
-
- var baseMethodEval = Eval ("genericClass.BaseMethodWithClassTArg (wrappedA)");
- Assert.NotNull (baseMethodEval);
- Assert.AreEqual ("{Wrapper(wrappedA)}", baseMethodEval.Value);
-
- var thisMethodEval = Eval ("genericClass.RetMethodWithClassTArg (a)");
- Assert.NotNull (thisMethodEval);
- Assert.AreEqual ("{Just A}", thisMethodEval.Value);
- }
-
-
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/BreakpointsAndSteppingTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/BreakpointsAndSteppingTests.cs
deleted file mode 100644
index a1d16e178a..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/BreakpointsAndSteppingTests.cs
+++ /dev/null
@@ -1,1157 +0,0 @@
-//
-// BreakpointsAndSteppingTests.cs
-//
-// Author:
-// David Karlaš <david.karlas@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
-//
-// 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.
-using System;
-using NUnit.Framework;
-using Mono.Debugging.Client;
-using System.Collections.Generic;
-using Mono.Debugging.Soft;
-
-namespace MonoDevelop.Debugger.Tests
-{
- [TestFixture]
- public abstract class BreakpointsAndSteppingTests:DebugTests
- {
- protected BreakpointsAndSteppingTests (string de)
- : base (de)
- {
- }
-
- [TestFixtureSetUp]
- public override void SetUp ()
- {
- base.SetUp ();
- Start ("BreakpointsAndStepping");
- }
-
- [Test]
- public void OneLineProperty ()
- {
- InitializeTest ();
- AddBreakpoint ("8e7787ed-699f-4512-b52a-5a0629a0b9eb");
- StartTest ("OneLineProperty");
- CheckPosition ("8e7787ed-699f-4512-b52a-5a0629a0b9eb");
- StepIn ("3722cad3-7da1-4c86-a398-bb2cf6cc65a9", "{");
- StepIn ("3722cad3-7da1-4c86-a398-bb2cf6cc65a9", "return");
- StepIn ("3722cad3-7da1-4c86-a398-bb2cf6cc65a9", "}");
- StepIn ("8e7787ed-699f-4512-b52a-5a0629a0b9eb");
- StepIn ("36c0a44a-44ac-4676-b99b-9a58b73bae9d");
- }
-
- /// <summary>
- /// Bug 775
- /// </summary>
- [Test]
- public void StepOverPropertiesAndOperatorsSetting ()
- {
- InitializeTest ();
- //This is default but lets set again for code readability
- Session.Options.StepOverPropertiesAndOperators = false;
- AddBreakpoint ("8e7787ed-699f-4512-b52a-5a0629a0b9eb");
- StartTest ("OneLineProperty");
- CheckPosition ("8e7787ed-699f-4512-b52a-5a0629a0b9eb");
- StepIn ("3722cad3-7da1-4c86-a398-bb2cf6cc65a9");
-
-
- InitializeTest ();
- Session.Options.StepOverPropertiesAndOperators = true;
- AddBreakpoint ("8e7787ed-699f-4512-b52a-5a0629a0b9eb");
- StartTest ("OneLineProperty");
- CheckPosition ("8e7787ed-699f-4512-b52a-5a0629a0b9eb");
- StepIn ("36c0a44a-44ac-4676-b99b-9a58b73bae9d");
-
-
- InitializeTest ();
- //This is default but lets set again for code readability
- Session.Options.StepOverPropertiesAndOperators = false;
- AddBreakpoint ("6049ea77-e04a-43ba-907a-5d198727c448");
- StartTest ("TestOperators");
- CheckPosition ("6049ea77-e04a-43ba-907a-5d198727c448");
- StepIn ("5a3eb8d5-88f5-49c0-913f-65018e5a1c5c");
-
-
- InitializeTest ();
- Session.Options.StepOverPropertiesAndOperators = true;
- AddBreakpoint ("6049ea77-e04a-43ba-907a-5d198727c448");
- StartTest ("TestOperators");
- CheckPosition ("6049ea77-e04a-43ba-907a-5d198727c448");
- StepIn ("49737db6-e62b-4c5e-8758-1a9d655be11a");
- }
-
- [Test]
- public void StaticConstructorStepping ()
- {
- InitializeTest ();
- AddBreakpoint ("6c42f31b-ca4f-4963-bca1-7d7c163087f1");
- StartTest ("StaticConstructorStepping");
- CheckPosition ("6c42f31b-ca4f-4963-bca1-7d7c163087f1");
- StepOver ("7e6862cd-bf31-486c-94fe-19933ae46094");
- }
-
- [Test]
- public void SteppingInsidePropertyWhenStepInPropertyDisabled ()
- {
- InitializeTest ();
- Session.Options.StepOverPropertiesAndOperators = true;
- AddBreakpoint ("e0082b9a-26d7-4279-8749-31cd13866abf");
- StartTest ("SteppingInsidePropertyWhenStepInPropertyDisabled");
- CheckPosition ("e0082b9a-26d7-4279-8749-31cd13866abf");
- StepIn ("04f1ce38-121a-4ce7-b4ba-14fb3f6184a2");
- }
-
- [Test]
- public void CheckIfNull ()
- {
- InitializeTest ();
- AddBreakpoint ("d42a19ec-98db-4166-a3b4-fc102ebd7905");
- StartTest ("CheckIfNull");
- CheckPosition ("d42a19ec-98db-4166-a3b4-fc102ebd7905");
- StepIn ("c5361deb-aff5-468f-9293-0d2e50fc62fd");
- StepIn ("10e0f5c7-4c77-4897-8324-deef9aae0192");
- StepIn ("40f0acc2-2de2-44c8-8e18-3867151ba8da");
- StepIn ("3c0316e9-eace-48e8-b9ed-03a8c6306c66", 1);
- StepIn ("d42a19ec-98db-4166-a3b4-fc102ebd7905");
- StepIn ("f633d197-cb92-418a-860c-4d8eadbe2342");
- StepIn ("c5361deb-aff5-468f-9293-0d2e50fc62fd");
- StepIn ("10e0f5c7-4c77-4897-8324-deef9aae0192");
- StepIn ("ae71a41d-0c90-433d-b925-0b236b8119a9");
- StepIn ("3c0316e9-eace-48e8-b9ed-03a8c6306c66", 1);
- StepIn ("f633d197-cb92-418a-860c-4d8eadbe2342");
- StepIn ("6d50c480-1cd1-49a9-9758-05f65c07c037");
- }
-
- /// <summary>
- /// Bug 4015
- /// </summary>
- [Test]
- public void SimpleConstrutor ()
- {
- InitializeTest ();
- AddBreakpoint ("d62ff7ab-02fa-4205-a432-b4569709eab6");
- StartTest ("SimpleConstrutor");
- CheckPosition ("d62ff7ab-02fa-4205-a432-b4569709eab6");
- StepIn ("1f37aea1-77a1-40c1-9ea5-797db48a14f9", 1, "public");
- StepIn ("494fddfb-85f1-4ad0-b5b3-9b2f990bb6d0", -1, "{");
- StepIn ("494fddfb-85f1-4ad0-b5b3-9b2f990bb6d0", "int");
- StepIn ("494fddfb-85f1-4ad0-b5b3-9b2f990bb6d0", 1, "}");
- StepIn ("d62ff7ab-02fa-4205-a432-b4569709eab6", "var");
- StepIn ("d62ff7ab-02fa-4205-a432-b4569709eab6", 1, "}");
- }
-
- /// <summary>
- /// Bug 3262
- /// </summary>
- [Test]
- public void NoConstructor ()
- {
- InitializeTest ();
- Session.Options.ProjectAssembliesOnly = true;
- AddBreakpoint ("84fc04b2-ede2-4d8b-acc4-28441e1c5f55");
- StartTest ("NoConstructor");
- CheckPosition ("84fc04b2-ede2-4d8b-acc4-28441e1c5f55");
- StepIn ("84fc04b2-ede2-4d8b-acc4-28441e1c5f55", 1);
- }
-
- [Test]
- public void IfPropertyStepping ()
- {
- InitializeTest ();
- Session.Options.StepOverPropertiesAndOperators = true;
- AddBreakpoint ("0c64d51c-40b3-4d20-b7e3-4e3e641ec52a");
- StartTest ("IfPropertyStepping");
- CheckPosition ("0c64d51c-40b3-4d20-b7e3-4e3e641ec52a");
- StepIn ("ac7625ef-ebbd-4543-b7ff-c9c5d26fd8b4");
- }
-
- /// <summary>
- /// Bug 3565
- /// </summary>
- [Test]
- public void DebuggerHiddenMethod ()
- {
- InitializeTest ();
- AddBreakpoint ("b0abae8d-fbd0-4bde-b586-bb511b954d8a");
- StartTest ("DebuggerHiddenMethod");
- CheckPosition ("b0abae8d-fbd0-4bde-b586-bb511b954d8a");
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("b0abae8d-fbd0-4bde-b586-bb511b954d8a");
- StepIn ("b0abae8d-fbd0-4bde-b586-bb511b954d8a", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (3).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (4).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (5).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (3).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (4).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (3).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("b0abae8d-fbd0-4bde-b586-bb511b954d8a", 1);
- StepIn ("b0abae8d-fbd0-4bde-b586-bb511b954d8a", 2);
- StepIn ("b0abae8d-fbd0-4bde-b586-bb511b954d8a", 3);
- }
-
- /// <summary>
- /// Bug 3565
- /// </summary>
- [Test]
- public void DebuggerNonUserCodeMethod ()
- {
- InitializeTest ();
- Session.Options.ProjectAssembliesOnly = false;
- AddBreakpoint ("02757896-0e76-40b8-8235-d09d2110da78");
- StartTest ("DebuggerNonUserCodeMethod");
- CheckPosition ("02757896-0e76-40b8-8235-d09d2110da78");
- //entering testClass.DebuggerNonUserCodeMethod (true);
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", -1);
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -2);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- //entering EmptyTestMethod
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- //exited EmptyTestMethod
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 2);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78");
- //exited testClass.DebuggerNonUserCodeMethod (true);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 1);
- //entering testClass.DebuggerNonUserCodeMethod (true, 3); starts here
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", -1);
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", 1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", -2);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", -1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7");
- //entering resursion
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", -1);
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", 1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", -2);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", -1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7");
- //entering resursion
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", -1);
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", 1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", -2);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", -1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7");
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", -1);
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -2);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- //entering EmptyTestMethod
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- //exited EmptyTestMethod
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 2);
- //returning resursion
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7");
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", 1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", 2);
-
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -2);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- //entering EmptyTestMethod
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- //exited EmptyTestMethod
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 2);
- //returning resursion
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7");
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", 1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", 2);
-
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -2);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- //entering EmptyTestMethod
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- //exited EmptyTestMethod
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 2);
- //returning resursion
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7");
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", 1);
- StepIn ("6b2c05cd-1cb8-48fe-b6bf-c4949121d4c7", 2);
-
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -2);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- //entering EmptyTestMethod
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- //exited EmptyTestMethod
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce");
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 2);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 1);
- //exited testClass.DebuggerNonUserCodeMethod (true, 3);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 2);
- //entering testClass.DebuggerNonUserCodeMethod (false);
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", -1);
- StepIn ("5b9b96b6-ce24-413f-8660-715fccfc412f", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -2);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", -1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 1);
- StepIn ("754272b8-a14b-4de0-9075-6a911c37e6ce", 2);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 2);
- //exited testClass.DebuggerNonUserCodeMethod (false);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 3);
-
- InitializeTest ();
- Session.Options.ProjectAssembliesOnly = true;
- AddBreakpoint ("02757896-0e76-40b8-8235-d09d2110da78");
- StartTest ("DebuggerNonUserCodeMethod");
- CheckPosition ("02757896-0e76-40b8-8235-d09d2110da78");
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78");
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (3).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (4).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (5).IsExternalCode);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (3).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (4).IsExternalCode);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (3).IsExternalCode);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 1);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 2);
- StepIn ("02757896-0e76-40b8-8235-d09d2110da78", 3);
- }
-
- /// <summary>
- /// Bug 3565
- /// </summary>
- [Test]
- public void DebuggerStepperBoundaryMethod ()
- {
- InitializeTest ();
- AddBreakpoint ("0b7eef17-af79-4b34-b4fc-cede110f20fe");
- AddBreakpoint ("806c13f8-8a59-4ae0-83a2-33191368af47");
- StartTest ("DebuggerStepperBoundaryMethod");
- CheckPosition ("0b7eef17-af79-4b34-b4fc-cede110f20fe");
- StepIn ("806c13f8-8a59-4ae0-83a2-33191368af47");//This actually means it hit 2nd breakpoint
- //because [DebuggerStepperBoundary] actually means if you step into this method
- //its looks like pressing F5
- }
-
- /// <summary>
- /// Bug 21510
- /// </summary>
- [Test]
- public void DebuggerStepperBoundaryMethod2ProjectAssembliesOnly ()
- {
- IgnoreSoftDebugger ("Fix me");
- //SDB Ignore: DebuggerStepperBoundary is stupid and pretty much uselss attribute anyway
- //Problem that we have here is that DebuggerStepperBoundary is handled on IDE side
- //and if method that has DebuggerStepperBoundary also has DebuggerNonUserCode IDE
- //is never notified about entering such method since runtime handles DebuggerNonUserCode
- //hence bug
- InitializeTest ();
- Session.Options.ProjectAssembliesOnly = true;
- AddBreakpoint ("f3a22b38-596a-4463-a562-20b342fdec12");
- AddBreakpoint ("4721f27a-a268-4529-b327-c39f208c08c5");
- StartTest ("DebuggerStepperBoundaryMethod2");
- CheckPosition ("f3a22b38-596a-4463-a562-20b342fdec12");
- StepIn ("4721f27a-a268-4529-b327-c39f208c08c5");
- }
-
- /// <summary>
- /// Bug 21510
- /// </summary>
- [Test]
- public void DebuggerStepperBoundaryMethod2 ()
- {
- InitializeTest ();
- Session.Options.ProjectAssembliesOnly = false;
- AddBreakpoint ("f3a22b38-596a-4463-a562-20b342fdec12");
- AddBreakpoint ("4721f27a-a268-4529-b327-c39f208c08c5");
- StartTest ("DebuggerStepperBoundaryMethod2");
- CheckPosition ("f3a22b38-596a-4463-a562-20b342fdec12");
- StepIn ("d110546f-a622-4ec3-9564-1c51bfec28f9", -1);
- StepIn ("d110546f-a622-4ec3-9564-1c51bfec28f9");
- StepIn ("4721f27a-a268-4529-b327-c39f208c08c5");
- }
-
- /// <summary>
- /// Bug 3565
- /// </summary>
- [Test]
- public void DebuggerStepThroughMethod ()
- {
- InitializeTest ();
- AddBreakpoint ("707ccd6c-3464-4700-8487-a83c948aa0c3");
- StartTest ("DebuggerStepThroughMethod");
- CheckPosition ("707ccd6c-3464-4700-8487-a83c948aa0c3");
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (0).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsDebuggerHidden);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (2).IsDebuggerHidden);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("707ccd6c-3464-4700-8487-a83c948aa0c3");
- StepIn ("707ccd6c-3464-4700-8487-a83c948aa0c3", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", -1);
- StepIn ("49326780-f51b-4510-a52c-03e7af442dda", 1);
- StepIn ("707ccd6c-3464-4700-8487-a83c948aa0c3", 1);
- StepIn ("707ccd6c-3464-4700-8487-a83c948aa0c3", 2);
- StepIn ("707ccd6c-3464-4700-8487-a83c948aa0c3", 3);
- }
-
- /// <summary>
- /// This test is very specific because of Win32 debugger bug
- /// Placing breakpoint inside delegate fails if some other
- /// breakpoint adding failed before this(invalidBreakpointAtEndOfFile)
- /// </summary>
- [Test]
- public void BreakpointInsideDelegate ()
- {
- InitializeTest ();
- AddBreakpoint ("f3b6862d-732b-4f68-81f5-f362d5a092e2");
- StartTest ("BreakpointInsideDelegate");
- CheckPosition ("f3b6862d-732b-4f68-81f5-f362d5a092e2");
- AddBreakpoint ("invalidBreakpointAtEndOfFile");
- AddBreakpoint ("ffde3c82-4310-43d3-93d1-4c39e9cf615e");
- Continue ("ffde3c82-4310-43d3-93d1-4c39e9cf615e");
- }
-
- [Test]
- public void BreakpointInsideOneLineDelegateNoDisplayClass ()
- {
- InitializeTest ();
- AddBreakpoint ("e0a96c37-577f-43e3-9a20-2cdd8bf7824e");
- AddBreakpoint ("e72a2fa6-2d95-4f96-b3d0-ba321da3cb55", statement: "Console.WriteLine");
- StartTest ("BreakpointInsideOneLineDelegateNoDisplayClass");
- CheckPosition ("e0a96c37-577f-43e3-9a20-2cdd8bf7824e");
- StepOver ("e72a2fa6-2d95-4f96-b3d0-ba321da3cb55", "Console.WriteLine");
- StepOut ("3be64647-76c1-455b-a4a7-a21b37383dcb");
- StepOut ("e0a96c37-577f-43e3-9a20-2cdd8bf7824e");
- }
-
- [Test]
- public void BreakpointInsideOneLineDelegate ()
- {
- InitializeTest ();
- AddBreakpoint ("67ae4cce-22b3-49d8-8221-7e5b26a5e79b");
- AddBreakpoint ("22af08d6-dafc-47f1-b8d1-bee1526840fd", statement: "button.SetTitle");
- StartTest ("BreakpointInsideOneLineDelegate");
- CheckPosition ("67ae4cce-22b3-49d8-8221-7e5b26a5e79b");
- StepOver ("22af08d6-dafc-47f1-b8d1-bee1526840fd", "button.SetTitle");
- StepOut ("3be64647-76c1-455b-a4a7-a21b37383dcb");
- StepOut ("67ae4cce-22b3-49d8-8221-7e5b26a5e79b");
- }
-
- [Test]
- public void BreakpointInsideOneLineDelegateAsync ()
- {
- InitializeTest ();
- AddBreakpoint ("b6a65e9e-5db2-4850-969a-b3747b2459af", statement: "button.SetTitle");
- AddBreakpoint ("b6a65e9e-5db2-4850-969a-b3747b2459af", 1);
- StartTest ("BreakpointInsideOneLineDelegateAsync");
- CheckPosition ("b6a65e9e-5db2-4850-969a-b3747b2459af", 1);
- StepOver ("b6a65e9e-5db2-4850-969a-b3747b2459af", "button.SetTitle");
- if (Session is SoftDebuggerSession) {
- StepOut ("3be64647-76c1-455b-a4a7-a21b37383dcb");
- } else {
- StepOut ("3be64647-76c1-455b-a4a7-a21b37383dcb", 1);//Feels like CorDebugger bug
- }
- StepOut ("b6a65e9e-5db2-4850-969a-b3747b2459af", 1);
- }
-
- /// <summary>
- /// Bug 2851
- /// </summary>
- [Test]
- public void ForeachEnumerable ()
- {
- IgnoreSoftDebugger ("Sdb has some problems when stepping into yeild methods. Have to investigate");
-
- InitializeTest ();
- AddBreakpoint ("b73bec88-2c43-4157-8574-ad517730bc74");
- StartTest ("ForeachEnumerable");
- CheckPosition ("b73bec88-2c43-4157-8574-ad517730bc74");
- StepOver ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "foreach");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "testClass.Iter_1");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- StepIn ("1463a77d-f27e-4bcd-8f92-89a682faa1c7", -1, "{");
- StepIn ("1463a77d-f27e-4bcd-8f92-89a682faa1c7", "yield return 1;");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "var");
- StepIn ("69dba3ab-0941-47e9-99fa-10222a2e894d", -1, "{");
- StepIn ("69dba3ab-0941-47e9-99fa-10222a2e894d", 1, "}");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- StepIn ("1463a77d-f27e-4bcd-8f92-89a682faa1c7", 1, "yield return 2;");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "var");
- StepIn ("69dba3ab-0941-47e9-99fa-10222a2e894d", -1, "{");
- StepIn ("69dba3ab-0941-47e9-99fa-10222a2e894d", 1, "}");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- StepIn ("1463a77d-f27e-4bcd-8f92-89a682faa1c7", 2, "}");
- StepIn ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- StepIn ("e01a5428-b067-4ca3-ac8c-a19d5d800228", 1, "}");
- }
-
- [Test]
- public void SetBreakpointOnColumn ()
- {
- InitializeTest ();
- AddBreakpoint ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "testClass.Iter_1");
- AddBreakpoint ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- AddBreakpoint ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "var");
- AddBreakpoint ("e01a5428-b067-4ca3-ac8c-a19d5d800228", 1);//end of method
- StartTest ("ForeachEnumerable");
- CheckPosition ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "testClass.Iter_1");
- Continue ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- Continue ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "var");
- Continue ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- Continue ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "var");
- Continue ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- Continue ("e01a5428-b067-4ca3-ac8c-a19d5d800228", 1);//end of method
- }
-
- [Test]
- public void RunToCursorTest ()
- {
- InitializeTest ();
- AddBreakpoint ("b73bec88-2c43-4157-8574-ad517730bc74");
- StartTest ("ForeachEnumerable");
- CheckPosition ("b73bec88-2c43-4157-8574-ad517730bc74");
- RunToCursor ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "testClass.Iter_1");
- RunToCursor ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "var");
- RunToCursor ("b73bec88-2c43-4157-8574-ad517730bc74", 1, "in");
- RunToCursor ("69dba3ab-0941-47e9-99fa-10222a2e894d", 1, "}");
- RunToCursor ("e01a5428-b067-4ca3-ac8c-a19d5d800228", 1);
- }
-
- [Test]
- public void RunToCursorTest2 ()
- {
- InitializeTest ();
- AddBreakpoint ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 1);
- StartTest ("SimpleMethod");
- CheckPosition ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 1);
- RunToCursor ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 3);
- }
-
- /// <summary>
- /// Bug 4032
- /// </summary>
- [Test]
- public void PListSchemeTest ()
- {
- IgnoreSoftDebugger ("Sdb is reapeating StepIn in StaticConstructor instead of StepOut. Resulting in step stopping at unexpected location.");
-
- InitializeTest ();
- AddBreakpoint ("41eb3a30-3b19-4ea5-a7dc-e4c76871f391");
- StartTest ("PListSchemeTest");
- CheckPosition ("41eb3a30-3b19-4ea5-a7dc-e4c76871f391");
- StepIn ("c9b18785-1348-42e3-a479-9cac1e7c5360", -1);
- }
-
- /// <summary>
- /// Bug 4433 StepOverPropertiesAndOperators = true
- /// </summary>
- [Test]
- public void Bug4433StepOverProperties ()
- {
- InitializeTest ();
- Session.Options.StepOverPropertiesAndOperators = true;
- AddBreakpoint ("a062e69c-e3f7-4fd7-8985-fc7abd5c27d2");
- StartTest ("Bug4433Test");
- CheckPosition ("a062e69c-e3f7-4fd7-8985-fc7abd5c27d2");
- StepIn ("ad9b8803-eef0-438c-bf2b-9156782f4027", -1);
- }
-
- /// <summary>
- /// Bug 4433 StepOverPropertiesAndOperators = false
- /// </summary>
- [Test]
- public void Bug4433 ()
- {
- InitializeTest ();
- Session.Options.StepOverPropertiesAndOperators = false;
- AddBreakpoint ("a062e69c-e3f7-4fd7-8985-fc7abd5c27d2");
- StartTest ("Bug4433Test");
- CheckPosition ("a062e69c-e3f7-4fd7-8985-fc7abd5c27d2");
- StepIn ("ad9b8803-eef0-438c-bf2b-9156782f4027", -1);
- }
-
- /// <summary>
- /// Bug 5386
- /// </summary>
- [Test]
- public void EmptyForLoopTest ()
- {
- InitializeTest ();
- AddBreakpoint ("946d5781-a162-4cd9-a7b6-c320564cc594", -1);
- StartTest ("EmptyForLoopTest");
- CheckPosition ("946d5781-a162-4cd9-a7b6-c320564cc594", -1);
- //make 3 loops...
- StepIn ("a2ff92da-3796-47e3-886a-4bd786a07547", -1);
- StepIn ("a2ff92da-3796-47e3-886a-4bd786a07547", 1);
- StepIn ("a2ff92da-3796-47e3-886a-4bd786a07547", -1);
- StepIn ("a2ff92da-3796-47e3-886a-4bd786a07547", 1);
- StepIn ("a2ff92da-3796-47e3-886a-4bd786a07547", -1);
- StepIn ("a2ff92da-3796-47e3-886a-4bd786a07547", 1);
- }
-
- /// <summary>
- /// Bug 6724
- /// </summary>
- [Test]
- public void CallMethodWithPropertyAsArgument ()
- {
- InitializeTest ();
- Session.Options.StepOverPropertiesAndOperators = true;
- AddBreakpoint ("1c3e65ca-3201-42ba-9c6e-6f9a45ddac44");
- StartTest ("CallMethodWithPropertyAsArgument");
- CheckPosition ("1c3e65ca-3201-42ba-9c6e-6f9a45ddac44");
- StepIn ("c25be44e-ead3-4891-ab42-0e4cf8450f7a", -1);
- StepOut ("1c3e65ca-3201-42ba-9c6e-6f9a45ddac44");
- StepIn ("1c3e65ca-3201-42ba-9c6e-6f9a45ddac44", 1);
- StepIn ("c25be44e-ead3-4891-ab42-0e4cf8450f7a", -1);
- }
-
- /// <summary>
- /// Bug 7901
- /// </summary>
- [Test]
- public void Bug7901 ()
- {
- InitializeTest ();
- AddBreakpoint ("956bd9fd-39fe-4587-9d9e-a2a817d76286");
- StartTest ("TestBug7901");
- CheckPosition ("956bd9fd-39fe-4587-9d9e-a2a817d76286");
- StepIn ("f456a9b0-9c1a-4b34-bef4-d80b8541ebdb", -1);
- StepIn ("f456a9b0-9c1a-4b34-bef4-d80b8541ebdb", 1);
- StepIn ("11259de1-944d-4052-b970-62662e21876a", -1);
- StepIn ("11259de1-944d-4052-b970-62662e21876a");
- StepIn ("11259de1-944d-4052-b970-62662e21876a", 1);
- StepIn ("11259de1-944d-4052-b970-62662e21876a", 2);
- StepIn ("4863ebb7-8c90-4704-af8b-66a9f53657b9");
- StepOut ("956bd9fd-39fe-4587-9d9e-a2a817d76286");
- }
-
- /// <summary>
- /// Bug 10782
- /// </summary>
- [Test]
- public void Bug10782 ()
- {
- InitializeTest ();
- AddBreakpoint ("cdcabe93-4f55-4dbb-821e-912097c4f727");
- StartTest ("TestBug10782");
- CheckPosition ("cdcabe93-4f55-4dbb-821e-912097c4f727");
- StepIn ("1f37aea1-77a1-40c1-9ea5-797db48a14f9", 1);
- StepOut ("cdcabe93-4f55-4dbb-821e-912097c4f727");
- StepIn ("3bda6643-6d06-4504-a4da-91bc8c5eb887", -1);
- }
-
- /// <summary>
- /// Bug 11868
- /// </summary>
- [Test]
- [Ignore ("Todo")]
- public void AwaitCall ()
- {
- InitializeTest ();
- AddBreakpoint ("a221c9d4-6d00-4fce-99e6-d712e9a23c02", -1);
- StartTest ("TestAwaitCall");
- CheckPosition ("a221c9d4-6d00-4fce-99e6-d712e9a23c02", -1);
- StepOver ("a221c9d4-6d00-4fce-99e6-d712e9a23c02");
- StepOver ("a221c9d4-6d00-4fce-99e6-d712e9a23c02", 1);
- StepOver ("a221c9d4-6d00-4fce-99e6-d712e9a23c02", 2);
- }
-
- /// <summary>
- /// Bug 13396
- /// </summary>
- [Test]
- [Ignore ("This is not working in VS as well is this doable or should bug be closed as invalid?")]
- public void StepInsideAwaitTaskRun ()
- {
- InitializeTest ();
- AddBreakpoint ("a221c9d4-6d00-4fce-99e6-d712e9a23c02", -1);
- StartTest ("StepInsideAwaitTaskRun");
- CheckPosition ("a221c9d4-6d00-4fce-99e6-d712e9a23c02", -1);
- StepIn ("a221c9d4-6d00-4fce-99e6-d712e9a23c02");
- StepIn ("a221c9d4-6d00-4fce-99e6-d712e9a23c02");//Now we are on delegate
- //entering EmptyMethod
- StepIn ("3c27f60f-fdfa-44c0-b58f-552ecaaa77f1", -1);
- StepIn ("3c27f60f-fdfa-44c0-b58f-552ecaaa77f1", 1);
- StepIn ("a221c9d4-6d00-4fce-99e6-d712e9a23c02");//Back at delegate
- StepIn ("a221c9d4-6d00-4fce-99e6-d712e9a23c02");//Back at await?
- StepIn ("a221c9d4-6d00-4fce-99e6-d712e9a23c02", 1);
- }
-
- /// <summary>
- /// Bug 13640
- /// </summary>
- [Test]
- public void Bug13640 ()
- {
- InitializeTest ();
- AddBreakpoint ("b64e6497-e976-4125-9741-801909e5eeb1");
- StartTest ("Bug13640");
- CheckPosition ("b64e6497-e976-4125-9741-801909e5eeb1");
- StepIn ("b64e6497-e976-4125-9741-801909e5eeb1", 1, "foreach");
- StepIn ("b64e6497-e976-4125-9741-801909e5eeb1", 1, "l");
- StepIn ("b64e6497-e976-4125-9741-801909e5eeb1", 1, "in");
- StepIn ("a90ba766-0891-4837-9b1d-e5458f6b8e07", "return");
- StepIn ("a90ba766-0891-4837-9b1d-e5458f6b8e07", 1, "}");
- }
-
- [Test]
- public void SetNextStatementTest ()
- {
- InitializeTest ();
- AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- SetNextStatement ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- StepIn ("3e2e4759-f6d9-4839-98e6-4fa96b227458", 1);
- }
-
-
- [Test]
- public void SetNextStatementTest2 ()
- {
- InitializeTest ();
- AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- SetNextStatement ("c35046f7-e87d-4b8f-b260-43e181a0a07c", -1, "{");
- StepIn ("c35046f7-e87d-4b8f-b260-43e181a0a07c", 1, "int");
- }
-
- [Test]
- public void SetNextStatementTest3 ()
- {
- InitializeTest ();
- AddBreakpoint ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 1);
- StartTest ("SimpleMethod");
- CheckPosition ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 1);
- StepOver ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 2);
- StepOver ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 3);
- StepOver ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 4);
- SetNextStatement ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 1);
- StepOver ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 2);
- StepOver ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 3);
- SetNextStatement ("f4e3a214-229e-44dd-9da2-db82ddfbec11", -1);
- StepOver ("f4e3a214-229e-44dd-9da2-db82ddfbec11", 1);
- }
-
- [Test]
- public void CatchPointTest1 ()
- {
- InitializeTest ();
- AddBreakpoint ("fcdc2412-c00e-4c95-b2ea-e3cf5d5bf856");
- AddCatchpoint ("System.Exception", true);
- StartTest ("Catchpoint1");
- if (!CheckPosition ("526795d3-ee9e-44a7-8423-df0b406e9e8d", 1, null, true))//Workaround for Win32 debugger which stops at +1 line
- CheckPosition ("526795d3-ee9e-44a7-8423-df0b406e9e8d");
- var ops = Session.EvaluationOptions.Clone ();
- ops.MemberEvaluationTimeout = 0;
- ops.EvaluationTimeout = 0;
- ops.EllipsizeStrings = false;
-
- var val = Frame.GetException (ops);
- Assert.AreEqual ("System.NotImplementedException", val.Type);
-
- InitializeTest ();
- AddBreakpoint ("fcdc2412-c00e-4c95-b2ea-e3cf5d5bf856");
- AddCatchpoint ("System.Exception", false);
- StartTest ("Catchpoint1");
- CheckPosition ("fcdc2412-c00e-4c95-b2ea-e3cf5d5bf856");
- }
-
- [Test]
- public void CatchPointTest2 ()
- {
- IgnoreSoftDebugger ("I'm having problem testing this because. There is error nonstop happening in framework about CurrentCulture featching.");
- IgnoreCorDebugger ("Randomly fails");
-
- InitializeTest ();
- AddCatchpoint ("System.Exception", true);
- StartTest ("Catchpoint2");
- CheckPosition ("d24b1c9d-3944-4f0d-be31-5556251fbdf5");
- Assert.IsTrue (Session.ActiveThread.Backtrace.GetFrame (0).IsExternalCode);
- Assert.IsFalse (Session.ActiveThread.Backtrace.GetFrame (1).IsExternalCode);
- }
-
- [Test]
- public void CatchpointIgnoreExceptionsInNonUserCodeTest ()
- {
- //It seems CorDebugger has different definition of what is user code and what is not.
- IgnoreCorDebugger ("CorDebugger: TODO");
-
- InitializeTest ();
- Session.Options.ProjectAssembliesOnly = true;
- AddBreakpoint ("999b8a83-8c32-4640-a8e1-f74309cda79c");
- AddCatchpoint ("System.Exception", true);
- StartTest ("CatchpointIgnoreExceptionsInNonUserCode");
- CheckPosition ("999b8a83-8c32-4640-a8e1-f74309cda79c");
-
- InitializeTest ();
- Session.Options.ProjectAssembliesOnly = false;
- AddCatchpoint ("System.Exception", true);
- AddBreakpoint ("999b8a83-8c32-4640-a8e1-f74309cda79c");
- StartTest ("CatchpointIgnoreExceptionsInNonUserCode");
- WaitStop (2000);
- Assert.AreEqual ("3913936e-3f89-4f07-a863-7275aaaa5fc9", Session.ActiveThread.Backtrace.GetFrame (0).GetException ().Message);
- }
-
- [Test]
- public void ConditionalBreakpoints ()
- {
- ObjectValue val;
- Breakpoint bp;
-
- InitializeTest ();
- AddBreakpoint ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- bp = AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- bp.ConditionExpression = "i==2";
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("2", val.Value);
- Continue ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
-
- IgnoreCorDebugger ("TODO: Conditional breakpoints with compare against string or enum is not working on CorDebugger");
-
- InitializeTest ();
- bp = AddBreakpoint ("033dd01d-6cb4-4e1a-b445-de6d7fa0d2a7");
- bp.ConditionExpression = "str == \"bbb\"";
- StartTest ("ConditionalBreakpointString");
- CheckPosition ("033dd01d-6cb4-4e1a-b445-de6d7fa0d2a7");
- val = Eval ("str");
- Assert.AreEqual ("\"bbb\"", val.Value);
-
- InitializeTest ();
- bp = AddBreakpoint ("ecf764bf-9182-48d6-adb0-0ba36e2653a7");
- bp.ConditionExpression = "en == BooleanEnum.False";
- StartTest ("ConitionalBreakpointEnum");
- CheckPosition ("ecf764bf-9182-48d6-adb0-0ba36e2653a7");
- val = Eval ("en");
- Assert.AreEqual ("BooleanEnum.False", val.Value);
- }
-
- [Test]
- public void HitCountBreakpoints ()
- {
- ObjectValue val;
- Breakpoint bp;
-
- InitializeTest ();
- AddBreakpoint ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- bp = AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- bp.HitCount = 3;
- bp.HitCountMode = HitCountMode.EqualTo;
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("2", val.Value);
- Continue ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
-
- InitializeTest ();
- AddBreakpoint ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- bp = AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- bp.HitCount = 3;
- bp.HitCountMode = HitCountMode.GreaterThan;
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("3", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("4", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("5", val.Value);
-
- InitializeTest ();
- AddBreakpoint ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- bp = AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- bp.HitCount = 3;
- bp.HitCountMode = HitCountMode.GreaterThanOrEqualTo;
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("2", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("3", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("4", val.Value);
-
- InitializeTest ();
- AddBreakpoint ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- bp = AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- bp.HitCount = 3;
- bp.HitCountMode = HitCountMode.LessThan;
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("0", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("1", val.Value);
- Continue ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
-
- InitializeTest ();
- AddBreakpoint ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- bp = AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- bp.HitCount = 3;
- bp.HitCountMode = HitCountMode.LessThanOrEqualTo;
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("0", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("1", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("2", val.Value);
- Continue ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
-
- InitializeTest ();
- AddBreakpoint ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- bp = AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- bp.HitCount = 3;
- bp.HitCountMode = HitCountMode.MultipleOf;
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("2", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("5", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("8", val.Value);
- Continue ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
-
- InitializeTest ();
- AddBreakpoint ("3e2e4759-f6d9-4839-98e6-4fa96b227458");
- bp = AddBreakpoint ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- bp.HitCount = 3;
- bp.HitCountMode = HitCountMode.None;
- StartTest ("ForLoop10");
- CheckPosition ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("0", val.Value);
- Continue ("eef5bea2-aaa6-4718-b26f-b35be6a6a13e");
- val = Eval ("i");
- Assert.AreEqual ("1", val.Value);
- }
-
- [Test]
- public void Bug13401 ()
- {
- InitializeTest ();
- AddBreakpoint ("977ee8ce-ee61-4de0-9fc1-138fa164870b");
- StartTest ("Bug13401");
- CheckPosition ("977ee8ce-ee61-4de0-9fc1-138fa164870b");
- var val = Eval ("s");
- Assert.AreEqual ("string", val.TypeName);
- Assert.AreEqual ("\"Hello from Bar\"", val.Value);
- }
-
- [Test]
- public void OutputAndDebugWriter ()
- {
- //Interesting fact... Debug.Write(""); produces log entry
- //but Console.Write(""); does not
-
- InitializeTest ();
- AddBreakpoint ("5070ed1c-593d-4cbe-b4fa-b2b0c7b25289");
- var errorsList = new List<string> ();
- errorsList.Add ("ErrorText");
- var outputList = new HashSet<string> ();
- outputList.Add ("NormalText");
- var debugList = new List<Tuple<int,string,string>> ();
- debugList.Add (new Tuple<int,string,string> (0, "", "DebugText"));
- debugList.Add (new Tuple<int, string, string> (3, "SomeCategory", "DebugText2"));
-
- var unexpectedOutput = new List<string> ();
- var unexpectedError = new List<string> ();
- var unexpectedDebug = new List<Tuple<int,string,string>> ();
-
- Session.DebugWriter = delegate(int level, string category, string message) {
- var entry = new Tuple<int,string,string> (level, category, message);
- if (entry.Equals (new Tuple<int,string,string> (0, "", "")))//Sdb is emitting some empty messages :S
- return;
- if (debugList.Contains (entry)) {
- debugList.Remove (entry);
- } else {
- unexpectedDebug.Add (entry);
- }
- };
- Session.OutputWriter = delegate(bool isStderr, string text) {
- if (isStderr) {
- if (errorsList.Contains (text))
- errorsList.Remove (text);
- else
- unexpectedError.Add (text);
- } else {
- if (outputList.Contains (text))
- outputList.Remove (text);
- else
- unexpectedOutput.Add (text);
- }
- };
- StartTest ("OutputAndDebugWriter");
- CheckPosition ("5070ed1c-593d-4cbe-b4fa-b2b0c7b25289");
- if (outputList.Count > 0)
- Assert.Fail ("Output list still has following items:" + string.Join (",", outputList));
- if (errorsList.Count > 0)
- Assert.Fail ("Error list still has following items:" + string.Join (",", errorsList));
- if (debugList.Count > 0)
- Assert.Fail ("Debug list still has following items:" + string.Join (",", debugList));
- if (unexpectedOutput.Count > 0)
- Assert.Fail ("Unexcpected Output list has following items:" + string.Join (",", unexpectedOutput));
- if (unexpectedError.Count > 0)
- Assert.Fail ("Unexcpected Error list has following items:" + string.Join (",", unexpectedError));
- if (unexpectedDebug.Count > 0)
- Assert.Fail ("Unexcpected Debug list has following items:" + string.Join (",", unexpectedDebug));
- }
-
- [Test]
- public void Bug25358 ()
- {
- InitializeTest ();
- AddBreakpoint ("4b30f826-2ba0-4b53-ab36-85b2cdde1069");
- StartTest ("TestBug25358");
- CheckPosition ("4b30f826-2ba0-4b53-ab36-85b2cdde1069");
- var val = Eval ("e");
- val = val.GetChildSync ("Message", EvaluationOptions.DefaultOptions);
- Assert.AreEqual ("\"2b2c4423-accf-4c2c-af31-7d8dcee31c32\"", val.Value);
- }
-
- [Test]
- public void Bug21410 ()
- {
- IgnoreSoftDebugger ("Runtime bug.");
-
- InitializeTest ();
- AddBreakpoint ("5e6663d0-9088-40ad-914d-0fcc05b2d0d5");
- StartTest ("TestBug21410");
- CheckPosition ("5e6663d0-9088-40ad-914d-0fcc05b2d0d5");
- StepOver ("5e6663d0-9088-40ad-914d-0fcc05b2d0d5", 1);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorBreakpointsAndSteppingTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorBreakpointsAndSteppingTests.cs
deleted file mode 100644
index 43eaec378d..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorBreakpointsAndSteppingTests.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// CorBreakpointsAndSteppingTests.cs
-//
-// Author:
-// David Karlaš <david.karlas@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
-//
-// 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.
-using System;
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests.Win32
-{
- [TestFixture]
- [Platform (Include = "Win")]
- public class CorBreakpointsAndSteppingTests: BreakpointsAndSteppingTests
- {
- public CorBreakpointsAndSteppingTests () : base ("MonoDevelop.Debugger.Win32")
- {
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorEvaluationTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorEvaluationTests.cs
deleted file mode 100644
index f6714b4375..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorEvaluationTests.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// CorEvaluationTests.cs
-//
-// Author:
-// Therzok <teromario@yahoo.com>
-//
-// Copyright (c) 2013 Xamarin Inc.
-//
-// 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.
-
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests.Win32
-{
- [TestFixture]
- [Platform (Include = "Win")]
- public class CorEvaluationAllowTargetInvokesTests: EvaluationTests
- {
- public CorEvaluationAllowTargetInvokesTests (): base ("MonoDevelop.Debugger.Win32", true)
- {
- }
- }
-
- [TestFixture]
- [Platform (Include = "Win")]
- [Ignore ("Disabled for now")]
- public class CorEvaluationNoTargetInvokesTests: EvaluationTests
- {
- public CorEvaluationNoTargetInvokesTests (): base ("MonoDevelop.Debugger.Win32", false)
- {
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorStackFrameTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorStackFrameTests.cs
deleted file mode 100644
index 41d0b3ae12..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/CorStackFrameTests.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// CorStackFrametests.cs
-//
-// Author:
-// Therzok <teromario@yahoo.com>
-//
-// Copyright (c) 2013 Xamarin Inc.
-//
-// 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.
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests.Win32
-{
- [TestFixture]
- [Platform (Include = "Win")]
- public class CorStackFrameAllowTargetInvokesTests : StackFrameTests
- {
- public CorStackFrameAllowTargetInvokesTests (): base ("MonoDevelop.Debugger.Win32", true)
- {
- }
- }
-
- [TestFixture]
- [Platform (Include = "Win")]
- public class CorStackFrameNoTargetInvokesTests : StackFrameTests
- {
- public CorStackFrameNoTargetInvokesTests (): base ("MonoDevelop.Debugger.Win32", false)
- {
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/DebugTests.MonoDevelop.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/DebugTests.MonoDevelop.cs
new file mode 100644
index 0000000000..d7bd837f54
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/DebugTests.MonoDevelop.cs
@@ -0,0 +1,136 @@
+using System;
+using System.IO;
+using System.Linq;
+using Mono.Debugging.Client;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Assemblies;
+using MonoDevelop.Core.Execution;
+using MonoDevelop.Debugger;
+using NUnit.Framework;
+
+using MDTextFile = MonoDevelop.Projects.Text.TextFile;
+
+namespace Mono.Debugging.Tests
+{
+ public abstract partial class DebugTests
+ {
+ DebuggerEngine engine;
+ TargetRuntime runtime;
+
+ partial void SetUpPartial()
+ {
+ foreach (var e in DebuggingService.GetDebuggerEngines ()) {
+ if (e.Id == EngineId) {
+ engine = e;
+ break;
+ }
+ }
+ if (engine == null)
+ Assert.Ignore ("Engine not found: {0}", EngineId);
+ }
+
+ partial void TearDownPartial ()
+ {
+ }
+
+ FilePath UnitTestsDir
+ {
+ get{
+ FilePath thisAssemblyPath = GetType ().Assembly.Location;
+ return thisAssemblyPath.ParentDirectory.ParentDirectory.ParentDirectory.Combine ("external", "debugger-libs", "UnitTests");
+ }
+ }
+
+ protected string TargetExeDirectory
+ {
+ get{
+ return Path.GetDirectoryName (GetType ().Assembly.Location);
+ }
+ }
+
+ protected string TargetProjectSourceDir
+ {
+ get{
+ FilePath path = TargetExeDirectory;
+ return UnitTestsDir.Combine (TestAppProjectDirName);
+ }
+ }
+
+ protected DebuggerSession CreateSession (string test, string engineId)
+ {
+ switch (engineId) {
+ case "MonoDevelop.Debugger.Win32":
+ runtime = Runtime.SystemAssemblyService.GetTargetRuntime ("MS.NET");
+ break;
+ case "Mono.Debugger.Soft":
+ runtime = Runtime.SystemAssemblyService.GetTargetRuntimes ()
+ .OfType<MonoTargetRuntime> ()
+ .OrderByDescending ((o) => {
+ //Attempt to find latest version of Mono registred in IDE and use that for unit tests
+ if (string.IsNullOrWhiteSpace (o.Version) || o.Version == "Unknown")
+ return new Version (0, 0, 0, 0);
+ int indexOfBeforeDetails = o.Version.IndexOf (" (", StringComparison.Ordinal);
+ if (indexOfBeforeDetails == -1)
+ return new Version (0, 0, 0, 0);
+ string hopefullyVersion = o.Version.Remove (indexOfBeforeDetails);
+ Version version;
+ if (Version.TryParse (hopefullyVersion, out version)) {
+ return version;
+ } else {
+ return new Version (0, 0, 0, 0);
+ }
+ }).FirstOrDefault ();
+ break;
+ default:
+ runtime = Runtime.SystemAssemblyService.DefaultRuntime;
+ break;
+ }
+
+ if (runtime == null) {
+ Assert.Ignore ("Runtime not found for: {0}", engineId);
+ }
+
+ Console.WriteLine ("Target Runtime: " + runtime.DisplayRuntimeName + " " + runtime.Version + " " + (IntPtr.Size == 8 ? "64bit" : "32bit"));
+
+ // main/build/tests
+ var exe = TargetExePath;
+
+ var cmd = new DotNetExecutionCommand ();
+ cmd.TargetRuntime = runtime;
+ cmd.Command = exe;
+ cmd.Arguments = test;
+
+ if (Platform.IsWindows) {
+ var monoRuntime = runtime as MonoTargetRuntime;
+ if (monoRuntime != null) {
+ var psi = new System.Diagnostics.ProcessStartInfo (Path.Combine (monoRuntime.Prefix, "bin", "pdb2mdb.bat"), exe);
+ psi.UseShellExecute = false;
+ psi.CreateNoWindow = true;
+ System.Diagnostics.Process.Start (psi).WaitForExit ();
+ }
+ }
+ return engine.CreateSession ();
+ }
+
+ protected DebuggerStartInfo CreateStartInfo (string test, string engineId)
+ {
+ var cmd = new DotNetExecutionCommand {
+ TargetRuntime = runtime,
+ Command = TargetExePath,
+ Arguments = test
+ };
+ var dsi = engine.CreateDebuggerStartInfo (cmd);
+ return dsi;
+ }
+
+ /// <summary>
+ /// Reads file from given path
+ /// </summary>
+ /// <param name="sourcePath"></param>
+ /// <returns></returns>
+ public static ITextFile ReadFile (string sourcePath)
+ {
+ return new TextFile(MDTextFile.ReadFile (sourcePath));
+ }
+ }
+} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/DebugTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/DebugTests.cs
deleted file mode 100644
index fafb2b96c6..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/DebugTests.cs
+++ /dev/null
@@ -1,466 +0,0 @@
-//
-// DebugTests.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using System.Reflection;
-using System.Collections.Generic;
-
-using Mono.Debugging.Soft;
-using Mono.Debugging.Client;
-
-using MonoDevelop.Core;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Projects.Text;
-using MonoDevelop.Core.Assemblies;
-
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests
-{
- [TestFixture]
- public abstract class DebugTests
- {
- readonly ManualResetEvent targetStoppedEvent = new ManualResetEvent (false);
- readonly string EngineId;
- DebuggerEngine engine;
- string TestName = "";
- TextFile SourceFile;
-
- SourceLocation lastStoppedPosition;
-
- public bool AllowTargetInvokes { get; protected set; }
-
- public DebuggerSession Session { get; private set; }
-
- public StackFrame Frame { get; private set; }
-
- protected DebugTests (string engineId)
- {
- EngineId = engineId;
- }
-
- public void IgnoreCorDebugger (string message = "")
- {
- if (!(Session is SoftDebuggerSession)) {
- Assert.Ignore (message);
- }
- }
-
- public void IgnoreSoftDebugger (string message = "")
- {
- if (Session is SoftDebuggerSession) {
- Assert.Ignore (message);
- }
- }
-
- [TestFixtureSetUp]
- public virtual void SetUp ()
- {
- foreach (var e in DebuggingService.GetDebuggerEngines ()) {
- if (e.Id == EngineId) {
- engine = e;
- break;
- }
- }
- if (engine == null)
- Assert.Ignore ("Engine not found: {0}", EngineId);
- }
-
- [TestFixtureTearDown]
- public virtual void TearDown ()
- {
- if (Session != null) {
- Session.Exit ();
- Session.Dispose ();
- Session = null;
- }
- }
-
- protected void Start (string test)
- {
- TargetRuntime runtime;
-
- switch (EngineId) {
- case "MonoDevelop.Debugger.Win32":
- runtime = Runtime.SystemAssemblyService.GetTargetRuntime ("MS.NET");
- break;
- case "Mono.Debugger.Soft":
- runtime = Runtime.SystemAssemblyService.GetTargetRuntimes ()
- .OfType<MonoTargetRuntime> ()
- .OrderByDescending ((o) => {
- //Attempt to find latest version of Mono registred in IDE and use that for unit tests
- if (string.IsNullOrWhiteSpace (o.Version) || o.Version == "Unknown")
- return new Version (0, 0, 0, 0);
- int indexOfBeforeDetails = o.Version.IndexOf (" (", StringComparison.Ordinal);
- if (indexOfBeforeDetails == -1)
- return new Version (0, 0, 0, 0);
- string hopefullyVersion = o.Version.Remove (indexOfBeforeDetails);
- Version version;
- if (Version.TryParse (hopefullyVersion, out version)) {
- return version;
- } else {
- return new Version (0, 0, 0, 0);
- }
- }).FirstOrDefault ();
- break;
- default:
- runtime = Runtime.SystemAssemblyService.DefaultRuntime;
- break;
- }
-
- if (runtime == null) {
- Assert.Ignore ("Runtime not found for: {0}", EngineId);
- return;
- }
-
- Console.WriteLine ("Target Runtime: " + runtime.DisplayRuntimeName + " " + runtime.Version + " " + (IntPtr.Size == 8 ? "64bit" : "32bit"));
-
- // main/build/tests
- FilePath path = Path.GetDirectoryName (GetType ().Assembly.Location);
- var exe = Path.Combine (path, "MonoDevelop.Debugger.Tests.TestApp.exe");
-
- var cmd = new DotNetExecutionCommand ();
- cmd.TargetRuntime = runtime;
- cmd.Command = exe;
- cmd.Arguments = test;
-
- if (Platform.IsWindows) {
- var monoRuntime = runtime as MonoTargetRuntime;
- if (monoRuntime != null) {
- var psi = new System.Diagnostics.ProcessStartInfo (Path.Combine (monoRuntime.Prefix, "bin", "pdb2mdb.bat"), cmd.Command);
- psi.UseShellExecute = false;
- psi.CreateNoWindow = true;
- System.Diagnostics.Process.Start (psi).WaitForExit ();
- }
- }
-
- var dsi = engine.CreateDebuggerStartInfo (cmd);
- var soft = dsi as SoftDebuggerStartInfo;
-
- if (soft != null) {
- var assemblyName = AssemblyName.GetAssemblyName (exe);
-
- soft.UserAssemblyNames = new List<AssemblyName> ();
- soft.UserAssemblyNames.Add (assemblyName);
- }
-
- Session = engine.CreateSession ();
- var ops = new DebuggerSessionOptions ();
- ops.ProjectAssembliesOnly = true;
- ops.EvaluationOptions = EvaluationOptions.DefaultOptions;
- ops.EvaluationOptions.AllowTargetInvoke = AllowTargetInvokes;
- ops.EvaluationOptions.EvaluationTimeout = 100000;
-
- path = path.ParentDirectory.ParentDirectory.Combine ("src", "addins", "MonoDevelop.Debugger", "MonoDevelop.Debugger.Tests.TestApp", test + ".cs").FullPath;
- SourceFile = TextFile.ReadFile (path);
- TestName = test;
- AddBreakpoint ("break");
-
- var done = new ManualResetEvent (false);
-
- Session.TargetHitBreakpoint += (sender, e) => {
- Frame = e.Backtrace.GetFrame (0);
- lastStoppedPosition = Frame.SourceLocation;
- targetStoppedEvent.Set ();
- done.Set ();
- };
-
- Session.TargetExceptionThrown += (sender, e) => {
- Frame = e.Backtrace.GetFrame (0);
- for (int i = 0; i < e.Backtrace.FrameCount; i++) {
- if (!e.Backtrace.GetFrame (i).IsExternalCode) {
- Frame = e.Backtrace.GetFrame (i);
- break;
- }
- }
- lastStoppedPosition = Frame.SourceLocation;
- targetStoppedEvent.Set ();
- };
-
- Session.TargetStopped += (sender, e) => {
- //This can be null in case of ForcedStop
- //which is called when exception is thrown
- //when Continue & Stepping is executed
- if (e.Backtrace != null) {
- Frame = e.Backtrace.GetFrame (0);
- lastStoppedPosition = Frame.SourceLocation;
- targetStoppedEvent.Set ();
- } else {
- Console.WriteLine ("e.Backtrace is null");
- }
- };
-
- var targetExited = new ManualResetEvent (false);
- Session.TargetExited += delegate {
- targetExited.Set ();
- };
-
- Session.Run (dsi, ops);
- Session.ExceptionHandler = (ex) => {
- Console.WriteLine ("Session.ExceptionHandler:" + Environment.NewLine + ex.ToString ());
- return true;
- };
- switch (WaitHandle.WaitAny (new WaitHandle[]{ done, targetExited }, 30000)) {
- case 0:
- //Breakpoint is hit good... run tests now
- break;
- case 1:
- throw new Exception ("Test application exited before hitting breakpoint");
- default:
- throw new Exception ("Timeout while waiting for initial breakpoint");
- }
- if (Session is SoftDebuggerSession) {
- Console.WriteLine ("SDB protocol version:" + ((SoftDebuggerSession)Session).ProtocolVersion);
- }
- }
-
- void GetLineAndColumn (string breakpointMarker, int offset, string statement, out int line, out int col)
- {
- int i = SourceFile.Text.IndexOf ("/*" + breakpointMarker + "*/", StringComparison.Ordinal);
- if (i == -1)
- Assert.Fail ("Break marker not found: " + breakpointMarker + " in " + SourceFile.Name);
- SourceFile.GetLineColumnFromPosition (i, out line, out col);
- line += offset;
- if (statement != null) {
- int lineStartPosition = SourceFile.GetPositionFromLineColumn (line, 1);
- string lineText = SourceFile.GetText (lineStartPosition, lineStartPosition + SourceFile.GetLineLength (line));
- col = lineText.IndexOf (statement, StringComparison.Ordinal) + 1;
- if (col == 0)
- Assert.Fail ("Failed to find statement:" + statement + " at " + SourceFile.Name + "(" + line + ")");
- } else {
- col = 1;
- }
- }
-
- public Breakpoint AddBreakpoint (string breakpointMarker, int offset = 0, string statement = null)
- {
- int col, line;
- GetLineAndColumn (breakpointMarker, offset, statement, out line, out col);
- var bp = new Breakpoint (SourceFile.Name, line, col);
- Session.Breakpoints.Add (bp);
- return bp;
- }
-
- public void RunToCursor (string breakpointMarker, int offset = 0, string statement = null)
- {
- int col, line;
- GetLineAndColumn (breakpointMarker, offset, statement, out line, out col);
- targetStoppedEvent.Reset ();
- Session.Breakpoints.RemoveRunToCursorBreakpoints ();
- var bp = new RunToCursorBreakpoint (SourceFile.Name, line, col);
- Session.Breakpoints.Add (bp);
- Session.Continue ();
- CheckPosition (breakpointMarker, offset, statement);
- }
-
- public void InitializeTest ()
- {
- Session.Breakpoints.Clear ();
- Session.Options.EvaluationOptions = EvaluationOptions.DefaultOptions;
- Session.Options.ProjectAssembliesOnly = true;
- Session.Options.StepOverPropertiesAndOperators = false;
- AddBreakpoint ("break");
- while (!CheckPosition ("break", 0, silent: true)) {
- targetStoppedEvent.Reset ();
- Session.Continue ();
- }
- }
-
- public ObjectValue Eval (string exp)
- {
- return Frame.GetExpressionValue (exp, true).Sync ();
- }
-
- public void WaitStop (int miliseconds)
- {
- if (!targetStoppedEvent.WaitOne (miliseconds)) {
- Assert.Fail ("WaitStop failure: Target stop timeout");
- }
- }
-
- public bool CheckPosition (string guid, int offset = 0, string statement = null, bool silent = false)
- {
- if (!targetStoppedEvent.WaitOne (6000)) {
- if (!silent)
- Assert.Fail ("CheckPosition failure: Target stop timeout");
- return false;
- }
- if (lastStoppedPosition.FileName == SourceFile.Name) {
- int i = SourceFile.Text.IndexOf ("/*" + guid + "*/", StringComparison.Ordinal);
- if (i == -1) {
- if (!silent)
- Assert.Fail ("CheckPosition failure: Guid marker not found:" + guid + " in file:" + SourceFile.Name);
- return false;
- }
- int line, col;
- SourceFile.GetLineColumnFromPosition (i, out line, out col);
- if ((line + offset) != lastStoppedPosition.Line) {
- if (!silent)
- Assert.Fail ("CheckPosition failure: Wrong line Expected:" + (line + offset) + " Actual:" + lastStoppedPosition.Line + " in file:" + SourceFile.Name);
- return false;
- }
- if (!string.IsNullOrEmpty (statement)) {
- int position = SourceFile.GetPositionFromLineColumn (lastStoppedPosition.Line, lastStoppedPosition.Column);
- string actualStatement = SourceFile.GetText (position, position + statement.Length);
- if (statement != actualStatement) {
- if (!silent)
- Assert.AreEqual (statement, actualStatement);
- return false;
- }
- }
- } else {
- if (!silent)
- Assert.Fail ("CheckPosition failure: Wrong file Excpected:" + SourceFile.Name + " Actual:" + lastStoppedPosition.FileName);
- return false;
- }
- return true;
- }
-
- public void StepIn (string guid, string statement)
- {
- StepIn (guid, 0, statement);
- }
-
- public void StepIn (string guid, int offset = 0, string statement = null)
- {
- targetStoppedEvent.Reset ();
- Session.StepInstruction ();
- CheckPosition (guid, offset, statement);
- }
-
- public void StepOver (string guid, string statement)
- {
- StepOver (guid, 0, statement);
- }
-
- public void StepOver (string guid, int offset = 0, string statement = null)
- {
- targetStoppedEvent.Reset ();
- Session.NextInstruction ();
- CheckPosition (guid, offset, statement);
- }
-
- public void StepOut (string guid, string statement)
- {
- StepOut (guid, 0, statement);
- }
-
- public void StepOut (string guid, int offset = 0, string statement = null)
- {
- targetStoppedEvent.Reset ();
- Session.Finish ();
- CheckPosition (guid, offset, statement);
- }
-
- public void Continue (string guid, string statement)
- {
- Continue (guid, 0, statement);
- }
-
- public void Continue (string guid, int offset = 0, string statement = null)
- {
- targetStoppedEvent.Reset ();
- Session.Continue ();
- CheckPosition (guid, offset, statement);
- }
-
- public void StartTest (string methodName)
- {
- if (!targetStoppedEvent.WaitOne (3000)) {
- Assert.Fail ("StartTest failure: Target stop timeout");
- }
- Assert.AreEqual ('"' + methodName + '"', Eval ("NextMethodToCall = \"" + methodName + "\";").Value);
- targetStoppedEvent.Reset ();
- Session.Continue ();
- }
-
- public void SetNextStatement (string guid, int offset = 0, string statement = null)
- {
- int line, column;
- GetLineAndColumn (guid, offset, statement, out line, out column);
- Session.SetNextStatement (SourceFile.Name, line, column);
- }
-
- public void AddCatchpoint (string exceptionName, bool includeSubclasses)
- {
- Session.Breakpoints.Add (new Catchpoint (exceptionName, includeSubclasses));
- }
- }
-
- static class EvalHelper
- {
- public static bool AtLeast (this Version ver, int major, int minor) {
- if ((ver.Major > major) || ((ver.Major == major && ver.Minor >= minor)))
- return true;
- else
- return false;
- }
-
- public static ObjectValue Sync (this ObjectValue val)
- {
- if (!val.IsEvaluating)
- return val;
-
- object locker = new object ();
- EventHandler h = delegate {
- lock (locker) {
- Monitor.PulseAll (locker);
- }
- };
-
- val.ValueChanged += h;
-
- lock (locker) {
- while (val.IsEvaluating) {
- if (!Monitor.Wait (locker, 8000))
- throw new Exception ("Timeout while waiting for value evaluation");
- }
- }
-
- val.ValueChanged -= h;
- return val;
- }
-
- public static ObjectValue GetChildSync (this ObjectValue val, string name, EvaluationOptions ops)
- {
- var result = val.GetChild (name, ops);
-
- return result != null ? result.Sync () : null;
- }
-
- public static ObjectValue[] GetAllChildrenSync (this ObjectValue val)
- {
- var children = val.GetAllChildren ();
- foreach (var child in children) {
- child.Sync ();
- }
- return children;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/EvaluationTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/EvaluationTests.cs
deleted file mode 100644
index ffda5ad636..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/EvaluationTests.cs
+++ /dev/null
@@ -1,2459 +0,0 @@
-//
-// EvaluationTests.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// 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.
-
-using System;
-
-using Mono.Debugging.Client;
-using NUnit.Framework;
-using Mono.Debugging.Soft;
-
-namespace MonoDevelop.Debugger.Tests
-{
- [TestFixture]
- public abstract class EvaluationTests: DebugTests
- {
- protected EvaluationTests (string de, bool allowTargetInvokes) : base (de)
- {
- AllowTargetInvokes = allowTargetInvokes;
- }
-
- [TestFixtureSetUp]
- public override void SetUp ()
- {
- base.SetUp ();
-
- Start ("TestEvaluation");
- Session.TypeResolverHandler = ResolveType;
- }
-
- static string ResolveType (string identifier, SourceLocation location)
- {
- switch (identifier) {
- case "SomeClassInNamespace":
- return "MonoDevelop.Debugger.Tests.TestApp.SomeClassInNamespace";
- case "ParentNestedClass":
- return "MonoDevelop.Debugger.Tests.TestApp.TestEvaluationParent.ParentNestedClass";
- case "NestedClass":
- return "MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.NestedClass";
- case "TestEvaluation":
- return "MonoDevelop.Debugger.Tests.TestApp.TestEvaluation";
- case "NestedGenericClass`2":
- return "MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.NestedGenericClass";
- case "Dictionary`2":
- return "System.Collections.Generic.Dictionary";
- case "Thing`1":
- return "Thing";
- case "A":
- return "A";
- case "B":
- return "B";
- case "C":
- return "C";
- case "System":
- return "System";
- case "MonoDevelop":
- return "MonoDevelop";
- case "SomeEnum":
- return "SomeEnum";
- case "IFoo":
- return "MonoDevelop.Debugger.Tests.TestApp.IFoo";
- case "IBar":
- return "MonoDevelop.Debugger.Tests.TestApp.IBar";
- case "Bo":
- return "MonoDevelop.Debugger.Tests.TestApp.Bo";
- }
- return null;
- }
-
- [Test]
- public void This ()
- {
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- ObjectValue val = Eval ("this");
- Assert.AreEqual ("{MonoDevelop.Debugger.Tests.TestApp.TestEvaluationChild}", val.Value);
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluationChild", val.TypeName);
- }
-
- [Test]
- public void UnaryOperators ()
- {
- ObjectValue val = Eval ("~1234");
- Assert.AreEqual ((~1234).ToString (), val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("!true");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("!false");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("-1234");
- Assert.AreEqual ("-1234", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("+1234");
- Assert.AreEqual ("1234", val.Value);
- Assert.AreEqual ("int", val.TypeName);
- }
-
- [Test]
- public void TypeReference ()
- {
- ObjectValue val;
- val = Eval ("System.String");
- Assert.AreEqual ("string", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("TestEvaluation");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("A");
- Assert.AreEqual ("A", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("NestedClass");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.NestedClass", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("NestedClass.DoubleNestedClass");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.NestedClass.DoubleNestedClass", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("ParentNestedClass");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluationParent.ParentNestedClass", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("SomeClassInNamespace");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.SomeClassInNamespace", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("ClassWithCompilerGeneratedNestedClass");
- Assert.AreEqual ("ClassWithCompilerGeneratedNestedClass", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
- var children = val.GetAllChildrenSync ();
- Assert.AreEqual (2, children.Length);
- Assert.AreEqual ("ClassWithCompilerGeneratedNestedClass.NestedClass", children [0].Value);
- Assert.AreEqual ("<type>", children [0].TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, children [0].Flags & ObjectValueFlags.OriginMask);
- }
-
- [Test]
- public virtual void HiddenMembers ()
- {
- IgnoreCorDebugger ("TODO");
- if (Session is SoftDebuggerSession) {
- if (!((SoftDebuggerSession)Session).ProtocolVersion.AtLeast (2, 40)) {
- Assert.Ignore ("Need newer Mono with SDB protocol 2.40+");
- }
- }
- ObjectValue val;
- val = Eval ("HiddenField");
- Assert.AreEqual ("5", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("HiddenProperty");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("5", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("HiddenMethod()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("5", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("OverridenPropertyInt");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("6", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("OverridenMethodInt()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("6", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("OverridenPropertyString");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"6\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("OverridenMethodString()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"6\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
-
-
- val = Eval ("testEvaluationChild.HiddenField");
- Assert.AreEqual ("6", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("testEvaluationChild.HiddenProperty");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("6", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("testEvaluationChild.HiddenMethod()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("6", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("testEvaluationChild.OverridenPropertyInt");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("6", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("testEvaluationChild.OverridenMethodInt()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("6", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("testEvaluationChild.OverridenPropertyString");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"6\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("testEvaluationChild.OverridenMethodString()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"6\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
- }
-
- [Test]
- public virtual void TypeReferenceGeneric ()
- {
- ObjectValue val;
- val = Eval ("System.Collections.Generic.Dictionary<string,int>");
- Assert.AreEqual ("System.Collections.Generic.Dictionary<string,int>", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- val = Eval ("Thing<string>.Done<int>");
- Assert.AreEqual ("Thing<string>.Done<int>", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
- }
-
- [Test]
- public virtual void Typeof ()
- {
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- var val = Eval ("typeof(System.Console)");
- Assert.IsTrue (val.TypeName == "System.MonoType" || val.TypeName == "System.RuntimeType", "Incorrect type name: " + val.TypeName);
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.Value == "{System.MonoType}" || val.Value == "{System.RuntimeType}");
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("{System.Console}", val.Value);
- }
-
- [Test]
- public void MethodInvoke ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("TestMethod ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("TestMethod (\"23\")");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("24", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("TestMethod (42)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("43", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("TestMethod (false)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("2", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("this.TestMethod ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("this.TestMethod (\"23\")");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("24", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("this.TestMethod (42)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("43", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("System.Int32.Parse (\"67\")");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("67", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("this.BoxingTestMethod (43)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"43\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("objWithMethodA.MethodA()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"AbstractImplementation\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- IgnoreCorDebugger("TODO: CorDebugger support explicit interfaces");
-
- val = Eval ("((IInterfaceWithMethodA)objWithMethodA).MethodA()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"InterfaceImplementation\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("true.ToString()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
-
- Assert.AreEqual ("\"True\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
- }
-
- [Test]
- public void GenericMethodInvoke ()
- {
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- if (Session.GetType ().Name == "CorDebuggerSession")
- Assert.Ignore ("TODO: Win32 support generic invokes");
-
- if (!AllowTargetInvokes)
- return;
-
- ObjectValue val;
- val = Eval ("done.ReturnInt5()");
- Assert.AreEqual ("5", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("done.ReturnSame(3)");
- Assert.AreEqual ("3", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("ReturnSame(4)");
- Assert.AreEqual ("4", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("ReturnSame(\"someString\")");
- Assert.AreEqual ("\"someString\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("ReturnNew<WithToString>()");
- Assert.AreEqual ("{SomeString}", val.Value);
- Assert.AreEqual ("WithToString", val.TypeName);
-
- val = Eval ("intZero");
- Assert.AreEqual ("0", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("intOne");
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- // TODO: in, out, and ref params are not currently supported
- //val = Eval ("Swap (ref intZero, ref intOne)");
- //Assert.AreEqual ("", val.Value);
-
- //val = Eval ("intZero");
- //Assert.AreEqual ("1", val.Value);
- //Assert.AreEqual ("int", val.TypeName);
-
- //val = Eval ("intOne");
- //Assert.AreEqual ("0", val.Value);
- //Assert.AreEqual ("int", val.TypeName);
-
- //Lets return in same state as before in case some other test will use
- //val = Eval ("Swap (ref intZero, ref intOne)");
- //Assert.AreEqual ("", val.Value);
-
- val = Eval ("GenerateList(\"someString\", 5)");
- Assert.AreEqual ("Count=5", val.Value.Replace (" ", ""));//Remove spaces is for references source and old mono compatiblity
- Assert.AreEqual ("System.Collections.Generic.List<string>", val.TypeName);
-
- val = Eval ("GenerateList(2.0, 6)");
- Assert.AreEqual ("Count=6", val.Value.Replace (" ", ""));//Remove spaces is for references source and old mono compatiblity
- Assert.AreEqual ("System.Collections.Generic.List<double>", val.TypeName);
-
- val = Eval ("done.GetDefault()");
- Assert.AreEqual ("0", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("done.GetParentDefault()");
- Assert.AreEqual ("(null)", val.Value);
- Assert.AreEqual ("object", val.TypeName);
-
- val = Eval ("new Dictionary<int,string>()");
- Assert.AreEqual ("Count=0", val.Value.Replace (" ", ""));//Remove spaces is for references source and old mono compatiblity
- Assert.AreEqual ("System.Collections.Generic.Dictionary<int,string>", val.TypeName);
-
- val = Eval ("done.Property");
- Assert.AreEqual ("54", val.Value);
- Assert.AreEqual ("int", val.TypeName);
- }
-
- [Test]
- public void Indexers ()
- {
- ObjectValue val = Eval ("numbers[0]");
- Assert.AreEqual ("\"one\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("numbers[1]");
- Assert.AreEqual ("\"two\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("numbers[2]");
- Assert.AreEqual ("\"three\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("staticString[2]");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("'m'", val.Value);
- Assert.AreEqual ("char", val.TypeName);
-
- val = Eval ("alist[0]");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("alist[1]");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"two\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("alist[2]");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("3", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- IgnoreCorDebugger("TODO: CorDebugger support explicit interfaces");
-
- val = Eval ("FooBar[2]");
- Assert.IsTrue (val.IsUnknown);
- //We have IFoo and IBar implementation but without typecasting and determening which implementation user wants
- //we have to return error/Unknown instead of random implementation(FooBar[2] is not compilable anyway)
- val = Eval ("((IFoo)FooBar)[2]");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("2", val.Value);
- val = Eval ("((IBar)FooBar)[2]");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("-2", val.Value);
- val = Eval ("Bar[3]");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("-3", val.Value);
- val = Eval ("Foo[3]");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("3", val.Value);
- }
-
- void CheckValue (string expected, string actual, bool isSimpleProperty)
- {
- if (AllowTargetInvokes || isSimpleProperty)
- Assert.AreEqual (expected, actual);
- else
- Assert.AreEqual ("Implicit evaluation is disabled", actual);
- }
-
- [Test]
- public void MemberReference ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("\"someString\".Length");
- if (!AllowTargetInvokes && soft == null) {
- // Note: this is a simple property which gets evaluated client-side by the SDB backend
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("10", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("numbers.Length");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("3", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("\"someString\".GetHashCode()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("numbers.GetHashCode()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("\"someString\".EndsWith (\"ing\")");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("alist.Count");
- if (!AllowTargetInvokes) {
- // Note: this is a simple property which gets evaluated client-side by the SDB backend
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("3", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- Eval ("var tt = this");
-
- // FIXME: this errors out when target invokes are disabled
- if (AllowTargetInvokes) {
- val = Eval ("tt.someString");
- Assert.AreEqual ("\"hi\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
- }
-
- val = Eval ("MonoDevelop.Debugger.Tests");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests", val.Value);
- Assert.AreEqual ("<namespace>", val.TypeName);
-
- val = Eval ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
-
- val = Eval ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.staticString");
- Assert.AreEqual ("\"some static\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("richObject");
- Assert.AreEqual ("{RichClass}", val.Value);
- Assert.AreEqual ("RichClass", val.TypeName);
-
- var richChildren = val.GetAllChildrenSync ();
- Assert.AreEqual (13, richChildren.Length);
- Assert.AreEqual ("publicInt1", richChildren [0].Name);
- Assert.AreEqual ("int", richChildren [0].TypeName);
- Assert.AreEqual ("1", richChildren [0].Value);
- Assert.AreEqual ("publicInt2", richChildren [1].Name);
- Assert.AreEqual ("int", richChildren [1].TypeName);
- Assert.AreEqual ("2", richChildren [1].Value);
- Assert.AreEqual ("publicInt3", richChildren [2].Name);
- Assert.AreEqual ("int", richChildren [2].TypeName);
- Assert.AreEqual ("3", richChildren [2].Value);
- Assert.AreEqual ("publicPropInt1", richChildren [3].Name);
- Assert.AreEqual ("int", richChildren [3].TypeName);
- CheckValue ("1", richChildren [3].Value, soft != null);
- Assert.AreEqual ("publicPropInt2", richChildren [4].Name);
- Assert.AreEqual ("int", richChildren [4].TypeName);
- CheckValue ("2", richChildren [4].Value, soft != null);
- Assert.AreEqual ("publicPropInt3", richChildren [5].Name);
- Assert.AreEqual ("int", richChildren [5].TypeName);
- CheckValue ("3", richChildren [5].Value, soft != null);
- Assert.AreEqual ("publicPropStringA", richChildren [6].Name);
- Assert.AreEqual ("string", richChildren [6].TypeName);
- CheckValue ("\"stringA\"", richChildren [6].Value, soft != null);
- Assert.AreEqual ("publicPropStringB", richChildren [7].Name);
- Assert.AreEqual ("string", richChildren [7].TypeName);
- CheckValue ("\"stringB\"", richChildren [7].Value, soft != null);
- Assert.AreEqual ("publicPropStringC", richChildren [8].Name);
- Assert.AreEqual ("string", richChildren [8].TypeName);
- CheckValue ("\"stringC\"", richChildren [8].Value, soft != null);
- Assert.AreEqual ("publicStringA", richChildren [9].Name);
- Assert.AreEqual ("string", richChildren [9].TypeName);
- Assert.AreEqual ("\"stringA\"", richChildren [9].Value);
- Assert.AreEqual ("publicStringB", richChildren [10].Name);
- Assert.AreEqual ("string", richChildren [10].TypeName);
- Assert.AreEqual ("\"stringB\"", richChildren [10].Value);
- Assert.AreEqual ("publicStringC", richChildren [11].Name);
- Assert.AreEqual ("string", richChildren [11].TypeName);
- Assert.AreEqual ("\"stringC\"", richChildren [11].Value);
- Assert.AreEqual ("Non-public members", richChildren [12].Name);
-
- richChildren = richChildren [12].GetAllChildrenSync ();
- Assert.AreEqual (12, richChildren.Length);
- Assert.AreEqual ("privateInt1", richChildren [0].Name);
- Assert.AreEqual ("int", richChildren [0].TypeName);
- Assert.AreEqual ("1", richChildren [0].Value);
- Assert.AreEqual ("privateInt2", richChildren [1].Name);
- Assert.AreEqual ("int", richChildren [1].TypeName);
- Assert.AreEqual ("2", richChildren [1].Value);
- Assert.AreEqual ("privateInt3", richChildren [2].Name);
- Assert.AreEqual ("int", richChildren [2].TypeName);
- Assert.AreEqual ("3", richChildren [2].Value);
- Assert.AreEqual ("privatePropInt1", richChildren [3].Name);
- Assert.AreEqual ("int", richChildren [3].TypeName);
- CheckValue ("1", richChildren [3].Value, soft != null);
- Assert.AreEqual ("privatePropInt2", richChildren [4].Name);
- Assert.AreEqual ("int", richChildren [4].TypeName);
- CheckValue ("2", richChildren [4].Value, soft != null);
- Assert.AreEqual ("privatePropInt3", richChildren [5].Name);
- Assert.AreEqual ("int", richChildren [5].TypeName);
- CheckValue ("3", richChildren [5].Value, soft != null);
- Assert.AreEqual ("privatePropStringA", richChildren [6].Name);
- Assert.AreEqual ("string", richChildren [6].TypeName);
- CheckValue ("\"stringA\"", richChildren [6].Value, soft != null);
- Assert.AreEqual ("privatePropStringB", richChildren [7].Name);
- Assert.AreEqual ("string", richChildren [7].TypeName);
- CheckValue ("\"stringB\"", richChildren [7].Value, soft != null);
- Assert.AreEqual ("privatePropStringC", richChildren [8].Name);
- Assert.AreEqual ("string", richChildren [8].TypeName);
- CheckValue ("\"stringC\"", richChildren [8].Value, soft != null);
- Assert.AreEqual ("privateStringA", richChildren [9].Name);
- Assert.AreEqual ("string", richChildren [9].TypeName);
- Assert.AreEqual ("\"stringA\"", richChildren [9].Value);
- Assert.AreEqual ("privateStringB", richChildren [10].Name);
- Assert.AreEqual ("string", richChildren [10].TypeName);
- Assert.AreEqual ("\"stringB\"", richChildren [10].Value);
- Assert.AreEqual ("privateStringC", richChildren [11].Name);
- Assert.AreEqual ("string", richChildren [11].TypeName);
- Assert.AreEqual ("\"stringC\"", richChildren [11].Value);
-
- if (AllowTargetInvokes) {
- val = Eval ("richObject.publicStringB=\"changedTextB\"");
- Assert.AreEqual ("string", val.TypeName);
- Assert.AreEqual ("\"changedTextB\"", val.Value);
- val = Eval ("richObject.publicStringB");
- Assert.AreEqual ("string", val.TypeName);
- Assert.AreEqual ("\"changedTextB\"", val.Value);
-
- val = Eval ("richObject");
- Assert.AreEqual ("{RichClass}", val.Value);
- Assert.AreEqual ("RichClass", val.TypeName);
- richChildren = val.GetAllChildrenSync ();
- Assert.AreEqual ("publicPropStringB", richChildren [7].Name);
- Assert.AreEqual ("string", richChildren [7].TypeName);
- Assert.AreEqual ("\"stringB\"", richChildren [7].Value);
- }
-
- val = Eval ("numbers.GetLength(0)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("3", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- IgnoreCorDebugger("TODO: CorDebugger support explicit interfaces");
-
- val = Eval ("Bar.Prop");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("1", val.Value);
- val = Eval ("Foo.Prop");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("2", val.Value);
- val = Eval ("FooBar.Prop");
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("3", val.Value);
- val = Eval ("((Bo)FooBar).Prop");
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("4", val.Value);
- val = Eval ("FooBar");
- richChildren = val.GetAllChildrenSync ();
- Assert.AreEqual ("Prop (MonoDevelop.Debugger.Tests.TestApp.FooBar)", richChildren [0].Name);
- Assert.AreEqual ("int", richChildren [0].TypeName);
- Assert.AreEqual ("3", richChildren [0].Value);
- Assert.AreEqual ("Prop (MonoDevelop.Debugger.Tests.TestApp.Bo)", richChildren [1].Name);
- Assert.AreEqual ("int", richChildren [1].TypeName);
- Assert.AreEqual ("4", richChildren [1].Value);
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (richChildren [2].IsImplicitNotSupported);
- richChildren [2].Refresh (options);
- richChildren [2] = richChildren [2].Sync ();
- Assert.IsTrue (richChildren [3].IsImplicitNotSupported);
- richChildren [3].Refresh (options);
- richChildren [3] = richChildren [3].Sync ();
- }
- //TODO: Include interface names into sorting
- if ("Prop (MonoDevelop.Debugger.Tests.TestApp.IFoo)" == richChildren [2].Name) {
- Assert.AreEqual ("Prop (MonoDevelop.Debugger.Tests.TestApp.IFoo)", richChildren [2].Name);
- Assert.AreEqual ("int", richChildren [2].TypeName);
- Assert.AreEqual ("2", richChildren [2].Value);
- Assert.AreEqual ("Prop (MonoDevelop.Debugger.Tests.TestApp.IBar)", richChildren [3].Name);
- Assert.AreEqual ("int", richChildren [3].TypeName);
- Assert.AreEqual ("1", richChildren [3].Value);
- } else {
- Assert.AreEqual ("Prop (MonoDevelop.Debugger.Tests.TestApp.IFoo)", richChildren [3].Name);
- Assert.AreEqual ("int", richChildren [3].TypeName);
- Assert.AreEqual ("2", richChildren [3].Value);
- Assert.AreEqual ("Prop (MonoDevelop.Debugger.Tests.TestApp.IBar)", richChildren [2].Name);
- Assert.AreEqual ("int", richChildren [2].TypeName);
- Assert.AreEqual ("1", richChildren [2].Value);
- }
- }
-
- [Test]
- public void NullableEquality ()
- {
- var val = Eval ("nullableBool == null");
- Assert.AreEqual ("false", val.Value);
-
- val = Eval ("nullableBool != null");
- Assert.AreEqual ("true", val.Value);
-
- val = Eval ("nullableBool != false");
- Assert.AreEqual ("true", val.Value);
-
- val = Eval ("nullableBool == true");
- Assert.AreEqual ("true", val.Value);
- }
-
- [Test]
- public void ConditionalExpression ()
- {
- ObjectValue val = Eval ("true ? \"yes\" : \"no\"");
- Assert.AreEqual ("\"yes\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("false ? \"yes\" : \"no\"");
- Assert.AreEqual ("\"no\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
- }
-
- [Test]
- public void Cast ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("(int)19.7");
- Assert.AreEqual ("19", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("(byte)n");
- Assert.AreEqual ("32", val.Value);
- Assert.AreEqual ("byte", val.TypeName);
-
- val = Eval ("(int)n");
- Assert.AreEqual ("32", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("(long)n");
- Assert.AreEqual ("32", val.Value);
- Assert.AreEqual ("long", val.TypeName);
-
- val = Eval ("(float)n");
- Assert.AreEqual ("32", val.Value);
- Assert.AreEqual ("float", val.TypeName);
-
- val = Eval ("(double)n");
- Assert.AreEqual ("32", val.Value);
- Assert.AreEqual ("double", val.TypeName);
-
- val = Eval ("(string)staticString");
- Assert.AreEqual ("\"some static\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("(int)numbers");
- Assert.IsTrue (val.IsError);
-
- val = Eval ("(int)this");
- Assert.IsTrue (val.IsError);
-
- val = Eval ("(C)a");
- Assert.IsTrue (val.IsError);
-
- val = Eval ("(C)b");
- Assert.IsTrue (val.IsError);
-
- val = Eval ("(C)c");
- Assert.AreEqual ("{C}", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- val = Eval ("(B)a");
- Assert.IsTrue (val.IsError);
-
- val = Eval ("(B)b");
- Assert.AreEqual ("{B}", val.Value);
- Assert.AreEqual ("B", val.TypeName);
-
- val = Eval ("(B)c");
- Assert.AreEqual ("{C}", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- val = Eval ("(A)a");
- Assert.AreEqual ("{A}", val.Value);
- Assert.AreEqual ("A", val.TypeName);
-
- val = Eval ("(A)b");
- Assert.AreEqual ("{B}", val.Value);
- Assert.AreEqual ("B", val.TypeName);
-
- val = Eval ("(A)c");
- Assert.AreEqual ("{C}", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- // Try cast
-
- val = Eval ("c as A");
- Assert.AreEqual ("{C}", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- val = Eval ("c as B");
- Assert.AreEqual ("{C}", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- val = Eval ("c as C");
- Assert.AreEqual ("{C}", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- val = Eval ("b as A");
- Assert.AreEqual ("{B}", val.Value);
- Assert.AreEqual ("B", val.TypeName);
-
- val = Eval ("b as B");
- Assert.AreEqual ("{B}", val.Value);
- Assert.AreEqual ("B", val.TypeName);
-
- val = Eval ("b as C");
- Assert.AreEqual ("null", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- val = Eval ("a as A");
- Assert.AreEqual ("{A}", val.Value);
- Assert.AreEqual ("A", val.TypeName);
-
- val = Eval ("a as B");
- Assert.AreEqual ("null", val.Value);
- Assert.AreEqual ("B", val.TypeName);
-
- val = Eval ("a as C");
- Assert.AreEqual ("null", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- val = Eval ("a as string");
- Assert.AreEqual ("null", val.Value);
- Assert.AreEqual ("System.String", val.TypeName);
-
-
- // Is operator
-
- val = Eval ("c is A");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("c is B");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("c is C");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("b is A");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("b is B");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("b is C");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("a is A");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("a is B");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("a is C");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("a is string");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- // Enum cast
-
- val = Eval ("(int)SomeEnum.two");
- Assert.AreEqual ("2", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("(long)SomeEnum.two");
- Assert.AreEqual ("2", val.Value);
- Assert.AreEqual ("long", val.TypeName);
-
- val = Eval ("(SomeEnum)2");
- Assert.AreEqual ("SomeEnum.two", val.Value);
- Assert.AreEqual ("two", val.DisplayValue);
- Assert.AreEqual ("SomeEnum", val.TypeName);
-
- val = Eval ("(SomeEnum)3");
- Assert.AreEqual ("SomeEnum.one | SomeEnum.two", val.Value);
- Assert.AreEqual ("one | two", val.DisplayValue);
- Assert.AreEqual ("SomeEnum", val.TypeName);
-
- IgnoreCorDebugger ("CorDebugger: Implicit casting");
-
- // Casting primitive <-> custom class via implicit operator
- val = Eval ("(myNint)3");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("{3}", val.Value);
- Assert.AreEqual ("myNint", val.TypeName);
-
- val = Eval ("(int)(myNint)4");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("4", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("TestCastingArgument(4)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"4\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("new RichClass(5).publicPropInt1");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("5", val.Value);
- Assert.AreEqual ("int", val.TypeName);
- }
-
- [Test]
- public void BinaryOperators ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- // Boolean
-
- val = Eval ("true && true");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("true && false");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("false && true");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("false && false");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("false || false");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("false || true");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("true || false");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("true || true");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("false || 1");
- Assert.IsTrue (val.IsError);
-
- val = Eval ("1 || true");
- Assert.IsTrue (val.IsError);
-
- val = Eval ("true && 1");
- Assert.IsTrue (val.IsError);
-
- val = Eval ("1 && true");
- Assert.IsTrue (val.IsError);
-
- // Concat string
-
- val = Eval ("\"a\" + \"b\"");
- Assert.AreEqual ("\"ab\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("\"a\" + 2");
- Assert.AreEqual ("\"a2\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("2 + \"a\"");
- Assert.AreEqual ("\"2a\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("this + \"a\"");
- Assert.AreEqual ("\"MonoDevelop.Debugger.Tests.TestApp.TestEvaluationChilda\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- // Equality
-
- val = Eval ("2 == 2");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("2 == 3");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("(long)2 == (int)2");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("SomeEnum.two == SomeEnum.one");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("SomeEnum.one != SomeEnum.one");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- // Arithmetic
-
- val = Eval ("2 + 3");
- Assert.AreEqual ("5", val.Value);
-
- val = Eval ("2 + 2 == 4");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("(2 * 1.5f) / 2");
- Assert.AreEqual ("1.5", val.Value);
- Assert.AreEqual ("float", val.TypeName);
- }
-
- [Test]
- public void BinaryOperatorOverrides ()
- {
- ObjectValue val;
-
- if (!AllowTargetInvokes)
- return;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("Requires a newer version of the Mono runtime.");
-
- val = Eval ("ops1 == ops3");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("ops1 != ops3");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("ops2 == ops3");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("ops2 != ops3");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("ops1 <= ops2");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("ops1 < ops2");
- Assert.AreEqual ("true", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("ops1 >= ops2");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("ops1 > ops2");
- Assert.AreEqual ("false", val.Value);
- Assert.AreEqual ("bool", val.TypeName);
-
- val = Eval ("ops1 + ops2");
- Assert.AreEqual ("{[BinaryOperatorOverrides 3]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops1 - ops2");
- Assert.AreEqual ("{[BinaryOperatorOverrides -1]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops1 * ops2");
- Assert.AreEqual ("{[BinaryOperatorOverrides 2]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops2 / ops1");
- Assert.AreEqual ("{[BinaryOperatorOverrides 2]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops1 % ops2");
- Assert.AreEqual ("{[BinaryOperatorOverrides 1]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops1 & ops2");
- Assert.AreEqual ("{[BinaryOperatorOverrides 0]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops1 | ops2");
- Assert.AreEqual ("{[BinaryOperatorOverrides 3]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops1 ^ ops2");
- Assert.AreEqual ("{[BinaryOperatorOverrides 3]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops1 << 1");
- Assert.AreEqual ("{[BinaryOperatorOverrides 2]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
-
- val = Eval ("ops2 >> 1");
- Assert.AreEqual ("{[BinaryOperatorOverrides 1]}", val.Value);
- Assert.AreEqual ("BinaryOperatorOverrides", val.TypeName);
- }
-
- void AssertAssignment (string assignment, string variable, string value, string type)
- {
- ObjectValue val;
-
- val = Eval (assignment);
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
-
- Assert.AreEqual (value, val.Value);
- Assert.AreEqual (type, val.TypeName);
-
- val = Eval (variable);
- if (!AllowTargetInvokes && val.IsImplicitNotSupported) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- val.Refresh (options);
- val = val.Sync ();
- }
-
- Assert.AreEqual (value, val.Value);
- Assert.AreEqual (type, val.TypeName);
- }
-
- [Test]
- public void MethodParameters ()
- {
- ObjectValue val;
- val = Eval ("stringParam");
- Assert.AreEqual ("\"testString\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- val = Eval ("intParam");
- Assert.AreEqual ("55", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("intParam2");
- Assert.AreEqual ("66", val.Value);
- Assert.AreEqual ("int", val.TypeName);
- }
-
- [Test]
- public virtual void Assignment ()
- {
- AssertAssignment ("n = 6", "n", "6", "int");
- AssertAssignment ("n = 32", "n", "32", "int");
-
- AssertAssignment ("someString = \"test\"", "someString", "\"test\"", "string");
- AssertAssignment ("someString = \"hi\"", "someString", "\"hi\"", "string");
-
- AssertAssignment ("numbers[0] = \"test\"", "numbers[0]", "\"test\"", "string");
- AssertAssignment ("numbers[0] = \"one\"", "numbers[0]", "\"one\"", "string");
-
- AssertAssignment ("alist[0] = 6", "alist[0]", "6", "int");
- AssertAssignment ("alist[0] = 1", "alist[0]", "1", "int");
-
- AssertAssignment ("ProtectedStringProperty = \"test\"", "ProtectedStringProperty", "\"test\"", "string");
- AssertAssignment ("ProtectedStringProperty = \"hi\"", "ProtectedStringProperty", "\"hi\"", "string");
- }
-
- [Test]
- public virtual void AssignmentStatic ()
- {
- AssertAssignment ("staticString = \"test\"", "staticString", "\"test\"", "string");
- AssertAssignment ("staticString = \"some static\"", "staticString", "\"some static\"", "string");
- }
-
- [Test]
- public void FormatBool ()
- {
- ObjectValue val;
-
- val = Eval ("true");
- Assert.AreEqual ("true", val.Value);
-
- val = Eval ("false");
- Assert.AreEqual ("false", val.Value);
- }
-
- [Test]
- public void FormatNumber ()
- {
- ObjectValue val;
- val = Eval ("(int)123");
- Assert.AreEqual ("123", val.Value);
- val = Eval ("(int)-123");
- Assert.AreEqual ("-123", val.Value);
-
- val = Eval ("(long)123");
- Assert.AreEqual ("123", val.Value);
- val = Eval ("(long)-123");
- Assert.AreEqual ("-123", val.Value);
-
- val = Eval ("(byte)123");
- Assert.AreEqual ("123", val.Value);
-
- val = Eval ("(uint)123");
- Assert.AreEqual ("123", val.Value);
-
- val = Eval ("(ulong)123");
- Assert.AreEqual ("123", val.Value);
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- return;
-
- val = Eval ("dec");
- Assert.AreEqual ("123.456", val.Value);
- }
-
- [Test]
- public void FormatString ()
- {
- ObjectValue val;
- val = Eval ("\"hi\"");
- Assert.AreEqual ("\"hi\"", val.Value);
-
- val = Eval ("EscapedStrings");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\" \\\" \\\\ \\a \\b \\f \\v \\n \\r \\t\"", val.Value);
-
- val = Eval ("\" \\\" \\\\ \\a \\b \\f \\v \\n \\r \\t\"");
- Assert.AreEqual ("\" \\\" \\\\ \\a \\b \\f \\v \\n \\r \\t\"", val.Value);
- }
-
- [Test]
- public void FormatChar ()
- {
- ObjectValue val;
- val = Eval ("'A'");
- Assert.AreEqual ("'A'", val.Value);
- Assert.AreEqual ("65 'A'", val.DisplayValue);
-
- val = Eval ("'\\0'");
- Assert.AreEqual ("'\\0'", val.Value);
- Assert.AreEqual ("0 '\\0'", val.DisplayValue);
-
- val = Eval ("'\"'");
- Assert.AreEqual ("'\"'", val.Value);
- Assert.AreEqual ("34 '\"'", val.DisplayValue);
-
- val = Eval ("'\\''");
- Assert.AreEqual ("'\\''", val.Value);
- Assert.AreEqual ("39 '\\''", val.DisplayValue);
-
- val = Eval ("'\\\\'");
- Assert.AreEqual ("'\\\\'", val.Value);
- Assert.AreEqual ("92 '\\\\'", val.DisplayValue);
-
- val = Eval ("'\\a'");
- Assert.AreEqual ("'\\a'", val.Value);
- Assert.AreEqual ("7 '\\a'", val.DisplayValue);
-
- val = Eval ("'\\b'");
- Assert.AreEqual ("'\\b'", val.Value);
- Assert.AreEqual ("8 '\\b'", val.DisplayValue);
-
- val = Eval ("'\\f'");
- Assert.AreEqual ("'\\f'", val.Value);
- Assert.AreEqual ("12 '\\f'", val.DisplayValue);
-
- val = Eval ("'\\v'");
- Assert.AreEqual ("'\\v'", val.Value);
- Assert.AreEqual ("11 '\\v'", val.DisplayValue);
-
- val = Eval ("'\\n'");
- Assert.AreEqual ("'\\n'", val.Value);
- Assert.AreEqual ("10 '\\n'", val.DisplayValue);
-
- val = Eval ("'\\r'");
- Assert.AreEqual ("'\\r'", val.Value);
- Assert.AreEqual ("13 '\\r'", val.DisplayValue);
-
- val = Eval ("'\\t'");
- Assert.AreEqual ("'\\t'", val.Value);
- Assert.AreEqual ("9 '\\t'", val.DisplayValue);
- }
-
- [Test]
- public void FormatObject ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("c");
- Assert.AreEqual ("{C}", val.Value);
- Assert.AreEqual ("C", val.TypeName);
-
- val = Eval ("withDisplayString");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.AreEqual ("{WithDisplayString}", val.Value);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("Some one Value 2 End", val.Value);
- Assert.AreEqual ("WithDisplayString", val.TypeName);
-
- val = Eval ("withProxy");
- Assert.AreEqual ("{WithProxy}", val.Value);
- Assert.AreEqual ("WithProxy", val.TypeName);
-
-/* val = Eval ("withToString");
- Assert.AreEqual ("{SomeString}", val.Value);
- Assert.AreEqual ("WithToString", val.TypeName);*/
- }
-
- [Test]
- public void FormatArray ()
- {
- ObjectValue val;
-
- val = Eval ("numbers");
- Assert.AreEqual ("{string[3]}", val.Value);
- Assert.AreEqual ("string[]", val.TypeName);
-
- val = Eval ("numbersArrays");
- Assert.AreEqual ("{int[2][]}", val.Value);
- Assert.AreEqual ("int[][]", val.TypeName);
-
- IgnoreCorDebugger ("Randomly fails");
-
- val = Eval ("arrayWithLowerBounds");
- Assert.AreEqual ("int[,,]", val.TypeName);
- Assert.AreEqual ("{int[3,4,5]}", val.Value);
-
- val = Eval ("numbersMulti");
- Assert.AreEqual ("{int[3,4,5]}", val.Value);
- Assert.AreEqual ("int[,,]", val.TypeName);
- Assert.IsFalse (val.IsNull);
-
- val = Eval ("nulledByteArray");
- Assert.AreEqual ("(null)", val.Value);
- Assert.AreEqual ("byte[]", val.TypeName);
- Assert.IsTrue (val.IsNull);
- }
-
- [Test]
- public void FormatGeneric ()
- {
- ObjectValue val;
-
- try {
- Session.Options.EvaluationOptions.AllowTargetInvoke = false;
- val = Eval ("dict");
- } finally {
- Session.Options.EvaluationOptions.AllowTargetInvoke = AllowTargetInvokes;
- }
- Assert.AreEqual ("{System.Collections.Generic.Dictionary<int,string[]>}", val.Value);
- Assert.AreEqual ("System.Collections.Generic.Dictionary<int,string[]>", val.TypeName);
-
- try {
- Session.Options.EvaluationOptions.AllowTargetInvoke = false;
- val = Eval ("dictArray");
- } finally {
- Session.Options.EvaluationOptions.AllowTargetInvoke = AllowTargetInvokes;
- }
- Assert.AreEqual ("{System.Collections.Generic.Dictionary<int,string[]>[2,3]}", val.Value);
- Assert.AreEqual ("System.Collections.Generic.Dictionary<int,string[]>[,]", val.TypeName);
-
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- return;
-
- val = Eval ("thing.done");
- Assert.AreEqual ("{Thing<string>.Done<int>[1]}", val.Value);
- Assert.AreEqual ("Thing<string>.Done<int>[]", val.TypeName);
-
- val = Eval ("done");
- Assert.AreEqual ("{Thing<string>.Done<int>}", val.Value);
- Assert.AreEqual ("Thing<string>.Done<int>", val.TypeName);
- }
-
- [Test]
- public void FormatEnum ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("SomeEnum.one");
- Assert.AreEqual ("SomeEnum.one", val.Value);
- Assert.AreEqual ("one", val.DisplayValue);
-
- val = Eval ("SomeEnum.two");
- Assert.AreEqual ("SomeEnum.two", val.Value);
- Assert.AreEqual ("two", val.DisplayValue);
-
- val = Eval ("SomeEnum.one | SomeEnum.two");
- Assert.AreEqual ("SomeEnum.one | SomeEnum.two", val.Value);
- Assert.AreEqual ("one | two", val.DisplayValue);
- }
-
- [Test]
- public void LambdaInvoke ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("action");
- Assert.AreEqual ("{System.Action}", val.Value);
- Assert.AreEqual ("System.Action", val.TypeName);
-
- val = Eval ("modifyInLamda");
- Assert.AreEqual ("\"modified\"", val.Value);
- Assert.AreEqual ("string", val.TypeName);
-
- }
-
- [Test]
- public void Structures ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("simpleStruct");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.AreEqual ("{SimpleStruct}", val.Value);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("{str 45 }", val.Value);
- Assert.AreEqual ("SimpleStruct", val.TypeName);
-
- val = Eval ("nulledSimpleStruct");
- Assert.AreEqual ("null", val.Value);
- Assert.AreEqual ("SimpleStruct?", val.TypeName);
- }
-
- [Test]
- [Ignore ("TODO")]
- public void SdbFailingTests ()
- {
- ObjectValue val;
-
- val = Eval ("base.TestMethodBase (\"23\")");
- Assert.AreEqual ("25", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("base.TestMethodBase (42)");
- Assert.AreEqual ("44", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- //When fixed put into TypeReferenceGeneric
- val = Eval ("Dictionary<string,NestedClass>");
- Assert.AreEqual ("System.Collections.Generic.Dictionary<string,MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.NestedClass>", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- //When fixed put into TypeReferenceGeneric
- val = Eval ("NestedGenericClass<int,string>");
- Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.NestedGenericClass<int,string>", val.Value);
- Assert.AreEqual ("<type>", val.TypeName);
- Assert.AreEqual (ObjectValueFlags.Type, val.Flags & ObjectValueFlags.OriginMask);
-
- }
-
- [Test]
- public void ObjectCreation ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("new A().ConstructedBy");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"NoArg\"", val.Value);
-
- val = Eval ("new A(7).ConstructedBy");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"IntArg\"", val.Value);
-
- val = Eval ("new A(\"someString\").ConstructedBy");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("\"StringArg\"", val.Value);
- }
-
- [Test]
- public void StructCreation ()
- {
- if (!AllowTargetInvokes)
- return;
-
- var soft = Session as SoftDebuggerSession;
-
- if (soft == null)
- Assert.Ignore ("TODO: Win32 support generic invokes");
-
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Inconclusive ("A newer version of the Mono runtime is required.");
-
- ObjectValue val;
-
- val = Eval ("new SimpleStruct()");
- Assert.AreEqual ("SimpleStruct", val.TypeName);
- }
-
- [Test]
- public void Inheriting ()
- {
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("a.Prop");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("a.PropNoVirt1");
- if (!AllowTargetInvokes && soft == null) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("a.PropNoVirt2");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("a.IntField");
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("a.TestMethod ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("a.TestMethod (\"23\")");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("24", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("a.TestMethod (42)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("43", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- if (soft != null && soft.ProtocolVersion < new Version (2, 40))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("b.Prop");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("2", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("((B)b).PropNoVirt1");
- if (!AllowTargetInvokes && soft == null) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("2", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("((B)b).PropNoVirt2");
- if (!AllowTargetInvokes && soft == null) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("2", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("((B)b).IntField");
- Assert.AreEqual ("2", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("this.TestMethodBase ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("this.TestMethodBase (\"23\")");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("24", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("this.TestMethodBase (42)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("43", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("this.TestMethodBaseNotOverrided ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("TestMethodBase ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("TestMethodBase (\"23\")");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("24", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("TestMethodBase (42)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("43", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("TestMethodBaseNotOverrided ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("b.TestMethod (\"23\")");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("25", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("base.TestMethodBaseNotOverrided ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval("base.TestMethodBase ()");
- if (!AllowTargetInvokes)
- {
- var options = Session.Options.EvaluationOptions.Clone();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue(val.IsImplicitNotSupported);
- val.Refresh(options);
- val = val.Sync();
- }
- Assert.AreEqual("2", val.Value);
- Assert.AreEqual("int", val.TypeName);
-
- IgnoreCorDebugger("Not working on CorDebugger");
-
- val = Eval("b.PropNoVirt2");
- if (!AllowTargetInvokes)
- {
- var options = Session.Options.EvaluationOptions.Clone();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue(val.IsImplicitNotSupported);
- val.Refresh(options);
- val = val.Sync();
- }
- Assert.AreEqual("1", val.Value);
- Assert.AreEqual("int", val.TypeName);
-
- val = Eval("b.IntField");
- Assert.AreEqual("1", val.Value);
- Assert.AreEqual("int", val.TypeName);
-
- val = Eval("b.PropNoVirt1");
- if (!AllowTargetInvokes && soft == null)
- {
- var options = Session.Options.EvaluationOptions.Clone();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue(val.IsImplicitNotSupported);
- val.Refresh(options);
- val = val.Sync();
- }
- Assert.AreEqual("1", val.Value);
- Assert.AreEqual("int", val.TypeName);
-
- val = Eval ("System.Text.Encoding.UTF8.GetPreamble ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("byte[]", val.TypeName);
- Assert.AreEqual ("{byte[3]}", val.Value);
- var bytes = ((RawValueArray)val.GetRawValue ()).ToArray ();
- Assert.AreEqual (239, bytes.GetValue (0));
- Assert.AreEqual (187, bytes.GetValue (1));
- Assert.AreEqual (191, bytes.GetValue (2));
-
- val = Eval ("b.TestMethod ()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("1", val.Value);
- Assert.AreEqual ("int", val.TypeName);
-
- val = Eval ("b.TestMethod (42)");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.AreEqual ("43", val.Value);
- Assert.AreEqual ("int", val.TypeName);
- }
-
- [Test]
- public void Lists ()
- {
- ObjectValue[] children;
- ObjectValue val;
-
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- val = Eval ("dict");
- children = val.GetAllChildrenSync ();
-
- if (AllowTargetInvokes) {
- // AllowTargetInvokes also allows debugger proxies
- Assert.AreEqual (2, children.Length);
- Assert.AreEqual ("[0]", children [0].Name);
- Assert.AreEqual ("{[5, System.String[]]}", children [0].Value);
- Assert.AreEqual ("Raw View", children [1].Name);
-
- children = children [0].GetAllChildrenSync ();
- Assert.AreEqual ("Key", children [0].Name);
- Assert.AreEqual ("5", children [0].Value);
- Assert.AreEqual ("int", children [0].TypeName);
- Assert.AreEqual ("Value", children [1].Name);
- Assert.AreEqual ("{string[2]}", children [1].Value);
-
- children = children [1].GetAllChildrenSync ();
- Assert.AreEqual ("\"a\"", children [0].Value);
- Assert.AreEqual ("string", children [0].TypeName);
- Assert.AreEqual ("\"b\"", children [1].Value);
- } else {
- // when AllowTargetInvokes is disabled, it also disables debugger proxies
- Assert.AreEqual (18, children.Length);
- Assert.AreEqual ("Comparer", children [0].Name);
- Assert.AreEqual ("Static members", children [15].Name);
- Assert.AreEqual ("Non-public members", children [16].Name);
- Assert.AreEqual ("IEnumerator", children [17].Name);
- }
-
- val = Eval ("stringList");
- children = val.GetAllChildrenSync ();
-
- if (AllowTargetInvokes) {
- // AllowTargetInvokes also allows debugger proxies
- Assert.AreEqual (4, children.Length);
- Assert.AreEqual ("[0]", children [0].Name);
- Assert.AreEqual ("[1]", children [1].Name);
- Assert.AreEqual ("[2]", children [2].Name);
- Assert.AreEqual ("Raw View", children [3].Name);
- Assert.AreEqual ("\"aaa\"", children [0].Value);
- Assert.AreEqual ("\"bbb\"", children [1].Value);
- Assert.AreEqual ("\"ccc\"", children [2].Value);
- } else {
- // when AllowTargetInvokes is disabled, it also disables debugger proxies
- Assert.AreEqual (10, children.Length);
- Assert.AreEqual ("Capacity", children [0].Name);
- Assert.AreEqual ("Static members", children [7].Name);
- Assert.AreEqual ("Non-public members", children [8].Name);
- Assert.AreEqual ("IEnumerator", children [9].Name);
- }
-
- val = Eval ("alist");
- children = val.GetAllChildrenSync ();
-
- if (AllowTargetInvokes) {
- // AllowTargetInvokes also allows debugger proxies
- Assert.AreEqual (4, children.Length);
- Assert.AreEqual ("[0]", children [0].Name);
- Assert.AreEqual ("[1]", children [1].Name);
- Assert.AreEqual ("[2]", children [2].Name);
- Assert.AreEqual ("Raw View", children [3].Name);
- Assert.AreEqual ("1", children [0].Value);
- Assert.AreEqual ("\"two\"", children [1].Value);
- Assert.AreEqual ("3", children [2].Value);
- } else {
- // when AllowTargetInvokes is disabled, it also disables debugger proxies
- Assert.AreEqual (9, children.Length);
- Assert.AreEqual ("Capacity", children [0].Name);
- Assert.AreEqual ("Count", children [1].Name);
- Assert.AreEqual ("IsFixedSize", children [2].Name);
- Assert.AreEqual ("IsReadOnly", children [3].Name);
- Assert.AreEqual ("IsSynchronized", children [4].Name);
- Assert.AreEqual ("SyncRoot", children [5].Name);
- Assert.AreEqual ("Static members", children [6].Name);
- Assert.AreEqual ("Non-public members", children [7].Name);
- Assert.AreEqual ("IEnumerator", children [8].Name);
- }
- }
-
- [Test]
- [Ignore ("TODO: Evaluating dynamic objects")]
- public void DynamicObjects ()
- {
- ObjectValue val;
- val = Eval ("dynObj.someInt");
- Assert.AreEqual ("dynamic {int}", val.TypeName);
- Assert.AreEqual ("53", val.Value);
-
- val = Eval ("dynObj.someString");
- Assert.AreEqual ("dynamic {string}", val.TypeName);
- Assert.AreEqual ("\"Hello dynamic objects!\"", val.Value);
- }
-
- [Test]
- public void GetTypeTest ()
- {
- if (Session.GetType ().Name == "CorDebuggerSession") {
- Assert.Ignore ("TODO: GetType() is not implemented in CorDebugger");
- }
- ObjectValue val;
- val = Eval ("a.GetType()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.IsTrue (val.TypeName == "System.MonoType" || val.TypeName == "System.RuntimeType", "Incorrect type name: " + val.TypeName);
- Assert.AreEqual ("{A}", val.Value);
-
- val = Eval ("this.GetType()");
- if (!AllowTargetInvokes) {
- var options = Session.Options.EvaluationOptions.Clone ();
- options.AllowTargetInvoke = true;
-
- Assert.IsTrue (val.IsImplicitNotSupported);
- val.Refresh (options);
- val = val.Sync ();
- }
- Assert.IsTrue (val.TypeName == "System.MonoType" || val.TypeName == "System.RuntimeType", "Incorrect type name: " + val.TypeName);
- Assert.AreEqual ("{MonoDevelop.Debugger.Tests.TestApp.TestEvaluationChild}", val.Value);
- }
-
- [Test]
- [Ignore ("Operator \"is\" is not implemented")]
- public void IsOperatorTest ()
- {
- ObjectValue val;
- val = Eval ("b is A");
- Assert.AreEqual ("bool", val.TypeName);
- Assert.AreEqual ("true", val.Value);
-
- val = Eval ("b is B");
- Assert.AreEqual ("bool", val.TypeName);
- Assert.AreEqual ("true", val.Value);
-
- val = Eval ("b is C");
- Assert.AreEqual ("bool", val.TypeName);
- Assert.AreEqual ("false", val.Value);
- }
-
- [Test]
- public void DebugDisplayTest ()
- {
- ObjectValue val;
- if (AllowTargetInvokes) {
- val = Eval ("debugDisplayMethodTest");
- Assert.AreEqual ("DebuggerDisplayMethodTest", val.TypeName);
- Assert.AreEqual ("First Int:32 Second Int:43", val.Value);
- }
- }
-
- [Test]
- public void ArrayTests ()
- {
- ObjectValue val;
-
- val = Eval ("numbersMulti[1,2,3]");
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("133", val.Value);
-
- val = Eval ("numbersArrays[0][7]");
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("24", val.Value);
-
- val = Eval ("arrayWithLowerBounds[5,6,7]");
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("114", val.Value);
-
- if (AllowTargetInvokes) {
- val = Eval ("arrayWithLowerBounds.GetValue(5,6,7)");
- Assert.AreEqual ("int", val.TypeName);
- Assert.AreEqual ("114", val.Value);
- }
-
- var children = Eval ("arrayWithLowerBounds").GetAllChildrenSync ();
- Assert.AreEqual ("[5, ...]", children [0].Name);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
index 1693728b7b..a1f9144212 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
@@ -38,17 +38,11 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
- <Compile Include="DebugTests.cs" />
- <Compile Include="SdbEvaluationTests.cs" />
- <Compile Include="EvaluationTests.cs" />
- <Compile Include="StackFrameTests.cs" />
- <Compile Include="SdbStackFrameTests.cs" />
- <Compile Include="CorEvaluationTests.cs" />
- <Compile Include="CorStackFrameTests.cs" />
- <Compile Include="BreakpointsAndSteppingTests.cs" />
- <Compile Include="CorBreakpointsAndSteppingTests.cs" />
- <Compile Include="SdbBreakpointsAndSteppingTests.cs" />
- <Compile Include="AdvancedEvaluationTests.cs" />
+ <Compile Include="..\..\..\..\external\debugger-libs\UnitTests\Mono.Debugging.Tests\Shared\*.cs">
+ <Link>Shared\Placeholder</Link>
+ </Compile>
+ <Compile Include="DebugTests.MonoDevelop.cs" />
+ <Compile Include="TextFile.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MonoDevelop.Debugger.csproj">
@@ -66,7 +60,7 @@
<Name>MonoDevelop.Ide</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\MonoDevelop.Debugger.Tests.TestApp\MonoDevelop.Debugger.Tests.TestApp.csproj">
+ <ProjectReference Include="..\..\..\..\external\debugger-libs\UnitTests\MonoDevelop.Debugger.Tests.TestApp\MonoDevelop.Debugger.Tests.TestApp.csproj">
<Project>{05EDFE55-C8D1-47E4-BB61-0BC809CD82E2}</Project>
<Name>MonoDevelop.Debugger.Tests.TestApp</Name>
<Private>False</Private>
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbEvaluationTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbEvaluationTests.cs
deleted file mode 100644
index d475c985d9..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbEvaluationTests.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// SdbEvaluationTests.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// 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.
-
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests.Soft
-{
- [TestFixture]
- public class SdbEvaluationAllowTargetInvokesTests: EvaluationTests
- {
- public SdbEvaluationAllowTargetInvokesTests (): base ("Mono.Debugger.Soft", true)
- {
- }
- }
-
- [TestFixture]
- public class SdbEvaluationNoTargetInvokesTests: EvaluationTests
- {
- public SdbEvaluationNoTargetInvokesTests (): base ("Mono.Debugger.Soft", false)
- {
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbStackFrameTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbStackFrameTests.cs
deleted file mode 100644
index 4ce7bf1490..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbStackFrameTests.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// SdbStackFrameTests.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
-//
-// 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.
-
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests.Soft
-{
- [TestFixture]
- public class SdbStackFrameAllowTargetInvokesTests : StackFrameTests
- {
- public SdbStackFrameAllowTargetInvokesTests (): base ("Mono.Debugger.Soft", true)
- {
- }
- }
-
- [TestFixture]
- public class SdbStackFrameNoTargetInvokesTests : StackFrameTests
- {
- public SdbStackFrameNoTargetInvokesTests (): base ("Mono.Debugger.Soft", false)
- {
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/StackFrameTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/StackFrameTests.cs
deleted file mode 100644
index 79fa7ca824..0000000000
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/StackFrameTests.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-//
-// StackFrameTests.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
-//
-// 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.
-
-using System;
-
-using Mono.Debugging.Soft;
-using Mono.Debugging.Client;
-
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests
-{
- [TestFixture]
- public abstract class StackFrameTests: DebugTests
- {
- protected StackFrameTests (string de, bool allowTargetInvoke): base (de)
- {
- AllowTargetInvokes = allowTargetInvoke;
- }
-
- [TestFixtureSetUp]
- public override void SetUp ()
- {
- base.SetUp ();
-
- Start ("TestEvaluation");
- }
-
- [Test]
- public void VirtualProperty ()
- {
- var soft = Session as SoftDebuggerSession;
- if (soft != null && soft.ProtocolVersion < new Version (2, 31))
- Assert.Ignore ("A newer version of the Mono runtime is required.");
-
- var ops = EvaluationOptions.DefaultOptions.Clone ();
- ops.FlattenHierarchy = false;
-
- ObjectValue val = Frame.GetExpressionValue ("c", ops);
- Assert.IsNotNull (val);
- val = val.Sync ();
- Assert.IsFalse (val.IsError);
- Assert.IsFalse (val.IsUnknown);
-
- // The C class does not have a Prop property
-
- ObjectValue prop = val.GetChildSync ("Prop", ops);
- Assert.IsNull (prop);
-
- prop = val.GetChildSync ("PropNoVirt1", ops);
- Assert.IsNull (prop);
-
- prop = val.GetChildSync ("PropNoVirt2", ops);
- Assert.IsNull (prop);
-
- val = val.GetChildSync ("base", ops);
- Assert.IsNotNull (val);
- val.WaitHandle.WaitOne ();
- Assert.IsFalse (val.IsError);
- Assert.IsFalse (val.IsUnknown);
-
- // The B class has a Prop property, value is 2
-
- prop = val.GetChildSync ("Prop", ops);
- Assert.IsNotNull (prop);
- Assert.AreEqual ("2", prop.Value);
-
- prop = val.GetChildSync ("PropNoVirt1", ops);
- Assert.IsNotNull (prop);
- Assert.AreEqual ("2", prop.Value);
-
- prop = val.GetChildSync ("PropNoVirt2", ops);
- Assert.IsNotNull (prop);
- Assert.AreEqual ("2", prop.Value);
-
- val = val.GetChildSync ("base", ops);
- Assert.IsNotNull (val);
- val.WaitHandle.WaitOne ();
- Assert.IsFalse (val.IsError);
- Assert.IsFalse (val.IsUnknown);
-
- // The A class has a Prop property, value is 1, but must return 2 becasue it is overriden
-
- prop = val.GetChildSync ("Prop", ops);
- Assert.IsNotNull (prop);
- Assert.AreEqual ("2", prop.Value);
-
- prop = val.GetChildSync ("PropNoVirt1", ops);
- Assert.IsNotNull (prop);
- Assert.AreEqual ("1", prop.Value);
-
- prop = val.GetChildSync ("PropNoVirt2", ops);
- Assert.IsNotNull (prop);
- Assert.AreEqual ("1", prop.Value);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/TextFile.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/TextFile.cs
new file mode 100644
index 0000000000..4a674bf417
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/TextFile.cs
@@ -0,0 +1,77 @@
+using MDTextFile = MonoDevelop.Projects.Text.TextFile;
+
+namespace Mono.Debugging.Tests
+{
+ public class TextFile : ITextFile
+ {
+ readonly MDTextFile file;
+
+ public TextFile (MDTextFile file)
+ {
+ this.file = file;
+ }
+
+ /// <summary>
+ /// Content of the file
+ /// </summary>
+ public string Text
+ {
+ get{
+ return file.Text;
+ }
+ }
+
+ /// <summary>
+ /// Full path to file
+ /// </summary>
+ public string Name
+ {
+ get{
+ return file.Name;
+ }
+ }
+
+ /// <summary>
+ /// Returns line and column (1-based) by given offset (0-based)
+ /// </summary>
+ /// <param name="offset">0-based</param>
+ /// <param name="line">1-based</param>
+ /// <param name="col">1-based</param>
+ public void GetLineColumnFromPosition (int offset, out int line, out int col)
+ {
+ file.GetLineColumnFromPosition (offset, out line, out col);
+ }
+
+ /// <summary>
+ /// Returns offset by given line and column (1-based)
+ /// </summary>
+ /// <param name="line">line (1-based)</param>
+ /// <param name="column">column (1-based)</param>
+ /// <returns>offset (0-based)</returns>
+ public int GetPositionFromLineColumn (int line, int column)
+ {
+ return file.GetPositionFromLineColumn (line, column);
+ }
+
+ /// <summary>
+ /// Returns the text starting from <paramref name="offset"/> with length=<paramref name="length"/>
+ /// </summary>
+ /// <param name="offset">0-based starting offset</param>
+ /// <param name="length">length of text</param>
+ /// <returns></returns>
+ public string GetText (int offset, int length)
+ {
+ return file.GetText (offset, length);
+ }
+
+ /// <summary>
+ /// Returns length of the given line (1-based)
+ /// </summary>
+ /// <param name="line">1-based line</param>
+ /// <returns></returns>
+ public int GetLineLength (int line)
+ {
+ return file.GetLineLength (line);
+ }
+ }
+} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
index b53615f242..5c592e9170 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
@@ -131,8 +131,12 @@ namespace MonoDevelop.DotNetCore
DotNetCoreExecutionCommand CreateDotNetCoreExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration, ProjectRunConfiguration runConfiguration)
{
- FilePath outputFileName = GetOutputFileName (configuration);
+ FilePath outputFileName;
var dotnetCoreRunConfiguration = runConfiguration as DotNetCoreRunConfiguration;
+ if (dotnetCoreRunConfiguration?.StartAction == AssemblyRunConfiguration.StartActions.Program)
+ outputFileName = dotnetCoreRunConfiguration.StartProgram;
+ else
+ outputFileName = GetOutputFileName (configuration);
return new DotNetCoreExecutionCommand (
string.IsNullOrEmpty (dotnetCoreRunConfiguration?.StartWorkingDirectory) ? Project.BaseDirectory : dotnetCoreRunConfiguration.StartWorkingDirectory,
@@ -561,7 +565,14 @@ namespace MonoDevelop.DotNetCore
protected override bool OnGetSupportsImportedItem (IMSBuildItemEvaluated buildItem)
{
- return BuildAction.DotNetActions.Contains (buildItem.Name);
+ if (!BuildAction.DotNetActions.Contains (buildItem.Name))
+ return false;
+
+ // HACK: Remove any imported items that are not in the EvaluatedItems
+ // This may happen if a condition excludes the item. All items passed to the
+ // OnGetSupportsImportedItem are from the EvaluatedItemsIgnoringCondition
+ return Project.MSBuildProject.EvaluatedItems
+ .Any (item => item.IsImported && item.Name == buildItem.Name && item.Include == buildItem.Include);
}
protected override ProjectRunConfiguration OnCreateRunConfiguration (string name)
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdkPaths.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdkPaths.cs
index 9435b2ae16..3d7aaa51d0 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdkPaths.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdkPaths.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using MonoDevelop.Core;
+using MonoDevelop.Projects.MSBuild;
namespace MonoDevelop.DotNetCore
{
@@ -55,9 +56,7 @@ namespace MonoDevelop.DotNetCore
MSBuildSDKsPath = Path.Combine (SdksParentDirectory, "Sdks");
- // HACK: Set MSBuildSDKsPath environment variable so MSBuild will find the
- // SDK files when building and running targets.
- Environment.SetEnvironmentVariable ("MSBuildSDKsPath", MSBuildSDKsPath + Path.DirectorySeparatorChar);
+ MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", MSBuildSDKsPath);
}
public void FindSdkPaths (string sdk)
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
index f973c1bdda..ab5f2ada89 100644
--- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
+++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
@@ -435,7 +435,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder
if (p != null)
path = p.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration);
} else if (pref.ReferenceType == ReferenceType.Assembly) {
- path = pref.Reference;
+ path = pref.HintPath;
} else if (pref.ReferenceType == ReferenceType.Package) {
path = pref.Reference;
}
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/ActionGroup.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/ActionGroup.xft.xml
index c1d256519b..6e71c2624e 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/ActionGroup.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/ActionGroup.xft.xml
@@ -13,6 +13,7 @@
<Conditions>
<PartialTypeSupport Requirement="Disabled" />
+ <HasReference Assembly="gtk-sharp" />
</Conditions>
<TemplateFiles>
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/ActionGroupPartial.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/ActionGroupPartial.xft.xml
index d05cc4dd35..d534caa8ca 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/ActionGroupPartial.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/ActionGroupPartial.xft.xml
@@ -13,6 +13,7 @@
<Conditions>
<PartialTypeSupport Requirement="Enabled" />
+ <HasReference Assembly="gtk-sharp" />
</Conditions>
<TemplateFiles>
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/Dialog.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/Dialog.xft.xml
index e8aa208671..e41ec9e88a 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/Dialog.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/Dialog.xft.xml
@@ -13,6 +13,7 @@
<Conditions>
<PartialTypeSupport Requirement="Disabled" />
+ <HasReference Assembly="gtk-sharp" />
</Conditions>
<TemplateFiles>
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/DialogPartial.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/DialogPartial.xft.xml
index fdb11da595..f6e249dc75 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/DialogPartial.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/DialogPartial.xft.xml
@@ -13,6 +13,7 @@
<Conditions>
<PartialTypeSupport Requirement="Enabled" />
+ <HasReference Assembly="gtk-sharp" />
</Conditions>
<TemplateFiles>
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/DrawingArea.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/DrawingArea.xft.xml
index b6a983055c..2c8082951b 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/DrawingArea.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/DrawingArea.xft.xml
@@ -9,6 +9,9 @@
<_Description>Creates a custom Gtk.DrawingArea subclass.</_Description>
<DefaultFilename>DrawingArea</DefaultFilename>
</TemplateConfiguration>
+ <Conditions>
+ <HasReference Assembly="gtk-sharp" />
+ </Conditions>
<TemplateFiles>
<CodeDomFile>
<CompileUnit>
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/Widget.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/Widget.xft.xml
index 7935b4f18d..35817aacf3 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/Widget.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/Widget.xft.xml
@@ -13,6 +13,7 @@
<Conditions>
<PartialTypeSupport Requirement="Disabled" />
+ <HasReference Assembly="gtk-sharp" />
</Conditions>
<TemplateFiles>
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/WidgetPartial.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/WidgetPartial.xft.xml
index 7da4c74494..a1d36b2669 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/WidgetPartial.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/WidgetPartial.xft.xml
@@ -13,12 +13,9 @@
<Conditions>
<PartialTypeSupport Requirement="Enabled" />
+ <HasReference Assembly="gtk-sharp" />
</Conditions>
-
- <Conditions>
- <PartialTypeSupport Requirement="Enabled" />
- </Conditions>
-
+
<TemplateFiles>
<Widget DefaultName="${Name}">
<SteticTemplate>
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/Window.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/Window.xft.xml
index 6e39d2d8eb..32f7a9c5fe 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/Window.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/Window.xft.xml
@@ -13,6 +13,7 @@
<Conditions>
<PartialTypeSupport Requirement="Disabled" />
+ <HasReference Assembly="gtk-sharp" />
</Conditions>
<TemplateFiles>
diff --git a/main/src/addins/MonoDevelop.GtkCore/templates/WindowPartial.xft.xml b/main/src/addins/MonoDevelop.GtkCore/templates/WindowPartial.xft.xml
index d0fc35229c..eacabbd45d 100644
--- a/main/src/addins/MonoDevelop.GtkCore/templates/WindowPartial.xft.xml
+++ b/main/src/addins/MonoDevelop.GtkCore/templates/WindowPartial.xft.xml
@@ -13,6 +13,7 @@
<Conditions>
<PartialTypeSupport Requirement="Enabled" />
+ <HasReference Assembly="gtk-sharp" />
</Conditions>
<TemplateFiles>
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs
index 2e289c0ef5..c981095f4e 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs
@@ -83,8 +83,12 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers
public IDotNetProject ResolveProject (ProjectReference projectReference)
{
+ if (OnResolveProject != null)
+ return OnResolveProject (projectReference);
return Projects.FirstOrDefault (project => project.Name == projectReference.Include);
}
+
+ public Func<ProjectReference, IDotNetProject> OnResolveProject;
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSpecCreatorTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSpecCreatorTests.cs
index 9f4c707e62..3e6171b96d 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSpecCreatorTests.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSpecCreatorTests.cs
@@ -29,6 +29,7 @@ using MonoDevelop.PackageManagement.Tests.Helpers;
using MonoDevelop.Projects;
using NuGet.Frameworks;
using NuGet.LibraryModel;
+using NuGet.ProjectManagement;
using NuGet.ProjectModel;
using NUnit.Framework;
@@ -40,9 +41,13 @@ namespace MonoDevelop.PackageManagement.Tests
PackageSpec spec;
FakeDotNetProject project;
FakeSolution solution;
+ PackageManagementEvents packageManagementEvents;
+ PackageManagementLogger logger;
void CreateProject (string name, string fileName = @"d:\projects\MyProject\MyProject.csproj")
{
+ packageManagementEvents = new PackageManagementEvents ();
+ logger = new PackageManagementLogger (packageManagementEvents);
solution = new FakeSolution ();
project = new FakeDotNetProject (fileName.ToNativePath ());
project.ParentSolution = solution;
@@ -56,7 +61,7 @@ namespace MonoDevelop.PackageManagement.Tests
void CreatePackageSpec ()
{
- spec = PackageSpecCreator.CreatePackageSpec (project);
+ spec = PackageSpecCreator.CreatePackageSpec (project, logger);
}
void AddPackageReference (string id, string version)
@@ -65,18 +70,17 @@ namespace MonoDevelop.PackageManagement.Tests
project.PackageReferences.Add (packageReference);
}
- void AddProjectReference (string projectName, string fileName)
+ FakeDotNetProject AddProjectReference (string projectName, string fileName, string include)
{
fileName = fileName.ToNativePath ();
- var otherProject = new DummyDotNetProject ();
- otherProject.Name = projectName;
- otherProject.FileName = fileName;
- var projectReference = ProjectReference.CreateProjectReference (otherProject);
+ var projectReference = ProjectReference.CreateCustomReference (ReferenceType.Project, include);
project.References.Add (projectReference);
var fakeOtherProject = new FakeDotNetProject (fileName);
fakeOtherProject.Name = projectName;
solution.Projects.Add (fakeOtherProject);
+
+ return fakeOtherProject;
}
void AddPackageTargetFallback (string packageTargetFallback)
@@ -136,8 +140,13 @@ namespace MonoDevelop.PackageManagement.Tests
CreateProject ("MyProject", @"d:\projects\MyProject\MyProject.csproj");
AddTargetFramework ("netcoreapp1.0");
string referencedProjectFileName = @"d:\projects\MyProject\Lib\Lib.csproj".ToNativePath ();
- AddProjectReference ("Lib", referencedProjectFileName);
-
+ string include = @"Lib\Lib.csproj".ToNativePath ();
+ var referencedProject = AddProjectReference ("Lib", referencedProjectFileName, include);
+ solution.OnResolveProject = pr => {
+ if (pr.Include == include)
+ return referencedProject;
+ return null;
+ };
CreatePackageSpec ();
var targetFramework = spec.RestoreMetadata.TargetFrameworks.Single ();
@@ -156,6 +165,52 @@ namespace MonoDevelop.PackageManagement.Tests
}
[Test]
+ public void CreatePackageSpec_OneSharedProjectReference_NoProjectReferencedAddedToPackageSpec ()
+ {
+ CreateProject ("MyProject", @"d:\projects\MyProject\MyProject.csproj");
+ AddTargetFramework ("netcoreapp1.0");
+ string referencedProjectFileName = @"d:\projects\MyProject\Lib\Lib.shproj".ToNativePath ();
+ AddProjectReference ("Lib", referencedProjectFileName, @"Lib\Lib.shproj".ToNativePath ());
+
+ CreatePackageSpec ();
+
+ var targetFramework = spec.RestoreMetadata.TargetFrameworks.Single ();
+ Assert.AreEqual ("MyProject", spec.Name);
+ Assert.AreEqual ("MyProject", spec.RestoreMetadata.ProjectName);
+ Assert.AreEqual ("netcoreapp1.0", spec.RestoreMetadata.OriginalTargetFrameworks.Single ());
+ Assert.AreEqual (".NETCoreApp,Version=v1.0", targetFramework.FrameworkName.ToString ());
+ Assert.AreEqual (0, targetFramework.ProjectReferences.Count);
+ }
+
+ [Test]
+ public void CreatePackageSpec_OneProjectReferenceWhichCannotBeResolved_WarningLoggedAndNoProjectReferencedAddedToPackageSpec ()
+ {
+ CreateProject ("MyProject", @"d:\projects\MyProject\MyProject.csproj");
+ AddTargetFramework ("netcoreapp1.0");
+ string referencedProjectFileName = @"d:\projects\MyProject\Lib\Lib.csproj".ToNativePath ();
+ string include = @"Lib\Lib.csproj".ToNativePath ();
+ AddProjectReference ("Lib", referencedProjectFileName, include);
+ solution.OnResolveProject = pr => {
+ return null;
+ };
+ PackageOperationMessage messageLogged = null;
+ packageManagementEvents.PackageOperationMessageLogged += (sender, e) => {
+ messageLogged = e.Message;
+ };
+ CreatePackageSpec ();
+
+ var targetFramework = spec.RestoreMetadata.TargetFrameworks.Single ();
+ string expectedMessage = string.Format ("WARNING: Unable to resolve project '{0}' referenced by 'MyProject'.", include);
+ Assert.AreEqual ("MyProject", spec.Name);
+ Assert.AreEqual ("MyProject", spec.RestoreMetadata.ProjectName);
+ Assert.AreEqual ("netcoreapp1.0", spec.RestoreMetadata.OriginalTargetFrameworks.Single ());
+ Assert.AreEqual (".NETCoreApp,Version=v1.0", targetFramework.FrameworkName.ToString ());
+ Assert.AreEqual (expectedMessage, messageLogged.ToString ());
+ Assert.AreEqual (MessageLevel.Warning, messageLogged.Level);
+ Assert.AreEqual (0, targetFramework.ProjectReferences.Count);
+ }
+
+ [Test]
public void CreatePackageSpec_PackageTargetFallback_ImportsAddedToTargetFramework ()
{
CreateProject ("MyProject", @"d:\projects\MyProject\MyProject.csproj");
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs
index 5d3139f394..342618cf25 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs
@@ -203,7 +203,7 @@ namespace MonoDevelop.PackageManagement
return new [] { existingPackageSpec };
}
- PackageSpec packageSpec = await CreateProjectPackageSpec ();
+ PackageSpec packageSpec = await CreateProjectPackageSpec (context);
if (context != null) {
AddToCache (context, packageSpec);
@@ -223,15 +223,15 @@ namespace MonoDevelop.PackageManagement
return packageSpec;
}
- async Task<PackageSpec> CreateProjectPackageSpec ()
+ async Task<PackageSpec> CreateProjectPackageSpec (DependencyGraphCacheContext context)
{
- PackageSpec packageSpec = await Runtime.RunInMainThread (() => CreateProjectPackageSpec (project));
+ PackageSpec packageSpec = await Runtime.RunInMainThread (() => CreateProjectPackageSpec (project, context));
return packageSpec;
}
- static PackageSpec CreateProjectPackageSpec (DotNetProject project)
+ static PackageSpec CreateProjectPackageSpec (DotNetProject project, DependencyGraphCacheContext context)
{
- PackageSpec packageSpec = PackageSpecCreator.CreatePackageSpec (project);
+ PackageSpec packageSpec = PackageSpecCreator.CreatePackageSpec (project, context.Logger);
return packageSpec;
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSpecCreator.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSpecCreator.cs
index f0e345b7e5..eef2fc8b5a 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSpecCreator.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSpecCreator.cs
@@ -24,8 +24,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using MonoDevelop.Core;
using MonoDevelop.Projects;
using NuGet.Commands;
+using NuGet.Common;
using NuGet.Frameworks;
using NuGet.LibraryModel;
using NuGet.ProjectModel;
@@ -36,12 +38,12 @@ namespace MonoDevelop.PackageManagement
{
static class PackageSpecCreator
{
- public static PackageSpec CreatePackageSpec (DotNetProject project)
+ public static PackageSpec CreatePackageSpec (DotNetProject project, ILogger logger)
{
- return CreatePackageSpec (new DotNetProjectProxy (project));
+ return CreatePackageSpec (new DotNetProjectProxy (project), logger);
}
- public static PackageSpec CreatePackageSpec (IDotNetProject project)
+ public static PackageSpec CreatePackageSpec (IDotNetProject project, ILogger logger)
{
var packageSpec = new PackageSpec (GetTargetFrameworks (project));
packageSpec.FilePath = project.FileName;
@@ -50,7 +52,7 @@ namespace MonoDevelop.PackageManagement
packageSpec.RestoreMetadata = CreateRestoreMetadata (packageSpec, project);
packageSpec.RuntimeGraph = GetRuntimeGraph (project);
- AddProjectReferences (packageSpec, project);
+ AddProjectReferences (packageSpec, project, logger);
AddPackageReferences (packageSpec, project);
AddPackageTargetFallbacks (packageSpec, project);
@@ -116,7 +118,7 @@ namespace MonoDevelop.PackageManagement
return new string[0];
}
- static void AddProjectReferences (PackageSpec spec, IDotNetProject project)
+ static void AddProjectReferences (PackageSpec spec, IDotNetProject project, ILogger logger)
{
// Add groups for each spec framework
var frameworkGroups = new Dictionary<NuGetFramework, List<ProjectRestoreReference>> ();
@@ -124,8 +126,9 @@ namespace MonoDevelop.PackageManagement
frameworkGroups.Add (framework, new List<ProjectRestoreReference> ());
}
- var flatReferences = project.References.Where (projectReference => projectReference.ReferenceType == ReferenceType.Project)
- .Select (projectReference => GetProjectRestoreReference (projectReference, project));
+ var flatReferences = project.References.Where (IsProjectReference)
+ .Select (projectReference => GetProjectRestoreReference (projectReference, project, logger))
+ .Where (projectReference => projectReference != null);
// Add project paths
foreach (var frameworkPair in flatReferences) {
@@ -155,13 +158,29 @@ namespace MonoDevelop.PackageManagement
}
}
+ static bool IsProjectReference (ProjectReference projectReference)
+ {
+ if (projectReference.ReferenceType != ReferenceType.Project)
+ return false;
+
+ if (projectReference.Include != null)
+ return !projectReference.Include.EndsWith (".shproj", StringComparison.OrdinalIgnoreCase);
+
+ return false;
+ }
+
static Tuple<List<NuGetFramework>, ProjectRestoreReference> GetProjectRestoreReference (
ProjectReference item,
- IDotNetProject project)
+ IDotNetProject project,
+ ILogger logger)
{
var frameworks = GetFrameworks (project).ToList ();
var referencedProject = project.ParentSolution.ResolveProject (item);
+ if (referencedProject == null) {
+ logger.LogWarning (GettextCatalog.GetString ("WARNING: Unable to resolve project '{0}' referenced by '{1}'.", item.Include, project.Name));
+ return null;
+ }
var reference = new ProjectRestoreReference () {
ProjectPath = referencedProject.FileName,
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectPackageReference.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectPackageReference.cs
index 523737976e..8416137f3c 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectPackageReference.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectPackageReference.cs
@@ -110,10 +110,16 @@ namespace MonoDevelop.PackageManagement
public static ProjectPackageReference Create (IMSBuildItemEvaluated evaluatedItem)
{
- return Create (
+ var packageReference = Create (
evaluatedItem.Include,
evaluatedItem.Metadata.GetValue ("Version")
);
+
+ foreach (IMSBuildPropertyEvaluated property in evaluatedItem.Metadata.GetProperties ()) {
+ packageReference.Metadata.SetValue (property.Name, property.Value);
+ }
+
+ return packageReference;
}
public override string ToString ()
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs
index 3cb410a961..9377430b1d 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs
@@ -87,23 +87,25 @@ namespace MonoDevelop.UnitTesting
record.Results.Add (result);
}
}
-
+
public UnitTestResult GetNextResult (string configuration, UnitTest test, DateTime date)
{
DateTime currentDate = date;
- TestRecord root = GetRootRecord (configuration, currentDate);
- if (root == null)
- root = GetNextRootRecord (configuration, ref currentDate);
-
- while (root != null) {
- TestRecord tr = FindRecord (root, test.StoreRelativeName);
- if (tr != null && tr.Results != null) {
- foreach (UnitTestResult res in tr.Results) {
- if (res.TestDate > date)
- return res;
+ lock (fileCache) {
+ TestRecord root = GetRootRecord (configuration, currentDate);
+ if (root == null)
+ root = GetNextRootRecord (configuration, ref currentDate);
+
+ while (root != null) {
+ TestRecord tr = FindRecord (root, test.StoreRelativeName);
+ if (tr != null && tr.Results != null) {
+ foreach (UnitTestResult res in tr.Results) {
+ if (res.TestDate > date)
+ return res;
+ }
}
+ root = GetNextRootRecord (configuration, ref currentDate);
}
- root = GetNextRootRecord (configuration, ref currentDate);
}
return null;
}
@@ -111,20 +113,22 @@ namespace MonoDevelop.UnitTesting
public UnitTestResult GetPreviousResult (string configuration, UnitTest test, DateTime date)
{
DateTime currentDate = date;
- TestRecord root = GetRootRecord (configuration, currentDate);
- if (root == null)
- root = GetPreviousRootRecord (configuration, ref currentDate);
-
- while (root != null) {
- TestRecord tr = FindRecord (root, test.StoreRelativeName);
- if (tr != null && tr.Results != null) {
- for (int n = tr.Results.Count - 1; n >= 0; n--) {
- UnitTestResult res = (UnitTestResult) tr.Results [n];
- if (res.TestDate < date)
- return res;
+ lock (fileCache) {
+ TestRecord root = GetRootRecord (configuration, currentDate);
+ if (root == null)
+ root = GetPreviousRootRecord (configuration, ref currentDate);
+
+ while (root != null) {
+ TestRecord tr = FindRecord (root, test.StoreRelativeName);
+ if (tr != null && tr.Results != null) {
+ for (int n = tr.Results.Count - 1; n >= 0; n--) {
+ UnitTestResult res = (UnitTestResult)tr.Results [n];
+ if (res.TestDate < date)
+ return res;
+ }
}
+ root = GetPreviousRootRecord (configuration, ref currentDate);
}
- root = GetPreviousRootRecord (configuration, ref currentDate);
}
return null;
}
@@ -140,21 +144,23 @@ namespace MonoDevelop.UnitTesting
DateTime firstDay = new DateTime (startDate.Year, startDate.Month, startDate.Day);
DateTime[] dates = GetStoreDates (configuration);
-
- foreach (DateTime date in dates) {
- if (date < firstDay)
- continue;
- if (date > endDate)
- break;
-
- TestRecord root = GetRootRecord (configuration, date);
- if (root == null) continue;
- TestRecord tr = FindRecord (root, test.StoreRelativeName);
- if (tr != null && tr.Results != null) {
- foreach (UnitTestResult res in tr.Results) {
- if (res.TestDate >= startDate && res.TestDate <= endDate)
- list.Add (res);
+ lock (fileCache) {
+ foreach (DateTime date in dates) {
+ if (date < firstDay)
+ continue;
+ if (date > endDate)
+ break;
+
+ TestRecord root = GetRootRecord (configuration, date);
+ if (root == null) continue;
+
+ TestRecord tr = FindRecord (root, test.StoreRelativeName);
+ if (tr != null && tr.Results != null) {
+ foreach (UnitTestResult res in tr.Results) {
+ if (res.TestDate >= startDate && res.TestDate <= endDate)
+ list.Add (res);
+ }
}
}
}
@@ -166,20 +172,22 @@ namespace MonoDevelop.UnitTesting
{
ArrayList list = new ArrayList ();
DateTime[] dates = GetStoreDates (configuration);
-
- for (int n = dates.Length - 1; n >= 0 && list.Count < count; n--) {
- if (dates [n] > endDate)
- continue;
-
- TestRecord root = GetRootRecord (configuration, dates [n]);
- if (root == null) continue;
- TestRecord tr = FindRecord (root, test.StoreRelativeName);
- if (tr != null && tr.Results != null) {
- for (int m = tr.Results.Count - 1; m >= 0 && list.Count < count; m--) {
- UnitTestResult res = (UnitTestResult) tr.Results [m];
- if (res.TestDate <= endDate)
- list.Add (res);
+ lock (fileCache) {
+ for (int n = dates.Length - 1; n >= 0 && list.Count < count; n--) {
+ if (dates [n] > endDate)
+ continue;
+
+ TestRecord root = GetRootRecord (configuration, dates [n]);
+ if (root == null) continue;
+
+ TestRecord tr = FindRecord (root, test.StoreRelativeName);
+ if (tr != null && tr.Results != null) {
+ for (int m = tr.Results.Count - 1; m >= 0 && list.Count < count; m--) {
+ UnitTestResult res = (UnitTestResult)tr.Results [m];
+ if (res.TestDate <= endDate)
+ list.Add (res);
+ }
}
}
}
@@ -193,21 +201,24 @@ namespace MonoDevelop.UnitTesting
{
if (!Directory.Exists (basePath))
Directory.CreateDirectory (basePath);
-
- foreach (DictionaryEntry entry in fileCache) {
- TestRecord record = (TestRecord) entry.Value;
- if (!record.Modified)
- continue;
-
- string filePath = Path.Combine (basePath, (string)entry.Key);
- try {
- serializer.Serialize (filePath, record);
- record.Modified = false;
- } catch (Exception ex) {
- LoggingService.LogError (ex.ToString ());
+
+ lock (fileCache) {
+ foreach (DictionaryEntry entry in fileCache) {
+ TestRecord record = (TestRecord)entry.Value;
+ if (!record.Modified)
+ continue;
+
+ string filePath = Path.Combine (basePath, (string)entry.Key);
+ try {
+ serializer.Serialize (filePath, record);
+ record.Modified = false;
+ } catch (Exception ex) {
+ LoggingService.LogError (ex.ToString ());
+ }
}
}
- cachedRootList.Clear ();
+ lock (cachedRootList)
+ cachedRootList.Clear ();
}
TestRecord FindRecord (TestRecord root, string aname)
@@ -313,22 +324,24 @@ namespace MonoDevelop.UnitTesting
{
if (!Directory.Exists (basePath))
return new DateTime [0];
-
- DateTime[] res = (DateTime[]) cachedRootList [configuration];
- if (res != null)
+
+ lock (cachedRootList) {
+ DateTime [] res = (DateTime [])cachedRootList [configuration];
+ if (res != null)
+ return res;
+
+ var dates = new List<DateTime> ();
+ var escapedConfiguration = EscapeFilename (configuration);
+ foreach (string file in Directory.GetFiles (basePath, storeId + "-" + escapedConfiguration + "-*")) {
+ try {
+ DateTime t = ParseFileNameDate (escapedConfiguration, Path.GetFileName (file));
+ dates.Add (t);
+ } catch { }
+ }
+ res = dates.ToArray ();
+ cachedRootList [configuration] = res;
return res;
-
- var dates = new List<DateTime> ();
- var escapedConfiguration = EscapeFilename (configuration);
- foreach (string file in Directory.GetFiles (basePath, storeId + "-" + escapedConfiguration + "-*")) {
- try {
- DateTime t = ParseFileNameDate (escapedConfiguration, Path.GetFileName (file));
- dates.Add (t);
- } catch { }
}
- res = dates.ToArray ();
- cachedRootList [configuration] = res;
- return res;
}
}
diff --git a/main/src/addins/TextTemplating/Makefile.am b/main/src/addins/TextTemplating/Makefile.am
index 8bf41893d4..0a3a6e73dd 100644
--- a/main/src/addins/TextTemplating/Makefile.am
+++ b/main/src/addins/TextTemplating/Makefile.am
@@ -1,5 +1,2 @@
SUBDIRS = \
- Mono.TextTemplating \
- TextTransform \
- MonoDevelop.TextTemplating \
- Mono.TextTemplating.Tests
+ MonoDevelop.TextTemplating
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs
deleted file mode 100644
index 027a2ddc7a..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-//
-// IncludeFileProviderHost.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating.Tests
-{
-
- public class DummyHost : ITextTemplatingEngineHost
- {
- public readonly Dictionary<string, string> Locations = new Dictionary<string, string> ();
- public readonly Dictionary<string, string> Contents = new Dictionary<string, string> ();
- public readonly Dictionary<string, object> HostOptions = new Dictionary<string, object> ();
- List<string> standardAssemblyReferences = new List<string> ();
- List<string> standardImports = new List<string> ();
- public readonly CompilerErrorCollection Errors = new CompilerErrorCollection ();
- public readonly Dictionary<string, Type> DirectiveProcessors = new Dictionary<string, Type> ();
-
- public virtual object GetHostOption (string optionName)
- {
- object o;
- HostOptions.TryGetValue (optionName, out o);
- return o;
- }
-
- public virtual bool LoadIncludeText (string requestFileName, out string content, out string location)
- {
- content = null;
- return Locations.TryGetValue (requestFileName, out location)
- && Contents.TryGetValue (requestFileName, out content);
- }
-
- public virtual void LogErrors (CompilerErrorCollection errors)
- {
- Errors.AddRange (errors);
- }
-
- public virtual AppDomain ProvideTemplatingAppDomain (string content)
- {
- return null;
- }
-
- public virtual string ResolveAssemblyReference (string assemblyReference)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual Type ResolveDirectiveProcessor (string processorName)
- {
- Type t;
- DirectiveProcessors.TryGetValue (processorName, out t);
- return t;
- }
-
- public virtual string ResolveParameterValue (string directiveId, string processorName, string parameterName)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual string ResolvePath (string path)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual void SetFileExtension (string extension)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual void SetOutputEncoding (System.Text.Encoding encoding, bool fromOutputDirective)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual IList<string> StandardAssemblyReferences {
- get { return standardAssemblyReferences; }
- }
-
- public virtual IList<string> StandardImports {
- get { return standardImports; }
- }
-
- public virtual string TemplateFile {
- get; set;
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/EngineTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/EngineTests.cs
deleted file mode 100644
index e81aee6164..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/EngineTests.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// EngineTests.cs
-//
-// Author:
-// Mikayla Hutchinson <m.j.hutchinson@gmail.com>
-//
-// Copyright (c) 2016 Xamarin Inc.
-//
-// 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.
-
-using System;
-using NUnit.Framework;
-
-namespace Mono.TextTemplating.Tests
-{
- [TestFixture]
- public class EngineTests
- {
- #pragma warning disable 414
- static object [] ParameterParsingCases = {
- new object [] { "foo=bar", true, "", "", "foo", "bar" },
- new object [] { "a=b", true, "", "", "a", "b" },
- new object [] { "a=b=c", true, "", "", "a", "b=c" },
- new object [] { "!!c!d", true, "", "", "c", "d" },
- new object [] { "!!!", false, "", "", "", "" },
- new object [] { "a=", true, "", "", "a", "" },
- new object [] { "=", false, "", "", "", "" },
- new object [] { "", false, "", "", "", "" },
- new object [] { "!", false, "", "", "", "" },
- new object [] { "a!", true, "", "", "a", "" },
- new object [] { "!b!c!d", true, "", "b", "c", "d" },
- new object [] { "a!b!c!d", true, "a", "b", "c", "d" },
- new object [] { "a=b!c!d!e", true, "", "", "a", "b!c!d!e" },
- new object [] { "a!b!c!d!e", true, "a", "b", "c", "d!e" },
- new object [] { "foo!bar!baz!wibb!le", true, "foo", "bar", "baz", "wibb!le" },
- };
- #pragma warning restore 414
-
- [Test]
- [TestCaseSource(nameof (ParameterParsingCases))]
- public void ParameterParsing (
- string parameter, bool valid,
- string expectedProcessor, string expectedDirective,
- string expectedName, string expectedValue)
- {
- string processor, directive, name, value;
- var success = TemplateGenerator.TryParseParameter (parameter, out processor, out directive, out name, out value);
-
- Assert.AreEqual (valid, success);
- Assert.AreEqual (expectedProcessor, processor);
- Assert.AreEqual (expectedDirective, directive);
- Assert.AreEqual (expectedName, name);
- Assert.AreEqual (expectedValue, value);
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerateIndentedClassCodeTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerateIndentedClassCodeTests.cs
deleted file mode 100644
index 0810e2e783..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerateIndentedClassCodeTests.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-//
-// GenerateIndentedClassCodeTests.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// 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.
-
-using System;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using NUnit.Framework;
-using System.IO;
-
-namespace Mono.TextTemplating.Tests
-{
- [TestFixture]
- public class GenerateIndentedClassCodeTests
- {
- [Test]
- public void FieldAndPropertyGenerated ()
- {
- var provider = CodeDomProvider.CreateProvider ("C#");
- var field = CreateBoolField ();
- var property = CreateBoolProperty ();
-
- string output = TemplatingEngine.GenerateIndentedClassCode (provider, field, property);
- output = FixOutput (output);
- string expectedOutput = FixOutput (MethodAndFieldGeneratedOutput);
-
- Assert.AreEqual (expectedOutput, output);
- }
-
- static CodeTypeMember CreateVoidMethod ()
- {
- var meth = new CodeMemberMethod { Name = "MyMethod" };
- meth.ReturnType = new CodeTypeReference (typeof(void));
- return meth;
- }
-
- static CodeTypeMember CreateBoolField ()
- {
- var type = new CodeTypeReference (typeof(bool));
- return new CodeMemberField { Name = "myField", Type = type };
- }
-
- static CodeTypeMember CreateBoolProperty ()
- {
- var type = new CodeTypeReference (typeof(bool));
- var prop = new CodeMemberProperty { Name = "MyProperty", Type = type };
- prop.GetStatements.Add (
- new CodeMethodReturnStatement (
- new CodePrimitiveExpression (true)
- )
- );
- return prop;
- }
-
- /// <summary>
- /// Remove empty lines which are not generated on Mono.
- /// </summary>
- static string FixOutput (string output, string newLine = "\n")
- {
- using (var writer = new StringWriter ()) {
- using (var reader = new StringReader (output)) {
-
- string line;
- while ((line = reader.ReadLine ()) != null) {
- if (!String.IsNullOrWhiteSpace (line)) {
- writer.Write (line);
- writer.Write (newLine);
- }
- }
- }
- return writer.ToString ();
- }
- }
-
- public static string MethodAndFieldGeneratedOutput =
-@"
- private bool myField;
-
- private bool MyProperty {
- get {
- return true;
- }
- }
-";
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs
deleted file mode 100644
index 4455c393a1..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-//
-// GenerationTests.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using NUnit.Framework;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating.Tests
-{
-
-
- [TestFixture]
- public class GenerationTests
- {
- [Test]
- public void TemplateGeneratorTest ()
- {
- var gen = new TemplateGenerator ();
- string tmp = null;
- gen.ProcessTemplate (null, "<#@ template language=\"C#\" #>", ref tmp, out tmp);
- Assert.AreEqual (0, gen.Errors.Count, "ProcessTemplate");
- }
-
- [Test]
- public void ImportReferencesTest ()
- {
- var gen = new TemplateGenerator ();
- string tmp = null;
- gen.ReferencePaths.Add (Path.GetDirectoryName (typeof (Uri).Assembly.Location));
- gen.ReferencePaths.Add (Path.GetDirectoryName (typeof (System.Linq.Enumerable).Assembly.Location));
- gen.ProcessTemplate (null, "<#@ assembly name=\"System.dll\" #>\n<#@ assembly name=\"System.Core.dll\" #>", ref tmp, out tmp);
- Assert.AreEqual (0, gen.Errors.Count, "ImportReferencesTest");
- }
-
- [Test]
- public void Generate ()
- {
- string Input = ParsingTests.ParseSample1;
- string Output = OutputSample1;
- Generate (Input, Output, "\n");
- }
-
- [Test]
- public void GenerateMacNewlines ()
- {
- string MacInput = ParsingTests.ParseSample1.Replace ("\n", "\r");
- string MacOutput = OutputSample1.Replace ("\\n", "\\r").Replace ("\n", "\r");;
- Generate (MacInput, MacOutput, "\r");
- }
-
- [Test]
- public void GenerateWindowsNewlines ()
- {
- string WinInput = ParsingTests.ParseSample1.Replace ("\n", "\r\n");
- string WinOutput = OutputSample1.Replace ("\\n", "\\r\\n").Replace ("\n", "\r\n");
- Generate (WinInput, WinOutput, "\r\n");
- }
-
- [Test]
- public void DefaultLanguage ()
- {
- DummyHost host = new DummyHost ();
- string template = @"<#= DateTime.Now #>";
- ParsedTemplate pt = ParsedTemplate.FromText (template, host);
- Assert.AreEqual (0, host.Errors.Count);
- TemplateSettings settings = TemplatingEngine.GetSettings (host, pt);
- Assert.AreEqual (settings.Language, "C#");
- }
-
- //NOTE: we set the newline property on the code generator so that the whole files has matching newlines,
- // in order to match the newlines in the verbatim code blocks
- void Generate (string input, string expectedOutput, string newline)
- {
- DummyHost host = new DummyHost ();
- string className = "GeneratedTextTransformation4f504ca0";
- string code = GenerateCode (host, input, className, newline);
- Assert.AreEqual (0, host.Errors.Count);
-
- var generated = TemplatingEngineHelper.CleanCodeDom (code, newline);
- expectedOutput = TemplatingEngineHelper.CleanCodeDom (expectedOutput, newline);
- Assert.AreEqual (expectedOutput, generated);
- }
-
- #region Helpers
-
- string GenerateCode (ITextTemplatingEngineHost host, string content, string name, string generatorNewline)
- {
- ParsedTemplate pt = ParsedTemplate.FromText (content, host);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- TemplateSettings settings = TemplatingEngine.GetSettings (host, pt);
- if (name != null)
- settings.Name = name;
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var ccu = TemplatingEngine.GenerateCompileUnit (host, content, pt, settings);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var opts = new System.CodeDom.Compiler.CodeGeneratorOptions ();
- using (var writer = new System.IO.StringWriter ()) {
- writer.NewLine = generatorNewline;
- settings.Provider.GenerateCodeFromCompileUnit (ccu, writer, opts);
- return writer.ToString ();
- }
- }
-
- #endregion
-
- #region Expected output strings
-
- public static string OutputSample1 =
-@"
-namespace Microsoft.VisualStudio.TextTemplating {
-
-
- public partial class GeneratedTextTransformation4f504ca0 : global::Microsoft.VisualStudio.TextTemplating.TextTransformation {
-
-
- #line 9 """"
-
-baz \#>
-
- #line default
- #line hidden
-
- public override string TransformText() {
- this.GenerationEnvironment = null;
-
- #line 2 """"
- this.Write(""Line One\nLine Two\n"");
-
- #line default
- #line hidden
-
- #line 4 """"
-
-foo
-
-
- #line default
- #line hidden
-
- #line 7 """"
- this.Write(""Line Three "");
-
- #line default
- #line hidden
-
- #line 7 """"
- this.Write(global::Microsoft.VisualStudio.TextTemplating.ToStringHelper.ToStringWithCulture( bar ));
-
- #line default
- #line hidden
-
- #line 7 """"
- this.Write(""\nLine Four\n"");
-
- #line default
- #line hidden
- return this.GenerationEnvironment.ToString();
- }
-
- public override void Initialize() {
- base.Initialize();
- }
- }
-}
-";
- #endregion
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Makefile.am b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Makefile.am
deleted file mode 100644
index c9cc87438f..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-include $(top_srcdir)/xbuild.include
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj
deleted file mode 100644
index e8fd9751f4..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <Import Project="..\..\..\..\MonoDevelop.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{CB590106-8331-4CBE-8131-B154E7BF79E1}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AssemblyName>Mono.TextTemplating.Tests</AssemblyName>
- <RootNamespace>Mono.TextTemplating.Tests</RootNamespace>
- <TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
- <TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>True</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>False</Optimize>
- <OutputPath>..\..\..\..\build\tests</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <NoWarn>1591;1573</NoWarn>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\..\build\tests</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <DebugSymbols>true</DebugSymbols>
- <NoWarn>1591;1573</NoWarn>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ParsingTests.cs" />
- <Compile Include="DummyHost.cs" />
- <Compile Include="GenerationTests.cs" />
- <Compile Include="TemplatingEngineHelper.cs" />
- <Compile Include="TemplateEnginePreprocessTemplateTests.cs" />
- <Compile Include="GenerateIndentedClassCodeTests.cs" />
- <Compile Include="TextTemplatingSessionTests.cs" />
- <Compile Include="EngineTests.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Mono.TextTemplating\Mono.TextTemplating.csproj">
- <Project>{A2364D6A-00EF-417C-80A6-815726C70032}</Project>
- <Name>Mono.TextTemplating</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\..\..\..\external\guiunit\src\framework\GuiUnit_NET_4_5.csproj">
- <Project>{D12F0F7B-8DE3-43EC-BA49-41052D065A9B}</Project>
- <Name>GuiUnit_NET_4_5</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project>
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs
deleted file mode 100644
index 5e2475091d..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-//
-// Test.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Collections.Generic;
-using NUnit.Framework;
-
-namespace Mono.TextTemplating.Tests
-{
-
-
- [TestFixture]
- public class ParsingTests
- {
- public static string ParseSample1 =
-@"<#@ template language=""C#v3.5"" #>
-Line One
-Line Two
-<#
-foo
-#>
-Line Three <#= bar #>
-Line Four
-<#+
-baz \#>
-#>
-";
-
- [Test]
- public void TokenTest ()
- {
- string tf = "test.input";
- Tokeniser tk = new Tokeniser (tf, ParseSample1);
-
- //line 1
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 1, 1), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.Directive, tk.State);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 1, 5), tk.Location);
- Assert.AreEqual (State.DirectiveName, tk.State);
- Assert.AreEqual ("template", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.Directive, tk.State);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 1, 14), tk.Location);
- Assert.AreEqual (State.DirectiveName, tk.State);
- Assert.AreEqual ("language", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.Directive, tk.State);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.DirectiveValue, tk.State);
- Assert.AreEqual (new Location (tf, 1, 23), tk.Location);
- Assert.AreEqual ("C#v3.5", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.Directive, tk.State);
-
- //line 2, 3
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 2, 1), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("Line One\nLine Two\n", tk.Value);
-
- //line 4, 5, 6
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 4, 1), tk.TagStartLocation);
- Assert.AreEqual (new Location (tf, 4, 3), tk.Location);
- Assert.AreEqual (new Location (tf, 6, 3), tk.TagEndLocation);
- Assert.AreEqual (State.Block, tk.State);
- Assert.AreEqual ("\nfoo\n", tk.Value);
-
- //line 7
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 7, 1), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("Line Three ", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 7, 12), tk.TagStartLocation);
- Assert.AreEqual (new Location (tf, 7, 15), tk.Location);
- Assert.AreEqual (new Location (tf, 7, 22), tk.TagEndLocation);
- Assert.AreEqual (State.Expression, tk.State);
- Assert.AreEqual (" bar ", tk.Value);
-
- //line 8
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 7, 22), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("\nLine Four\n", tk.Value);
-
- //line 9, 10, 11
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 9, 1), tk.TagStartLocation);
- Assert.AreEqual (new Location (tf, 9, 4), tk.Location);
- Assert.AreEqual (new Location (tf, 11, 3), tk.TagEndLocation);
- Assert.AreEqual (State.Helper, tk.State);
- Assert.AreEqual (" \nbaz \\#>\n", tk.Value);
-
- //line 12
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 12, 1), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("", tk.Value);
-
- //EOF
- Assert.IsFalse (tk.Advance ());
- Assert.AreEqual (new Location (tf, 12, 1), tk.Location);
- Assert.AreEqual (State.EOF, tk.State);
- }
-
- [Test]
- public void ParseTest ()
- {
- string tf = "test.input";
-
- ParsedTemplate pt = new ParsedTemplate ("test.input");
- Tokeniser tk = new Tokeniser (tf, ParseSample1);
- DummyHost host = new DummyHost ();
- pt.Parse (host, tk);
-
- Assert.AreEqual (0, pt.Errors.Count);
- var content = new List<TemplateSegment> (pt.Content);
- var dirs = new List<Directive> (pt.Directives);
-
- Assert.AreEqual (1, dirs.Count);
- Assert.AreEqual (6, content.Count);
-
- Assert.AreEqual ("template", dirs[0].Name);
- Assert.AreEqual (1, dirs[0].Attributes.Count);
- Assert.AreEqual ("C#v3.5", dirs[0].Attributes["language"]);
- Assert.AreEqual (new Location (tf, 1, 1), dirs[0].TagStartLocation);
- Assert.AreEqual (new Location (tf, 1, 34), dirs[0].EndLocation);
-
- Assert.AreEqual ("Line One\nLine Two\n", content[0].Text);
- Assert.AreEqual ("\nfoo\n", content[1].Text);
- Assert.AreEqual ("Line Three ", content[2].Text);
- Assert.AreEqual (" bar ", content[3].Text);
- Assert.AreEqual ("\nLine Four\n", content[4].Text);
- Assert.AreEqual (" \nbaz \\#>\n", content[5].Text);
-
- Assert.AreEqual (SegmentType.Content, content[0].Type);
- Assert.AreEqual (SegmentType.Block, content[1].Type);
- Assert.AreEqual (SegmentType.Content, content[2].Type);
- Assert.AreEqual (SegmentType.Expression, content[3].Type);
- Assert.AreEqual (SegmentType.Content, content[4].Type);
- Assert.AreEqual (SegmentType.Helper, content[5].Type);
-
- Assert.AreEqual (new Location (tf, 4, 1), content[1].TagStartLocation);
- Assert.AreEqual (new Location (tf, 7, 12), content[3].TagStartLocation);
- Assert.AreEqual (new Location (tf, 9, 1), content[5].TagStartLocation);
-
- Assert.AreEqual (new Location (tf, 2, 1), content[0].StartLocation);
- Assert.AreEqual (new Location (tf, 4, 3), content[1].StartLocation);
- Assert.AreEqual (new Location (tf, 7, 1), content[2].StartLocation);
- Assert.AreEqual (new Location (tf, 7, 15), content[3].StartLocation);
- Assert.AreEqual (new Location (tf, 7, 22), content[4].StartLocation);
- Assert.AreEqual (new Location (tf, 9, 4), content[5].StartLocation);
-
- Assert.AreEqual (new Location (tf, 6, 3), content[1].EndLocation);
- Assert.AreEqual (new Location (tf, 7, 22), content[3].EndLocation);
- Assert.AreEqual (new Location (tf, 11, 3), content[5].EndLocation);
- }
-
-
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs
deleted file mode 100644
index 3e71f4bbca..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs
+++ /dev/null
@@ -1,636 +0,0 @@
-//
-// TemplateEnginePreprocessTemplateTests.cs
-//
-// Author:
-// Matt Ward
-//
-// Copyright (c) 2011 Matt Ward
-//
-// 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.
-
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.IO;
-using NUnit.Framework;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating.Tests
-{
- [TestFixture]
- public class TemplateEnginePreprocessTemplateTests
- {
- [Test]
- public void Preprocess ()
- {
- string input =
- "<#@ template language=\"C#\" #>\r\n" +
- "Test\r\n";
-
- string expectedOutput = TemplatingEngineHelper.CleanCodeDom (OutputSample1, "\n");
- string output = Preprocess (input);
-
- Assert.AreEqual (expectedOutput, output);
- }
-
- [Test]
- public void Preprocess_ControlBlockAfterIncludedTemplateWithClassFeatureBlock_ReturnsValidCSharpOutput ()
- {
- string input = InputTemplate_ControlBlockAfterIncludedTemplateWithClassFeatureBlock;
- DummyHost host = CreateDummyHostForControlBlockAfterIncludedTemplateWithClassFeatureBlockTest ();
-
- string expectedOutput = TemplatingEngineHelper.CleanCodeDom (Output_ControlBlockAfterIncludedTemplateWithClassFeatureBlock, "\n");
- string output = Preprocess (input, host);
-
- Assert.AreEqual (expectedOutput, output, output);
- }
-
- [Test]
- public void CaptureEncodingAndExtension ()
- {
- string input = InputTemplate_CaptureEncodingAndExtension;
- string output = Preprocess (input);
- string expectedOutput = TemplatingEngineHelper.CleanCodeDom (Output_CaptureEncodingAndExtension, "\n");
-
- Assert.AreEqual (expectedOutput, output, output);
- }
-
- #region Helpers
-
- string Preprocess (string input)
- {
- DummyHost host = new DummyHost ();
- return Preprocess (input, host);
- }
-
- string Preprocess (string input, DummyHost host)
- {
- string className = "PreprocessedTemplate";
- string classNamespace = "Templating";
- string language = null;
- string[] references = null;
-
- TemplatingEngine engine = new TemplatingEngine ();
- string output = engine.PreprocessTemplate (input, host, className, classNamespace, out language, out references);
- ReportErrors (host.Errors);
- if (output != null) {
- return TemplatingEngineHelper.CleanCodeDom (output, "\n");
- }
- return null;
- }
-
- void ReportErrors(CompilerErrorCollection errors)
- {
- foreach (CompilerError error in errors) {
- Console.WriteLine(error.ErrorText);
- }
- }
-
- DummyHost CreateDummyHostForControlBlockAfterIncludedTemplateWithClassFeatureBlockTest()
- {
- DummyHost host = new DummyHost ();
-
- string includeTemplateFileName = @"d:\test\IncludedFile.tt";
- host.Locations.Add (includeTemplateFileName, includeTemplateFileName);
- host.Contents.Add (includeTemplateFileName, IncludedTemplate_ControlBlockAfterIncludedTemplate);
-
- return host;
- }
-
- #endregion
-
- #region Input templates
-
- public static string InputTemplate_ControlBlockAfterIncludedTemplateWithClassFeatureBlock =
-@"
-<#@ template debug=""false"" language=""C#"" #>
-<#@ output extension="".cs"" #>
-Text Block 1
-<#
- this.TemplateMethod();
-#>
-Text Block 2
-<#@ include file=""d:\test\IncludedFile.tt"" #>
-Text Block 3
-<#
- this.IncludedMethod();
-#>
-<#+
- void TemplateMethod()
- {
- }
-#>
-";
-
- public static string IncludedTemplate_ControlBlockAfterIncludedTemplate =
-@"
-<#@ template debug=""false"" language=""C#"" #>
-<#@ output extension="".cs"" #>
-Included Text Block 1
-<# this.WriteLine(""Included statement block""); #>
-Included Text Block 2
-<#+
- void IncludedMethod()
- {
-#>
-Included Method Body Text Block
-<#+
- }
-#>
-";
-
- public static string InputTemplate_CaptureEncodingAndExtension =
- @"
-<#@ template debug=""false"" language=""C#"" inherits=""Foo"" hostspecific=""trueFromBase"" #>
-<#@ output extension="".cs"" encoding=""utf-8"" #>
-";
-
- #endregion
-
- #region Expected output strings
-
- public static string OutputSample1 =
-@"
-namespace Templating {
-
-
- public partial class PreprocessedTemplate : PreprocessedTemplateBase {
-
- public virtual string TransformText() {
- this.GenerationEnvironment = null;
-
- #line 2 """"
-
- this.Write(""Test\r\n"");
-
- #line default
- #line hidden
- return this.GenerationEnvironment.ToString();
- }
-
- public virtual void Initialize() {
- }
- }
-
- public class PreprocessedTemplateBase {
-
- private global::System.Text.StringBuilder builder;
-
- private global::System.Collections.Generic.IDictionary<string, object> session;
-
- private global::System.CodeDom.Compiler.CompilerErrorCollection errors;
-
- private string currentIndent = string.Empty;
-
- private global::System.Collections.Generic.Stack<int> indents;
-
- private ToStringInstanceHelper _toStringHelper = new ToStringInstanceHelper();
-
- public virtual global::System.Collections.Generic.IDictionary<string, object> Session {
- get {
- return this.session;
- }
- set {
- this.session = value;
- }
- }
-
- public global::System.Text.StringBuilder GenerationEnvironment {
- get {
- if ((this.builder == null)) {
- this.builder = new global::System.Text.StringBuilder();
- }
- return this.builder;
- }
- set {
- this.builder = value;
- }
- }
-
- protected global::System.CodeDom.Compiler.CompilerErrorCollection Errors {
- get {
- if ((this.errors == null)) {
- this.errors = new global::System.CodeDom.Compiler.CompilerErrorCollection();
- }
- return this.errors;
- }
- }
-
- public string CurrentIndent {
- get {
- return this.currentIndent;
- }
- }
-
- private global::System.Collections.Generic.Stack<int> Indents {
- get {
- if ((this.indents == null)) {
- this.indents = new global::System.Collections.Generic.Stack<int>();
- }
- return this.indents;
- }
- }
-
- public ToStringInstanceHelper ToStringHelper {
- get {
- return this._toStringHelper;
- }
- }
-
- public void Error(string message) {
- this.Errors.Add(new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message));
- }
-
- public void Warning(string message) {
- global::System.CodeDom.Compiler.CompilerError val = new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message);
- val.IsWarning = true;
- this.Errors.Add(val);
- }
-
- public string PopIndent() {
- if ((this.Indents.Count == 0)) {
- return string.Empty;
- }
- int lastPos = (this.currentIndent.Length - this.Indents.Pop());
- string last = this.currentIndent.Substring(lastPos);
- this.currentIndent = this.currentIndent.Substring(0, lastPos);
- return last;
- }
-
- public void PushIndent(string indent) {
- this.Indents.Push(indent.Length);
- this.currentIndent = (this.currentIndent + indent);
- }
-
- public void ClearIndent() {
- this.currentIndent = string.Empty;
- this.Indents.Clear();
- }
-
- public void Write(string textToAppend) {
- this.GenerationEnvironment.Append(textToAppend);
- }
-
- public void Write(string format, params object[] args) {
- this.GenerationEnvironment.AppendFormat(format, args);
- }
-
- public void WriteLine(string textToAppend) {
- this.GenerationEnvironment.Append(this.currentIndent);
- this.GenerationEnvironment.AppendLine(textToAppend);
- }
-
- public void WriteLine(string format, params object[] args) {
- this.GenerationEnvironment.Append(this.currentIndent);
- this.GenerationEnvironment.AppendFormat(format, args);
- this.GenerationEnvironment.AppendLine();
- }
-
- public class ToStringInstanceHelper {
-
- private global::System.IFormatProvider formatProvider = global::System.Globalization.CultureInfo.InvariantCulture;
-
- public global::System.IFormatProvider FormatProvider {
- get {
- return this.formatProvider;
- }
- set {
- if ((value != null)) {
- this.formatProvider = value;
- }
- }
- }
-
- public string ToStringWithCulture(object objectToConvert) {
- if ((objectToConvert == null)) {
- throw new global::System.ArgumentNullException(""objectToConvert"");
- }
- global::System.Type type = objectToConvert.GetType();
- global::System.Type iConvertibleType = typeof(global::System.IConvertible);
- if (iConvertibleType.IsAssignableFrom(type)) {
- return ((global::System.IConvertible)(objectToConvert)).ToString(this.formatProvider);
- }
- global::System.Reflection.MethodInfo methInfo = type.GetMethod(""ToString"", new global::System.Type[] {
- iConvertibleType});
- if ((methInfo != null)) {
- return ((string)(methInfo.Invoke(objectToConvert, new object[] {
- this.formatProvider})));
- }
- return objectToConvert.ToString();
- }
- }
- }
-}
-";
-
- public static string Output_ControlBlockAfterIncludedTemplateWithClassFeatureBlock =
-@"
-namespace Templating {
-
-
- public partial class PreprocessedTemplate : PreprocessedTemplateBase {
-
-
- #line 14 """"
-
- void TemplateMethod()
- {
- }
-
- #line default
- #line hidden
-
-
- #line 7 ""d:\test\IncludedFile.tt""
-
- void IncludedMethod()
- {
-
- #line default
- #line hidden
-
-
- #line 11 ""d:\test\IncludedFile.tt""
- this.Write(""Included Method Body Text Block\n"");
-
- #line default
- #line hidden
-
-
- #line 12 ""d:\test\IncludedFile.tt""
-
- }
-
- #line default
- #line hidden
-
- public virtual string TransformText() {
- this.GenerationEnvironment = null;
-
- #line 1 """"
- this.Write(""\n"");
-
- #line default
- #line hidden
-
- #line 4 """"
- this.Write(""Text Block 1\n"");
-
- #line default
- #line hidden
-
- #line 5 """"
-
- this.TemplateMethod();
-
-
- #line default
- #line hidden
-
- #line 8 """"
- this.Write(""Text Block 2\n"");
-
- #line default
- #line hidden
-
- #line 1 ""d:\test\IncludedFile.tt""
- this.Write(""\n"");
-
- #line default
- #line hidden
-
- #line 4 ""d:\test\IncludedFile.tt""
- this.Write(""Included Text Block 1\n"");
-
- #line default
- #line hidden
-
- #line 5 ""d:\test\IncludedFile.tt""
- this.WriteLine(""Included statement block"");
-
- #line default
- #line hidden
-
- #line 6 ""d:\test\IncludedFile.tt""
- this.Write(""Included Text Block 2\n"");
-
- #line default
- #line hidden
-
- #line 10 """"
- this.Write(""Text Block 3\n"");
-
- #line default
- #line hidden
-
- #line 11 """"
-
- this.IncludedMethod();
-
-
- #line default
- #line hidden
- return this.GenerationEnvironment.ToString();
- }
-
- public virtual void Initialize() {
- }
- }
-
- public class PreprocessedTemplateBase {
-
- private global::System.Text.StringBuilder builder;
-
- private global::System.Collections.Generic.IDictionary<string, object> session;
-
- private global::System.CodeDom.Compiler.CompilerErrorCollection errors;
-
- private string currentIndent = string.Empty;
-
- private global::System.Collections.Generic.Stack<int> indents;
-
- private ToStringInstanceHelper _toStringHelper = new ToStringInstanceHelper();
-
- public virtual global::System.Collections.Generic.IDictionary<string, object> Session {
- get {
- return this.session;
- }
- set {
- this.session = value;
- }
- }
-
- public global::System.Text.StringBuilder GenerationEnvironment {
- get {
- if ((this.builder == null)) {
- this.builder = new global::System.Text.StringBuilder();
- }
- return this.builder;
- }
- set {
- this.builder = value;
- }
- }
-
- protected global::System.CodeDom.Compiler.CompilerErrorCollection Errors {
- get {
- if ((this.errors == null)) {
- this.errors = new global::System.CodeDom.Compiler.CompilerErrorCollection();
- }
- return this.errors;
- }
- }
-
- public string CurrentIndent {
- get {
- return this.currentIndent;
- }
- }
-
- private global::System.Collections.Generic.Stack<int> Indents {
- get {
- if ((this.indents == null)) {
- this.indents = new global::System.Collections.Generic.Stack<int>();
- }
- return this.indents;
- }
- }
-
- public ToStringInstanceHelper ToStringHelper {
- get {
- return this._toStringHelper;
- }
- }
-
- public void Error(string message) {
- this.Errors.Add(new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message));
- }
-
- public void Warning(string message) {
- global::System.CodeDom.Compiler.CompilerError val = new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message);
- val.IsWarning = true;
- this.Errors.Add(val);
- }
-
- public string PopIndent() {
- if ((this.Indents.Count == 0)) {
- return string.Empty;
- }
- int lastPos = (this.currentIndent.Length - this.Indents.Pop());
- string last = this.currentIndent.Substring(lastPos);
- this.currentIndent = this.currentIndent.Substring(0, lastPos);
- return last;
- }
-
- public void PushIndent(string indent) {
- this.Indents.Push(indent.Length);
- this.currentIndent = (this.currentIndent + indent);
- }
-
- public void ClearIndent() {
- this.currentIndent = string.Empty;
- this.Indents.Clear();
- }
-
- public void Write(string textToAppend) {
- this.GenerationEnvironment.Append(textToAppend);
- }
-
- public void Write(string format, params object[] args) {
- this.GenerationEnvironment.AppendFormat(format, args);
- }
-
- public void WriteLine(string textToAppend) {
- this.GenerationEnvironment.Append(this.currentIndent);
- this.GenerationEnvironment.AppendLine(textToAppend);
- }
-
- public void WriteLine(string format, params object[] args) {
- this.GenerationEnvironment.Append(this.currentIndent);
- this.GenerationEnvironment.AppendFormat(format, args);
- this.GenerationEnvironment.AppendLine();
- }
-
- public class ToStringInstanceHelper {
-
- private global::System.IFormatProvider formatProvider = global::System.Globalization.CultureInfo.InvariantCulture;
-
- public global::System.IFormatProvider FormatProvider {
- get {
- return this.formatProvider;
- }
- set {
- if ((value != null)) {
- this.formatProvider = value;
- }
- }
- }
-
- public string ToStringWithCulture(object objectToConvert) {
- if ((objectToConvert == null)) {
- throw new global::System.ArgumentNullException(""objectToConvert"");
- }
- global::System.Type type = objectToConvert.GetType();
- global::System.Type iConvertibleType = typeof(global::System.IConvertible);
- if (iConvertibleType.IsAssignableFrom(type)) {
- return ((global::System.IConvertible)(objectToConvert)).ToString(this.formatProvider);
- }
- global::System.Reflection.MethodInfo methInfo = type.GetMethod(""ToString"", new global::System.Type[] {
- iConvertibleType});
- if ((methInfo != null)) {
- return ((string)(methInfo.Invoke(objectToConvert, new object[] {
- this.formatProvider})));
- }
- return objectToConvert.ToString();
- }
- }
- }
-}
-";
-
- public static string Output_CaptureEncodingAndExtension =
-
- @"namespace Templating {
-
-
- public partial class PreprocessedTemplate : Foo {
-
- public override string TransformText() {
- this.GenerationEnvironment = null;
-
- #line 1 """"
- this.Write(""\n"");
-
- #line default
- #line hidden
- return this.GenerationEnvironment.ToString();
- }
-
- public override void Initialize() {
- if ((this.Host != null)) {
- this.Host.SetFileExtension("".cs"");
- this.Host.SetOutputEncoding(System.Text.Encoding.GetEncoding(65001, true));
- }
- base.Initialize();
- }
- }
-}";
- #endregion
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs
deleted file mode 100644
index da432927ba..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// Test.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.IO;
-
-namespace Mono.TextTemplating.Tests
-{
- public static class TemplatingEngineHelper
- {
- /// <summary>
- /// Cleans CodeDOM generated code so that Windows/Mac and Mono/.NET output can be compared.
- /// </summary>
- public static string CleanCodeDom (string input, string newLine)
- {
- using (var writer = new StringWriter ()) {
- using (var reader = new StringReader (input)) {
-
- bool afterLineDirective = true;
- bool stripHeader = true;
-
- string line;
- while ((line = reader.ReadLine ()) != null) {
-
- if (stripHeader) {
- if (line.StartsWith ("//", StringComparison.Ordinal) || string.IsNullOrWhiteSpace (line))
- continue;
- stripHeader = false;
- }
-
- if (afterLineDirective) {
- if (string.IsNullOrWhiteSpace (line))
- continue;
- afterLineDirective = false;
- }
-
- if (line.Contains ("#line")) {
- afterLineDirective = true;
- }
-
- writer.Write (line);
- writer.Write (newLine);
- }
- }
- return writer.ToString ();
- }
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TextTemplatingSessionTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TextTemplatingSessionTests.cs
deleted file mode 100644
index c5b0606394..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TextTemplatingSessionTests.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// TextTemplatingSessionTests.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2016 Xamarin Inc. (http://xamarin.com)
-//
-// 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.
-
-using System;
-using System.Reflection;
-using Microsoft.VisualStudio.TextTemplating;
-using NUnit.Framework;
-
-namespace Mono.TextTemplating.Tests
-{
- [TestFixture]
- public class TextTemplatingSessionTests
- {
- [Test]
- public void AppDomainSerializationTest ()
- {
- var guid = Guid.NewGuid ();
- var appDomain = AppDomain.CreateDomain ("TextTemplatingSessionSerializationTestAppDomain");
-
- var session = (TextTemplatingSession)appDomain.CreateInstanceFromAndUnwrap (
- typeof(TextTemplatingSession).Assembly.Location,
- typeof(TextTemplatingSession).FullName,
- false,
- BindingFlags.Public | BindingFlags.Instance,
- null,
- new object[] { guid },
- null,
- null);
-
- Assert.AreEqual (guid, session.Id);
- }
- }
-}
-
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/AssemblyInfo.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/AssemblyInfo.cs
deleted file mode 100644
index 13849716d3..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/AssemblyInfo.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// AssemblyInfo.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System;
-
-[assembly: AssemblyTitle("Mono.TextTemplating")]
-[assembly: AssemblyDescription("An implementation of Visual Studio's T4 text templating")]
-[assembly: AssemblyCompany("The Mono Project")]
-[assembly: AssemblyProduct("MonoDevelop")]
-[assembly: AssemblyCopyright("MIT/X11")]
-[assembly: CLSCompliant (true)]
-
-//[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Makefile.am b/main/src/addins/TextTemplating/Mono.TextTemplating/Makefile.am
deleted file mode 100644
index c9cc87438f..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-include $(top_srcdir)/xbuild.include
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs
deleted file mode 100644
index 133bcb64ca..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// DirectiveProcessor.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-using System.CodeDom;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public abstract class DirectiveProcessor : IDirectiveProcessor
- {
- CompilerErrorCollection errors;
-
- protected DirectiveProcessor ()
- {
- }
-
- public virtual void Initialize (ITextTemplatingEngineHost host)
- {
- if (host == null)
- throw new ArgumentNullException ("host");
- }
-
- public virtual void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
- {
- if (languageProvider == null)
- throw new ArgumentNullException ("languageProvider");
- this.errors = errors;
- }
-
- public abstract void FinishProcessingRun ();
- public abstract string GetClassCodeForProcessingRun ();
- public abstract string[] GetImportsForProcessingRun ();
- public abstract string GetPostInitializationCodeForProcessingRun ();
- public abstract string GetPreInitializationCodeForProcessingRun ();
- public abstract string[] GetReferencesForProcessingRun ();
- public abstract bool IsDirectiveSupported (string directiveName);
- public abstract void ProcessDirective (string directiveName, IDictionary<string, string> arguments);
-
- public virtual CodeAttributeDeclarationCollection GetTemplateClassCustomAttributes ()
- {
- return null;
- }
-
- CompilerErrorCollection IDirectiveProcessor.Errors { get { return errors; } }
-
- void IDirectiveProcessor.SetProcessingRunIsHostSpecific (bool hostSpecific)
- {
- }
-
- bool IDirectiveProcessor.RequiresProcessingRunIsHostSpecific {
- get { return false; }
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs
deleted file mode 100644
index 1d95facae1..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// DirectiveProcessorException.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Runtime.Serialization;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
-
- [Serializable]
- public class DirectiveProcessorException : Exception
- {
-
- public DirectiveProcessorException ()
- {
- }
-
- public DirectiveProcessorException (string message)
- : base (message)
- {
- }
-
- public DirectiveProcessorException (SerializationInfo info, StreamingContext context)
- : base (info, context)
- {
- }
-
- public DirectiveProcessorException (string message, Exception inner)
- : base (message, inner)
- {
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs
deleted file mode 100644
index beb7c9edb5..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// EncodingHelper.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// 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.
-
-using System;
-using System.Text;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public static class EncodingHelper
- {
- public static Encoding GetEncoding (string filePath)
- {
- throw new NotImplementedException ();
- }
- }
-}
-
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Engine.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Engine.cs
deleted file mode 100644
index fc9c9aacba..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Engine.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Engine.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using Mono.TextTemplating;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public class Engine : ITextTemplatingEngine
- {
- TemplatingEngine engine = new TemplatingEngine ();
-
- public Engine ()
- {
- }
-
- public string ProcessTemplate (string content, ITextTemplatingEngineHost host)
- {
- return engine.ProcessTemplate (content, host);
- }
-
- public string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
- string classNamespace, out string language, out string[] references)
- {
- return engine.PreprocessTemplate (content, host, className, classNamespace, out language, out references);
- }
-
- public const string CacheAssembliesOptionString = "CacheAssemblies";
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Interfaces.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Interfaces.cs
deleted file mode 100644
index bf7f62a23d..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Interfaces.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// ITextTemplatingEngineHost.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009-2010 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Text;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.Collections;
-using System.Runtime.Serialization;
-using System.CodeDom;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public interface IRecognizeHostSpecific
- {
- void SetProcessingRunIsHostSpecific (bool hostSpecific);
- bool RequiresProcessingRunIsHostSpecific { get; }
- }
-
- [CLSCompliant(true)]
- public interface ITextTemplatingEngine
- {
- string ProcessTemplate (string content, ITextTemplatingEngineHost host);
- string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
- string classNamespace, out string language, out string[] references);
- }
-
- [CLSCompliant(true)]
- public interface ITextTemplatingEngineHost
- {
- object GetHostOption (string optionName);
- bool LoadIncludeText (string requestFileName, out string content, out string location);
- void LogErrors (CompilerErrorCollection errors);
- AppDomain ProvideTemplatingAppDomain (string content);
- string ResolveAssemblyReference (string assemblyReference);
- Type ResolveDirectiveProcessor (string processorName);
- string ResolveParameterValue (string directiveId, string processorName, string parameterName);
- string ResolvePath (string path);
- void SetFileExtension (string extension);
- void SetOutputEncoding (Encoding encoding, bool fromOutputDirective);
- IList<string> StandardAssemblyReferences { get; }
- IList<string> StandardImports { get; }
- string TemplateFile { get; }
- }
-
- [CLSCompliant(true)]
- public interface ITextTemplatingSession :
- IEquatable<ITextTemplatingSession>, IEquatable<Guid>, IDictionary<string, Object>,
- ICollection<KeyValuePair<string, Object>>,
- IEnumerable<KeyValuePair<string, Object>>,
- IEnumerable, ISerializable
- {
- Guid Id { get; }
- }
-
- [CLSCompliant(true)]
- public interface ITextTemplatingSessionHost
- {
- ITextTemplatingSession CreateSession ();
- ITextTemplatingSession Session { get; set; }
- }
-
- public interface IDirectiveProcessor
- {
- CompilerErrorCollection Errors { get; }
- bool RequiresProcessingRunIsHostSpecific { get; }
-
- void FinishProcessingRun ();
- string GetClassCodeForProcessingRun ();
- string[] GetImportsForProcessingRun ();
- string GetPostInitializationCodeForProcessingRun ();
- string GetPreInitializationCodeForProcessingRun ();
- string[] GetReferencesForProcessingRun ();
- CodeAttributeDeclarationCollection GetTemplateClassCustomAttributes (); //TODO
- void Initialize (ITextTemplatingEngineHost host);
- bool IsDirectiveSupported (string directiveName);
- void ProcessDirective (string directiveName, IDictionary<string, string> arguments);
- void SetProcessingRunIsHostSpecific (bool hostSpecific);
- void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors);
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs
deleted file mode 100644
index cc5eb4123d..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-//
-// ParameterDirectiveProcessor.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// 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.
-
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.IO;
-using Mono.TextTemplating;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public sealed class ParameterDirectiveProcessor : DirectiveProcessor, IRecognizeHostSpecific
- {
- CodeDomProvider provider;
-
- bool hostSpecific;
- readonly List<CodeStatement> postStatements = new List<CodeStatement> ();
- readonly List<CodeTypeMember> members = new List<CodeTypeMember> ();
-
- public override void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
- {
- base.StartProcessingRun (languageProvider, templateContents, errors);
- provider = languageProvider;
- postStatements.Clear ();
- members.Clear ();
- }
-
- public override void FinishProcessingRun ()
- {
- var statement = new CodeConditionStatement (
- new CodeBinaryOperatorExpression (
- new CodePropertyReferenceExpression (
- new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "Errors"), "HasErrors"),
- CodeBinaryOperatorType.ValueEquality,
- new CodePrimitiveExpression (false)),
- postStatements.ToArray ());
-
- postStatements.Clear ();
- postStatements.Add (statement);
- }
-
- public override string GetClassCodeForProcessingRun ()
- {
- return TemplatingEngine.GenerateIndentedClassCode (provider, members);
- }
-
- public override string[] GetImportsForProcessingRun ()
- {
- return null;
- }
-
- public override string GetPostInitializationCodeForProcessingRun ()
- {
- return TemplatingEngine.IndentSnippetText (provider, StatementsToCode (postStatements), " ");
- }
-
- public override string GetPreInitializationCodeForProcessingRun ()
- {
- return null;
- }
-
- string StatementsToCode (List<CodeStatement> statements)
- {
- var options = new CodeGeneratorOptions ();
- using (var sw = new StringWriter ()) {
- foreach (var statement in statements)
- provider.GenerateCodeFromStatement (statement, sw, options);
- return sw.ToString ();
- }
- }
-
- public override string[] GetReferencesForProcessingRun ()
- {
- return null;
- }
-
- public override bool IsDirectiveSupported (string directiveName)
- {
- return directiveName == "parameter";
- }
-
- public override void ProcessDirective (string directiveName, IDictionary<string, string> arguments)
- {
- string name = arguments["name"];
- string type = arguments["type"];
- if (string.IsNullOrEmpty (name))
- throw new DirectiveProcessorException ("Parameter directive has no name argument");
- if (string.IsNullOrEmpty (type))
- throw new DirectiveProcessorException ("Parameter directive has no type argument");
-
- string fieldName = "_" + name + "Field";
- var typeRef = new CodeTypeReference (type);
- var thisRef = new CodeThisReferenceExpression ();
- var fieldRef = new CodeFieldReferenceExpression (thisRef, fieldName);
-
- var property = new CodeMemberProperty () {
- Name = name,
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- HasGet = true,
- HasSet = false,
- Type = typeRef
- };
- property.GetStatements.Add (new CodeMethodReturnStatement (fieldRef));
- members.Add (new CodeMemberField (typeRef, fieldName));
- members.Add (property);
-
- string acquiredName = "_" + name + "Acquired";
- var valRef = new CodeVariableReferenceExpression ("data");
- var namePrimitive = new CodePrimitiveExpression (name);
- var sessionRef = new CodePropertyReferenceExpression (thisRef, "Session");
- var callContextTypeRefExpr = new CodeTypeReferenceExpression ("System.Runtime.Remoting.Messaging.CallContext");
- var nullPrim = new CodePrimitiveExpression (null);
-
- var acquiredVariable = new CodeVariableDeclarationStatement (typeof (bool), acquiredName, new CodePrimitiveExpression (false));
- var acquiredVariableRef = new CodeVariableReferenceExpression (acquiredVariable.Name);
- this.postStatements.Add (acquiredVariable);
-
- //checks the local called "data" can be cast and assigned to the field, and if successful, sets acquiredVariable to true
- var checkCastThenAssignVal = new CodeConditionStatement (
- new CodeMethodInvokeExpression (
- new CodeTypeOfExpression (typeRef), "IsAssignableFrom", new CodeMethodInvokeExpression (valRef, "GetType")),
- new CodeStatement[] {
- new CodeAssignStatement (fieldRef, new CodeCastExpression (typeRef, valRef)),
- new CodeAssignStatement (acquiredVariableRef, new CodePrimitiveExpression (true)),
- },
- new CodeStatement[] {
- new CodeExpressionStatement (new CodeMethodInvokeExpression (thisRef, "Error",
- new CodePrimitiveExpression ("The type '" + type + "' of the parameter '" + name +
- "' did not match the type passed to the template"))),
- });
-
- //tries to gets the value from the session
- var checkSession = new CodeConditionStatement (
- new CodeBinaryOperatorExpression (NotNull (sessionRef), CodeBinaryOperatorType.BooleanAnd,
- new CodeMethodInvokeExpression (sessionRef, "ContainsKey", namePrimitive)),
- new CodeVariableDeclarationStatement (typeof (object), "data", new CodeIndexerExpression (sessionRef, namePrimitive)),
- checkCastThenAssignVal);
-
- this.postStatements.Add (checkSession);
-
- //if acquiredVariable is false, tries to gets the value from the host
- if (hostSpecific) {
- var hostRef = new CodePropertyReferenceExpression (thisRef, "Host");
- var checkHost = new CodeConditionStatement (
- BooleanAnd (IsFalse (acquiredVariableRef), NotNull (hostRef)),
- new CodeVariableDeclarationStatement (typeof (string), "data",
- new CodeMethodInvokeExpression (hostRef, "ResolveParameterValue", nullPrim, nullPrim, namePrimitive)),
- new CodeConditionStatement (NotNull (valRef), checkCastThenAssignVal));
-
- this.postStatements.Add (checkHost);
- }
-
- //if acquiredVariable is false, tries to gets the value from the call context
- var checkCallContext = new CodeConditionStatement (
- IsFalse (acquiredVariableRef),
- new CodeVariableDeclarationStatement (typeof (object), "data",
- new CodeMethodInvokeExpression (callContextTypeRefExpr, "LogicalGetData", namePrimitive)),
- new CodeConditionStatement (NotNull (valRef), checkCastThenAssignVal));
-
- this.postStatements.Add (checkCallContext);
- }
-
- static CodeBinaryOperatorExpression NotNull (CodeExpression reference)
- {
- return new CodeBinaryOperatorExpression (reference, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression (null));
- }
-
- static CodeBinaryOperatorExpression IsFalse (CodeExpression expr)
- {
- return new CodeBinaryOperatorExpression (expr, CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (false));
- }
-
- static CodeBinaryOperatorExpression BooleanAnd (CodeExpression expr1, CodeExpression expr2)
- {
- return new CodeBinaryOperatorExpression (expr1, CodeBinaryOperatorType.BooleanAnd, expr2);
- }
-
- void IRecognizeHostSpecific.SetProcessingRunIsHostSpecific (bool hostSpecific)
- {
- this.hostSpecific = hostSpecific;
- }
-
- public bool RequiresProcessingRunIsHostSpecific {
- get { return false; }
- }
- }
-}
-
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs
deleted file mode 100644
index bb48357c32..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs
+++ /dev/null
@@ -1,196 +0,0 @@
-//
-// RequiresProvidesDirectiveProcessor.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-using System.Text;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
-
-
- public abstract class RequiresProvidesDirectiveProcessor : DirectiveProcessor
- {
- bool isInProcessingRun;
- ITextTemplatingEngineHost host;
- StringBuilder preInitBuffer = new StringBuilder ();
- StringBuilder postInitBuffer = new StringBuilder ();
- StringBuilder codeBuffer = new StringBuilder ();
- CodeDomProvider languageProvider;
-
- protected RequiresProvidesDirectiveProcessor ()
- {
- }
-
- public override void Initialize (ITextTemplatingEngineHost host)
- {
- base.Initialize (host);
- this.host = host;
- }
-
- protected abstract void InitializeProvidesDictionary (string directiveName, IDictionary<string, string> providesDictionary);
- protected abstract void InitializeRequiresDictionary (string directiveName, IDictionary<string, string> requiresDictionary);
- protected abstract string FriendlyName { get; }
-
- protected abstract void GeneratePostInitializationCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
- IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments);
- protected abstract void GeneratePreInitializationCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
- IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments);
- protected abstract void GenerateTransformCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
- IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments);
-
- protected virtual void PostProcessArguments (string directiveName, IDictionary<string, string> requiresArguments,
- IDictionary<string, string> providesArguments)
- {
- }
-
- public override string GetClassCodeForProcessingRun ()
- {
- AssertNotProcessing ();
- return codeBuffer.ToString ();
- }
-
- public override string[] GetImportsForProcessingRun ()
- {
- AssertNotProcessing ();
- return null;
- }
-
- public override string[] GetReferencesForProcessingRun ()
- {
- AssertNotProcessing ();
- return null;
- }
-
- public override string GetPostInitializationCodeForProcessingRun ()
- {
- AssertNotProcessing ();
- return postInitBuffer.ToString ();
- }
-
- public override string GetPreInitializationCodeForProcessingRun ()
- {
- AssertNotProcessing ();
- return preInitBuffer.ToString ();
- }
-
- public override void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
- {
- AssertNotProcessing ();
- isInProcessingRun = true;
- base.StartProcessingRun (languageProvider, templateContents, errors);
-
- this.languageProvider = languageProvider;
- codeBuffer.Length = 0;
- preInitBuffer.Length = 0;
- postInitBuffer.Length = 0;
- }
-
- public override void FinishProcessingRun ()
- {
- isInProcessingRun = false;
- }
-
- void AssertNotProcessing ()
- {
- if (isInProcessingRun)
- throw new InvalidOperationException ();
- }
-
- //FIXME: handle escaping
- IEnumerable<KeyValuePair<string,string>> ParseArgs (string args)
- {
- var pairs = args.Split (';');
- foreach (var p in pairs) {
- int eq = p.IndexOf ('=');
- var k = p.Substring (0, eq);
- var v = p.Substring (eq);
- yield return new KeyValuePair<string, string> (k, v);
- }
- }
-
- public override void ProcessDirective (string directiveName, IDictionary<string, string> arguments)
- {
- if (directiveName == null)
- throw new ArgumentNullException ("directiveName");
- if (arguments == null)
- throw new ArgumentNullException ("arguments");
-
- var providesDictionary = new Dictionary<string,string> ();
- var requiresDictionary = new Dictionary<string,string> ();
-
- string provides;
- if (arguments.TryGetValue ("provides", out provides)) {
- foreach (var arg in ParseArgs (provides)) {
- providesDictionary.Add (arg.Key, arg.Value);
- }
- }
-
- string requires;
- if (arguments.TryGetValue ("requires", out requires)) {
- foreach (var arg in ParseArgs (requires)) {
- requiresDictionary.Add (arg.Key, arg.Value);
- }
- }
-
- InitializeRequiresDictionary (directiveName, requiresDictionary);
- InitializeProvidesDictionary (directiveName, providesDictionary);
-
- var id = ProvideUniqueId (directiveName, arguments, requiresDictionary, providesDictionary);
-
- foreach (var req in requiresDictionary) {
- var val = host.ResolveParameterValue (id, FriendlyName, req.Key);
- if (val != null)
- requiresDictionary[req.Key] = val;
- else if (req.Value == null)
- throw new DirectiveProcessorException ("Could not resolve required value '" + req.Key + "'");
- }
-
- foreach (var req in providesDictionary) {
- var val = host.ResolveParameterValue (id, FriendlyName, req.Key);
- if (val != null)
- providesDictionary[req.Key] = val;
- }
-
- PostProcessArguments (directiveName, requiresDictionary, providesDictionary);
-
- GeneratePreInitializationCode (directiveName, preInitBuffer, languageProvider, requiresDictionary, providesDictionary);
- GeneratePostInitializationCode (directiveName, postInitBuffer, languageProvider, requiresDictionary, providesDictionary);
- GenerateTransformCode (directiveName, codeBuffer, languageProvider, requiresDictionary, providesDictionary);
- }
-
- protected virtual string ProvideUniqueId (string directiveName, IDictionary<string, string> arguments,
- IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments)
- {
- return directiveName;
- }
-
- protected ITextTemplatingEngineHost Host {
- get { return host; }
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs
deleted file mode 100644
index cf1fc83b20..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// TextTemplatingSession.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// 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.
-using System;
-using System.Collections.Generic;
-using System.Collections;
-using System.Runtime.Serialization;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- [Serializable]
- public sealed class TextTemplatingSession : Dictionary<string, Object>, ITextTemplatingSession, ISerializable
- {
- public TextTemplatingSession () : this (Guid.NewGuid ())
- {
- }
-
- TextTemplatingSession (SerializationInfo info, StreamingContext context)
- : base (info, context)
- {
- Id = (Guid)info.GetValue ("Id", typeof (Guid));
- }
-
- public TextTemplatingSession (Guid id)
- {
- this.Id = id;
- }
-
- public Guid Id {
- get; private set;
- }
-
- public override int GetHashCode ()
- {
- return Id.GetHashCode ();
- }
-
- public override bool Equals (object obj)
- {
- var o = obj as TextTemplatingSession;
- return o != null && o.Equals (this);
- }
-
- public bool Equals (Guid other)
- {
- return other.Equals (Id);
- }
-
- public bool Equals (ITextTemplatingSession other)
- {
- return other != null && other.Id == this.Id;
- }
-
- void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
- {
- base.GetObjectData (info, context);
- info.AddValue ("Id", Id);
- }
- }
-}
-
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTransformation.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTransformation.cs
deleted file mode 100644
index f6a597752d..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTransformation.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-//
-// TextTransformation.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public abstract class TextTransformation : IDisposable
- {
- Stack<int> indents;
- string currentIndent = string.Empty;
- CompilerErrorCollection errors;
- StringBuilder builder;
- bool endsWithNewline;
-
- public TextTransformation ()
- {
- }
-
- public virtual void Initialize ()
- {
- }
-
- public abstract string TransformText ();
-
- public virtual IDictionary<string, object> Session { get; set; }
-
- #region Errors
-
- public void Error (string message)
- {
- Errors.Add (new CompilerError ("", 0, 0, "", message));
- }
-
- public void Warning (string message)
- {
- Errors.Add (new CompilerError ("", 0, 0, "", message) { IsWarning = true });
- }
-
- protected internal CompilerErrorCollection Errors {
- get {
- if (errors == null)
- errors = new CompilerErrorCollection ();
- return errors;
- }
- }
-
- Stack<int> Indents {
- get {
- if (indents == null)
- indents = new Stack<int> ();
- return indents;
- }
- }
-
- #endregion
-
- #region Indents
-
- public string PopIndent ()
- {
- if (Indents.Count == 0)
- return "";
- int lastPos = currentIndent.Length - Indents.Pop ();
- string last = currentIndent.Substring (lastPos);
- currentIndent = currentIndent.Substring (0, lastPos);
- return last;
- }
-
- public void PushIndent (string indent)
- {
- if (indent == null)
- throw new ArgumentNullException ("indent");
- Indents.Push (indent.Length);
- currentIndent += indent;
- }
-
- public void ClearIndent ()
- {
- currentIndent = string.Empty;
- Indents.Clear ();
- }
-
- public string CurrentIndent {
- get { return currentIndent; }
- }
-
- #endregion
-
- #region Writing
-
- protected StringBuilder GenerationEnvironment {
- get {
- if (builder == null)
- builder = new StringBuilder ();
- return builder;
- }
- set {
- builder = value;
- }
- }
-
- public void Write (string textToAppend)
- {
- if (string.IsNullOrEmpty (textToAppend))
- return;
-
- if ((GenerationEnvironment.Length == 0 || endsWithNewline) && CurrentIndent.Length > 0) {
- GenerationEnvironment.Append (CurrentIndent);
- }
- endsWithNewline = false;
-
- char last = textToAppend[textToAppend.Length-1];
- if (last == '\n' || last == '\r') {
- endsWithNewline = true;
- }
-
- if (CurrentIndent.Length == 0) {
- GenerationEnvironment.Append (textToAppend);
- return;
- }
-
- //insert CurrentIndent after every newline (\n, \r, \r\n)
- //but if there's one at the end of the string, ignore it, it'll be handled next time thanks to endsWithNewline
- int lastNewline = 0;
- for (int i = 0; i < textToAppend.Length - 1; i++) {
- char c = textToAppend[i];
- if (c == '\r') {
- if (textToAppend[i + 1] == '\n') {
- i++;
- if (i == textToAppend.Length - 1)
- break;
- }
- } else if (c != '\n') {
- continue;
- }
- i++;
- int len = i - lastNewline;
- if (len > 0) {
- GenerationEnvironment.Append (textToAppend, lastNewline, i - lastNewline);
- }
- GenerationEnvironment.Append (CurrentIndent);
- lastNewline = i;
- }
- if (lastNewline > 0)
- GenerationEnvironment.Append (textToAppend, lastNewline, textToAppend.Length - lastNewline);
- else
- GenerationEnvironment.Append (textToAppend);
- }
-
- public void Write (string format, params object[] args)
- {
- Write (string.Format (format, args));
- }
-
- public void WriteLine (string textToAppend)
- {
- Write (textToAppend);
- GenerationEnvironment.AppendLine ();
- endsWithNewline = true;
- }
-
- public void WriteLine (string format, params object[] args)
- {
- WriteLine (string.Format (format, args));
- }
-
- #endregion
-
- #region Dispose
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- }
-
- ~TextTransformation ()
- {
- Dispose (false);
- }
-
- #endregion
-
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs
deleted file mode 100644
index 7f5934e238..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// ToStringHelper.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public static class ToStringHelper
- {
- static object [] formatProviderAsParameterArray;
-
- static IFormatProvider formatProvider = System.Globalization.CultureInfo.InvariantCulture;
-
- static ToStringHelper ()
- {
- formatProviderAsParameterArray = new object[] { formatProvider };
- }
-
- public static string ToStringWithCulture (object objectToConvert)
- {
- if (objectToConvert == null)
- throw new ArgumentNullException ("objectToConvert");
-
- IConvertible conv = objectToConvert as IConvertible;
- if (conv != null)
- return conv.ToString (formatProvider);
-
- var str = objectToConvert as string;
- if (str != null)
- return str;
-
- //TODO: implement a cache of types and DynamicMethods
- MethodInfo mi = objectToConvert.GetType ().GetMethod ("ToString", new Type[] { typeof (IFormatProvider) });
- if (mi != null)
- return (string) mi.Invoke (objectToConvert, formatProviderAsParameterArray);
- return objectToConvert.ToString ();
- }
-
- public static IFormatProvider FormatProvider {
- get { return (IFormatProvider)formatProviderAsParameterArray[0]; }
- set { formatProviderAsParameterArray[0] = formatProvider = value; }
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.csproj b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.csproj
deleted file mode 100644
index 0c9a3d1d8e..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.csproj
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <Import Project="..\..\..\..\MonoDevelop.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{A2364D6A-00EF-417C-80A6-815726C70032}</ProjectGuid>
- <OutputType>Library</OutputType>
- <RootNamespace>Mono.TextTemplating</RootNamespace>
- <AssemblyName>Mono.TextTemplating</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>True</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>False</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.TextTemplating</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <ConsolePause>False</ConsolePause>
- <NoWarn>1591;1573</NoWarn>
- <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.TextTemplating\Mono.TextTemplating.xml</DocumentationFile>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.TextTemplating</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <ConsolePause>False</ConsolePause>
- <DebugSymbols>true</DebugSymbols>
- <NoWarn>1591;1573</NoWarn>
- <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.TextTemplating\Mono.TextTemplating.xml</DocumentationFile>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Microsoft.VisualStudio.TextTemplating\DirectiveProcessor.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\DirectiveProcessorException.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\Engine.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\RequiresProvidesDirectiveProcessor.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\TextTransformation.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\ToStringHelper.cs" />
- <Compile Include="Mono.TextTemplating\CompiledTemplate.cs" />
- <Compile Include="Mono.TextTemplating\ParsedTemplate.cs" />
- <Compile Include="Mono.TextTemplating\Tokeniser.cs" />
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="Mono.TextTemplating\TemplateGenerator.cs" />
- <Compile Include="Mono.TextTemplating\TemplatingEngine.cs" />
- <Compile Include="Mono.TextTemplating\TemplateSettings.cs" />
- <Compile Include="Mono.TextTemplating\CrossAppDomainAssemblyResolver.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\EncodingHelper.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\ParameterDirectiveProcessor.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\TextTemplatingSession.cs" />
- <Compile Include="Microsoft.VisualStudio.TextTemplating\Interfaces.cs" />
- <Compile Include="Mono.TextTemplating\RecyclableAppDomain.cs" />
- <Compile Include="Mono.TextTemplating\FileUtil.cs" />
- </ItemGroup>
- <ItemGroup>
- <Folder Include="Microsoft.VisualStudio.TextTemplating\" />
- <Folder Include="Mono.TextTemplating\" />
- </ItemGroup>
- <ItemGroup>
- <InternalsVisibleTo Include="Mono.TextTemplating.Tests" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ProjectExtensions>
- <MonoDevelop>
- <Properties>
- <Policies>
- <DotNetNamingPolicy DirectoryNamespaceAssociation="Flat" ResourceNamePolicy="FileName" />
- </Policies>
- </Properties>
- </MonoDevelop>
- </ProjectExtensions>
-</Project>
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.nuspec b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.nuspec
deleted file mode 100644
index 9b294cf88e..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.nuspec
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
- <metadata>
- <id>Mono.TextTemplating</id>
- <version>1.1.0</version>
- <title>Mono.TextTemplating</title>
- <authors>Mikayla Hutchinson</authors>
- <licenseUrl>http://opensource.org/licenses/MIT</licenseUrl>
- <projectUrl>https://github.com/mono/monodevelop/tree/master/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating</projectUrl>
- <requireLicenseAcceptance>false</requireLicenseAcceptance>
- <description>Open-source implementation of the T4 templating engine.</description>
- <releaseNotes>Built from MonoDevelop git repository, commit ad93842159363eaaebcb36701ac95a4eaef23c87</releaseNotes>
- <copyright>2009-2011 Novell, Inc. 2011-2016 Xamarin Inc.</copyright>
- <tags>T4, templating</tags>
- </metadata>
- <files>
- <file src="../../../../build/AddIns/MonoDevelop.TextTemplating/Mono.TextTemplating.dll" target="lib/net45/Mono.TextTemplating.dll" />
- <file src="../../../../build/AddIns/MonoDevelop.TextTemplating/TextTransform.exe" target="tools/TextTransform.exe" />
- <file src="../../../../build/AddIns/MonoDevelop.TextTemplating/Mono.TextTemplating.dll" target="tools/Mono.TextTemplating.dll" />
- </files>
-</package>
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs
deleted file mode 100644
index 3679b6f860..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//
-// CompiledTemplate.cs
-//
-// Author:
-// Nathan Baulch <nathan.baulch@gmail.com>
-//
-// Copyright (c) 2009 Nathan Baulch
-//
-// 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.
-
-using System;
-using System.Reflection;
-using Microsoft.VisualStudio.TextTemplating;
-using System.CodeDom.Compiler;
-using System.Globalization;
-using System.Collections.Generic;
-
-namespace Mono.TextTemplating
-{
- public sealed class CompiledTemplate : MarshalByRefObject, IDisposable
- {
- ITextTemplatingEngineHost host;
- object textTransformation;
- readonly CultureInfo culture;
- readonly string[] assemblyFiles;
-
- public CompiledTemplate (ITextTemplatingEngineHost host, CompilerResults results, string fullName, CultureInfo culture,
- string[] assemblyFiles)
- {
- AppDomain.CurrentDomain.AssemblyResolve += ResolveReferencedAssemblies;
- this.host = host;
- this.culture = culture;
- this.assemblyFiles = assemblyFiles;
- Load (results, fullName);
- }
-
- void Load (CompilerResults results, string fullName)
- {
- var assembly = results.CompiledAssembly;
- Type transformType = assembly.GetType (fullName);
- //MS Templating Engine does not look on the type itself,
- //it checks only that required methods are exists in the compiled type
- textTransformation = Activator.CreateInstance (transformType);
-
- //set the host property if it exists
- Type hostType = null;
- var gen = host as TemplateGenerator;
- if (gen != null) {
- hostType = gen.SpecificHostType;
- }
- var hostProp = transformType.GetProperty ("Host", hostType ?? typeof(ITextTemplatingEngineHost));
- if (hostProp != null && hostProp.CanWrite)
- hostProp.SetValue (textTransformation, host, null);
-
- var sessionHost = host as ITextTemplatingSessionHost;
- if (sessionHost != null) {
- //FIXME: should we create a session if it's null?
- var sessionProp = transformType.GetProperty ("Session", typeof (IDictionary<string, object>));
- sessionProp.SetValue (textTransformation, sessionHost.Session, null);
- }
- }
-
- public string Process ()
- {
- var ttType = textTransformation.GetType ();
-
- var errorProp = ttType.GetProperty ("Errors", BindingFlags.Instance | BindingFlags.NonPublic);
- if (errorProp == null)
- throw new ArgumentException ("Template must have 'Errors' property");
- var errorMethod = ttType.GetMethod ("Error",new Type[]{typeof(string)});
- if (errorMethod == null) {
- throw new ArgumentException ("Template must have 'Error(string message)' method");
- }
-
- var errors = (CompilerErrorCollection) errorProp.GetValue (textTransformation);
- errors.Clear ();
-
- //set the culture
- if (culture != null)
- ToStringHelper.FormatProvider = culture;
- else
- ToStringHelper.FormatProvider = CultureInfo.InvariantCulture;
-
- string output = null;
-
- var initMethod = ttType.GetMethod ("Initialize");
- var transformMethod = ttType.GetMethod ("TransformText");
-
- if (initMethod == null) {
- errorMethod.Invoke (textTransformation, new object[]{ "Error running transform: no method Initialize()" });
- } else if (transformMethod == null) {
- errorMethod.Invoke (textTransformation, new object[]{ "Error running transform: no method TransformText()" });
- } else try {
- initMethod.Invoke (textTransformation, null);
- output = (string)transformMethod.Invoke (textTransformation, null);
- } catch (Exception ex) {
- errorMethod.Invoke (textTransformation, new object[]{ "Error running transform: " + ex });
- }
-
- host.LogErrors (errors);
-
- ToStringHelper.FormatProvider = CultureInfo.InvariantCulture;
- return output;
- }
-
- Assembly ResolveReferencedAssemblies (object sender, ResolveEventArgs args)
- {
- AssemblyName asmName = new AssemblyName (args.Name);
- foreach (var asmFile in assemblyFiles) {
- if (asmName.Name == System.IO.Path.GetFileNameWithoutExtension (asmFile))
- return Assembly.LoadFrom (asmFile);
- }
-
- var path = host.ResolveAssemblyReference (asmName.Name + ".dll");
- if (System.IO.File.Exists (path))
- return Assembly.LoadFrom (path);
-
- return null;
- }
-
- public void Dispose ()
- {
- if (host != null) {
- host = null;
- AppDomain.CurrentDomain.AssemblyResolve -= ResolveReferencedAssemblies;
- }
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs
deleted file mode 100644
index b15feeba2e..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// CrossAppDomainAssemblyResolver.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-
-namespace Mono.TextTemplating
-{
- /// <summary>
- /// Provides a handler for AssemblyResolve events that looks them up in the domain that created the resolver.
- /// </summary>
- [Serializable]
- public class CrossAppDomainAssemblyResolver
- {
- readonly ParentDomainLookup parent = new ParentDomainLookup ();
-
- public System.Reflection.Assembly Resolve (object sender, ResolveEventArgs args)
- {
- var location = parent.GetAssemblyPath (args.Name);
- if (location != null)
- return System.Reflection.Assembly.LoadFrom (location);
- return null;
- }
-
- class ParentDomainLookup : MarshalByRefObject
- {
- public string GetAssemblyPath (string name)
- {
- var assem = System.Reflection.Assembly.Load (name);
- if (assem != null)
- return assem.Location;
- return null;
- }
- }
- }
-}
-
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/FileUtil.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/FileUtil.cs
deleted file mode 100644
index 62289db3db..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/FileUtil.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-//
-// FileUtil.cs
-//
-// Author:
-// Michael Hutchinson <m.j.hutchinson@gmail.com>
-//
-// Copyright (c) 2013 Xamarin Inc.
-//
-// 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.
-using System;
-using System.IO;
-
-namespace Mono.TextTemplating
-{
- static class FileUtil
- {
- //from MonoDevelop.Core.FileService, copied here so Mono.TextTemplating can be used w/o MD dependency
- public unsafe static string AbsoluteToRelativePath (string baseDirectoryPath, string absPath)
- {
- if (!Path.IsPathRooted (absPath) || string.IsNullOrEmpty (baseDirectoryPath))
- return absPath;
-
- absPath = GetFullPath (absPath);
- baseDirectoryPath = GetFullPath (baseDirectoryPath).TrimEnd (Path.DirectorySeparatorChar);
-
- fixed (char* bPtr = baseDirectoryPath, aPtr = absPath) {
- var bEnd = bPtr + baseDirectoryPath.Length;
- var aEnd = aPtr + absPath.Length;
- char* lastStartA = aEnd;
- char* lastStartB = bEnd;
-
- int indx = 0;
- // search common base path
- var a = aPtr;
- var b = bPtr;
- while (a < aEnd) {
- if (*a != *b)
- break;
- if (IsSeparator (*a)) {
- indx++;
- lastStartA = a + 1;
- lastStartB = b;
- }
- a++;
- b++;
- if (b >= bEnd) {
- if (a >= aEnd || IsSeparator (*a)) {
- indx++;
- lastStartA = a + 1;
- lastStartB = b;
- }
- break;
- }
- }
- if (indx == 0)
- return absPath;
-
- if (lastStartA >= aEnd)
- return ".";
-
- // handle case a: some/path b: some/path/deeper...
- if (a >= aEnd) {
- if (IsSeparator (*b)) {
- lastStartA = a + 1;
- lastStartB = b;
- }
- }
-
- // look how many levels to go up into the base path
- int goUpCount = 0;
- while (lastStartB < bEnd) {
- if (IsSeparator (*lastStartB))
- goUpCount++;
- lastStartB++;
- }
- var size = goUpCount * 2 + goUpCount + aEnd - lastStartA;
- var result = new char [size];
- fixed (char* rPtr = result) {
- // go paths up
- var r = rPtr;
- for (int i = 0; i < goUpCount; i++) {
- *(r++) = '.';
- *(r++) = '.';
- *(r++) = Path.DirectorySeparatorChar;
- }
- // copy the remaining absulute path
- while (lastStartA < aEnd)
- *(r++) = *(lastStartA++);
- }
- return new string (result);
- }
- }
-
- static bool IsSeparator (char ch)
- {
- return ch == Path.DirectorySeparatorChar || ch == Path.AltDirectorySeparatorChar || ch == Path.VolumeSeparatorChar;
- }
-
- static string GetFullPath (string path)
- {
- if (path == null)
- throw new ArgumentNullException ("path");
- if (!isWindows || path.IndexOf ('*') == -1)
- return Path.GetFullPath (path);
- else {
- // On Windows, GetFullPath doesn't work if the path contains wildcards.
- path = path.Replace ("*", wildcardMarker);
- path = Path.GetFullPath (path);
- return path.Replace (wildcardMarker, "*");
- }
- }
-
- static readonly string wildcardMarker = "_" + Guid.NewGuid () + "_";
- static readonly bool isWindows = Path.DirectorySeparatorChar == '\\';
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/ParsedTemplate.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/ParsedTemplate.cs
deleted file mode 100644
index 1e20c0cf49..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/ParsedTemplate.cs
+++ /dev/null
@@ -1,337 +0,0 @@
-//
-// Template.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.IO;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating
-{
- public class ParsedTemplate
- {
- readonly List<ISegment> segments = new List<ISegment> ();
- readonly List<ISegment> importedHelperSegments = new List<ISegment> ();
- readonly CompilerErrorCollection errors = new CompilerErrorCollection ();
- readonly string rootFileName;
-
- public ParsedTemplate (string rootFileName)
- {
- this.rootFileName = rootFileName;
- }
-
- public List<ISegment> RawSegments {
- get { return segments; }
- }
-
- public IEnumerable<Directive> Directives {
- get {
- foreach (ISegment seg in segments) {
- var dir = seg as Directive;
- if (dir != null)
- yield return dir;
- }
- }
- }
-
- public IEnumerable<TemplateSegment> Content {
- get {
- foreach (ISegment seg in segments) {
- var ts = seg as TemplateSegment;
- if (ts != null)
- yield return ts;
- }
- }
- }
-
- public CompilerErrorCollection Errors {
- get { return errors; }
- }
-
- public static ParsedTemplate FromText (string content, ITextTemplatingEngineHost host)
- {
- ParsedTemplate template = new ParsedTemplate (host.TemplateFile);
- try {
- template.Parse (host, new Tokeniser (host.TemplateFile, content));
- } catch (ParserException ex) {
- template.LogError (ex.Message, ex.Location);
- }
- return template;
- }
-
- public void Parse (ITextTemplatingEngineHost host, Tokeniser tokeniser)
- {
- Parse (host, tokeniser, true);
- }
-
- public void ParseWithoutIncludes (Tokeniser tokeniser)
- {
- Parse (null, tokeniser, false);
- }
-
- void Parse (ITextTemplatingEngineHost host, Tokeniser tokeniser, bool parseIncludes)
- {
- Parse (host, tokeniser, parseIncludes, false);
- }
-
- void Parse (ITextTemplatingEngineHost host, Tokeniser tokeniser, bool parseIncludes, bool isImport)
- {
- bool skip = false;
- bool addToImportedHelpers = false;
- while ((skip || tokeniser.Advance ()) && tokeniser.State != State.EOF) {
- skip = false;
- ISegment seg = null;
- switch (tokeniser.State) {
- case State.Block:
- if (!String.IsNullOrEmpty (tokeniser.Value))
- seg = new TemplateSegment (SegmentType.Block, tokeniser.Value, tokeniser.Location);
- break;
- case State.Content:
- if (!String.IsNullOrEmpty (tokeniser.Value))
- seg = new TemplateSegment (SegmentType.Content, tokeniser.Value, tokeniser.Location);
- break;
- case State.Expression:
- if (!String.IsNullOrEmpty (tokeniser.Value))
- seg = new TemplateSegment (SegmentType.Expression, tokeniser.Value, tokeniser.Location);
- break;
- case State.Helper:
- addToImportedHelpers = isImport;
- if (!String.IsNullOrEmpty (tokeniser.Value))
- seg = new TemplateSegment (SegmentType.Helper, tokeniser.Value, tokeniser.Location);
- break;
- case State.Directive:
- Directive directive = null;
- string attName = null;
- while (!skip && tokeniser.Advance ()) {
- switch (tokeniser.State) {
- case State.DirectiveName:
- if (directive == null) {
- directive = new Directive (tokeniser.Value, tokeniser.Location);
- directive.TagStartLocation = tokeniser.TagStartLocation;
- if (!parseIncludes || !string.Equals (directive.Name, "include", StringComparison.OrdinalIgnoreCase))
- segments.Add (directive);
- } else
- attName = tokeniser.Value;
- break;
- case State.DirectiveValue:
- if (attName != null && directive != null)
- directive.Attributes[attName] = tokeniser.Value;
- else
- LogError ("Directive value without name", tokeniser.Location);
- attName = null;
- break;
- case State.Directive:
- if (directive != null)
- directive.EndLocation = tokeniser.TagEndLocation;
- break;
- default:
- skip = true;
- break;
- }
- }
- if (parseIncludes && directive != null && string.Equals (directive.Name, "include", StringComparison.OrdinalIgnoreCase))
- Import (host, directive, Path.GetDirectoryName (tokeniser.Location.FileName));
- break;
- default:
- throw new InvalidOperationException ();
- }
- if (seg != null) {
- seg.TagStartLocation = tokeniser.TagStartLocation;
- seg.EndLocation = tokeniser.TagEndLocation;
- if (addToImportedHelpers)
- importedHelperSegments.Add (seg);
- else
- segments.Add (seg);
- }
- }
- if (!isImport)
- AppendAnyImportedHelperSegments ();
- }
-
- void Import (ITextTemplatingEngineHost host, Directive includeDirective, string relativeToDirectory)
- {
- string fileName;
- if (includeDirective.Attributes.Count > 1 || !includeDirective.Attributes.TryGetValue ("file", out fileName)) {
- LogError ("Unexpected attributes in include directive", includeDirective.StartLocation);
- return;
- }
-
- //try to resolve path relative to the file that included it
- if (relativeToDirectory != null && !Path.IsPathRooted (fileName)) {
- string possible = Path.Combine (relativeToDirectory, fileName);
- if (File.Exists (possible))
- fileName = Path.GetFullPath (possible);
- }
-
- string content, resolvedName;
- if (host.LoadIncludeText (fileName, out content, out resolvedName))
- Parse (host, new Tokeniser (resolvedName, content), true, true);
- else
- LogError ("Could not resolve include file '" + fileName + "'.", includeDirective.StartLocation);
- }
-
- void AppendAnyImportedHelperSegments ()
- {
- segments.AddRange (importedHelperSegments);
- importedHelperSegments.Clear ();
- }
-
- void LogError (string message, Location location, bool isWarning)
- {
- var err = new CompilerError ();
- err.ErrorText = message;
- if (location.FileName != null) {
- err.Line = location.Line;
- err.Column = location.Column;
- err.FileName = location.FileName ?? string.Empty;
- } else {
- err.FileName = rootFileName ?? string.Empty;
- }
- err.IsWarning = isWarning;
- errors.Add (err);
- }
-
- public void LogError (string message)
- {
- LogError (message, Location.Empty, false);
- }
-
- public void LogWarning (string message)
- {
- LogError (message, Location.Empty, true);
- }
-
- public void LogError (string message, Location location)
- {
- LogError (message, location, false);
- }
-
- public void LogWarning (string message, Location location)
- {
- LogError (message, location, true);
- }
- }
-
- public interface ISegment
- {
- Location StartLocation { get; }
- Location EndLocation { get; set; }
- Location TagStartLocation {get; set; }
- }
-
- public class TemplateSegment : ISegment
- {
- public TemplateSegment (SegmentType type, string text, Location start)
- {
- this.Type = type;
- this.StartLocation = start;
- this.Text = text;
- }
-
- public SegmentType Type { get; private set; }
- public string Text { get; private set; }
- public Location TagStartLocation { get; set; }
- public Location StartLocation { get; private set; }
- public Location EndLocation { get; set; }
- }
-
- public class Directive : ISegment
- {
- public Directive (string name, Location start)
- {
- this.Name = name;
- this.Attributes = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase);
- this.StartLocation = start;
- }
-
- public string Name { get; private set; }
- public Dictionary<string,string> Attributes { get; private set; }
- public Location TagStartLocation { get; set; }
- public Location StartLocation { get; private set; }
- public Location EndLocation { get; set; }
-
- public string Extract (string key)
- {
- string value;
- if (!Attributes.TryGetValue (key, out value))
- return null;
- Attributes.Remove (key);
- return value;
- }
- }
-
- public enum SegmentType
- {
- Block,
- Expression,
- Content,
- Helper
- }
-
- public struct Location : IEquatable<Location>
- {
- public Location (string fileName, int line, int column) : this()
- {
- FileName = fileName;
- Column = column;
- Line = line;
- }
-
- public int Line { get; private set; }
- public int Column { get; private set; }
- public string FileName { get; private set; }
-
- public static Location Empty {
- get { return new Location (null, -1, -1); }
- }
-
- public Location AddLine ()
- {
- return new Location (FileName, Line + 1, 1);
- }
-
- public Location AddCol ()
- {
- return AddCols (1);
- }
-
- public Location AddCols (int number)
- {
- return new Location (this.FileName, this.Line, this.Column + number);
- }
-
- public override string ToString ()
- {
- return string.Format("[{0} ({1},{2})]", FileName, Line, Column);
- }
-
- public bool Equals (Location other)
- {
- return other.Line == Line && other.Column == Column && other.FileName == FileName;
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/RecyclableAppDomain.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/RecyclableAppDomain.cs
deleted file mode 100644
index 0de9c52226..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/RecyclableAppDomain.cs
+++ /dev/null
@@ -1,215 +0,0 @@
-//
-// RecyclableAppDomain.cs
-//
-// Author:
-// Michael Hutchinson <mhutch@xamarin.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com_
-//
-// 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.
-
-using System;
-using System.Collections.Generic;
-
-namespace Mono.TextTemplating
-{
- public class TemplatingAppDomainRecycler
- {
- const int DEFAULT_TIMEOUT_MS = 2 * 60 * 1000;
- const int DEFAULT_MAX_USES = 20;
-
- readonly string name;
- readonly object lockObj = new object ();
-
- RecyclableAppDomain domain;
-
- public TemplatingAppDomainRecycler (string name)
- {
- this.name = name;
- }
-
- public TemplatingAppDomainRecycler.Handle GetHandle ()
- {
- lock (lockObj) {
- if (domain == null || domain.Domain == null || domain.UnusedHandles == 0) {
- domain = new RecyclableAppDomain (name);
- }
- return domain.GetHandle ();
- }
- }
-
- internal class RecyclableAppDomain
- {
- //TODO: implement timeout based recycling
- //DateTime lastUsed;
-
- AppDomain domain;
- DomainAssemblyLoader assemblyMap;
-
- int liveHandles;
- int unusedHandles = DEFAULT_MAX_USES;
-
- public RecyclableAppDomain (string name)
- {
- var info = new AppDomainSetup () {
- //appbase needs to allow loading this assembly, for remoting
- ApplicationBase = System.IO.Path.GetDirectoryName (typeof (TemplatingAppDomainRecycler).Assembly.Location),
- DisallowBindingRedirects = false,
- DisallowCodeDownload = true,
- DisallowApplicationBaseProbing = false,
- ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile,
- };
- domain = AppDomain.CreateDomain (name, null, info);
- var t = typeof(DomainAssemblyLoader);
- AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
- assemblyMap = (DomainAssemblyLoader) domain.CreateInstanceFromAndUnwrap(t.Assembly.Location, t.FullName);
- AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
- domain.AssemblyResolve += assemblyMap.Resolve;// new DomainAssemblyLoader(assemblyMap).Resolve;
- }
-
- System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
- {
- var a = typeof(RecyclableAppDomain).Assembly;
- if (args.Name == a.FullName)
- return a;
- return null;
- }
-
- public int UnusedHandles { get { return unusedHandles; } }
- public int LiveHandles { get { return liveHandles; } }
- public AppDomain Domain { get { return domain; } }
-
- public void AddAssembly (System.Reflection.Assembly assembly)
- {
- assemblyMap.Add (assembly.FullName, assembly.Location);
- }
-
- public Handle GetHandle ()
- {
- lock (this) {
- if (unusedHandles <= 0) {
- throw new InvalidOperationException ("No handles left");
- }
- unusedHandles--;
- liveHandles++;
- }
- return new Handle (this);
- }
-
- public void ReleaseHandle ()
- {
- int lh;
- lock (this) {
- liveHandles--;
- lh = liveHandles;
- }
- //We must unload domain every time after using it for generation
- //Otherwise we could not load new version of the project-generated
- //assemblies into it. So remove checking for unusedHandles == 0
- if (lh == 0) {
- UnloadDomain ();
- }
- }
-
- void UnloadDomain ()
- {
- AppDomain.Unload (domain);
- domain = null;
- assemblyMap = null;
- GC.SuppressFinalize (this);
- }
-
- ~RecyclableAppDomain ()
- {
- if (liveHandles != 0)
- Console.WriteLine ("WARNING: recyclable AppDomain's handles were not all disposed");
- }
- }
-
- public class Handle : IDisposable
- {
- RecyclableAppDomain parent;
-
- internal Handle (RecyclableAppDomain parent)
- {
- this.parent = parent;
- }
-
- public AppDomain Domain {
- get { return parent.Domain; }
- }
-
- public void Dispose ()
- {
- if (parent == null)
- return;
- var p = parent;
- lock (this) {
- if (parent == null)
- return;
- parent = null;
- }
- p.ReleaseHandle ();
- }
-
- public void AddAssembly (System.Reflection.Assembly assembly)
- {
- parent.AddAssembly (assembly);
- }
- }
-
- [Serializable]
- class DomainAssemblyLoader : MarshalByRefObject
- {
- readonly Dictionary<string, string> map = new Dictionary<string, string>();
-
- public DomainAssemblyLoader ()
- {
- }
-
- public System.Reflection.Assembly Resolve (object sender, ResolveEventArgs args)
- {
- var assemblyFile = ResolveAssembly (args.Name);
- if (assemblyFile != null)
- return System.Reflection.Assembly.LoadFrom (assemblyFile);
- return null;
- }
-
- public string ResolveAssembly(string name)
- {
- string result;
- if (map.TryGetValue(name, out result))
- return result;
- return null;
- }
-
- public void Add(string name, string location)
- {
- map[name] = location;
- }
-
- //keep this alive as long as the app domain is alive
- public override object InitializeLifetimeService ()
- {
- return null;
- }
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs
deleted file mode 100644
index f4899d6068..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs
+++ /dev/null
@@ -1,466 +0,0 @@
-//
-// TemplatingHost.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-using System.IO;
-using System.Reflection;
-using System.Text;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating
-{
- public class TemplateGenerator : MarshalByRefObject, ITextTemplatingEngineHost
- {
- //re-usable
- TemplatingEngine engine;
-
- //per-run variables
- string inputFile, outputFile;
- Encoding encoding;
-
- //host fields
- readonly CompilerErrorCollection errors = new CompilerErrorCollection ();
- readonly List<string> refs = new List<string> ();
- readonly List<string> imports = new List<string> ();
- readonly List<string> includePaths = new List<string> ();
- readonly List<string> referencePaths = new List<string> ();
-
- //host properties for consumers to access
- public CompilerErrorCollection Errors { get { return errors; } }
- public List<string> Refs { get { return refs; } }
- public List<string> Imports { get { return imports; } }
- public List<string> IncludePaths { get { return includePaths; } }
- public List<string> ReferencePaths { get { return referencePaths; } }
- public string OutputFile { get { return outputFile; } }
- public bool UseRelativeLinePragmas { get; set; }
-
- public TemplateGenerator ()
- {
- Refs.Add (typeof (TextTransformation).Assembly.Location);
- Refs.Add (typeof(Uri).Assembly.Location);
- Imports.Add ("System");
- }
-
- public CompiledTemplate CompileTemplate (string content)
- {
- if (String.IsNullOrEmpty (content))
- throw new ArgumentNullException ("content");
-
- errors.Clear ();
- encoding = Encoding.UTF8;
-
- return Engine.CompileTemplate (content, this);
- }
-
- protected TemplatingEngine Engine {
- get {
- if (engine == null)
- engine = new TemplatingEngine ();
- return engine;
- }
- }
-
- public bool ProcessTemplate (string inputFile, string outputFile)
- {
- if (String.IsNullOrEmpty (inputFile))
- throw new ArgumentNullException ("inputFile");
- if (String.IsNullOrEmpty (outputFile))
- throw new ArgumentNullException ("outputFile");
-
- string content;
- try {
- content = File.ReadAllText (inputFile);
- } catch (IOException ex) {
- errors.Clear ();
- AddError ("Could not read input file '" + inputFile + "':\n" + ex);
- return false;
- }
-
- string output;
- ProcessTemplate (inputFile, content, ref outputFile, out output);
-
- try {
- if (!errors.HasErrors)
- File.WriteAllText (outputFile, output, encoding);
- } catch (IOException ex) {
- AddError ("Could not write output file '" + outputFile + "':\n" + ex);
- }
-
- return !errors.HasErrors;
- }
-
- public bool ProcessTemplate (string inputFileName, string inputContent, ref string outputFileName, out string outputContent)
- {
- errors.Clear ();
- encoding = Encoding.UTF8;
-
- outputFile = outputFileName;
- inputFile = inputFileName;
- outputContent = Engine.ProcessTemplate (inputContent, this);
- outputFileName = outputFile;
-
- return !errors.HasErrors;
- }
-
- public bool PreprocessTemplate (string inputFile, string className, string classNamespace,
- string outputFile, Encoding encoding, out string language, out string[] references)
- {
- language = null;
- references = null;
-
- if (string.IsNullOrEmpty (inputFile))
- throw new ArgumentNullException ("inputFile");
- if (string.IsNullOrEmpty (outputFile))
- throw new ArgumentNullException ("outputFile");
-
- string content;
- try {
- content = File.ReadAllText (inputFile);
- } catch (IOException ex) {
- errors.Clear ();
- AddError ("Could not read input file '" + inputFile + "':\n" + ex);
- return false;
- }
-
- string output;
- PreprocessTemplate (inputFile, className, classNamespace, content, out language, out references, out output);
-
- try {
- if (!errors.HasErrors)
- File.WriteAllText (outputFile, output, encoding);
- } catch (IOException ex) {
- AddError ("Could not write output file '" + outputFile + "':\n" + ex);
- }
-
- return !errors.HasErrors;
- }
-
- public bool PreprocessTemplate (string inputFileName, string className, string classNamespace, string inputContent,
- out string language, out string[] references, out string outputContent)
- {
- errors.Clear ();
- encoding = Encoding.UTF8;
-
- inputFile = inputFileName;
- outputContent = Engine.PreprocessTemplate (inputContent, this, className, classNamespace, out language, out references);
-
- return !errors.HasErrors;
- }
-
- CompilerError AddError (string error)
- {
- var err = new CompilerError ();
- err.ErrorText = error;
- Errors.Add (err);
- return err;
- }
-
- #region Virtual members
-
- public virtual object GetHostOption (string optionName)
- {
- switch (optionName) {
- case "UseRelativeLinePragmas":
- return UseRelativeLinePragmas;
- }
- return null;
- }
-
- public virtual AppDomain ProvideTemplatingAppDomain (string content)
- {
- return null;
- }
-
- protected virtual string ResolveAssemblyReference (string assemblyReference)
- {
- if (System.IO.Path.IsPathRooted (assemblyReference))
- return assemblyReference;
- foreach (string referencePath in ReferencePaths) {
- var path = System.IO.Path.Combine (referencePath, assemblyReference);
- if (System.IO.File.Exists (path))
- return path;
- }
-
- var assemblyName = new AssemblyName(assemblyReference);
- if (assemblyName.Version != null)//Load via GAC and return full path
- return Assembly.Load (assemblyName).Location;
-
- if (!assemblyReference.EndsWith (".dll", StringComparison.OrdinalIgnoreCase) && !assemblyReference.EndsWith (".exe", StringComparison.OrdinalIgnoreCase))
- return assemblyReference + ".dll";
- return assemblyReference;
- }
-
- protected virtual string ResolveParameterValue (string directiveId, string processorName, string parameterName)
- {
- var key = new ParameterKey (processorName, directiveId, parameterName);
- string value;
- if (parameters.TryGetValue (key, out value))
- return value;
- if (processorName != null || directiveId != null)
- return ResolveParameterValue (null, null, parameterName);
- return null;
- }
-
- protected virtual Type ResolveDirectiveProcessor (string processorName)
- {
- KeyValuePair<string,string> value;
- if (!directiveProcessors.TryGetValue (processorName, out value))
- throw new Exception (string.Format ("No directive processor registered as '{0}'", processorName));
- var asmPath = ResolveAssemblyReference (value.Value);
- if (asmPath == null)
- throw new Exception (string.Format ("Could not resolve assembly '{0}' for directive processor '{1}'", value.Value, processorName));
- var asm = Assembly.LoadFrom (asmPath);
- return asm.GetType (value.Key, true);
- }
-
- protected virtual string ResolvePath (string path)
- {
- path = Environment.ExpandEnvironmentVariables (path);
- if (Path.IsPathRooted (path))
- return path;
- var dir = Path.GetDirectoryName (inputFile);
- var test = Path.Combine (dir, path);
- if (File.Exists (test) || Directory.Exists (test))
- return test;
- return path;
- }
-
- #endregion
-
- readonly Dictionary<ParameterKey,string> parameters = new Dictionary<ParameterKey, string> ();
- readonly Dictionary<string,KeyValuePair<string,string>> directiveProcessors = new Dictionary<string, KeyValuePair<string,string>> ();
-
- public void AddDirectiveProcessor (string name, string klass, string assembly)
- {
- directiveProcessors.Add (name, new KeyValuePair<string,string> (klass,assembly));
- }
-
- public void AddParameter (string processorName, string directiveName, string parameterName, string value)
- {
- parameters.Add (new ParameterKey (processorName, directiveName, parameterName), value);
- }
-
- /// <summary>
- /// Parses a parameter and adds it.
- /// </summary>
- /// <returns>Whether the parameter was parsed successfully.</returns>
- /// <param name="unparsedParameter">Parameter in name=value or processor!directive!name!value format.</param>
- public bool TryAddParameter (string unparsedParameter)
- {
- string processor, directive, name, value;
- if (TryParseParameter (unparsedParameter, out processor, out directive, out name, out value)) {
- AddParameter (processor, directive, name, value);
- return true;
- }
- return false;
- }
-
- internal static bool TryParseParameter (string parameter, out string processor, out string directive, out string name, out string value)
- {
- processor = directive = name = value = "";
-
- int start = 0;
- int end = parameter.IndexOfAny (new [] { '=', '!' });
- if (end < 0)
- return false;
-
- //simple format n=v
- if (parameter [end] == '=') {
- name = parameter.Substring (start, end);
- value = parameter.Substring (end + 1);
- return !string.IsNullOrEmpty (name);
- }
-
- //official format, p!d!n!v
- processor = parameter.Substring (start, end);
-
- start = end + 1;
- end = parameter.IndexOf ('!', start);
- if (end < 0) {
- //unlike official version, we allow you to omit processor/directive
- name = processor;
- value = parameter.Substring (start);
- processor = "";
- return !string.IsNullOrEmpty (name);
- }
-
- directive = parameter.Substring (start, end - start);
-
-
- start = end + 1;
- end = parameter.IndexOf ('!', start);
- if (end < 0) {
- //we also allow you just omit the processor
- name = directive;
- directive = processor;
- value = parameter.Substring (start);
- processor = "";
- return !string.IsNullOrEmpty (name);
- }
-
- name = parameter.Substring (start, end - start);
- value = parameter.Substring (end + 1);
-
- return !string.IsNullOrEmpty (name);
- }
-
- protected virtual bool LoadIncludeText (string requestFileName, out string content, out string location)
- {
- content = "";
- location = ResolvePath (requestFileName);
-
- if (location == null || !File.Exists (location)) {
- foreach (string path in includePaths) {
- string f = Path.Combine (path, requestFileName);
- if (File.Exists (f)) {
- location = f;
- break;
- }
- }
- }
-
- if (location == null)
- return false;
-
- try {
- content = File.ReadAllText (location);
- return true;
- } catch (IOException ex) {
- AddError ("Could not read included file '" + location + "':\n" + ex);
- }
- return false;
- }
-
- #region Explicit ITextTemplatingEngineHost implementation
-
- bool ITextTemplatingEngineHost.LoadIncludeText (string requestFileName, out string content, out string location)
- {
- return LoadIncludeText (requestFileName, out content, out location);
- }
-
- void ITextTemplatingEngineHost.LogErrors (CompilerErrorCollection errors)
- {
- this.errors.AddRange (errors);
- }
-
- string ITextTemplatingEngineHost.ResolveAssemblyReference (string assemblyReference)
- {
- return ResolveAssemblyReference (assemblyReference);
- }
-
- string ITextTemplatingEngineHost.ResolveParameterValue (string directiveId, string processorName, string parameterName)
- {
- return ResolveParameterValue (directiveId, processorName, parameterName);
- }
-
- Type ITextTemplatingEngineHost.ResolveDirectiveProcessor (string processorName)
- {
- return ResolveDirectiveProcessor (processorName);
- }
-
- string ITextTemplatingEngineHost.ResolvePath (string path)
- {
- return ResolvePath (path);
- }
-
- void ITextTemplatingEngineHost.SetFileExtension (string extension)
- {
- extension = extension.TrimStart ('.');
- if (Path.HasExtension (outputFile)) {
- outputFile = Path.ChangeExtension (outputFile, extension);
- } else {
- outputFile = outputFile + "." + extension;
- }
- }
-
- void ITextTemplatingEngineHost.SetOutputEncoding (Encoding encoding, bool fromOutputDirective)
- {
- this.encoding = encoding;
- }
-
- IList<string> ITextTemplatingEngineHost.StandardAssemblyReferences {
- get { return refs; }
- }
-
- IList<string> ITextTemplatingEngineHost.StandardImports {
- get { return imports; }
- }
-
- string ITextTemplatingEngineHost.TemplateFile {
- get { return inputFile; }
- }
-
- #endregion
-
- struct ParameterKey : IEquatable<ParameterKey>
- {
- public ParameterKey (string processorName, string directiveName, string parameterName)
- {
- this.processorName = processorName ?? "";
- this.directiveName = directiveName ?? "";
- this.parameterName = parameterName ?? "";
- unchecked {
- hashCode = this.processorName.GetHashCode ()
- ^ this.directiveName.GetHashCode ()
- ^ this.parameterName.GetHashCode ();
- }
- }
-
- string processorName, directiveName, parameterName;
- readonly int hashCode;
-
- public override bool Equals (object obj)
- {
- return obj is ParameterKey && Equals ((ParameterKey)obj);
- }
-
- public bool Equals (ParameterKey other)
- {
- return processorName == other.processorName && directiveName == other.directiveName && parameterName == other.parameterName;
- }
-
- public override int GetHashCode ()
- {
- return hashCode;
- }
- }
-
- /// <summary>
- /// If non-null, the template's Host property will be the full type of this host.
- /// </summary>
- public virtual Type SpecificHostType { get { return null; } }
-
- /// <summary>
- /// Gets any additional directive processors to be included in the processing run.
- /// </summary>
- public virtual IEnumerable<IDirectiveProcessor> GetAdditionalDirectiveProcessors ()
- {
- yield break;
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateSettings.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateSettings.cs
deleted file mode 100644
index 627dc76f47..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateSettings.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// TemplateSettings.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.Text;
-using System.Collections.Generic;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating
-{
- public class TemplateSettings
- {
- public TemplateSettings ()
- {
- Imports = new HashSet<string> ();
- Assemblies = new HashSet<string> ();
- CustomDirectives = new List<CustomDirective> ();
- DirectiveProcessors = new Dictionary<string, IDirectiveProcessor> ();
- }
-
- public bool HostSpecific { get; set; }
- public bool HostPropertyOnBase { get; set; }
- public bool Debug { get; set; }
- public string Inherits { get; set; }
- public string Name { get; set; }
- public string Namespace { get; set; }
- public HashSet<string> Imports { get; private set; }
- public HashSet<string> Assemblies { get; private set; }
- public System.CodeDom.Compiler.CodeDomProvider Provider { get; set; }
- public string Language { get; set; }
- public string CompilerOptions { get; set; }
- public Encoding Encoding { get; set; }
- public string Extension { get; set; }
- public System.Globalization.CultureInfo Culture { get; set; }
- public List<CustomDirective> CustomDirectives { get; private set; }
- public Dictionary<string,IDirectiveProcessor> DirectiveProcessors { get; private set; }
- public bool IncludePreprocessingHelpers { get; set; }
- public bool IsPreprocessed { get; set; }
- public bool RelativeLinePragmas { get; set; }
- public bool NoLinePragmas { get; set; }
- public bool InternalVisibility { get; set; }
- public Type HostType { get; set; }
- }
-
- public class CustomDirective
- {
- public CustomDirective (string processorName, Directive directive)
- {
- this.ProcessorName = processorName;
- this.Directive = directive;
- }
-
- public string ProcessorName { get; set; }
- public Directive Directive { get; set; }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs
deleted file mode 100644
index 7720093b36..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs
+++ /dev/null
@@ -1,1169 +0,0 @@
-//
-// Engine.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using Microsoft.CSharp;
-using Microsoft.VisualStudio.TextTemplating;
-using System.Linq;
-using System.Reflection;
-
-namespace Mono.TextTemplating
-{
- public class TemplatingEngine : MarshalByRefObject, ITextTemplatingEngine
- {
- public string ProcessTemplate (string content, ITextTemplatingEngineHost host)
- {
- var tpl = CompileTemplate (content, host);
- try {
- if (tpl != null)
- return tpl.Process ();
- return null;
- } finally {
- if (tpl != null)
- tpl.Dispose ();
- }
- }
-
- public string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
- string classNamespace, out string language, out string[] references)
- {
- if (content == null)
- throw new ArgumentNullException ("content");
- if (host == null)
- throw new ArgumentNullException ("host");
- if (className == null)
- throw new ArgumentNullException ("className");
- if (classNamespace == null)
- throw new ArgumentNullException ("classNamespace");
-
- language = null;
- references = null;
-
- var pt = ParsedTemplate.FromText (content, host);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var settings = GetSettings (host, pt);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
- settings.Name = className;
- settings.Namespace = classNamespace;
- settings.IncludePreprocessingHelpers = string.IsNullOrEmpty (settings.Inherits);
- settings.IsPreprocessed = true;
- language = settings.Language;
-
- var ccu = GenerateCompileUnit (host, content, pt, settings);
- references = ProcessReferences (host, pt, settings).ToArray ();
-
- host.LogErrors (pt.Errors);
- if (pt.Errors.HasErrors) {
- return null;
- }
-
- var options = new CodeGeneratorOptions ();
- using (var sw = new StringWriter ()) {
- settings.Provider.GenerateCodeFromCompileUnit (ccu, sw, options);
- return sw.ToString ();
- }
- }
-
- public CompiledTemplate CompileTemplate (string content, ITextTemplatingEngineHost host)
- {
- if (content == null)
- throw new ArgumentNullException ("content");
- if (host == null)
- throw new ArgumentNullException ("host");
-
- var pt = ParsedTemplate.FromText (content, host);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var settings = GetSettings (host, pt);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- if (!string.IsNullOrEmpty (settings.Extension)) {
- host.SetFileExtension (settings.Extension);
- }
- if (settings.Encoding != null) {
- //FIXME: when is this called with false?
- host.SetOutputEncoding (settings.Encoding, true);
- }
-
- var ccu = GenerateCompileUnit (host, content, pt, settings);
- var references = ProcessReferences (host, pt, settings);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var results = GenerateCode (references, settings, ccu);
- if (results.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- host.LogErrors (results.Errors);
- return null;
- }
-
- var templateClassFullName = settings.Namespace + "." + settings.Name;
- var domain = host.ProvideTemplatingAppDomain (content);
- if (domain != null) {
- var type = typeof(CompiledTemplate);
- var obj = domain.CreateInstanceFromAndUnwrap (type.Assembly.Location, type.FullName, false,
- BindingFlags.Default, null,
- new object[] { host, results, templateClassFullName, settings.Culture, references.ToArray () },
- null, null);
- return (CompiledTemplate)obj;
- }
- return new CompiledTemplate (host, results, templateClassFullName, settings.Culture, references.ToArray ());
- }
-
- static CompilerResults GenerateCode (IEnumerable<string> references, TemplateSettings settings, CodeCompileUnit ccu)
- {
- var pars = new CompilerParameters {
- GenerateExecutable = false,
- CompilerOptions = settings.CompilerOptions,
- IncludeDebugInformation = settings.Debug,
- GenerateInMemory = false,
- };
-
- foreach (var r in references)
- pars.ReferencedAssemblies.Add (r);
-
- if (settings.Debug)
- pars.TempFiles.KeepFiles = true;
- if (string.IsNullOrWhiteSpace (pars.CompilerOptions))
- pars.CompilerOptions = "/noconfig";
- else if (!pars.CompilerOptions.Contains ("/noconfig"))
- pars.CompilerOptions = "/noconfig " + pars.CompilerOptions;
- return settings.Provider.CompileAssemblyFromDom (pars, ccu);
- }
-
- static string [] ProcessReferences (ITextTemplatingEngineHost host, ParsedTemplate pt, TemplateSettings settings)
- {
- var resolved = new Dictionary<string, string> ();
-
- foreach (string assem in settings.Assemblies.Union (host.StandardAssemblyReferences)) {
- if (resolved.Values.Contains (assem))
- continue;
-
- string resolvedAssem = host.ResolveAssemblyReference (assem);
- if (!string.IsNullOrEmpty (resolvedAssem)) {
- var assemblyName = resolvedAssem;
- if (File.Exists (resolvedAssem))
- assemblyName = AssemblyName.GetAssemblyName (resolvedAssem).FullName;
- resolved [assemblyName] = resolvedAssem;
- } else {
- pt.LogError ("Could not resolve assembly reference '" + assem + "'");
- return null;
- }
- }
- return resolved.Values.ToArray ();
- }
-
- public static TemplateSettings GetSettings (ITextTemplatingEngineHost host, ParsedTemplate pt)
- {
- var settings = new TemplateSettings ();
-
- bool relativeLinePragmas = host.GetHostOption ("UseRelativeLinePragmas") as bool? ?? false;
-
- foreach (Directive dt in pt.Directives) {
- switch (dt.Name.ToLowerInvariant ()) {
- case "template":
- string val = dt.Extract ("language");
- if (val != null)
- settings.Language = val;
- val = dt.Extract ("debug");
- if (val != null)
- settings.Debug = string.Compare (val, "true", StringComparison.OrdinalIgnoreCase) == 0;
- val = dt.Extract ("inherits");
- if (val != null)
- settings.Inherits = val;
- val = dt.Extract ("culture");
- if (val != null) {
- System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.GetCultureInfo (val);
- if (culture == null)
- pt.LogWarning ("Could not find culture '" + val + "'", dt.StartLocation);
- else
- settings.Culture = culture;
- }
- val = dt.Extract ("hostspecific");
- if (val != null) {
- if (string.Compare (val, "trueFromBase", StringComparison.OrdinalIgnoreCase) == 0) {
- settings.HostPropertyOnBase = true;
- settings.HostSpecific = true;
- } else {
- settings.HostSpecific = string.Compare (val, "true", StringComparison.OrdinalIgnoreCase) == 0;
- }
- }
- val = dt.Extract ("CompilerOptions");
- if (val != null) {
- settings.CompilerOptions = val;
- }
- val = dt.Extract ("relativeLinePragmas");
- if (val != null) {
- relativeLinePragmas = string.Compare (val, "true", StringComparison.OrdinalIgnoreCase) == 0;
- }
- val = dt.Extract ("linePragmas");
- if (val != null) {
- settings.NoLinePragmas = string.Compare (val, "false", StringComparison.OrdinalIgnoreCase) == 0;
- }
- val = dt.Extract ("visibility");
- if (val != null) {
- settings.InternalVisibility = string.Compare (val, "internal", StringComparison.OrdinalIgnoreCase) == 0;
- }
- break;
-
- case "assembly":
- string name = dt.Extract ("name");
- if (name == null)
- pt.LogError ("Missing name attribute in assembly directive", dt.StartLocation);
- else
- settings.Assemblies.Add (name);
- break;
-
- case "import":
- string namespac = dt.Extract ("namespace");
- if (namespac == null)
- pt.LogError ("Missing namespace attribute in import directive", dt.StartLocation);
- else
- settings.Imports.Add (namespac);
- break;
-
- case "output":
- settings.Extension = dt.Extract ("extension");
- string encoding = dt.Extract ("encoding");
- if (encoding != null)
- settings.Encoding = Encoding.GetEncoding (encoding);
- break;
-
- case "include":
- throw new InvalidOperationException ("Include is handled in the parser");
-
- case "parameter":
- AddDirective (settings, host, "ParameterDirectiveProcessor", dt);
- continue;
-
- default:
- string processorName = dt.Extract ("Processor");
- if (processorName == null)
- throw new InvalidOperationException ("Custom directive '" + dt.Name + "' does not specify a processor");
-
- AddDirective (settings, host, processorName, dt);
- continue;
- }
- ComplainExcessAttributes (dt, pt);
- }
-
- var gen = host as TemplateGenerator;
- if (gen != null) {
- settings.HostType = gen.SpecificHostType;
- if (settings.HostType != null) {
- settings.Assemblies.Add (settings.HostType.Assembly.Location);
- } else {
- settings.HostType = typeof(ITextTemplatingEngineHost);
- }
- foreach (var processor in gen.GetAdditionalDirectiveProcessors ()) {
- settings.DirectiveProcessors [processor.GetType ().FullName] = processor;
- }
- }
-
- //initialize the custom processors
- foreach (var kv in settings.DirectiveProcessors) {
- kv.Value.Initialize (host);
-
- IRecognizeHostSpecific hs;
- if (settings.HostSpecific || (
- !((IDirectiveProcessor)kv.Value).RequiresProcessingRunIsHostSpecific &&
- ((hs = kv.Value as IRecognizeHostSpecific) == null || !hs.RequiresProcessingRunIsHostSpecific)))
- continue;
-
- settings.HostSpecific = true;
- pt.LogWarning ("Directive processor '" + kv.Key + "' requires hostspecific=true, forcing on.");
- }
-
- foreach (var kv in settings.DirectiveProcessors) {
- ((IDirectiveProcessor)kv.Value).SetProcessingRunIsHostSpecific (settings.HostSpecific);
- var hs = kv.Value as IRecognizeHostSpecific;
- if (hs != null)
- hs.SetProcessingRunIsHostSpecific (settings.HostSpecific);
- }
-
- if (settings.Name == null)
- settings.Name = string.Format ("GeneratedTextTransformation{0:x}", new Random ().Next ());
- if (settings.Namespace == null)
- settings.Namespace = typeof (TextTransformation).Namespace;
-
- //resolve the CodeDOM provider
- if (String.IsNullOrEmpty (settings.Language)) {
- settings.Language = "C#";
- }
-
- if (settings.Language == "C#v3.5") {
- var providerOptions = new Dictionary<string, string> ();
- providerOptions.Add ("CompilerVersion", "v3.5");
- settings.Provider = new CSharpCodeProvider (providerOptions);
- }
- else {
- settings.Provider = CodeDomProvider.CreateProvider (settings.Language);
- }
-
- if (settings.Provider == null) {
- pt.LogError ("A provider could not be found for the language '" + settings.Language + "'");
- return settings;
- }
-
- settings.RelativeLinePragmas = relativeLinePragmas;
-
- return settings;
- }
-
- public static string IndentSnippetText (CodeDomProvider provider, string text, string indent)
- {
- if (provider is CSharpCodeProvider)
- return IndentSnippetText (text, indent);
- return text;
- }
-
- public static string IndentSnippetText (string text, string indent)
- {
- var builder = new StringBuilder (text.Length);
- builder.Append (indent);
- int lastNewline = 0;
- for (int i = 0; i < text.Length - 1; i++) {
- char c = text[i];
- if (c == '\r') {
- if (text[i + 1] == '\n') {
- i++;
- if (i == text.Length - 1)
- break;
- }
- } else if (c != '\n') {
- continue;
- }
- i++;
- int len = i - lastNewline;
- if (len > 0) {
- builder.Append (text, lastNewline, i - lastNewline);
- }
- builder.Append (indent);
- lastNewline = i;
- }
- if (lastNewline > 0)
- builder.Append (text, lastNewline, text.Length - lastNewline);
- else
- builder.Append (text);
- return builder.ToString ();
- }
-
- static void AddDirective (TemplateSettings settings, ITextTemplatingEngineHost host, string processorName, Directive directive)
- {
- IDirectiveProcessor processor;
- if (!settings.DirectiveProcessors.TryGetValue (processorName, out processor)) {
- switch (processorName) {
- case "ParameterDirectiveProcessor":
- processor = new ParameterDirectiveProcessor ();
- break;
- default:
- Type processorType = host.ResolveDirectiveProcessor (processorName);
- processor = (IDirectiveProcessor) Activator.CreateInstance (processorType);
- break;
- }
- if (!processor.IsDirectiveSupported (directive.Name))
- throw new InvalidOperationException ("Directive processor '" + processorName + "' does not support directive '" + directive.Name + "'");
-
- settings.DirectiveProcessors [processorName] = processor;
- }
- settings.CustomDirectives.Add (new CustomDirective (processorName, directive));
- }
-
- static bool ComplainExcessAttributes (Directive dt, ParsedTemplate pt)
- {
- if (dt.Attributes.Count == 0)
- return false;
- var sb = new StringBuilder ("Unknown attributes ");
- bool first = true;
- foreach (string key in dt.Attributes.Keys) {
- if (!first) {
- sb.Append (", ");
- } else {
- first = false;
- }
- sb.Append (key);
- }
- sb.Append (" found in ");
- sb.Append (dt.Name);
- sb.Append (" directive.");
- pt.LogWarning (sb.ToString (), dt.StartLocation);
- return false;
- }
-
- static void ProcessDirectives (string content, ParsedTemplate pt, TemplateSettings settings)
- {
- foreach (var processor in settings.DirectiveProcessors.Values) {
- processor.StartProcessingRun (settings.Provider, content, pt.Errors);
- }
-
- foreach (var dt in settings.CustomDirectives) {
- var processor = settings.DirectiveProcessors[dt.ProcessorName];
- processor.ProcessDirective (dt.Directive.Name, dt.Directive.Attributes);
- }
-
- foreach (var processor in settings.DirectiveProcessors.Values) {
- processor.FinishProcessingRun ();
-
- var imports = processor.GetImportsForProcessingRun ();
- if (imports != null)
- settings.Imports.UnionWith (imports);
- var references = processor.GetReferencesForProcessingRun ();
- if (references != null)
- settings.Assemblies.UnionWith (references);
- }
- }
-
- public static CodeCompileUnit GenerateCompileUnit (ITextTemplatingEngineHost host, string content, ParsedTemplate pt, TemplateSettings settings)
- {
- ProcessDirectives (content, pt, settings);
-
- string baseDirectory = Path.GetDirectoryName (host.TemplateFile);
-
- //prep the compile unit
- var ccu = new CodeCompileUnit ();
- var namespac = new CodeNamespace (settings.Namespace);
- ccu.Namespaces.Add (namespac);
-
- foreach (string ns in settings.Imports.Union (host.StandardImports))
- namespac.Imports.Add (new CodeNamespaceImport (ns));
-
- //prep the type
- var type = new CodeTypeDeclaration (settings.Name);
- type.IsPartial = true;
- if (settings.InternalVisibility) {
- type.TypeAttributes = (type.TypeAttributes & ~TypeAttributes.VisibilityMask) | TypeAttributes.NotPublic;
- }
- if (!string.IsNullOrEmpty (settings.Inherits)) {
- type.BaseTypes.Add (new CodeTypeReference (settings.Inherits));
- } else if (!settings.IncludePreprocessingHelpers) {
- type.BaseTypes.Add (TypeRef<TextTransformation> ());
- } else {
- type.BaseTypes.Add (new CodeTypeReference (settings.Name + "Base"));
- }
- namespac.Types.Add (type);
-
- //prep the transform method
- var transformMeth = new CodeMemberMethod {
- Name = "TransformText",
- ReturnType = new CodeTypeReference (typeof (String)),
- Attributes = MemberAttributes.Public,
- };
- if (!settings.IncludePreprocessingHelpers)
- transformMeth.Attributes |= MemberAttributes.Override;
-
- transformMeth.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "GenerationEnvironment"),
- new CodePrimitiveExpression (null)));
-
- CodeExpression toStringHelper;
- if (settings.IsPreprocessed) {
- toStringHelper = new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "ToStringHelper");
- } else {
- toStringHelper = new CodeTypeReferenceExpression (
- new CodeTypeReference (typeof (ToStringHelper), CodeTypeReferenceOptions.GlobalReference));
- }
-
- //method references that will need to be used multiple times
- var writeMeth = new CodeMethodReferenceExpression (new CodeThisReferenceExpression (), "Write");
- var toStringMeth = new CodeMethodReferenceExpression (toStringHelper, "ToStringWithCulture");
- bool helperMode = false;
-
- //build the code from the segments
- foreach (TemplateSegment seg in pt.Content) {
- CodeStatement st = null;
- CodeLinePragma location = null;
- if (!settings.NoLinePragmas) {
- var f = seg.StartLocation.FileName ?? host.TemplateFile;
- if (settings.RelativeLinePragmas)
- f = FileUtil.AbsoluteToRelativePath (baseDirectory, f).Replace ('\\', '/');
- location = new CodeLinePragma (f, seg.StartLocation.Line);
- }
- switch (seg.Type) {
- case SegmentType.Block:
- if (helperMode)
- //TODO: are blocks permitted after helpers?
- pt.LogError ("Blocks are not permitted after helpers", seg.TagStartLocation);
- st = new CodeSnippetStatement (seg.Text);
- break;
- case SegmentType.Expression:
- st = new CodeExpressionStatement (
- new CodeMethodInvokeExpression (writeMeth,
- new CodeMethodInvokeExpression (toStringMeth, new CodeSnippetExpression (seg.Text))));
- break;
- case SegmentType.Content:
- st = new CodeExpressionStatement (new CodeMethodInvokeExpression (writeMeth, new CodePrimitiveExpression (seg.Text)));
- break;
- case SegmentType.Helper:
- if (!string.IsNullOrEmpty (seg.Text))
- type.Members.Add (CreateSnippetMember (seg.Text, location));
- helperMode = true;
- break;
- default:
- throw new InvalidOperationException ();
- }
- if (st != null) {
- if (helperMode) {
- //convert the statement into a snippet member and attach it to the top level type
- //TODO: is there a way to do this for languages that use indentation for blocks, e.g. python?
- using (var writer = new StringWriter ()) {
- settings.Provider.GenerateCodeFromStatement (st, writer, null);
- var text = writer.ToString ();
- if (!string.IsNullOrEmpty (text))
- type.Members.Add (CreateSnippetMember (text, location));
- }
- } else {
- st.LinePragma = location;
- transformMeth.Statements.Add (st);
- continue;
- }
- }
- }
-
- //complete the transform method
- transformMeth.Statements.Add (new CodeMethodReturnStatement (
- new CodeMethodInvokeExpression (
- new CodePropertyReferenceExpression (
- new CodeThisReferenceExpression (),
- "GenerationEnvironment"),
- "ToString")));
- type.Members.Add (transformMeth);
-
- //class code and attributes from processors
- foreach (var processor in settings.DirectiveProcessors.Values) {
- string classCode = processor.GetClassCodeForProcessingRun ();
- if (!string.IsNullOrEmpty (classCode))
- type.Members.Add (CreateSnippetMember (classCode));
- var atts = processor.GetTemplateClassCustomAttributes ();
- if (atts != null) {
- if (type.CustomAttributes == null)
- type.CustomAttributes = new CodeAttributeDeclarationCollection ();
- type.CustomAttributes.AddRange (atts);
- }
- }
-
- //generate the Host property if needed
- if (settings.HostSpecific && !settings.HostPropertyOnBase) {
- GenerateHostProperty (type, settings.HostType);
- }
-
- GenerateInitializationMethod (type, settings);
-
- if (settings.IncludePreprocessingHelpers) {
- var baseClass = new CodeTypeDeclaration (settings.Name + "Base");
- GenerateProcessingHelpers (baseClass, settings);
- AddToStringHelper (baseClass, settings);
- namespac.Types.Add (baseClass);
- }
- return ccu;
- }
-
- static CodeSnippetTypeMember CreateSnippetMember (string value, CodeLinePragma location = null)
- {
- //HACK: workaround for code generator not indenting first line of member snippet when inserting into class
- const string indent = "\n ";
- if (!char.IsWhiteSpace (value[0]))
- value = indent + value;
-
- return new CodeSnippetTypeMember (value) {
- LinePragma = location
- };
- }
-
- static void GenerateHostProperty (CodeTypeDeclaration type, Type hostType)
- {
- var hostTypeRef = new CodeTypeReference (hostType, CodeTypeReferenceOptions.GlobalReference);
- var hostField = new CodeMemberField (hostTypeRef, "hostValue");
- hostField.Attributes = (hostField.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Private;
- type.Members.Add (hostField);
-
- var hostProp = GenerateGetterSetterProperty ("Host", hostField);
- hostProp.Attributes = MemberAttributes.Public | MemberAttributes.Final;
- type.Members.Add (hostProp);
- }
-
- static void GenerateInitializationMethod (CodeTypeDeclaration type, TemplateSettings settings)
- {
- //initialization method
- var initializeMeth = new CodeMemberMethod {
- Name = "Initialize",
- ReturnType = new CodeTypeReference (typeof (void), CodeTypeReferenceOptions.GlobalReference),
- Attributes = MemberAttributes.Public
- };
- if (!settings.IncludePreprocessingHelpers)
- initializeMeth.Attributes |= MemberAttributes.Override;
-
- //if preprocessed, pass the extension and encoding to the host
- if (settings.IsPreprocessed && settings.HostSpecific) {
- var hostProp = new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "Host");
- var statements = new List<CodeStatement> ();
-
- if (!string.IsNullOrEmpty (settings.Extension)) {
- statements.Add (new CodeExpressionStatement (new CodeMethodInvokeExpression (
- hostProp,
- "SetFileExtension",
- new CodePrimitiveExpression (settings.Extension)
- )));
- }
-
- if (settings.Encoding != null) {
- statements.Add (new CodeExpressionStatement (new CodeMethodInvokeExpression (
- hostProp,
- "SetOutputEncoding",
- new CodeMethodInvokeExpression(
- new CodeTypeReferenceExpression (typeof(Encoding)),
- "GetEncoding",
- new CodePrimitiveExpression (settings.Encoding.CodePage),
- new CodePrimitiveExpression(true)
- )
- )));
- }
-
- if (statements.Count > 0) {
- initializeMeth.Statements.Add (new CodeConditionStatement (
- new CodeBinaryOperatorExpression (
- hostProp,
- CodeBinaryOperatorType.IdentityInequality,
- new CodePrimitiveExpression (null)
- ),
- statements.ToArray()
- ));
- }
- }
-
- //pre-init code from processors
- foreach (var processor in settings.DirectiveProcessors.Values) {
- string code = processor.GetPreInitializationCodeForProcessingRun ();
- if (code != null)
- initializeMeth.Statements.Add (new CodeSnippetStatement (code));
- }
-
- //base call
- if (!settings.IncludePreprocessingHelpers) {
- initializeMeth.Statements.Add (
- new CodeMethodInvokeExpression (
- new CodeMethodReferenceExpression (
- new CodeBaseReferenceExpression (),
- "Initialize")));
- }
-
- //post-init code from processors
- foreach (var processor in settings.DirectiveProcessors.Values) {
- string code = processor.GetPostInitializationCodeForProcessingRun ();
- if (code != null)
- initializeMeth.Statements.Add (new CodeSnippetStatement (code));
- }
-
- type.Members.Add (initializeMeth);
- }
-
- static void GenerateProcessingHelpers (CodeTypeDeclaration type, TemplateSettings settings)
- {
- var thisRef = new CodeThisReferenceExpression ();
- var sbTypeRef = TypeRef<StringBuilder> ();
-
- var sessionField = PrivateField (TypeRef<IDictionary<string,object>> (), "session");
- var sessionProp = GenerateGetterSetterProperty ("Session", sessionField);
- sessionProp.Attributes = MemberAttributes.Public;
-
- var builderField = PrivateField (sbTypeRef, "builder");
- var builderFieldRef = new CodeFieldReferenceExpression (thisRef, builderField.Name);
-
- var generationEnvironmentProp = GenerateGetterSetterProperty ("GenerationEnvironment", builderField);
- AddPropertyGetterInitializationIfFieldIsNull (generationEnvironmentProp, builderFieldRef, TypeRef<StringBuilder> ());
-
- type.Members.Add (builderField);
- type.Members.Add (sessionField);
- type.Members.Add (sessionProp);
- type.Members.Add (generationEnvironmentProp);
-
- AddErrorHelpers (type);
- AddIndentHelpers (type);
- AddWriteHelpers (type);
- }
-
- static void AddPropertyGetterInitializationIfFieldIsNull (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef, CodeTypeReference typeRef)
- {
- var fieldInit = FieldInitializationIfNull (fieldRef, typeRef);
- property.GetStatements.Insert (0, fieldInit);
- }
-
- static CodeConditionStatement FieldInitializationIfNull (CodeExpression fieldRef, CodeTypeReference typeRef)
- {
- return new CodeConditionStatement (
- new CodeBinaryOperatorExpression (fieldRef,
- CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (null)),
- new CodeAssignStatement (fieldRef, new CodeObjectCreateExpression (typeRef)));
- }
-
- static void AddErrorHelpers (CodeTypeDeclaration type)
- {
- var cecTypeRef = TypeRef<CompilerErrorCollection> ();
- var thisRef = new CodeThisReferenceExpression ();
- var stringTypeRef = TypeRef<string> ();
- var nullPrim = new CodePrimitiveExpression (null);
- var minusOnePrim = new CodePrimitiveExpression (-1);
-
- var errorsField = PrivateField (cecTypeRef, "errors");
- var errorsFieldRef = new CodeFieldReferenceExpression (thisRef, errorsField.Name);
-
- var errorsProp = GenerateGetterProperty ("Errors", errorsField);
- errorsProp.Attributes = MemberAttributes.Family | MemberAttributes.Final;
- errorsProp.GetStatements.Insert (0, FieldInitializationIfNull (errorsFieldRef, TypeRef<CompilerErrorCollection>()));
-
- var errorsPropRef = new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "Errors");
-
- var compilerErrorTypeRef = TypeRef<CompilerError> ();
- var errorMeth = new CodeMemberMethod {
- Name = "Error",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- errorMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "message"));
- errorMeth.Statements.Add (new CodeMethodInvokeExpression (errorsPropRef, "Add",
- new CodeObjectCreateExpression (compilerErrorTypeRef, nullPrim, minusOnePrim, minusOnePrim, nullPrim,
- new CodeArgumentReferenceExpression ("message"))));
-
- var warningMeth = new CodeMemberMethod {
- Name = "Warning",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- warningMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "message"));
- warningMeth.Statements.Add (new CodeVariableDeclarationStatement (compilerErrorTypeRef, "val",
- new CodeObjectCreateExpression (compilerErrorTypeRef, nullPrim, minusOnePrim, minusOnePrim, nullPrim,
- new CodeArgumentReferenceExpression ("message"))));
- warningMeth.Statements.Add (new CodeAssignStatement (new CodePropertyReferenceExpression (
- new CodeVariableReferenceExpression ("val"), "IsWarning"), new CodePrimitiveExpression (true)));
- warningMeth.Statements.Add (new CodeMethodInvokeExpression (errorsPropRef, "Add",
- new CodeVariableReferenceExpression ("val")));
-
- type.Members.Add (errorsField);
- type.Members.Add (errorMeth);
- type.Members.Add (warningMeth);
- type.Members.Add (errorsProp);
- }
-
- static void AddIndentHelpers (CodeTypeDeclaration type)
- {
- var stringTypeRef = TypeRef<string> ();
- var thisRef = new CodeThisReferenceExpression ();
- var zeroPrim = new CodePrimitiveExpression (0);
- var stringEmptyRef = new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (stringTypeRef), "Empty");
- var intTypeRef = TypeRef<int> ();
- var stackIntTypeRef = TypeRef<Stack<int>> ();
-
- var indentsField = PrivateField (stackIntTypeRef, "indents");
- var indentsFieldRef = new CodeFieldReferenceExpression (thisRef, indentsField.Name);
-
- var indentsProp = GenerateGetterProperty ("Indents", indentsField);
- indentsProp.Attributes = MemberAttributes.Private;
- AddPropertyGetterInitializationIfFieldIsNull (indentsProp, indentsFieldRef, TypeRef<Stack<int>> ());
-
- var indentsPropRef = new CodeFieldReferenceExpression (thisRef, indentsProp.Name);
-
- var currentIndentField = PrivateField (stringTypeRef, "currentIndent");
- currentIndentField.InitExpression = stringEmptyRef;
- var currentIndentFieldRef = new CodeFieldReferenceExpression (thisRef, currentIndentField.Name);
-
- var popIndentMeth = new CodeMemberMethod {
- Name = "PopIndent",
- ReturnType = stringTypeRef,
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- popIndentMeth.Statements.Add (new CodeConditionStatement (
- new CodeBinaryOperatorExpression (new CodePropertyReferenceExpression (indentsPropRef, "Count"),
- CodeBinaryOperatorType.ValueEquality, zeroPrim),
- new CodeMethodReturnStatement (stringEmptyRef)));
- popIndentMeth.Statements.Add (new CodeVariableDeclarationStatement (intTypeRef, "lastPos",
- new CodeBinaryOperatorExpression (
- new CodePropertyReferenceExpression (currentIndentFieldRef, "Length"),
- CodeBinaryOperatorType.Subtract,
- new CodeMethodInvokeExpression (indentsPropRef, "Pop"))));
- popIndentMeth.Statements.Add (new CodeVariableDeclarationStatement (stringTypeRef, "last",
- new CodeMethodInvokeExpression (currentIndentFieldRef, "Substring", new CodeVariableReferenceExpression ("lastPos"))));
- popIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef,
- new CodeMethodInvokeExpression (currentIndentFieldRef, "Substring", zeroPrim, new CodeVariableReferenceExpression ("lastPos"))));
- popIndentMeth.Statements.Add (new CodeMethodReturnStatement (new CodeVariableReferenceExpression ("last")));
-
- var pushIndentMeth = new CodeMemberMethod {
- Name = "PushIndent",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- pushIndentMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "indent"));
- pushIndentMeth.Statements.Add (new CodeMethodInvokeExpression (indentsPropRef, "Push",
- new CodePropertyReferenceExpression (new CodeArgumentReferenceExpression ("indent"), "Length")));
- pushIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef,
- new CodeBinaryOperatorExpression (currentIndentFieldRef, CodeBinaryOperatorType.Add, new CodeArgumentReferenceExpression ("indent"))));
-
- var clearIndentMeth = new CodeMemberMethod {
- Name = "ClearIndent",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- clearIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef, stringEmptyRef));
- clearIndentMeth.Statements.Add (new CodeMethodInvokeExpression (indentsPropRef, "Clear"));
-
- var currentIndentProp = GenerateGetterProperty ("CurrentIndent", currentIndentField);
- type.Members.Add (currentIndentField);
- type.Members.Add (indentsField);
- type.Members.Add (popIndentMeth);
- type.Members.Add (pushIndentMeth);
- type.Members.Add (clearIndentMeth);
- type.Members.Add (currentIndentProp);
- type.Members.Add (indentsProp);
- }
-
- static void AddWriteHelpers (CodeTypeDeclaration type)
- {
- var stringTypeRef = TypeRef<string> ();
- var thisRef = new CodeThisReferenceExpression ();
- var genEnvPropRef = new CodePropertyReferenceExpression (thisRef, "GenerationEnvironment");
- var currentIndentFieldRef = new CodeFieldReferenceExpression (thisRef, "currentIndent");
-
- var textToAppendParam = new CodeParameterDeclarationExpression (stringTypeRef, "textToAppend");
- var formatParam = new CodeParameterDeclarationExpression (stringTypeRef, "format");
- var argsParam = new CodeParameterDeclarationExpression (TypeRef<object[]> (), "args");
- argsParam.CustomAttributes.Add (new CodeAttributeDeclaration (TypeRef<ParamArrayAttribute> ()));
-
- var textToAppendParamRef = new CodeArgumentReferenceExpression ("textToAppend");
- var formatParamRef = new CodeArgumentReferenceExpression ("format");
- var argsParamRef = new CodeArgumentReferenceExpression ("args");
-
- var writeMeth = new CodeMemberMethod {
- Name = "Write",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- writeMeth.Parameters.Add (textToAppendParam);
- writeMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "Append", new CodeArgumentReferenceExpression ("textToAppend")));
-
- var writeArgsMeth = new CodeMemberMethod {
- Name = "Write",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- writeArgsMeth.Parameters.Add (formatParam);
- writeArgsMeth.Parameters.Add (argsParam);
- writeArgsMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "AppendFormat", formatParamRef, argsParamRef));
-
- var writeLineMeth = new CodeMemberMethod {
- Name = "WriteLine",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- writeLineMeth.Parameters.Add (textToAppendParam);
- writeLineMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "Append", currentIndentFieldRef));
- writeLineMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "AppendLine", textToAppendParamRef));
-
- var writeLineArgsMeth = new CodeMemberMethod {
- Name = "WriteLine",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- writeLineArgsMeth.Parameters.Add (formatParam);
- writeLineArgsMeth.Parameters.Add (argsParam);
- writeLineArgsMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "Append", currentIndentFieldRef));
- writeLineArgsMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "AppendFormat", formatParamRef, argsParamRef));
- writeLineArgsMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "AppendLine"));
-
- type.Members.Add (writeMeth);
- type.Members.Add (writeArgsMeth);
- type.Members.Add (writeLineMeth);
- type.Members.Add (writeLineArgsMeth);
- }
-
- static void AddToStringHelper (CodeTypeDeclaration type, TemplateSettings settings)
- {
- var helperCls = new CodeTypeDeclaration ("ToStringInstanceHelper") {
- IsClass = true,
- TypeAttributes = TypeAttributes.NestedPublic,
- };
-
- var formatProviderField = PrivateField (TypeRef<IFormatProvider> (), "formatProvider");
- formatProviderField.InitExpression = new CodePropertyReferenceExpression (
- new CodeTypeReferenceExpression (TypeRef<System.Globalization.CultureInfo> ()), "InvariantCulture");
- var formatProviderFieldRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), formatProviderField.Name);
-
- var formatProviderProp = GenerateGetterSetterProperty ("FormatProvider", formatProviderField);
- MakeSimpleSetterIgnoreNull (formatProviderProp);
-
- helperCls.Members.Add (formatProviderField);
- helperCls.Members.Add (formatProviderProp);
-
- var meth = new CodeMemberMethod {
- Name = "ToStringWithCulture",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- ReturnType = TypeRef<string> (),
- };
- meth.Parameters.Add (new CodeParameterDeclarationExpression (TypeRef<object> (), "objectToConvert"));
- var paramRef = new CodeArgumentReferenceExpression ("objectToConvert");
-
- meth.Statements.Add (NullCheck (paramRef, paramRef.ParameterName));
-
- var typeLocal = new CodeVariableDeclarationStatement (TypeRef<Type> (), "type", new CodeMethodInvokeExpression (paramRef, "GetType"));
- var typeLocalRef = new CodeVariableReferenceExpression (typeLocal.Name);
- meth.Statements.Add (typeLocal);
-
- var iConvertibleTypeLocal = new CodeVariableDeclarationStatement (TypeRef<Type> (), "iConvertibleType",
- new CodeTypeOfExpression (TypeRef<IConvertible> ()));
- var iConvertibleTypeLocalRef = new CodeVariableReferenceExpression (iConvertibleTypeLocal.Name);
- meth.Statements.Add (iConvertibleTypeLocal);
-
- meth.Statements.Add (new CodeConditionStatement (
- new CodeMethodInvokeExpression (iConvertibleTypeLocalRef, "IsAssignableFrom", typeLocalRef),
- new CodeMethodReturnStatement (new CodeMethodInvokeExpression (
- new CodeCastExpression (TypeRef<IConvertible> (), paramRef), "ToString", formatProviderFieldRef))));
-
- var methInfoLocal = new CodeVariableDeclarationStatement (TypeRef<MethodInfo> (), "methInfo",
- new CodeMethodInvokeExpression (typeLocalRef, "GetMethod",
- new CodePrimitiveExpression ("ToString"),
- new CodeArrayCreateExpression (TypeRef<Type> (), new CodeExpression [] { iConvertibleTypeLocalRef })));
- meth.Statements.Add (methInfoLocal);
- var methInfoLocalRef = new CodeVariableReferenceExpression (methInfoLocal.Name);
- meth.Statements.Add (new CodeConditionStatement (NotNull (methInfoLocalRef),
- new CodeMethodReturnStatement (new CodeCastExpression (TypeRef<string> (),
- new CodeMethodInvokeExpression (
- methInfoLocalRef, "Invoke", paramRef,
- new CodeArrayCreateExpression (TypeRef<object> (), new CodeExpression [] { formatProviderFieldRef } ))))));
-
- meth.Statements.Add (new CodeMethodReturnStatement (new CodeMethodInvokeExpression (paramRef, "ToString")));
-
- helperCls.Members.Add (meth);
-
-
- var helperFieldName = settings.Provider.CreateValidIdentifier ("_toStringHelper");
- var helperField = PrivateField (new CodeTypeReference (helperCls.Name), helperFieldName);
- helperField.InitExpression = new CodeObjectCreateExpression (helperField.Type);
- type.Members.Add (helperField);
- type.Members.Add (GenerateGetterProperty ("ToStringHelper", helperField));
- type.Members.Add (helperCls);
- }
-
- #region CodeDom helpers
-
- static CodeTypeReference TypeRef<T> ()
- {
- return new CodeTypeReference (typeof (T), CodeTypeReferenceOptions.GlobalReference);
- }
-
- static CodeMemberProperty GenerateGetterSetterProperty (string propertyName, CodeMemberField field)
- {
- var prop = new CodeMemberProperty {
- Name = propertyName,
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- Type = field.Type
- };
- var fieldRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), field.Name);
- AddGetter (prop, fieldRef);
- AddSetter (prop, fieldRef);
- return prop;
- }
-
- static CodeMemberProperty GenerateGetterProperty (string propertyName, CodeMemberField field)
- {
- var prop = new CodeMemberProperty {
- Name = propertyName,
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- HasSet = false,
- Type = field.Type
- };
- var fieldRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), field.Name);
- AddGetter (prop, fieldRef);
- return prop;
- }
-
- static void AddSetter (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef)
- {
- property.HasSet = true;
- property.SetStatements.Add (new CodeAssignStatement (fieldRef, new CodePropertySetValueReferenceExpression ()));
- }
-
- static void AddGetter (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef)
- {
- property.HasGet = true;
- property.GetStatements.Add (new CodeMethodReturnStatement (fieldRef));
- }
-
- static void MakeGetterLazy (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef, CodeExpression initExpression)
- {
- property.GetStatements.Insert (0, new CodeConditionStatement (
- NotNull (fieldRef),
- new CodeAssignStatement (fieldRef, initExpression))
- );
- }
-
- static void MakeSimpleSetterIgnoreNull (CodeMemberProperty property)
- {
- property.SetStatements [0] = new CodeConditionStatement (
- NotNull (new CodePropertySetValueReferenceExpression ()),
- property.SetStatements [0]);
- }
-
- static CodeStatement NullCheck (CodeExpression expr, string exceptionMessage)
- {
- return new CodeConditionStatement (
- IsNull (expr),
- new CodeThrowExceptionStatement (new CodeObjectCreateExpression (
- new CodeTypeReference (typeof (ArgumentNullException), CodeTypeReferenceOptions.GlobalReference),
- new CodePrimitiveExpression (exceptionMessage)))
- );
- }
-
- static CodeBinaryOperatorExpression NotNull (CodeExpression reference)
- {
- return new CodeBinaryOperatorExpression (reference, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression (null));
- }
-
- static CodeBinaryOperatorExpression IsNull (CodeExpression reference)
- {
- return new CodeBinaryOperatorExpression (reference, CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (null));
- }
-
- static CodeBinaryOperatorExpression IsFalse (CodeExpression expr)
- {
- return new CodeBinaryOperatorExpression (expr, CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (false));
- }
-
- static CodeBinaryOperatorExpression BooleanAnd (CodeExpression expr1, CodeExpression expr2)
- {
- return new CodeBinaryOperatorExpression (expr1, CodeBinaryOperatorType.BooleanAnd, expr2);
- }
-
- static CodeStatement ArgNullCheck (CodeExpression value, params CodeExpression[] argNullExcArgs)
- {
- return new CodeConditionStatement (
- new CodeBinaryOperatorExpression (value,
- CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (null)),
- new CodeThrowExceptionStatement (new CodeObjectCreateExpression (typeof (ArgumentNullException), argNullExcArgs)));
- }
-
- static CodeMemberField PrivateField (CodeTypeReference typeRef, string name)
- {
- return new CodeMemberField (typeRef, name) {
- Attributes = MemberAttributes.Private
- };
- }
-
- #endregion
-
- //HACK: Mono as of 2.10.2 doesn't implement GenerateCodeFromMember
- static readonly bool useMonoHack = Type.GetType ("Mono.Runtime") != null;
-
- /// <summary>
- /// An implementation of CodeDomProvider.GenerateCodeFromMember that works on Mono.
- /// </summary>
- public static void GenerateCodeFromMembers (CodeDomProvider provider, CodeGeneratorOptions options, StringWriter sw, IEnumerable<CodeTypeMember> members)
- {
- if (!useMonoHack) {
- foreach (CodeTypeMember member in members)
- provider.GenerateCodeFromMember (member, sw, options);
- return;
- }
-
- var cgType = typeof (CodeGenerator);
- var initializeCodeGenerator = GetInitializeCodeGeneratorAction (cgType);
- var cgFieldGen = cgType.GetMethod ("GenerateField", BindingFlags.NonPublic | BindingFlags.Instance);
- var cgPropGen = cgType.GetMethod ("GenerateProperty", BindingFlags.NonPublic | BindingFlags.Instance);
- var cgMethGen = cgType.GetMethod ("GenerateMethod", BindingFlags.NonPublic | BindingFlags.Instance);
-
- #pragma warning disable 0618
- var generator = (CodeGenerator) provider.CreateGenerator ();
- #pragma warning restore 0618
- var dummy = new CodeTypeDeclaration ("Foo");
-
- foreach (CodeTypeMember member in members) {
- var f = member as CodeMemberField;
- if (f != null) {
- initializeCodeGenerator (generator, sw, options);
- cgFieldGen.Invoke (generator, new object[] { f });
- continue;
- }
- var p = member as CodeMemberProperty;
- if (p != null) {
- initializeCodeGenerator (generator, sw, options);
- cgPropGen.Invoke (generator, new object[] { p, dummy });
- continue;
- }
- var m = member as CodeMemberMethod;
- if (m != null) {
- initializeCodeGenerator (generator, sw, options);
- cgMethGen.Invoke (generator, new object[] { m, dummy });
- continue;
- }
- }
- }
-
- static Action<CodeGenerator, StringWriter, CodeGeneratorOptions> GetInitializeCodeGeneratorAction (Type cgType)
- {
- var cgInit = cgType.GetMethod ("InitOutput", BindingFlags.NonPublic | BindingFlags.Instance);
- if (cgInit != null) {
- return new Action<CodeGenerator, StringWriter, CodeGeneratorOptions> ((generator, sw, options) => {
- cgInit.Invoke (generator, new object[] { sw, options });
- });
- }
-
- var cgOptions = cgType.GetField ("options", BindingFlags.NonPublic | BindingFlags.Instance);
- var cgOutput = cgType.GetField ("output", BindingFlags.NonPublic | BindingFlags.Instance);
-
- if (cgOptions != null && cgOutput != null) {
- return new Action<CodeGenerator, StringWriter, CodeGeneratorOptions> ((generator, sw, options) => {
- var output = new IndentedTextWriter (sw);
- cgOptions.SetValue (generator, options);
- cgOutput.SetValue (generator, output);
- });
- }
-
- throw new InvalidOperationException ("Unable to initialize CodeGenerator.");
- }
-
- public static string GenerateIndentedClassCode (CodeDomProvider provider, params CodeTypeMember[] members)
- {
- return GenerateIndentedClassCode (provider, (IEnumerable<CodeTypeMember>)members);
- }
-
- public static string GenerateIndentedClassCode (CodeDomProvider provider, IEnumerable<CodeTypeMember> members)
- {
- var options = new CodeGeneratorOptions ();
- using (var sw = new StringWriter ()) {
- TemplatingEngine.GenerateCodeFromMembers (provider, options, sw, members);
- return TemplatingEngine.IndentSnippetText (provider, sw.ToString (), " ");
- }
- }
- }
-}
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/Tokeniser.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/Tokeniser.cs
deleted file mode 100644
index 1ff578ed8e..0000000000
--- a/main/src/addins/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/Tokeniser.cs
+++ /dev/null
@@ -1,293 +0,0 @@
-//
-// Tokeniser.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-
-namespace Mono.TextTemplating
-{
-
- public class Tokeniser
- {
- readonly string content;
- int position;
- string value;
- State nextState = State.Content;
- Location nextStateLocation;
- Location nextStateTagStartLocation;
-
- public Tokeniser (string fileName, string content)
- {
- State = State.Content;
- this.content = content;
- this.Location = this.nextStateLocation = this.nextStateTagStartLocation = new Location (fileName, 1, 1);
- }
-
- public bool Advance ()
- {
- value = null;
- State = nextState;
- Location = nextStateLocation;
- TagStartLocation = nextStateTagStartLocation;
- if (nextState == State.EOF)
- return false;
- nextState = GetNextStateAndCurrentValue ();
- return true;
- }
-
- State GetNextStateAndCurrentValue ()
- {
- switch (State) {
- case State.Block:
- case State.Expression:
- case State.Helper:
- return GetBlockEnd ();
-
- case State.Directive:
- return NextStateInDirective ();
-
- case State.Content:
- return NextStateInContent ();
-
- case State.DirectiveName:
- return GetDirectiveName ();
-
- case State.DirectiveValue:
- return GetDirectiveValue ();
-
- default:
- throw new InvalidOperationException ("Unexpected state '" + State + "'");
- }
- }
-
- State GetBlockEnd ()
- {
- int start = position;
- for (; position < content.Length; position++) {
- char c = content[position];
- nextStateTagStartLocation = nextStateLocation;
- nextStateLocation = nextStateLocation.AddCol ();
- if (c == '\r') {
- if (position + 1 < content.Length && content[position + 1] == '\n')
- position++;
- nextStateLocation = nextStateLocation.AddLine();
- } else if (c == '\n') {
- nextStateLocation = nextStateLocation.AddLine();
- } else if (c =='>' && content[position-1] == '#' && content[position-2] != '\\') {
- value = content.Substring (start, position - start - 1);
- position++;
- TagEndLocation = nextStateLocation;
-
- //skip newlines directly after blocks, unless they're expressions
- if (State != State.Expression && (position += IsNewLine()) > 0) {
- nextStateLocation = nextStateLocation.AddLine ();
- }
- return State.Content;
- }
- }
- throw new ParserException ("Unexpected end of file.", nextStateLocation);
- }
-
- State GetDirectiveName ()
- {
- int start = position;
- for (; position < content.Length; position++) {
- char c = content [position];
- if (!Char.IsLetterOrDigit (c)) {
- value = content.Substring (start, position - start);
- return State.Directive;
- }
- nextStateLocation = nextStateLocation.AddCol ();
- }
- throw new ParserException ("Unexpected end of file.", nextStateLocation);
- }
-
- State GetDirectiveValue ()
- {
- int start = position;
- int delimiter = '\0';
- for (; position < content.Length; position++) {
- char c = content[position];
- nextStateLocation = nextStateLocation.AddCol ();
- if (c == '\r') {
- if (position + 1 < content.Length && content[position + 1] == '\n')
- position++;
- nextStateLocation = nextStateLocation.AddLine();
- } else if (c == '\n')
- nextStateLocation = nextStateLocation.AddLine();
- if (delimiter == '\0') {
- if (c == '\'' || c == '"') {
- start = position;
- delimiter = c;
- } else if (!Char.IsWhiteSpace (c)) {
- throw new ParserException ("Unexpected character '" + c + "'. Expecting attribute value.", nextStateLocation);
- }
- continue;
- }
- if (c == delimiter) {
- value = content.Substring (start + 1, position - start - 1);
- position++;
- return State.Directive;
- }
- }
- throw new ParserException ("Unexpected end of file.", nextStateLocation);
- }
-
- State NextStateInContent ()
- {
- int start = position;
- for (; position < content.Length; position++) {
- char c = content[position];
- nextStateTagStartLocation = nextStateLocation;
- nextStateLocation = nextStateLocation.AddCol ();
- if (c == '\r') {
- if (position + 1 < content.Length && content[position + 1] == '\n')
- position++;
- nextStateLocation = nextStateLocation.AddLine();
- } else if (c == '\n') {
- nextStateLocation = nextStateLocation.AddLine();
- } else if (c =='<' && position + 2 < content.Length && content[position+1] == '#') {
- TagEndLocation = nextStateLocation;
- char type = content [position + 2];
- if (type == '@') {
- nextStateLocation = nextStateLocation.AddCols (2);
- value = content.Substring (start, position - start);
- position += 3;
- return State.Directive;
- }
- if (type == '=') {
- nextStateLocation = nextStateLocation.AddCols (2);
- value = content.Substring (start, position - start);
- position += 3;
- return State.Expression;
- }
- if (type == '+') {
- nextStateLocation = nextStateLocation.AddCols (2);
- value = content.Substring (start, position - start);
- position += 3;
- return State.Helper;
- }
- value = content.Substring (start, position - start);
- nextStateLocation = nextStateLocation.AddCol ();
- position += 2;
- return State.Block;
- }
- }
- //EOF is only valid when we're in content
- value = content.Substring (start);
- return State.EOF;
- }
-
- int IsNewLine() {
- int found = 0;
-
- if (position < content.Length && content[position] == '\r') {
- found++;
- }
- if (position+found < content.Length && content[position+found] == '\n') {
- found++;
- }
- return found;
- }
-
- State NextStateInDirective () {
- for (; position < content.Length; position++) {
- char c = content[position];
- if (c == '\r') {
- if (position + 1 < content.Length && content[position + 1] == '\n')
- position++;
- nextStateLocation = nextStateLocation.AddLine();
- } else if (c == '\n') {
- nextStateLocation = nextStateLocation.AddLine();
- } else if (Char.IsLetter (c)) {
- return State.DirectiveName;
- } else if (c == '=') {
- nextStateLocation = nextStateLocation.AddCol ();
- position++;
- return State.DirectiveValue;
- } else if (c == '#' && position + 1 < content.Length && content[position+1] == '>') {
- position+=2;
- TagEndLocation = nextStateLocation.AddCols (2);
- nextStateLocation = nextStateLocation.AddCols (3);
-
- //skip newlines directly after directives
- if ((position += IsNewLine()) > 0) {
- nextStateLocation = nextStateLocation.AddLine();
- }
-
- return State.Content;
- } else if (!Char.IsWhiteSpace (c)) {
- throw new ParserException ("Directive ended unexpectedly with character '" + c + "'", nextStateLocation);
- } else {
- nextStateLocation = nextStateLocation.AddCol ();
- }
- }
- throw new ParserException ("Unexpected end of file.", nextStateLocation);
- }
-
- public State State {
- get; private set;
- }
-
- public int Position {
- get { return position; }
- }
-
- public string Content {
- get { return content; }
- }
-
- public string Value {
- get { return value; }
- }
-
- public Location Location { get; private set; }
- public Location TagStartLocation { get; private set; }
- public Location TagEndLocation { get; private set; }
- }
-
- public enum State
- {
- Content = 0,
- Directive,
- Expression,
- Block,
- Helper,
- DirectiveName,
- DirectiveValue,
- Name,
- EOF
- }
-
- public class ParserException : Exception
- {
- public ParserException (string message, Location location) : base (message)
- {
- Location = location;
- }
-
- public Location Location { get; private set; }
- }
-}
diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj
index 8df136c0bc..70532b3906 100644
--- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj
+++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj
@@ -82,6 +82,9 @@
<HintPath>..\..\..\..\build\bin\Microsoft.CodeAnalysis.dll</HintPath>
<Private>False</Private>
</Reference>
+ <Reference Include="Mono.TextTemplating">
+ <HintPath>..\..\..\..\packages\Mono.TextTemplating.1.3.0\lib\net45\Mono.TextTemplating.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Parser\" />
@@ -89,11 +92,6 @@
<Folder Include="Templates\" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\Mono.TextTemplating\Mono.TextTemplating.csproj">
- <Project>{A2364D6A-00EF-417C-80A6-815726C70032}</Project>
- <Name>Mono.TextTemplating</Name>
- <Private>False</Private>
- </ProjectReference>
<ProjectReference Include="..\..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
<Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
<Name>MonoDevelop.Core</Name>
@@ -128,6 +126,11 @@
<None Include="Templates\T4PreprocessedTemplateCSharp.xft.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="packages.config" />
+ <None Include="..\..\..\..\packages\Mono.TextTemplating.1.3.0\tools\TextTransform.exe">
+ <Link>TextTransform.exe</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/packages.config b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/packages.config
new file mode 100644
index 0000000000..f2cdb24097
--- /dev/null
+++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Mono.TextTemplating" version="1.3.0" targetFramework="net45" />
+</packages>
diff --git a/main/src/addins/TextTemplating/TextTransform/AssemblyInfo.cs b/main/src/addins/TextTemplating/TextTransform/AssemblyInfo.cs
deleted file mode 100644
index abe1e8b46d..0000000000
--- a/main/src/addins/TextTemplating/TextTransform/AssemblyInfo.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// AssemblyInfo.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-// Information about this assembly is defined by the following attributes.
-// Change them to the values specific to your project.
-
-[assembly: AssemblyTitle("TextTransform")]
-[assembly: AssemblyDescription("T4 text transformation tool")]
-[assembly: AssemblyCompany("The Mono Project")]
-[assembly: AssemblyProduct("MonoDevelop")]
-[assembly: AssemblyCopyright("MIT/X11")]
-
-//[assembly: AssemblyVersion("1.0.0.0")]
-
diff --git a/main/src/addins/TextTemplating/TextTransform/Makefile.am b/main/src/addins/TextTemplating/TextTransform/Makefile.am
deleted file mode 100644
index c9cc87438f..0000000000
--- a/main/src/addins/TextTemplating/TextTransform/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-include $(top_srcdir)/xbuild.include
diff --git a/main/src/addins/TextTemplating/TextTransform/Options.cs b/main/src/addins/TextTemplating/TextTransform/Options.cs
deleted file mode 100644
index 124ad72fd3..0000000000
--- a/main/src/addins/TextTemplating/TextTransform/Options.cs
+++ /dev/null
@@ -1,1099 +0,0 @@
-//
-// Options.cs
-//
-// Authors:
-// Jonathan Pryor <jpryor@novell.com>
-//
-// Copyright (C) 2008 Novell (http://www.novell.com)
-//
-// 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.
-//
-
-// Compile With:
-// gmcs -debug+ -r:System.Core Options.cs -o:NDesk.Options.dll
-// gmcs -debug+ -d:LINQ -r:System.Core Options.cs -o:NDesk.Options.dll
-//
-// The LINQ version just changes the implementation of
-// OptionSet.Parse(IEnumerable<string>), and confers no semantic changes.
-
-//
-// A Getopt::Long-inspired option parsing library for C#.
-//
-// NDesk.Options.OptionSet is built upon a key/value table, where the
-// key is a option format string and the value is a delegate that is
-// invoked when the format string is matched.
-//
-// Option format strings:
-// Regex-like BNF Grammar:
-// name: .+
-// type: [=:]
-// sep: ( [^{}]+ | '{' .+ '}' )?
-// aliases: ( name type sep ) ( '|' name type sep )*
-//
-// Each '|'-delimited name is an alias for the associated action. If the
-// format string ends in a '=', it has a required value. If the format
-// string ends in a ':', it has an optional value. If neither '=' or ':'
-// is present, no value is supported. `=' or `:' need only be defined on one
-// alias, but if they are provided on more than one they must be consistent.
-//
-// Each alias portion may also end with a "key/value separator", which is used
-// to split option values if the option accepts > 1 value. If not specified,
-// it defaults to '=' and ':'. If specified, it can be any character except
-// '{' and '}' OR the *string* between '{' and '}'. If no separator should be
-// used (i.e. the separate values should be distinct arguments), then "{}"
-// should be used as the separator.
-//
-// Options are extracted either from the current option by looking for
-// the option name followed by an '=' or ':', or is taken from the
-// following option IFF:
-// - The current option does not contain a '=' or a ':'
-// - The current option requires a value (i.e. not a Option type of ':')
-//
-// The `name' used in the option format string does NOT include any leading
-// option indicator, such as '-', '--', or '/'. All three of these are
-// permitted/required on any named option.
-//
-// Option bundling is permitted so long as:
-// - '-' is used to start the option group
-// - all of the bundled options are a single character
-// - at most one of the bundled options accepts a value, and the value
-// provided starts from the next character to the end of the string.
-//
-// This allows specifying '-a -b -c' as '-abc', and specifying '-D name=value'
-// as '-Dname=value'.
-//
-// Option processing is disabled by specifying "--". All options after "--"
-// are returned by OptionSet.Parse() unchanged and unprocessed.
-//
-// Unprocessed options are returned from OptionSet.Parse().
-//
-// Examples:
-// int verbose = 0;
-// OptionSet p = new OptionSet ()
-// .Add ("v", v => ++verbose)
-// .Add ("name=|value=", v => Console.WriteLine (v));
-// p.Parse (new string[]{"-v", "--v", "/v", "-name=A", "/name", "B", "extra"});
-//
-// The above would parse the argument string array, and would invoke the
-// lambda expression three times, setting `verbose' to 3 when complete.
-// It would also print out "A" and "B" to standard output.
-// The returned array would contain the string "extra".
-//
-// C# 3.0 collection initializers are supported and encouraged:
-// var p = new OptionSet () {
-// { "h|?|help", v => ShowHelp () },
-// };
-//
-// System.ComponentModel.TypeConverter is also supported, allowing the use of
-// custom data types in the callback type; TypeConverter.ConvertFromString()
-// is used to convert the value option to an instance of the specified
-// type:
-//
-// var p = new OptionSet () {
-// { "foo=", (Foo f) => Console.WriteLine (f.ToString ()) },
-// };
-//
-// Random other tidbits:
-// - Boolean options (those w/o '=' or ':' in the option format string)
-// are explicitly enabled if they are followed with '+', and explicitly
-// disabled if they are followed with '-':
-// string a = null;
-// var p = new OptionSet () {
-// { "a", s => a = s },
-// };
-// p.Parse (new string[]{"-a"}); // sets v != null
-// p.Parse (new string[]{"-a+"}); // sets v != null
-// p.Parse (new string[]{"-a-"}); // sets v == null
-//
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Globalization;
-using System.IO;
-using System.Runtime.Serialization;
-using System.Security.Permissions;
-using System.Text;
-using System.Text.RegularExpressions;
-
-#if LINQ
-using System.Linq;
-#endif
-
-#if TEST
-using NDesk.Options;
-#endif
-
-#if NDESK_OPTIONS
-namespace NDesk.Options
-#else
-namespace Mono.Options
-#endif
-{
- public class OptionValueCollection : IList, IList<string> {
-
- List<string> values = new List<string> ();
- OptionContext c;
-
- internal OptionValueCollection (OptionContext c)
- {
- this.c = c;
- }
-
- #region ICollection
- void ICollection.CopyTo (Array array, int index) {(values as ICollection).CopyTo (array, index);}
- bool ICollection.IsSynchronized {get {return (values as ICollection).IsSynchronized;}}
- object ICollection.SyncRoot {get {return (values as ICollection).SyncRoot;}}
- #endregion
-
- #region ICollection<T>
- public void Add (string item) {values.Add (item);}
- public void Clear () {values.Clear ();}
- public bool Contains (string item) {return values.Contains (item);}
- public void CopyTo (string[] array, int arrayIndex) {values.CopyTo (array, arrayIndex);}
- public bool Remove (string item) {return values.Remove (item);}
- public int Count {get {return values.Count;}}
- public bool IsReadOnly {get {return false;}}
- #endregion
-
- #region IEnumerable
- IEnumerator IEnumerable.GetEnumerator () {return values.GetEnumerator ();}
- #endregion
-
- #region IEnumerable<T>
- public IEnumerator<string> GetEnumerator () {return values.GetEnumerator ();}
- #endregion
-
- #region IList
- int IList.Add (object value) {return (values as IList).Add (value);}
- bool IList.Contains (object value) {return (values as IList).Contains (value);}
- int IList.IndexOf (object value) {return (values as IList).IndexOf (value);}
- void IList.Insert (int index, object value) {(values as IList).Insert (index, value);}
- void IList.Remove (object value) {(values as IList).Remove (value);}
- void IList.RemoveAt (int index) {(values as IList).RemoveAt (index);}
- bool IList.IsFixedSize {get {return false;}}
- object IList.this [int index] {get {return this [index];} set {(values as IList)[index] = value;}}
- #endregion
-
- #region IList<T>
- public int IndexOf (string item) {return values.IndexOf (item);}
- public void Insert (int index, string item) {values.Insert (index, item);}
- public void RemoveAt (int index) {values.RemoveAt (index);}
-
- private void AssertValid (int index)
- {
- if (c.Option == null)
- throw new InvalidOperationException ("OptionContext.Option is null.");
- if (index >= c.Option.MaxValueCount)
- throw new ArgumentOutOfRangeException ("index");
- if (c.Option.OptionValueType == OptionValueType.Required &&
- index >= values.Count)
- throw new OptionException (string.Format (
- c.OptionSet.MessageLocalizer ("Missing required value for option '{0}'."), c.OptionName),
- c.OptionName);
- }
-
- public string this [int index] {
- get {
- AssertValid (index);
- return index >= values.Count ? null : values [index];
- }
- set {
- values [index] = value;
- }
- }
- #endregion
-
- public List<string> ToList ()
- {
- return new List<string> (values);
- }
-
- public string[] ToArray ()
- {
- return values.ToArray ();
- }
-
- public override string ToString ()
- {
- return string.Join (", ", values.ToArray ());
- }
- }
-
- public class OptionContext {
- private Option option;
- private string name;
- private int index;
- private OptionSet set;
- private OptionValueCollection c;
-
- public OptionContext (OptionSet set)
- {
- this.set = set;
- this.c = new OptionValueCollection (this);
- }
-
- public Option Option {
- get {return option;}
- set {option = value;}
- }
-
- public string OptionName {
- get {return name;}
- set {name = value;}
- }
-
- public int OptionIndex {
- get {return index;}
- set {index = value;}
- }
-
- public OptionSet OptionSet {
- get {return set;}
- }
-
- public OptionValueCollection OptionValues {
- get {return c;}
- }
- }
-
- public enum OptionValueType {
- None,
- Optional,
- Required,
- }
-
- public abstract class Option {
- string prototype, description;
- string[] names;
- OptionValueType type;
- int count;
- string[] separators;
-
- protected Option (string prototype, string description)
- : this (prototype, description, 1)
- {
- }
-
- protected Option (string prototype, string description, int maxValueCount)
- {
- if (prototype == null)
- throw new ArgumentNullException ("prototype");
- if (prototype.Length == 0)
- throw new ArgumentException ("Cannot be the empty string.", "prototype");
- if (maxValueCount < 0)
- throw new ArgumentOutOfRangeException ("maxValueCount");
-
- this.prototype = prototype;
- this.names = prototype.Split ('|');
- this.description = description;
- this.count = maxValueCount;
- this.type = ParsePrototype ();
-
- if (this.count == 0 && type != OptionValueType.None)
- throw new ArgumentException (
- "Cannot provide maxValueCount of 0 for OptionValueType.Required or " +
- "OptionValueType.Optional.",
- "maxValueCount");
- if (this.type == OptionValueType.None && maxValueCount > 1)
- throw new ArgumentException (
- string.Format ("Cannot provide maxValueCount of {0} for OptionValueType.None.", maxValueCount),
- "maxValueCount");
- if (Array.IndexOf (names, "<>") >= 0 &&
- ((names.Length == 1 && this.type != OptionValueType.None) ||
- (names.Length > 1 && this.MaxValueCount > 1)))
- throw new ArgumentException (
- "The default option handler '<>' cannot require values.",
- "prototype");
- }
-
- public string Prototype {get {return prototype;}}
- public string Description {get {return description;}}
- public OptionValueType OptionValueType {get {return type;}}
- public int MaxValueCount {get {return count;}}
-
- public string[] GetNames ()
- {
- return (string[]) names.Clone ();
- }
-
- public string[] GetValueSeparators ()
- {
- if (separators == null)
- return new string [0];
- return (string[]) separators.Clone ();
- }
-
- protected static T Parse<T> (string value, OptionContext c)
- {
- Type tt = typeof (T);
- bool nullable = tt.IsValueType && tt.IsGenericType &&
- !tt.IsGenericTypeDefinition &&
- tt.GetGenericTypeDefinition () == typeof (Nullable<>);
- Type targetType = nullable ? tt.GetGenericArguments () [0] : typeof (T);
- TypeConverter conv = TypeDescriptor.GetConverter (targetType);
- T t = default (T);
- try {
- if (value != null)
- t = (T) conv.ConvertFromString (value);
- }
- catch (Exception e) {
- throw new OptionException (
- string.Format (
- c.OptionSet.MessageLocalizer ("Could not convert string `{0}' to type {1} for option `{2}'."),
- value, targetType.Name, c.OptionName),
- c.OptionName, e);
- }
- return t;
- }
-
- internal string[] Names {get {return names;}}
- internal string[] ValueSeparators {get {return separators;}}
-
- static readonly char[] NameTerminator = new char[]{'=', ':'};
-
- private OptionValueType ParsePrototype ()
- {
- char type = '\0';
- List<string> seps = new List<string> ();
- for (int i = 0; i < names.Length; ++i) {
- string name = names [i];
- if (name.Length == 0)
- throw new ArgumentException ("Empty option names are not supported.", "prototype");
-
- int end = name.IndexOfAny (NameTerminator);
- if (end == -1)
- continue;
- names [i] = name.Substring (0, end);
- if (type == '\0' || type == name [end])
- type = name [end];
- else
- throw new ArgumentException (
- string.Format ("Conflicting option types: '{0}' vs. '{1}'.", type, name [end]),
- "prototype");
- AddSeparators (name, end, seps);
- }
-
- if (type == '\0')
- return OptionValueType.None;
-
- if (count <= 1 && seps.Count != 0)
- throw new ArgumentException (
- string.Format ("Cannot provide key/value separators for Options taking {0} value(s).", count),
- "prototype");
- if (count > 1) {
- if (seps.Count == 0)
- this.separators = new string[]{":", "="};
- else if (seps.Count == 1 && seps [0].Length == 0)
- this.separators = null;
- else
- this.separators = seps.ToArray ();
- }
-
- return type == '=' ? OptionValueType.Required : OptionValueType.Optional;
- }
-
- private static void AddSeparators (string name, int end, ICollection<string> seps)
- {
- int start = -1;
- for (int i = end+1; i < name.Length; ++i) {
- switch (name [i]) {
- case '{':
- if (start != -1)
- throw new ArgumentException (
- string.Format ("Ill-formed name/value separator found in \"{0}\".", name),
- "prototype");
- start = i+1;
- break;
- case '}':
- if (start == -1)
- throw new ArgumentException (
- string.Format ("Ill-formed name/value separator found in \"{0}\".", name),
- "prototype");
- seps.Add (name.Substring (start, i-start));
- start = -1;
- break;
- default:
- if (start == -1)
- seps.Add (name [i].ToString ());
- break;
- }
- }
- if (start != -1)
- throw new ArgumentException (
- string.Format ("Ill-formed name/value separator found in \"{0}\".", name),
- "prototype");
- }
-
- public void Invoke (OptionContext c)
- {
- OnParseComplete (c);
- c.OptionName = null;
- c.Option = null;
- c.OptionValues.Clear ();
- }
-
- protected abstract void OnParseComplete (OptionContext c);
-
- public override string ToString ()
- {
- return Prototype;
- }
- }
-
- [Serializable]
- public class OptionException : Exception {
- private string option;
-
- public OptionException ()
- {
- }
-
- public OptionException (string message, string optionName)
- : base (message)
- {
- this.option = optionName;
- }
-
- public OptionException (string message, string optionName, Exception innerException)
- : base (message, innerException)
- {
- this.option = optionName;
- }
-
- protected OptionException (SerializationInfo info, StreamingContext context)
- : base (info, context)
- {
- this.option = info.GetString ("OptionName");
- }
-
- public string OptionName {
- get {return this.option;}
- }
-
- [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
- public override void GetObjectData (SerializationInfo info, StreamingContext context)
- {
- base.GetObjectData (info, context);
- info.AddValue ("OptionName", option);
- }
- }
-
- public delegate void OptionAction<TKey, TValue> (TKey key, TValue value);
-
- public class OptionSet : KeyedCollection<string, Option>
- {
- public OptionSet ()
- : this (delegate (string f) {return f;})
- {
- }
-
- public OptionSet (Converter<string, string> localizer)
- {
- this.localizer = localizer;
- }
-
- Converter<string, string> localizer;
-
- public Converter<string, string> MessageLocalizer {
- get {return localizer;}
- }
-
- protected override string GetKeyForItem (Option item)
- {
- if (item == null)
- throw new ArgumentNullException ("option");
- if (item.Names != null && item.Names.Length > 0)
- return item.Names [0];
- // This should never happen, as it's invalid for Option to be
- // constructed w/o any names.
- throw new InvalidOperationException ("Option has no names!");
- }
-
- protected override void InsertItem (int index, Option item)
- {
- base.InsertItem (index, item);
- AddImpl (item);
- }
-
- protected override void RemoveItem (int index)
- {
- base.RemoveItem (index);
- Option p = Items [index];
- // KeyedCollection.RemoveItem() handles the 0th item
- for (int i = 1; i < p.Names.Length; ++i) {
- Dictionary.Remove (p.Names [i]);
- }
- }
-
- protected override void SetItem (int index, Option item)
- {
- base.SetItem (index, item);
- RemoveItem (index);
- AddImpl (item);
- }
-
- private void AddImpl (Option option)
- {
- if (option == null)
- throw new ArgumentNullException ("option");
- List<string> added = new List<string> (option.Names.Length);
- try {
- // KeyedCollection.InsertItem/SetItem handle the 0th name.
- for (int i = 1; i < option.Names.Length; ++i) {
- Dictionary.Add (option.Names [i], option);
- added.Add (option.Names [i]);
- }
- }
- catch (Exception) {
- foreach (string name in added)
- Dictionary.Remove (name);
- throw;
- }
- }
-
- public new OptionSet Add (Option option)
- {
- base.Add (option);
- return this;
- }
-
- sealed class ActionOption : Option {
- Action<OptionValueCollection> action;
-
- public ActionOption (string prototype, string description, int count, Action<OptionValueCollection> action)
- : base (prototype, description, count)
- {
- if (action == null)
- throw new ArgumentNullException ("action");
- this.action = action;
- }
-
- protected override void OnParseComplete (OptionContext c)
- {
- action (c.OptionValues);
- }
- }
-
- public OptionSet Add (string prototype, Action<string> action)
- {
- return Add (prototype, null, action);
- }
-
- public OptionSet Add (string prototype, string description, Action<string> action)
- {
- if (action == null)
- throw new ArgumentNullException ("action");
- Option p = new ActionOption (prototype, description, 1,
- delegate (OptionValueCollection v) { action (v [0]); });
- base.Add (p);
- return this;
- }
-
- public OptionSet Add (string prototype, OptionAction<string, string> action)
- {
- return Add (prototype, null, action);
- }
-
- public OptionSet Add (string prototype, string description, OptionAction<string, string> action)
- {
- if (action == null)
- throw new ArgumentNullException ("action");
- Option p = new ActionOption (prototype, description, 2,
- delegate (OptionValueCollection v) {action (v [0], v [1]);});
- base.Add (p);
- return this;
- }
-
- sealed class ActionOption<T> : Option {
- Action<T> action;
-
- public ActionOption (string prototype, string description, Action<T> action)
- : base (prototype, description, 1)
- {
- if (action == null)
- throw new ArgumentNullException ("action");
- this.action = action;
- }
-
- protected override void OnParseComplete (OptionContext c)
- {
- action (Parse<T> (c.OptionValues [0], c));
- }
- }
-
- sealed class ActionOption<TKey, TValue> : Option {
- OptionAction<TKey, TValue> action;
-
- public ActionOption (string prototype, string description, OptionAction<TKey, TValue> action)
- : base (prototype, description, 2)
- {
- if (action == null)
- throw new ArgumentNullException ("action");
- this.action = action;
- }
-
- protected override void OnParseComplete (OptionContext c)
- {
- action (
- Parse<TKey> (c.OptionValues [0], c),
- Parse<TValue> (c.OptionValues [1], c));
- }
- }
-
- public OptionSet Add<T> (string prototype, Action<T> action)
- {
- return Add (prototype, null, action);
- }
-
- public OptionSet Add<T> (string prototype, string description, Action<T> action)
- {
- return Add (new ActionOption<T> (prototype, description, action));
- }
-
- public OptionSet Add<TKey, TValue> (string prototype, OptionAction<TKey, TValue> action)
- {
- return Add (prototype, null, action);
- }
-
- public OptionSet Add<TKey, TValue> (string prototype, string description, OptionAction<TKey, TValue> action)
- {
- return Add (new ActionOption<TKey, TValue> (prototype, description, action));
- }
-
- protected virtual OptionContext CreateOptionContext ()
- {
- return new OptionContext (this);
- }
-
-#if LINQ
- public List<string> Parse (IEnumerable<string> arguments)
- {
- bool process = true;
- OptionContext c = CreateOptionContext ();
- c.OptionIndex = -1;
- var def = GetOptionForName ("<>");
- var unprocessed =
- from argument in arguments
- where ++c.OptionIndex >= 0 && (process || def != null)
- ? process
- ? argument == "--"
- ? (process = false)
- : !Parse (argument, c)
- ? def != null
- ? Unprocessed (null, def, c, argument)
- : true
- : false
- : def != null
- ? Unprocessed (null, def, c, argument)
- : true
- : true
- select argument;
- List<string> r = unprocessed.ToList ();
- if (c.Option != null)
- c.Option.Invoke (c);
- return r;
- }
-#else
- public List<string> Parse (IEnumerable<string> arguments)
- {
- OptionContext c = CreateOptionContext ();
- c.OptionIndex = -1;
- bool process = true;
- List<string> unprocessed = new List<string> ();
- Option def = Contains ("<>") ? this ["<>"] : null;
- foreach (string argument in arguments) {
- ++c.OptionIndex;
- if (argument == "--") {
- process = false;
- continue;
- }
- if (!process) {
- Unprocessed (unprocessed, def, c, argument);
- continue;
- }
- if (!Parse (argument, c))
- Unprocessed (unprocessed, def, c, argument);
- }
- if (c.Option != null)
- c.Option.Invoke (c);
- return unprocessed;
- }
-#endif
-
- private static bool Unprocessed (ICollection<string> extra, Option def, OptionContext c, string argument)
- {
- if (def == null) {
- extra.Add (argument);
- return false;
- }
- c.OptionValues.Add (argument);
- c.Option = def;
- c.Option.Invoke (c);
- return false;
- }
-
- private readonly Regex ValueOption = new Regex (
- @"^(?<flag>--|-|/)(?<name>[^:=]+)((?<sep>[:=])(?<value>.*))?$");
-
- protected bool GetOptionParts (string argument, out string flag, out string name, out string sep, out string value)
- {
- if (argument == null)
- throw new ArgumentNullException ("argument");
-
- flag = name = sep = value = null;
- Match m = ValueOption.Match (argument);
- if (!m.Success) {
- return false;
- }
- flag = m.Groups ["flag"].Value;
- name = m.Groups ["name"].Value;
- if (m.Groups ["sep"].Success && m.Groups ["value"].Success) {
- sep = m.Groups ["sep"].Value;
- value = m.Groups ["value"].Value;
- }
- return true;
- }
-
- protected virtual bool Parse (string argument, OptionContext c)
- {
- if (c.Option != null) {
- ParseValue (argument, c);
- return true;
- }
-
- string f, n, s, v;
- if (!GetOptionParts (argument, out f, out n, out s, out v))
- return false;
-
- Option p;
- if (Contains (n)) {
- p = this [n];
- c.OptionName = f + n;
- c.Option = p;
- switch (p.OptionValueType) {
- case OptionValueType.None:
- c.OptionValues.Add (n);
- c.Option.Invoke (c);
- break;
- case OptionValueType.Optional:
- case OptionValueType.Required:
- ParseValue (v, c);
- break;
- }
- return true;
- }
- // no match; is it a bool option?
- if (ParseBool (argument, n, c))
- return true;
- // is it a bundled option?
- if (ParseBundledValue (f, string.Concat (n + s + v), c))
- return true;
-
- return false;
- }
-
- private void ParseValue (string option, OptionContext c)
- {
- if (option != null)
- foreach (string o in c.Option.ValueSeparators != null
- ? option.Split (c.Option.ValueSeparators, StringSplitOptions.None)
- : new string[]{option}) {
- c.OptionValues.Add (o);
- }
- if (c.OptionValues.Count == c.Option.MaxValueCount ||
- c.Option.OptionValueType == OptionValueType.Optional)
- c.Option.Invoke (c);
- else if (c.OptionValues.Count > c.Option.MaxValueCount) {
- throw new OptionException (localizer (string.Format (
- "Error: Found {0} option values when expecting {1}.",
- c.OptionValues.Count, c.Option.MaxValueCount)),
- c.OptionName);
- }
- }
-
- private bool ParseBool (string option, string n, OptionContext c)
- {
- Option p;
- string rn;
- if (n.Length >= 1 && (n [n.Length-1] == '+' || n [n.Length-1] == '-') &&
- Contains ((rn = n.Substring (0, n.Length-1)))) {
- p = this [rn];
- string v = n [n.Length-1] == '+' ? option : null;
- c.OptionName = option;
- c.Option = p;
- c.OptionValues.Add (v);
- p.Invoke (c);
- return true;
- }
- return false;
- }
-
- private bool ParseBundledValue (string f, string n, OptionContext c)
- {
- if (f != "-")
- return false;
- for (int i = 0; i < n.Length; ++i) {
- Option p;
- string opt = f + n [i].ToString ();
- string rn = n [i].ToString ();
- if (!Contains (rn)) {
- if (i == 0)
- return false;
- throw new OptionException (string.Format (localizer (
- "Cannot bundle unregistered option '{0}'."), opt), opt);
- }
- p = this [rn];
- switch (p.OptionValueType) {
- case OptionValueType.None:
- Invoke (c, opt, n, p);
- break;
- case OptionValueType.Optional:
- case OptionValueType.Required: {
- string v = n.Substring (i+1);
- c.Option = p;
- c.OptionName = opt;
- ParseValue (v.Length != 0 ? v : null, c);
- return true;
- }
- default:
- throw new InvalidOperationException ("Unknown OptionValueType: " + p.OptionValueType);
- }
- }
- return true;
- }
-
- private static void Invoke (OptionContext c, string name, string value, Option option)
- {
- c.OptionName = name;
- c.Option = option;
- c.OptionValues.Add (value);
- option.Invoke (c);
- }
-
- private const int OptionWidth = 29;
-
- public void WriteOptionDescriptions (TextWriter o)
- {
- foreach (Option p in this) {
- int written = 0;
- if (!WriteOptionPrototype (o, p, ref written))
- continue;
-
- if (written < OptionWidth)
- o.Write (new string (' ', OptionWidth - written));
- else {
- o.WriteLine ();
- o.Write (new string (' ', OptionWidth));
- }
-
- List<string> lines = GetLines (localizer (GetDescription (p.Description)));
- o.WriteLine (lines [0]);
- string prefix = new string (' ', OptionWidth+2);
- for (int i = 1; i < lines.Count; ++i) {
- o.Write (prefix);
- o.WriteLine (lines [i]);
- }
- }
- }
-
- bool WriteOptionPrototype (TextWriter o, Option p, ref int written)
- {
- string[] names = p.Names;
-
- int i = GetNextOptionIndex (names, 0);
- if (i == names.Length)
- return false;
-
- if (names [i].Length == 1) {
- Write (o, ref written, " -");
- Write (o, ref written, names [0]);
- }
- else {
- Write (o, ref written, " --");
- Write (o, ref written, names [0]);
- }
-
- for ( i = GetNextOptionIndex (names, i+1);
- i < names.Length; i = GetNextOptionIndex (names, i+1)) {
- Write (o, ref written, ", ");
- Write (o, ref written, names [i].Length == 1 ? "-" : "--");
- Write (o, ref written, names [i]);
- }
-
- if (p.OptionValueType == OptionValueType.Optional ||
- p.OptionValueType == OptionValueType.Required) {
- if (p.OptionValueType == OptionValueType.Optional) {
- Write (o, ref written, localizer ("["));
- }
- Write (o, ref written, localizer ("=" + GetArgumentName (0, p.MaxValueCount, p.Description)));
- string sep = p.ValueSeparators != null && p.ValueSeparators.Length > 0
- ? p.ValueSeparators [0]
- : " ";
- for (int c = 1; c < p.MaxValueCount; ++c) {
- Write (o, ref written, localizer (sep + GetArgumentName (c, p.MaxValueCount, p.Description)));
- }
- if (p.OptionValueType == OptionValueType.Optional) {
- Write (o, ref written, localizer ("]"));
- }
- }
- return true;
- }
-
- static int GetNextOptionIndex (string[] names, int i)
- {
- while (i < names.Length && names [i] == "<>") {
- ++i;
- }
- return i;
- }
-
- static void Write (TextWriter o, ref int n, string s)
- {
- n += s.Length;
- o.Write (s);
- }
-
- private static string GetArgumentName (int index, int maxIndex, string description)
- {
- if (description == null)
- return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1);
- string[] nameStart;
- if (maxIndex == 1)
- nameStart = new string[]{"{0:", "{"};
- else
- nameStart = new string[]{"{" + index + ":"};
- for (int i = 0; i < nameStart.Length; ++i) {
- int start, j = 0;
- do {
- start = description.IndexOf (nameStart [i], j);
- } while (start >= 0 && j != 0 ? description [j++ - 1] == '{' : false);
- if (start == -1)
- continue;
- int end = description.IndexOf ("}", start);
- if (end == -1)
- continue;
- return description.Substring (start + nameStart [i].Length, end - start - nameStart [i].Length);
- }
- return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1);
- }
-
- private static string GetDescription (string description)
- {
- if (description == null)
- return string.Empty;
- StringBuilder sb = new StringBuilder (description.Length);
- int start = -1;
- for (int i = 0; i < description.Length; ++i) {
- switch (description [i]) {
- case '{':
- if (i == start) {
- sb.Append ('{');
- start = -1;
- }
- else if (start < 0)
- start = i + 1;
- break;
- case '}':
- if (start < 0) {
- if ((i+1) == description.Length || description [i+1] != '}')
- throw new InvalidOperationException ("Invalid option description: " + description);
- ++i;
- sb.Append ("}");
- }
- else {
- sb.Append (description, start, i - start);
- start = -1;
- }
- break;
- case ':':
- if (start < 0)
- goto default;
- start = i + 1;
- break;
- default:
- if (start < 0)
- sb.Append (description [i]);
- break;
- }
- }
- return sb.ToString ();
- }
-
- private static List<string> GetLines (string description)
- {
- List<string> lines = new List<string> ();
- if (string.IsNullOrEmpty (description)) {
- lines.Add (string.Empty);
- return lines;
- }
- int length = 80 - OptionWidth - 2;
- int start = 0, end;
- do {
- end = GetLineEnd (start, length, description);
- bool cont = false;
- if (end < description.Length) {
- char c = description [end];
- if (c == '-' || (char.IsWhiteSpace (c) && c != '\n'))
- ++end;
- else if (c != '\n') {
- cont = true;
- --end;
- }
- }
- lines.Add (description.Substring (start, end - start));
- if (cont) {
- lines [lines.Count-1] += "-";
- }
- start = end;
- if (start < description.Length && description [start] == '\n')
- ++start;
- } while (end < description.Length);
- return lines;
- }
-
- private static int GetLineEnd (int start, int length, string description)
- {
- int end = System.Math.Min (start + length, description.Length);
- int sep = -1;
- for (int i = start; i < end; ++i) {
- switch (description [i]) {
- case ' ':
- case '\t':
- case '\v':
- case '-':
- case ',':
- case '.':
- case ';':
- sep = i;
- break;
- case '\n':
- return i;
- }
- }
- if (sep == -1 || end == description.Length)
- return end;
- return sep;
- }
- }
-}
-
diff --git a/main/src/addins/TextTemplating/TextTransform/TextTransform.cs b/main/src/addins/TextTemplating/TextTransform/TextTransform.cs
deleted file mode 100644
index 914b739fe9..0000000000
--- a/main/src/addins/TextTemplating/TextTransform/TextTransform.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-//
-// Main.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// 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.
-
-using System;
-using System.IO;
-using System.Collections.Generic;
-using Mono.Options;
-
-namespace Mono.TextTemplating
-{
- class TextTransform
- {
- static OptionSet optionSet;
- const string name ="TextTransform.exe";
-
- public static int Main (string[] args)
- {
- try {
- return MainInternal(args);
- }
- catch (Exception e) {
- Console.Error.WriteLine(e);
- return -1;
- }
- }
-
- private static int MainInternal (string[] args)
- {
- if (args.Length == 0) {
- ShowHelp (true);
- }
-
- var generator = new TemplateGenerator ();
- string outputFile = null, inputFile = null;
- var directives = new List<string> ();
- var parameters = new List<string> ();
- // var session = new Microsoft.VisualStudio.TextTemplating.TextTemplatingSession ();
- string preprocess = null;
-
- optionSet = new OptionSet () {
- { "o=|out=", "The name of the output {file}", s => outputFile = s },
- { "r=", "Assemblies to reference", s => generator.Refs.Add (s) },
- { "u=", "Namespaces to import <{0:namespace}>", s => generator.Imports.Add (s) },
- { "I=", "Paths to search for included files", s => generator.IncludePaths.Add (s) },
- { "P=", "Paths to search for referenced assemblies", s => generator.ReferencePaths.Add (s) },
- { "dp=", "Directive processor (name!class!assembly)", s => directives.Add (s) },
- { "a=", "Parameters (name=value) or ([processorName!][directiveName!]name!value)", s => parameters.Add (s) },
- { "h|?|help", "Show help", s => ShowHelp (false) },
- // { "k=,", "Session {key},{value} pairs", (s, t) => session.Add (s, t) },
- { "c=", "Preprocess the template into {0:class}", (s) => preprocess = s },
- };
-
- var remainingArgs = optionSet.Parse (args);
-
- if (remainingArgs.Count != 1) {
- Console.Error.WriteLine ("No input file specified.");
- return -1;
- }
- inputFile = remainingArgs [0];
-
- if (!File.Exists (inputFile)) {
- Console.Error.WriteLine ("Input file '{0}' does not exist.", inputFile);
- return -1;
- }
-
- if (string.IsNullOrEmpty (outputFile)) {
- outputFile = inputFile;
- if (Path.HasExtension (outputFile)) {
- var dir = Path.GetDirectoryName (outputFile);
- var fn = Path.GetFileNameWithoutExtension (outputFile);
- outputFile = Path.Combine (dir, fn + ".txt");
- } else {
- outputFile = outputFile + ".txt";
- }
- }
-
- foreach (var par in parameters) {
- if (!generator.TryAddParameter (par)) {
- Console.Error.WriteLine ("Parameter has incorrect format: {0}", par);
- return -1;
- }
- }
-
- foreach (var dir in directives) {
- var split = dir.Split ('!');
-
- if (split.Length != 3) {
- Console.Error.WriteLine ("Directive must have 3 values: {0}", dir);
- return -1;
- }
-
- for (int i = 0; i < 3; i++) {
- string s = split [i];
- if (string.IsNullOrEmpty (s)) {
- string kind = i == 0? "name" : (i == 1 ? "class" : "assembly");
- Console.Error.WriteLine ("Directive has missing {0} value: {1}", kind, dir);
- return -1;
- }
- }
-
- generator.AddDirectiveProcessor (split[0], split[1], split[2]);
- }
-
- if (preprocess == null) {
- generator.ProcessTemplate (inputFile, outputFile);
- if (generator.Errors.HasErrors) {
- Console.WriteLine ("Processing '{0}' failed.", inputFile);
- }
- } else {
- string className = preprocess;
- string classNamespace = null;
- int s = preprocess.LastIndexOf ('.');
- if (s > 0) {
- classNamespace = preprocess.Substring (0, s);
- className = preprocess.Substring (s + 1);
- }
-
- string language;
- string[] references;
- generator.PreprocessTemplate (inputFile, className, classNamespace, outputFile, System.Text.Encoding.UTF8,
- out language, out references);
- if (generator.Errors.HasErrors) {
- Console.Write ("Preprocessing '{0}' into class '{1}.{2}' failed.", inputFile, classNamespace, className);
- }
- }
-
- foreach (System.CodeDom.Compiler.CompilerError err in generator.Errors)
- Console.Error.WriteLine ("{0}({1},{2}): {3} {4}", err.FileName, err.Line, err.Column,
- err.IsWarning? "WARNING" : "ERROR", err.ErrorText);
-
- return generator.Errors.HasErrors? -1 : 0;
- }
-
- static void ShowHelp (bool concise)
- {
- Console.WriteLine ("TextTransform command line T4 processor");
- Console.WriteLine ("Usage: {0} [options] input-file", name);
- if (concise) {
- Console.WriteLine ("Use --help to display options.");
- } else {
- Console.WriteLine ("Options:");
- optionSet.WriteOptionDescriptions (System.Console.Out);
- }
- Console.WriteLine ();
- Environment.Exit (0);
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/TextTemplating/TextTransform/TextTransform.csproj b/main/src/addins/TextTemplating/TextTransform/TextTransform.csproj
deleted file mode 100644
index 4664b454d6..0000000000
--- a/main/src/addins/TextTemplating/TextTransform/TextTransform.csproj
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <Import Project="..\..\..\..\MonoDevelop.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{D1D35409-C814-47F6-B038-B9B5BF0FE490}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AssemblyName>TextTransform</AssemblyName>
- <RootNamespace>Mono.TextTemplating</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>True</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>False</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.TextTemplating</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Commandlineparameters>-o:out.txt in.tt</Commandlineparameters>
- <NoWarn>1591;1573</NoWarn>
- <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.TextTemplating\TextTransform.xml</DocumentationFile>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.TextTemplating</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <DebugSymbols>true</DebugSymbols>
- <NoWarn>1591;1573</NoWarn>
- <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.TextTemplating\TextTransform.xml</DocumentationFile>
- <Commandlineparameters>-o:out.txt in.tt</Commandlineparameters>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="TextTransform.cs" />
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="Options.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Mono.TextTemplating\Mono.TextTemplating.csproj">
- <Project>{A2364D6A-00EF-417C-80A6-815726C70032}</Project>
- <Name>Mono.TextTemplating</Name>
- <Private>False</Private>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project>
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs
index e3320c91d4..f72d11c971 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs
@@ -63,7 +63,9 @@ namespace MonoDevelop.Core.Assemblies
ComposedAssemblyContext composedAssemblyContext;
ITimeTracker timer;
TargetFramework[] customFrameworks = new TargetFramework[0];
-
+
+ static int internalIdCounter;
+
protected bool ShuttingDown { get; private set; }
public TargetRuntime ()
@@ -72,6 +74,8 @@ namespace MonoDevelop.Core.Assemblies
composedAssemblyContext = new ComposedAssemblyContext ();
composedAssemblyContext.Add (Runtime.SystemAssemblyService.UserAssemblyContext);
composedAssemblyContext.Add (assemblyContext);
+
+ InternalId = Interlocked.Increment (ref internalIdCounter);
Runtime.ShuttingDown += delegate {
ShuttingDown = true;
@@ -140,6 +144,12 @@ namespace MonoDevelop.Core.Assemblies
/// Returns 'true' if this runtime is the one currently running MonoDevelop.
/// </summary>
public abstract bool IsRunning { get; }
+
+ /// <summary>
+ /// Internal id, to be used at run time
+ /// </summary>
+ /// <value>The internal identifier.</value>
+ internal int InternalId { get; private set; }
public virtual IEnumerable<FilePath> GetReferenceFrameworkDirectories ()
{
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml
index d73721077a..e16355a7f8 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml
@@ -160,9 +160,13 @@
<ExtensionNode name="Item" customAttributeType="MonoDevelop.Projects.ExportProjectItemTypeAttribute" />
</ExtensionPoint>
+ <ExtensionPoint path = "/MonoDevelop/ProjectModel/MSBuildImportSearchPaths" name = "MSBuild project import search paths">
+ <Description>Allows defining fallback search paths for MSBuild project imports</Description>
+ <ExtensionNode name="SearchPath" type="MonoDevelop.Projects.Extensions.ImportSearchPathExtensionNode" />
+ </ExtensionPoint>
+
<!-- Extensions -->
-
<Extension path = "/MonoDevelop/Core/ExecutionModes">
<ModeSet id="Run" _name="Run" />
<ModeSet id="Debug" _name="Debug" />
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
index c4d30ce75c..d229375f99 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
@@ -698,6 +698,7 @@
</Compile>
<Compile Include="MonoDevelop.Projects.MSBuild\MSBuildEvent.cs" />
<Compile Include="MonoDevelop.Projects\MSBuildLogger.cs" />
+ <Compile Include="MonoDevelop.Projects.Extensions\ImportSearchPathExtensionNode.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbBreakpointsAndSteppingTests.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ImportSearchPathExtensionNode.cs
index 0b63c22913..7835f1cc35 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/SdbBreakpointsAndSteppingTests.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ImportSearchPathExtensionNode.cs
@@ -1,40 +1,51 @@
-//
-// SdbBreakpointsAndSteppingTests.cs
-//
-// Author:
-// David Karlaš <david.karlas@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
-//
-// 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.
-using System;
-using NUnit.Framework;
-
-namespace MonoDevelop.Debugger.Tests.Soft
-{
- [TestFixture]
- [Ignore("Sdb has many failings until resolved ignore all")]
- public class SdbBreakpointsAndSteppingTests: BreakpointsAndSteppingTests
- {
- public SdbBreakpointsAndSteppingTests () : base ("Mono.Debugger.Soft")
- {
- }
- }
-}
-
+//
+// ImportSearchPathExtensionNode.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@xamarin.com>
+//
+// Copyright (c) 2017 Xamarin, Inc (http://www.xamarin.com)
+//
+// 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.
+using System;
+using Mono.Addins;
+
+namespace MonoDevelop.Projects.Extensions
+{
+ class ImportSearchPathExtensionNode: ExtensionNode
+ {
+ [NodeAttribute ("path")]
+ string addinPath;
+
+ [NodeAttribute ("property")]
+ public string Property { get; set; }
+
+ string path;
+
+ public new string Path {
+ get {
+ return addinPath != null ? Addin.GetFilePath (addinPath) : path;
+ }
+ set {
+ path = value;
+ addinPath = null;
+ }
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild.Conditions/ConditionRelationalExpression.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild.Conditions/ConditionRelationalExpression.cs
index 68af394a26..03e0a4cec0 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild.Conditions/ConditionRelationalExpression.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild.Conditions/ConditionRelationalExpression.cs
@@ -148,33 +148,40 @@ namespace MonoDevelop.Projects.MSBuild.Conditions {
throw new NotSupportedException (String.Format ("Relational operator {0} is not supported.", op));
}
}
-
+
+ List<string> combinedProperty = null;
+ List<string> combinedValue = null;
+ bool combinedPropertySet;
+ object conditionPropertiesLock = new object ();
public override void CollectConditionProperties (ConditionedPropertyCollection properties)
{
- if ((op == RelationOperator.Equal || op == RelationOperator.NotEqual) && left is ConditionFactorExpression && right is ConditionFactorExpression) {
- var leftString = ((ConditionFactorExpression)left).Token.Value;
- var rightString = ((ConditionFactorExpression)right).Token.Value;
- List<string> combinedProperty = null;
- List<string> combinedValue = null;
-
- int il = 0;
- int rl = 0;
- while (il < leftString.Length && rl < rightString.Length) {
- if (il < leftString.Length - 2 && leftString [il] == '$' && leftString [il + 1] == '(')
- ReadPropertyCondition (leftString, ref combinedProperty, ref combinedValue, ref il, rightString, ref rl);
- else if (rl < rightString.Length - 2 && rightString [rl] == '$' && rightString [rl + 1] == '(')
- ReadPropertyCondition (rightString, ref combinedProperty, ref combinedValue, ref rl, leftString, ref il);
- else if (leftString [il] != rightString [rl])
- return; // Condition can't be true
- il++; rl++;
+ lock (conditionPropertiesLock) {
+ if (!combinedPropertySet) {
+ combinedPropertySet = true;
+ if ((op == RelationOperator.Equal || op == RelationOperator.NotEqual) && left is ConditionFactorExpression && right is ConditionFactorExpression) {
+ var leftString = ((ConditionFactorExpression)left).Token.Value;
+ var rightString = ((ConditionFactorExpression)right).Token.Value;
+
+ int il = 0;
+ int rl = 0;
+ while (il < leftString.Length && rl < rightString.Length) {
+ if (il < leftString.Length - 2 && leftString [il] == '$' && leftString [il + 1] == '(')
+ ReadPropertyCondition (leftString, ref combinedProperty, ref combinedValue, ref il, rightString, ref rl);
+ else if (rl < rightString.Length - 2 && rightString [rl] == '$' && rightString [rl + 1] == '(')
+ ReadPropertyCondition (rightString, ref combinedProperty, ref combinedValue, ref rl, leftString, ref il);
+ else if (leftString [il] != rightString [rl])
+ return; // Condition can't be true
+ il++; rl++;
+ }
+ }
}
-
- // This condition sets values for more that one property. In addition to the individual values, also register
- // the combination of values. So for example if the condition has "$(Configuration)|$(Platform) == Foo|Bar",
- // the conditioned property collection would contain Configuration=Foo, Platform=Bar, (Configuration|Platfrom)=Foo|Bar
- if (combinedProperty != null)
- properties.AddPropertyValues (combinedProperty, combinedValue);
}
+
+ // This condition sets values for more that one property. In addition to the individual values, also register
+ // the combination of values. So for example if the condition has "$(Configuration)|$(Platform) == Foo|Bar",
+ // the conditioned property collection would contain Configuration=Foo, Platform=Bar, (Configuration|Platfrom)=Foo|Bar
+ if (combinedProperty != null)
+ properties.AddPropertyValues (combinedProperty, combinedValue);
}
void ReadPropertyCondition (string propString, ref List<string> combinedProperty, ref List<string> combinedValue, ref int i, string valString, ref int j)
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs
index 06a70a189c..238c249d2c 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs
@@ -393,7 +393,7 @@ namespace MonoDevelop.Projects.MSBuild
project.EvaluatedItemsIgnoringCondition.RemoveAll (it => it.Name == item.Name && it.Include == include);
}
- static void AddItem (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item, MSBuildItemEvaluated it, string include, Regex excludeRegex, bool trueCond)
+ void AddItem (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item, MSBuildItemEvaluated it, string include, Regex excludeRegex, bool trueCond)
{
// Don't add the result from any item that has an empty include. MSBuild never returns those.
if (include == string.Empty)
@@ -435,7 +435,7 @@ namespace MonoDevelop.Projects.MSBuild
}
}
- static bool ExecuteTransform (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item, string transformExp, out List<MSBuildItemEvaluated> items)
+ bool ExecuteTransform (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item, string transformExp, out List<MSBuildItemEvaluated> items)
{
bool ignoreMetadata = false;
@@ -726,7 +726,7 @@ namespace MonoDevelop.Projects.MSBuild
return include.IndexOf ('*') != -1;
}
- static IEnumerable<MSBuildItemEvaluated> ExpandWildcardFilePath (ProjectInfo pinfo, MSBuildEvaluationContext context, MSBuildItem sourceItem, string path)
+ IEnumerable<MSBuildItemEvaluated> ExpandWildcardFilePath (ProjectInfo pinfo, MSBuildEvaluationContext context, MSBuildItem sourceItem, string path)
{
var subpath = SplitWildcardFilePath (path);
@@ -861,7 +861,7 @@ namespace MonoDevelop.Projects.MSBuild
return include.Length > 3 && include [0] == '@' && include [1] == '(' && include [include.Length - 1] == ')';
}
- static MSBuildItemEvaluated CreateEvaluatedItem (MSBuildEvaluationContext context, ProjectInfo pinfo, MSBuildProject project, MSBuildItem sourceItem, string include)
+ MSBuildItemEvaluated CreateEvaluatedItem (MSBuildEvaluationContext context, ProjectInfo pinfo, MSBuildProject project, MSBuildItem sourceItem, string include)
{
var it = new MSBuildItemEvaluated (project, sourceItem.Name, sourceItem.Include, include);
var md = new Dictionary<string,IMSBuildPropertyEvaluated> ();
@@ -952,43 +952,68 @@ namespace MonoDevelop.Projects.MSBuild
return;
}
- // For some reason, Mono can have several extension paths, so we need to try each of them
- foreach (var ep in MSBuildEvaluationContext.GetApplicableExtensionsPaths ()) {
- var files = GetImportFiles (project, context, import, ep);
- if (files == null || files.Length == 0)
- continue;
+
+ // Try importing the files using the import as is
+
+ bool keepSearching;
+
+ var files = GetImportFiles (project, context, import, null, null, out keepSearching);
+ if (files != null) {
foreach (var f in files)
ImportFile (project, context, import, f);
- return;
}
- // No import was found
+ // We may need to keep searching if the import was not found, or if the import had a wildcard.
+ // In that case, look in fallback search paths
+
+ if (keepSearching) {
+ foreach (var prop in context.GetProjectImportSearchPaths ()) {
+ if (import.Project.IndexOf ("$(" + prop.Property + ")", StringComparison.OrdinalIgnoreCase) == -1)
+ continue;
+ files = GetImportFiles (project, context, import, prop.Property, prop.Path, out keepSearching);
+ if (files != null) {
+ foreach (var f in files)
+ ImportFile (project, context, import, f);
+ }
+ if (!keepSearching)
+ break;
+ }
+ }
}
- string[] GetImportFiles (ProjectInfo project, MSBuildEvaluationContext context, MSBuildImport import, string extensionsPath)
+ string[] GetImportFiles (ProjectInfo project, MSBuildEvaluationContext context, MSBuildImport import, string pathProperty, string pathPropertyValue, out bool keepSearching)
{
- if (extensionsPath != null) {
+ // This methods looks for targets in location specified by the import, and replacing pathProperty by a specific value.
+
+ if (pathPropertyValue != null) {
var tempCtx = new MSBuildEvaluationContext (context);
- var mep = MSBuildProjectService.ToMSBuildPath (null, extensionsPath);
- tempCtx.SetPropertyValue ("MSBuildExtensionsPath", mep);
- tempCtx.SetPropertyValue ("MSBuildExtensionsPath32", mep);
- tempCtx.SetPropertyValue ("MSBuildExtensionsPath64", mep);
+ var mep = MSBuildProjectService.ToMSBuildPath (null, pathPropertyValue);
+ tempCtx.SetContextualPropertyValue (pathProperty, mep);
context = tempCtx;
}
var pr = context.EvaluateString (import.Project);
project.Imports [import] = pr;
- if (!string.IsNullOrEmpty (import.Condition) && !SafeParseAndEvaluate (project, context, import.Condition, true))
+ if (!string.IsNullOrEmpty (import.Condition) && !SafeParseAndEvaluate (project, context, import.Condition, true)) {
+ // Condition evaluates to false. Keep searching because maybe another value for the path property makes
+ // the condition evaluate to true.
+ keepSearching = true;
return null;
+ }
var path = MSBuildProjectService.FromMSBuildPath (project.Project.BaseDirectory, pr);
var fileName = Path.GetFileName (path);
if (fileName.IndexOfAny (new [] { '*', '?' }) == -1) {
- return File.Exists (path) ? new [] { path } : null;
+ // Not a wildcard. Keep searching if the file doesn't exist.
+ var result = File.Exists (path) ? new [] { path } : null;
+ keepSearching = result == null;
+ return result;
}
else {
+ // Wildcard import. Always keep searching since we want to import all files that match from all search paths.
+ keepSearching = true;
path = Path.GetDirectoryName (path);
if (!Directory.Exists (path))
return null;
@@ -1045,14 +1070,21 @@ namespace MonoDevelop.Projects.MSBuild
project.Targets.Add (newTarget);
}
- static bool SafeParseAndEvaluate (ProjectInfo project, MSBuildEvaluationContext context, string condition, bool collectConditionedProperties = false)
+ Dictionary<string, ConditionExpression> conditionCache = new Dictionary<string, ConditionExpression> ();
+ bool SafeParseAndEvaluate (ProjectInfo project, MSBuildEvaluationContext context, string condition, bool collectConditionedProperties = false)
{
try {
if (String.IsNullOrEmpty (condition))
return true;
try {
- ConditionExpression ce = ConditionParser.ParseCondition (condition);
+ ConditionExpression ce;
+ lock (conditionCache) {
+ if (conditionCache == null || !conditionCache.TryGetValue (condition, out ce))
+ ce = ConditionParser.ParseCondition (condition);
+ if (conditionCache != null)
+ conditionCache [condition] = ce;
+ }
if (!ce.CanEvaluateToBool (context))
throw new InvalidProjectFileException (String.Format ("Can not evaluate \"{0}\" to bool.", condition));
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
index 09f18664f3..af944f57e7 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
@@ -39,6 +39,7 @@ using MonoDevelop.Projects.MSBuild.Conditions;
using System.Globalization;
using Microsoft.Build.Evaluation;
using System.Web.UI.WebControls;
+using MonoDevelop.Projects.Extensions;
namespace MonoDevelop.Projects.MSBuild
{
@@ -48,6 +49,8 @@ namespace MonoDevelop.Projects.MSBuild
static Dictionary<string, string> envVars = new Dictionary<string, string> ();
HashSet<string> propertiesWithTransforms = new HashSet<string> ();
List<string> propertiesWithTransformsSorted = new List<string> ();
+ List<ImportSearchPathExtensionNode> searchPaths;
+
public Dictionary<string, bool> ExistsEvaluationCache { get; } = new Dictionary<string, bool> ();
bool allResolved;
@@ -106,7 +109,7 @@ namespace MonoDevelop.Projects.MSBuild
string toolsVersion = "15.0";
properties.Add ("MSBuildAssemblyVersion", "15.0");
- var toolsPath = Runtime.SystemAssemblyService.DefaultRuntime.GetMSBuildToolsPath (toolsVersion);
+ var toolsPath = (project.TargetRuntime ?? Runtime.SystemAssemblyService.DefaultRuntime).GetMSBuildToolsPath (toolsVersion);
var frameworkToolsPath = ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.VersionLatest);
@@ -168,8 +171,8 @@ namespace MonoDevelop.Projects.MSBuild
extensionsPath = extensionsPath32;
properties.Add ("MSBuildExtensionsPath", extensionsPath);
}
- else if (!String.IsNullOrEmpty (DefaultExtensionsPath)) {
- var ep = MSBuildProjectService.ToMSBuildPath (null, extensionsPath);
+ else {
+ var ep = MSBuildProjectService.ToMSBuildPath (null, project.TargetRuntime.GetMSBuildExtensionsPath ());
properties.Add ("MSBuildExtensionsPath", ep);
properties.Add ("MSBuildExtensionsPath32", ep);
properties.Add ("MSBuildExtensionsPath64", ep);
@@ -178,52 +181,34 @@ namespace MonoDevelop.Projects.MSBuild
// Environment
properties.Add ("MSBuildProgramFiles32", MSBuildProjectService.ToMSBuildPath (null, Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86)));
- }
- }
-
- public MSBuildProject Project {
- get { return project; }
- }
- static string extensionsPath;
+ // Search paths
- internal static string DefaultExtensionsPath {
- get {
- if (extensionsPath == null) {
- var path = Environment.GetEnvironmentVariable ("MSBuildExtensionsPath");
- if (path != null && !IsExternalMSBuildExtensionsPath (path))
- extensionsPath = path;
- }
+ searchPaths = MSBuildProjectService.GetProjectImportSearchPaths (project.TargetRuntime, true).ToList ();
- if (extensionsPath == null) {
- // NOTE: code from mcs/tools/gacutil/driver.cs
- PropertyInfo gac = typeof (System.Environment).GetProperty (
- "GacPath", BindingFlags.Static | BindingFlags.NonPublic);
+ // Custom override of MSBuildExtensionsPath using an env var
- if (gac != null) {
- MethodInfo get_gac = gac.GetGetMethod (true);
- string gac_path = (string) get_gac.Invoke (null, null);
- extensionsPath = Path.GetFullPath (Path.Combine (
- gac_path, Path.Combine ("..", "xbuild")));
- }
+ var customExtensionsPath = Environment.GetEnvironmentVariable ("MSBuildExtensionsPath");
+ if (!string.IsNullOrEmpty (customExtensionsPath)) {
+ if (IsExternalMSBuildExtensionsPath (customExtensionsPath))
+ // This is actually an override of the mono extensions path. Don't replace the default MSBuildExtensionsPath value since
+ // core targets still need to be loaded from there.
+ searchPaths.Insert (0, new ImportSearchPathExtensionNode { Property = "MSBuildExtensionsPath", Path = customExtensionsPath });
+ else
+ properties ["MSBuildExtensionsPath"] = MSBuildProjectService.ToMSBuildPath (null, customExtensionsPath);
}
- return extensionsPath;
}
}
- static string macOSXExternalXBuildDir;
+ public MSBuildProject Project {
+ get { return project; }
+ }
- static string DefaultMacOSXExternalXBuildDir {
- get {
- if (macOSXExternalXBuildDir == null) {
- var path = Environment.GetEnvironmentVariable ("MSBuildExtensionsPath");
- if (path != null && IsExternalMSBuildExtensionsPath (path))
- macOSXExternalXBuildDir = path;
- else
- macOSXExternalXBuildDir = MacOSXExternalXBuildDir;
- }
- return macOSXExternalXBuildDir;
- }
+ public IEnumerable<ImportSearchPathExtensionNode> GetProjectImportSearchPaths ()
+ {
+ if (parentContext != null)
+ return parentContext.GetProjectImportSearchPaths ();
+ return searchPaths;
}
static bool IsExternalMSBuildExtensionsPath (string path)
@@ -245,20 +230,6 @@ namespace MonoDevelop.Projects.MSBuild
return Platform.IsMac && path.Contains ("Mono.framework/External/xbuild");
}
- static string DotConfigExtensionsPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), Path.Combine ("xbuild", "tasks"));
- const string MacOSXExternalXBuildDir = "/Library/Frameworks/Mono.framework/External/xbuild";
-
- internal static IEnumerable<string> GetApplicableExtensionsPaths ()
- {
- // On windows there is a single extension path, which is already properly defined in the engine
- if (Platform.IsWindows)
- yield return null;
- if (Platform.IsMac)
- yield return DefaultMacOSXExternalXBuildDir;
- yield return DotConfigExtensionsPath;
- yield return DefaultExtensionsPath;
- }
-
internal void SetItemContext (string itemFile, string recursiveDir, IMSBuildPropertyGroupEvaluated metadata = null)
{
this.itemFile = itemFile;
@@ -356,6 +327,12 @@ namespace MonoDevelop.Projects.MSBuild
properties [name] = value;
}
+ public void SetContextualPropertyValue (string name, string value)
+ {
+ // Sets a properly value only for the scope of this context, not for the scope of the global evaluation operation
+ properties [name] = value;
+ }
+
public void ClearPropertyValue (string name)
{
properties.Remove (name);
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs
index 8f32357801..f049052694 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs
@@ -36,6 +36,7 @@ using MonoDevelop.Projects.Utility;
using System.Linq;
using MonoDevelop.Projects.Text;
using System.Threading.Tasks;
+using MonoDevelop.Core.Assemblies;
namespace MonoDevelop.Projects.MSBuild
{
@@ -190,6 +191,8 @@ namespace MonoDevelop.Projects.MSBuild
}
}
+ public TargetRuntime TargetRuntime { get; set; } = Runtime.SystemAssemblyService.DefaultRuntime;
+
public static Task<MSBuildProject> LoadAsync (string file)
{
return Task<MSBuildProject>.Factory.StartNew (delegate {
@@ -815,8 +818,9 @@ namespace MonoDevelop.Projects.MSBuild
if (group != null)
return group.AddNewItem (name, include, beforeItem);
}
- MSBuildItemGroup grp = FindBestGroupForItem (name);
- return grp.AddNewItem (name, include);
+ MSBuildItem it = CreateItem (name, include);
+ AddItem (it);
+ return it;
}
public MSBuildItem CreateItem (string name, string include)
@@ -843,34 +847,65 @@ namespace MonoDevelop.Projects.MSBuild
return;
}
}
- MSBuildItemGroup grp = FindBestGroupForItem (it.Name);
+ MSBuildItemGroup grp = FindBestGroupForItem (it);
grp.AddItem (it);
}
- MSBuildItemGroup FindBestGroupForItem (string itemName)
+ MSBuildItemGroup FindBestGroupForItem (MSBuildItem newItem)
{
+ string groupId = GetBestGroupId (newItem);
MSBuildItemGroup group;
if (bestGroups == null)
bestGroups = new Dictionary<string, MSBuildItemGroup> ();
else {
- if (bestGroups.TryGetValue (itemName, out group))
+ if (bestGroups.TryGetValue (groupId, out group))
return group;
}
+ MSBuildItemGroup insertBefore = null;
foreach (MSBuildItemGroup grp in ItemGroups) {
foreach (MSBuildItem it in grp.Items) {
- if (it.Name == itemName) {
- bestGroups [itemName] = grp;
+ if (ShouldAddItemToGroup (it, newItem)) {
+ bestGroups [groupId] = grp;
return grp;
+ } else if (insertBefore == null && ShouldInsertItemGroupBefore (it, newItem)) {
+ insertBefore = grp;
}
}
}
- group = AddNewItemGroup ();
- bestGroups [itemName] = group;
+ group = AddNewItemGroup (insertBefore);
+ bestGroups [groupId] = group;
return group;
}
+ static string GetBestGroupId (MSBuildItem it)
+ {
+ if (it.IsRemove)
+ return it.Name + ":Remove";
+ else if (it.IsUpdate)
+ return it.Name + ":Update";
+ return it.Name;
+ }
+
+ static bool ShouldAddItemToGroup (MSBuildItem existingItem, MSBuildItem newItem)
+ {
+ return existingItem.Name == newItem.Name &&
+ existingItem.IsRemove == newItem.IsRemove &&
+ existingItem.IsUpdate == newItem.IsUpdate;
+ }
+
+ static bool ShouldInsertItemGroupBefore (MSBuildItem existing, MSBuildItem newItem)
+ {
+ if (existing.Name != newItem.Name)
+ return false;
+ if (newItem.IsInclusion)
+ return existing.IsUpdate;
+ if (newItem.IsRemove)
+ return existing.IsUpdate || (existing.IsInclusion && !existing.IsWildcardItem);
+ return false;
+ }
+
public XmlElement GetProjectExtension (string section)
{
var ext = (MSBuildProjectExtensions)ChildNodes.FirstOrDefault (ob => ob is MSBuildProjectExtensions);
@@ -888,6 +923,17 @@ namespace MonoDevelop.Projects.MSBuild
return null;
}
+ /// <summary>
+ /// Returns a list of SDKs referenced by this project
+ /// </summary>
+ public string[] GetReferencedSDKs ()
+ {
+ if (!string.IsNullOrEmpty (Sdk))
+ return Sdk.Split (new [] { ';' }, StringSplitOptions.RemoveEmptyEntries);
+ else
+ return new string [0];
+ }
+
XmlNamespaceManager GetNamespaceManagerForProject ()
{
if (Namespace == Schema)
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs
index 374eebd5df..5b45cb2ddf 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs
@@ -44,6 +44,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using MonoDevelop.Core.Execution;
+using System.Xml.Linq;
namespace MonoDevelop.Projects.MSBuild
{
@@ -54,6 +55,7 @@ namespace MonoDevelop.Projects.MSBuild
internal const string GlobalPropertyProvidersExtensionPath = "/MonoDevelop/ProjectModel/MSBuildGlobalPropertyProviders";
internal const string UnknownMSBuildProjectTypesExtensionPath = "/MonoDevelop/ProjectModel/UnknownMSBuildProjectTypes";
internal const string MSBuildProjectItemTypesPath = "/MonoDevelop/ProjectModel/MSBuildProjectItemTypes";
+ internal const string MSBuildImportSearchPathsPath = "/MonoDevelop/ProjectModel/MSBuildImportSearchPaths";
public const string GenericItemGuid = "{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}";
public const string FolderTypeGuid = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}";
@@ -71,6 +73,10 @@ namespace MonoDevelop.Projects.MSBuild
static UnknownProjectTypeNode[] unknownProjectTypeNodes;
static IDictionary<string,TypeExtensionNode> projecItemTypeNodes;
+ static Dictionary<TargetRuntime, List<ImportSearchPathExtensionNode>> defaultImportSearchPaths = new Dictionary<TargetRuntime, List<ImportSearchPathExtensionNode>> ();
+ static List<ImportSearchPathExtensionNode> importSearchPaths = new List<ImportSearchPathExtensionNode> ();
+ static bool searchPathConfigNeedsUpdate;
+
static AsyncCriticalSection buildersLock = new AsyncCriticalSection ();
@@ -109,6 +115,8 @@ namespace MonoDevelop.Projects.MSBuild
specialCharactersEscaped [specialCharacters [i]] = '%' + escaped;
specialCharactersUnescaped [escaped] = specialCharacters [i];
}
+
+ CleanCachedMSBuildExes ();
}
static void OnExtensionChanged (object sender, ExtensionEventArgs args)
@@ -119,6 +127,13 @@ namespace MonoDevelop.Projects.MSBuild
args.Path == GlobalPropertyProvidersExtensionPath ||
args.Path == MSBuildProjectItemTypesPath)
LoadExtensionData ();
+
+ if (args.Path == MSBuildImportSearchPathsPath) {
+ searchPathConfigNeedsUpdate = true;
+
+ // Reload all builders since search paths have changed
+ RecycleAllBuilders ().Ignore ();
+ }
}
static void LoadExtensionData ()
@@ -165,6 +180,103 @@ namespace MonoDevelop.Projects.MSBuild
customProjectItemTypes.Remove (name);
}
+ /// <summary>
+ /// Registers a custom project import search path. This path will be used as a fallback when evaluating
+ /// an import and targets file is not found using the value assigned by MSBuild to the property.
+ /// </summary>
+ /// <param name="propertyName">Name of the property for which to add a fallback path</param>
+ /// <param name="path">The fallback path</param>
+ public static void RegisterProjectImportSearchPath (string propertyName, FilePath path)
+ {
+ if (!importSearchPaths.Any (sp => sp.Property == propertyName && sp.Path == path)) {
+ importSearchPaths.Add (new ImportSearchPathExtensionNode { Property = propertyName, Path = path });
+ searchPathConfigNeedsUpdate = true;
+ RecycleAllBuilders ().Ignore ();
+ }
+ }
+
+ /// <summary>
+ /// Unregisters a previously registered import search path
+ /// </summary>
+ /// <param name="propertyName">Name of the property for which a fallback path was added.</param>
+ /// <param name="path">The fallback path to remove</param>
+ public static void UnregisterProjectImportSearchPath (string propertyName, FilePath path)
+ {
+ importSearchPaths.RemoveAll (i => i.Property == propertyName && i.Path == path);
+ searchPathConfigNeedsUpdate = true;
+ RecycleAllBuilders ().Ignore ();
+ }
+
+ /// <summary>
+ /// Gets a list of all search paths assigned to properties
+ /// </summary>
+ /// <returns>The search paths</returns>
+ /// <param name="runtime">Runtime for which to get the search paths.</param>
+ /// <param name="includeImplicitImports">If set to <c>true</c>, it returns all search paths, including those registered by
+ /// MSBuild and those registered using RegisterProjectImportSearchPath. If <c>false</c>, it only returns the paths
+ /// registered by RegisterProjectImportSearchPath.</param>
+ internal static IEnumerable<ImportSearchPathExtensionNode> GetProjectImportSearchPaths (TargetRuntime runtime, bool includeImplicitImports)
+ {
+ var result = AddinManager.GetExtensionNodes<ImportSearchPathExtensionNode> (MSBuildImportSearchPathsPath).Concat (importSearchPaths);
+ if (includeImplicitImports)
+ result = LoadDefaultProjectImportSearchPaths (runtime).Concat (result);
+ return result;
+ }
+
+ /// <summary>
+ /// Finds an SDKs path that contains the specified SDK.
+ /// </summary>
+ internal static string FindSdkPath (TargetRuntime runtime, string[] sdks)
+ {
+ string binDir;
+ GetNewestInstalledToolsVersion (runtime, true, out binDir);
+
+ // Look for SDKs in the default SDKs path first, and then in the fallback paths
+ var defaultSdksPath = Path.Combine (binDir, "Sdks");
+ var allPaths = Enumerable.Repeat (defaultSdksPath, 1).Concat (GetProjectImportSearchPaths (runtime, true).Where (n => n.Property == "MSBuildSDKsPath").Select (sp => sp.Path));
+
+ foreach (var path in allPaths) {
+ // We need to find a path that contains all required SDKs, since we can only read SDKs from one place for a project.
+ if (sdks.All (sdk => Directory.Exists (Path.Combine (path, sdk))))
+ return path;
+ }
+ return null;
+ }
+
+ static List<ImportSearchPathExtensionNode> LoadDefaultProjectImportSearchPaths (TargetRuntime runtime)
+ {
+ // Load the default search paths defined in MSBuild.dll.config
+
+ lock (defaultImportSearchPaths) {
+ List<ImportSearchPathExtensionNode> list;
+ if (defaultImportSearchPaths.TryGetValue (runtime, out list))
+ return list;
+
+ list = new List<ImportSearchPathExtensionNode> ();
+ defaultImportSearchPaths [runtime] = list;
+
+ string binDir;
+ GetNewestInstalledToolsVersion (runtime, true, out binDir);
+
+ var configFile = Path.Combine (binDir, "MSBuild.dll.config");
+ if (File.Exists (configFile)) {
+ var doc = XDocument.Load (configFile);
+ var projectImportSearchPaths = doc.Root.Elements ("msbuildToolsets").FirstOrDefault ()?.Elements ("toolset")?.FirstOrDefault ()?.Element ("projectImportSearchPaths");
+ if (projectImportSearchPaths != null) {
+ var os = Platform.IsMac ? "osx" : Platform.IsWindows ? "windows" : "unix";
+ foreach (var searchPaths in projectImportSearchPaths.Elements ("searchPaths")) {
+ var pathOs = (string)searchPaths.Attribute ("os")?.Value;
+ if (!string.IsNullOrEmpty (pathOs) && pathOs != os)
+ continue;
+ foreach (var property in searchPaths.Elements ("property"))
+ list.Add (new ImportSearchPathExtensionNode { Property = property.Attribute ("name").Value, Path = property.Attribute ("value").Value });
+ }
+ }
+ }
+ return list;
+ }
+ }
+
static async void HandleGlobalPropertyProviderChanged (object sender, EventArgs e)
{
using (await buildersLock.EnterAsync ()) {
@@ -929,7 +1041,24 @@ namespace MonoDevelop.Projects.MSBuild
throw new Exception ("Did not find MSBuild for runtime " + runtime.Id);
}
- internal static async Task<RemoteProjectBuilder> GetProjectBuilder (TargetRuntime runtime, string minToolsVersion, string file, string solutionFile, int customId, bool requiresMicrosoftBuild, bool lockBuilder = false)
+ /// <summary>
+ /// Forces the reload of all project builders
+ /// </summary>
+ /// <remarks>
+ /// This method can be used to discard all currently active project builders, and force the creation
+ /// of new ones. This method is useful when there is a change in the MSBuild options or environment
+ /// that has an effect on all builders. If a builder is running a task, it will be discarded when
+ /// the task ends.
+ /// </remarks>
+ public static async Task RecycleAllBuilders ()
+ {
+ using (await buildersLock.EnterAsync ()) {
+ foreach (var b in builders.GetAllBuilders ())
+ b.Shutdown ();
+ }
+ }
+
+ internal static async Task<RemoteProjectBuilder> GetProjectBuilder (TargetRuntime runtime, string minToolsVersion, string file, string solutionFile, string sdksPath, int customId, bool requiresMicrosoftBuild, bool lockBuilder = false)
{
Version mtv = Version.Parse (minToolsVersion);
if (mtv >= new Version (15,0))
@@ -955,6 +1084,8 @@ namespace MonoDevelop.Projects.MSBuild
if (lockBuilder) {
foreach (var b in builders.GetBuilders (builderKey)) {
+ if (b.IsShuttingDown)
+ continue;
if (b.Lock ()) {
builder = b;
break;
@@ -962,13 +1093,11 @@ namespace MonoDevelop.Projects.MSBuild
b.Unlock ();
}
} else
- builder = builders.GetBuilders (builderKey).FirstOrDefault ();
+ builder = builders.GetBuilders (builderKey).FirstOrDefault (b => !b.IsShuttingDown);
if (builder != null) {
builder.ReferenceCount++;
- var pb = new RemoteProjectBuilder (file, builder);
- await pb.Load ();
- return pb;
+ return await builder.CreateRemoteProjectBuilder (file, sdksPath).ConfigureAwait (false);
}
return await Task.Run (async () => {
@@ -1015,9 +1144,7 @@ namespace MonoDevelop.Projects.MSBuild
};
if (lockBuilder)
builder.Lock ();
- var pb = new RemoteProjectBuilder (file, builder);
- await pb.Load ().ConfigureAwait (false);
- return pb;
+ return await builder.CreateRemoteProjectBuilder (file, sdksPath).ConfigureAwait (false);
});
}
}
@@ -1044,9 +1171,33 @@ namespace MonoDevelop.Projects.MSBuild
return dictionary;;
}
-
+
+#region MSBuild exe file location
+
+ /// <summary>
+ /// Gets the project builder exe to be used to for a specific runtime and tools version
+ /// </summary>
static string GetExeLocation (TargetRuntime runtime, string toolsVersion, bool requiresMicrosoftBuild)
{
+ // If the builder for the latest MSBuild tools is being requested, return a local copy of the exe.
+ // That local copy is configured to add additional msbuild search paths defined by add-ins.
+
+ var mainExe = GetMSBuildExeLocationInBundle (runtime);
+ var exe = GetExeLocationInBundle (runtime, toolsVersion, requiresMicrosoftBuild);
+ if (exe == mainExe)
+ return GetLocalMSBuildExeLocation (runtime);
+ return exe;
+ }
+
+ static string GetMSBuildExeLocationInBundle (TargetRuntime runtime)
+ {
+ return GetExeLocationInBundle (runtime, "15.0", true);
+ }
+
+ static string GetExeLocationInBundle (TargetRuntime runtime, string toolsVersion, bool requiresMicrosoftBuild)
+ {
+ // Locate the project builder exe in the MD directory
+
var builderDir = new FilePath (typeof(MSBuildProjectService).Assembly.Location).ParentDirectory.Combine ("MSBuild");
var version = Version.Parse (toolsVersion);
@@ -1066,6 +1217,136 @@ namespace MonoDevelop.Projects.MSBuild
throw new InvalidOperationException ("Unsupported MSBuild ToolsVersion '" + version + "'");
}
+ static string GetLocalMSBuildExeLocation (TargetRuntime runtime)
+ {
+ // Gets a path to the local copy of the project builder for the provided runtime.
+ // If no local copy exists, create one.
+
+ // Builders are copied to a folder inside the cache folder. This folder is cleaned
+ // every time XS is started, removing unused builders. The process id is used
+ // as folder name, so it is easy to check if the folder is currently in use or not.
+
+ var dirId = Process.GetCurrentProcess ().Id.ToString () + "_" + runtime.InternalId;
+ var exesDir = UserProfile.Current.CacheDir.Combine ("MSBuild").Combine (dirId);
+
+ if (!Directory.Exists (exesDir)) {
+ // Copy the builder to the local dir, including the debug file and config file.
+ Directory.CreateDirectory (exesDir);
+ var exe = GetMSBuildExeLocationInBundle (runtime);
+ File.Copy (exe, exesDir.Combine (Path.GetFileName (exe)));
+ var exeMdb = exe + ".mdb";
+ if (File.Exists (exeMdb))
+ File.Copy (exeMdb, exesDir.Combine (Path.GetFileName (exeMdb)));
+ var exePdb = Path.ChangeExtension (exe, ".pdb");
+ if (File.Exists (exePdb))
+ File.Copy (exePdb, exesDir.Combine (Path.GetFileName (exePdb)));
+ var exeConfig = exe + ".config";
+ if (File.Exists (exeConfig))
+ File.Copy (exeConfig, exesDir.Combine (Path.GetFileName (exeConfig + ".original")));
+
+ searchPathConfigNeedsUpdate = true;
+ }
+
+ if (searchPathConfigNeedsUpdate) {
+ // There is already a local copy of the builder, but the config file needs to be updated.
+ searchPathConfigNeedsUpdate = false;
+ UpdateMSBuildExeConfigFile (runtime);
+ }
+ return exesDir.Combine ("MonoDevelop.Projects.Formats.MSBuild.exe");
+ }
+
+ static void UpdateMSBuildExeConfigFile (TargetRuntime runtime)
+ {
+ // Creates an MSBuild config file with the search paths registered by add-ins.
+
+ foreach (var configFile in Directory.GetFiles (Path.GetDirectoryName (GetLocalMSBuildExeLocation (runtime)), "*.config.original")) {
+
+ var localConfigFile = configFile.Substring (0, configFile.Length - 9);
+
+ var doc = XDocument.Load (configFile);
+ var toolset = doc.Root.Elements ("msbuildToolsets").FirstOrDefault ()?.Elements ("toolset")?.FirstOrDefault ();
+
+ if (toolset != null) {
+
+ string binDir;
+ GetNewestInstalledToolsVersion (runtime, true, out binDir);
+
+ // This is required for MSBuild to properly load the searchPaths element (@radical knows why)
+ SetMSBuildConfigProperty (toolset, "MSBuildBinPath", binDir, false, true);
+
+ var projectImportSearchPaths = doc.Root.Elements ("msbuildToolsets").FirstOrDefault ()?.Elements ("toolset")?.FirstOrDefault ()?.Element ("projectImportSearchPaths");
+ if (projectImportSearchPaths != null) {
+ var os = Platform.IsMac ? "osx" : Platform.IsWindows ? "windows" : "unix";
+ XElement searchPaths = projectImportSearchPaths.Elements ("searchPaths").FirstOrDefault (sp => sp.Attribute ("os")?.Value == os);
+ if (searchPaths == null) {
+ searchPaths = new XElement ("searchPaths");
+ searchPaths.SetAttributeValue ("os", os);
+ projectImportSearchPaths.Add (searchPaths);
+ }
+ foreach (var path in GetProjectImportSearchPaths (runtime, false))
+ SetMSBuildConfigProperty (searchPaths, path.Property, path.Path, true, false);
+ }
+ doc.Save (localConfigFile);
+ }
+ }
+ }
+
+ static void SetMSBuildConfigProperty (XElement elem, string name, string value, bool append, bool insertBefore)
+ {
+ var prop = elem.Elements ("property").FirstOrDefault (p => p.Attribute ("name")?.Value == name);
+ if (prop != null) {
+ var val = prop.Attribute ("value")?.Value;
+ if (append)
+ prop.SetAttributeValue ("value", val + ";" + value);
+ else
+ prop.SetAttributeValue ("value", value);
+ } else {
+ prop = new XElement ("property");
+ prop.SetAttributeValue ("name", name);
+ prop.SetAttributeValue ("value", value);
+ if (insertBefore)
+ elem.AddFirst (prop);
+ else
+ elem.Add (prop);
+ }
+ }
+
+ static void CleanCachedMSBuildExes ()
+ {
+ // Removes local copies of project builders that are not currently being used.
+
+ var exesDir = UserProfile.Current.CacheDir.Combine ("MSBuild");
+ if (!Directory.Exists (exesDir))
+ return;
+
+ foreach (var dir in Directory.GetDirectories (exesDir)) {
+ // The file name has to parts: <process-id>_<runtime-id>
+ var spid = Path.GetFileName (dir);
+ int i = spid.IndexOf ('_');
+ if (i == -1)
+ continue;
+ spid = spid.Substring (0, i);
+ int pid;
+ if (int.TryParse (Path.GetFileName (spid), out pid)) {
+ try {
+ // If there is a process running with this id it means the builder is still being used
+ if (Process.GetProcessById (pid) != null)
+ continue;
+ } catch {
+ // Ignore
+ }
+ // No process for this id, it should be safe to delete the folder
+ try {
+ Directory.Delete (dir, true);
+ } catch (Exception ex) {
+ LoggingService.LogError ("Could not delete MSBuild cache folder", ex);
+ }
+ }
+ }
+ }
+
+#endregion
+
internal static async void ReleaseProjectBuilder (RemoteBuildEngine engine)
{
using (await buildersLock.EnterAsync ().ConfigureAwait (false)) {
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/RemoteProjectBuilder.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/RemoteProjectBuilder.cs
index 891c15fd21..36ea07c8d5 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/RemoteProjectBuilder.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/RemoteProjectBuilder.cs
@@ -51,6 +51,8 @@ namespace MonoDevelop.Projects.MSBuild
public int ReferenceCount { get; set; }
public DateTime ReleaseTime { get; set; }
+ List<RemoteProjectBuilder> remoteProjectBuilders = new List<RemoteProjectBuilder> ();
+
public RemoteBuildEngine (RemoteProcessConnection connection)
{
this.connection = connection;
@@ -66,10 +68,24 @@ namespace MonoDevelop.Projects.MSBuild
}
}
- public async Task<ProjectBuilder> LoadProject (string projectFile)
+ public async Task<RemoteProjectBuilder> CreateRemoteProjectBuilder (string projectFile, string sdksPath)
+ {
+ var builder = await LoadProject (projectFile, sdksPath).ConfigureAwait (false);
+ var pb = new RemoteProjectBuilder (projectFile, builder, this);
+ lock (remoteProjectBuilders) {
+ remoteProjectBuilders.Add (pb);
+
+ // Unlikely, but it may happen
+ if (IsShuttingDown)
+ pb.Shutdown ();
+ }
+ return pb;
+ }
+
+ async Task<ProjectBuilder> LoadProject (string projectFile, string sdksPath)
{
try {
- var pid = (await connection.SendMessage (new LoadProjectRequest { ProjectFile = projectFile})).ProjectId;
+ var pid = (await connection.SendMessage (new LoadProjectRequest { ProjectFile = projectFile, SDKsPath = sdksPath })).ProjectId;
return new ProjectBuilder (connection, pid);
} catch {
await CheckDisconnected ();
@@ -77,8 +93,11 @@ namespace MonoDevelop.Projects.MSBuild
}
}
- public async Task UnloadProject (ProjectBuilder builder)
+ internal async Task UnloadProject (RemoteProjectBuilder remoteBuilder, ProjectBuilder builder)
{
+ lock (remoteProjectBuilders)
+ remoteProjectBuilders.Remove (remoteBuilder);
+
try {
await connection.SendMessage (new UnloadProjectRequest { ProjectId = ((ProjectBuilder)builder).ProjectId});
} catch (Exception ex) {
@@ -88,6 +107,22 @@ namespace MonoDevelop.Projects.MSBuild
}
}
+ /// <summary>
+ /// Marks this instance as being shutdown, so it should not be used to create new project builders.
+ /// </summary>
+ public void Shutdown ()
+ {
+ lock (remoteProjectBuilders) {
+ if (IsShuttingDown)
+ return;
+ IsShuttingDown = true;
+ foreach (var pb in remoteProjectBuilders)
+ pb.Shutdown ();
+ }
+ }
+
+ public bool IsShuttingDown { get; private set; }
+
public async Task CancelTask (int taskId)
{
try {
@@ -263,19 +298,15 @@ namespace MonoDevelop.Projects.MSBuild
string file;
static int lastTaskId;
- internal RemoteProjectBuilder (string file, RemoteBuildEngine engine)
+ internal RemoteProjectBuilder (string file, ProjectBuilder builder, RemoteBuildEngine engine)
{
this.file = file;
this.engine = engine;
+ this.builder = builder;
referenceCache = new Dictionary<string, AssemblyReference[]> ();
packageDependenciesCache = new Dictionary<string, PackageDependency[]> ();
}
- internal async Task Load ()
- {
- builder = await engine.LoadProject (file).ConfigureAwait (false);
- }
-
public event EventHandler Disconnected;
async Task CheckDisconnected ()
@@ -474,7 +505,7 @@ namespace MonoDevelop.Projects.MSBuild
if (!MSBuildProjectService.ShutDown && engine != null) {
try {
if (builder != null)
- await engine.UnloadProject (builder).ConfigureAwait (false);
+ await engine.UnloadProject (this, builder).ConfigureAwait (false);
MSBuildProjectService.ReleaseProjectBuilder (engine);
} catch {
// Ignore
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
index 840d502296..be14669e94 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
@@ -1335,7 +1335,8 @@ namespace MonoDevelop.Projects
projectBuilder.Shutdown ();
projectBuilder.ReleaseReference ();
}
- var pb = await MSBuildProjectService.GetProjectBuilder (runtime, ToolsVersion, FileName, slnFile, 0, RequiresMicrosoftBuild);
+ var sdkPath = !string.IsNullOrEmpty (MSBuildProject.Sdk) ? MSBuildProjectService.FindSdkPath (runtime, MSBuildProject.GetReferencedSDKs ()) : null;
+ var pb = await MSBuildProjectService.GetProjectBuilder (runtime, ToolsVersion, FileName, slnFile, sdkPath, 0, RequiresMicrosoftBuild);
pb.AddReference ();
pb.Disconnected += delegate {
CleanupProjectBuilder ();
@@ -1378,7 +1379,8 @@ namespace MonoDevelop.Projects
var sln = ParentSolution;
var slnFile = sln != null ? sln.FileName : null;
- var pb = await MSBuildProjectService.GetProjectBuilder (runtime, ToolsVersion, FileName, slnFile, 0, RequiresMicrosoftBuild, true);
+ var sdkPath = !string.IsNullOrEmpty (MSBuildProject.Sdk) ? MSBuildProjectService.FindSdkPath (runtime, MSBuildProject.GetReferencedSDKs ()) : null;
+ var pb = await MSBuildProjectService.GetProjectBuilder (runtime, ToolsVersion, FileName, slnFile, sdkPath, 0, RequiresMicrosoftBuild, true);
pb.AddReference ();
if (modifiedInMemory) {
try {
@@ -3141,7 +3143,7 @@ namespace MonoDevelop.Projects
void SaveProjectItem (ProgressMonitor monitor, MSBuildProject msproject, ProjectItem item, Dictionary<MSBuildItem,ExpandedItemList> expandedItems, HashSet<MSBuildItem> unusedItems, HashSet<MSBuildItem> loadedItems, string pathPrefix = null)
{
- if (item.IsFromWildcardItem) {
+ if (item.IsFromWildcardItem && item.ItemName == item.WildcardItem.Name) {
var globItem = item.WildcardItem;
// Store the item in the list of expanded items
ExpandedItemList items;
@@ -3199,9 +3201,35 @@ namespace MonoDevelop.Projects
item.Write (this, it);
if (it.Metadata.GetProperties ().Count () == 0)
buildItem = globItem;
+
+ // Add an expanded item so a Remove item does not
+ // get added back again.
+ ExpandedItemList items;
+ if (!expandedItems.TryGetValue (globItem, out items))
+ items = expandedItems [globItem] = new ExpandedItemList ();
+
+ var einfo = new ExpandedItemInfo {
+ ProjectItem = item,
+ MSBuildItem = it
+ };
+ items.Add (einfo);
+
+ if (buildItem == null && item.BackingItem != null && globItem.Name != item.BackingItem.Name) {
+ it.Update = item.Include;
+ sourceItems = new [] { globItem };
+ item.BackingItem = globItem;
+ item.BackingEvalItem = CreateFakeEvaluatedItem (msproject, it, globItem.Include, sourceItems);
+ einfo.Action = ExpandedItemAction.AddUpdateItem;
+ items.Modified = true;
+ return;
+ }
+ }
+ } else if (item.IsFromWildcardItem && item.ItemName != item.WildcardItem.Name) {
+ include = item.Include;
+ var removeItem = new MSBuildItem (item.WildcardItem.Name) { Remove = include };
+ msproject.AddItem (removeItem);
}
}
- }
if (buildItem == null)
buildItem = msproject.AddNewItem (item.ItemName, include);
item.BackingItem = buildItem;
@@ -3342,7 +3370,7 @@ namespace MonoDevelop.Projects
if (itemsToDelete != null) {
foreach (var it in itemsToDelete)
- it.ParentGroup.RemoveItem (it);
+ it.ParentProject.RemoveItem (it);
}
foreach (var p in evalItem.Metadata.GetProperties ()) {
@@ -3430,7 +3458,7 @@ namespace MonoDevelop.Projects
((MSBuildPropertyGroupEvaluated)eit.Metadata).SetProperties (md);
if (sourceItems != null) {
foreach (var s in sourceItems)
- eit.AddSourceItem (item);
+ eit.AddSourceItem (s);
} else
eit.AddSourceItem (item);
return eit;
diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml
index e936cf1dc5..08dddaba6c 100644
--- a/main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml
+++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml
@@ -92,6 +92,7 @@
</Extension>
<Extension path = "/MonoDevelop/Ide/FileTemplateConditionTypes">
+ <FileTemplateConditionType name = "HasReference" class = "MonoDevelop.Ide.Templates.HasReferenceFileTemplateCondition"/>
<FileTemplateConditionType name = "ClrVersion" class = "MonoDevelop.Ide.Templates.ClrVersionFileTemplateCondition"/>
<FileTemplateConditionType name = "PartialTypeSupport" class = "MonoDevelop.Ide.Templates.PartialTypeFileTemplateCondition"/>
<FileTemplateConditionType name = "ParentProject" class = "MonoDevelop.Ide.Templates.ParentProjectFileTemplateCondition"/>
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/HasReferenceFileTemplateCondition.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/HasReferenceFileTemplateCondition.cs
new file mode 100644
index 0000000000..a09b267edb
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/HasReferenceFileTemplateCondition.cs
@@ -0,0 +1,64 @@
+//
+// HasReferenceFileTemplateCondition.cs
+//
+// Author:
+// therzok <marius.ungureanu@xamarin.com>
+//
+// Copyright (c) 2017 (c) Marius Ungureanu
+//
+// 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.
+using System;
+using System.Linq;
+using System.Xml;
+using MonoDevelop.Projects;
+
+namespace MonoDevelop.Ide.Templates
+{
+ public class HasReferenceFileTemplateCondition : FileTemplateCondition
+ {
+ string reference;
+ public override void Load (XmlElement element)
+ {
+ reference = element.GetAttribute ("Assembly");
+ if (string.IsNullOrWhiteSpace (reference))
+ throw new InvalidOperationException ("Invalid value for Assembly condition in template.");
+ }
+
+ public override bool ShouldEnableFor (Project proj, string projectPath)
+ {
+ var dnp = proj as DotNetProject;
+ if (dnp != null) {
+ return dnp.References.Where (x => x.ReferenceType != ReferenceType.Project).Any (x => {
+ if (x.StoredReference.Length < reference.Length)
+ return false;
+
+ var trimmed = x.StoredReference.TrimStart ();
+ if (trimmed.Length < reference.Length)
+ return false;
+
+ int letterCount = trimmed.IndexOf (',');
+ if (letterCount == -1)
+ letterCount = reference.Length;
+ return trimmed.IndexOf (reference, 0, letterCount, StringComparison.Ordinal) == 0;
+ });
+ }
+ return false;
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
index 04f94b3855..b7f809dba5 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
@@ -785,6 +785,15 @@ namespace MonoDevelop.Ide.TypeSystem
internal void InformDocumentClose (DocumentId analysisDocument, string filePath)
{
try {
+ lock (openDocuments) {
+ var openDoc = openDocuments.FirstOrDefault (d => d.Id == analysisDocument);
+ if (openDoc != null) {
+ openDoc.Dispose ();
+ openDocuments.Remove (openDoc);
+ }
+ }
+ if (!CurrentSolution.ContainsDocument (analysisDocument))
+ return;
var loader = new MonoDevelopTextLoader (filePath);
var document = this.GetDocument (analysisDocument);
var openDocument = this.openDocuments.FirstOrDefault (w => w.Id == analysisDocument);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
index 727ea145a5..f2c592531d 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
@@ -9371,6 +9371,7 @@
<Compile Include="MonoDevelop.Ide.Templates\MicrosoftTemplateEngineSolutionTemplate.cs" />
<Compile Include="MonoDevelop.Ide.Templates\MicrosoftTemplateEngineProcessedTemplateResult.cs" />
<Compile Include="MonoDevelop.Ide.Codons\TemplateExtensionNode.cs" />
+ <Compile Include="MonoDevelop.Ide.Templates\HasReferenceFileTemplateCondition.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.cs
index 63be2feb9e..8b0347575f 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.cs
@@ -54,7 +54,7 @@ namespace MonoDevelop.Projects.MSBuild
gp.SetProperty (p.Key, p.Value);
}
- public ProjectBuilder LoadProject (string file)
+ public ProjectBuilder LoadProject (string file, string sdksPath)
{
return new ProjectBuilder (this, file);
}
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs
index c65576afbf..b74f179f79 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs
@@ -53,9 +53,9 @@ namespace MonoDevelop.Projects.MSBuild
engine.SetGlobalProperty (p.Key, p.Value);
}
- public ProjectBuilder LoadProject (string file)
+ public ProjectBuilder LoadProject (string file, string sdksPath)
{
- return new ProjectBuilder (this, engine, file);
+ return new ProjectBuilder (this, engine, file, sdksPath);
}
public void UnloadProject (ProjectBuilder pb)
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs
index 67ab9d16d6..61e163c8d7 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs
@@ -44,10 +44,12 @@ namespace MonoDevelop.Projects.MSBuild
readonly ProjectCollection engine;
readonly string file;
readonly BuildEngine buildEngine;
+ readonly string sdksPath;
- public ProjectBuilder (BuildEngine buildEngine, ProjectCollection engine, string file)
+ public ProjectBuilder (BuildEngine buildEngine, ProjectCollection engine, string file, string sdksPath)
{
this.file = file;
+ this.sdksPath = sdksPath;
this.engine = engine;
this.buildEngine = buildEngine;
Refresh ();
@@ -65,6 +67,8 @@ namespace MonoDevelop.Projects.MSBuild
Project project = null;
Dictionary<string, string> originalGlobalProperties = null;
try {
+ if (sdksPath != null)
+ Environment.SetEnvironmentVariable ("MSBuildSDKsPath", sdksPath);
project = SetupProject (configurations);
InitLogger (logWriter);
@@ -78,12 +82,16 @@ namespace MonoDevelop.Projects.MSBuild
loggers = new ILogger[] { logger };
}
- if (globalProperties != null) {
+ if (globalProperties != null || sdksPath != null) {
originalGlobalProperties = new Dictionary<string, string> ();
foreach (var p in project.GlobalProperties)
originalGlobalProperties [p.Key] = p.Value;
- foreach (var p in globalProperties)
- project.SetGlobalProperty (p.Key, p.Value);
+ if (globalProperties != null) {
+ foreach (var p in globalProperties)
+ project.SetGlobalProperty (p.Key, p.Value);
+ }
+ if (sdksPath != null)
+ project.SetGlobalProperty ("MSBuildSDKsPath", sdksPath);
project.ReevaluateIfNecessary ();
}
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/BuildEngine.Shared.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/BuildEngine.Shared.cs
index 199a89c067..fc6dfab325 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/BuildEngine.Shared.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/BuildEngine.Shared.cs
@@ -128,7 +128,7 @@ namespace MonoDevelop.Projects.MSBuild
[MessageHandler]
public LoadProjectResponse LoadProject (LoadProjectRequest msg)
{
- var pb = LoadProject (msg.ProjectFile);
+ var pb = LoadProject (msg.ProjectFile, msg.SDKsPath);
lock (projects) {
var id = ++projectIdCounter;
projects [id] = pb;
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/Main.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/Main.cs
index 0fdff77118..5d3524ffc4 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/Main.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/Main.cs
@@ -44,6 +44,9 @@ namespace MonoDevelop.Projects.MSBuild
[STAThread]
public static void Main (string[] args)
{
+ // This is required for MSBuild to properly load the .exe.config configuration file for this executable.
+ Environment.SetEnvironmentVariable ("MSBUILD_EXE_PATH", typeof(MainClass).Assembly.Location);
+
RemoteProcessServer server = new RemoteProcessServer ();
server.Connect (args, new AssemblyResolver (server));
}
@@ -72,12 +75,26 @@ namespace MonoDevelop.Projects.MSBuild
"Microsoft.Build.Engine",
"Microsoft.Build.Framework",
"Microsoft.Build.Tasks.Core",
- "Microsoft.Build.Utilities.Core" };
+ "Microsoft.Build.Utilities.Core",
+ "System.Reflection.Metadata"};
var asmName = new AssemblyName (args.Name);
if (!msbuildAssemblies.Any (n => string.Compare (n, asmName.Name, StringComparison.OrdinalIgnoreCase) == 0))
return null;
+ // Temporary workaround: System.Reflection.Metadata.dll is required in msbuildBinDir, but it is present only
+ // in $msbuildBinDir/Roslyn .
+ //
+ // https://github.com/xamarin/bockbuild/commit/3609dac69598f10fbfc33281289c34772eef4350
+ //
+ // Adding this till we have a release out with the above fix!
+ if (String.Compare (asmName.Name, "System.Reflection.Metadata") == 0) {
+ string fixedPath = Path.Combine (msbuildBinDir, "Roslyn", "System.Reflection.Metadata.dll");
+ if (File.Exists (fixedPath))
+ return Assembly.LoadFrom (fixedPath);
+ return null;
+ }
+
string fullPath = Path.Combine (msbuildBinDir, asmName.Name + ".dll");
if (File.Exists (fullPath)) {
// If the file exists under the msbuild bin dir, then we need
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/RemoteBuildEngineMessages.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/RemoteBuildEngineMessages.cs
index e52d8806bd..2d940f6895 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/RemoteBuildEngineMessages.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.MSBuild.Shared/RemoteBuildEngineMessages.cs
@@ -50,6 +50,9 @@ namespace MonoDevelop.Projects.MSBuild
{
[MessageDataProperty]
public string ProjectFile { get; set; }
+
+ [MessageDataProperty]
+ public string SDKsPath { get; set; }
}
[MessageDataTypeAttribute]
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.config b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.config
index 8e09aaba49..284991cf79 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.config
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.config
@@ -32,8 +32,11 @@
</runtime>
<msbuildToolsets default="15.0">
<toolset toolsVersion="15.0">
- <property name="MSBuildBinPath" value="/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/15.0/bin" />
- <property name="MSBuildToolsPath" value="/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/15.0/bin" />
+ <property name="MSBuildRuntimeVersion" value="4.0.30319" />
+ <property name="MSBuildToolsPath" value="$(MSBuildBinPath)" />
+ <property name="MSBuildToolsPath32" value="$(MSBuildBinPath)" />
+ <property name="MSBuildToolsPath64" value="$(MSBuildBinPath)" />
+ <property name="RoslynTargetsPath" value="$(MSBuildToolsPath)\Roslyn" />
<property name="TargetFrameworkRootPathSearchPathsOSX" value="/Library/Frameworks/Mono.framework/External/xbuild-frameworks/" />
<projectImportSearchPaths>
<searchPaths os="osx">
@@ -45,4 +48,4 @@
</toolset>
</msbuildToolsets>
-</configuration>
+</configuration> \ No newline at end of file
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildGlobTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildGlobTests.cs
index 783ae4355c..55ac7439ad 100644
--- a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildGlobTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildGlobTests.cs
@@ -369,33 +369,35 @@ namespace MonoDevelop.Projects
[Test]
public async Task FileUpdateChangeThenRemoveMetadata2 ()
{
- //var tn = new ProjectTypeNode ();
var fn = new CustomItemNode<SupportImportedProjectFilesProjectExtension> ();
- //MSBuildProjectService.RegisterCustomItemType (tn);
WorkspaceObject.RegisterCustomExtension (fn);
- string projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-import-test.csproj");
- string originalProjFile = new FilePath (projFile).ChangeName ("glob-import-test-original.csproj");
- File.Copy (projFile, originalProjFile);
- var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
- p.UseAdvancedGlobSupport = true;
+ try {
+ string projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-import-test.csproj");
+ string originalProjFile = new FilePath (projFile).ChangeName ("glob-import-test-original.csproj");
+ File.Copy (projFile, originalProjFile);
+ var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
- Assert.AreEqual (3, p.Files.Count);
+ Assert.AreEqual (3, p.Files.Count);
- var f = p.Files.First (fi => fi.FilePath.FileName == "c2.cs");
- f.Metadata.SetValue ("foo", "bar");
+ var f = p.Files.First (fi => fi.FilePath.FileName == "c2.cs");
+ f.Metadata.SetValue ("foo", "bar");
- await p.SaveAsync (Util.GetMonitor ());
+ await p.SaveAsync (Util.GetMonitor ());
- string projectXml = File.ReadAllText (p.FileName);
- Assert.AreEqual (File.ReadAllText (p.FileName.ChangeName ("glob-import-update1-test")), projectXml);
+ string projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (File.ReadAllText (p.FileName.ChangeName ("glob-import-update1-test")), projectXml);
- f.Metadata.RemoveProperty ("foo");
+ f.Metadata.RemoveProperty ("foo");
- await p.SaveAsync (Util.GetMonitor ());
+ await p.SaveAsync (Util.GetMonitor ());
- projectXml = File.ReadAllText (p.FileName);
- Assert.AreEqual (File.ReadAllText (originalProjFile), projectXml);
+ projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (File.ReadAllText (originalProjFile), projectXml);
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
}
[Test]
@@ -441,33 +443,40 @@ namespace MonoDevelop.Projects
[Test]
public async Task FileUpdateChangeThenRemoveMetadataAfterReload2 ()
{
- string projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-import-test.csproj");
- string originalProjFile = new FilePath (projFile).ChangeName ("glob-import-test-original.csproj");
- File.Copy (projFile, originalProjFile);
- var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
- p.UseAdvancedGlobSupport = true;
+ var fn = new CustomItemNode<SupportImportedProjectFilesProjectExtension> ();
+ WorkspaceObject.RegisterCustomExtension (fn);
- Assert.AreEqual (3, p.Files.Count);
+ try {
+ string projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-import-test.csproj");
+ string originalProjFile = new FilePath (projFile).ChangeName ("glob-import-test-original.csproj");
+ File.Copy (projFile, originalProjFile);
+ var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
- var f = p.Files.First (fi => fi.FilePath.FileName == "c2.cs");
- f.Metadata.SetValue ("foo", "bar");
+ Assert.AreEqual (3, p.Files.Count);
- await p.SaveAsync (Util.GetMonitor ());
+ var f = p.Files.First (fi => fi.FilePath.FileName == "c2.cs");
+ f.Metadata.SetValue ("foo", "bar");
- string projectXml = File.ReadAllText (p.FileName);
- Assert.AreEqual (File.ReadAllText (p.FileName.ChangeName ("glob-import-update1-test")), projectXml);
+ await p.SaveAsync (Util.GetMonitor ());
- // Reload the project.
- p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
- p.UseAdvancedGlobSupport = true;
- f = p.Files.First (fi => fi.FilePath.FileName == "c2.cs");
+ string projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (File.ReadAllText (p.FileName.ChangeName ("glob-import-update1-test")), projectXml);
- f.Metadata.RemoveProperty ("foo");
+ // Reload the project.
+ p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
+ f = p.Files.First (fi => fi.FilePath.FileName == "c2.cs");
- await p.SaveAsync (Util.GetMonitor ());
+ f.Metadata.RemoveProperty ("foo");
- projectXml = File.ReadAllText (p.FileName);
- Assert.AreEqual (File.ReadAllText (originalProjFile), projectXml);
+ await p.SaveAsync (Util.GetMonitor ());
+
+ projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (File.ReadAllText (originalProjFile), projectXml);
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
}
[Test]
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildProjectTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildProjectTests.cs
index a7b423a0f9..4bca2dff65 100644
--- a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildProjectTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildProjectTests.cs
@@ -1022,6 +1022,383 @@ namespace MonoDevelop.Projects
Assert.IsFalse (import1.HasAttribute ("xmlns"));
Assert.IsFalse (import2.HasAttribute ("xmlns"));
}
+
+ /// <summary>
+ /// Remove items should be grouped together with MSBuildItems with the same type.
+ /// </summary>
+ [Test]
+ public void AddRemoveItem ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ var removeItem = p.CreateItem ("None", "Text2.txt");
+ removeItem.Remove = "Text2.txt";
+ removeItem.Include = null;
+ p.AddItem (removeItem);
+
+ p.AddNewItem ("None", "Text1.txt");
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Remove=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Include=\"Text1.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
+
+ /// <summary>
+ /// Remove items should be added before Include items in their own ItemGroup.
+ /// </summary>
+ [Test]
+ public void AddRemoveItemBeforeIncludeItem ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ p.AddNewItem ("None", "Text1.txt");
+
+ var removeItem = p.CreateItem ("None", "Text2.txt");
+ removeItem.Remove = "Text2.txt";
+ removeItem.Include = null;
+ p.AddItem (removeItem);
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Remove=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Include=\"Text1.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
+
+ [Test]
+ public void AddRemoveItemBeforeIncludeItemOfTheSameKind ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <Reference Include=\"System.Xml\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ p.AddNewItem ("None", "Text1.txt");
+
+ var removeItem = p.CreateItem ("None", "Text2.txt");
+ removeItem.Remove = "Text2.txt";
+ removeItem.Include = null;
+ p.AddItem (removeItem);
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <Reference Include=\"System.Xml\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Remove=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Include=\"Text1.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
+
+ /// <summary>
+ /// Remove items should be added before Update items in their own ItemGroup.
+ /// </summary>
+ [Test]
+ public void AddRemoveItemBeforeUpdateItem ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ var updateItem = p.CreateItem ("None", "Text1.txt");
+ updateItem.Update = "Text1.txt";
+ updateItem.Include = null;
+ p.AddItem (updateItem);
+
+ var removeItem = p.CreateItem ("None", "Text2.txt");
+ removeItem.Remove = "Text2.txt";
+ removeItem.Include = null;
+ p.AddItem (removeItem);
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Remove=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Update=\"Text1.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
+
+ [Test]
+ public void AddRemoveItemBeforeUpdateItemOfSameKind ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <Compile Update=\"a.cs\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ var updateItem = p.CreateItem ("None", "Text1.txt");
+ updateItem.Update = "Text1.txt";
+ updateItem.Include = null;
+ p.AddItem (updateItem);
+
+ var removeItem = p.CreateItem ("None", "Text2.txt");
+ removeItem.Remove = "Text2.txt";
+ removeItem.Include = null;
+ p.AddItem (removeItem);
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <Compile Update=\"a.cs\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Remove=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Update=\"Text1.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
+
+ /// <summary>
+ /// Remove items should be added before Include items in their own ItemGroup.
+ /// </summary>
+ [Test]
+ public void AddRemoveItemAfterWildcardIncludeItem ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ MSBuildItem item = p.AddNewItem ("None", @"**\*.txt");
+ item.EvaluatedItemCount = 2;
+
+ var removeItem = p.CreateItem ("None", "Text2.txt");
+ removeItem.Remove = "Text2.txt";
+ removeItem.Include = null;
+ p.AddItem (removeItem);
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Include=\"**\\*.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Remove=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
+
+ /// <summary>
+ /// Update items should be grouped together with MSBuildItems with the same type.
+ /// </summary>
+ [Test]
+ public void AddUpdateItem ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ p.AddNewItem ("None", "Text1.txt");
+
+ var updateItem = p.CreateItem ("None", "Text2.txt");
+ updateItem.Update = "Text2.txt";
+ updateItem.Include = null;
+ p.AddItem (updateItem);
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Include=\"Text1.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Update=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
+
+ /// <summary>
+ /// Include items should be inserted before existing Update items
+ /// in their own ItemGroup.
+ /// </summary>
+ [Test]
+ public void AddIncludeItemBeforeUpdateItem ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ var updateItem = p.CreateItem ("None", "Text2.txt");
+ updateItem.Update = "Text2.txt";
+ updateItem.Include = null;
+ p.AddItem (updateItem);
+
+ p.AddNewItem ("None", "Text1.txt");
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Include=\"Text1.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Update=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
+
+ [Test]
+ public void AddIncludeItemBeforeUpdateItemOfSameKind ()
+ {
+ string projectXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <Compile Update=\"a.cs\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+
+ var p = new MSBuildProject ();
+ p.LoadXml (projectXml);
+
+ var updateItem = p.CreateItem ("None", "Text2.txt");
+ updateItem.Update = "Text2.txt";
+ updateItem.Include = null;
+ p.AddItem (updateItem);
+
+ p.AddNewItem ("None", "Text1.txt");
+
+ string xml = p.SaveToString ();
+
+ string expectedXml =
+ "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" +
+ " <PropertyGroup>\r\n" +
+ " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" +
+ " </PropertyGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <Compile Update=\"a.cs\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Include=\"Text1.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ " <ItemGroup>\r\n" +
+ " <None Update=\"Text2.txt\" />\r\n" +
+ " </ItemGroup>\r\n" +
+ "</Project>";
+ Assert.AreEqual (expectedXml, xml);
+ }
}
}
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildSearchPathTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildSearchPathTests.cs
new file mode 100644
index 0000000000..9e075f1302
--- /dev/null
+++ b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildSearchPathTests.cs
@@ -0,0 +1,198 @@
+//
+// MSBuildSearchPathTests.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@xamarin.com>
+//
+// Copyright (c) 2017 Xamarin, Inc (http://www.xamarin.com)
+//
+// 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.
+using System;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using UnitTests;
+using System.IO;
+
+namespace MonoDevelop.Projects
+{
+ [TestFixture]
+ public class MSBuildSearchPathTests: TestBase
+ {
+ public void RegisterSearchPath ()
+ {
+ string extPath = Util.GetSampleProjectPath ("msbuild-search-paths", "extensions-path");
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildExtensionsPath", extPath);
+ }
+
+ public void UnregisterSearchPath ()
+ {
+ string extPath = Util.GetSampleProjectPath ("msbuild-search-paths", "extensions-path");
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildExtensionsPath", extPath);
+ }
+
+ [Test]
+ public async Task CustomTarget ()
+ {
+ try {
+ RegisterSearchPath ();
+ string projectFile = Util.GetSampleProject ("msbuild-search-paths", "ConsoleProject.csproj");
+ DotNetProject p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projectFile) as DotNetProject;
+ Assert.AreEqual ("Works!", p.MSBuildProject.EvaluatedProperties.GetValue ("TestTarget"));
+ } finally {
+ UnregisterSearchPath ();
+ }
+ }
+
+ [Test]
+ public async Task InjectTarget ()
+ {
+ try {
+ RegisterSearchPath ();
+ string solFile = Util.GetSampleProject ("console-project", "ConsoleProject.sln");
+
+ Solution sol = (Solution)await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
+ var project = (Project)sol.Items [0];
+ var res = await project.RunTarget (Util.GetMonitor (false), "TestInjected", project.Configurations [0].Selector);
+ Assert.AreEqual (1, res.BuildResult.WarningCount);
+ Assert.AreEqual ("Works!", res.BuildResult.Errors [0].ErrorText);
+ } finally {
+ UnregisterSearchPath ();
+ }
+ }
+
+ [Test]
+ public async Task InjectTargetAfterLoadingProject ()
+ {
+ string solFile = Util.GetSampleProject ("console-project", "ConsoleProject.sln");
+
+ Solution sol = (Solution)await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
+ var project = (Project)sol.Items [0];
+ var res = await project.RunTarget (Util.GetMonitor (false), "TestInjected", project.Configurations [0].Selector);
+ Assert.AreEqual (0, res.BuildResult.WarningCount);
+ Assert.AreEqual (1, res.BuildResult.ErrorCount);
+
+ try {
+ RegisterSearchPath ();
+ res = await project.RunTarget (Util.GetMonitor (false), "TestInjected", project.Configurations [0].Selector);
+ Assert.AreEqual (1, res.BuildResult.WarningCount);
+ Assert.AreEqual ("Works!", res.BuildResult.Errors [0].ErrorText);
+ } finally {
+ UnregisterSearchPath ();
+ }
+
+ res = await project.RunTarget (Util.GetMonitor (false), "TestInjected", project.Configurations [0].Selector);
+ Assert.AreEqual (0, res.BuildResult.WarningCount);
+ Assert.AreEqual (1, res.BuildResult.ErrorCount);
+ }
+
+ [Test]
+ public async Task ProjectUsingSdk ()
+ {
+ string sdkPath = Util.GetSampleProjectPath ("msbuild-search-paths", "sdk-path");
+ try {
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath);
+
+ string projectFile = Util.GetSampleProject ("msbuild-search-paths", "ProjectUsingSdk.csproj");
+ DotNetProject p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projectFile) as DotNetProject;
+ Assert.AreEqual ("Works!", p.MSBuildProject.EvaluatedProperties.GetValue ("SdkProp"));
+
+ var res = await p.RunTarget (Util.GetMonitor (false), "SdkTarget", p.Configurations [0].Selector);
+ Assert.AreEqual (1, res.BuildResult.WarningCount);
+ Assert.AreEqual ("Works!", res.BuildResult.Errors [0].ErrorText);
+ } finally {
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath);
+ }
+ }
+
+ [Test]
+ public async Task MultipleProjectsUsingSdk ()
+ {
+ string sdkPath1 = Util.GetSampleProjectPath ("msbuild-search-paths", "sdk-path");
+ string sdkPath2 = Util.GetSampleProjectPath ("msbuild-search-paths", "sdk-path-2");
+ try {
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath1);
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath2);
+
+ // Load and run the first project
+
+ string projectFile = Util.GetSampleProject ("msbuild-search-paths", "ProjectUsingSdk.csproj");
+ DotNetProject p1 = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projectFile) as DotNetProject;
+ Assert.AreEqual ("Works!", p1.MSBuildProject.EvaluatedProperties.GetValue ("SdkProp"));
+
+ var res = await p1.RunTarget (Util.GetMonitor (false), "SdkTarget", p1.Configurations [0].Selector);
+ Assert.AreEqual (1, res.BuildResult.WarningCount);
+ Assert.AreEqual ("Works!", res.BuildResult.Errors [0].ErrorText);
+
+ // Load and run the second project
+
+ projectFile = Util.GetSampleProject ("msbuild-search-paths", "ProjectUsingSdk2.csproj");
+ DotNetProject p2 = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projectFile) as DotNetProject;
+ Assert.AreEqual ("Works!", p2.MSBuildProject.EvaluatedProperties.GetValue ("BarProp"));
+
+ res = await p2.RunTarget (Util.GetMonitor (false), "BarTarget", p2.Configurations [0].Selector);
+ Assert.AreEqual (1, res.BuildResult.WarningCount);
+ Assert.AreEqual ("Works!", res.BuildResult.Errors [0].ErrorText);
+
+ // Try building again the first project
+
+ res = await p1.RunTarget (Util.GetMonitor (false), "SdkTarget", p1.Configurations [0].Selector);
+ Assert.AreEqual (1, res.BuildResult.WarningCount);
+ Assert.AreEqual ("Works!", res.BuildResult.Errors [0].ErrorText);
+
+ } finally {
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath1);
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath2);
+ }
+ }
+
+ [Test]
+ public async Task ProjectUsingMultipleSdk ()
+ {
+ // A project that references two SDKs must be assigned an SDKs folder that contains both SDKs
+
+ string sdkPath1 = Util.GetSampleProjectPath ("msbuild-search-paths", "sdk-path");
+ string sdkPath2 = Util.GetSampleProjectPath ("msbuild-search-paths", "sdk-path-2");
+ string sdkPath3 = Util.GetSampleProjectPath ("msbuild-search-paths", "sdk-path-all");
+
+ try {
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath1);
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath2);
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath3);
+
+ string projectFile = Util.GetSampleProject ("msbuild-search-paths", "ProjectUsingMultiSdk.csproj");
+ DotNetProject p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projectFile) as DotNetProject;
+
+ var res = await p.RunTarget (Util.GetMonitor (false), "SdkTarget", p.Configurations [0].Selector);
+ Assert.AreEqual (1, res.BuildResult.WarningCount);
+ Assert.AreEqual ("Works!", res.BuildResult.Errors [0].ErrorText);
+ Assert.AreEqual ("Works!", p.MSBuildProject.EvaluatedProperties.GetValue ("SdkProp"));
+
+ res = await p.RunTarget (Util.GetMonitor (false), "BarTarget", p.Configurations [0].Selector);
+ Assert.AreEqual (1, res.BuildResult.WarningCount);
+ Assert.AreEqual ("Works!", res.BuildResult.Errors [0].ErrorText);
+ Assert.AreEqual ("Works!", p.MSBuildProject.EvaluatedProperties.GetValue ("BarProp"));
+
+ } finally {
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath1);
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath2);
+ MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdkPath3);
+}
+ }
+ }
+}
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs
index 3e7bf77207..6dd3e7338a 100644
--- a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs
@@ -1049,6 +1049,34 @@ namespace MonoDevelop.Projects
}, files);
}
+ /// <summary>
+ /// EnableDefaultItems set to false in project. C# file directly in
+ /// project. The Sdk imports define C# files if EnableDefaultItems is true.
+ /// This test ensures that duplicate files are not added to the project. This
+ /// happens because Project.EvaluatedItemsIgnoringCondition is used when adding
+ /// files to the project.
+ /// </summary>
+ [Test]
+ public async Task LoadDotNetCoreProjectWithDefaultItemsDisabled ()
+ {
+ FilePath solFile = Util.GetSampleProject ("dotnetcore-console", "dotnetcore-disable-default-items.sln");
+ FilePath sdksPath = solFile.ParentDirectory.Combine ("Sdks");
+ MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdksPath);
+
+ try {
+ var sol = (Solution)await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
+ var p = (Project)sol.Items [0];
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ var files = mp.Files.Select (f => f.FilePath.FileName).ToArray ();
+ Assert.AreEqual (new string [] {
+ "Program.cs"
+ }, files);
+ } finally {
+ MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdksPath);
+ }
+ }
+
[Test]
public async Task SaveProjectWithWildcards ()
{
@@ -1085,6 +1113,290 @@ namespace MonoDevelop.Projects
}
[Test]
+ public async Task SaveProjectWithWildcardsAfterBuildActionChanged ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ // Changing the text1-1.txt. file to EmbeddedResource should result in the following
+ // being added:
+ //
+ // <Content Remove="Content\text1-1.txt" />
+ // <EmbeddedResource Include="Content\text1-1.txt" />
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.BuildAction = BuildAction.EmbeddedResource;
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved3")), File.ReadAllText (p.FileName));
+ }
+
+ [Test]
+ public async Task SaveProjectWithWildcardsBuildActionChangedThenCopyToOutputChanged ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.BuildAction = BuildAction.EmbeddedResource;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ f.CopyToOutputDirectory = FileCopyMode.PreserveNewest;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved4")), File.ReadAllText (p.FileName));
+ }
+
+ [Test]
+ public async Task SaveProjectWithImportedWildcardsBuildActionChangedThenCopyToOutputChanged ()
+ {
+ var fn = new CustomItemNode<SupportImportedProjectFilesDotNetProjectExtension> ();
+ WorkspaceObject.RegisterCustomExtension (fn);
+
+ try {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject-import.csproj");
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.BuildAction = BuildAction.EmbeddedResource;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ f.CopyToOutputDirectory = FileCopyMode.PreserveNewest;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved1")), File.ReadAllText (p.FileName));
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
+ }
+
+ [Test]
+ public async Task SaveProjectWithWildcardsBuildActionChangedProjectReloadThenCopyToOutputChanged ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.BuildAction = BuildAction.EmbeddedResource;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+ f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.CopyToOutputDirectory = FileCopyMode.PreserveNewest;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved4")), File.ReadAllText (p.FileName));
+ }
+
+ [Test]
+ public async Task SaveProjectWithWildcardsBuildActionChangedThenCopyToOutputChangedRemoved ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.BuildAction = BuildAction.EmbeddedResource;
+ f.CopyToOutputDirectory = FileCopyMode.PreserveNewest;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ f.CopyToOutputDirectory = FileCopyMode.None;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved3")), File.ReadAllText (p.FileName));
+ }
+
+ /// <summary>
+ /// If an MSBuild item has a property on loading then if all the properties are removed the
+ /// project file when saved will still have an end element. So this test uses a different
+ /// .saved5 file compared with the previous test and includes the extra end tag for the
+ /// EmbeddedResource.
+ /// </summary>
+ [Test]
+ public async Task SaveProjectWithWildcardsBuildActionChangedThenCopyToOutputChangedRemovedAfterReload ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.BuildAction = BuildAction.EmbeddedResource;
+ f.CopyToOutputDirectory = FileCopyMode.PreserveNewest;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+ f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.CopyToOutputDirectory = FileCopyMode.None;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved5")), File.ReadAllText (p.FileName));
+ }
+
+ [Test]
+ public async Task SaveProjectWithWildcardsBuildActionChangedBackAgain ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+ string originalProjectFileText = File.ReadAllText (projFile);
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ var originalBuildAction = f.BuildAction;
+ f.BuildAction = BuildAction.EmbeddedResource;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ f.BuildAction = originalBuildAction;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (originalProjectFileText), File.ReadAllText (p.FileName));
+ }
+
+ [Test]
+ public async Task SaveProjectWithWildcardsBuildActionChangedBackAgainAfterReload ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+ string originalProjectFileText = File.ReadAllText (projFile);
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ var originalBuildAction = f.BuildAction;
+ f.BuildAction = BuildAction.EmbeddedResource;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+ f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.BuildAction = originalBuildAction;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (originalProjectFileText), File.ReadAllText (p.FileName));
+ }
+
+ /// <summary>
+ /// Changed BuildAction include has an CopyToOutputDirectory property. After reverting
+ /// the BuildAction the Remove and Include item should be removed but an Update
+ /// item should be added with the CopyToOutputDirectory property.
+ /// </summary>
+ [Test]
+ public async Task SaveProjectWithWildcardsBuildActionChangedBackAgain2 ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ var originalBuildAction = f.BuildAction;
+ f.BuildAction = BuildAction.EmbeddedResource;
+ f.CopyToOutputDirectory = FileCopyMode.PreserveNewest;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ f.BuildAction = originalBuildAction;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved6")), File.ReadAllText (p.FileName));
+ }
+
+ [Test]
+ public async Task SaveProjectWithWildcardsBuildActionChangedBackAgainAfterReload2 ()
+ {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ var originalBuildAction = f.BuildAction;
+ f.BuildAction = BuildAction.EmbeddedResource;
+ f.CopyToOutputDirectory = FileCopyMode.PreserveNewest;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+ f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ f.BuildAction = originalBuildAction;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved6")), File.ReadAllText (p.FileName));
+
+ // Save again to make sure another Update item is not added.
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (File.ReadAllText (p.FileName + ".saved6")), File.ReadAllText (p.FileName));
+ }
+
+ /// <summary>
+ /// The globs are defined in a file that is imported into the project.
+ /// </summary>
+ [Test]
+ public async Task SaveProjectWithImportedWildcardsBuildActionChangedBackAgain ()
+ {
+ var fn = new CustomItemNode<SupportImportedProjectFilesDotNetProjectExtension> ();
+ WorkspaceObject.RegisterCustomExtension (fn);
+
+ try {
+ string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject-import.csproj");
+ string originalProjectFileText = File.ReadAllText (projFile);
+
+ var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ mp.UseAdvancedGlobSupport = true;
+
+ var f = mp.Files.FirstOrDefault (pf => pf.FilePath.FileName == "text1-1.txt");
+ var originalBuildAction = f.BuildAction;
+ f.BuildAction = BuildAction.EmbeddedResource;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ f.BuildAction = originalBuildAction;
+ await p.SaveAsync (Util.GetMonitor ());
+
+ Assert.AreEqual (Util.ToSystemEndings (originalProjectFileText), File.ReadAllText (p.FileName));
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
+ }
+
+ [Test]
//[Ignore ("xbuild bug: RecursiveDir metadata returns the wrong value")]
public async Task LoadProjectWithWildcardLinks ()
{
@@ -1814,6 +2126,39 @@ namespace MonoDevelop.Projects
Assert.AreEqual ("Something failed (true.targets): true", res.Errors [0].ErrorText);
}
+ /// <summary>
+ /// Tests that the MSBuildSDKsPath property is set when building a project.
+ /// This is used by Microsoft.NET.Sdk.Web .NET Core projects when importing
+ /// other MSBuild .targets and .props.
+ /// </summary>
+ [Test]
+ public async Task BuildDotNetCoreProjectWithImportUsingMSBuildSDKsPathProperty ()
+ {
+ FilePath solFile = Util.GetSampleProject ("dotnetcore-console", "dotnetcore-msbuildsdkspath-import.sln");
+
+ FilePath sdksPath = solFile.ParentDirectory.Combine ("Sdks");
+ MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdksPath);
+
+ try {
+ var sol = (Solution)await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
+ var p = (Project)sol.Items [0];
+ p.RequiresMicrosoftBuild = true;
+
+ p.DefaultConfiguration = new DotNetProjectConfiguration ("Debug") {
+ OutputAssembly = p.BaseDirectory.Combine ("bin", "test.dll")
+ };
+ var res = await p.RunTarget (Util.GetMonitor (), "Build", ConfigurationSelector.Default);
+ var buildResult = res.BuildResult;
+
+ Assert.AreEqual (1, buildResult.Errors.Count);
+ string expectedMessage = string.Format ("Something failed (test-import.targets): {0}", sdksPath);
+ Assert.AreEqual (expectedMessage, buildResult.Errors [0].ErrorText);
+
+ } finally {
+ MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdksPath);
+ }
+ }
+
[Test]
public async Task CopyConfiguration ()
{
@@ -2186,4 +2531,12 @@ namespace MonoDevelop.Projects
class CustomFlavor: ProjectExtension
{
}
+
+ class SupportImportedProjectFilesDotNetProjectExtension : DotNetProjectExtension
+ {
+ protected internal override bool OnGetSupportsImportedItem (IMSBuildItemEvaluated buildItem)
+ {
+ return BuildAction.DotNetActions.Contains (buildItem.Name);
+ }
+ }
}
diff --git a/main/tests/UnitTests/UnitTests.csproj b/main/tests/UnitTests/UnitTests.csproj
index 2f6e3907dd..8051ff2e74 100644
--- a/main/tests/UnitTests/UnitTests.csproj
+++ b/main/tests/UnitTests/UnitTests.csproj
@@ -151,11 +151,6 @@
<Name>MonoDevelop.TextTemplating</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\..\src\addins\TextTemplating\Mono.TextTemplating\Mono.TextTemplating.csproj">
- <Project>{A2364D6A-00EF-417C-80A6-815726C70032}</Project>
- <Name>Mono.TextTemplating</Name>
- <Private>False</Private>
- </ProjectReference>
<ProjectReference Include="..\..\src\addins\Deployment\MonoDevelop.Deployment.Linux\MonoDevelop.Deployment.Linux.csproj">
<Project>{BA9020AD-A2D1-47C8-9A7C-756162C38296}</Project>
<Name>MonoDevelop.Deployment.Linux</Name>
@@ -307,6 +302,7 @@
<Compile Include="MonoDevelop.Projects\MSBuildLoggerTests.cs" />
<Compile Include="MonoDevelop.Core\MonoExecutionParametersTests.cs" />
<Compile Include="MonoDevelop.Components.PropertyGrid\EditorManagerTests.cs" />
+ <Compile Include="MonoDevelop.Projects\MSBuildSearchPathTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
diff --git a/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.csproj b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.csproj
new file mode 100755
index 0000000000..37c0a382f1
--- /dev/null
+++ b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.csproj
@@ -0,0 +1,45 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="ConsoleProject-import.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.csproj.saved1 b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.csproj.saved1
new file mode 100755
index 0000000000..6f35348fa4
--- /dev/null
+++ b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.csproj.saved1
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="ConsoleProject-import.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Remove="Content\text1-1.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Content\text1-1.txt">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </EmbeddedResource>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.targets b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.targets
new file mode 100755
index 0000000000..0e23edbabb
--- /dev/null
+++ b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-import.targets
@@ -0,0 +1,9 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Content\**\*.cs" />
+ <Content Include="*.txt" />
+ <Content Include="Content\*.txt" />
+ <Content Include="Content\Data\*.txt" />
+ </ItemGroup>
+</Project>
diff --git a/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved3 b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved3
new file mode 100755
index 0000000000..741c958658
--- /dev/null
+++ b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved3
@@ -0,0 +1,57 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Content\**\*.cs" />
+ <Content Include="*.txt" />
+ <Content Include="Content\*.txt" />
+ <Content Include="Content\Data\*.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Remove="Content\text1-1.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Content\text1-1.txt" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved4 b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved4
new file mode 100755
index 0000000000..19093d6df1
--- /dev/null
+++ b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved4
@@ -0,0 +1,59 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Content\**\*.cs" />
+ <Content Include="*.txt" />
+ <Content Include="Content\*.txt" />
+ <Content Include="Content\Data\*.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Remove="Content\text1-1.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Content\text1-1.txt">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </EmbeddedResource>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved5 b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved5
new file mode 100755
index 0000000000..7ebbe2f0cb
--- /dev/null
+++ b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved5
@@ -0,0 +1,58 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Content\**\*.cs" />
+ <Content Include="*.txt" />
+ <Content Include="Content\*.txt" />
+ <Content Include="Content\Data\*.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Remove="Content\text1-1.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Content\text1-1.txt">
+ </EmbeddedResource>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved6 b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved6
new file mode 100755
index 0000000000..5bc58a4971
--- /dev/null
+++ b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject.csproj.saved6
@@ -0,0 +1,56 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Content\**\*.cs" />
+ <Content Include="*.txt" />
+ <Content Include="Content\*.txt" />
+ <Content Include="Content\Data\*.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Update="Content\text1-1.txt">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/Sdk.props b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/Sdk.props
new file mode 100755
index 0000000000..649ee9c728
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/Sdk.props
@@ -0,0 +1,6 @@
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <Import Project="$(MSBuildSdksPath)\Test.Import.Sdk\Sdk\test-import.targets"
+ Condition="Exists('$(MSBuildSdksPath)\Test.Import.Sdk\Sdk\test-import.targets')" />
+
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/Sdk.targets b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/Sdk.targets
new file mode 100755
index 0000000000..0dfb6a3114
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/Sdk.targets
@@ -0,0 +1,3 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/test-import.targets b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/test-import.targets
new file mode 100644
index 0000000000..215c5cf0ce
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Import.Sdk/Sdk/test-import.targets
@@ -0,0 +1,5 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Target Name="Build">
+ <Error Text="Something failed (test-import.targets): $(MSBuildSDKsPath)" />
+ </Target>
+</Project>
diff --git a/main/tests/test-projects/dotnetcore-console/Sdks/Test.Sdk/Sdk/Sdk.props b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Sdk/Sdk/Sdk.props
new file mode 100755
index 0000000000..64614d2a4b
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Sdk/Sdk/Sdk.props
@@ -0,0 +1,9 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <EnableDefaultItems Condition=" '$(EnableDefaultItems)' == '' ">true</EnableDefaultItems>
+ <EnableDefaultCompileItems Condition=" '$(EnableDefaultCompileItems)' == '' ">true</EnableDefaultCompileItems>
+ </PropertyGroup>
+ <ItemGroup Condition=" '$(EnableDefaultItems)' == 'true' ">
+ <Compile Include="**/*.cs" Condition=" '$(EnableDefaultCompileItems)' == 'true' " />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/dotnetcore-console/Sdks/Test.Sdk/Sdk/Sdk.targets b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Sdk/Sdk/Sdk.targets
new file mode 100755
index 0000000000..0dfb6a3114
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/Sdks/Test.Sdk/Sdk/Sdk.targets
@@ -0,0 +1,3 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/dotnetcore-console/dotnetcore-console/dotnetcore-disable-default-items.csproj b/main/tests/test-projects/dotnetcore-console/dotnetcore-console/dotnetcore-disable-default-items.csproj
new file mode 100755
index 0000000000..fd1623b06c
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/dotnetcore-console/dotnetcore-disable-default-items.csproj
@@ -0,0 +1,12 @@
+<Project Sdk="Test.Sdk" ToolsVersion="15.0">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>netcoreapp1.0</TargetFramework>
+ <EnableDefaultItems>false</EnableDefaultItems>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/dotnetcore-console/dotnetcore-console/dotnetcore-msbuildsdkspath-import.csproj b/main/tests/test-projects/dotnetcore-console/dotnetcore-console/dotnetcore-msbuildsdkspath-import.csproj
new file mode 100755
index 0000000000..6c741bdf2f
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/dotnetcore-console/dotnetcore-msbuildsdkspath-import.csproj
@@ -0,0 +1,8 @@
+<Project Sdk="Test.Import.Sdk" ToolsVersion="15.0">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>netcoreapp1.0</TargetFramework>
+ </PropertyGroup>
+
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/dotnetcore-console/dotnetcore-disable-default-items.sln b/main/tests/test-projects/dotnetcore-console/dotnetcore-disable-default-items.sln
new file mode 100755
index 0000000000..a679f7a265
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/dotnetcore-disable-default-items.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.25806.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetcore-console", "dotnetcore-console\dotnetcore-disable-default-items.csproj", "{57E09661-7610-453D-8F3D-F4B68461DEFB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {57E09661-7610-453D-8F3D-F4B68461DEFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {57E09661-7610-453D-8F3D-F4B68461DEFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {57E09661-7610-453D-8F3D-F4B68461DEFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {57E09661-7610-453D-8F3D-F4B68461DEFB}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/main/tests/test-projects/dotnetcore-console/dotnetcore-msbuildsdkspath-import.sln b/main/tests/test-projects/dotnetcore-console/dotnetcore-msbuildsdkspath-import.sln
new file mode 100755
index 0000000000..89e3869361
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-console/dotnetcore-msbuildsdkspath-import.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.25806.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetcore-console", "dotnetcore-console\dotnetcore-msbuildsdkspath-import.csproj", "{57E09661-7610-453D-8F3D-F4B68461DEFB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {57E09661-7610-453D-8F3D-F4B68461DEFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {57E09661-7610-453D-8F3D-F4B68461DEFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {57E09661-7610-453D-8F3D-F4B68461DEFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {57E09661-7610-453D-8F3D-F4B68461DEFB}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-test-saved1.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-test-saved1.csproj
index e0218003a6..164382fa45 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-test-saved1.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-test-saved1.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Remove="c1.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-test-saved5.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-test-saved5.csproj
index 5c7f994251..9cbe4d3b63 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-test-saved5.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-test-saved5.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<foo>bar</foo>
</Compile>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update1-test-saved.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update1-test-saved.csproj
index 8a4f4b3799..e9c280840f 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update1-test-saved.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update1-test-saved.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<foo>test</foo>
</Compile>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update1-test.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update1-test.csproj
index 5c7f994251..9cbe4d3b63 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update1-test.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update1-test.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<foo>bar</foo>
</Compile>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved.csproj
index 1db67550e2..9496237b2d 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<one>test1</one>
<foo>bar</foo>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved2.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved2.csproj
index 8eaa09d704..c6d0cde2a9 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved2.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update2-test-saved2.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<one>test1</one>
</Compile>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update2-test.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update2-test.csproj
index 4ba4b8bad7..21e0eb5f36 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update2-test.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update2-test.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<one>test1</one>
<foo>bar</foo>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved.csproj
index 3033a7dadd..5a0dbd5f79 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved.csproj
@@ -33,9 +33,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs">
- <base>one</base>
+ <base>one</base>
<foo>bar</foo>
</Compile>
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<foo>custom</foo>
</Compile>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved2.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved2.csproj
index dba0e8ca03..4fe133bf4e 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved2.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved2.csproj
@@ -33,7 +33,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs">
- <base>one</base>
+ <base>one</base>
<foo>bar</foo>
</Compile>
</ItemGroup>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved3.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved3.csproj
index 5f99ffafd0..5e7d12415e 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved3.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update3-test-saved3.csproj
@@ -33,7 +33,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs;c1.cs;c2.cs">
- <base>one</base>
+ <base>one</base>
<foo>bar</foo>
</Compile>
<Compile Include="c1.cs">
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update3-test.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update3-test.csproj
index 88c5fecc01..5773c7e926 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update3-test.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update3-test.csproj
@@ -33,9 +33,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs">
- <base>one</base>
+ <base>one</base>
<foo>bar</foo>
</Compile>
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<foo>custom</foo>
</Compile>
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update4-test-saved.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update4-test-saved.csproj
index 6b4ef25b98..1f1141963f 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update4-test-saved.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update4-test-saved.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Remove="c2.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-update4-test.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-update4-test.csproj
index c4b9129fea..2614d5cc8d 100644
--- a/main/tests/test-projects/msbuild-glob-tests/glob-update4-test.csproj
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-update4-test.csproj
@@ -33,6 +33,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="**\\*.cs" Exclude="*9.cs" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Update="c2.cs">
<foo>bar1</foo>
</Compile>
diff --git a/main/tests/test-projects/msbuild-search-paths/ConsoleProject.csproj b/main/tests/test-projects/msbuild-search-paths/ConsoleProject.csproj
new file mode 100755
index 0000000000..16536b63a7
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/ConsoleProject.csproj
@@ -0,0 +1,42 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\simple.props" />
+</Project>
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.NonUserCodeTestLib/MonoDevelop.Debugger.Tests.NonUserCodeTestLib.csproj b/main/tests/test-projects/msbuild-search-paths/ProjectUsingMultiSdk.csproj
index a6ad6eb5a0..34218f4083 100644..100755
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests.NonUserCodeTestLib/MonoDevelop.Debugger.Tests.NonUserCodeTestLib.csproj
+++ b/main/tests/test-projects/msbuild-search-paths/ProjectUsingMultiSdk.csproj
@@ -1,40 +1,41 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" Sdk="Foo.Sdk;Bar.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
+ <ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{8AFA4FB4-BD2D-478F-942B-7AE3451535BB}</ProjectGuid>
- <OutputType>Library</OutputType>
- <RootNamespace>MonoDevelop.Debugger.Tests.NonUserCodeTestLib</RootNamespace>
- <AssemblyName>MonoDevelop.Debugger.Tests.NonUserCodeTestLib</AssemblyName>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
+ <DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG;</DefineConstants>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release</OutputPath>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
- <DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="NonUserCodeClass.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/ProjectUsingSdk.csproj b/main/tests/test-projects/msbuild-search-paths/ProjectUsingSdk.csproj
new file mode 100755
index 0000000000..8d8985e7d4
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/ProjectUsingSdk.csproj
@@ -0,0 +1,41 @@
+<Project DefaultTargets="Build" Sdk="Foo.Sdk">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/ProjectUsingSdk2.csproj b/main/tests/test-projects/msbuild-search-paths/ProjectUsingSdk2.csproj
new file mode 100755
index 0000000000..5caeff9ddc
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/ProjectUsingSdk2.csproj
@@ -0,0 +1,41 @@
+<Project DefaultTargets="Build" Sdk="Bar.Sdk">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleProject</RootNamespace>
+ <AssemblyName>ConsoleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/extensions-path/15.0/Microsoft.Common.targets/ImportAfter/injected-target.targets b/main/tests/test-projects/msbuild-search-paths/extensions-path/15.0/Microsoft.Common.targets/ImportAfter/injected-target.targets
new file mode 100755
index 0000000000..c50fbd3c4d
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/extensions-path/15.0/Microsoft.Common.targets/ImportAfter/injected-target.targets
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Target Name="TestInjected">
+ <Warning Text="Works!" />
+ </Target>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/extensions-path/simple.props b/main/tests/test-projects/msbuild-search-paths/extensions-path/simple.props
new file mode 100755
index 0000000000..68bf1d671a
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/extensions-path/simple.props
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <TestTarget>Works!</TestTarget>
+ </PropertyGroup>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/sdk-path-2/Bar.Sdk/Sdk/Sdk.props b/main/tests/test-projects/msbuild-search-paths/sdk-path-2/Bar.Sdk/Sdk/Sdk.props
new file mode 100755
index 0000000000..e7134bb5b4
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/sdk-path-2/Bar.Sdk/Sdk/Sdk.props
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <BarProp>Works!</BarProp>
+ </PropertyGroup>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/sdk-path-2/Bar.Sdk/Sdk/Sdk.targets b/main/tests/test-projects/msbuild-search-paths/sdk-path-2/Bar.Sdk/Sdk/Sdk.targets
new file mode 100755
index 0000000000..18546bb748
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/sdk-path-2/Bar.Sdk/Sdk/Sdk.targets
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Target Name="BarTarget">
+ <Warning Text="Works!" />
+ </Target>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Bar.Sdk/Sdk/Sdk.props b/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Bar.Sdk/Sdk/Sdk.props
new file mode 100755
index 0000000000..e7134bb5b4
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Bar.Sdk/Sdk/Sdk.props
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <BarProp>Works!</BarProp>
+ </PropertyGroup>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Bar.Sdk/Sdk/Sdk.targets b/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Bar.Sdk/Sdk/Sdk.targets
new file mode 100755
index 0000000000..18546bb748
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Bar.Sdk/Sdk/Sdk.targets
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Target Name="BarTarget">
+ <Warning Text="Works!" />
+ </Target>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Foo.Sdk/Sdk/Sdk.props b/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Foo.Sdk/Sdk/Sdk.props
new file mode 100755
index 0000000000..6c6829cb52
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Foo.Sdk/Sdk/Sdk.props
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <SdkProp>Works!</SdkProp>
+ </PropertyGroup>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Foo.Sdk/Sdk/Sdk.targets b/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Foo.Sdk/Sdk/Sdk.targets
new file mode 100755
index 0000000000..9f18ce0b42
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/sdk-path-all/Foo.Sdk/Sdk/Sdk.targets
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Target Name="SdkTarget">
+ <Warning Text="Works!" />
+ </Target>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/sdk-path/Foo.Sdk/Sdk/Sdk.props b/main/tests/test-projects/msbuild-search-paths/sdk-path/Foo.Sdk/Sdk/Sdk.props
new file mode 100755
index 0000000000..6c6829cb52
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/sdk-path/Foo.Sdk/Sdk/Sdk.props
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <SdkProp>Works!</SdkProp>
+ </PropertyGroup>
+</Project>
diff --git a/main/tests/test-projects/msbuild-search-paths/sdk-path/Foo.Sdk/Sdk/Sdk.targets b/main/tests/test-projects/msbuild-search-paths/sdk-path/Foo.Sdk/Sdk/Sdk.targets
new file mode 100755
index 0000000000..9f18ce0b42
--- /dev/null
+++ b/main/tests/test-projects/msbuild-search-paths/sdk-path/Foo.Sdk/Sdk/Sdk.targets
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Target Name="SdkTarget">
+ <Warning Text="Works!" />
+ </Target>
+</Project>