From e123480f796f98342775c8bc9c734b419c3dd4f6 Mon Sep 17 00:00:00 2001 From: Basoundr_ms Date: Tue, 26 Aug 2014 09:43:30 -0700 Subject: [PATCH] Rollbacking changeset 1324466 to prevent build break. (changeset 1324482) --- .../Workspace/MSBuild/MSBuildWorkspace.cs | 92 +------------------ .../WorkspaceTests/MSBuildWorkspaceTests.cs | 16 +--- .../WorkspaceTests/SolutionParsingTests.cs | 12 +-- 3 files changed, 10 insertions(+), 110 deletions(-) diff --git a/Src/Workspaces/Core/Workspace/MSBuild/MSBuildWorkspace.cs b/Src/Workspaces/Core/Workspace/MSBuild/MSBuildWorkspace.cs index 31cc28488c8..0e6efea5da7 100644 --- a/Src/Workspaces/Core/Workspace/MSBuild/MSBuildWorkspace.cs +++ b/Src/Workspaces/Core/Workspace/MSBuild/MSBuildWorkspace.cs @@ -8,13 +8,10 @@ using System.Text; using System.Threading; using System.Threading.Tasks; - -#if !MSBUILD12 -using Microsoft.Build.Construction; -#endif - using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; @@ -369,60 +366,6 @@ public async Task OpenSolutionAsync(string solutionFilePath, Cancellat } VersionStamp version = default(VersionStamp); - -#if !MSBUILD12 - Microsoft.Build.Construction.SolutionFile solutionFile = Microsoft.Build.Construction.SolutionFile.Parse(absoluteSolutionPath); - var reportMode = this.SkipUnrecognizedProjects ? ReportMode.Log : ReportMode.Throw; - var invalidProjects = new List(); - - // seed loaders from known project types - using (this.dataGuard.DisposableWait()) - { - foreach (var project in solutionFile.ProjectsInOrder) - { - var projectAbsolutePath = TryGetAbsolutePath(project.AbsolutePath, reportMode); - if (projectAbsolutePath != null) - { - var extension = Path.GetExtension(projectAbsolutePath); - extension = extension.StartsWith(".") ? extension.Substring(1) : extension; - - var loader = ProjectFileLoader.GetLoaderForProjectFileExtension(this, extension); - if (loader != null) - { - this.projectPathToLoaderMap[projectAbsolutePath] = loader; - } - } - else - { - invalidProjects.Add(project); - } - } - } - - // a list to accumulate all the loaded projects - var loadedProjects = new List(); - - // load all the projects - foreach (var project in solutionFile.ProjectsInOrder) - { - cancellationToken.ThrowIfCancellationRequested(); - - if (!invalidProjects.Contains(project)) - { - var projectAbsolutePath = TryGetAbsolutePath(project.AbsolutePath, reportMode); - if (projectAbsolutePath != null) - { - IProjectFileLoader loader; - if (TryGetLoaderFromProjectPath(projectAbsolutePath, reportMode, out loader)) - { - // projects get added to 'loadedProjects' as side-effect - // never perfer metadata when loading solution, all projects get loaded if they can. - var tmp = await GetOrLoadProjectAsync(projectAbsolutePath, loader, preferMetadata: false, loadedProjects: loadedProjects, cancellationToken: cancellationToken).ConfigureAwait(false); - } - } - } - } -#else SolutionFile solutionFile = null; using (var reader = new StreamReader(absoluteSolutionPath)) @@ -473,7 +416,6 @@ public async Task OpenSolutionAsync(string solutionFilePath, Cancellat } } } -#endif // construct workspace from loaded project infos this.OnSolutionAdded(SolutionInfo.Create(SolutionId.CreateNewId(debugName: absoluteSolutionPath), version, absoluteSolutionPath, loadedProjects)); @@ -518,30 +460,6 @@ public async Task OpenProjectAsync(string projectFilePath, Cancellation return null; } - private string TryGetAbsolutePath(string path, ReportMode mode) - { - try - { - path = Path.GetFullPath(path); - } - catch (Exception) - { - ReportFailure(mode, string.Format(WorkspacesResources.InvalidProjectFilePath, path)); - return null; - } - - if (!File.Exists(path)) - { - ReportFailure( - mode, - string.Format(WorkspacesResources.ProjectFileNotFound, path), - msg => new FileNotFoundException(msg)); - return null; - } - - return path; - } - private void UpdateReferencesAfterAdd() { using (this.serializationLock.DisposableWait()) @@ -845,9 +763,9 @@ private async Task GetProjectMetadata(string projectFilePath, return null; } -#endregion + #endregion -#region Apply Changes + #region Apply Changes public override bool CanApplyChange(ApplyChangesKind feature) { switch (feature) @@ -1052,5 +970,5 @@ private void DeleteDocumentFile(DocumentId documentId, string fullPath) } } } -#endregion + #endregion } \ No newline at end of file diff --git a/Src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs b/Src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs index 2ba7db26d2f..a87b34a6476 100644 --- a/Src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs +++ b/Src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs @@ -666,19 +666,6 @@ public void TestOpenSolution_WithNonExistentProject_SkipFalse_Fails() }); } -#if !MSBUILD12 - [Fact, Trait(Traits.Feature, Traits.Features.Workspace)] - public void TestOpenSolution_WithUnrecognizedProjectFileExtension_Fails() - { - // proves that for solution open, project type guid and extension are both necessary - CreateFiles(GetSimpleCSharpSolutionFiles() - .WithFile(@"TestSolution.sln", GetResourceText("TestSolution_CSharp_UnknownProjectExtension.sln")) - .WithFile(@"CSharpProject\CSharpProject.noproj", GetResourceText("CSharpProject_CSharpProject.csproj"))); - - var solution = MSBuildWorkspace.Create().OpenSolutionAsync(GetSolutionFileName(@"TestSolution.sln")).Result; - Assert.Equal(0, solution.ProjectIds.Count); - } -#else [Fact, Trait(Traits.Feature, Traits.Features.Workspace)] public void TestOpenSolution_WithUnrecognizedProjectFileExtension_Succeeds() { @@ -690,7 +677,6 @@ public void TestOpenSolution_WithUnrecognizedProjectFileExtension_Succeeds() var solution = MSBuildWorkspace.Create().OpenSolutionAsync(GetSolutionFileName(@"TestSolution.sln")).Result; Assert.Equal(1, solution.ProjectIds.Count); } -#endif [Fact, Trait(Traits.Feature, Traits.Features.Workspace)] public void TestOpenSolution_WithUnrecognizedProjectTypeGuidButRecognizedExtension_Succeeds() @@ -2136,7 +2122,7 @@ public void TestOpenSolution_SolutionFileHasEmptyLineBetweenProjectBlock() var solution = MSBuildWorkspace.Create().OpenSolutionAsync(GetSolutionFileName("TestSolution.sln")).Result; } - [Fact(Skip = "531283"), Trait(Traits.Feature, Traits.Features.Workspace)] + [Fact, Trait(Traits.Feature, Traits.Features.Workspace)] [WorkItem(531283, "DevDiv")] public void TestOpenSolution_SolutionFileHasMissingEndProject() { diff --git a/Src/Workspaces/CoreTest/WorkspaceTests/SolutionParsingTests.cs b/Src/Workspaces/CoreTest/WorkspaceTests/SolutionParsingTests.cs index b47ad11fa0b..ee487c730f3 100644 --- a/Src/Workspaces/CoreTest/WorkspaceTests/SolutionParsingTests.cs +++ b/Src/Workspaces/CoreTest/WorkspaceTests/SolutionParsingTests.cs @@ -11,9 +11,6 @@ namespace Roslyn.Editor.UnitTests.SolutionParsing { public class SolutionParsingTests { - private static string visualStudio2010 = @"# Visual Studio 2010"; - private static string visualStudio2012 = @"# Visual Studio 2012"; -#if MSBUILD12 [Fact] public void ParseEmptyFile() { @@ -30,7 +27,7 @@ public void ParseEmptySolution() { var emptySolution = @" Microsoft Visual Studio Solution File, Format Version 11.00 -" + visualStudio2010 + @" +# Visual Studio 2010 Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -60,7 +57,7 @@ public void ParseVisualBasicConsoleApplicationSolution() { var vbConsoleApplicationSolution = @" Microsoft Visual Studio Solution File, Format Version 11.00 -" + visualStudio2010 + @" +# Visual Studio 2010 Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") = ""ConsoleApplication1"", ""ConsoleApplication1\ConsoleApplication1.vbproj"", ""{09BC9F5A-FBFA-4BEE-A13C-77A99C95D06B}"" EndProject Global @@ -113,7 +110,7 @@ public void ParseSolutionWithMissingWhiteSpaces() { var vbConsoleApplicationSolution = @" Microsoft Visual Studio Solution File, Format Version 11.00 -" + visualStudio2010 + @" +# Visual Studio 2010 Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") =""ConsoleApplication1"" , ""Console Application1\ConsoleApplication1.vbproj"",""{09BC9F5A-FBFA-4BEE-A13C-77A99C95D06B}"" EndProject Global @@ -149,7 +146,7 @@ public void ParseSolutionFileWithVisualStudioVersion() { var vbConsoleApplicationSolution = @" Microsoft Visual Studio Solution File, Format Version 12.00 -" + visualStudio2012 + @" +# Visual Studio 12 VisualStudioVersion = 12.0.20430.1 PREVIEW MinimumVisualStudioVersion = 10.0.40219.1 Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") =""ConsoleApplication1"" , ""Console Application1\ConsoleApplication1.vbproj"",""{09BC9F5A-FBFA-4BEE-A13C-77A99C95D06B}"" @@ -190,6 +187,5 @@ private Microsoft.CodeAnalysis.MSBuild.SolutionFile Parse(StringReader stringRea { return Microsoft.CodeAnalysis.MSBuild.SolutionFile.Parse(stringReader); } -#endif } } -- GitLab