From 0a7116b82177a89c558a8ac40f9e4745b509212a Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Thu, 9 Jul 2020 18:40:27 -0700 Subject: [PATCH 1/3] Couple of test cases --- .../FSharpScriptTests.fs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs index 386f9de9ecd..104a6eeaf88 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs @@ -168,12 +168,34 @@ printfn ""%A"" result [] member __.``Eval script with package manager invalid key``() = - use script = new FSharpScript() + use script = new FSharpScript(additionalArgs=[|"/langversion:preview"|]) let result, _errors = script.Eval(@"#r ""nugt:FSharp.Data""") match result with | Ok(_) -> Assert.Fail("expected a failure") | Error(ex) -> Assert.IsInstanceOf(ex) + [] + member __.``Eval script with invalid PackageName should fail immediately``() = + use output = new RedirectConsoleOutput() + use script = new FSharpScript(additionalArgs=[|"/langversion:preview"|]) + let mutable found = 0 + output.OutputProduced.Add (fun line -> if line.Contains("error NU1101:") && line.Contains("FSharp.Really.Not.A.Package") then found <- found + 1) + let _result, _errors = script.Eval("""#r "nuget:FSharp.Really.Not.A.Package" """) + Assert.True( (found = 1), "Expected to see output contains 'error NU1101:' and 'FSharp.Really.Not.A.Package'") + + [] + member __.``Eval script with invalid PackageName should fail immediately and resolve one time only``() = + use output = new RedirectConsoleOutput() + use script = new FSharpScript(additionalArgs=[|"/langversion:preview"|]) + let mutable foundResolve = 0 + output.OutputProduced.Add (fun line -> if line.Contains("Microsoft (R) Build Engine version") then foundResolve <- foundResolve + 1) + let _result, _errors = + script.Eval(""" +#r "nuget:FSharp.Really.Not.A.Package" +#r "nuget:FSharp.Really.Not.Another.Package" + """) + Assert.True( (foundResolve = 1), (sprintf "Expected to see 'Microsoft (R) Build Engine version' resolve only onceactually resolve %d times" foundResolve)) + [] member __.``ML - use assembly with ref dependencies``() = let code = @" From e01ad6e80ff768aaf95c772455623e2f7990c478 Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Thu, 9 Jul 2020 23:58:17 -0700 Subject: [PATCH 2/3] Eager packages --- .../FSharp.DependencyManager.Utilities.fs | 4 ++-- src/fsharp/fsi/fsi.fs | 15 ++++++++++++++- src/fsharp/fsi/fsi.fsproj | 2 +- .../FSharpScriptTests.fs | 9 +++++++-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs b/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs index e16dacc71f6..a79a10a95f7 100644 --- a/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs +++ b/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs @@ -209,10 +209,10 @@ module internal Utilities = let succeeded, stdOut, stdErr = if not (isRunningOnCoreClr) then // The Desktop build uses "msbuild" to build - executeBuild msbuildExePath (arguments "") workingDir + executeBuild msbuildExePath (arguments "-v:quiet") workingDir else // The coreclr uses "dotnet msbuild" to build - executeBuild dotnetHostPath (arguments "msbuild") workingDir + executeBuild dotnetHostPath (arguments "msbuild -v:quiet") workingDir let outputFile = projectPath + ".resolvedReferences.paths" let resultOutFile = if succeeded && File.Exists(outputFile) then Some outputFile else None diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 8bbf592c3f5..232343e24bb 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -2290,6 +2290,19 @@ type internal FsiInteractionProcessor | EndOfFile -> istate,defaultArg lastResult (Completed None) (* drop nextAction on EOF *) | CtrlC -> istate,CtrlC (* drop nextAction on CtrlC *) + /// Execute a single parsed interaction which may contain multiple items to be executed + /// independently, because some are #directives. Called on the GUI/execute/main thread. + /// + /// #directive comes through with other definitions as a SynModuleDecl.HashDirective. + /// We split these out for individual processing. + let executeParsedInteractions (ctok, tcConfig, istate, action, errorLogger: ErrorLogger, lastResult:option, cancellationToken: CancellationToken) = + let istate, completed = execParsedInteractions (ctok, tcConfig, istate, action, errorLogger, lastResult, cancellationToken) + match completed with + | Completed _ -> + let istate = fsiDynamicCompiler.CommitDependencyManagerText(ctok, istate, lexResourceManager, errorLogger) + istate, completed + | _ -> istate, completed + /// Execute a single parsed interaction on the parser/execute thread. let mainThreadProcessAction ctok action istate = try @@ -2314,7 +2327,7 @@ type internal FsiInteractionProcessor let mainThreadProcessParsedInteractions ctok errorLogger (action, istate) cancellationToken = istate |> mainThreadProcessAction ctok (fun ctok tcConfig istate -> - execParsedInteractions (ctok, tcConfig, istate, action, errorLogger, None, cancellationToken)) + executeParsedInteractions (ctok, tcConfig, istate, action, errorLogger, None, cancellationToken)) let parseExpression (tokenizer:LexFilter.LexFilter) = reusingLexbufForParsing tokenizer.LexBuffer (fun () -> diff --git a/src/fsharp/fsi/fsi.fsproj b/src/fsharp/fsi/fsi.fsproj index 32591e18d2e..bb2bcc73b25 100644 --- a/src/fsharp/fsi/fsi.fsproj +++ b/src/fsharp/fsi/fsi.fsproj @@ -10,7 +10,7 @@ .exe $(NoWarn);45;55;62;75;1204 true - $(OtherFlags) --warnon:1182 --maxerrors:20 --extraoptimizationloops:1 + --warnon:1182 --maxerrors:20 --extraoptimizationloops:1 fsi.res true diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs index 104a6eeaf88..a437b95283d 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs @@ -179,7 +179,12 @@ printfn ""%A"" result use output = new RedirectConsoleOutput() use script = new FSharpScript(additionalArgs=[|"/langversion:preview"|]) let mutable found = 0 - output.OutputProduced.Add (fun line -> if line.Contains("error NU1101:") && line.Contains("FSharp.Really.Not.A.Package") then found <- found + 1) + let outp = System.Collections.Generic.List() + output.OutputProduced.Add( + fun line -> + if line.Contains("error NU1101:") && line.Contains("FSharp.Really.Not.A.Package") then + found <- found + 1 + outp.Add(line)) let _result, _errors = script.Eval("""#r "nuget:FSharp.Really.Not.A.Package" """) Assert.True( (found = 1), "Expected to see output contains 'error NU1101:' and 'FSharp.Really.Not.A.Package'") @@ -194,7 +199,7 @@ printfn ""%A"" result #r "nuget:FSharp.Really.Not.A.Package" #r "nuget:FSharp.Really.Not.Another.Package" """) - Assert.True( (foundResolve = 1), (sprintf "Expected to see 'Microsoft (R) Build Engine version' resolve only onceactually resolve %d times" foundResolve)) + Assert.True( (foundResolve = 1), (sprintf "Expected to see 'Microsoft (R) Build Engine version' only once actually resolved %d times" foundResolve)) [] member __.``ML - use assembly with ref dependencies``() = From dfd00322e739927e47f353fedc15dbf53a76a6fc Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Fri, 10 Jul 2020 00:23:09 -0700 Subject: [PATCH 3/3] Update fsi.fs comment --- src/fsharp/fsi/fsi.fs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 232343e24bb..0ef2834ac2b 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -2291,10 +2291,7 @@ type internal FsiInteractionProcessor | CtrlC -> istate,CtrlC (* drop nextAction on CtrlC *) /// Execute a single parsed interaction which may contain multiple items to be executed - /// independently, because some are #directives. Called on the GUI/execute/main thread. - /// - /// #directive comes through with other definitions as a SynModuleDecl.HashDirective. - /// We split these out for individual processing. + /// independently let executeParsedInteractions (ctok, tcConfig, istate, action, errorLogger: ErrorLogger, lastResult:option, cancellationToken: CancellationToken) = let istate, completed = execParsedInteractions (ctok, tcConfig, istate, action, errorLogger, lastResult, cancellationToken) match completed with