Skip to content

Commit

Permalink
Show default value of compiler options (#18054)
Browse files Browse the repository at this point in the history
* Show default value of compiler options

* Locale files

* Revert "Show default value of compiler options"

This reverts commit 842c2c1.

* Revert "Locale files"

This reverts commit 47de522.

* Draft

* Auto-generated default values

* Update compiler_help_output.bsl

* Format file

* Update expected-help-output.bsl

* Update help baseline files

* Update release notes

---------

Co-authored-by: nih0n <feh.omori@gmail.com>
  • Loading branch information
nih0n and nih0n authored Dec 16, 2024
1 parent 3914a47 commit 143e375
Show file tree
Hide file tree
Showing 36 changed files with 767 additions and 702 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Added project property ParallelCompilation which turns on graph based type checking, parallel ILXGen and parallel optimization. By default on for users of langversion=preview ([PR #17948](https://github.com/dotnet/fsharp/pull/17948))
* Adding warning when consuming generic method returning T|null for types not supporting nullness (structs,anons,tuples) ([PR #18057](https://github.com/dotnet/fsharp/pull/18057))
* Sink: report SynPat.ArrayOrList type ([PR #18127](https://github.com/dotnet/fsharp/pull/18127))
* Show the default value of compiler options ([PR #18054](https://github.com/dotnet/fsharp/pull/18054))

### Changed

Expand Down
78 changes: 60 additions & 18 deletions src/Compiler/Driver/CompilerOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,8 @@ let setSignatureFile tcConfigB s =
let setAllSignatureFiles tcConfigB () =
tcConfigB.printAllSignatureFiles <- true

let formatOptionSwitch (value: bool) = if value then "on" else "off"

// option tags
let tagString = "<string>"
let tagExe = "exe"
Expand Down Expand Up @@ -806,7 +808,7 @@ let errorsAndWarningsFlags (tcConfigB: TcConfigBuilder) =
GlobalWarnAsError = switch <> OptionSwitch.Off
}),
None,
Some(FSComp.SR.optsWarnaserrorPM ())
Some(FSComp.SR.optsWarnaserrorPM (formatOptionSwitch tcConfigB.diagnosticsOptions.GlobalWarnAsError))
)

CompilerOption(
Expand Down Expand Up @@ -870,15 +872,15 @@ let errorsAndWarningsFlags (tcConfigB: TcConfigBuilder) =
tagNone,
OptionSwitch(fun switch -> tcConfigB.checkNullness <- switch = OptionSwitch.On),
None,
Some(FSComp.SR.optsCheckNulls ())
Some(FSComp.SR.optsCheckNulls (formatOptionSwitch tcConfigB.checkNullness))
)

CompilerOption(
"consolecolors",
tagNone,
OptionSwitch(fun switch -> enableConsoleColoring <- switch = OptionSwitch.On),
None,
Some(FSComp.SR.optsConsoleColors ())
Some(FSComp.SR.optsConsoleColors (formatOptionSwitch enableConsoleColoring))
)
]

Expand All @@ -904,15 +906,15 @@ let outputFileFlagsFsc (tcConfigB: TcConfigBuilder) =
tagNone,
OptionSwitch(fun s -> tcConfigB.delaysign <- (s = OptionSwitch.On)),
None,
Some(FSComp.SR.optsDelaySign ())
Some(FSComp.SR.optsDelaySign (formatOptionSwitch tcConfigB.delaysign))
)

CompilerOption(
"publicsign",
tagNone,
OptionSwitch(fun s -> tcConfigB.publicsign <- (s = OptionSwitch.On)),
None,
Some(FSComp.SR.optsPublicSign ())
Some(FSComp.SR.optsPublicSign (formatOptionSwitch tcConfigB.publicsign))
)

CompilerOption("doc", tagFile, OptionString(fun s -> tcConfigB.xmlDocOutputFile <- Some s), None, Some(FSComp.SR.optsWriteXml ()))
Expand Down Expand Up @@ -944,7 +946,7 @@ let outputFileFlagsFsc (tcConfigB: TcConfigBuilder) =
tagNone,
OptionSwitch(fun switch -> tcConfigB.compressMetadata <- switch = OptionSwitch.On),
None,
Some(FSComp.SR.optsCompressMetadata ())
Some(FSComp.SR.optsCompressMetadata (formatOptionSwitch tcConfigB.compressMetadata))
)

CompilerOption(
Expand Down Expand Up @@ -975,7 +977,13 @@ let outputFileFlagsFsc (tcConfigB: TcConfigBuilder) =
Some(FSComp.SR.optsNoCopyFsharpCore ())
)

CompilerOption("refonly", tagNone, OptionSwitch(SetReferenceAssemblyOnlySwitch tcConfigB), None, Some(FSComp.SR.optsRefOnly ()))
CompilerOption(
"refonly",
tagNone,
OptionSwitch(SetReferenceAssemblyOnlySwitch tcConfigB),
None,
Some(FSComp.SR.optsRefOnly (formatOptionSwitch (tcConfigB.emitMetadataAssembly <> MetadataAssemblyGeneration.None)))
)

CompilerOption("refout", tagFile, OptionString(SetReferenceAssemblyOutSwitch tcConfigB), None, Some(FSComp.SR.optsRefOut ()))
]
Expand Down Expand Up @@ -1023,7 +1031,13 @@ let resourcesFlagsFsc (tcConfigB: TcConfigBuilder) =
let codeGenerationFlags isFsi (tcConfigB: TcConfigBuilder) =
let debug =
[
CompilerOption("debug", tagNone, OptionSwitch(SetDebugSwitch tcConfigB None), None, Some(FSComp.SR.optsDebugPM ()))
CompilerOption(
"debug",
tagNone,
OptionSwitch(SetDebugSwitch tcConfigB None),
None,
Some(FSComp.SR.optsDebugPM (formatOptionSwitch tcConfigB.debuginfo))
)

CompilerOption(
"debug",
Expand All @@ -1036,7 +1050,13 @@ let codeGenerationFlags isFsi (tcConfigB: TcConfigBuilder) =

let embed =
[
CompilerOption("embed", tagNone, OptionSwitch(SetEmbedAllSourceSwitch tcConfigB), None, Some(FSComp.SR.optsEmbedAllSource ()))
CompilerOption(
"embed",
tagNone,
OptionSwitch(SetEmbedAllSourceSwitch tcConfigB),
None,
Some(FSComp.SR.optsEmbedAllSource (formatOptionSwitch tcConfigB.embedAllSource))
)

CompilerOption("embed", tagFileList, OptionStringList tcConfigB.AddEmbeddedSourceFile, None, Some(FSComp.SR.optsEmbedSource ()))

Expand All @@ -1045,19 +1065,37 @@ let codeGenerationFlags isFsi (tcConfigB: TcConfigBuilder) =

let codegen =
[
CompilerOption("optimize", tagNone, OptionSwitch(SetOptimizeSwitch tcConfigB), None, Some(FSComp.SR.optsOptimize ()))
CompilerOption(
"optimize",
tagNone,
OptionSwitch(SetOptimizeSwitch tcConfigB),
None,
Some(FSComp.SR.optsOptimize (formatOptionSwitch (tcConfigB.optSettings <> OptimizationSettings.Defaults)))
)

CompilerOption("tailcalls", tagNone, OptionSwitch(SetTailcallSwitch tcConfigB), None, Some(FSComp.SR.optsTailcalls ()))
CompilerOption(
"tailcalls",
tagNone,
OptionSwitch(SetTailcallSwitch tcConfigB),
None,
Some(FSComp.SR.optsTailcalls (formatOptionSwitch tcConfigB.emitTailcalls))
)

CompilerOption(
"deterministic",
tagNone,
OptionSwitch(SetDeterministicSwitch tcConfigB),
None,
Some(FSComp.SR.optsDeterministic ())
Some(FSComp.SR.optsDeterministic (formatOptionSwitch tcConfigB.deterministic))
)

CompilerOption("realsig", tagNone, OptionSwitch(SetRealsig tcConfigB), None, Some(FSComp.SR.optsRealsig ()))
CompilerOption(
"realsig",
tagNone,
OptionSwitch(SetRealsig tcConfigB),
None,
Some(FSComp.SR.optsRealsig (formatOptionSwitch tcConfigB.realsig))
)

CompilerOption("pathmap", tagPathMap, OptionStringList(AddPathMapping tcConfigB), None, Some(FSComp.SR.optsPathMap ()))

Expand All @@ -1066,7 +1104,11 @@ let codeGenerationFlags isFsi (tcConfigB: TcConfigBuilder) =
tagNone,
OptionSwitch(crossOptimizeSwitch tcConfigB),
None,
Some(FSComp.SR.optsCrossoptimize ())
Some(
FSComp.SR.optsCrossoptimize (
formatOptionSwitch (Option.defaultValue false tcConfigB.optSettings.crossAssemblyOptimizationUser)
)
)
)

CompilerOption(
Expand Down Expand Up @@ -1144,7 +1186,7 @@ let languageFlags tcConfigB =
tagNone,
OptionSwitch(fun switch -> tcConfigB.checkOverflow <- (switch = OptionSwitch.On)),
None,
Some(FSComp.SR.optsChecked ())
Some(FSComp.SR.optsChecked (formatOptionSwitch tcConfigB.checkOverflow))
)

CompilerOption("define", tagString, OptionString(defineSymbol tcConfigB), None, Some(FSComp.SR.optsDefine ()))
Expand All @@ -1156,7 +1198,7 @@ let languageFlags tcConfigB =
tagNone,
OptionSwitch(fun switch -> tcConfigB.strictIndentation <- Some(switch = OptionSwitch.On)),
None,
Some(FSComp.SR.optsStrictIndentation ())
Some(FSComp.SR.optsStrictIndentation (formatOptionSwitch (Option.defaultValue false tcConfigB.strictIndentation)))
)
]

Expand Down Expand Up @@ -1328,7 +1370,7 @@ let advancedFlagsFsc tcConfigB =
tagNone,
OptionSwitch(useHighEntropyVASwitch tcConfigB),
None,
Some(FSComp.SR.optsUseHighEntropyVA ())
Some(FSComp.SR.optsUseHighEntropyVA (formatOptionSwitch tcConfigB.useHighEntropyVA))
)

CompilerOption(
Expand All @@ -1344,7 +1386,7 @@ let advancedFlagsFsc tcConfigB =
tagNone,
OptionSwitch(fun switch -> tcConfigB.emitDebugInfoInQuotations <- switch = OptionSwitch.On),
None,
Some(FSComp.SR.optsEmitDebugInfoInQuotations ())
Some(FSComp.SR.optsEmitDebugInfoInQuotations (formatOptionSwitch tcConfigB.emitDebugInfoInQuotations))
)
]

Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/Driver/CompilerOptions.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ val ignoreFailureOnMono1_1_16: (unit -> unit) -> unit

val mutable enableConsoleColoring: bool

val formatOptionSwitch: bool -> string

val DoWithColor: ConsoleColor -> (unit -> 'T) -> 'T

val DoWithDiagnosticColor: FSharpDiagnosticSeverity -> (unit -> 'T) -> 'T
Expand Down
36 changes: 18 additions & 18 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,12 @@ optsBuildConsole,"Build a console executable"
optsBuildWindows,"Build a Windows executable"
optsBuildLibrary,"Build a library (Short form: -a)"
optsBuildModule,"Build a module that can be added to another assembly"
optsDelaySign,"Delay-sign the assembly using only the public portion of the strong name key"
optsPublicSign,"Public-sign the assembly using only the public portion of the strong name key, and mark the assembly as signed"
optsDelaySign,"Delay-sign the assembly using only the public portion of the strong name key (%s by default)"
optsPublicSign,"Public-sign the assembly using only the public portion of the strong name key, and mark the assembly as signed (%s by default)"
optsWriteXml,"Write the xmldoc of the assembly to the given file"
optsStrongKeyFile,"Specify a strong name key file"
optsStrongKeyContainer,"Specify a strong name key container"
optsCompressMetadata,"Compress interface and optimization data files"
optsCompressMetadata,"Compress interface and optimization data files (%s by default)"
optsPlatform,"Limit which platforms this code can run on: x86, x64, Arm, Arm64, Itanium, anycpu32bitpreferred, or anycpu. The default is anycpu."
optsNoOpt,"Only include optimization information essential for implementing inlined constructs. Inhibits cross-module inlining but improves binary compatibility."
optsNoInterface,"Don't add a resource to the generated assembly containing F#-specific metadata"
Expand All @@ -867,30 +867,30 @@ optsWin32icon,"Specify a Win32 icon file (.ico)"
optsWin32res,"Specify a Win32 resource file (.res)"
optsWin32manifest,"Specify a Win32 manifest file"
optsNowin32manifest,"Do not include the default Win32 manifest"
optsEmbedAllSource,"Embed all source files in the portable PDB file"
optsEmbedAllSource,"Embed all source files in the portable PDB file (%s by default)"
optsEmbedSource,"Embed specific source files in the portable PDB file"
optsSourceLink,"Source link information file to embed in the portable PDB file"
1001,optsPdbMatchesOutputFileName,"The pdb output file name cannot match the build output filename use --pdb:filename.pdb"
srcFileTooLarge,"Source file is too large to embed in a portable PDB"
optsResource,"Embed the specified managed resource"
optsLinkresource,"Link the specified resource to this assembly where the resinfo format is <file>[,<string name>[,public|private]]"
optsDebugPM,"Emit debug information (Short form: -g)"
optsDebugPM,"Emit debug information (Short form: -g) (%s by default)"
optsDebug,"Specify debugging type: full, portable, embedded, pdbonly. ('%s' is the default if no debugging type specified and enables attaching a debugger to a running program, 'portable' is a cross-platform format, 'embedded' is a cross-platform format embedded into the output file)."
optsOptimize,"Enable optimizations (Short form: -O)"
optsTailcalls,"Enable or disable tailcalls"
optsDeterministic,"Produce a deterministic assembly (including module version GUID and timestamp)"
optsRealsig,"Generate assembly with IL visibility that matches the source code visibility"
optsRefOnly,"Produce a reference assembly, instead of a full assembly, as the primary output"
optsOptimize,"Enable optimizations (Short form: -O) (%s by default)"
optsTailcalls,"Enable or disable tailcalls (%s by default)"
optsDeterministic,"Produce a deterministic assembly (including module version GUID and timestamp) (%s by default)"
optsRealsig,"Generate assembly with IL visibility that matches the source code visibility (%s by default)"
optsRefOnly,"Produce a reference assembly, instead of a full assembly, as the primary output (%s by default)"
optsRefOut,"Produce a reference assembly with the specified file path."
optsPathMap,"Maps physical paths to source path names output by the compiler"
optsCrossoptimize,"Enable or disable cross-module optimizations"
optsCrossoptimize,"Enable or disable cross-module optimizations (%s by default)"
optsReflectionFree,"Disable implicit generation of constructs using reflection"
optsWarnaserrorPM,"Report all warnings as errors"
optsWarnaserrorPM,"Report all warnings as errors (%s by default)"
optsWarnaserror,"Report specific warnings as errors"
optsWarn,"Set a warning level (0-5)"
optsNowarn,"Disable specific warning messages"
optsWarnOn,"Enable specific warnings that may be off by default"
optsChecked,"Generate overflow checks"
optsChecked,"Generate overflow checks (%s by default)"
optsDefine,"Define conditional compilation symbols (Short form: -d)"
optsMlcompatibility,"Ignore ML compatibility warnings"
optsNologo,"Suppress compiler copyright message"
Expand Down Expand Up @@ -925,11 +925,11 @@ optsInternalNoDescription,"The command-line option '%s' is for test purposes onl
optsDCLONoDescription,"The command-line option '%s' has been deprecated"
optsDCLODeprecatedSuggestAlternative,"The command-line option '%s' has been deprecated. Use '%s' instead."
optsDCLOHtmlDoc,"The command-line option '%s' has been deprecated. HTML document generation is now part of the F# Power Pack, via the tool FsHtmlDoc.exe."
optsConsoleColors,"Output warning and error messages in color"
optsUseHighEntropyVA,"Enable high-entropy ASLR"
optsConsoleColors,"Output warning and error messages in color (%s by default)"
optsUseHighEntropyVA,"Enable high-entropy ASLR (%s by default)"
optsSubSystemVersion,"Specify subsystem version of this assembly"
optsTargetProfile,"Specify target framework profile of this assembly. Valid values are mscorlib, netcore or netstandard. Default - mscorlib"
optsEmitDebugInfoInQuotations,"Emit debug information in quotations"
optsEmitDebugInfoInQuotations,"Emit debug information in quotations (%s by default)"
optsPreferredUiLang,"Specify the preferred output language culture name (e.g. es-ES, ja-JP)"
optsNoCopyFsharpCore,"Don't copy FSharp.Core.dll along the produced binaries"
optsSignatureData,"Include F# interface information, the default is file. Essential for distributing libraries."
Expand Down Expand Up @@ -1557,12 +1557,12 @@ csTypeHasNullAsExtraValue,"The type '%s' supports 'null' but a non-null type is
3352,typrelInterfaceMemberNoMostSpecificImplementation,"Interface member '%s' does not have a most specific implementation."
3353,fsiInvalidDirective,"Invalid directive '#%s %s'"
useSdkRefs,"Use reference assemblies for .NET framework references when available (Enabled by default)."
optsCheckNulls,"Enable nullness declarations and checks"
optsCheckNulls,"Enable nullness declarations and checks (%s by default)"
fSharpBannerVersion,"%s for F# %s"
optsGetLangVersions,"Display the allowed values for language version."
optsSetLangVersion,"Specify language version such as 'latest' or 'preview'."
optsSupportedLangVersions,"Supported language versions:"
optsStrictIndentation,"Override indentation rules implied by the language version"
optsStrictIndentation,"Override indentation rules implied by the language version (%s by default)"
nativeResourceFormatError,"Stream does not begin with a null resource and is not in '.RES' format."
nativeResourceHeaderMalformed,"Resource header beginning at offset %s is malformed."
formatDashItem," - %s"
Expand Down
10 changes: 5 additions & 5 deletions src/Compiler/Interactive/FSIstrings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ fsiLoad,"#load the given file on startup"
fsiRemaining,"Treat remaining arguments as command line arguments, accessed using fsi.CommandLineArgs"
fsiHelp,"Display this usage message (Short form: -?)"
fsiExec,"Exit fsi after loading the files or running the .fsx script given on the command line"
fsiGui,"Execute interactions on a Windows Forms event loop (on by default)"
fsiGui,"Execute interactions on a Windows Forms event loop (%s by default)"
fsiQuiet,"Suppress fsi writing to stdout"
fsiReadline,"Support TAB completion in console (on by default)"
fsiEmitDebugInfoInQuotations,"Emit debug information in quotations"
fsiReadline,"Support TAB completion in console (%s by default)"
fsiEmitDebugInfoInQuotations,"Emit debug information in quotations (%s by default)"
fsiBanner3,"For help type #help;;"
fsiConsoleProblem,"A problem occurred starting the F# Interactive process. This may be due to a known problem with background process console support for Unicode-enabled applications on some Windows systems. Try selecting Tools->Options->F# Interactive for Visual Studio and enter '--fsi-server-no-unicode'."
2301,fsiInvalidAssembly,"'%s' is not a valid assembly name"
Expand Down Expand Up @@ -53,9 +53,9 @@ fsiFailedToResolveAssembly,"Failed to resolve assembly '%s'"
fsiBindingSessionTo,"Binding session to '%s'..."
fsiProductName,"Microsoft (R) F# Interactive version %s"
fsiProductNameCommunity,"F# Interactive for F# %s"
shadowCopyReferences,"Prevents references from being locked by the F# Interactive process"
shadowCopyReferences,"Prevents references from being locked by the F# Interactive process (%s by default)"
fsiOperationCouldNotBeCompleted,"Operation could not be completed due to earlier error"
fsiOperationFailed,"Operation failed. The error text has been printed in the error stream. To return the corresponding FSharpDiagnostic use the EvalInteractionNonThrowing, EvalScriptNonThrowing or EvalExpressionNonThrowing"
fsiMultiAssemblyEmitOption,"Emit multiple assemblies (on by default)"
fsiMultiAssemblyEmitOption,"Emit multiple assemblies (%s by default)"
2304,fsiEntryPointWontBeInvoked,"Functions with [<EntryPoint>] are not invoked in FSI. '%s' was not invoked. Execute '%s <args>' in order to invoke '%s' with the appropriate string array of command line arguments."
fsiDetailedHelpLink,"See https://learn.microsoft.com/dotnet/fsharp/language-reference/fsharp-interactive-options for more details."
Loading

0 comments on commit 143e375

Please sign in to comment.