From 3ff405925786ea9ea3bd256c435d8a155d2f6323 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 11 Jan 2018 22:10:39 +0100 Subject: [PATCH 1/6] recognize ASP.NET website project based on GUID --- src/OmniSharp.MSBuild/ProjectSystem.cs | 2 +- src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/OmniSharp.MSBuild/ProjectSystem.cs b/src/OmniSharp.MSBuild/ProjectSystem.cs index b12aa1bc7a..7b32dc8a89 100644 --- a/src/OmniSharp.MSBuild/ProjectSystem.cs +++ b/src/OmniSharp.MSBuild/ProjectSystem.cs @@ -134,7 +134,7 @@ private IEnumerable GetProjectPathsFromSolution(string solutionFilePath) foreach (var project in solutionFile.Projects) { - if (project.IsSolutionFolder || project.IsAspWebsite()) + if (project.IsSupported) { continue; } diff --git a/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs b/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs index 3745f23f56..aaee4c3a85 100644 --- a/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs +++ b/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs @@ -8,6 +8,7 @@ namespace OmniSharp.MSBuild.SolutionParsing internal class ProjectBlock { private const string SolutionFolderGuid = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"; + private const string LegacyAspNetWebsite = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}"; // An example of a project line looks like this: // Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{DEBCE986-61B9-435E-8018-44B9EF751655}" @@ -32,7 +33,9 @@ internal class ProjectBlock public string ProjectGuid { get; } public ImmutableArray Sections { get; } - public bool IsSolutionFolder => ProjectTypeGuid.Equals(SolutionFolderGuid, StringComparison.OrdinalIgnoreCase); + public bool IsSupported => + ProjectTypeGuid.Equals(SolutionFolderGuid, StringComparison.OrdinalIgnoreCase) || + ProjectTypeGuid.Equals(LegacyAspNetWebsite, StringComparison.OrdinalIgnoreCase); private ProjectBlock(string projectTypeGuid, string projectName, string relativePath, string projectGuid, ImmutableArray sections) { From 3b3710866e0c690b4d164911e14d35ddd77cc456 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 11 Jan 2018 22:34:50 +0100 Subject: [PATCH 2/6] added test for legacy ASP.NET Website --- .../SolutionParsingTests.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs b/tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs index 8d95aaeb9a..6a95515667 100644 --- a/tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs +++ b/tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs @@ -162,6 +162,32 @@ public class SolutionParsingTests EndGlobalSection EndGlobal"; #endregion + #region LegacyAspNetWebsiteSolutionContent + private const string LegacyAspNetWebsiteSolutionContent = @" + Microsoft Visual Studio Solution File, Format Version 12.00 + # Visual Studio 2013 + VisualStudioVersion = 12.0.31101.0 + MinimumVisualStudioVersion = 10.0.40219.1 + Project(""{E24C65DC-7377-472B-9ABA-BC803B73C61A}"") = ""OmniSharp_Test_Website"", ""localhost"", ""{914CBCF1-2DED-4994-AE99-C1CE5FE79EDF}"" + + ProjectSection(WebsiteProperties) = preProject + Debug.AspNetCompiler.Debug = ""True"" + Release.AspNetCompiler.Debug = ""False"" + EndProjectSection + EndProject + Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {914CBCF1-2DED-4994-AE99-C1CE5FE79EDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {914CBCF1-2DED-4994-AE99-C1CE5FE79EDF}.Debug|Any CPU.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + EndGlobal"; + #endregion [Fact] public void SolutionFile_Parse_throws_with_null_text() @@ -298,5 +324,12 @@ public void SolutionFile_Parse_solution_with_project_section() Assert.Equal("ProjectConfigurationPlatforms", solution.GlobalSections[2].Name); Assert.Equal("NestedProjects", solution.GlobalSections[3].Name); } + + [Fact] + public void SolutionFile_LegacyAspNetWebsite_NotSupported() + { + var solution = SolutionFile.Parse(LegacyAspNetWebsiteSolutionContent); + Assert.True(solution.Projects[0].IsSupported); + } } } From 47d53adfcbb69e7fb3578843e3fd949400979f50 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 11 Jan 2018 22:38:22 +0100 Subject: [PATCH 3/6] removed unnecessary code --- src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs b/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs index aaee4c3a85..becc320827 100644 --- a/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs +++ b/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs @@ -46,12 +46,6 @@ private ProjectBlock(string projectTypeGuid, string projectName, string relative Sections = sections; } - public bool IsAspWebsite() - { - var match = Regex.Match(RelativePath, "http://", RegexOptions.IgnoreCase); - return match.Success; - } - public static ProjectBlock Parse(string headerLine, Scanner scanner) { var match = s_lazyProjectHeader.Value.Match(headerLine); From 63aa99e85ba234acfb72f0e845ba3406f0efc132 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 11 Jan 2018 22:41:05 +0100 Subject: [PATCH 4/6] added legacy asp.net website info to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e0efaa18a..a30f4c3bcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All changes to the project will be documented in this file. * Updated to Roslyn 2.6.1 packages - C# 7.2 support, PR: [#1055](https://github.com/OmniSharp/omnisharp-roslyn/pull/1055) * Shipped Language Server Protocol support in box. PR: [#969](https://github.com/OmniSharp/omnisharp-roslyn/pull/969) - Additional information and features tracked at [#968](https://github.com/OmniSharp/omnisharp-roslyn/issues/968) +* Do not crash when encoutering Legacy ASP.NET Website projects. PR: [#1066](https://github.com/OmniSharp/omnisharp-roslyn/pull/1066) and [#1084](https://github.com/OmniSharp/omnisharp-roslyn/pull/1084) ## [1.28.0] - 2017-12-14 From 5a98fc1e2dfb663f857a703a2f12c69e611bee48 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 11 Jan 2018 22:44:35 +0100 Subject: [PATCH 5/6] logic reversal --- src/OmniSharp.MSBuild/ProjectSystem.cs | 2 +- src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs | 2 +- tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OmniSharp.MSBuild/ProjectSystem.cs b/src/OmniSharp.MSBuild/ProjectSystem.cs index 7b32dc8a89..4240e85bf4 100644 --- a/src/OmniSharp.MSBuild/ProjectSystem.cs +++ b/src/OmniSharp.MSBuild/ProjectSystem.cs @@ -134,7 +134,7 @@ private IEnumerable GetProjectPathsFromSolution(string solutionFilePath) foreach (var project in solutionFile.Projects) { - if (project.IsSupported) + if (project.IsNotSupported) { continue; } diff --git a/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs b/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs index becc320827..b1ff18e501 100644 --- a/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs +++ b/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs @@ -33,7 +33,7 @@ internal class ProjectBlock public string ProjectGuid { get; } public ImmutableArray Sections { get; } - public bool IsSupported => + public bool IsNotSupported => ProjectTypeGuid.Equals(SolutionFolderGuid, StringComparison.OrdinalIgnoreCase) || ProjectTypeGuid.Equals(LegacyAspNetWebsite, StringComparison.OrdinalIgnoreCase); diff --git a/tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs b/tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs index 6a95515667..42b059b983 100644 --- a/tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs +++ b/tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs @@ -329,7 +329,7 @@ public void SolutionFile_Parse_solution_with_project_section() public void SolutionFile_LegacyAspNetWebsite_NotSupported() { var solution = SolutionFile.Parse(LegacyAspNetWebsiteSolutionContent); - Assert.True(solution.Projects[0].IsSupported); + Assert.True(solution.Projects[0].IsNotSupported); } } } From b2835d7355c15ed62728e1194a395388aaebfe0b Mon Sep 17 00:00:00 2001 From: filipw Date: Fri, 12 Jan 2018 17:23:46 +0100 Subject: [PATCH 6/6] additional check for path starting with http --- src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs b/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs index b1ff18e501..9cf83c4cfc 100644 --- a/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs +++ b/src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs @@ -35,7 +35,8 @@ internal class ProjectBlock public bool IsNotSupported => ProjectTypeGuid.Equals(SolutionFolderGuid, StringComparison.OrdinalIgnoreCase) || - ProjectTypeGuid.Equals(LegacyAspNetWebsite, StringComparison.OrdinalIgnoreCase); + ProjectTypeGuid.Equals(LegacyAspNetWebsite, StringComparison.OrdinalIgnoreCase) || + (RelativePath != null && RelativePath.ToLowerInvariant().StartsWith("http://")); private ProjectBlock(string projectTypeGuid, string projectName, string relativePath, string projectGuid, ImmutableArray sections) {