Skip to content

Commit 4b4cfea

Browse files
committed
Add #version;; directive to F# Interactive
Prints version, .NET runtime, and OS/architecture info on demand, useful for debugging and bug reporting when the startup banner has scrolled away. Closes #13307.
1 parent cb4bfe4 commit 4b4cfea

24 files changed

Lines changed: 109 additions & 0 deletions

docs/release-notes/.FSharp.Compiler.Service/10.0.300.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Added
44

5+
* 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))
6+
57
### Changed
68

79
### Breaking Changes

src/Compiler/Interactive/FSIstrings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fsiIntroTextHashhelpInfo,"Display help"
3535
fsiIntroTextHashhelpdocInfo,"Display documentation for an identifier, e.g. #help \"List.map\";;"
3636
fsiIntroTextHashquitInfo,"Exit"
3737
fsiIntroTextHashclearInfo,"Clear screen"
38+
fsiIntroTextHashversionInfo,"Display F# Interactive version and environment information"
3839
fsiIntroTextHeader2commandLine," F# Interactive command line options:"
3940
fsiIntroTextHeader3," See '%s' for options"
4041
fsiLoadingFilesPrefixText,"Loading"

src/Compiler/Interactive/fsi.fs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,16 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
12631263
fsiConsoleOutput.uprintfnn "%s" (FSComp.SR.optsCopyright ())
12641264
fsiConsoleOutput.uprintfn "%s" (FSIstrings.SR.fsiBanner3 ())
12651265

1266+
member _.ShowVersion() =
1267+
fsiConsoleOutput.uprintnfn "%s" tcConfigB.productNameForBannerText
1268+
1269+
fsiConsoleOutput.uprintnfn ".NET: %s" System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
1270+
1271+
fsiConsoleOutput.uprintnfn
1272+
"OS: %s (%O)"
1273+
System.Runtime.InteropServices.RuntimeInformation.OSDescription
1274+
System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture
1275+
12661276
member _.ShowHelp(m) =
12671277
let helpLine = sprintf "%s --help" executableFileNameWithoutExtension.Value
12681278

@@ -1294,6 +1304,11 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
12941304
fsiConsoleOutput.uprintfn "%s" msg
12951305

12961306
fsiConsoleOutput.uprintfn """ #clear;; // %s""" (FSIstrings.SR.fsiIntroTextHashclearInfo ())
1307+
1308+
fsiConsoleOutput.uprintfn
1309+
""" #version;; // %s"""
1310+
(FSIstrings.SR.fsiIntroTextHashversionInfo ())
1311+
12971312
fsiConsoleOutput.uprintfn """ #quit;; // %s""" (FSIstrings.SR.fsiIntroTextHashquitInfo ())
12981313
fsiConsoleOutput.uprintfn ""
12991314
fsiConsoleOutput.uprintfnn "%s" (FSIstrings.SR.fsiIntroTextHeader2commandLine ())
@@ -3885,6 +3900,10 @@ type FsiInteractionProcessor
38853900
fsiOptions.ClearScreen()
38863901
istate, Completed None
38873902

3903+
| ParsedHashDirective("version", [], _) ->
3904+
fsiOptions.ShowVersion()
3905+
istate, Completed None
3906+
38883907
| ParsedHashDirective(("q" | "quit"), [], _) -> fsiInterruptController.Exit()
38893908

38903909
| ParsedHashDirective("help", hashArguments, m) ->

src/Compiler/Interactive/xlf/FSIstrings.txt.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/Interactive/xlf/FSIstrings.txt.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/Interactive/xlf/FSIstrings.txt.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/Interactive/xlf/FSIstrings.txt.fr.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/Interactive/xlf/FSIstrings.txt.it.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/Interactive/xlf/FSIstrings.txt.ja.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/Interactive/xlf/FSIstrings.txt.ko.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)