diff options
author | Alan McGovern <alan.mcgovern@gmail.com> | 2012-05-31 15:16:49 +0400 |
---|---|---|
committer | Alan McGovern <alan.mcgovern@gmail.com> | 2012-05-31 15:41:24 +0400 |
commit | 7098b8c53f280c195e628ec4969bad7aabd3c2fe (patch) | |
tree | 73b053226b98ce27d38a4f954b19e3767c960bfe | |
parent | e61bbd6fd885d2b343743217a4c9da81a76446c4 (diff) |
[MonoDevelop.Ide] Link a csproj file to its owning project
I've also added a test to verify the new behaviour so that this does not
regress.
Fixes bug #5434.
5 files changed, 54 insertions, 1 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs index 169605edea..28eb0caac4 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs @@ -488,7 +488,7 @@ namespace MonoDevelop.Projects { ReadOnlyCollection<Project> projects = GetAllProjects (); foreach (Project projectEntry in projects) { - if (projectEntry.IsFileInProject(fileName)) { + if (projectEntry.FileName == fileName || projectEntry.IsFileInProject(fileName)) { return projectEntry; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs index dfa61ac71b..4712de293b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs @@ -697,6 +697,8 @@ namespace MonoDevelop.Ide.Gui if (IdeApp.ProjectOperations.CurrentSelectedProject != null) { if (IdeApp.ProjectOperations.CurrentSelectedProject.Files.GetFile (fileName) != null) project = IdeApp.ProjectOperations.CurrentSelectedProject; + else if (IdeApp.ProjectOperations.CurrentSelectedProject.FileName == fileName) + project = IdeApp.ProjectOperations.CurrentSelectedProject; } if (project == null && IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem != null) { project = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem.GetProjectContainingFile (fileName); diff --git a/main/tests/UnitTests/Makefile.am b/main/tests/UnitTests/Makefile.am index 6e90c71f2f..601098f25a 100644 --- a/main/tests/UnitTests/Makefile.am +++ b/main/tests/UnitTests/Makefile.am @@ -93,6 +93,7 @@ FILES = \ MonoDevelop.Projects/MSBuildTests.cs \ MonoDevelop.Projects/PackagingTests.cs \ MonoDevelop.Projects/ProjectTests.cs \ + MonoDevelop.Projects/SolutionFolderTests.cs \ MonoDevelop.Projects/SolutionTests.cs \ MonoDevelop.Projects/TestProjectsChecks.cs \ MonoDevelop.Projects/TextFormatterTests.cs \ diff --git a/main/tests/UnitTests/MonoDevelop.Projects/SolutionFolderTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/SolutionFolderTests.cs new file mode 100644 index 0000000000..ec5ad7841a --- /dev/null +++ b/main/tests/UnitTests/MonoDevelop.Projects/SolutionFolderTests.cs @@ -0,0 +1,49 @@ +// +// ProjectFolderTests.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright (c) 2012 Xamarin, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +using System; +using UnitTests; +using NUnit.Framework; +using MonoDevelop.Ide.Gui.Pads.ProjectPad; + +namespace MonoDevelop.Projects +{ + [TestFixture] + public class SolutionFolderTests : TestBase + { + [Test] + public void CheckProjectContainsItself () + { + var folder = new SolutionFolder (); + var project = new DotNetAssemblyProject { Name = "foo" }; + folder.AddItem (project); + + Assert.IsNotNull (folder.GetProjectContainingFile (project.FileName), "#1"); + } + } +} + diff --git a/main/tests/UnitTests/UnitTests.csproj b/main/tests/UnitTests/UnitTests.csproj index 74d6ea11a2..da6655dbbc 100644 --- a/main/tests/UnitTests/UnitTests.csproj +++ b/main/tests/UnitTests/UnitTests.csproj @@ -239,6 +239,7 @@ <Compile Include="Mono.TextEditor.Tests\RtfWriterTests.cs" /> <Compile Include="MonoDevelop.SourceEditor\SourceEditorTests.cs" /> <Compile Include="MonoDevelop.Projects\FileServiceTests.cs" /> + <Compile Include="MonoDevelop.Projects\SolutionFolderTests.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\md.targets" /> |