Skip to content

Commit

Permalink
Merge pull request #321 from waf/fix-relative-path-files-passed-as-lo…
Browse files Browse the repository at this point in the history
…ad-scripts

Fix CSX loading using relative paths from command line
  • Loading branch information
waf authored Nov 17, 2023
2 parents ba21d40 + e073462 commit d56d924
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CSharpRepl.Services/Roslyn/Scripting/ScriptRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public ScriptRunner(
);
this.scriptOptions = ScriptOptions.Default
.WithMetadataResolver(metadataResolver)
.WithSourceResolver(compilationOptions.SourceReferenceResolver)
.WithReferences(referenceAssemblyService.LoadedImplementationAssemblies)
.WithAllowUnsafe(compilationOptions.AllowUnsafe)
.WithLanguageVersion(LanguageVersion.Preview)
Expand Down
18 changes: 18 additions & 0 deletions CSharpRepl.Tests/ReadEvalPrintLoopTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,24 @@ await repl.RunAsync(new Configuration(
Assert.Contains(@"""Hello World""", console.AnsiConsole.Output);
}

[Fact]
public async Task RunAsync_LoadScriptByFilePath_RunsScript()
{
prompt
.ReadLineAsync()
.Returns(
new PromptResult(true, "exit", default)
);

await repl.RunAsync(new Configuration(
loadScript: "#load \"Data/LoadScript.csx\""
));

Assert.DoesNotContain("Exception", console.AnsiConsole.Output);
Assert.DoesNotContain("CS1504", console.AnsiConsole.Output);
Assert.DoesNotContain("Could not find file", console.AnsiConsole.Output);
}

[Fact]
public async Task RunAsync_Reference_AddsReference()
{
Expand Down

0 comments on commit d56d924

Please sign in to comment.