-
Notifications
You must be signed in to change notification settings - Fork 420
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
Bump Dotnet.Script.DependencyModel to version 0.50.0 #1609
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6f691eb
Bumped Dotnet.Script.DependencyModel
seesharper 1f04e8c
Added NullableDiagnostics
seesharper 47a0216
Make NullableDianostics lazy
seesharper 9e4ba2e
Update to Dotnet.Script.DependencyModel 0.50.0
seesharper 75acdd7
Packages
seesharper f804678
Dotnet.Script.DependencyModel 0.50.0
seesharper 1a4c5cb
Merge remote-tracking branch 'upstream/master'
seesharper 3bbc506
Bump Nuget package version
seesharper d44b8c1
Add detected script files to ScriptOptions
seesharper cbe9473
Pass csx files to CreateScriptContext
seesharper 4d51320
Map all log levels
seesharper 2afcc5b
Merge remote-tracking branch 'upstream/master'
seesharper 729bc54
Reset and re-edit packages.props
seesharper a3c63bb
Resolve highest compilation assembly version
seesharper 0d25abd
Merge remote-tracking branch 'upstream/master'
seesharper c436758
Merge branch 'master' into master
seesharper 6cb6e09
Merge branch 'master' into master
david-driscoll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Scripting.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using OmniSharp.FileSystem; | ||
using OmniSharp.Roslyn.Utilities; | ||
using OmniSharp.Services; | ||
using LogLevel = Dotnet.Script.DependencyModel.Logging.LogLevel; | ||
|
@@ -23,22 +24,28 @@ public class ScriptContextProvider | |
private readonly CompilationDependencyResolver _compilationDependencyResolver; | ||
private readonly IOmniSharpEnvironment _env; | ||
private readonly MetadataFileReferenceCache _metadataFileReferenceCache; | ||
private readonly FileSystemHelper _fileSystemHelper; | ||
private readonly ILogger _logger; | ||
|
||
[ImportingConstructor] | ||
public ScriptContextProvider(ILoggerFactory loggerFactory, IOmniSharpEnvironment env, MetadataFileReferenceCache metadataFileReferenceCache) | ||
public ScriptContextProvider(ILoggerFactory loggerFactory, IOmniSharpEnvironment env, MetadataFileReferenceCache metadataFileReferenceCache, FileSystemHelper fileSystemHelper) | ||
{ | ||
_loggerFactory = loggerFactory; | ||
_env = env; | ||
_metadataFileReferenceCache = metadataFileReferenceCache; | ||
_fileSystemHelper = fileSystemHelper; | ||
_logger = loggerFactory.CreateLogger<ScriptContextProvider>(); | ||
_compilationDependencyResolver = new CompilationDependencyResolver(type => | ||
{ | ||
// Prefix with "OmniSharp" so that we make it through the log filter. | ||
var categoryName = $"OmniSharp.Script.{type.FullName}"; | ||
var dependencyResolverLogger = loggerFactory.CreateLogger(categoryName); | ||
return ((level, message) => | ||
return ((level, message, exception) => | ||
{ | ||
if (level == LogLevel.Trace) | ||
{ | ||
dependencyResolverLogger.LogTrace(message); | ||
} | ||
if (level == LogLevel.Debug) | ||
{ | ||
dependencyResolverLogger.LogDebug(message); | ||
|
@@ -47,11 +54,23 @@ public ScriptContextProvider(ILoggerFactory loggerFactory, IOmniSharpEnvironment | |
{ | ||
dependencyResolverLogger.LogInformation(message); | ||
} | ||
if (level == LogLevel.Warning) | ||
{ | ||
dependencyResolverLogger.LogWarning(message); | ||
} | ||
if (level == LogLevel.Error) | ||
{ | ||
dependencyResolverLogger.LogError(exception, message); | ||
} | ||
if (level == LogLevel.Critical) | ||
{ | ||
dependencyResolverLogger.LogCritical(exception, message); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
public ScriptContext CreateScriptContext(ScriptOptions scriptOptions) | ||
public ScriptContext CreateScriptContext(ScriptOptions scriptOptions, string[] allCsxFiles) | ||
{ | ||
var currentDomainAssemblies = AppDomain.CurrentDomain.GetAssemblies(); | ||
|
||
|
@@ -67,7 +86,7 @@ public ScriptContext CreateScriptContext(ScriptOptions scriptOptions) | |
try | ||
{ | ||
_logger.LogInformation($"Searching for compilation dependencies with the fallback framework of '{scriptOptions.DefaultTargetFramework}'."); | ||
compilationDependencies = _compilationDependencyResolver.GetDependencies(_env.TargetDirectory, scriptOptions.IsNugetEnabled(), scriptOptions.DefaultTargetFramework).ToArray(); | ||
compilationDependencies = _compilationDependencyResolver.GetDependencies(_env.TargetDirectory, allCsxFiles, scriptOptions.IsNugetEnabled(), scriptOptions.DefaultTargetFramework).ToArray(); | ||
} | ||
catch (Exception e) | ||
{ | ||
|
@@ -92,7 +111,13 @@ public ScriptContext CreateScriptContext(ScriptOptions scriptOptions) | |
isDesktopClr = false; | ||
HashSet<string> loadedFiles = new HashSet<string>(StringComparer.OrdinalIgnoreCase); | ||
|
||
foreach (var compilationAssembly in compilationDependencies.SelectMany(cd => cd.AssemblyPaths).Distinct()) | ||
// Pick the highest version | ||
var resolvedAssemblyPaths = compilationDependencies.SelectMany(cd => cd.AssemblyPaths) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "one liner" 😂 |
||
.Select(path => new { AssemblyName = AssemblyName.GetAssemblyName(path), Path = path }).Distinct() | ||
.GroupBy(nameAndPath => nameAndPath.AssemblyName.Name, nameAndPath => nameAndPath) | ||
.Select(gr => gr.OrderBy(nameAndPath => nameAndPath.AssemblyName.Version).Last()).Select(nameAndPath => nameAndPath.Path); | ||
|
||
foreach (var compilationAssembly in resolvedAssemblyPaths) | ||
{ | ||
if (loadedFiles.Add(Path.GetFileName(compilationAssembly))) | ||
{ | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please reset the changes to this file so that only the relevant lines are updated? we often look here at the blame to identify when a specific dependency was introduced - and this will break it