From a8297a6b9fdb167f788d02a072ff5aec76bbdf1b Mon Sep 17 00:00:00 2001 From: ByronMayne Date: Tue, 3 Nov 2020 12:37:04 -0500 Subject: [PATCH 1/2] C# Scripting now uses the loadPaths and libPaths from rsp file Before these values were being parsed but not used. --- src/OmniSharp.Script/ScriptProjectProvider.cs | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/OmniSharp.Script/ScriptProjectProvider.cs b/src/OmniSharp.Script/ScriptProjectProvider.cs index 6109b0d461..6eac29cea2 100644 --- a/src/OmniSharp.Script/ScriptProjectProvider.cs +++ b/src/OmniSharp.Script/ScriptProjectProvider.cs @@ -98,10 +98,14 @@ private CSharpCompilationOptions CreateCompilationOptions() _logger.LogDebug($"CSX global using statement: {ns}"); } + var metadataReferenceResolver = CreateMetadataReferenceResolver(csharpCommandLineArguments?.ReferencePaths); + var sourceResolver = CreateScriptSourceResolver(csharpCommandLineArguments?.SourcePaths); + compilationOptions = compilationOptions .WithAllowUnsafe(true) - .WithMetadataReferenceResolver(CreateMetadataReferenceResolver()) - .WithSourceReferenceResolver(ScriptSourceResolver.Default) + + .WithMetadataReferenceResolver(metadataReferenceResolver) + .WithSourceReferenceResolver(sourceResolver) .WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default) .WithSpecificDiagnosticOptions(!_scriptOptions.IsNugetEnabled() ? CompilationOptionsHelper.GetDefaultSuppressedDiagnosticOptions() @@ -125,9 +129,39 @@ private CSharpCompilationOptions CreateCompilationOptions() return compilationOptions; } - private CachingScriptMetadataResolver CreateMetadataReferenceResolver() + private ScriptSourceResolver CreateScriptSourceResolver(IEnumerable searchPaths) + { + var defaultResolver = ScriptSourceResolver.Default; + + if (searchPaths == null) + { + return defaultResolver; + } + + defaultResolver = defaultResolver.WithSearchPaths(searchPaths); + + foreach (string path in searchPaths) + { + _logger.LogInformation($"CSX source path: {path}."); + } + + return defaultResolver; + } + + private CachingScriptMetadataResolver CreateMetadataReferenceResolver(IEnumerable searchPaths) { var defaultResolver = ScriptMetadataResolver.Default.WithBaseDirectory(_env.TargetDirectory); + + if (searchPaths != null) + { + defaultResolver = defaultResolver.WithSearchPaths(searchPaths); + + foreach (string path in searchPaths) + { + _logger.LogInformation($"CSX reference path: {path}."); + } + } + InjectXMLDocumentationProviderIntoRuntimeMetadataReferenceResolver(defaultResolver); var decoratedResolver = _scriptOptions.EnableScriptNuGetReferences From d8ed4ba34bfba73eff10a7e73f7bc769448f38eb Mon Sep 17 00:00:00 2001 From: ByronMayne Date: Tue, 3 Nov 2020 12:39:51 -0500 Subject: [PATCH 2/2] Removed the early return --- src/OmniSharp.Script/ScriptProjectProvider.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/OmniSharp.Script/ScriptProjectProvider.cs b/src/OmniSharp.Script/ScriptProjectProvider.cs index 6eac29cea2..24436d0db9 100644 --- a/src/OmniSharp.Script/ScriptProjectProvider.cs +++ b/src/OmniSharp.Script/ScriptProjectProvider.cs @@ -133,16 +133,14 @@ private ScriptSourceResolver CreateScriptSourceResolver(IEnumerable sear { var defaultResolver = ScriptSourceResolver.Default; - if (searchPaths == null) + if (searchPaths != null) { - return defaultResolver; - } - - defaultResolver = defaultResolver.WithSearchPaths(searchPaths); + defaultResolver = defaultResolver.WithSearchPaths(searchPaths); - foreach (string path in searchPaths) - { - _logger.LogInformation($"CSX source path: {path}."); + foreach (string path in searchPaths) + { + _logger.LogInformation($"CSX source path: {path}."); + } } return defaultResolver;