-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fixRefusingHTTPConenctions
- Loading branch information
Showing
92 changed files
with
2,016 additions
and
545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"sdk": { | ||
"version": "2.1.301" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/OmniSharp.Abstractions/Models/Events/ProjectConfigurationMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
namespace OmniSharp.Models.Events | ||
{ | ||
public class ProjectConfigurationMessage | ||
{ | ||
public string ProjectGuid { get; set; } | ||
public IEnumerable<string> TargetFrameworks { get; set; } | ||
public IEnumerable<string> References { get; set; } | ||
public IEnumerable<string> FileExtensions { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
public class HashedString | ||
{ | ||
public HashedString(string value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
public string Value { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,96 @@ | ||
using Microsoft.Extensions.Logging; | ||
using System.IO; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace OmniSharp.MSBuild.Discovery | ||
{ | ||
internal static class Extensions | ||
{ | ||
public static void RegisterDefaultInstance(this IMSBuildLocator msbuildLocator, ILogger logger) | ||
{ | ||
MSBuildInstance instanceToRegister = null; | ||
var invalidVSFound = false; | ||
var bestInstanceFound = GetBestInstance(msbuildLocator, out var invalidVSFound); | ||
|
||
foreach (var instance in msbuildLocator.GetInstances()) | ||
{ | ||
if (instance.IsInvalidVisualStudio()) | ||
{ | ||
invalidVSFound = true; | ||
} | ||
else | ||
{ | ||
instanceToRegister = instance; | ||
break; | ||
} | ||
} | ||
|
||
|
||
if (instanceToRegister != null) | ||
if (bestInstanceFound != null) | ||
{ | ||
// Did we end up choosing the standalone MSBuild because there was an invalid Visual Studio? | ||
// If so, provide a helpful message to the user. | ||
if (invalidVSFound && instanceToRegister.DiscoveryType == DiscoveryType.StandAlone) | ||
if (invalidVSFound && bestInstanceFound.DiscoveryType == DiscoveryType.StandAlone) | ||
{ | ||
logger.LogWarning(@"It looks like you have Visual Studio 2017 RTM installed. | ||
Try updating Visual Studio 2017 to the most recent release to enable better MSBuild support."); | ||
logger.LogWarning( | ||
@"It looks like you have Visual Studio 2017 RTM installed. | ||
Try updating Visual Studio 2017 to the most recent release to enable better MSBuild support." | ||
); | ||
} | ||
|
||
msbuildLocator.RegisterInstance(instanceToRegister); | ||
msbuildLocator.RegisterInstance(bestInstanceFound); | ||
} | ||
else | ||
{ | ||
logger.LogError("Could not locate MSBuild instance to register with OmniSharp"); | ||
} | ||
} | ||
|
||
public static bool HasDotNetSdksResolvers(this MSBuildInstance instance) | ||
{ | ||
const string dotnetSdkResolver = "Microsoft.DotNet.MSBuildSdkResolver"; | ||
|
||
return File.Exists( | ||
Path.Combine( | ||
instance.MSBuildPath, | ||
"SdkResolvers", | ||
dotnetSdkResolver, | ||
dotnetSdkResolver + ".dll" | ||
) | ||
); | ||
} | ||
|
||
/// <summary> | ||
/// Checks if it is MSBuild from Visual Studio 2017 RTM that cannot be used. | ||
/// </summary> | ||
public static bool IsInvalidVisualStudio(this MSBuildInstance instance) | ||
// MSBuild from Visual Studio 2017 RTM cannot be used. | ||
=> instance.Version.Major == 15 | ||
&& instance.Version.Minor == 0 | ||
&& (instance.DiscoveryType == DiscoveryType.DeveloperConsole | ||
|| instance.DiscoveryType == DiscoveryType.VisualStudioSetup); | ||
&& instance.Version.Minor == 0 | ||
&& (instance.DiscoveryType == DiscoveryType.DeveloperConsole | ||
|| instance.DiscoveryType == DiscoveryType.VisualStudioSetup); | ||
|
||
public static MSBuildInstance GetBestInstance(this IMSBuildLocator msbuildLocator, out bool invalidVSFound) | ||
{ | ||
invalidVSFound = false; | ||
MSBuildInstance bestMatchInstance = null; | ||
var bestMatchScore = 0; | ||
|
||
foreach (var instance in msbuildLocator.GetInstances()) | ||
{ | ||
var score = GetInstanceFeatureScore(instance); | ||
|
||
invalidVSFound = invalidVSFound || instance.IsInvalidVisualStudio(); | ||
|
||
if (score > bestMatchScore | ||
|| (score == bestMatchScore && instance.Version.Major > (bestMatchInstance?.Version.Major ?? 0))) | ||
{ | ||
bestMatchInstance = instance; | ||
bestMatchScore = score; | ||
} | ||
} | ||
|
||
return bestMatchInstance; | ||
} | ||
|
||
private static int GetInstanceFeatureScore(MSBuildInstance i) | ||
{ | ||
var score = 0; | ||
|
||
if (i.HasDotNetSdksResolvers()) | ||
score++; | ||
|
||
if (i.IsInvalidVisualStudio()) | ||
return int.MinValue; | ||
else | ||
score++; | ||
|
||
if (i.DiscoveryType == DiscoveryType.StandAlone) | ||
score--; | ||
|
||
return score; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.