Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Added

* Add `#version;;` directive to F# Interactive to display version and environment information. ([Issue #13307](https://github.com/dotnet/fsharp/issues/13307), [PR #19332](https://github.com/dotnet/fsharp/pull/19332))

### Changed

### Breaking Changes
1 change: 1 addition & 0 deletions src/Compiler/Interactive/FSIstrings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fsiIntroTextHashhelpInfo,"Display help"
fsiIntroTextHashhelpdocInfo,"Display documentation for an identifier, e.g. #help \"List.map\";;"
fsiIntroTextHashquitInfo,"Exit"
fsiIntroTextHashclearInfo,"Clear screen"
fsiIntroTextHashversionInfo,"Display F# Interactive version and environment information"
fsiIntroTextHeader2commandLine," F# Interactive command line options:"
fsiIntroTextHeader3," See '%s' for options"
fsiLoadingFilesPrefixText,"Loading"
Expand Down
24 changes: 24 additions & 0 deletions src/Compiler/Interactive/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,21 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
fsiConsoleOutput.uprintfnn "%s" (FSComp.SR.optsCopyright ())
fsiConsoleOutput.uprintfn "%s" (FSIstrings.SR.fsiBanner3 ())

member _.ShowVersion() =
fsiConsoleOutput.uprintnfn "%s" tcConfigB.productNameForBannerText
fsiConsoleOutput.uprintnfn "Language Version: %s" tcConfigB.langVersion.SpecifiedVersionString

let fsharpCoreVersion = typeof<unit>.Assembly.GetName().Version |> string

fsiConsoleOutput.uprintnfn "FSharp.Core: %s" fsharpCoreVersion

fsiConsoleOutput.uprintnfn ".NET: %s" System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription

fsiConsoleOutput.uprintnfn
"OS: %s (%O)"
System.Runtime.InteropServices.RuntimeInformation.OSDescription
System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture

member _.ShowHelp(m) =
let helpLine = sprintf "%s --help" executableFileNameWithoutExtension.Value

Expand Down Expand Up @@ -1294,6 +1309,11 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
fsiConsoleOutput.uprintfn "%s" msg

fsiConsoleOutput.uprintfn """ #clear;; // %s""" (FSIstrings.SR.fsiIntroTextHashclearInfo ())

fsiConsoleOutput.uprintfn
""" #version;; // %s"""
(FSIstrings.SR.fsiIntroTextHashversionInfo ())

fsiConsoleOutput.uprintfn """ #quit;; // %s""" (FSIstrings.SR.fsiIntroTextHashquitInfo ())
fsiConsoleOutput.uprintfn ""
fsiConsoleOutput.uprintfnn "%s" (FSIstrings.SR.fsiIntroTextHeader2commandLine ())
Expand Down Expand Up @@ -3885,6 +3905,10 @@ type FsiInteractionProcessor
fsiOptions.ClearScreen()
istate, Completed None

| ParsedHashDirective("version", [], _) ->
fsiOptions.ShowVersion()
istate, Completed None

| ParsedHashDirective(("q" | "quit"), [], _) -> fsiInterruptController.Exit()

| ParsedHashDirective("help", hashArguments, m) ->
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/Interactive/xlf/FSIstrings.txt.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/FSharp.Compiler.ComponentTests/Scripting/Interactive.fs
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,19 @@ module MultiEmit =
"""if A.v <> 7.2 then failwith $"8: Failed {A.v} <> 7.2" """
"""if B.v <> 9.3 then failwith $"9: Failed {A.v} <> 9.3" """
|] |> Seq.iter(fun item -> item |> scriptIt)

[<Fact>]
let ``Version directive displays version and environment info``() =
Fsx """
#version;;
()
"""
|> withOptions ["--nologo"]
|> runFsi
|> shouldSucceed
|> withStdOutContains "F#"
|> withStdOutContains "Language Version:"
|> withStdOutContains "FSharp.Core:"
|> withStdOutContains ".NET:"
|> withStdOutContains "OS:"
|> ignore
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ x |> Seq.iter(fun r ->
#r "nuget:FSharp.Data, 3.1.2";; // Load Nuget Package 'FSharp.Data' version '3.1.2'
#r "nuget:FSharp.Data";; // Load Nuget Package 'FSharp.Data' with the highest version
#clear;; // Clear screen
#version;; // Display F# Interactive version and environment information
#quit;; // Exit

F# Interactive command line options:"""
Expand Down Expand Up @@ -765,6 +766,7 @@ x |> Seq.iter(fun r ->
#r "nuget:FSharp.Data, 3.1.2";; // Load Nuget Package 'FSharp.Data' version '3.1.2'
#r "nuget:FSharp.Data";; // Load Nuget Package 'FSharp.Data' with the highest version
#clear;; // Clear screen
#version;; // Display F# Interactive version and environment information
#quit;; // Exit

F# Interactive command line options:"""
Expand Down
1 change: 1 addition & 0 deletions tests/fsharp/core/printing/output.1000.stdout.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ type 'a T4063 = | AT4063 of 'a
#r "nuget:FSharp.Data, 3.1.2";; // Load Nuget Package 'FSharp.Data' version '3.1.2'
#r "nuget:FSharp.Data";; // Load Nuget Package 'FSharp.Data' with the highest version
#clear;; // Clear screen
#version;; // Display F# Interactive version and environment information
#quit;; // Exit

F# Interactive command line options:
Expand Down
1 change: 1 addition & 0 deletions tests/fsharp/core/printing/output.200.stdout.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ type 'a T4063 = | AT4063 of 'a
#r "nuget:FSharp.Data, 3.1.2";; // Load Nuget Package 'FSharp.Data' version '3.1.2'
#r "nuget:FSharp.Data";; // Load Nuget Package 'FSharp.Data' with the highest version
#clear;; // Clear screen
#version;; // Display F# Interactive version and environment information
#quit;; // Exit

F# Interactive command line options:
Expand Down
1 change: 1 addition & 0 deletions tests/fsharp/core/printing/output.47.stdout.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -4062,6 +4062,7 @@ type 'a T4063 = | AT4063 of 'a
#help;; // Display help
#help "idn";; // Display documentation for an identifier, e.g. #help "List.map";;
#clear;; // Clear screen
#version;; // Display F# Interactive version and environment information
#quit;; // Exit

F# Interactive command line options:
Expand Down
1 change: 1 addition & 0 deletions tests/fsharp/core/printing/output.multiemit.stdout.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,7 @@ type 'a T4063 = | AT4063 of 'a
#r "nuget:FSharp.Data, 3.1.2";; // Load Nuget Package 'FSharp.Data' version '3.1.2'
#r "nuget:FSharp.Data";; // Load Nuget Package 'FSharp.Data' with the highest version
#clear;; // Clear screen
#version;; // Display F# Interactive version and environment information
#quit;; // Exit

F# Interactive command line options:
Expand Down
1 change: 1 addition & 0 deletions tests/fsharp/core/printing/output.off.stdout.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ type 'a T4063 = | AT4063 of 'a
#r "nuget:FSharp.Data, 3.1.2";; // Load Nuget Package 'FSharp.Data' version '3.1.2'
#r "nuget:FSharp.Data";; // Load Nuget Package 'FSharp.Data' with the highest version
#clear;; // Clear screen
#version;; // Display F# Interactive version and environment information
#quit;; // Exit

F# Interactive command line options:
Expand Down
1 change: 1 addition & 0 deletions tests/fsharp/core/printing/output.stdout.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,7 @@ type 'a T4063 = | AT4063 of 'a
#r "nuget:FSharp.Data, 3.1.2";; // Load Nuget Package 'FSharp.Data' version '3.1.2'
#r "nuget:FSharp.Data";; // Load Nuget Package 'FSharp.Data' with the highest version
#clear;; // Clear screen
#version;; // Display F# Interactive version and environment information
#quit;; // Exit

F# Interactive command line options:
Expand Down
Loading