Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect legacy ASP.NET Websites via project GUID #1084

Merged
merged 6 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/OmniSharp.MSBuild/ProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private IEnumerable<string> GetProjectPathsFromSolution(string solutionFilePath)

foreach (var project in solutionFile.Projects)
{
if (project.IsSolutionFolder || project.IsAspWebsite())
if (project.IsNotSupported)
{
continue;
}
Expand Down
12 changes: 5 additions & 7 deletions src/OmniSharp.MSBuild/SolutionParsing/ProjectBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -32,7 +33,10 @@ internal class ProjectBlock
public string ProjectGuid { get; }
public ImmutableArray<SectionBlock> Sections { get; }

public bool IsSolutionFolder => ProjectTypeGuid.Equals(SolutionFolderGuid, StringComparison.OrdinalIgnoreCase);
public bool IsNotSupported =>
ProjectTypeGuid.Equals(SolutionFolderGuid, StringComparison.OrdinalIgnoreCase) ||
ProjectTypeGuid.Equals(LegacyAspNetWebsite, StringComparison.OrdinalIgnoreCase) ||
(RelativePath != null && RelativePath.ToLowerInvariant().StartsWith("http://"));

private ProjectBlock(string projectTypeGuid, string projectName, string relativePath, string projectGuid, ImmutableArray<SectionBlock> sections)
{
Expand All @@ -43,12 +47,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);
Expand Down
33 changes: 33 additions & 0 deletions tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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].IsNotSupported);
}
}
}