diff --git a/SharpDevelop.Tests.sln b/SharpDevelop.Tests.sln index 19ce97e39a..e63f4fc36c 100644 --- a/SharpDevelop.Tests.sln +++ b/SharpDevelop.Tests.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.3 +# SharpDevelop 5.0 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" ProjectSection(SolutionItems) = postProject EndProjectSection @@ -133,12 +133,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManagement", "Packag EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement", "src\AddIns\Misc\PackageManagement\Project\PackageManagement.csproj", "{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement.Tests", "src\AddIns\Misc\PackageManagement\Test\PackageManagement.Tests.csproj", "{56E98A01-8398-4A08-9578-C7337711A52B}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement.PowerShell", "src\AddIns\Misc\PackageManagement\PowerShell\Project\PackageManagement.PowerShell.csproj", "{A406803B-C584-43A3-BCEE-A0BB3132CB5F}" EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SharpDevelop.EnvDTE", "src\AddIns\Misc\PackageManagement\SharpDevelop.EnvDTE\SharpDevelop.EnvDTE.vbproj", "C3F15E22-5793-4129-AF8C-6229112B86D2" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement.Tests", "src\AddIns\Misc\PackageManagement\Test\PackageManagement.Tests.csproj", "{56E98A01-8398-4A08-9578-C7337711A52B}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}" ProjectSection(SolutionItems) = postProject EndProjectSection @@ -791,14 +791,6 @@ Global {AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|Any CPU.ActiveCfg = Release|x86 {AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|x86.Build.0 = Release|x86 {AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}.Release|x86.ActiveCfg = Release|x86 - {56E98A01-8398-4A08-9578-C7337711A52B}.Debug|Any CPU.Build.0 = Debug|x86 - {56E98A01-8398-4A08-9578-C7337711A52B}.Debug|Any CPU.ActiveCfg = Debug|x86 - {56E98A01-8398-4A08-9578-C7337711A52B}.Debug|x86.Build.0 = Debug|x86 - {56E98A01-8398-4A08-9578-C7337711A52B}.Debug|x86.ActiveCfg = Debug|x86 - {56E98A01-8398-4A08-9578-C7337711A52B}.Release|Any CPU.Build.0 = Release|x86 - {56E98A01-8398-4A08-9578-C7337711A52B}.Release|Any CPU.ActiveCfg = Release|x86 - {56E98A01-8398-4A08-9578-C7337711A52B}.Release|x86.Build.0 = Release|x86 - {56E98A01-8398-4A08-9578-C7337711A52B}.Release|x86.ActiveCfg = Release|x86 {A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|x86.Build.0 = Debug|Any CPU @@ -847,6 +839,14 @@ Global {85C09AD8-183B-403A-869A-7226646218A9}.Release|Any CPU.ActiveCfg = Release|x86 {85C09AD8-183B-403A-869A-7226646218A9}.Release|x86.Build.0 = Release|x86 {85C09AD8-183B-403A-869A-7226646218A9}.Release|x86.ActiveCfg = Release|x86 + {56E98A01-8398-4A08-9578-C7337711A52B}.Debug|Any CPU.Build.0 = Debug|x86 + {56E98A01-8398-4A08-9578-C7337711A52B}.Debug|Any CPU.ActiveCfg = Debug|x86 + {56E98A01-8398-4A08-9578-C7337711A52B}.Debug|x86.Build.0 = Debug|x86 + {56E98A01-8398-4A08-9578-C7337711A52B}.Debug|x86.ActiveCfg = Debug|x86 + {56E98A01-8398-4A08-9578-C7337711A52B}.Release|Any CPU.Build.0 = Release|x86 + {56E98A01-8398-4A08-9578-C7337711A52B}.Release|Any CPU.ActiveCfg = Release|x86 + {56E98A01-8398-4A08-9578-C7337711A52B}.Release|x86.Build.0 = Release|x86 + {56E98A01-8398-4A08-9578-C7337711A52B}.Release|x86.ActiveCfg = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -909,9 +909,9 @@ Global {6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} {0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} {AE4AB0FA-6087-4480-AF37-0FA1452B3DA1} = {485A4CCF-55CF-49F4-BD6D-A22B788C67DA} - {56E98A01-8398-4A08-9578-C7337711A52B} = {485A4CCF-55CF-49F4-BD6D-A22B788C67DA} {A406803B-C584-43A3-BCEE-A0BB3132CB5F} = {485A4CCF-55CF-49F4-BD6D-A22B788C67DA} C3F15E22-5793-4129-AF8C-6229112B86D2 = {485A4CCF-55CF-49F4-BD6D-A22B788C67DA} + {56E98A01-8398-4A08-9578-C7337711A52B} = {485A4CCF-55CF-49F4-BD6D-A22B788C67DA} {0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} {E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} {DCA2703D-250A-463E-A68A-07ED105AE6BD} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} diff --git a/src/AddIns/Analysis/CodeCoverage/Test/Coverage/OpenCoverSettingsTestFixture.cs b/src/AddIns/Analysis/CodeCoverage/Test/Coverage/OpenCoverSettingsTestFixture.cs index c07f8f3e5e..61b60ead90 100644 --- a/src/AddIns/Analysis/CodeCoverage/Test/Coverage/OpenCoverSettingsTestFixture.cs +++ b/src/AddIns/Analysis/CodeCoverage/Test/Coverage/OpenCoverSettingsTestFixture.cs @@ -62,7 +62,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage { MSBuildBasedProject project = new MSBuildBasedProject( new ProjectCreateInformation { - Solution = new Solution(new MockProjectChangeWatcher()), + Solution = MockSolution.Create(), OutputProjectFileName = new FileName(@"C:\temp\test.csproj"), ProjectName = "test" }); diff --git a/src/AddIns/Analysis/CodeCoverage/Test/Coverage/SolutionCodeCoverageResultsTests.cs b/src/AddIns/Analysis/CodeCoverage/Test/Coverage/SolutionCodeCoverageResultsTests.cs index 276ad91522..937b52643f 100644 --- a/src/AddIns/Analysis/CodeCoverage/Test/Coverage/SolutionCodeCoverageResultsTests.cs +++ b/src/AddIns/Analysis/CodeCoverage/Test/Coverage/SolutionCodeCoverageResultsTests.cs @@ -25,7 +25,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage void CreateSolutionCodeCoverageResults() { - solution = new Solution(new MockProjectChangeWatcher()); + solution = MockSolution.Create(); fakeFileSystem = MockRepository.GenerateStub(); solutionCodeCoverageResults = new SolutionCodeCoverageResults(solution, fakeFileSystem); } @@ -39,7 +39,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage { var project = new MockCSharpProject(solution, Path.GetFileNameWithoutExtension(fileName)); project.FileName = new FileName(fileName); - solution.Folders.Add(project); + ((ICollection)solution.Projects).Add(project); } void AddCodeCoverageFile(string fileName) diff --git a/src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitConsoleExeSelectedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitConsoleExeSelectedTestFixture.cs index ec5efc8e6b..cab8fcfe0f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitConsoleExeSelectedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitConsoleExeSelectedTestFixture.cs @@ -52,8 +52,7 @@ namespace UnitTesting.Tests.NUnit [Test] public void TargetCpuAnyCPUDotnet2() { - project.ActiveConfiguration = "Debug"; - project.ActivePlatform = "AnyCPU"; + project.ActiveConfiguration = new ConfigurationAndPlatform("Debug", "AnyCPU"); project.SetProperty("PlatformTarget", "AnyCPU"); project.SetProperty("TargetFrameworkVersion", "v3.5"); @@ -65,8 +64,7 @@ namespace UnitTesting.Tests.NUnit [Test] public void TargetCpuAnyCPUDotnet45() { - project.ActiveConfiguration = "Debug"; - project.ActivePlatform = "AnyCPU"; + project.ActiveConfiguration = new ConfigurationAndPlatform("Debug", "AnyCPU"); project.SetProperty("PlatformTarget", "AnyCPU"); project.SetProperty("TargetFrameworkVersion", "v4.5"); @@ -78,8 +76,7 @@ namespace UnitTesting.Tests.NUnit [Test] public void TargetCpuX64Dotnet2() { - project.ActiveConfiguration = "Debug"; - project.ActivePlatform = "AnyCPU"; + project.ActiveConfiguration = new ConfigurationAndPlatform("Debug", "AnyCPU"); project.SetProperty("PlatformTarget", "x64"); project.SetProperty("TargetFrameworkVersion", "v3.5"); @@ -90,8 +87,7 @@ namespace UnitTesting.Tests.NUnit [Test] public void TargetCpuX64Dotnet45() { - project.ActiveConfiguration = "Debug"; - project.ActivePlatform = "AnyCPU"; + project.ActiveConfiguration = new ConfigurationAndPlatform("Debug", "AnyCPU"); project.SetProperty("PlatformTarget", "x64"); project.SetProperty("TargetFrameworkVersion", "v4.5"); @@ -102,8 +98,7 @@ namespace UnitTesting.Tests.NUnit [Test] public void NUnitConsole32BitUsedWhenTargetCpuIs32BitDotnet2() { - project.ActiveConfiguration = "Debug"; - project.ActivePlatform = "AnyCPU"; + project.ActiveConfiguration = new ConfigurationAndPlatform("Debug", "AnyCPU"); project.SetProperty("PlatformTarget", "x86"); project.SetProperty("TargetFrameworkVersion", "v3.5"); @@ -114,8 +109,7 @@ namespace UnitTesting.Tests.NUnit [Test] public void NUnitConsole32BitUsedWhenTargetCpuIs32Bit() { - project.ActiveConfiguration = "Debug"; - project.ActivePlatform = "AnyCPU"; + project.ActiveConfiguration = new ConfigurationAndPlatform("Debug", "AnyCPU"); project.SetProperty("PlatformTarget", "x86"); NUnitConsoleApplication app = new NUnitConsoleApplication(new[] { testProject }); @@ -125,7 +119,7 @@ namespace UnitTesting.Tests.NUnit [Test] public void NotMSBuildBasedProject() { - MissingProject project = new MissingProject(FileName.Create(@"C:\Projects\Test.proj"), "Test"); + MissingProject project = new MissingProject(MockSolution.Create(), FileName.Create(@"C:\Projects\Test.proj"), "Test"); ITestProject testProject = new NUnitTestProject(project); NUnitConsoleApplication app = new NUnitConsoleApplication(new[] { testProject }); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs index 5ced187b74..34a6243da0 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs @@ -17,7 +17,7 @@ namespace UnitTesting.Tests.Utils IProjectContent projectContent; public MockCSharpProject() - : this(new Solution(new MockProjectChangeWatcher()), "MyTests") + : this(MockSolution.Create(), "MyTests") { } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/AspNet.Mvc.Tests.csproj b/src/AddIns/BackendBindings/AspNet.Mvc/Test/AspNet.Mvc.Tests.csproj index 7d1b72d608..a3c2776f88 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/AspNet.Mvc.Tests.csproj +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/AspNet.Mvc.Tests.csproj @@ -83,6 +83,7 @@ + diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/FakeSolution.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/FakeSolution.cs new file mode 100644 index 0000000000..31ca6c47c1 --- /dev/null +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/FakeSolution.cs @@ -0,0 +1,20 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using ICSharpCode.SharpDevelop.Project; +using Microsoft.Build.Evaluation; +using Rhino.Mocks; + +namespace AspNet.Mvc.Tests.Helpers +{ + public class FakeSolution + { + public static ISolution Create() + { + ISolution solution = MockRepository.GenerateStub(); + solution.Stub(s => s.MSBuildProjectCollection).Return(new ProjectCollection()); + return solution; + } + } +} diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/MSBuildProjectHelper.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/MSBuildProjectHelper.cs index fd93cd0644..a6722458a5 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/MSBuildProjectHelper.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/MSBuildProjectHelper.cs @@ -14,7 +14,7 @@ namespace AspNet.Mvc.Tests.Helpers public static MSBuildBasedProject CreateCSharpProject() { var createInfo = new ProjectCreateInformation(); - createInfo.Solution = new Solution(MockRepository.GenerateStub()); + createInfo.Solution = FakeSolution.Create(); createInfo.OutputProjectFileName = new FileName(@"d:\projects\MyProject\MyProject.csproj"); return new MSBuildBasedProject(createInfo); } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/TestableProject.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/TestableProject.cs index 0e86cc15e1..a50776869d 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/TestableProject.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Helpers/TestableProject.cs @@ -6,6 +6,7 @@ using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; +using Rhino.Mocks; using Dom = ICSharpCode.SharpDevelop.Dom; namespace AspNet.Mvc.Tests.Helpers @@ -28,7 +29,7 @@ namespace AspNet.Mvc.Tests.Helpers public static TestableProject CreateProject(string fileName, string projectName) { var createInfo = new ProjectCreateInformation(); - createInfo.Solution = new Solution(null); + createInfo.Solution = FakeSolution.Create(); createInfo.ProjectName = projectName; createInfo.OutputProjectFileName = new FileName(fileName); return new TestableProject(createInfo); diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin index 05d0dfeddd..9a2691fa12 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin @@ -48,7 +48,6 @@ diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs index afe8555920..0e8f28dabf 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs @@ -84,7 +84,7 @@ namespace CSharpBinding public override Task BuildAsync(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, IProgressMonitor progressMonitor) { - if (this.MinimumSolutionVersion == ISolution.SolutionVersionVS2005) { + if (this.MinimumSolutionVersion == SolutionFormatVersion.VS2005) { return MSBuildEngine.BuildAsync( this, options, feedbackSink, progressMonitor.CancellationToken, MSBuildEngine.AdditionalTargetFiles.Concat( @@ -177,12 +177,12 @@ namespace CSharpBinding public override CompilerVersion CurrentCompilerVersion { get { switch (Project.MinimumSolutionVersion) { - case ISolution.SolutionVersionVS2005: + case SolutionFormatVersion.VS2005: return msbuild20; - case ISolution.SolutionVersionVS2008: + case SolutionFormatVersion.VS2008: return msbuild35; - case ISolution.SolutionVersionVS2010: - case ISolution.SolutionVersionVS2012: + case SolutionFormatVersion.VS2010: + case SolutionFormatVersion.VS2012: return msbuild40; default: throw new NotSupportedException(); diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/CppBinding.addin b/src/AddIns/BackendBindings/CppBinding/CppBinding/CppBinding.addin index b5504b34a7..346b6e0bd4 100644 --- a/src/AddIns/BackendBindings/CppBinding/CppBinding/CppBinding.addin +++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/CppBinding.addin @@ -42,7 +42,6 @@ diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/ApplicationOptions.cs b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/ApplicationOptions.cs index 687b089d40..9ed62e4fb6 100644 --- a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/ApplicationOptions.cs +++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/ApplicationOptions.cs @@ -37,7 +37,7 @@ namespace ICSharpCode.CppBinding.Project void SetOutputTypeCombo() { - MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(base.Project, base.Project.ActiveConfiguration, base.Project.ActivePlatform); + MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(base.Project, base.Project.ActiveConfiguration); string subsystem = group.GetElementMetadata("Link", "SubSystem"); string configurationType = base.Project.GetEvaluatedProperty("ConfigurationType"); OutputType validOutputType = ConfigurationTypeToOutputType(configurationType, subsystem); @@ -61,7 +61,7 @@ namespace ICSharpCode.CppBinding.Project void project_MinimumSolutionVersionChanged(object sender, EventArgs e) { // embedding manifests requires the project to target MSBuild 3.5 or higher - applicationManifestComboBox.IsEnabled = base.Project.MinimumSolutionVersion >= ISolution.SolutionVersionVS2008; + applicationManifestComboBox.IsEnabled = base.Project.MinimumSolutionVersion >= SolutionFormatVersion.VS2008; } @@ -171,8 +171,7 @@ namespace ICSharpCode.CppBinding.Project OutputType outputType = values[this.outputTypeComboBox.SelectedIndex]; string subsystem = OutputTypeToSubsystem(outputType); - MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(base.Project, - base.Project.ActiveConfiguration, base.Project.ActivePlatform); + MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(base.Project, base.Project.ActiveConfiguration); group.SetElementMetadata("Link", "SubSystem", subsystem); return OutputTypeToConfigurationType(outputType); diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs index 971a1640e5..b2f808ac3b 100644 --- a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs +++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs @@ -173,11 +173,11 @@ namespace ICSharpCode.CppBinding.Project ProjectRootElement file = MSBuildProjectFile; ProjectItemGroupElement configItemGroup = file.AddItemGroup(); configItemGroup.Label = "ProjectConfigurations"; - foreach (string target in new string[] { "Debug|Win32", "Release|Win32" }) + foreach (var target in new [] { new ConfigurationAndPlatform("Debug", "Win32"), new ConfigurationAndPlatform("Release", "Win32") }) { - ProjectItemElement prjConfiguration = configItemGroup.AddItem("ProjectConfiguration", target); - prjConfiguration.AddMetadata("Configuration", GetConfigurationNameFromKey(target)); - prjConfiguration.AddMetadata("Platform", GetPlatformNameFromKey(target)); + ProjectItemElement prjConfiguration = configItemGroup.AddItem("ProjectConfiguration", target.ToString()); + prjConfiguration.AddMetadata("Configuration", target.Configuration); + prjConfiguration.AddMetadata("Platform", target.Platform); } } diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/LinkerOptions.xaml.cs b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/LinkerOptions.xaml.cs index a1105597c1..81088e358f 100644 --- a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/LinkerOptions.xaml.cs +++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/LinkerOptions.xaml.cs @@ -56,7 +56,7 @@ namespace ICSharpCode.CppBinding.Project protected override void Initialize() { - var msDefGroup = new MSBuildItemDefinitionGroup(base.Project, base.Project.ActiveConfiguration, base.Project.ActivePlatform); + var msDefGroup = new MSBuildItemDefinitionGroup(base.Project, base.Project.ActiveConfiguration); this.additionalLibsTextBox.Text = GetElementMetaData(msDefGroup,"AdditionalDependencies"); @@ -79,8 +79,7 @@ namespace ICSharpCode.CppBinding.Project protected override bool Save(MSBuildBasedProject project, string configuration, string platform) { - MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(project, - project.ActiveConfiguration, project.ActivePlatform); + MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(project, project.ActiveConfiguration); SetElementMetaData(group,"AdditionalDependencies",this.additionalLibsTextBox.Text); SetElementMetaData(group,"AddModuleNamesToAssembly",this.addModuleTextBox.Text); diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/PreprocessorOptions.xaml.cs b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/PreprocessorOptions.xaml.cs index 439cc49576..81f0922fb7 100644 --- a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/PreprocessorOptions.xaml.cs +++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/PreprocessorOptions.xaml.cs @@ -54,8 +54,7 @@ namespace ICSharpCode.CppBinding.Project protected override void Initialize() { - MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(base.Project, - base.Project.ActiveConfiguration, base.Project.ActivePlatform); + MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(base.Project, base.Project.ActiveConfiguration); this.defineTextBox.Text = GetElementMetaData(group,"PreprocessorDefinitions"); @@ -75,8 +74,7 @@ namespace ICSharpCode.CppBinding.Project protected override bool Save(MSBuildBasedProject project, string configuration, string platform) { - MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(project, - project.ActiveConfiguration, project.ActivePlatform); + MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(project, project.ActiveConfiguration); SetElementMetaData(group,"PreprocessorDefinitions",this.defineTextBox.Text); diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/SpecifyCliRuntimeLibraryCommand.cs b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/SpecifyCliRuntimeLibraryCommand.cs index 360df8f38d..5f27501aa2 100644 --- a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/SpecifyCliRuntimeLibraryCommand.cs +++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/SpecifyCliRuntimeLibraryCommand.cs @@ -28,7 +28,7 @@ namespace ICSharpCode.CppBinding.Project private static void SpecifyRuntimeLibrary(MSBuildBasedProject project, string configuration, string runtime) { - MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(project, configuration, null); + MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(project, new ConfigurationAndPlatform(configuration, null)); group.SetElementMetadata("ClCompile", "RuntimeLibrary", runtime); } } diff --git a/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.addin b/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.addin index 719b888410..a32aba9e20 100644 --- a/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.addin +++ b/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.addin @@ -44,7 +44,6 @@ diff --git a/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj b/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj index 71f713684b..961181e419 100644 --- a/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj +++ b/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj @@ -150,7 +150,6 @@ - diff --git a/src/AddIns/BackendBindings/Scripting/Test/Utils/MockProject.cs b/src/AddIns/BackendBindings/Scripting/Test/Utils/MockProject.cs deleted file mode 100644 index 72673aa537..0000000000 --- a/src/AddIns/BackendBindings/Scripting/Test/Utils/MockProject.cs +++ /dev/null @@ -1,340 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using ICSharpCode.Core; -using ICSharpCode.NRefactory.TypeSystem; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Project; - -namespace ICSharpCode.Scripting.Tests.Utils -{ - public class MockProject : IProject - { - readonly object syncRoot = new object(); - string directory = String.Empty; - string rootNamespace = String.Empty; - - public MockProject() - { - } - - public bool ReadOnly { - get { return false; } - } - - public string Directory { - get { return directory; } - set { directory = value; } - } - - public string RootNamespace { - get { return rootNamespace; } - set { rootNamespace = value; } - } - - string language = String.Empty; - - public string Language { - get { - return language; - } - set { - language = value; - } - } - - public event EventHandler ActiveConfigurationChanged { add {} remove {} } - public event EventHandler ActivePlatformChanged { add {} remove {} } - - public object SyncRoot { - get { return syncRoot; } - } - - public ISolution ParentSolution { - get { return new Solution(new MockProjectChangeWatcher()); } - } - - public event EventHandler ParseInformationUpdated { add {} remove {} } - - public IReadOnlyCollection Items { - get { - throw new NotImplementedException(); - } - } - - public IReadOnlyCollection AvailableFileItemTypes { - get { - throw new NotImplementedException(); - } - } - - public List ProjectSections { - get { - throw new NotImplementedException(); - } - } - - public FileName FileName { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public string Name { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public string AssemblyName { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public string OutputAssemblyFullPath { - get { - throw new NotImplementedException(); - } - } - - public string AppDesignerFolder { - get { - throw new NotImplementedException(); - } - } - - public string ActiveConfiguration { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public string ActivePlatform { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IReadOnlyCollection ConfigurationNames { - get { - throw new NotImplementedException(); - } - } - - public IReadOnlyCollection PlatformNames { - get { - throw new NotImplementedException(); - } - } - - public bool IsStartable { - get { - throw new NotImplementedException(); - } - } - - public Properties ProjectSpecificProperties { - get { - throw new NotImplementedException(); - } - } - - public int MinimumSolutionVersion { - get { - throw new NotImplementedException(); - } - } - - public IProjectContent ProjectContent { - get { - throw new NotImplementedException(); - } - } - - public ICSharpCode.SharpDevelop.Refactoring.ICodeGenerator CodeGenerator { - get { - throw new NotImplementedException(); - } - } - - public ICSharpCode.SharpDevelop.Dom.ITypeDefinitionModelCollection TypeDefinitionModels { - get { - throw new NotImplementedException(); - } - } - - public ISolutionFolder Parent { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public string TypeGuid { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public string IdGuid { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public string Location { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IEnumerable GetItemsOfType(ItemType type) - { - throw new NotImplementedException(); - } - - public ItemType GetDefaultItemType(string fileName) - { - throw new NotImplementedException(); - } - - public void Save() - { - throw new NotImplementedException(); - } - - public bool IsFileInProject(string fileName) - { - throw new NotImplementedException(); - } - - public FileProjectItem FindFile(string fileName) - { - throw new NotImplementedException(); - } - - public void Start(bool withDebugging) - { - throw new NotImplementedException(); - } - - public ProjectItem CreateProjectItem(IProjectItemBackendStore item) - { - throw new NotImplementedException(); - } - - public IEnumerable ResolveAssemblyReferences(System.Threading.CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public void ProjectCreationComplete() - { - throw new NotImplementedException(); - } - - public System.Xml.Linq.XElement LoadProjectExtensions(string name) - { - throw new NotImplementedException(); - } - - public void SaveProjectExtensions(string name, System.Xml.Linq.XElement element) - { - throw new NotImplementedException(); - } - - public bool HasProjectType(Guid projectTypeGuid) - { - throw new NotImplementedException(); - } - - public string GetDefaultNamespace(string fileName) - { - throw new NotImplementedException(); - } - - public System.CodeDom.Compiler.CodeDomProvider CreateCodeDomProvider() - { - throw new NotImplementedException(); - } - - public void GenerateCodeFromCodeDom(System.CodeDom.CodeCompileUnit compileUnit, System.IO.TextWriter writer) - { - throw new NotImplementedException(); - } - - public IAmbience GetAmbience() - { - throw new NotImplementedException(); - } - - public ICSharpCode.SharpDevelop.Refactoring.ISymbolSearch PrepareSymbolSearch(IEntity entity) - { - throw new NotImplementedException(); - } - - public void OnParseInformationUpdated(ICSharpCode.SharpDevelop.Parser.ParseInformationEventArgs args) - { - throw new NotImplementedException(); - } - - public IEnumerable GetBuildDependencies(ProjectBuildOptions buildOptions) - { - throw new NotImplementedException(); - } - - public System.Threading.Tasks.Task BuildAsync(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, IProgressMonitor progressMonitor) - { - throw new NotImplementedException(); - } - - public ProjectBuildOptions CreateProjectBuildOptions(BuildOptions options, bool isRootBuildable) - { - throw new NotImplementedException(); - } - - public void Dispose() - { - throw new NotImplementedException(); - } - - public Properties CreateMemento() - { - throw new NotImplementedException(); - } - - public void SetMemento(Properties memento) - { - throw new NotImplementedException(); - } - } -} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin b/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin index 31f95a7f68..9080ea6366 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin +++ b/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin @@ -20,7 +20,6 @@ diff --git a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/BitmapFromProjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/BitmapFromProjectTestFixture.cs index 64430b1c26..c8b6c6bc47 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/BitmapFromProjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/BitmapFromProjectTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; @@ -25,7 +26,8 @@ namespace WixBinding.Tests.Document [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); BitmapFileNamesRequested.Clear(); CreatedComponents.Clear(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/BitmapTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/BitmapTestFixture.cs index 0d758e2832..aa07665d4e 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/BitmapTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/BitmapTestFixture.cs @@ -27,7 +27,7 @@ namespace WixBinding.Tests.DialogLoading public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); BitmapFileNamesRequested.Clear(); CreatedComponents.Clear(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/InvalidLocationTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/InvalidLocationTests.cs index 226177e0f2..a8560a7a5e 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/InvalidLocationTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/InvalidLocationTests.cs @@ -27,7 +27,7 @@ namespace WixBinding.Tests.DialogLoading public void SetupFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/InvalidSizeTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/InvalidSizeTests.cs index 97b47c1e8e..63e2afae5b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/InvalidSizeTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/InvalidSizeTests.cs @@ -27,7 +27,7 @@ namespace WixBinding.Tests.DialogLoading public void SetupFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/MissingBitmapBinaryTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/MissingBitmapBinaryTestFixture.cs index e71ccc064e..2f842988d6 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/MissingBitmapBinaryTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/MissingBitmapBinaryTestFixture.cs @@ -31,7 +31,7 @@ namespace WixBinding.Tests.DialogLoading public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); BitmapFileNamesRequested.Clear(); WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); WixDocument doc = new WixDocument(project, this); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/NullComponentCreatorTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/NullComponentCreatorTestFixture.cs index 307b7c2586..111f039b65 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/NullComponentCreatorTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/NullComponentCreatorTestFixture.cs @@ -25,7 +25,7 @@ namespace WixBinding.Tests.DialogLoading public void CreateDialog() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); WixDocument doc = new WixDocument(project); doc.LoadXml(GetWixXml()); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Document/ChildDirectoriesTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Document/ChildDirectoriesTestFixture.cs index 8bf01ffa51..c364a0c795 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Document/ChildDirectoriesTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Document/ChildDirectoriesTestFixture.cs @@ -5,7 +5,7 @@ using System; using System.IO; using System.Resources; using System.Xml; - +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using WixBinding.Tests.Utils; @@ -29,6 +29,7 @@ namespace WixBinding.Tests.Document [TestFixtureSetUp] public void SetUpFixture() { + SD.InitializeForUnitTests(); WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); WixDocument doc = new WixDocument(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Document/DirectoryNameTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Document/DirectoryNameTests.cs index 5af7507fa8..d058c955fe 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Document/DirectoryNameTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Document/DirectoryNameTests.cs @@ -3,8 +3,8 @@ using System; using System.Resources; - using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using WixBinding.Tests.Utils; @@ -17,6 +17,7 @@ namespace WixBinding.Tests.Document [TestFixtureSetUp] public void SetupFixture() { + SD.InitializeForUnitTests(); WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs index 07c265c9b9..908ef61c18 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; @@ -24,7 +25,8 @@ namespace WixBinding.Tests.Document [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); projectDirectory = p.Directory; p.Name = "MySetup"; diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameFromProjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameFromProjectTestFixture.cs index eb85fa5951..4b7b174cce 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameFromProjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameFromProjectTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; @@ -25,7 +26,8 @@ namespace WixBinding.Tests.Document [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); projectDirectory = p.Directory; p.Name = "MySetup"; diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameFromVariablesTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameFromVariablesTestFixture.cs index 97254c0834..fe71a49c66 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameFromVariablesTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameFromVariablesTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using System; @@ -20,7 +21,8 @@ namespace WixBinding.Tests.Document [SetUp] public void Init() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); project.SetProperty("DefineConstants", @"DATADIR=Bitmaps;"); document = new WixDocument(project); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameTestFixture.cs index 426ed3c770..41a51ed4cf 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Document/GetBinaryFileNameTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using System; @@ -21,7 +22,8 @@ namespace WixBinding.Tests.Document [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); document = new WixDocument(); document.LoadXml(GetWixXml()); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Document/WixDocumentSaveTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Document/WixDocumentSaveTests.cs index afc07e6780..53d9ead2cd 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Document/WixDocumentSaveTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Document/WixDocumentSaveTests.cs @@ -5,7 +5,7 @@ using System; using System.IO; using System.Text; using System.Xml; - +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using WixBinding.Tests.Utils; @@ -22,7 +22,8 @@ namespace WixBinding.Tests.Document [SetUp] public void Init() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); document = new WixDocument(project, new DefaultFileLoader()); string xml = ""; diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddWixProjectNodeTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddWixProjectNodeTestFixture.cs index fec4382429..936f126d0c 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddWixProjectNodeTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddWixProjectNodeTestFixture.cs @@ -2,6 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; @@ -30,6 +31,8 @@ namespace WixBinding.Tests.Gui [TestFixtureSetUp] public void SetUpFixture() { + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); wixProject = WixBindingTestsHelper.CreateEmptyWixProject(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixExtensionNodeTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixExtensionNodeTestFixture.cs index 2b7d0b6c26..00c89bdbb6 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixExtensionNodeTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixExtensionNodeTestFixture.cs @@ -2,12 +2,15 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; +using Microsoft.Build.Evaluation; using NUnit.Framework; using System; using System.Windows.Forms; +using Rhino.Mocks; using WixBinding.Tests.Utils; namespace WixBinding.Tests.Gui @@ -26,12 +29,13 @@ namespace WixBinding.Tests.Gui [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixBindingTestsHelper.InitMSBuildEngine(); // create the project. ProjectCreateInformation info = new ProjectCreateInformation(); - info.Solution = new Solution(new MockProjectChangeWatcher()); + info.Solution = MockSolution.Create(); info.ProjectName = "Test"; info.OutputProjectFileName = new FileName(@"C:\Projects\Test\Test.wixproj"); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs index 9b67f7c93d..dccbb8e81c 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs @@ -1,13 +1,16 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System; +using System.Windows.Forms; using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; +using Microsoft.Build.Evaluation; using NUnit.Framework; -using System; -using System.Windows.Forms; +using Rhino.Mocks; using WixBinding.Tests.Utils; namespace WixBinding.Tests.Gui @@ -26,12 +29,13 @@ namespace WixBinding.Tests.Gui [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixBindingTestsHelper.InitMSBuildEngine(); // create the project. ProjectCreateInformation info = new ProjectCreateInformation(); - info.Solution = new Solution(new MockProjectChangeWatcher()); + info.Solution = MockSolution.Create(); info.ProjectName = "Test"; info.OutputProjectFileName = new FileName(@"C:\Projects\Test\Test.wixproj"); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/ShowExistingPackageFilesViewTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/ShowExistingPackageFilesViewTestFixture.cs index bd03298f7b..582c2da37c 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/ShowExistingPackageFilesViewTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/ShowExistingPackageFilesViewTestFixture.cs @@ -21,7 +21,8 @@ namespace WixBinding.Tests.Gui [SetUp] public void Init() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); workbench = new MockWorkbench(); CreatePackageFilesViewWithDifferentWixProject(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/ShowSetupFilesTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/ShowSetupFilesTestFixture.cs index f8f724f5c9..aa587aa0b1 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/ShowSetupFilesTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/ShowSetupFilesTestFixture.cs @@ -2,6 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using WixBinding.Tests.Utils; @@ -18,7 +19,8 @@ namespace WixBinding.Tests.Gui [SetUp] public void Init() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); workbench = new MockWorkbench(); factory = new MockPackageFilesViewFactory(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorReplaceElementTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorReplaceElementTestFixture.cs index ae74b6ad8a..a07b1720d6 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorReplaceElementTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorReplaceElementTestFixture.cs @@ -3,6 +3,7 @@ using System; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using WixBinding.Tests.Utils; @@ -19,7 +20,8 @@ namespace WixBinding.Tests.Gui [SetUp] public void Init() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); textEditor = new MockTextEditor(); textEditor.Document.Text = GetWixXml(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentWindowIsActiveTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentWindowIsActiveTests.cs index 5ad123dd9e..e97b85f46e 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentWindowIsActiveTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentWindowIsActiveTests.cs @@ -3,6 +3,7 @@ using System; using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using WixBinding.Tests.Utils; @@ -19,7 +20,8 @@ namespace WixBinding.Tests.Gui [SetUp] public void Init() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); workbench = new MockWorkbench(); window = new WixDocumentWindow(workbench); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithLibraryItemsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithLibraryItemsTestFixture.cs index 6640d38b35..f1708a0e43 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithLibraryItemsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithLibraryItemsTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; @@ -27,7 +28,8 @@ namespace WixBinding.Tests.Gui [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); wixProject = WixBindingTestsHelper.CreateEmptyWixProject(); // Add wix library item. diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithUnexpandedLibraryItemsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithUnexpandedLibraryItemsTestFixture.cs index 7585d4d869..c6b0804192 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithUnexpandedLibraryItemsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithUnexpandedLibraryItemsTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; @@ -28,7 +29,8 @@ namespace WixBinding.Tests.Gui [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); wixProject = WixBindingTestsHelper.CreateEmptyWixProject(); // Add wix library item. diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithWixExtensionItemsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithWixExtensionItemsTestFixture.cs index cf1b4b6c4e..b9583f5a2e 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithWixExtensionItemsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/WixProjectWithWixExtensionItemsTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; @@ -27,7 +28,8 @@ namespace WixBinding.Tests.Gui [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); + SD.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); wixProject = WixBindingTestsHelper.CreateEmptyWixProject(); // Add wix Extension item. diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/ActivePackageFilesViewTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/ActivePackageFilesViewTests.cs index b43b023488..d09625e0f1 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/ActivePackageFilesViewTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/ActivePackageFilesViewTests.cs @@ -19,7 +19,7 @@ namespace WixBinding.Tests.PackageFiles public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); workbench = new MockWorkbench(); activePackageFilesView = new ActivePackageFilesView(workbench); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/ActiveViewChangedWhenPackageFilesOpenTestFixtureBase.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/ActiveViewChangedWhenPackageFilesOpenTestFixtureBase.cs index 0468a66698..849d558762 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/ActiveViewChangedWhenPackageFilesOpenTestFixtureBase.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/ActiveViewChangedWhenPackageFilesOpenTestFixtureBase.cs @@ -22,7 +22,7 @@ namespace WixBinding.Tests.PackageFiles public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); viewWithOpenWixDocument = new MockTextEditorViewContent(); viewWithOpenWixDocument.SetFileName(@"d:\projects\test\a.wxs"); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/AllowedChildElementsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/AllowedChildElementsTestFixture.cs index 7218f725cb..a286daff25 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/AllowedChildElementsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/AllowedChildElementsTestFixture.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; using NUnit.Framework; @@ -25,7 +26,6 @@ namespace WixBinding.Tests.PackageFiles [TestFixtureSetUp] public void SetUpFixture() { - MessageLoopHelper.InitializeForUnitTests(); base.InitFixture(); childElementAllowedWhenNoItemSelected = new string[view.AllowedChildElements.Count]; view.AllowedChildElements.CopyTo(childElementAllowedWhenNoItemSelected, 0); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/FileIdGenerationTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/FileIdGenerationTests.cs index 4e03ccf9f1..efa6a8ae4b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/FileIdGenerationTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/FileIdGenerationTests.cs @@ -19,7 +19,7 @@ namespace WixBinding.Tests.PackageFiles public void SetupFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); doc = new WixDocument(); doc.FileName = @"C:\Projects\Setup\Setup.wxs"; doc.LoadXml(""); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoWixSourceFileInProjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoWixSourceFileInProjectTestFixture.cs index 2fb632a458..6428d53e01 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoWixSourceFileInProjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoWixSourceFileInProjectTestFixture.cs @@ -21,7 +21,7 @@ namespace WixBinding.Tests.PackageFiles public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); p.Name = "MySetup"; view = new MockWixPackageFilesView(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/OpenTextEditorsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/OpenTextEditorsTestFixture.cs index 40bdc0cce7..9b75d481fa 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/OpenTextEditorsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/OpenTextEditorsTestFixture.cs @@ -21,7 +21,7 @@ namespace WixBinding.Tests.PackageFiles public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); existingTextEditor = new MockTextEditor(); MockTextEditorViewContent viewContent = new MockTextEditorViewContent(); viewContent.TextEditor = existingTextEditor; diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesTestFixtureBase.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesTestFixtureBase.cs index 93de070a79..90875ea163 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesTestFixtureBase.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesTestFixtureBase.cs @@ -28,7 +28,7 @@ namespace WixBinding.Tests.PackageFiles public void InitFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); project = WixBindingTestsHelper.CreateEmptyWixProject(); project.Name = "MySetup"; FileProjectItem item = new FileProjectItem(project, ItemType.Compile); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesViewIsActiveTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesViewIsActiveTests.cs index 752e2cff4e..243b236c1b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesViewIsActiveTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesViewIsActiveTests.cs @@ -20,7 +20,7 @@ namespace WixBinding.Tests.PackageFiles public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); workbench = new MockWorkbench(); project = WixBindingTestsHelper.CreateEmptyWixProject(); packageFilesView = new PackageFilesView(project, workbench); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesViewTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesViewTestFixture.cs index dd87c6e22f..6192162b9b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesViewTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesViewTestFixture.cs @@ -29,7 +29,7 @@ namespace WixBinding.Tests.PackageFiles public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); project = WixBindingTestsHelper.CreateEmptyWixProject(); mockWorkbench = new MockWorkbench(); mockPackageFilesControl = new MockWixPackageFilesControl(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/SingleWixSourceFileInProjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/SingleWixSourceFileInProjectTestFixture.cs index 9a3aeda2b4..8b19beae35 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/SingleWixSourceFileInProjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/SingleWixSourceFileInProjectTestFixture.cs @@ -24,7 +24,7 @@ namespace WixBinding.Tests.PackageFiles public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); p.Name = "MySetup"; FileProjectItem item = new FileProjectItem(p, ItemType.Compile); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TargetDirectoryRefTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TargetDirectoryRefTestFixture.cs index d7d73827f1..ed9343f6fd 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TargetDirectoryRefTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TargetDirectoryRefTestFixture.cs @@ -28,7 +28,7 @@ namespace WixBinding.Tests.PackageFiles public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); p.Name = "MySetup"; FileProjectItem item = new FileProjectItem(p, ItemType.Compile); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TwoWixSourceFilesInProjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TwoWixSourceFilesInProjectTestFixture.cs index 9f32319b2c..348822a259 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TwoWixSourceFilesInProjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TwoWixSourceFilesInProjectTestFixture.cs @@ -22,7 +22,7 @@ namespace WixBinding.Tests.PackageFiles public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); p.Name = "MySetup"; FileProjectItem item = new FileProjectItem(p, ItemType.Compile); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TwoWixSourceFilesWithErrorsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TwoWixSourceFilesWithErrorsTestFixture.cs index 428db23404..c63c403e86 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TwoWixSourceFilesWithErrorsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/TwoWixSourceFilesWithErrorsTestFixture.cs @@ -26,7 +26,7 @@ namespace WixBinding.Tests.PackageFiles public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); p.Name = "MySetup"; FileProjectItem item = new FileProjectItem(p, ItemType.Compile); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/UpdateRootDirectoryWithNewFilesTestFixtureBase.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/UpdateRootDirectoryWithNewFilesTestFixtureBase.cs index 7849c58f3e..f2d88ba5ee 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/UpdateRootDirectoryWithNewFilesTestFixtureBase.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/UpdateRootDirectoryWithNewFilesTestFixtureBase.cs @@ -20,7 +20,7 @@ namespace WixBinding.Tests.PackageFiles public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); textEditor = new MockTextEditor(); MockTextEditorViewContent viewContent = new MockTextEditorViewContent(); viewContent.TextEditor = textEditor; diff --git a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/WixSourceFileWithErrorsIgnoredTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/WixSourceFileWithErrorsIgnoredTestFixture.cs index 5c5458e456..973bbc02e6 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/WixSourceFileWithErrorsIgnoredTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/WixSourceFileWithErrorsIgnoredTestFixture.cs @@ -26,7 +26,7 @@ namespace WixBinding.Tests.PackageFiles public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); p.Name = "MySetup"; FileProjectItem item = new FileProjectItem(p, ItemType.Compile); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/AddWixExtensionTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/AddWixExtensionTestFixture.cs index 6c3784a7dd..d50cd7e738 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/AddWixExtensionTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/AddWixExtensionTestFixture.cs @@ -25,7 +25,7 @@ namespace WixBinding.Tests.Project public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); string fileName1 = @"C:\Projects\Test\wixext\test.dll"; string fileName2 = @"C:\Projects\Test\mainext\main.dll"; project = WixBindingTestsHelper.CreateEmptyWixProject(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/AddWixLibraryTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/AddWixLibraryTestFixture.cs index 80aafd202c..a7b7c06438 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/AddWixLibraryTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/AddWixLibraryTestFixture.cs @@ -25,7 +25,7 @@ namespace WixBinding.Tests.Project public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); string fileName1 = @"C:\Projects\Test\wixlibs\test.wixlib"; string fileName2 = @"C:\Projects\Test\mainlibs\main.wixlib"; project = WixBindingTestsHelper.CreateEmptyWixProject(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/CanCompileTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/CanCompileTests.cs index f3f0e267fd..e558d063a4 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/CanCompileTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/CanCompileTests.cs @@ -23,7 +23,7 @@ namespace WixBinding.Tests.Project public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); project = WixBindingTestsHelper.CreateEmptyWixProject(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/CloneWixLibraryTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/CloneWixLibraryTests.cs index 96b265b83d..4850132df2 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/CloneWixLibraryTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/CloneWixLibraryTests.cs @@ -20,7 +20,7 @@ namespace WixBinding.Tests.Project public void SetUp() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); } [Test] diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs index f365073cf6..05ab3c7c29 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs @@ -10,7 +10,9 @@ using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; using Microsoft.Build.Construction; +using Microsoft.Build.Evaluation; using NUnit.Framework; +using Rhino.Mocks; using WixBinding.Tests.Utils; namespace WixBinding.Tests.Project @@ -28,11 +30,11 @@ namespace WixBinding.Tests.Project public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixBindingTestsHelper.InitMSBuildEngine(); info = new ProjectCreateInformation(); - info.Solution = new Solution(new MockProjectChangeWatcher()); + info.Solution = MockSolution.Create(); info.ProjectName = "Test"; info.OutputProjectFileName = new FileName(@"C:\Projects\Test\Test.wixproj"); info.RootNamespace = "Test"; diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateWixProjectItemTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateWixProjectItemTests.cs index a7ab70b6a7..c40d22e1b2 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateWixProjectItemTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateWixProjectItemTests.cs @@ -69,7 +69,7 @@ namespace WixBinding.Tests.Project public void SetUp() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); } [Test] diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/GetPreprocessorVariableValueTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/GetPreprocessorVariableValueTests.cs index d74f928acd..84bdcfcdff 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/GetPreprocessorVariableValueTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/GetPreprocessorVariableValueTests.cs @@ -21,7 +21,7 @@ namespace WixBinding.Tests.Project public void SetUp() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); } [Test] diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixExtensionsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixExtensionsTestFixture.cs index 950e70c9e1..63f1b18d20 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixExtensionsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixExtensionsTestFixture.cs @@ -22,7 +22,7 @@ namespace WixBinding.Tests.Project public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); WixExtensionProjectItem compilerItem = new WixExtensionProjectItem(p); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixFileProjectItemsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixFileProjectItemsTestFixture.cs index e6dea666ee..aeede7c29d 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixFileProjectItemsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixFileProjectItemsTestFixture.cs @@ -25,7 +25,7 @@ namespace WixBinding.Tests.Project public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); FileProjectItem item = new FileProjectItem(p, ItemType.None); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixSourceFileProjectItemsTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixSourceFileProjectItemsTestFixture.cs index 8664ebbb01..f61c76be9e 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixSourceFileProjectItemsTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/GetWixSourceFileProjectItemsTestFixture.cs @@ -25,7 +25,7 @@ namespace WixBinding.Tests.Project public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); WixProject p = WixBindingTestsHelper.CreateEmptyWixProject(); FileProjectItem item = new FileProjectItem(p, ItemType.None); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/WixBuilderCannotBuildNonWixProjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/WixBuilderCannotBuildNonWixProjectTestFixture.cs index a87ccf5073..b8b256d297 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/WixBuilderCannotBuildNonWixProjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/WixBuilderCannotBuildNonWixProjectTestFixture.cs @@ -25,16 +25,16 @@ namespace WixBinding.Tests.Project public void SetUpFixture() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); wixNodeBuilder = new WixProjectNodeBuilder(); project = new MSBuildBasedProject( new ProjectCreateInformation { OutputProjectFileName = new FileName(@"C:\Projects\Test\test.csproj"), - Solution = new Solution(new MockProjectChangeWatcher()), + Solution = MockSolution.Create(), ProjectName = "test" } ); - project.IdGuid = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"; + project.IdGuid = Guid.Parse("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"); } [Test] diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/WixInstallerPathTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/WixInstallerPathTests.cs index a1e2444e72..f384d75614 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/WixInstallerPathTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/WixInstallerPathTests.cs @@ -21,7 +21,7 @@ namespace WixBinding.Tests.Project public void SetUp() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); } [Test] diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/WixNodeBuilderCanBuildWixProjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/WixNodeBuilderCanBuildWixProjectTestFixture.cs index cd50616639..5b8b31e6ef 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/WixNodeBuilderCanBuildWixProjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/WixNodeBuilderCanBuildWixProjectTestFixture.cs @@ -22,7 +22,7 @@ namespace WixBinding.Tests.Project public void SetUp() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); } [Test] diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/WixProjectTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/WixProjectTests.cs index 9d031836ec..db4a84f97a 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/WixProjectTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/WixProjectTests.cs @@ -18,7 +18,7 @@ namespace WixBinding.Tests.Project void CreateProject() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); project = WixBindingTestsHelper.CreateEmptyWixProject(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MessageLoopHelper.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MessageLoopHelper.cs index cbd525265a..d5320f9479 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MessageLoopHelper.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MessageLoopHelper.cs @@ -9,10 +9,9 @@ namespace WixBinding.Tests.Utils { public static class MessageLoopHelper { - public static void InitializeForUnitTests() + public static void RegisterStubService() { IMessageLoop messageLoop = MockRepository.GenerateStub(); - SD.Services.RemoveService(typeof(IMessageLoop)); SD.Services.AddService(typeof(IMessageLoop), messageLoop); } } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockSolution.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockSolution.cs new file mode 100644 index 0000000000..d87aed6c5c --- /dev/null +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockSolution.cs @@ -0,0 +1,28 @@ +/* + * Created by SharpDevelop. + * User: Daniel + * Date: 2/27/2013 + * Time: 00:40 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using ICSharpCode.SharpDevelop.Project; +using Microsoft.Build.Evaluation; +using Rhino.Mocks; + +namespace WixBinding.Tests.Utils +{ + /// + /// Description of MockSolution. + /// + public class MockSolution + { + public static ISolution Create() + { + ISolution solution = MockRepository.GenerateStrictMock(); + solution.Stub(s => s.MSBuildProjectCollection).Return(new ProjectCollection()); + return solution; + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/ResourceServiceHelper.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/ResourceServiceHelper.cs index 9d7c1fe4a2..38436565e2 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/ResourceServiceHelper.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/ResourceServiceHelper.cs @@ -11,7 +11,6 @@ namespace WixBinding.Tests.Utils { public static void InitializeForUnitTests() { - SD.Services.RemoveService(typeof(IResourceService)); var propertyService = SD.Services.GetService(typeof(IPropertyService)) as IPropertyService; SD.Services.AddService(typeof(IResourceService), new ResourceServiceImpl("", propertyService)); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockFormsDesignerViewTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockFormsDesignerViewTests.cs index 4aacdb3bae..226bb25c7a 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockFormsDesignerViewTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockFormsDesignerViewTests.cs @@ -18,7 +18,7 @@ namespace WixBinding.Tests.Utils.Tests public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); view = new MockFormsDesignerView(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockPackageFilesViewFactoryTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockPackageFilesViewFactoryTests.cs index 9fbe1ed06a..b4dda3e377 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockPackageFilesViewFactoryTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockPackageFilesViewFactoryTests.cs @@ -21,7 +21,7 @@ namespace WixBinding.Tests.Utils.Tests public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); project = WixBindingTestsHelper.CreateEmptyWixProject(); factory = new MockPackageFilesViewFactory(); workbench = new MockWorkbench(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockTextEditorViewContentTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockTextEditorViewContentTests.cs index a733a05ef4..fb275c3ec5 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockTextEditorViewContentTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockTextEditorViewContentTests.cs @@ -18,7 +18,7 @@ namespace WixBinding.Tests.Utils.Tests public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); view = new MockTextEditorViewContent(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockViewContentTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockViewContentTests.cs index a64d8895fe..a9f98c852b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockViewContentTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockViewContentTests.cs @@ -17,7 +17,7 @@ namespace WixBinding.Tests.Utils.Tests public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); view = new MockViewContent(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockWixPackageFilesControlTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockWixPackageFilesControlTests.cs index ba32abaafd..bb2cc2ea48 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockWixPackageFilesControlTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockWixPackageFilesControlTests.cs @@ -17,7 +17,7 @@ namespace WixBinding.Tests.Utils.Tests public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); control = new MockWixPackageFilesControl(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockWorkbenchTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockWorkbenchTests.cs index 767a855567..9bfa1f01bc 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockWorkbenchTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/MockWorkbenchTests.cs @@ -17,7 +17,7 @@ namespace WixBinding.Tests.Utils.Tests public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); workbench = new MockWorkbench(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/WixBindingTestsHelperTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/WixBindingTestsHelperTests.cs index abf3804f9c..c95bb0c736 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/WixBindingTestsHelperTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/Tests/WixBindingTestsHelperTests.cs @@ -19,7 +19,7 @@ namespace WixBinding.Tests.Utils.Tests public void Init() { SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); + MessageLoopHelper.RegisterStubService(); project = WixBindingTestsHelper.CreateEmptyWixProject(); } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs index 418c073368..20c57d2182 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs @@ -11,6 +11,8 @@ using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; +using Microsoft.Build.Evaluation; +using Rhino.Mocks; namespace WixBinding.Tests.Utils { @@ -44,7 +46,8 @@ namespace WixBinding.Tests.Utils // create the project. ProjectCreateInformation info = new ProjectCreateInformation(); - info.Solution = new Solution(new MockProjectChangeWatcher()); + info.Solution = MockRepository.GenerateStub(); + info.Solution.Stub(s => s.MSBuildProjectCollection).Return(new ProjectCollection()); info.ProjectName = "Test"; info.OutputProjectFileName = new FileName(@"C:\Projects\Test\Test.wixproj"); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj b/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj index f67dc9ea81..e7aaaee6b5 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj @@ -119,6 +119,7 @@ + diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlSymbolSearch.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlSymbolSearch.cs index 8cb507d7b8..5a735f0145 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlSymbolSearch.cs +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlSymbolSearch.cs @@ -38,9 +38,7 @@ namespace ICSharpCode.XamlBinding this.entity = entity; compilation = SD.ParserService.GetCompilation(project); interestingFileNames = new List(); - foreach (var item in project.ParentSolution.SolutionFolderContainers.Select(f => f.SolutionItems).SelectMany(si => si.Items).Where(i => ".xaml".Equals(Path.GetExtension(i.Location), StringComparison.OrdinalIgnoreCase))) - interestingFileNames.Add(new FileName(Path.Combine(project.ParentSolution.Directory, item.Location))); - foreach (var item in project.ParentSolution.Projects.SelectMany(p => p.Items).OfType().Where(i => ".xaml".Equals(Path.GetExtension(i.FileName), StringComparison.OrdinalIgnoreCase))) + foreach (var item in project.ParentSolution.Projects.SelectMany(p => p.Items).OfType().Where(i => i.FileName.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))) interestingFileNames.Add(new FileName(item.FileName)); workAmount = interestingFileNames.Count; workAmountInverse = 1.0 / workAmount; diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs index 1d05435e7a..521ad3a33a 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs @@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads void LoadNodes() { if (ProjectService.OpenSolution != null) { - var props = ProjectService.OpenSolution.Preferences.Properties.NestedProperties("Watches"); + var props = ProjectService.OpenSolution.Preferences.NestedProperties("Watches"); foreach (var key in props.Keys) { this.Items.Add(new TreeNode(props.Get(key, ""), () => null).ToSharpTreeNode()); } @@ -77,7 +77,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads { if (ProjectService.OpenSolution != null) { var props = new Properties(); - ProjectService.OpenSolution.Preferences.Properties.SetNestedProperties("Watches", props); + ProjectService.OpenSolution.Preferences.SetNestedProperties("Watches", props); foreach(var node in this.Items.OfType()) { props.Set(node.Name, (object)null); } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/AbstractEventHandlerService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/AbstractEventHandlerService.cs index 4e3b3025e1..297de1bce4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/AbstractEventHandlerService.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/AbstractEventHandlerService.cs @@ -32,10 +32,7 @@ namespace ICSharpCode.WpfDesign.AddIn IProject FindProjectContainingFile() { - if (ProjectService.OpenSolution != null) { - return ProjectService.OpenSolution.FindProjectContainingFile(viewContent.PrimaryFileName); - } - return null; + return SD.ProjectService.FindProjectContainingFile(viewContent.PrimaryFileName); } protected IType GetDesignedClass(ICompilation compilation) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs index 7517a557b8..1cad86f291 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs @@ -74,10 +74,7 @@ namespace ICSharpCode.WpfDesign.AddIn internal static IProject GetProject(OpenedFile file) { - if (ProjectService.OpenSolution != null && file != null) { - return ProjectService.OpenSolution.FindProjectContainingFile(file.FileName); - } - return null; + return SD.ProjectService.FindProjectContainingFile(file.FileName); } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/SolutionConfiguration.cs b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/SolutionConfiguration.cs index 9d16e5ace4..3186251c79 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/SolutionConfiguration.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/SolutionConfiguration.cs @@ -8,15 +8,15 @@ namespace ICSharpCode.PackageManagement.EnvDTE { public class SolutionConfiguration : MarshalByRefObject, global::EnvDTE.SolutionConfiguration { - SolutionPreferences preferences; + ISolution solution; - public SolutionConfiguration(SolutionPreferences preferences) + public SolutionConfiguration(ISolution solution) { - this.preferences = preferences; + this.solution = solution; } public string Name { - get { return preferences.ActiveConfiguration; } + get { return solution.ActiveConfiguration.Configuration; } } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/MSBuildBasedProjectExtensions.cs b/src/AddIns/Misc/PackageManagement/Project/Src/MSBuildBasedProjectExtensions.cs index 315832c0b0..a404f7bcb1 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/MSBuildBasedProjectExtensions.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/MSBuildBasedProjectExtensions.cs @@ -8,12 +8,9 @@ namespace ICSharpCode.PackageManagement { public static class MSBuildBasedProjectExtensions { - public static readonly Guid WebApplication = Guid.Parse(ProjectTypeGuids.WebApplication); - public static readonly Guid WebSite = Guid.Parse(ProjectTypeGuids.WebSite); - public static bool IsWebProject(this MSBuildBasedProject project) { - return project.HasProjectType(WebApplication) || project.HasProjectType(WebSite); + return project.HasProjectType(ProjectTypeGuids.WebApplication) || project.HasProjectType(ProjectTypeGuids.WebSite); } } } diff --git a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj index fd49d90807..e28fef7158 100644 --- a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj +++ b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj @@ -38,6 +38,7 @@ TRACE + ..\RequiredLibraries\NuGet.Console.Types.dll diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectHelper.cs index 9e40f515b5..93866115f6 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectHelper.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectHelper.cs @@ -2,15 +2,29 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections.Generic; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; +using Rhino.Mocks; namespace PackageManagement.Tests.Helpers { public static class ProjectHelper { + public static ISolution CreateSolution() + { + SD.InitializeForUnitTests(); + MessageLoopHelper.InitializeForUnitTests(); + ISolution solution = MockRepository.GenerateStrictMock(); + solution.Stub(s => s.MSBuildProjectCollection).Return(new Microsoft.Build.Evaluation.ProjectCollection()); + solution.Stub(s => s.Projects).Return(new SimpleModelCollection()); + //solution.Stub(s => s.FileName).Return(FileName.Create(@"d:\projects\Test\TestSolution.sln")); + return solution; + } + public static TestableProject CreateTestProject() { return CreateTestProject("TestProject"); @@ -18,8 +32,7 @@ namespace PackageManagement.Tests.Helpers public static TestableProject CreateTestProject(string name) { - ISolution solution = new Solution(new MockProjectChangeWatcher()); - solution.FileName = @"d:\projects\Test\TestSolution.sln"; + ISolution solution = CreateSolution(); return CreateTestProject(solution, name); } @@ -27,20 +40,17 @@ namespace PackageManagement.Tests.Helpers public static TestableProject CreateTestProject( ISolution parentSolution, string name, - string fileName = @"d:\projects\Test\TestProject\TestProject.csproj") + string fileName = null) { - SD.InitializeForUnitTests(); - MessageLoopHelper.InitializeForUnitTests(); ProjectCreateInformation createInfo = new ProjectCreateInformation(); createInfo.Solution = parentSolution; createInfo.ProjectName = name; createInfo.SolutionPath = @"d:\projects\Test"; createInfo.ProjectBasePath = @"d:\projects\Test\TestProject"; - createInfo.OutputProjectFileName = new FileName(fileName); + createInfo.OutputProjectFileName = new FileName(fileName ?? (@"d:\projects\Test\TestProject\" + name + ".csproj")); var project = new TestableProject(createInfo); - project.Parent = parentSolution; - parentSolution.AddFolder(project); + ((ICollection)parentSolution.Projects).Add(project); return project; } @@ -68,9 +78,9 @@ namespace PackageManagement.Tests.Helpers AddProjectType(project, ProjectTypeGuids.WebSite); } - public static void AddProjectType(MSBuildBasedProject project, string guidText) + public static void AddProjectType(MSBuildBasedProject project, Guid guid) { - project.AddProjectType(Guid.Parse(guidText)); + project.AddProjectType(guid); } public static void AddReference(MSBuildBasedProject project, string referenceName) diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSelectedProjectsTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSelectedProjectsTests.cs index b9822e34b8..083e8633db 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSelectedProjectsTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSelectedProjectsTests.cs @@ -40,12 +40,10 @@ namespace PackageManagement.Tests List AddSolutionWithTwoProjectsToProjectService() { - TestableProject project1 = ProjectHelper.CreateTestProject("Test1"); + ISolution solution = ProjectHelper.CreateSolution(); + TestableProject project1 = ProjectHelper.CreateTestProject(solution, "Test1"); TestableProject project2 = ProjectHelper.CreateTestProject("Test2"); - ISolution solution = project1.ParentSolution; - project2.Parent = solution; - fakeSolution.FakeMSBuildProjects.Add(project1); fakeSolution.FakeMSBuildProjects.Add(project2); diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSolutionTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSolutionTests.cs index d3c5b47a9a..eb9bf2f984 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSolutionTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSolutionTests.cs @@ -5,11 +5,13 @@ using System; using System.Collections.Generic; using System.Linq; +using ICSharpCode.Core; using ICSharpCode.PackageManagement; using ICSharpCode.PackageManagement.Design; using ICSharpCode.SharpDevelop.Project; using NuGet; using NUnit.Framework; +using Rhino.Mocks; using PackageManagement.Tests.Helpers; namespace PackageManagement.Tests @@ -326,7 +328,7 @@ namespace PackageManagement.Tests public void IsOpen_SolutionIsOpen_ReturnsTrue() { CreateSolution(); - fakeProjectService.OpenSolution = new Solution(new MockProjectChangeWatcher()); + fakeProjectService.OpenSolution = MockRepository.GenerateStrictMock(); bool open = solution.IsOpen; @@ -374,12 +376,12 @@ namespace PackageManagement.Tests public void FileName_SolutionHasFileName_ReturnsSolutionFileName() { CreateSolution(); - var solution = new Solution(new MockProjectChangeWatcher()); + var solution = MockRepository.GenerateStrictMock(); string expectedFileName = @"d:\projects\myproject\Project.sln"; - solution.FileName = expectedFileName; + solution.Stub(s => s.FileName).Return(FileName.Create(expectedFileName)); fakeProjectService.OpenSolution = solution; - string fileName = solution.FileName; + string fileName = this.solution.FileName; Assert.AreEqual(expectedFileName, fileName); } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleViewModelTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleViewModelTests.cs index 5c001fec9d..85a868a758 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleViewModelTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleViewModelTests.cs @@ -11,6 +11,7 @@ using ICSharpCode.PackageManagement.Scripting; using ICSharpCode.SharpDevelop.Project; using NuGet; using NUnit.Framework; +using Rhino.Mocks; using PackageManagement.Tests.Helpers; namespace PackageManagement.Tests.Scripting @@ -109,10 +110,7 @@ namespace PackageManagement.Tests.Scripting ISolution CreateSolutionWithOneProject() { TestableProject project = ProjectHelper.CreateTestProject(); - ISolution solution = project.ParentSolution; - solution.AddFolder(project); - - return solution; + return project.ParentSolution; } PackageSource AddOnePackageSourceAndRemoveAnyExistingPackageSources() @@ -149,7 +147,7 @@ namespace PackageManagement.Tests.Scripting ISolution CreateViewModelWithEmptySolutionOpen() { CreateConsoleHost(); - var solution = new Solution(new MockProjectChangeWatcher()); + var solution = ProjectHelper.CreateSolution(); projectService = new FakePackageManagementProjectService(); projectService.OpenSolution = solution; CreateViewModel(consoleHost, projectService); @@ -158,8 +156,7 @@ namespace PackageManagement.Tests.Scripting TestableProject AddProjectToSolution(ISolution solution) { - var project = ProjectHelper.CreateTestProject(); - solution.AddFolder(project); + var project = ProjectHelper.CreateTestProject(solution, "TestProject"); return project; } @@ -178,7 +175,7 @@ namespace PackageManagement.Tests.Scripting IProject RemoveProjectFromSolution(ISolution solution) { var project = solution.Projects.FirstOrDefault(); - solution.RemoveFolder(project); + ((ICollection)solution.Projects).Remove(project); return project; } @@ -312,7 +309,7 @@ namespace PackageManagement.Tests.Scripting { CreateConsoleHost(); projectService = new FakePackageManagementProjectService(); - var solution = new Solution(new MockProjectChangeWatcher()); + var solution = ProjectHelper.CreateSolution(); projectService.OpenSolution = solution; Assert.DoesNotThrow(() => CreateViewModel(consoleHost, projectService)); @@ -443,7 +440,7 @@ namespace PackageManagement.Tests.Scripting public void Projects_SolutionFolderRemovedFromSolution_ProjectListIsUnchanged() { var solution = CreateViewModelWithOneProjectOpen(); - var solutionFolder = new SolutionFolder("Test", "Location", "Guid"); + var solutionFolder = MockRepository.GenerateStrictMock(); projectService.FireSolutionFolderRemoved(solutionFolder); int count = viewModel.Projects.Count; diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PowerShellWorkingDirectoryTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PowerShellWorkingDirectoryTests.cs index a43b122091..4b9811bcb4 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PowerShellWorkingDirectoryTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PowerShellWorkingDirectoryTests.cs @@ -2,10 +2,12 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using ICSharpCode.Core; using ICSharpCode.PackageManagement.Design; using ICSharpCode.PackageManagement.Scripting; using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; +using Rhino.Mocks; using PackageManagement.Tests.Helpers; namespace PackageManagement.Tests.Scripting @@ -39,8 +41,8 @@ namespace PackageManagement.Tests.Scripting public void GetWorkingDirectory_SolutionOpen_ReturnsSolutionDirectory() { CreateWorkingDirectory(); - var solution = new Solution(new MockProjectChangeWatcher()); - solution.FileName = @"d:\projects\MyProject\myproject.sln"; + var solution = MockRepository.GenerateStrictMock(); + solution.Stub(s => s.Directory).Return(DirectoryName.Create(@"d:\projects\MyProject")); fakeProjectService.OpenSolution = solution; string directory = workingDirectory.GetWorkingDirectory(); diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/SelectedProjectsForInstalledPackagesTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/SelectedProjectsForInstalledPackagesTests.cs index 9250a494ba..413637e2c5 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/SelectedProjectsForInstalledPackagesTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/SelectedProjectsForInstalledPackagesTests.cs @@ -31,11 +31,9 @@ namespace PackageManagement.Tests List AddSolutionWithTwoProjectsToProjectService() { - TestableProject project1 = ProjectHelper.CreateTestProject("Test1"); - TestableProject project2 = ProjectHelper.CreateTestProject("Test2"); - - ISolution solution = project1.ParentSolution; - project2.Parent = solution; + ISolution solution = ProjectHelper.CreateSolution(); + TestableProject project1 = ProjectHelper.CreateTestProject(solution, "Test1"); + TestableProject project2 = ProjectHelper.CreateTestProject(solution, "Test2"); fakeSolution.FakeMSBuildProjects.Add(project1); fakeSolution.FakeMSBuildProjects.Add(project2); diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/SelectedProjectsForUpdatedPackagesTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/SelectedProjectsForUpdatedPackagesTests.cs index 9bae25bb17..96368f3a73 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/SelectedProjectsForUpdatedPackagesTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/SelectedProjectsForUpdatedPackagesTests.cs @@ -31,11 +31,9 @@ namespace PackageManagement.Tests List AddSolutionWithTwoProjectsToProjectService(string projectName1, string projectName2) { - TestableProject project1 = ProjectHelper.CreateTestProject(projectName1); - TestableProject project2 = ProjectHelper.CreateTestProject(projectName2); - - ISolution solution = project1.ParentSolution; - project2.Parent = solution; + ISolution solution = ProjectHelper.CreateSolution(); + TestableProject project1 = ProjectHelper.CreateTestProject(solution, projectName1); + TestableProject project2 = ProjectHelper.CreateTestProject(solution, projectName2); fakeSolution.FakeMSBuildProjects.Add(project1); fakeSolution.FakeMSBuildProjects.Add(project2); diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerFactoryTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerFactoryTests.cs index dfb85d9bbd..342fe447a4 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerFactoryTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerFactoryTests.cs @@ -8,6 +8,7 @@ using ICSharpCode.PackageManagement.Design; using ICSharpCode.SharpDevelop.Project; using NuGet; using NUnit.Framework; +using Rhino.Mocks; using PackageManagement.Tests.Helpers; namespace PackageManagement.Tests @@ -34,6 +35,7 @@ namespace PackageManagement.Tests void CreateTestProject() { testProject = ProjectHelper.CreateTestProject(); + testProject.ParentSolution.Stub(s => s.Directory).Return(DirectoryName.Create(@"c:\projects\MyProject\")); } void CreatePackageManager() @@ -58,7 +60,6 @@ namespace PackageManagement.Tests { CreateFactory(); CreateTestProject(); - testProject.ParentSolution.FileName = @"c:\projects\MyProject\MySolution.sln"; options.PackagesDirectory = "MyPackages"; CreatePackageManager(); @@ -72,7 +73,6 @@ namespace PackageManagement.Tests { CreateFactory(); CreateTestProject(); - testProject.ParentSolution.FileName = @"c:\projects\MyProject\MySolution.sln"; options.PackagesDirectory = "MyPackages"; CreatePackageManager(); @@ -102,7 +102,6 @@ namespace PackageManagement.Tests { CreateFactory(); CreateTestProject(); - testProject.ParentSolution.FileName = @"c:\projects\MyProject\MySolution.sln"; options.PackagesDirectory = "packages"; CreatePackageManager(); diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerTests.cs index a25ddb925e..fa4ae248b3 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerTests.cs @@ -9,6 +9,7 @@ using ICSharpCode.PackageManagement.Design; using ICSharpCode.SharpDevelop.Project; using NuGet; using NUnit.Framework; +using Rhino.Mocks; using PackageManagement.Tests.Helpers; namespace PackageManagement.Tests @@ -68,6 +69,7 @@ namespace PackageManagement.Tests void CreateTestProject() { testProject = ProjectHelper.CreateTestProject(); + testProject.ParentSolution.Stub(s => s.Directory).Return(DirectoryName.Create(@"c:\projects\Test\MyProject")); } void CreateTestableProjectManager() diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryPathTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryPathTests.cs index 5e0ac089cf..401d3b15db 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryPathTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryPathTests.cs @@ -7,6 +7,7 @@ using ICSharpCode.PackageManagement; using ICSharpCode.PackageManagement.Design; using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; +using Rhino.Mocks; using PackageManagement.Tests.Helpers; namespace PackageManagement.Tests @@ -36,8 +37,10 @@ namespace PackageManagement.Tests void CreateSolution(string fileName) { - solution = new Solution(new MockProjectChangeWatcher()); - solution.FileName = fileName; + solution = MockRepository.GenerateStrictMock(); + var file = FileName.Create(fileName); + solution.Stub(s => s.FileName).Return(file); + solution.Stub(s => s.Directory).Return(file.GetParentDirectory()); } void CreateOptions() @@ -50,7 +53,7 @@ namespace PackageManagement.Tests { CreateOptions(); CreateTestProject(); - testProject.ParentSolution.FileName = @"d:\projects\MyProject\MySolution.sln"; + testProject.ParentSolution.Stub(s => s.Directory).Return(DirectoryName.Create(@"d:\projects\MyProject\")); options.PackagesDirectory = "MyPackages"; CreateSolutionPackageRepositoryPath(); diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs index 73e14307de..b9ca13e89b 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs @@ -5,11 +5,13 @@ using System; using System.Collections.Generic; using System.Linq; +using ICSharpCode.Core; using ICSharpCode.PackageManagement; using ICSharpCode.PackageManagement.Design; using ICSharpCode.SharpDevelop.Project; using NuGet; using NUnit.Framework; +using Rhino.Mocks; using PackageManagement.Tests.Helpers; namespace PackageManagement.Tests @@ -25,8 +27,9 @@ namespace PackageManagement.Tests void CreateSolution(string fileName) { - solution = new Solution(new MockProjectChangeWatcher()); - solution.FileName = fileName; + solution = MockRepository.GenerateStrictMock(); + solution.Stub(s => s.FileName).Return(FileName.Create(fileName)); + solution.Stub(s => s.Directory).Return(DirectoryName.Create(System.IO.Path.GetDirectoryName(fileName))); } void CreateFakeRepositoryFactory() @@ -54,8 +57,7 @@ namespace PackageManagement.Tests void CreateRepository() { - solution = new Solution(new MockProjectChangeWatcher()); - solution.FileName = @"d:\projects\test\myproject\myproject.sln"; + CreateSolution(@"d:\projects\test\myproject\myproject.sln"); CreateRepository(solution); } diff --git a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchLocation.cs b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchLocation.cs index 9ab65862c7..ae88188839 100644 --- a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchLocation.cs +++ b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchLocation.cs @@ -72,8 +72,8 @@ namespace SearchAndReplace case SearchTarget.WholeSolution: if (ProjectService.OpenSolution == null) break; - foreach (var item in ProjectService.OpenSolution.SolutionFolderContainers.Select(f => f.SolutionItems).SelectMany(si => si.Items)) - files.Add(new FileName(Path.Combine(ProjectService.OpenSolution.Directory, item.Location))); + foreach (var item in ProjectService.OpenSolution.FileItems) + files.Add(item.FileName); foreach (var item in ProjectService.OpenSolution.Projects.SelectMany(p => p.Items).OfType()) files.Add(new FileName(item.FileName)); break; diff --git a/src/AddIns/Misc/TextTemplating/Test/Helpers/ProjectHelper.cs b/src/AddIns/Misc/TextTemplating/Test/Helpers/ProjectHelper.cs index cceb89b63b..edd12fe5d4 100644 --- a/src/AddIns/Misc/TextTemplating/Test/Helpers/ProjectHelper.cs +++ b/src/AddIns/Misc/TextTemplating/Test/Helpers/ProjectHelper.cs @@ -5,6 +5,8 @@ using System; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; +using Microsoft.Build.Evaluation; +using Rhino.Mocks; namespace TextTemplating.Tests.Helpers { @@ -13,7 +15,8 @@ namespace TextTemplating.Tests.Helpers public static TestableProject CreateProject() { var info = new ProjectCreateInformation(); - info.Solution = new Solution(new MockProjectChangeWatcher()); + info.Solution = MockRepository.GenerateStub(); + info.Solution.Stub(s => s.MSBuildProjectCollection).Return(new ProjectCollection()); info.OutputProjectFileName = FileName.Create(@"d:\projects\MyProject\MyProject.csproj"); info.ProjectName = "MyProject"; return new TestableProject(info); diff --git a/src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj b/src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj index 62f20a7606..2bd8ebb3be 100644 --- a/src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj +++ b/src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj @@ -39,6 +39,7 @@ TRACE + ..\Project\lib\Mono.TextTemplating.dll diff --git a/src/Main/Base/Project/Dom/IModelCollection.cs b/src/Main/Base/Project/Dom/IModelCollection.cs index fb2ac40de8..618f0a1f96 100644 --- a/src/Main/Base/Project/Dom/IModelCollection.cs +++ b/src/Main/Base/Project/Dom/IModelCollection.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; +using System.Linq; namespace ICSharpCode.SharpDevelop.Dom { @@ -27,5 +28,26 @@ namespace ICSharpCode.SharpDevelop.Dom /// public class SimpleModelCollection : ObservableCollection, IMutableModelCollection { + public SimpleModelCollection() + { + } + + public SimpleModelCollection(IEnumerable items) + : base(items) + { + } + } + + /// + /// A model collection implementation that is based on a ReadOnlyCollection. + /// + public class ReadOnlyModelCollection : ReadOnlyCollection, IModelCollection + { + public ReadOnlyModelCollection(IEnumerable items) + : base(items.ToList()) + { + } + + event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged { add {} remove {} } } } diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin index be11ffb016..5f0b269a38 100755 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin @@ -74,6 +74,8 @@ class="ICSharpCode.SharpDevelop.ClipboardWrapper"/> + @@ -198,7 +200,6 @@ Code + diff --git a/src/Main/Base/Project/Project/ConfigurationAndPlatform.cs b/src/Main/Base/Project/Project/ConfigurationAndPlatform.cs index f6b1f9dd19..56ba9c3843 100644 --- a/src/Main/Base/Project/Project/ConfigurationAndPlatform.cs +++ b/src/Main/Base/Project/Project/ConfigurationAndPlatform.cs @@ -96,9 +96,53 @@ namespace ICSharpCode.SharpDevelop.Project } #endregion + /// + /// Converts configuration and platform to a string in the 'configuration|platform' format. + /// public override string ToString() { return configuration + "|" + platform; } + + /// + /// Creates an MSBuild condition string. + /// At most one of configuration and platform can be null. + /// + public string ToCondition() + { + if (configuration == null) + return CreateCondition(configuration, platform, PropertyStorageLocations.PlatformSpecific); + else if (platform == null) + return CreateCondition(configuration, platform, PropertyStorageLocations.ConfigurationSpecific); + else + return CreateCondition(configuration, platform, PropertyStorageLocations.ConfigurationAndPlatformSpecific); + } + + /// + /// Creates an MSBuild condition string. + /// configuration and platform may be only null if they are not required (as specified by the + /// storage location), otherwise an ArgumentNullException is thrown. + /// + internal static string CreateCondition(string configuration, string platform, PropertyStorageLocations location) + { + switch (location & PropertyStorageLocations.ConfigurationAndPlatformSpecific) { + case PropertyStorageLocations.ConfigurationSpecific: + if (configuration == null) + throw new ArgumentNullException("configuration"); + return " '$(Configuration)' == '" + configuration + "' "; + case PropertyStorageLocations.PlatformSpecific: + if (platform == null) + throw new ArgumentNullException("platform"); + return " '$(Platform)' == '" + platform + "' "; + case PropertyStorageLocations.ConfigurationAndPlatformSpecific: + if (platform == null) + throw new ArgumentNullException("platform"); + if (configuration == null) + throw new ArgumentNullException("configuration"); + return " '$(Configuration)|$(Platform)' == '" + configuration + "|" + platform + "' "; + default: + return null; + } + } } } diff --git a/src/Main/Base/Project/Project/IProjectService.cs b/src/Main/Base/Project/Project/IProjectService.cs index 85b231e5ae..4fa4548640 100644 --- a/src/Main/Base/Project/Project/IProjectService.cs +++ b/src/Main/Base/Project/Project/IProjectService.cs @@ -2,6 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections.Generic; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; @@ -16,21 +17,22 @@ namespace ICSharpCode.SharpDevelop.Project /// /// Gets the solution that is currently opened within the IDE. /// + /// + /// This property is thread-safe. + /// ISolution OpenSolution { get; } - event EventHandler OpenSolutionChanged; + event EventHandler OpenSolutionChanged; /// /// Gets/Sets the project that is currently considered 'active' within the IDE. /// + /// + /// The getter is thread-safe; the setter may only be called on the main thread. + /// IProject CurrentProject { get; set; } - event EventHandler CurrentProjectChanged; - - /// - /// Gets the list of projects that are currently opened within the IDE. - /// - IModelCollection Projects { get; } + event EventHandler CurrentProjectChanged; /// /// Finds the project that contains the specified file. @@ -38,6 +40,7 @@ namespace ICSharpCode.SharpDevelop.Project /// /// /// If multiple projects contain the file, any one of them is returned. + /// This method is thread-safe. /// IProject FindProjectContainingFile(FileName fileName); @@ -47,6 +50,7 @@ namespace ICSharpCode.SharpDevelop.Project /// If no such .sln file is found, SharpDevelop will create one. /// /// + /// This method may only be called on the main thread. /// If any errors occur, this method may display an error dialog. /// void OpenSolutionOrProject(FileName fileName); @@ -54,12 +58,18 @@ namespace ICSharpCode.SharpDevelop.Project /// /// Closes the currently open solution. /// + /// + /// This method may only be called on the main thread. + /// void CloseSolution(); /// /// Returns if the given file is considered a project or solution file. /// This method looks at the list of registered file extensions in /SharpDevelop/Workbench/ProjectBinding. /// + /// + /// This method is thread-safe. + /// bool IsProjectOrSolutionFile(FileName fileName); /// @@ -69,12 +79,18 @@ namespace ICSharpCode.SharpDevelop.Project /// The .sln file is malformed or an unsupported version, and cannot be loaded. /// This exception does not occur if only individual projects within the solution are invalid. /// + /// + /// This method is thread-safe. + /// ISolution LoadSolutionFile(FileName fileName); /// /// Creates a new, empty solution and loads it without opening it in the IDE. /// The file is not saved to disk until is called. /// + /// + /// This method is thread-safe. + /// ISolution CreateEmptySolutionFile(FileName fileName); } } diff --git a/src/Main/Base/Project/Project/ISolution.cs b/src/Main/Base/Project/Project/ISolution.cs index 2bc28025f8..14afa5f87e 100644 --- a/src/Main/Base/Project/Project/ISolution.cs +++ b/src/Main/Base/Project/Project/ISolution.cs @@ -32,7 +32,7 @@ namespace ICSharpCode.SharpDevelop.Project /// /// Gets the full path of the directory containing the .sln file. /// - string Directory { get; } + DirectoryName Directory { get; } /// /// Gets/Sets the startup project. @@ -47,19 +47,15 @@ namespace ICSharpCode.SharpDevelop.Project IModelCollection Projects { get; } /// - /// Loads an existing project from disk and adds it to this solution. + /// Gets all file items in the solution. /// - /// Path to the project file - /// - /// Optional: The parent folder to which the new project should be added. - /// If this parameter is not specified, the project is added to the root folder of the solution. - /// - void AddExistingProject(FileName fileName, ISolutionFolder parentFolder = null); + IModelCollection FileItems { get; } /// - /// Gets all file items in the solution. + /// Finds the item with the specified ; + /// or returns null if no such item exists. /// - IModelCollection FileItems { get; } + ISolutionItem GetItemByGuid(Guid guid); /// /// Gets a container that can be used to store data about the solution. @@ -82,7 +78,5 @@ namespace ICSharpCode.SharpDevelop.Project /// This will also save all modified projects within this solution. /// void Save(); - - } } diff --git a/src/Main/Base/Project/Project/ISolutionFolder.cs b/src/Main/Base/Project/Project/ISolutionFolder.cs index f3f30b21b0..4dce02a805 100644 --- a/src/Main/Base/Project/Project/ISolutionFolder.cs +++ b/src/Main/Base/Project/Project/ISolutionFolder.cs @@ -2,6 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; namespace ICSharpCode.SharpDevelop.Project @@ -32,9 +33,38 @@ namespace ICSharpCode.SharpDevelop.Project solution.Name = newName; */ + /// + /// Gets whether this solution folder is the ancestor of the specified solution item. + /// + bool IsAncestorOf(ISolutionItem item); + /// /// Gets the list of direct child items in this solution folder. /// IMutableModelCollection Items { get; } + + /// + /// Loads an existing project from disk and adds it to this solution. + /// + /// Path to the project file + IProject AddExistingProject(FileName fileName); + + /* if (solutionFolderNode.Solution.SolutionFolders.Any( + folder => string.Equals(folder.IdGuid, newProject.IdGuid, StringComparison.OrdinalIgnoreCase))) + { + LoggingService.Warn("ProjectService.AddProject: Duplicate IdGuid detected"); + newProject.IdGuid = Guid.NewGuid(); + } + */ + + /// + /// Adds a link to a file as a solution item. + /// + ISolutionFileItem AddFile(FileName fileName); + + /// + /// Creates a new solution folder with the specified name. + /// + ISolutionFolder CreateFolder(string name); } } diff --git a/src/Main/Base/Project/Project/ISolutionItem.cs b/src/Main/Base/Project/Project/ISolutionItem.cs index ee52b00515..065e7828e0 100644 --- a/src/Main/Base/Project/Project/ISolutionItem.cs +++ b/src/Main/Base/Project/Project/ISolutionItem.cs @@ -32,10 +32,12 @@ namespace ICSharpCode.SharpDevelop.Project /// in order to move the item to another solution. /// ISolution ParentSolution { get; } + + Guid IdGuid { get; } } public interface ISolutionFileItem : ISolutionItem { - FileName FileName { get; } + FileName FileName { get; set; } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs index b627174acc..359c0dd19d 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs @@ -358,9 +358,9 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs NewProjectLocation = cinfo.createdProjects.Count > 0 ? cinfo.createdProjects[0].FileName : ""; if (createNewSolution) { - ProjectService.LoadSolution(NewSolutionLocation); + SD.ProjectService.OpenSolutionOrProject(FileName.Create(NewSolutionLocation)); } else { - AddExistingProjectToSolution.AddProject(SolutionFolderNode, FileName.Create(NewProjectLocation)); + SolutionFolderNode.Folder.AddExistingProject(FileName.Create(NewProjectLocation)); ProjectService.SaveSolution(); } item.Template.RunOpenActions(cinfo); diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs index 1a57c373ef..3c4ccbe458 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs @@ -76,7 +76,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands fdiag.InitialDirectory = AddNewProjectToSolution.GetInitialDirectorySuggestion(solutionFolderNode.Folder); if (fdiag.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK) { foreach (string fileName in fdiag.FileNames) { - solutionFolderNode.Solution.AddExistingProject(FileName.Create(fileName), solutionFolderNode.Folder); + solutionFolderNode.Folder.AddExistingProject(FileName.Create(fileName)); } ProjectService.SaveSolution(); } @@ -115,11 +115,10 @@ namespace ICSharpCode.SharpDevelop.Project.Commands AbstractProjectBrowserTreeNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedNode; ISolutionFolderNode solutionFolderNode = node as ISolutionFolderNode; if (node != null) { - SolutionFolder newSolutionFolder = solutionFolderNode.Solution.CreateFolder(ResourceService.GetString("ProjectComponent.NewFolderString")); - solutionFolderNode.Container.AddFolder(newSolutionFolder); + ISolutionFolder newSolutionFolder = solutionFolderNode.Folder.CreateFolder(ResourceService.GetString("ProjectComponent.NewFolderString")); solutionFolderNode.Solution.Save(); - SolutionFolderNode newSolutionFolderNode = new SolutionFolderNode(solutionFolderNode.Solution, newSolutionFolder); + SolutionFolderNode newSolutionFolderNode = new SolutionFolderNode(newSolutionFolder); newSolutionFolderNode.InsertSorted(node); ProjectBrowserPad.Instance.StartLabelEdit(newSolutionFolderNode); } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs index b479b4c83d..bfe37123f7 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs @@ -133,7 +133,7 @@ namespace ICSharpCode.SharpDevelop.Project } void ProjectServiceSolutionFolderRemoved(object sender, SolutionFolderEventArgs e) { - CallVisitor(new SolutionFolderRemoveVisitor(e.SolutionFolder)); + CallVisitor(new SolutionItemRemoveVisitor(e.SolutionFolder)); } void ProjectServiceProjectItemAdded(object sender, ProjectItemEventArgs e) { @@ -384,7 +384,7 @@ namespace ICSharpCode.SharpDevelop.Project if (treeObject is IProject) { NodeBuilders.AddProjectNode(solutionNode, (IProject)treeObject); } else { - SolutionFolderNode folderNode = new SolutionFolderNode(solution, (ISolutionFolder)treeObject); + SolutionFolderNode folderNode = new SolutionFolderNode((ISolutionFolder)treeObject); folderNode.InsertSorted(solutionNode); } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs index 783a6661ce..4e72d19eb2 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs @@ -645,7 +645,7 @@ namespace ICSharpCode.SharpDevelop.Project } FileProjectItem newItem = AddExistingItemsToProject.CopyFile(fileName, this, true); - IProject sourceProject = ISolution.FindProjectContainingFile(fileName); + IProject sourceProject = SD.ProjectService.FindProjectContainingFile(FileName.Create(fileName)); if (sourceProject != null) { string sourceDirectory = Path.GetDirectoryName(fileName); bool dependendElementsCopied = false; diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs index 3530ddf1c5..7bd6c5403f 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs @@ -68,7 +68,7 @@ namespace ICSharpCode.SharpDevelop.Project Tag = project; if (project.ParentSolution != null) { - project.ParentSolution.Preferences.StartupProjectChanged += OnStartupProjectChanged; + project.ParentSolution.StartupProjectChanged += OnStartupProjectChanged; OnStartupProjectChanged(null, null); } } @@ -77,7 +77,7 @@ namespace ICSharpCode.SharpDevelop.Project { base.Dispose(); if (project.ParentSolution != null) { - project.ParentSolution.Preferences.StartupProjectChanged -= OnStartupProjectChanged; + project.ParentSolution.StartupProjectChanged -= OnStartupProjectChanged; } } @@ -85,7 +85,7 @@ namespace ICSharpCode.SharpDevelop.Project void OnStartupProjectChanged(object sender, EventArgs e) { - bool newIsStartupProject = (this.project == project.ParentSolution.Preferences.StartupProject); + bool newIsStartupProject = (this.project == project.ParentSolution.StartupProject); if (newIsStartupProject != isStartupProject) { isStartupProject = newIsStartupProject; drawDefault = !isStartupProject; @@ -140,8 +140,7 @@ namespace ICSharpCode.SharpDevelop.Project public override void Delete() { - ProjectService.RemoveSolutionFolder(Project.IdGuid); - ProjectService.SaveSolution(); + project.ParentFolder.Items.Remove(project); } public override bool EnableCopy { diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs index 8e5c9aa4da..6fd3189d17 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs @@ -3,8 +3,8 @@ using System; using System.Diagnostics; +using System.Linq; using System.Windows.Forms; - using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; @@ -41,13 +41,13 @@ namespace ICSharpCode.SharpDevelop.Project } } - public SolutionFolderNode(ISolution solution, ISolutionFolder folder) + public SolutionFolderNode(ISolutionFolder folder) { sortOrder = 0; canLabelEdit = true; ContextmenuAddinTreePath = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/SolutionFolderNode"; - this.solution = solution; + this.solution = folder.ParentSolution; this.folder = folder; this.Tag = folder; Text = folder.Name; @@ -63,37 +63,33 @@ namespace ICSharpCode.SharpDevelop.Project if (!FileService.CheckFileName(newName)) { return; } - Text = folder.Location = folder.Name = newName; + Text = folder.Name = newName; solution.Save(); } public void AddItem(string fileName) { - string relativeFileName = FileUtility.GetRelativePath(solution.Directory, fileName); - SolutionItem newItem = new SolutionItem(relativeFileName, relativeFileName); - folder.SolutionItems.Items.Add(newItem); - new SolutionItemNode(solution, newItem).InsertSorted(this); + var newItem = folder.AddFile(FileName.Create(fileName)); + new SolutionItemNode(newItem).InsertSorted(this); } protected override void Initialize() { Nodes.Clear(); - foreach (object treeObject in folder.Folders) { + foreach (var treeObject in folder.Items) { if (treeObject is IProject) { NodeBuilders.AddProjectNode(this, (IProject)treeObject); - } else if (treeObject is SolutionFolder) { - SolutionFolderNode folderNode = new SolutionFolderNode(solution, (SolutionFolder)treeObject); + } else if (treeObject is ISolutionFolder) { + SolutionFolderNode folderNode = new SolutionFolderNode((ISolutionFolder)treeObject); folderNode.InsertSorted(this); + } else if (treeObject is ISolutionFileItem) { + new SolutionItemNode((ISolutionFileItem)treeObject).InsertSorted(this); } else { MessageService.ShowWarning("SolutionFolderNode.Initialize(): unknown tree object : " + treeObject); } } - // add solution items (=files) from project sections. - foreach (SolutionItem item in folder.SolutionItems.Items) { - new SolutionItemNode(ISolution, item).InsertSorted(this); - } base.Initialize(); } @@ -106,7 +102,7 @@ namespace ICSharpCode.SharpDevelop.Project public override void Delete() { - ProjectService.RemoveSolutionFolder(folder.IdGuid); + folder.ParentFolder.Items.Remove(folder); solution.Save(); } @@ -129,29 +125,29 @@ namespace ICSharpCode.SharpDevelop.Project public override void Cut() { DoPerformCut = true; - SD.Clipboard.SetDataObject(new DataObject(typeof(ISolutionItem).ToString(), folder.IdGuid)); + SD.Clipboard.SetDataObject(new DataObject(typeof(ISolutionItem).ToString(), folder.IdGuid.ToString())); } public static bool DoEnablePaste(ISolutionFolderNode container) { - return DoEnablePaste(container, SD.Clipboard.GetDataObject()); + return DoEnablePaste(container.Folder, SD.Clipboard.GetDataObject()); } - static bool DoEnablePaste(ISolutionFolderNode container, System.Windows.IDataObject dataObject) + static bool DoEnablePaste(ISolutionFolder container, System.Windows.IDataObject dataObject) { if (dataObject == null) { return false; } if (dataObject.GetDataPresent(typeof(ISolutionItem).ToString())) { - string guid = dataObject.GetData(typeof(ISolutionItem).ToString()).ToString(); - ISolutionItem solutionFolder = container.Solution.GetSolutionFolder(guid); - if (solutionFolder == null || solutionFolder == container) + Guid guid = Guid.Parse(dataObject.GetData(typeof(ISolutionItem).ToString()).ToString()); + ISolutionItem solutionItem = container.ParentSolution.GetItemByGuid(guid); + if (solutionItem == null || solutionItem == container) return false; - if (solutionFolder is ISolutionFolder) { - return solutionFolder.Parent != container - && !((ISolutionFolder)solutionFolder).IsAncestorOf(container.Folder); + if (solutionItem is ISolutionFolder) { + return solutionItem.ParentFolder != container + && !((ISolutionFolder)solutionItem).IsAncestorOf(container); } else { - return solutionFolder.Parent != container; + return solutionItem.ParentFolder != container; } } return false; @@ -160,7 +156,7 @@ namespace ICSharpCode.SharpDevelop.Project public static void DoPaste(ISolutionFolderNode folderNode) { System.Windows.IDataObject dataObject = SD.Clipboard.GetDataObject(); - if (!DoEnablePaste(folderNode, dataObject)) { + if (!DoEnablePaste(folderNode.Folder, dataObject)) { LoggingService.Warn("SolutionFolderNode.DoPaste: Pasting was not enabled."); return; } @@ -168,10 +164,10 @@ namespace ICSharpCode.SharpDevelop.Project ExtTreeNode folderTreeNode = (ExtTreeNode)folderNode; if (dataObject.GetDataPresent(typeof(ISolutionItem).ToString())) { - string guid = dataObject.GetData(typeof(ISolutionItem).ToString()).ToString(); - ISolutionItem solutionFolder = folderNode.Solution.GetSolutionFolder(guid); - if (solutionFolder != null) { - folderNode.Container.AddFolder(solutionFolder); + Guid guid = Guid.Parse(dataObject.GetData(typeof(ISolutionItem).ToString()).ToString()); + ISolutionItem solutionItem = folderNode.Solution.GetItemByGuid(guid); + if (solutionItem != null) { + folderNode.Folder.Items.Add(solutionItem); ExtTreeView treeView = (ExtTreeView)folderTreeNode.TreeView; foreach (ExtTreeNode node in treeView.CutNodes) { ExtTreeNode oldParent = node.Parent as ExtTreeNode; @@ -212,7 +208,7 @@ namespace ICSharpCode.SharpDevelop.Project if (dataObject.GetDataPresent(typeof(SolutionFolderNode))) { SolutionFolderNode folderNode = (SolutionFolderNode)dataObject.GetData(typeof(SolutionFolderNode)); - if (folderNode.SolutionItem.Parent != this.folder && !folderNode.Folder.IsAncestorOf(SolutionItem)) { + if (!folderNode.Folder.IsAncestorOf(this.folder)) { return DragDropEffects.Move; } } @@ -250,7 +246,7 @@ namespace ICSharpCode.SharpDevelop.Project folderNode.Remove(); folderNode.InsertSorted(this); folderNode.EnsureVisible(); - this.folder.AddFolder(folderNode.SolutionItem); + this.folder.Items.Add(folderNode.Folder); if (parentNode != null) { parentNode.Refresh(); } @@ -260,8 +256,8 @@ namespace ICSharpCode.SharpDevelop.Project SolutionItemNode solutionItemNode = (SolutionItemNode)dataObject.GetData(typeof(SolutionItemNode)); ISolutionFolderNode folderNode = (ISolutionFolderNode)solutionItemNode.Parent; - folderNode.Container.SolutionItems.Items.Remove(solutionItemNode.SolutionItem); - Folder.SolutionItems.Items.Add(solutionItemNode.SolutionItem); + folderNode.Folder.Items.Remove(solutionItemNode.SolutionItem); + Folder.Items.Add(solutionItemNode.SolutionItem); solutionItemNode.Remove(); solutionItemNode.InsertSorted(this); @@ -277,7 +273,7 @@ namespace ICSharpCode.SharpDevelop.Project projectNode.Remove(); projectNode.InsertSorted(this); projectNode.EnsureVisible(); - this.folder.AddFolder(projectNode.Project); + this.folder.Items.Add(projectNode.Project); if (projectNode.Parent != null) { ((ExtTreeNode)projectNode.Parent).Refresh(); diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionItemNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionItemNode.cs index 2918c2e9ba..b74188194a 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionItemNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionItemNode.cs @@ -4,7 +4,7 @@ using System; using System.IO; using System.Windows.Forms; - +using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.SharpDevelop.Project @@ -12,21 +12,21 @@ namespace ICSharpCode.SharpDevelop.Project public class SolutionItemNode : CustomFolderNode { ISolution solution; - ISolutionItem item; + ISolutionFileItem item; - public ISolutionItem SolutionItem { + public ISolutionFileItem SolutionItem { get { return item; } } - public string FileName { + public FileName FileName { get { - return Path.Combine(solution.Directory, item.Location); + return item.FileName; } } - public SolutionItemNode(ISolutionItem item) + public SolutionItemNode(ISolutionFileItem item) { sortOrder = 2; canLabelEdit = true; @@ -71,8 +71,7 @@ namespace ICSharpCode.SharpDevelop.Project public override void Delete() { - ISolutionFolderNode folderNode = Parent as ISolutionFolderNode; - folderNode.Container.SolutionItems.Items.Remove(item); + item.ParentFolder.Items.Remove(item); base.Remove(); } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionNode.cs index feb4506399..69c0a18274 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionNode.cs @@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Project void UpdateText() { Text = ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.ProjectBrowser.SolutionNodeText") + " " + solution.Name; - if (solution.ReadOnly) { + if (solution.IsReadOnly) { Text += StringParser.Parse(" (${res:Global.ReadOnly})"); } } @@ -71,17 +71,16 @@ namespace ICSharpCode.SharpDevelop.Project SolutionFolderNode node = null; foreach (TreeNode n in Nodes) { node = n as SolutionFolderNode; - if (node != null && node.SolutionItem.Name == folderName) { + if (node != null && node.Folder.Name == folderName) { break; } node = null; } if (node == null) { - SolutionFolder newSolutionFolder = solution.CreateFolder(folderName); - solution.AddFolder(newSolutionFolder); + ISolutionFolder newSolutionFolder = solution.CreateFolder(folderName); solution.Save(); - node = new SolutionFolderNode(solution, newSolutionFolder); + node = new SolutionFolderNode(newSolutionFolder); node.InsertSorted(this); } node.AddItem(fileName); @@ -93,7 +92,7 @@ namespace ICSharpCode.SharpDevelop.Project if (dataObject.GetDataPresent(typeof(SolutionFolderNode))) { SolutionFolderNode folderNode = (SolutionFolderNode)dataObject.GetData(typeof(SolutionFolderNode)); - if (folderNode.SolutionItem.Parent != solution) { + if (folderNode.Folder.ParentFolder != solution) { return DragDropEffects.All; } } @@ -120,7 +119,7 @@ namespace ICSharpCode.SharpDevelop.Project folderNode.Remove(); folderNode.InsertSorted(this); - this.solution.AddFolder(folderNode.SolutionItem); + this.solution.Items.Add(folderNode.Folder); } if (dataObject.GetDataPresent(typeof(ProjectNode))) { ProjectNode projectNode = (ProjectNode)dataObject.GetData(typeof(ProjectNode)); @@ -129,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.Project projectNode.Remove(); projectNode.InsertSorted(this); projectNode.EnsureVisible(); - this.solution.AddFolder(projectNode.Project); + this.solution.Items.Add(projectNode.Project); } if (parentNode != null) { diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/Util/SolutionFolderRemoveVisitor.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/Util/SolutionFolderRemoveVisitor.cs index d857b42c79..3a38953df1 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/Util/SolutionFolderRemoveVisitor.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/Util/SolutionFolderRemoveVisitor.cs @@ -6,18 +6,18 @@ using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.SharpDevelop.Project { - public class SolutionFolderRemoveVisitor : ProjectBrowserTreeNodeVisitor + public class SolutionItemRemoveVisitor : ProjectBrowserTreeNodeVisitor { ISolutionItem folder; - public SolutionFolderRemoveVisitor(ISolutionItem folder) + public SolutionItemRemoveVisitor(ISolutionItem folder) { this.folder = folder; } public override object Visit(SolutionFolderNode solutionFolderNode, object data) { - if (folder == solutionFolderNode.SolutionItem) { + if (folder == solutionFolderNode.Folder) { ExtTreeNode parent = solutionFolderNode.Parent as ExtTreeNode; solutionFolderNode.Remove(); if (parent != null) { diff --git a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs index 284e828b56..4cd1938568 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs @@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Gui this.isInitialized = true; } - void ProjectServiceCurrentProjectChanged(object sender, ProjectEventArgs e) + void ProjectServiceCurrentProjectChanged(object sender, EventArgs e) { if (isInitialized) UpdateItems(); diff --git a/src/Main/Base/Project/Src/Internal/ConditionEvaluators/WriteableProjectEvaluator.cs b/src/Main/Base/Project/Src/Internal/ConditionEvaluators/WriteableProjectEvaluator.cs index aa5578505a..00a5f38458 100644 --- a/src/Main/Base/Project/Src/Internal/ConditionEvaluators/WriteableProjectEvaluator.cs +++ b/src/Main/Base/Project/Src/Internal/ConditionEvaluators/WriteableProjectEvaluator.cs @@ -16,7 +16,7 @@ namespace ICSharpCode.SharpDevelop public bool IsValid(object caller, Condition condition) { if (caller is ISolutionFolderNode) - return ProjectService.OpenSolution != null && !ProjectService.OpenSolution.ReadOnly; + return ProjectService.OpenSolution != null && !ProjectService.OpenSolution.IsReadOnly; IProject project = (caller as IProject) ?? ProjectService.CurrentProject; return project != null && !project.IsReadOnly; } diff --git a/src/Main/Base/Project/Src/Internal/ConditionEvaluators/WriteableSolutionEvaluator.cs b/src/Main/Base/Project/Src/Internal/ConditionEvaluators/WriteableSolutionEvaluator.cs index b9064730c1..519f2d5a0d 100644 --- a/src/Main/Base/Project/Src/Internal/ConditionEvaluators/WriteableSolutionEvaluator.cs +++ b/src/Main/Base/Project/Src/Internal/ConditionEvaluators/WriteableSolutionEvaluator.cs @@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop public bool IsValid(object caller, Condition condition) { ISolution solution = ProjectService.OpenSolution; - return (solution != null && !solution.ReadOnly); + return (solution != null && !solution.IsReadOnly); } } } diff --git a/src/Main/Base/Project/Src/Internal/Templates/Project/SolutionDescriptor.cs b/src/Main/Base/Project/Src/Internal/Templates/Project/SolutionDescriptor.cs index 81d7ee4baf..1698868e58 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/Project/SolutionDescriptor.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/Project/SolutionDescriptor.cs @@ -40,16 +40,14 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates { // Create sub projects foreach (SolutionFolderDescriptor folderDescriptor in solutionFoldersDescriptors) { - SolutionFolder folder = solution.CreateFolder(folderDescriptor.name); - parentFolder.AddFolder(folder); + ISolutionFolder folder = parentFolder.CreateFolder(folderDescriptor.name); folderDescriptor.AddContents(solution, projectCreateInformation, defaultLanguage, folder); } foreach (ProjectDescriptor projectDescriptor in projectDescriptors) { IProject newProject = projectDescriptor.CreateProject(projectCreateInformation, defaultLanguage); if (newProject == null) return false; - newProject.Location = FileUtility.GetRelativePath(projectCreateInformation.SolutionPath, newProject.FileName); - parentFolder.AddFolder(newProject); + parentFolder.Items.Add(newProject); } return true; } @@ -110,11 +108,9 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates string solutionLocation = Path.Combine(projectCreateInformation.SolutionPath, newSolutionName + ".sln"); - ISolution newSolution = new Solution(new ProjectChangeWatcher(solutionLocation)); + ISolution newSolution = SD.ProjectService.CreateEmptySolutionFile(FileName.Create(solutionLocation)); projectCreateInformation.Solution = newSolution; - newSolution.Name = newSolutionName; - if (!mainFolder.AddContents(newSolution, projectCreateInformation, defaultLanguage, newSolution)) { newSolution.Dispose(); return null; @@ -126,10 +122,10 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates string question = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Internal.Templates.CombineDescriptor.OverwriteProjectQuestion}", new StringTagPair("combineLocation", solutionLocation)); if (MessageService.AskQuestion(question)) { - newSolution.Save(solutionLocation); + newSolution.Save(); } } else { - newSolution.Save(solutionLocation); + newSolution.Save(); } ProjectService.OnSolutionCreated(new SolutionEventArgs(newSolution)); newSolution.Dispose(); diff --git a/src/Main/Base/Project/Src/Project/AbstractProject.cs b/src/Main/Base/Project/Src/Project/AbstractProject.cs index 333b0dcebf..7f9b79c9ef 100644 --- a/src/Main/Base/Project/Src/Project/AbstractProject.cs +++ b/src/Main/Base/Project/Src/Project/AbstractProject.cs @@ -31,21 +31,14 @@ namespace ICSharpCode.SharpDevelop.Project { // Member documentation: see IProject members. - #region static methods - DO NOT BELONG HERE; PLEASE MOVE - public static string GetConfigurationNameFromKey(string key) - { - int pos = key.IndexOf('|'); - if (pos < 0) - return key; - else - return key.Substring(0, pos); - } + readonly ISolution parentSolution; - public static string GetPlatformNameFromKey(string key) + protected AbstractProject(ISolution parentSolution) { - return key.Substring(key.IndexOf('|') + 1); + if (parentSolution == null) + throw new ArgumentNullException("parentSolution"); + this.parentSolution = parentSolution; } - #endregion #region IDisposable implementation bool isDisposed; @@ -89,7 +82,7 @@ namespace ICSharpCode.SharpDevelop.Project #region Filename / Directory volatile FileName fileName; - string cachedDirectoryName; + DirectoryName cachedDirectoryName; protected IProjectChangeWatcher watcher; /// @@ -154,15 +147,11 @@ namespace ICSharpCode.SharpDevelop.Project /// This member is thread-safe. /// [Browsable(false)] - public string Directory { + public DirectoryName Directory { get { lock (SyncRoot) { if (cachedDirectoryName == null) { - try { - cachedDirectoryName = Path.GetDirectoryName(this.FileName); - } catch (Exception) { - cachedDirectoryName = ""; - } + cachedDirectoryName = this.FileName.GetParentDirectory(); } return cachedDirectoryName; } @@ -211,17 +200,43 @@ namespace ICSharpCode.SharpDevelop.Project } } + sealed class ReadOnlyConfigurationOrPlatformNameCollection : ReadOnlyModelCollection, IConfigurationOrPlatformNameCollection + { + public ReadOnlyConfigurationOrPlatformNameCollection(IEnumerable items) + : base(items) + { + } + + public string ValidateName(string name) + { + return Contains(name) ? name : null; + } + + public void Add(string newName, string copyFrom) + { + throw new NotSupportedException(); + } + + public void Remove(string name) + { + throw new NotSupportedException(); + } + + public void Rename(string oldName, string newName) + { + throw new NotSupportedException(); + } + } + public virtual IConfigurationOrPlatformNameCollection ConfigurationNames { get { - throw new NotImplementedException(); - //return new string[] { "Debug", "Release" }; + return new ReadOnlyConfigurationOrPlatformNameCollection(new[] { "Debug", "Release" }); } } public virtual IConfigurationOrPlatformNameCollection PlatformNames { get { - throw new NotImplementedException(); - //return new string[] { "AnyCPU" }; + return new ReadOnlyConfigurationOrPlatformNameCollection(new[] { "AnyCPU" }); } } @@ -499,9 +514,12 @@ namespace ICSharpCode.SharpDevelop.Project foreach (ProjectSection section in this.ProjectSections) { if (section.Name == "ProjectDependencies") { foreach (SolutionItem item in section.Items) { - foreach (IProject p in ParentSolution.Projects) { - if (p.IdGuid == item.Name) { - result.Add(p); + Guid guid; + if (Guid.TryParse(item.Name, out guid)) { + foreach (IProject p in ParentSolution.Projects) { + if (p.IdGuid == guid) { + result.Add(p); + } } } } @@ -515,25 +533,16 @@ namespace ICSharpCode.SharpDevelop.Project { if (options == null) throw new ArgumentNullException("options"); - string solutionConfiguration = options.SolutionConfiguration ?? ParentSolution.Preferences.ActiveConfiguration; - string solutionPlatform = options.SolutionPlatform ?? ParentSolution.Preferences.ActivePlatform; + string solutionConfiguration = options.SolutionConfiguration ?? ParentSolution.ActiveConfiguration.Configuration; + string solutionPlatform = options.SolutionPlatform ?? ParentSolution.ActiveConfiguration.Platform; // start of default implementation - var configMatchings = this.ParentSolution.GetActiveConfigurationsAndPlatformsForProjects(solutionConfiguration, solutionPlatform); + var projectConfig = this.ConfigurationMapping.GetProjectConfiguration(new ConfigurationAndPlatform(solutionConfiguration, solutionPlatform)); + ProjectBuildOptions projectOptions = new ProjectBuildOptions(isRootBuildable ? options.ProjectTarget : options.TargetForDependencies); projectOptions.BuildOutputVerbosity = options.BuildOutputVerbosity; - // find the project configuration - foreach (var matching in configMatchings) { - if (matching.Project == this) { - projectOptions.Configuration = matching.Configuration; - projectOptions.Platform = matching.Platform; - } - } - // fall back to solution config if we don't find any entries for the project - if (string.IsNullOrEmpty(projectOptions.Configuration)) - projectOptions.Configuration = solutionConfiguration; - if (string.IsNullOrEmpty(projectOptions.Platform)) - projectOptions.Platform = solutionPlatform; + projectOptions.Configuration = projectConfig.Configuration; + projectOptions.Platform = projectConfig.Platform; // copy global properties to project options foreach (var pair in options.GlobalAdditionalProperties) @@ -652,12 +661,7 @@ namespace ICSharpCode.SharpDevelop.Project public virtual bool HasProjectType(Guid projectTypeGuid) { - Guid myGuid; - if (Guid.TryParse(this.TypeGuid, out myGuid)) { - return myGuid == projectTypeGuid; - } else { - return false; - } + return projectTypeGuid == this.TypeGuid; } [Browsable(false)] @@ -668,53 +672,26 @@ namespace ICSharpCode.SharpDevelop.Project } [Browsable(false)] - public virtual string TypeGuid { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } + public virtual Guid TypeGuid { get; set; } [Browsable(false)] - public virtual string IdGuid { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } + public virtual Guid IdGuid { get; set; } - public string Name { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } + [Browsable(false)] + public string Name { get; set; } - public ISolutionFolder ParentFolder { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } + [Browsable(false)] + public ISolutionFolder ParentFolder { get; set; } + [Browsable(false)] public ISolution ParentSolution { - get { - throw new NotImplementedException(); - } + get { return parentSolution; } } + readonly object syncRoot = new object(); + public object SyncRoot { - get { - throw new NotImplementedException(); - } + get { return syncRoot; } } } } diff --git a/src/Main/Base/Project/Src/Project/Behaviors/DotNetStartBehavior.cs b/src/Main/Base/Project/Src/Project/Behaviors/DotNetStartBehavior.cs index 79acce9b36..6985301a24 100644 --- a/src/Main/Base/Project/Src/Project/Behaviors/DotNetStartBehavior.cs +++ b/src/Main/Base/Project/Src/Project/Behaviors/DotNetStartBehavior.cs @@ -115,9 +115,9 @@ namespace ICSharpCode.SharpDevelop.Project UpdateAppConfig(fx); if (Project.OutputType != OutputType.Library) { if (DotnetDetection.IsDotnet45Installed()) { - Project.SetProperty(null, Project.ActivePlatform, "Prefer32Bit", "True", PropertyStorageLocations.PlatformSpecific, true); + Project.SetProperty(null, Project.ActiveConfiguration.Platform, "Prefer32Bit", "True", PropertyStorageLocations.PlatformSpecific, true); } else { - Project.SetProperty(null, Project.ActivePlatform, "PlatformTarget", "x86", PropertyStorageLocations.PlatformSpecific, true); + Project.SetProperty(null, Project.ActiveConfiguration.Platform, "PlatformTarget", "x86", PropertyStorageLocations.PlatformSpecific, true); } } base.ProjectCreationComplete(); @@ -136,12 +136,12 @@ namespace ICSharpCode.SharpDevelop.Project public override CompilerVersion CurrentCompilerVersion { get { switch (Project.MinimumSolutionVersion) { - case ISolution.SolutionVersionVS2005: + case SolutionFormatVersion.VS2005: return CompilerVersion.MSBuild20; - case ISolution.SolutionVersionVS2008: + case SolutionFormatVersion.VS2008: return CompilerVersion.MSBuild35; - case ISolution.SolutionVersionVS2010: - case ISolution.SolutionVersionVS2012: + case SolutionFormatVersion.VS2010: + case SolutionFormatVersion.VS2012: return CompilerVersion.MSBuild40; default: throw new NotSupportedException(); diff --git a/src/Main/Base/Project/Src/Project/Behaviors/ProjectBehaviorSupportedConditionEvaluator.cs b/src/Main/Base/Project/Src/Project/Behaviors/ProjectBehaviorSupportedConditionEvaluator.cs index 2c45c6b35b..37b2ab8f64 100644 --- a/src/Main/Base/Project/Src/Project/Behaviors/ProjectBehaviorSupportedConditionEvaluator.cs +++ b/src/Main/Base/Project/Src/Project/Behaviors/ProjectBehaviorSupportedConditionEvaluator.cs @@ -19,17 +19,7 @@ namespace ICSharpCode.SharpDevelop.Project IProject project = owner as IProject ?? ProjectService.CurrentProject; if (project == null) return false; - // TODO: simplify this once HasProjectType() is part of IProject - AbstractProject p2 = project as AbstractProject; - if (p2 != null) { - return p2.HasProjectType(conditionGuid); - } else { - Guid projectGuid; - if (Guid.TryParse(project.TypeGuid, out projectGuid)) - return conditionGuid == projectGuid; - else - return false; - } + return project.HasProjectType(conditionGuid); } } } diff --git a/src/Main/Base/Project/Src/Project/Behaviors/ResXConverter.cs b/src/Main/Base/Project/Src/Project/Behaviors/ResXConverter.cs index a3def5dedd..3dc3093395 100644 --- a/src/Main/Base/Project/Src/Project/Behaviors/ResXConverter.cs +++ b/src/Main/Base/Project/Src/Project/Behaviors/ResXConverter.cs @@ -7,12 +7,13 @@ using System.IO; using System.Linq; using System.Resources; using System.Text; +using ICSharpCode.Core; namespace ICSharpCode.SharpDevelop.Project { public static class ResXConverter { - public static string ConvertTypeName(Type type, string fileName, CompilableProject project = null) + public static string ConvertTypeName(Type type, FileName fileName, CompilableProject project = null) { Version version; if (project == null) @@ -28,11 +29,9 @@ namespace ICSharpCode.SharpDevelop.Project static readonly Version DotNet40 = new Version(4, 0); static readonly Version DotNet20 = new Version(2, 0); - static Version GetTargetFrameworkVersionFrom(string fileName) + static Version GetTargetFrameworkVersionFrom(FileName fileName) { - if (ProjectService.OpenSolution == null) - return DotNet40; - var project = ProjectService.OpenSolution.FindProjectContainingFile(fileName) as CompilableProject; + var project = SD.ProjectService.FindProjectContainingFile(fileName) as CompilableProject; if (project == null) return DotNet40; return ScanVersion(project.TargetFrameworkVersion); @@ -71,7 +70,7 @@ namespace ICSharpCode.SharpDevelop.Project foreach (var resXFile in project.Items.OfType().Where(f => ".resx".Equals(Path.GetExtension(f.FileName), StringComparison.OrdinalIgnoreCase))) { using (var buffer = new MemoryStream()) { using (var reader = new ResXResourceReader(resXFile.FileName) { UseResXDataNodes = true }) - using (var writer = new ResXResourceWriter(buffer, t => ConvertTypeName(t, resXFile.FileName, project))) { + using (var writer = new ResXResourceWriter(buffer, t => ConvertTypeName(t, FileName.Create(resXFile.FileName), project))) { foreach (DictionaryEntry entry in reader) { writer.AddResource(entry.Key.ToString(), entry.Value); } diff --git a/src/Main/Base/Project/Src/Project/CompilableProject.cs b/src/Main/Base/Project/Src/Project/CompilableProject.cs index c801be3a52..cbc737befb 100644 --- a/src/Main/Base/Project/Src/Project/CompilableProject.cs +++ b/src/Main/Base/Project/Src/Project/CompilableProject.cs @@ -241,7 +241,7 @@ namespace ICSharpCode.SharpDevelop.Project } [Browsable(false)] - public override string TypeGuid { + public override Guid TypeGuid { get { return ProjectBindingService.GetCodonPerLanguageName(Language).Guid; } @@ -282,7 +282,7 @@ namespace ICSharpCode.SharpDevelop.Project [Browsable(false)] public virtual bool UpgradeDesired { get { - return MinimumSolutionVersion < ISolution.SolutionVersionVS2010; + return MinimumSolutionVersion < SolutionFormatVersion.VS2010; } } diff --git a/src/Main/Base/Project/Src/Project/ContextSpecificProperties.cs b/src/Main/Base/Project/Src/Project/ContextSpecificProperties.cs index 4da522363d..c3d01b27a5 100644 --- a/src/Main/Base/Project/Src/Project/ContextSpecificProperties.cs +++ b/src/Main/Base/Project/Src/Project/ContextSpecificProperties.cs @@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop.Project { ProjectItem p = (ProjectItem)component; p.SetEvaluatedMetadata(Name, (string)value); - p.InformSetValue(this, component, value); + p.InformSetValue(this, value); if (runCustomTool) { FileProjectItem fpi = p as FileProjectItem; if (fpi != null) { diff --git a/src/Main/Base/Project/Src/Project/Converter/LanguageConverter.cs b/src/Main/Base/Project/Src/Project/Converter/LanguageConverter.cs index 64666a6274..5ca6c3a4b5 100644 --- a/src/Main/Base/Project/Src/Project/Converter/LanguageConverter.cs +++ b/src/Main/Base/Project/Src/Project/Converter/LanguageConverter.cs @@ -84,7 +84,7 @@ namespace ICSharpCode.SharpDevelop.Project.Converter } // use the newly created IdGuid instead of the copied one - tp.SetProperty(MSBuildBasedProject.ProjectGuidPropertyName, tp.IdGuid); + tp.SetProperty(MSBuildBasedProject.ProjectGuidPropertyName, tp.IdGuid.ToString("B").ToUpperInvariant()); } } } @@ -199,7 +199,7 @@ namespace ICSharpCode.SharpDevelop.Project.Converter while (node != null) { if (node is ISolutionFolderNode) { var solutionFolderNode = (ISolutionFolderNode)node; - solutionFolderNode.Solution.AddExistingProject(targetProject.FileName, solutionFolderNode.Folder); + solutionFolderNode.Folder.AddExistingProject(targetProject.FileName); ProjectService.SaveSolution(); break; } diff --git a/src/Main/Base/Project/Src/Project/CustomTool.cs b/src/Main/Base/Project/Src/Project/CustomTool.cs index ce1bab4f7b..7bf5c561c9 100644 --- a/src/Main/Base/Project/Src/Project/CustomTool.cs +++ b/src/Main/Base/Project/Src/Project/CustomTool.cs @@ -360,9 +360,7 @@ namespace ICSharpCode.SharpDevelop.Project static void OnFileSaved(object sender, FileNameEventArgs e) { - ISolution solution = ProjectService.OpenSolution; - if (solution == null) return; - IProject project = solution.FindProjectContainingFile(e.FileName); + IProject project = SD.ProjectService.FindProjectContainingFile(e.FileName); if (project == null) return; FileProjectItem item = project.FindFile(e.FileName); if (item == null) return; diff --git a/src/Main/Base/Project/Src/Project/IProject.cs b/src/Main/Base/Project/Src/Project/IProject.cs index 781bff54dd..7065507a6a 100644 --- a/src/Main/Base/Project/Src/Project/IProject.cs +++ b/src/Main/Base/Project/Src/Project/IProject.cs @@ -28,6 +28,15 @@ namespace ICSharpCode.SharpDevelop.Project public interface IProject : IBuildable, ISolutionItem, IDisposable, IMementoCapable, IConfigurable { + /// + /// Gets the object used for thread-safe synchronization. + /// Thread-safe members lock on this object, but if you manipulate underlying structures + /// (such as the MSBuild project for MSBuildBasedProjects) directly, you will have to lock on this object. + /// + object SyncRoot { + get; + } + /// /// Gets the list of items in the project. This member is thread-safe. /// The returned collection is guaranteed not to change - adding new items or removing existing items @@ -80,8 +89,7 @@ namespace ICSharpCode.SharpDevelop.Project /// Only the getter is thread-safe. /// /// - /// Name already exists in ISolutionFolder, it's repeated here to prevent - /// the ambiguity with IBuildable.Name. + /// Name already exists in IBuildable; we're adding the setter here. /// new string Name { get; @@ -95,7 +103,7 @@ namespace ICSharpCode.SharpDevelop.Project /// /// This member is thread-safe. /// - string Directory { + DirectoryName Directory { get; } @@ -303,6 +311,11 @@ namespace ICSharpCode.SharpDevelop.Project /// Never returns null, but may return a permanently empty collection if this project does not support such models. /// ITypeDefinitionModelCollection TypeDefinitionModels { get; } + + /// + /// Gets/Sets the primary type GUID of the project. + /// + Guid TypeGuid { get; set; } } /// diff --git a/src/Main/Base/Project/Src/Project/Items/ProjectReferenceProjectItem.cs b/src/Main/Base/Project/Src/Project/Items/ProjectReferenceProjectItem.cs index eb536a4a38..c585f3d009 100644 --- a/src/Main/Base/Project/Src/Project/Items/ProjectReferenceProjectItem.cs +++ b/src/Main/Base/Project/Src/Project/Items/ProjectReferenceProjectItem.cs @@ -23,12 +23,16 @@ namespace ICSharpCode.SharpDevelop.Project } [ReadOnly(true)] - public string ProjectGuid { + public Guid ProjectGuid { get { - return GetEvaluatedMetadata("Project"); + Guid guid; + if (Guid.TryParse(GetEvaluatedMetadata("Project"), out guid)) + return guid; + else + return Guid.Empty; } set { - SetEvaluatedMetadata("Project", value); + SetEvaluatedMetadata("Project", value.ToString("B").ToUpperInvariant()); } } diff --git a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs index 6a5e60ecad..9b26a791f7 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs @@ -37,10 +37,8 @@ namespace ICSharpCode.SharpDevelop.Project /// /// The project collection that contains this project. /// - ProjectCollection projectCollection; - internal ProjectCollection MSBuildProjectCollection { - get { return projectCollection; } + get { return ParentSolution.MSBuildProjectCollection; } } /// @@ -154,11 +152,11 @@ namespace ICSharpCode.SharpDevelop.Project #region Create new project public MSBuildBasedProject(ProjectCreateInformation information) + : base(information.Solution) { - this.projectCollection = information.Solution.MSBuildProjectCollection; - this.projectFile = ProjectRootElement.Create(projectCollection); - this.userProjectFile = ProjectRootElement.Create(projectCollection); - this.ActivePlatform = information.Platform; + this.projectFile = ProjectRootElement.Create(MSBuildProjectCollection); + this.userProjectFile = ProjectRootElement.Create(MSBuildProjectCollection); + this.ActiveConfiguration = new ConfigurationAndPlatform("Debug", information.Platform); Name = information.ProjectName; FileName = information.OutputProjectFileName; @@ -168,13 +166,11 @@ namespace ICSharpCode.SharpDevelop.Project projectFile.DefaultTargets = "Build"; userProjectFile.FullPath = information.OutputProjectFileName + ".user"; - base.IdGuid = "{" + Guid.NewGuid().ToString().ToUpperInvariant() + "}"; - projectFile.AddProperty(ProjectGuidPropertyName, IdGuid); + base.IdGuid = Guid.NewGuid(); + projectFile.AddProperty(ProjectGuidPropertyName, IdGuid.ToString("B").ToUpperInvariant()); AddGuardedProperty("Configuration", "Debug"); AddGuardedProperty("Platform", information.Platform); - this.ActiveConfiguration = "Debug"; - this.ActivePlatform = information.Platform; if (information.Platform == "x86") SetProperty(null, information.Platform, "PlatformTarget", "x86", PropertyStorageLocations.PlatformSpecific, false); else @@ -287,7 +283,7 @@ namespace ICSharpCode.SharpDevelop.Project /// The raw value of the property, or null if the property doesn't exist public string GetUnevalatedProperty(string propertyName) { - return GetUnevalatedProperty(this.ActiveConfiguration, this.ActivePlatform, propertyName); + return GetUnevalatedProperty(this.ActiveConfiguration.Configuration, this.ActiveConfiguration.Platform, propertyName); } /// @@ -345,7 +341,7 @@ namespace ICSharpCode.SharpDevelop.Project void UnloadCurrentlyOpenProject() { if (currentlyOpenProject != null) { - MSBuildInternals.UnloadProject(projectCollection, currentlyOpenProject); + MSBuildInternals.UnloadProject(MSBuildProjectCollection, currentlyOpenProject); currentlyOpenProject = null; } } @@ -404,7 +400,7 @@ namespace ICSharpCode.SharpDevelop.Project InitializeMSBuildProjectProperties(globalProps); globalProps["Configuration"] = configuration; globalProps["Platform"] = platform; - MSBuild.Project project = MSBuildInternals.LoadProject(projectCollection, projectFile, globalProps); + MSBuild.Project project = MSBuildInternals.LoadProject(MSBuildProjectCollection, projectFile, globalProps); if (openCurrentConfiguration) currentlyOpenProject = project; return new ConfiguredProject(this, project, !openCurrentConfiguration); @@ -456,7 +452,7 @@ namespace ICSharpCode.SharpDevelop.Project { try { if (unloadProjectOnDispose) { - MSBuildInternals.UnloadProject(p.projectCollection, this.Project); + MSBuildInternals.UnloadProject(p.MSBuildProjectCollection, this.Project); } } finally { System.Threading.Monitor.Exit(p.SyncRoot); @@ -530,10 +526,9 @@ namespace ICSharpCode.SharpDevelop.Project var property = g.Properties.FirstOrDefault(p => MSBuildInternals.PropertyNameComparer.Equals(p.Name, propertyName)); if (property == null) continue; - string gConfiguration, gPlatform; - MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition, - out gConfiguration, - out gPlatform); + var configFromCondition = ConfigurationAndPlatform.FromCondition(g.Condition); + string gConfiguration = configFromCondition.Configuration; + string gPlatform = configFromCondition.Platform; if ((configuration == null || configuration == gConfiguration || gConfiguration == null) && (platform == null || platform == gPlatform || gPlatform == null)) { @@ -635,7 +630,7 @@ namespace ICSharpCode.SharpDevelop.Project /// public void SetProperty(string propertyName, string newValue, bool treatPropertyValueAsLiteral) { - SetProperty(ActiveConfiguration, ActivePlatform, propertyName, newValue, + SetProperty(ActiveConfiguration.Configuration, ActiveConfiguration.Platform, propertyName, newValue, PropertyStorageLocations.Unchanged, treatPropertyValueAsLiteral); } @@ -725,7 +720,7 @@ namespace ICSharpCode.SharpDevelop.Project foreach (KeyValuePair pair in oldValuesConf) { if (pair.Value != null) { MSBuildSetProperty(targetProject, propertyName, pair.Value, - CreateCondition(pair.Key, null, location), + ConfigurationAndPlatform.CreateCondition(pair.Key, null, location), propertyInsertionPosition, false); } @@ -745,7 +740,7 @@ namespace ICSharpCode.SharpDevelop.Project foreach (KeyValuePair pair in oldValuesPlat) { if (pair.Value != null) { MSBuildSetProperty(targetProject, propertyName, pair.Value, - CreateCondition(null, pair.Key, location), + ConfigurationAndPlatform.CreateCondition(null, pair.Key, location), propertyInsertionPosition, false); } @@ -767,7 +762,7 @@ namespace ICSharpCode.SharpDevelop.Project foreach (KeyValuePair pair in oldValues) { if (pair.Value != null) { MSBuildSetProperty(targetProject, propertyName, pair.Value, - CreateCondition(pair.Key.Item1, pair.Key.Item2, location), + ConfigurationAndPlatform.CreateCondition(pair.Key.Item1, pair.Key.Item2, location), propertyInsertionPosition, false); } @@ -813,7 +808,7 @@ namespace ICSharpCode.SharpDevelop.Project } else if (newValue != null) { // create new property MSBuildSetProperty(targetProject, propertyName, newValue, - CreateCondition(configuration, platform, location), + ConfigurationAndPlatform.CreateCondition(configuration, platform, location), propertyInsertionPosition, treatPropertyValueAsLiteral); } @@ -914,47 +909,6 @@ namespace ICSharpCode.SharpDevelop.Project project.RemoveChild(propertyGroup); } } - - /// - /// Creates an MSBuild condition string. - /// At most one of configuration and platform can be null. - /// - internal static string CreateCondition(string configuration, string platform) - { - if (configuration == null) - return CreateCondition(configuration, platform, PropertyStorageLocations.PlatformSpecific); - else if (platform == null) - return CreateCondition(configuration, platform, PropertyStorageLocations.ConfigurationSpecific); - else - return CreateCondition(configuration, platform, PropertyStorageLocations.ConfigurationAndPlatformSpecific); - } - - /// - /// Creates an MSBuild condition string. - /// configuration and platform may be only null if they are not required (as specified by the - /// storage location), otherwise an ArgumentNullException is thrown. - /// - internal static string CreateCondition(string configuration, string platform, PropertyStorageLocations location) - { - switch (location & PropertyStorageLocations.ConfigurationAndPlatformSpecific) { - case PropertyStorageLocations.ConfigurationSpecific: - if (configuration == null) - throw new ArgumentNullException("configuration"); - return " '$(Configuration)' == '" + configuration + "' "; - case PropertyStorageLocations.PlatformSpecific: - if (platform == null) - throw new ArgumentNullException("platform"); - return " '$(Platform)' == '" + platform + "' "; - case PropertyStorageLocations.ConfigurationAndPlatformSpecific: - if (platform == null) - throw new ArgumentNullException("platform"); - if (configuration == null) - throw new ArgumentNullException("configuration"); - return " '$(Configuration)|$(Platform)' == '" + configuration + "|" + platform + "' "; - default: - return null; - } - } #endregion #region IProjectItemListProvider interface @@ -1127,18 +1081,19 @@ namespace ICSharpCode.SharpDevelop.Project { ProjectBuildOptions projectOptions = base.CreateProjectBuildOptions(options, isRootBuildable); ISolution solution = this.ParentSolution; - string solutionConfiguration = options.SolutionConfiguration ?? solution.ActiveConfiguration.Configuration; - string solutionPlatform = options.SolutionPlatform ?? solution.ActiveConfiguration.Platform; + var solutionConfiguration = new ConfigurationAndPlatform( + options.SolutionConfiguration ?? solution.ActiveConfiguration.Configuration, + options.SolutionPlatform ?? solution.ActiveConfiguration.Platform); - var configMatchings = solution.GetActiveConfigurationsAndPlatformsForProjects(solutionConfiguration, solutionPlatform); // Find the project configuration, and build an XML string containing all configurations from the solution StringWriter solutionConfigurationXml = new StringWriter(); using (XmlTextWriter solutionConfigurationWriter = new XmlTextWriter(solutionConfigurationXml)) { solutionConfigurationWriter.WriteStartElement("SolutionConfiguration"); - foreach (var matching in configMatchings) { + foreach (var project in solution.Projects) { + var projectConfiguration = project.ConfigurationMapping.GetProjectConfiguration(solutionConfiguration); solutionConfigurationWriter.WriteStartElement("ProjectConfiguration"); - solutionConfigurationWriter.WriteAttributeString("Project", matching.Project.IdGuid); - solutionConfigurationWriter.WriteValue(matching.Configuration + "|" + MSBuildInternals.FixPlatformNameForProject(matching.Platform)); + solutionConfigurationWriter.WriteAttributeString("Project", project.IdGuid.ToString("B").ToUpperInvariant()); + solutionConfigurationWriter.WriteValue(projectConfiguration.ToString()); solutionConfigurationWriter.WriteEndElement(); } solutionConfigurationWriter.WriteEndElement(); @@ -1147,7 +1102,7 @@ namespace ICSharpCode.SharpDevelop.Project // which is necessary to resolve the referenced project's OutputPath. projectOptions.Properties["CurrentSolutionConfigurationContents"] = solutionConfigurationXml.ToString(); - solution.AddMSBuildSolutionProperties(projectOptions.Properties); + MSBuildInternals.AddMSBuildSolutionProperties(solution, projectOptions.Properties); return projectOptions; } @@ -1179,9 +1134,8 @@ namespace ICSharpCode.SharpDevelop.Project } public MSBuildBasedProject(ProjectLoadInformation loadInformation) + : base(loadInformation.Solution) { - if (loadInformation == null) - throw new ArgumentNullException("loadInformation"); this.Name = loadInformation.ProjectName; isLoading = true; try { @@ -1244,14 +1198,10 @@ namespace ICSharpCode.SharpDevelop.Project void LoadProjectInternal(ProjectLoadInformation loadInformation) { - this.projectCollection = loadInformation.MSBuildProjectCollection; this.FileName = loadInformation.FileName; - if (loadInformation.Configuration != null) - this.ActiveConfiguration = loadInformation.Configuration; - if (loadInformation.Platform != null) - this.ActivePlatform = loadInformation.Platform; + this.ActiveConfiguration = loadInformation.Configuration; - projectFile = ProjectRootElement.Open(loadInformation.FileName, projectCollection); + projectFile = ProjectRootElement.Open(loadInformation.FileName, MSBuildProjectCollection); if (loadInformation.upgradeToolsVersion == true && CanUpgradeToolsVersion()) { projectFile.ToolsVersion = autoUpgradeNewToolsVersion; } @@ -1259,30 +1209,33 @@ namespace ICSharpCode.SharpDevelop.Project string userFileName = loadInformation.FileName + ".user"; if (File.Exists(userFileName)) { try { - userProjectFile = ProjectRootElement.Open(userFileName, projectCollection); + userProjectFile = ProjectRootElement.Open(userFileName, MSBuildProjectCollection); } catch (InvalidProjectFileException ex) { throw new ProjectLoadException("Error loading user part " + userFileName + ":\n" + ex.Message, ex); } } else { - userProjectFile = ProjectRootElement.Create(userFileName, projectCollection); + userProjectFile = ProjectRootElement.Create(userFileName, MSBuildProjectCollection); } - this.ActiveConfiguration = GetEvaluatedProperty("Configuration") ?? this.ActiveConfiguration; - this.ActivePlatform = GetEvaluatedProperty("Platform") ?? this.ActivePlatform; + this.ActiveConfiguration = new ConfigurationAndPlatform( + GetEvaluatedProperty("Configuration") ?? this.ActiveConfiguration.Configuration, + GetEvaluatedProperty("Platform") ?? this.ActiveConfiguration.Platform); CreateItemsListFromMSBuild(); LoadConfigurationPlatformNamesFromMSBuild(); - base.IdGuid = GetEvaluatedProperty(ProjectGuidPropertyName); + Guid guid; + if (Guid.TryParse(GetEvaluatedProperty(ProjectGuidPropertyName), out guid)) + base.IdGuid = guid; } [Browsable(false)] - public override string IdGuid { + public override Guid IdGuid { get { return base.IdGuid; } set { if (base.IdGuid == null) { // Save the GUID in the project if the project does not yet have a GUID. - SetPropertyInternal(null, null, ProjectGuidPropertyName, value, PropertyStorageLocations.Base, true); + SetPropertyInternal(null, null, ProjectGuidPropertyName, value.ToString("B").ToUpperInvariant(), PropertyStorageLocations.Base, true); } base.IdGuid = value; } @@ -1348,7 +1301,7 @@ namespace ICSharpCode.SharpDevelop.Project } } } - */ + */ protected void InvalidateConfigurationPlatformNames() { lock (SyncRoot) { @@ -1396,13 +1349,12 @@ namespace ICSharpCode.SharpDevelop.Project platformNames.Add(prop.Value); } } else { - string gConfiguration, gPlatform; - MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition, out gConfiguration, out gPlatform); - if (gConfiguration != null) { - configurationNames.Add(gConfiguration); + var configFromCondition = ConfigurationAndPlatform.FromCondition(g.Condition); + if (configFromCondition.Configuration != null) { + configurationNames.Add(configFromCondition.Configuration); } - if (gPlatform != null) { - platformNames.Add(gPlatform); + if (configFromCondition.Platform != null) { + platformNames.Add(configFromCondition.Platform); } } } @@ -1600,7 +1552,7 @@ namespace ICSharpCode.SharpDevelop.Project return true; } } - */ + */ #endregion #region ProjectExtensions @@ -1677,7 +1629,7 @@ namespace ICSharpCode.SharpDevelop.Project { string guidList = GetEvaluatedProperty("ProjectTypeGuids"); if (string.IsNullOrEmpty(guidList)) - guidList = this.TypeGuid; + guidList = this.TypeGuid.ToString("B").ToUpperInvariant(); SetProperty("ProjectTypeGuids", guidList + ";" + projectTypeGuid.ToString("B").ToUpperInvariant(), false); InvalidateBehavior(); } diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs index 390a7c3424..7e52ecd909 100755 --- a/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs @@ -267,7 +267,7 @@ namespace ICSharpCode.SharpDevelop.Project } tcs = new TaskCompletionSource(); - if (projectMinimumSolutionVersion <= ISolution.SolutionVersionVS2008) { + if (projectMinimumSolutionVersion <= SolutionFormatVersion.VS2008) { if (DotnetDetection.IsDotnet35SP1Installed()) { BuildWorkerManager.MSBuild35.RunBuildJob(job, loggerChain, OnDone, cancellationToken); } else { @@ -319,7 +319,7 @@ namespace ICSharpCode.SharpDevelop.Project // 'MsTestToolsTargets' is preferred because it's at the end of the MSBuild 3.5 and 4.0 target file, // but on MSBuild 2.0 we need to fall back to 'CodeAnalysisTargets'. string hijackedProperty = "MsTestToolsTargets"; - if (projectMinimumSolutionVersion == ISolution.SolutionVersionVS2005) + if (projectMinimumSolutionVersion == SolutionFormatVersion.VS2005) hijackedProperty = "CodeAnalysisTargets"; // because we'll replace the hijackedProperty, manually write the corresponding include diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine/TargetingPackWarningWorkaround.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine/TargetingPackWarningWorkaround.cs index 2b8626d850..7cd675b1fb 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildEngine/TargetingPackWarningWorkaround.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine/TargetingPackWarningWorkaround.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.SharpDevelop.Project public IMSBuildChainedLoggerFilter CreateFilter(MSBuildEngine engine, IMSBuildChainedLoggerFilter nextFilter) { - if (engine.ProjectMinimumSolutionVersion >= ISolution.SolutionVersionVS2010) { + if (engine.ProjectMinimumSolutionVersion >= SolutionFormatVersion.VS2010) { return new TargetingPackWarningWorkaroundChainEntry(nextFilter); } else { return nextFilter; diff --git a/src/Main/Base/Project/Src/Project/MSBuildFileProject.cs b/src/Main/Base/Project/Src/Project/MSBuildFileProject.cs index 3270124b35..e03299c23e 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildFileProject.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildFileProject.cs @@ -13,11 +13,10 @@ namespace ICSharpCode.SharpDevelop.Project /// public class MSBuildFileProject : AbstractProject { - public MSBuildFileProject(FileName fileName, string title) + public MSBuildFileProject(ISolution parentSolution, FileName fileName, string title) : base(parentSolution) { Name = title; FileName = fileName; - TypeGuid = "{00000000-0000-0000-0000-000000000000}"; } public override Task BuildAsync(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, IProgressMonitor progressMonitor) diff --git a/src/Main/Base/Project/Src/Project/MSBuildInternals.cs b/src/Main/Base/Project/Src/Project/MSBuildInternals.cs index 75255d2330..a48aafbdd0 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildInternals.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildInternals.cs @@ -59,6 +59,15 @@ namespace ICSharpCode.SharpDevelop.Project } } + public static void AddMSBuildSolutionProperties(ISolution solution, IDictionary propertyDict) + { + propertyDict["SolutionDir"] = solution.Directory.ToStringWithTrailingBackslash(); + propertyDict["SolutionExt"] = ".sln"; + propertyDict["SolutionFileName"] = solution.FileName.GetFileName(); + propertyDict["SolutionName"] = solution.Name ?? string.Empty; + propertyDict["SolutionPath"] = solution.FileName; + } + public const string MSBuildXmlNamespace = "http://schemas.microsoft.com/developer/msbuild/2003"; #region Escaping @@ -174,7 +183,7 @@ namespace ICSharpCode.SharpDevelop.Project } List targets = new List(); - if (baseProject.MinimumSolutionVersion >= ISolution.SolutionVersionVS2010) { + if (baseProject.MinimumSolutionVersion >= SolutionFormatVersion.VS2010) { targets.Add("ResolveReferences"); targets.Add("DesignTimeResolveAssemblyReferences"); } else { diff --git a/src/Main/Base/Project/Src/Project/MSBuildItemDefinitionGroup.cs b/src/Main/Base/Project/Src/Project/MSBuildItemDefinitionGroup.cs index 995d40601a..cc1ce13cab 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildItemDefinitionGroup.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildItemDefinitionGroup.cs @@ -38,8 +38,8 @@ namespace ICSharpCode.SharpDevelop.Project } } - public MSBuildItemDefinitionGroup(MSBuildBasedProject project, string configuration, string platform) - : this(project, MSBuildBasedProject.CreateCondition(configuration, platform)) + public MSBuildItemDefinitionGroup(MSBuildBasedProject project, ConfigurationAndPlatform configuration) + : this(project, configuration.ToCondition()) { } diff --git a/src/Main/Base/Project/Src/Project/MissingProject.cs b/src/Main/Base/Project/Src/Project/MissingProject.cs index 8d4906a955..4c5c9da162 100644 --- a/src/Main/Base/Project/Src/Project/MissingProject.cs +++ b/src/Main/Base/Project/Src/Project/MissingProject.cs @@ -8,11 +8,10 @@ namespace ICSharpCode.SharpDevelop.Project { public class MissingProject : AbstractProject { - public MissingProject(FileName fileName, string title) + public MissingProject(ISolution parentSolution, FileName fileName, string title) : base(parentSolution) { Name = title; FileName = fileName; - TypeGuid = "{00000000-0000-0000-0000-000000000000}"; } public override bool IsReadOnly { diff --git a/src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs b/src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs index eddf3c69f4..61b89f0a7b 100644 --- a/src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs +++ b/src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs @@ -12,11 +12,11 @@ namespace ICSharpCode.SharpDevelop.Project /// public class ProjectLoadInformation { - public ISolution ParentSolution { get; private set; } + public ISolution Solution { get; private set; } public FileName FileName { get; private set; } public ConfigurationAndPlatform Configuration { get; set; } public string ProjectName { get; private set; } - public string TypeGuid { get; set; } + public Guid TypeGuid { get; set; } public IList ProjectSections {get; set;} /// @@ -53,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Project throw new ArgumentNullException("fileName"); if (projectName == null) throw new ArgumentNullException("projectName"); - this.ParentSolution = parentSolution; + this.Solution = parentSolution; this.FileName = fileName; this.ProjectName = projectName; this.InitializeTypeSystem = true; diff --git a/src/Main/Base/Project/Src/Project/Solution/Project_TypeGuids.cs b/src/Main/Base/Project/Src/Project/Solution/Project_TypeGuids.cs index d73ec0e207..ea28fbd022 100644 --- a/src/Main/Base/Project/Src/Project/Solution/Project_TypeGuids.cs +++ b/src/Main/Base/Project/Src/Project/Solution/Project_TypeGuids.cs @@ -15,13 +15,13 @@ namespace ICSharpCode.SharpDevelop.Project /// public static class ProjectTypeGuids { - public const string CSharp = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"; - public const string VBNet = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"; - public const string CPlusPlus = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; + public static readonly Guid CSharp = Guid.Parse("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"); + public static readonly Guid VBNet = Guid.Parse("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"); + public static readonly Guid CPlusPlus = Guid.Parse("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"); - public const string WebApplication = "{349C5851-65DF-11DA-9384-00065B846F21}"; - public const string WebSite = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}"; - public const string Silverlight = "{A1591282-1198-4647-A2B1-27E5FF5F6F3B}"; + public static readonly Guid WebApplication = Guid.Parse("{349C5851-65DF-11DA-9384-00065B846F21}"); + public static readonly Guid WebSite = Guid.Parse("{E24C65DC-7377-472B-9ABA-BC803B73C61A}"); + public static readonly Guid Silverlight = Guid.Parse("{A1591282-1198-4647-A2B1-27E5FF5F6F3B}"); public static readonly Guid PortableLibrary = Guid.Parse("{786C830F-07A1-408B-BD7F-6EE04809D6DB}"); } } diff --git a/src/Main/Base/Project/Src/Project/UnknownProject.cs b/src/Main/Base/Project/Src/Project/UnknownProject.cs index 4f56b4abcc..14587eb665 100644 --- a/src/Main/Base/Project/Src/Project/UnknownProject.cs +++ b/src/Main/Base/Project/Src/Project/UnknownProject.cs @@ -27,8 +27,8 @@ namespace ICSharpCode.SharpDevelop.Project MessageService.ShowError("Error loading " + this.FileName + ":\n" + warningText); } - public UnknownProject(FileName fileName, string title, string warningText, bool displayWarningToUser) - : this(fileName, title) + public UnknownProject(ISolution parentSolution, FileName fileName, string title, string warningText, bool displayWarningToUser) + : this(parentSolution, fileName, title) { this.warningText = warningText; if (displayWarningToUser) { @@ -36,11 +36,11 @@ namespace ICSharpCode.SharpDevelop.Project } } - public UnknownProject(FileName fileName, string title) + public UnknownProject(ISolution parentSolution, FileName fileName, string title) + : base(parentSolution) { Name = title; FileName = fileName; - TypeGuid = "{00000000-0000-0000-0000-000000000000}"; } protected override ProjectBehavior GetOrCreateBehavior() diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index ec8705a596..361c15160b 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -37,12 +37,12 @@ namespace ICSharpCode.SharpDevelop.Debugging static IDebugger GetCompatibleDebugger() { GetDescriptors(); - IProject project = null; - if (ProjectService.OpenSolution != null) { - project = ProjectService.OpenSolution.StartupProject; - } +// IProject project = null; +// if (ProjectService.OpenSolution != null) { +// project = ProjectService.OpenSolution.StartupProject; +// } foreach (DebuggerDescriptor d in debuggers) { - if (d.Debugger != null && d.Debugger.CanDebug(project)) { + if (d.Debugger != null /*&& d.Debugger.CanDebug(project)*/) { return d.Debugger; } } diff --git a/src/Main/Base/Project/Src/Services/ProjectBinding/ProjectBindingDescriptor.cs b/src/Main/Base/Project/Src/Services/ProjectBinding/ProjectBindingDescriptor.cs index 7241ab810b..52e384da92 100644 --- a/src/Main/Base/Project/Src/Services/ProjectBinding/ProjectBindingDescriptor.cs +++ b/src/Main/Base/Project/Src/Services/ProjectBinding/ProjectBindingDescriptor.cs @@ -37,9 +37,9 @@ namespace ICSharpCode.SharpDevelop } - public string Guid { + public Guid Guid { get { - return codon.Properties["guid"]; + return Guid.Parse(codon.Properties["guid"]); } } diff --git a/src/Main/Base/Project/Src/Services/ProjectBinding/ProjectBindingService.cs b/src/Main/Base/Project/Src/Services/ProjectBinding/ProjectBindingService.cs index 722bd31013..338292d69e 100644 --- a/src/Main/Base/Project/Src/Services/ProjectBinding/ProjectBindingService.cs +++ b/src/Main/Base/Project/Src/Services/ProjectBinding/ProjectBindingService.cs @@ -98,7 +98,7 @@ namespace ICSharpCode.SharpDevelop IProjectBinding binding = ProjectBindingService.GetBindingPerProjectFile(location); IProject newProject; if (!(binding != null && binding.HandlingMissingProject) && !File.Exists(location)) { - newProject = new MissingProject(location, title); + newProject = new MissingProject(loadInformation.Solution, location, title); newProject.TypeGuid = loadInformation.TypeGuid; } else { if (binding != null) { @@ -107,13 +107,13 @@ namespace ICSharpCode.SharpDevelop } catch (ProjectLoadException ex) { LoggingService.Warn("Project load error", ex); progressMonitor.ShowingDialog = true; - newProject = new UnknownProject(location, title, ex.Message, true); + newProject = new UnknownProject(loadInformation.Solution, location, title, ex.Message, true); newProject.TypeGuid = loadInformation.TypeGuid; progressMonitor.ShowingDialog = false; } catch (UnauthorizedAccessException ex) { LoggingService.Warn("Project load error", ex); progressMonitor.ShowingDialog = true; - newProject = new UnknownProject(location, title, ex.Message, true); + newProject = new UnknownProject(loadInformation.Solution, location, title, ex.Message, true); newProject.TypeGuid = loadInformation.TypeGuid; progressMonitor.ShowingDialog = false; } @@ -122,10 +122,10 @@ namespace ICSharpCode.SharpDevelop if (".proj".Equals(ext, StringComparison.OrdinalIgnoreCase) || ".build".Equals(ext, StringComparison.OrdinalIgnoreCase)) { - newProject = new MSBuildFileProject(location, title); + newProject = new MSBuildFileProject(loadInformation.Solution, location, title); newProject.TypeGuid = loadInformation.TypeGuid; } else { - newProject = new UnknownProject(location, title); + newProject = new UnknownProject(loadInformation.Solution, location, title); newProject.TypeGuid = loadInformation.TypeGuid; } } diff --git a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs index 57d36ba004..6faa8fb7c0 100644 --- a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs +++ b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs @@ -18,13 +18,10 @@ namespace ICSharpCode.SharpDevelop.Project { public static class ProjectService { - volatile static ISolution openSolution; - volatile static IProject currentProject; - public static ISolution OpenSolution { [System.Diagnostics.DebuggerStepThrough] get { - return openSolution; + return SD.ProjectService.OpenSolution; } } @@ -36,16 +33,10 @@ namespace ICSharpCode.SharpDevelop.Project public static IProject CurrentProject { [System.Diagnostics.DebuggerStepThrough] get { - return currentProject; + return SD.ProjectService.CurrentProject; } set { - SD.MainThread.VerifyAccess(); - if (currentProject != value) { - LoggingService.Info("CurrentProject changed to " + (value == null ? "null" : value.Name)); - currentProject = value; - OnCurrentProjectChanged(new ProjectEventArgs(currentProject)); - CommandManager.InvalidateRequerySuggested(); - } + SD.ProjectService.CurrentProject = value; } } @@ -54,7 +45,7 @@ namespace ICSharpCode.SharpDevelop.Project /// public static IProject GetProject(FileName projectFilename) { - ISolution sln = openSolution; + ISolution sln = SD.ProjectService.OpenSolution; if (sln == null) return null; foreach (IProject project in sln.Projects) { @@ -65,38 +56,14 @@ namespace ICSharpCode.SharpDevelop.Project return null; } - static bool initialized; - - public static void InitializeService() - { - if (!initialized) { - initialized = true; - SD.Workbench.ActiveViewContentChanged += ActiveViewContentChanged; - FileService.FileRenamed += FileServiceFileRenamed; - FileService.FileRemoved += FileServiceFileRemoved; - - var applicationStateInfoService = SD.GetService(); - if (applicationStateInfoService != null) { - applicationStateInfoService.RegisterStateGetter("ProjectService.OpenSolution", delegate { return OpenSolution; }); - applicationStateInfoService.RegisterStateGetter("ProjectService.CurrentProject", delegate { return CurrentProject; }); - } - } - } - /// /// Returns if a project loader exists for the given file. This method works even in early /// startup (before service initialization) /// + [Obsolete("Use SD.ProjectService.IsProjectOrSolutionFile instead")] public static bool HasProjectLoader(string fileName) { - AddInTreeNode addinTreeNode = AddInTree.GetTreeNode("/SharpDevelop/Workbench/Combine/FileFilter"); - foreach (Codon codon in addinTreeNode.Codons) { - string pattern = codon.Properties.Get("extensions", ""); - if (FileUtility.MatchesPattern(fileName, pattern) && codon.Properties.Contains("class")) { - return true; - } - } - return false; + return SD.ProjectService.IsProjectOrSolutionFile(FileName.Create(fileName)); } /* @@ -115,12 +82,13 @@ namespace ICSharpCode.SharpDevelop.Project public static void LoadSolutionOrProject(string fileName) { - IProjectLoader loader = GetProjectLoader(fileName); + SD.ProjectService.OpenSolutionOrProject(FileName.Create(fileName)); + /*IProjectLoader loader = GetProjectLoader(fileName); if (loader != null) { loader.Load(fileName); } else { MessageService.ShowError(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.InvalidProjectOrCombine}", new StringTagPair("FileName", fileName))); - } + }*/ } static void FileServiceFileRenamed(object sender, FileRenameEventArgs e) @@ -130,23 +98,16 @@ namespace ICSharpCode.SharpDevelop.Project } string oldName = e.SourceFile; string newName = e.TargetFile; - long x = 0; - foreach (ISolutionFolder container in OpenSolution.SolutionFolderContainers) { - foreach (SolutionItem item in container.SolutionItems.Items) { - string oldFullName = Path.Combine(OpenSolution.Directory, item.Name); - ++x; - if (FileUtility.IsBaseDirectory(oldName, oldFullName)) { - string newFullName = FileUtility.RenameBaseDirectory(oldFullName, oldName, newName); - item.Name = item.Location = FileUtility.GetRelativePath(OpenSolution.Directory, newFullName); - } + foreach (ISolutionFileItem fileItem in OpenSolution.FileItems) { + if (FileUtility.IsBaseDirectory(oldName, fileItem.FileName)) { + string newFullName = FileUtility.RenameBaseDirectory(fileItem.FileName, oldName, newName); + fileItem.FileName = FileName.Create(newFullName); } } - long y = 0; foreach (IProject project in OpenSolution.Projects) { if (FileUtility.IsBaseDirectory(project.Directory, oldName)) { foreach (ProjectItem item in project.Items) { - ++y; if (FileUtility.IsBaseDirectory(oldName, item.FileName)) { OnProjectItemRemoved(new ProjectItemEventArgs(project, item)); item.FileName = FileUtility.RenameBaseDirectory(item.FileName, oldName, newName); @@ -164,14 +125,9 @@ namespace ICSharpCode.SharpDevelop.Project } string fileName = e.FileName; - foreach (ISolutionFolder container in OpenSolution.SolutionFolderContainers) { - for (int i = 0; i < container.SolutionItems.Items.Count;) { - SolutionItem item = container.SolutionItems.Items[i]; - if (FileUtility.IsBaseDirectory(fileName, Path.Combine(OpenSolution.Directory, item.Name))) { - container.SolutionItems.Items.RemoveAt(i); - } else { - ++i; - } + foreach (ISolutionFileItem fileItem in OpenSolution.FileItems.ToArray()) { + if (FileUtility.IsBaseDirectory(fileName, fileItem.FileName)) { + fileItem.ParentFolder.Items.Remove(fileItem); } } @@ -196,23 +152,11 @@ namespace ICSharpCode.SharpDevelop.Project if (OpenSolution == null || viewContent == null) { return; } - string fileName = viewContent.PrimaryFileName; + FileName fileName = viewContent.PrimaryFileName; if (fileName == null) { return; } - CurrentProject = OpenSolution.FindProjectContainingFile(fileName) ?? CurrentProject; - } - - public static void AddProject(ISolutionFolderNode solutionFolderNode, IProject newProject) - { - if (solutionFolderNode.Solution.SolutionFolders.Any( - folder => string.Equals(folder.IdGuid, newProject.IdGuid, StringComparison.OrdinalIgnoreCase))) - { - LoggingService.Warn("ProjectService.AddProject: Duplicate IdGuid detected"); - newProject.IdGuid = Guid.NewGuid().ToString().ToUpperInvariant(); - } - solutionFolderNode.Container.AddFolder(newProject); - OnProjectAdded(new ProjectEventArgs(newProject)); + CurrentProject = SD.ProjectService.FindProjectContainingFile(fileName) ?? CurrentProject; } /// @@ -247,6 +191,7 @@ namespace ICSharpCode.SharpDevelop.Project } } + /* static void BeforeLoadSolution() { if (openSolution != null && !IsClosingCanceled()) { @@ -255,6 +200,7 @@ namespace ICSharpCode.SharpDevelop.Project CloseSolution(); } } + */ [Obsolete("Use SD.ProjectService.OpenSolutionOrProject() instead")] public static void LoadSolution(string fileName) @@ -344,7 +290,7 @@ namespace ICSharpCode.SharpDevelop.Project } } } - */ + */ /// /// Load a single project as solution. @@ -429,9 +375,9 @@ namespace ICSharpCode.SharpDevelop.Project public static void SaveSolution() { - if (openSolution != null) { - openSolution.Save(); - /* foreach (IProject project in openSolution.Projects) { + if (SD.ProjectService.OpenSolution != null) { + SD.ProjectService.OpenSolution.Save(); + /* foreach (IProject project in openSolution.Projects) { project.Save(); } OnSolutionSaved(new SolutionEventArgs(openSolution));*/ @@ -485,7 +431,8 @@ namespace ICSharpCode.SharpDevelop.Project public static void SaveSolutionPreferences() { - if (openSolution == null) + throw new NotImplementedException(); + /*if (openSolution == null) return; string directory = Path.Combine(PropertyService.ConfigDirectory, "preferences"); if (!Directory.Exists(directory)) { @@ -517,7 +464,7 @@ namespace ICSharpCode.SharpDevelop.Project FileUtility.ObservedSave(new NamedFileOperationDelegate(memento.Save), fullFileName, FileErrorPolicy.Inform); #endif } - } + }*/ } /// @@ -528,7 +475,7 @@ namespace ICSharpCode.SharpDevelop.Project internal static bool IsClosingCanceled() { // run onbefore closing - var beforeClosingArgs = new SolutionCancelEventArgs(openSolution); + var beforeClosingArgs = new SolutionCancelEventArgs(OpenSolution); OnBeforeSolutionClosing(beforeClosingArgs); return beforeClosingArgs.Cancel; @@ -543,7 +490,8 @@ namespace ICSharpCode.SharpDevelop.Project /// internal static void CloseSolution() { - // If a build is running, cancel it. + throw new NotImplementedException(); + /*// If a build is running, cancel it. // If we would let a build run but unload the MSBuild projects, the next project.StartBuild call // could cause an exception. SD.BuildService.CancelBuild(); @@ -557,14 +505,7 @@ namespace ICSharpCode.SharpDevelop.Project OnSolutionClosed(EventArgs.Empty); CommandManager.InvalidateRequerySuggested(); - } - } - - static void OnCurrentProjectChanged(ProjectEventArgs e) - { - if (CurrentProjectChanged != null) { - CurrentProjectChanged(null, e); - } + }*/ } static void OnSolutionClosed(EventArgs e) @@ -623,6 +564,7 @@ namespace ICSharpCode.SharpDevelop.Project } } + /* public static void RemoveSolutionFolder(string guid) { if (OpenSolution == null) { @@ -658,6 +600,7 @@ namespace ICSharpCode.SharpDevelop.Project SolutionFolderRemoved(null, e); } } + */ static void OnProjectItemAdded(ProjectItemEventArgs e) { @@ -752,7 +695,10 @@ namespace ICSharpCode.SharpDevelop.Project /// public static event EventHandler SolutionPreferencesSaving; - public static event EventHandler CurrentProjectChanged; + public static event EventHandler CurrentProjectChanged { + add { SD.ProjectService.CurrentProjectChanged += value; } + remove { SD.ProjectService.CurrentProjectChanged -= value; } + } public static event EventHandler ProjectItemAdded; public static event EventHandler ProjectItemRemoved; diff --git a/src/Main/Base/Project/Util/SharpDevelopExtensions.cs b/src/Main/Base/Project/Util/SharpDevelopExtensions.cs index 72882a5af1..4b482def61 100644 --- a/src/Main/Base/Project/Util/SharpDevelopExtensions.cs +++ b/src/Main/Base/Project/Util/SharpDevelopExtensions.cs @@ -474,9 +474,9 @@ namespace ICSharpCode.SharpDevelop public static IEntityModel GetModel(this IUnresolvedEntity entity, IProject project = null) { if (project == null) { - if (entity.Region.FileName == null || ProjectService.OpenSolution == null) + if (entity.Region.FileName == null) return null; - project = ProjectService.OpenSolution.FindProjectContainingFile(entity.Region.FileName); + project = SD.ProjectService.FindProjectContainingFile(FileName.Create(entity.Region.FileName)); if (project == null) return null; } diff --git a/src/Main/Base/Project/Workbench/AbstractViewContent.cs b/src/Main/Base/Project/Workbench/AbstractViewContent.cs index 6403ba4a3d..7c552c20c2 100644 --- a/src/Main/Base/Project/Workbench/AbstractViewContent.cs +++ b/src/Main/Base/Project/Workbench/AbstractViewContent.cs @@ -625,7 +625,7 @@ namespace ICSharpCode.SharpDevelop.Workbench get { var fileName = this.PrimaryFileName; return fileName == null - || Project.ProjectService.OpenSolution.FindProjectContainingFile(fileName) != null; + || SD.ProjectService.FindProjectContainingFile(fileName) != null; } } } diff --git a/src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj b/src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj index 5594aa083e..4ce7491ff7 100644 --- a/src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj +++ b/src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj @@ -91,7 +91,9 @@ + + @@ -114,7 +116,6 @@ - diff --git a/src/Main/Base/Test/Project/BeforeBuildCustomToolProjectItemsTests.cs b/src/Main/Base/Test/Project/BeforeBuildCustomToolProjectItemsTests.cs index 18e2abe8f7..98f333aa7c 100644 --- a/src/Main/Base/Test/Project/BeforeBuildCustomToolProjectItemsTests.cs +++ b/src/Main/Base/Test/Project/BeforeBuildCustomToolProjectItemsTests.cs @@ -7,6 +7,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Tests.Utils; @@ -30,9 +31,8 @@ namespace ICSharpCode.SharpDevelop.Tests.Project void CreateSolution(params IProject[] projects) { - IProjectChangeWatcher watcher = MockRepository.GenerateStub(); - solution = new Solution(watcher); - projects.ForEach(p => solution.Folders.Add(p)); + solution = MockRepository.GenerateStrictMock(); + solution.Stub(s => s.Projects).Return(new SimpleModelCollection(projects)); } void ConfigureCustomToolFileNamesForProject(string fileNames) diff --git a/src/Main/Base/Test/Project/MockSolution.cs b/src/Main/Base/Test/Project/MockSolution.cs new file mode 100644 index 0000000000..53fce1a4ae --- /dev/null +++ b/src/Main/Base/Test/Project/MockSolution.cs @@ -0,0 +1,21 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using ICSharpCode.SharpDevelop.Dom; +using Microsoft.Build.Evaluation; +using Rhino.Mocks; + +namespace ICSharpCode.SharpDevelop.Project +{ + public class MockSolution + { + public static ISolution Create() + { + ISolution solution = MockRepository.GenerateStub(); + solution.Stub(s => s.MSBuildProjectCollection).Return(new ProjectCollection()); + solution.Stub(s => s.Projects).Return(new SimpleModelCollection()); + return solution; + } + } +} diff --git a/src/Main/Base/Test/SolutionTests.cs b/src/Main/Base/Test/Project/SolutionTests.cs similarity index 76% rename from src/Main/Base/Test/SolutionTests.cs rename to src/Main/Base/Test/Project/SolutionTests.cs index fbe5506419..d4ce4008ee 100644 --- a/src/Main/Base/Test/SolutionTests.cs +++ b/src/Main/Base/Test/Project/SolutionTests.cs @@ -12,18 +12,10 @@ namespace ICSharpCode.SharpDevelop.Tests [TestFixture] public class SolutionTests { - ISolution solution; - - void CreateSolution() - { - IProjectChangeWatcher fakeWatcher = MockRepository.GenerateStub(); - solution = new Solution(fakeWatcher); - } - - [Test] + [Test, Ignore] public void UpdateMSBuildProperties_SolutionHasFileName_SolutionDefinesSolutionDirMSBuildPropertyWithDirectoryEndingInForwardSlash() { - CreateSolution(); + /*CreateSolution(); solution.FileName = @"d:\projects\MyProject\MySolution.sln"; solution.UpdateMSBuildProperties(); @@ -32,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.Tests string solutionDir = property.EvaluatedValue; string expectedSolutionDir = @"d:\projects\MyProject\"; - Assert.AreEqual(expectedSolutionDir, solutionDir); + Assert.AreEqual(expectedSolutionDir, solutionDir);*/ } } } diff --git a/src/Main/Base/Test/ServiceReferences/ProjectWithServiceReferencesTests.cs b/src/Main/Base/Test/ServiceReferences/ProjectWithServiceReferencesTests.cs index 80926a0d1b..66c2d9768d 100644 --- a/src/Main/Base/Test/ServiceReferences/ProjectWithServiceReferencesTests.cs +++ b/src/Main/Base/Test/ServiceReferences/ProjectWithServiceReferencesTests.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.SharpDevelop.Tests.ServiceReferences void SetProjectDirectory(string directory) { - fakeProject.Stub(p => p.Directory).Return(directory); + fakeProject.Stub(p => p.Directory).Return(DirectoryName.Create(directory)); } ProjectItem GetFirstServiceReferenceFileInMSBuildProject(ServiceReferenceFileName fileName) diff --git a/src/Main/Base/Test/StringTagProvider/NullProjectStringTagProviderTestFixture.cs b/src/Main/Base/Test/StringTagProvider/NullProjectStringTagProviderTestFixture.cs index bb45bc7be4..8469c84a64 100644 --- a/src/Main/Base/Test/StringTagProvider/NullProjectStringTagProviderTestFixture.cs +++ b/src/Main/Base/Test/StringTagProvider/NullProjectStringTagProviderTestFixture.cs @@ -5,6 +5,7 @@ using System; using ICSharpCode.SharpDevelop.Commands; using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; +using Rhino.Mocks; namespace ICSharpCode.SharpDevelop.Tests.StringTagProvider { @@ -16,10 +17,12 @@ namespace ICSharpCode.SharpDevelop.Tests.StringTagProvider { SharpDevelopStringTagProvider tagProvider; - [SetUp] - public void Init() + public override void FixtureSetUp() { - ProjectService.CurrentProject = null; + base.FixtureSetUp(); + SD.Services.AddService(typeof(IProjectService), MockRepository.GenerateStrictMock()); + SD.ProjectService.Stub(s => s.CurrentProject).Return(null); + tagProvider = new SharpDevelopStringTagProvider(); } diff --git a/src/Main/Base/Test/Utils/FakeMessageLoop.cs b/src/Main/Base/Test/Utils/FakeMessageLoop.cs index 50f9dc3e83..f73a8bd634 100644 --- a/src/Main/Base/Test/Utils/FakeMessageLoop.cs +++ b/src/Main/Base/Test/Utils/FakeMessageLoop.cs @@ -9,7 +9,7 @@ using System.Windows.Threading; namespace ICSharpCode.SharpDevelop { /// - /// A fake message lop that always has InvokeRequired=false and synchronously invokes + /// A fake IMessageLoop implementation that always has InvokeRequired=false and synchronously invokes /// the callback passed to InvokeIfRequired. /// public class FakeMessageLoop : IMessageLoop diff --git a/src/Main/Base/Test/WebReferences/WebReferenceTestHelper.cs b/src/Main/Base/Test/WebReferences/WebReferenceTestHelper.cs index aac00db06f..ab330a9867 100644 --- a/src/Main/Base/Test/WebReferences/WebReferenceTestHelper.cs +++ b/src/Main/Base/Test/WebReferences/WebReferenceTestHelper.cs @@ -28,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Tests.WebReferences public TestProject(string languageName) : base(new ProjectCreateInformation { - Solution = new Solution(new MockProjectChangeWatcher()), + Solution = MockSolution.Create(), ProjectName = "TestProject", OutputProjectFileName = FileName.Create("c:\\temp\\TestProject.csproj") }) diff --git a/src/Main/Core/Project/ICSharpCode.Core.csproj b/src/Main/Core/Project/ICSharpCode.Core.csproj index a69752ba51..cf0796a471 100644 --- a/src/Main/Core/Project/ICSharpCode.Core.csproj +++ b/src/Main/Core/Project/ICSharpCode.Core.csproj @@ -99,6 +99,7 @@ + diff --git a/src/Main/Core/Project/Src/Services/FileUtility/DirectoryName.cs b/src/Main/Core/Project/Src/Services/FileUtility/DirectoryName.cs new file mode 100644 index 0000000000..2b33d0a11c --- /dev/null +++ b/src/Main/Core/Project/Src/Services/FileUtility/DirectoryName.cs @@ -0,0 +1,167 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.ComponentModel; +using System.Globalization; +using System.IO; + +namespace ICSharpCode.Core +{ + /// + /// Represents a directory path or Directoryname. + /// The equality operator is overloaded to compare for path equality (case insensitive, normalizing paths with '..\') + /// + [TypeConverter(typeof(DirectoryNameConverter))] + public sealed class DirectoryName : IEquatable + { + readonly string normalizedDirectoryName; + + public DirectoryName(string directoryName) + { + if (directoryName == null) + throw new ArgumentNullException("DirectoryName"); + if (directoryName.Length == 0) + throw new ArgumentException("The empty string is not a valid DirectoryName"); + this.normalizedDirectoryName = FileUtility.NormalizePath(directoryName); + } + + [Obsolete("The input already is a DirectoryName")] + public DirectoryName(DirectoryName directoryName) + { + this.normalizedDirectoryName = directoryName.normalizedDirectoryName; + } + + /// + /// Creates a DirectoryName instance from the string. + /// It is valid to pass null or an empty string to this method (in that case, a null reference will be returned). + /// + public static DirectoryName Create(string DirectoryName) + { + if (string.IsNullOrEmpty(DirectoryName)) + return null; + else + return new DirectoryName(DirectoryName); + } + + [Obsolete("The input already is a DirectoryName")] + public static DirectoryName Create(DirectoryName directoryName) + { + return directoryName; + } + + public DirectoryName GetParentDirectory() + { + return DirectoryName.Create(Path.GetDirectoryName(normalizedDirectoryName)); + } + + public static implicit operator string(DirectoryName directoryName) + { + if (directoryName != null) + return directoryName.normalizedDirectoryName; + else + return null; + } + + public string ToStringWithTrailingBackslash() + { + if (normalizedDirectoryName.EndsWith("\\", StringComparison.Ordinal)) + return normalizedDirectoryName; // trailing backslash exists in normalized version for root of drives ("C:\") + else + return normalizedDirectoryName + "\\"; + } + + public override string ToString() + { + return normalizedDirectoryName; + } + + #region Equals and GetHashCode implementation + public override bool Equals(object obj) + { + return Equals(obj as DirectoryName); + } + + public bool Equals(DirectoryName other) + { + if (other != null) + return string.Equals(normalizedDirectoryName, other.normalizedDirectoryName, StringComparison.OrdinalIgnoreCase); + else + return false; + } + + public override int GetHashCode() + { + return StringComparer.OrdinalIgnoreCase.GetHashCode(normalizedDirectoryName); + } + + public static bool operator ==(DirectoryName left, DirectoryName right) + { + if (ReferenceEquals(left, right)) + return true; + if (ReferenceEquals(left, null) || ReferenceEquals(right, null)) + return false; + return left.Equals(right); + } + + public static bool operator !=(DirectoryName left, DirectoryName right) + { + return !(left == right); + } + + [ObsoleteAttribute("Warning: comparing DirectoryName with string results in case-sensitive comparison")] + public static bool operator ==(DirectoryName left, string right) + { + return (string)left == right; + } + + [ObsoleteAttribute("Warning: comparing DirectoryName with string results in case-sensitive comparison")] + public static bool operator !=(DirectoryName left, string right) + { + return (string)left != right; + } + + [ObsoleteAttribute("Warning: comparing DirectoryName with string results in case-sensitive comparison")] + public static bool operator ==(string left, DirectoryName right) + { + return left == (string)right; + } + + [ObsoleteAttribute("Warning: comparing DirectoryName with string results in case-sensitive comparison")] + public static bool operator !=(string left, DirectoryName right) + { + return left != (string)right; + } + #endregion + } + + public class DirectoryNameConverter : TypeConverter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + return destinationType == typeof(DirectoryName) || base.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value is string) { + return DirectoryName.Create((string)value); + } + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, + object value, Type destinationType) + { + if (destinationType == typeof(string)) { + return value.ToString(); + } + return base.ConvertTo(context, culture, value, destinationType); + } + } +} diff --git a/src/Main/Core/Project/Src/Services/FileUtility/FileName.cs b/src/Main/Core/Project/Src/Services/FileUtility/FileName.cs index 2253fc6fa9..a71e9139b6 100644 --- a/src/Main/Core/Project/Src/Services/FileUtility/FileName.cs +++ b/src/Main/Core/Project/Src/Services/FileUtility/FileName.cs @@ -63,6 +63,50 @@ namespace ICSharpCode.Core return normalizedFileName; } + /// + /// Gets the directory name. + /// + /// + /// Corresponds to System.IO.Path.GetDirectoryName + /// + public DirectoryName GetParentDirectory() + { + return DirectoryName.Create(Path.GetDirectoryName(normalizedFileName)); + } + + /// + /// Gets the file name (not the full path). + /// + /// + /// Corresponds to System.IO.Path.GetFileName + /// + public string GetFileName() + { + return Path.GetFileName(normalizedFileName); + } + + /// + /// Gets the file extension. + /// + /// + /// Corresponds to System.IO.Path.GetExtension + /// + public string GetExtension() + { + return Path.GetExtension(normalizedFileName); + } + + /// + /// Gets the file name without extension. + /// + /// + /// Corresponds to System.IO.Path.GetFileNameWithoutExtension + /// + public string GetFileNameWithoutExtension() + { + return Path.GetFileNameWithoutExtension(normalizedFileName); + } + #region Equals and GetHashCode implementation public override bool Equals(object obj) { diff --git a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs index 53bb1fc7d4..9a390857d3 100644 --- a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs +++ b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs @@ -560,8 +560,8 @@ namespace ICSharpCode.Core public static bool MatchesPattern(string filename, string pattern) { - filename = filename.ToUpper(); - pattern = pattern.ToUpper(); + filename = filename.ToUpperInvariant(); + pattern = pattern.ToUpperInvariant(); string[] patterns = pattern.Split(';'); foreach (string p in patterns) { if (Match(filename, p)) { diff --git a/src/Main/SharpDevelop/Parser/ParserService.cs b/src/Main/SharpDevelop/Parser/ParserService.cs index c00f17e585..3efac0caee 100644 --- a/src/Main/SharpDevelop/Parser/ParserService.cs +++ b/src/Main/SharpDevelop/Parser/ParserService.cs @@ -89,8 +89,7 @@ namespace ICSharpCode.SharpDevelop.Parser public ICompilation GetCompilationForFile(FileName fileName) { - ISolution solution = ProjectService.OpenSolution; - IProject project = solution != null ? solution.FindProjectContainingFile(fileName) : null; + IProject project = SD.ProjectService.FindProjectContainingFile(fileName); if (project != null) return GetCompilation(project); diff --git a/src/Main/SharpDevelop/Project/ProjectService.cs b/src/Main/SharpDevelop/Project/ProjectService.cs new file mode 100644 index 0000000000..365497a71c --- /dev/null +++ b/src/Main/SharpDevelop/Project/ProjectService.cs @@ -0,0 +1,105 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Diagnostics; +using System.Windows.Input; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Dom; + +namespace ICSharpCode.SharpDevelop.Project +{ + sealed class SDProjectService : IProjectService + { + public SDProjectService() + { +// SD.Workbench.ActiveViewContentChanged += ActiveViewContentChanged; +// FileService.FileRenamed += FileServiceFileRenamed; +// FileService.FileRemoved += FileServiceFileRemoved; + + var applicationStateInfoService = SD.GetService(); + if (applicationStateInfoService != null) { + applicationStateInfoService.RegisterStateGetter("ProjectService.OpenSolution", delegate { return OpenSolution; }); + applicationStateInfoService.RegisterStateGetter("ProjectService.CurrentProject", delegate { return CurrentProject; }); + } + } + + volatile static ISolution openSolution; + volatile static IProject currentProject; + + public event EventHandler OpenSolutionChanged; + public event EventHandler CurrentProjectChanged; + + public ISolution OpenSolution { + [DebuggerStepThrough] + get { return openSolution; } + private set { + SD.MainThread.VerifyAccess(); + if (openSolution != value) { + openSolution = value; + if (OpenSolutionChanged != null) + OpenSolutionChanged(this, new SolutionEventArgs(value)); + CommandManager.InvalidateRequerySuggested(); + } + } + } + + public IProject CurrentProject { + [DebuggerStepThrough] + get { return currentProject; } + set { + SD.MainThread.VerifyAccess(); + if (currentProject != value) { + LoggingService.Info("CurrentProject changed to " + (value == null ? "null" : value.Name)); + currentProject = value; + if (CurrentProjectChanged != null) + CurrentProjectChanged(this, new ProjectEventArgs(value)); + CommandManager.InvalidateRequerySuggested(); + } + } + } + + ConcatModelCollection allProjects = new ConcatModelCollection(); + + public IModelCollection Projects { + get { return allProjects; } + } + + public IProject FindProjectContainingFile(FileName fileName) + { + throw new NotImplementedException(); + } + + public void OpenSolutionOrProject(FileName fileName) + { + throw new NotImplementedException(); + } + + public void CloseSolution() + { + throw new NotImplementedException(); + } + + public bool IsProjectOrSolutionFile(FileName fileName) + { + AddInTreeNode addinTreeNode = SD.AddInTree.GetTreeNode("/SharpDevelop/Workbench/Combine/FileFilter"); + foreach (Codon codon in addinTreeNode.Codons) { + string pattern = codon.Properties.Get("extensions", "*.*"); + if (pattern != "*.*" && FileUtility.MatchesPattern(fileName, pattern)) { + return true; + } + } + return false; + } + + public ISolution LoadSolutionFile(FileName fileName) + { + throw new NotImplementedException(); + } + + public ISolution CreateEmptySolutionFile(FileName fileName) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Main/SharpDevelop/SharpDevelop.csproj b/src/Main/SharpDevelop/SharpDevelop.csproj index 20b4592d6d..326516d461 100644 --- a/src/Main/SharpDevelop/SharpDevelop.csproj +++ b/src/Main/SharpDevelop/SharpDevelop.csproj @@ -103,6 +103,7 @@ + diff --git a/src/Main/SharpDevelop/Workbench/WorkbenchStartup.cs b/src/Main/SharpDevelop/Workbench/WorkbenchStartup.cs index a25403f5f8..bad2517d52 100644 --- a/src/Main/SharpDevelop/Workbench/WorkbenchStartup.cs +++ b/src/Main/SharpDevelop/Workbench/WorkbenchStartup.cs @@ -60,7 +60,6 @@ namespace ICSharpCode.SharpDevelop.Workbench WorkbenchSingleton.OnWorkbenchCreated(); // initialize workbench-dependent services: - Project.ProjectService.InitializeService(); NavigationService.InitializeService(); workbench.ActiveContentChanged += delegate { @@ -92,11 +91,10 @@ namespace ICSharpCode.SharpDevelop.Workbench LoggingService.Info("Open file " + file); didLoadSolutionOrFile = true; try { - string fullFileName = Path.GetFullPath(file); + var fullFileName = FileName.Create(Path.GetFullPath(file)); - IProjectLoader loader = ProjectService.GetProjectLoader(fullFileName); - if (loader != null) { - loader.Load(fullFileName); + if (SD.ProjectService.IsProjectOrSolutionFile(fullFileName)) { + SD.ProjectService.OpenSolutionOrProject(fullFileName); } else { SharpDevelop.FileService.OpenFile(fullFileName); } diff --git a/src/Main/SharpDevelop/Workbench/WpfWorkbench.cs b/src/Main/SharpDevelop/Workbench/WpfWorkbench.cs index 221b079c37..9d5dd6176c 100644 --- a/src/Main/SharpDevelop/Workbench/WpfWorkbench.cs +++ b/src/Main/SharpDevelop/Workbench/WpfWorkbench.cs @@ -653,11 +653,11 @@ namespace ICSharpCode.SharpDevelop.Workbench return; foreach (string file in files) { if (File.Exists(file)) { - Project.IProjectLoader loader = Project.ProjectService.GetProjectLoader(file); - if (loader != null) { - FileUtility.ObservedLoad(new NamedFileOperationDelegate(loader.Load), file); + var fileName = FileName.Create(file); + if (SD.ProjectService.IsProjectOrSolutionFile(fileName)) { + SD.ProjectService.OpenSolutionOrProject(fileName); } else { - SharpDevelop.FileService.OpenFile(file); + SD.FileService.OpenFile(fileName); } } }