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

Omnisharp now uses libPaths and sourcePaths defined in custom .rsp file #2000

Merged
merged 2 commits into from
Nov 4, 2020
Merged
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
38 changes: 35 additions & 3 deletions src/OmniSharp.Script/ScriptProjectProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -125,9 +129,37 @@ private CSharpCompilationOptions CreateCompilationOptions()
return compilationOptions;
}

private CachingScriptMetadataResolver CreateMetadataReferenceResolver()
private ScriptSourceResolver CreateScriptSourceResolver(IEnumerable<string> searchPaths)
{
var defaultResolver = ScriptSourceResolver.Default;

if (searchPaths != null)
{
defaultResolver = defaultResolver.WithSearchPaths(searchPaths);

foreach (string path in searchPaths)
{
_logger.LogInformation($"CSX source path: {path}.");
}
}

return defaultResolver;
}

private CachingScriptMetadataResolver CreateMetadataReferenceResolver(IEnumerable<string> 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
Expand Down