Skip to content

Commit 4ea0cae

Browse files
authored
Merge pull request #13791 from dotnet/merges/main-to-release/dev17.4
Merge main to release/dev17.4
2 parents 88cec48 + a3366e2 commit 4ea0cae

31 files changed

+348
-85
lines changed

src/Compiler/Driver/CompilerOptions.fs

+58-28
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ open FSharp.Compiler.TypedTreeOps
2323
open FSharp.Compiler.DiagnosticsLogger
2424

2525
open Internal.Utilities
26+
open System.Text
2627

2728
module Attributes =
2829
open System.Runtime.CompilerServices
@@ -112,7 +113,11 @@ let compilerOptionUsage (CompilerOption (s, tag, spec, _, _)) =
112113
else
113114
sprintf "%s:%s" s tag (* still being decided *)
114115

115-
let PrintCompilerOption (CompilerOption (_s, _tag, _spec, _, help) as compilerOption) =
116+
let nl = Environment.NewLine
117+
118+
let getCompilerOption (CompilerOption (_s, _tag, _spec, _, help) as compilerOption) =
119+
let sb = StringBuilder()
120+
116121
let flagWidth = 42 // fixed width for printing of flags, e.g. --debug:{full|pdbonly|portable|embedded}
117122
let defaultLineWidth = 80 // the fallback width
118123

@@ -131,18 +136,18 @@ let PrintCompilerOption (CompilerOption (_s, _tag, _spec, _, help) as compilerOp
131136
// flagWidth chars - for flags description or padding on continuation lines.
132137
// single space - space.
133138
// description - words upto but excluding the final character of the line.
134-
printf "%-40s" (compilerOptionUsage compilerOption)
139+
let _ = sb.Append $"{compilerOptionUsage compilerOption, -40}"
135140

136141
let printWord column (word: string) =
137142
// Have printed upto column.
138143
// Now print the next word including any preceding whitespace.
139144
// Returns the column printed to (suited to folding).
140145
if column + 1 (*space*) + word.Length >= lineWidth then // NOTE: "equality" ensures final character of the line is never printed
141-
printfn "" (* newline *)
142-
printf "%-40s %s" "" (*<--flags*) word
146+
let _ = sb.Append $"{nl}"
147+
let _ = sb.Append $"{String.Empty, -40} {word}"
143148
flagWidth + 1 + word.Length
144149
else
145-
printf " %s" word
150+
let _ = sb.Append $" {word}"
146151
column + 1 + word.Length
147152

148153
let words =
@@ -151,16 +156,19 @@ let PrintCompilerOption (CompilerOption (_s, _tag, _spec, _, help) as compilerOp
151156
| Some s -> s.Split [| ' ' |]
152157

153158
let _finalColumn = Array.fold printWord flagWidth words
154-
printfn "" (* newline *)
159+
let _ = sb.Append $"{nl}"
160+
sb.ToString()
155161

156-
let PrintPublicOptions (heading, opts) =
162+
let getPublicOptions (heading, opts) =
157163
if not (isNil opts) then
158-
printfn ""
159-
printfn ""
160-
printfn "\t\t%s" heading
161-
List.iter PrintCompilerOption opts
164+
$"{nl}{nl}\t\t{heading}{nl}"
165+
+ (opts |> List.map getCompilerOption |> String.concat "")
166+
else
167+
""
168+
169+
let GetCompilerOptionBlocks blocks =
170+
let sb = new StringBuilder()
162171

163-
let PrintCompilerOptionBlocks blocks =
164172
let publicBlocks =
165173
blocks
166174
|> List.choose (function
@@ -174,10 +182,11 @@ let PrintCompilerOptionBlocks blocks =
174182
let headingOptions =
175183
publicBlocks |> List.filter (fun (h2, _) -> heading = h2) |> List.collect snd
176184

177-
PrintPublicOptions(heading, headingOptions)
185+
let _ = sb.Append(getPublicOptions (heading, headingOptions))
178186
Set.add heading doneHeadings
179187

180188
List.fold consider Set.empty publicBlocks |> ignore<Set<string>>
189+
sb.ToString()
181190

182191
(* For QA *)
183192
let dumpCompilerOption prefix (CompilerOption (str, _, spec, _, _)) =
@@ -1981,31 +1990,46 @@ let deprecatedFlagsFsc tcConfigB =
19811990
// OptionBlock: Miscellaneous options
19821991
//-----------------------------------
19831992

1984-
let DisplayBannerText tcConfigB =
1993+
let GetBannerText tcConfigB =
19851994
if tcConfigB.showBanner then
1986-
(printfn "%s" tcConfigB.productNameForBannerText
1987-
printfn "%s" (FSComp.SR.optsCopyright ()))
1995+
$"{tcConfigB.productNameForBannerText}{nl}"
1996+
+ $"{FSComp.SR.optsCopyright ()}{nl}"
1997+
else
1998+
""
19881999

19892000
/// FSC only help. (FSI has it's own help function).
1990-
let displayHelpFsc tcConfigB (blocks: CompilerOptionBlock list) =
1991-
DisplayBannerText tcConfigB
1992-
PrintCompilerOptionBlocks blocks
1993-
exit 0
2001+
let GetHelpFsc tcConfigB (blocks: CompilerOptionBlock list) =
2002+
GetBannerText tcConfigB + GetCompilerOptionBlocks blocks
19942003

1995-
let displayVersion tcConfigB =
1996-
printfn "%s" tcConfigB.productNameForBannerText
1997-
exit 0
2004+
let GetVersion tcConfigB =
2005+
$"{tcConfigB.productNameForBannerText}{nl}"
19982006

19992007
let miscFlagsBoth tcConfigB =
20002008
[
20012009
CompilerOption("nologo", tagNone, OptionUnit(fun () -> tcConfigB.showBanner <- false), None, Some(FSComp.SR.optsNologo ()))
2002-
CompilerOption("version", tagNone, OptionConsoleOnly(fun _ -> displayVersion tcConfigB), None, Some(FSComp.SR.optsVersion ()))
2010+
CompilerOption(
2011+
"version",
2012+
tagNone,
2013+
OptionConsoleOnly(fun _ ->
2014+
Console.Write(GetVersion tcConfigB)
2015+
exit 0),
2016+
None,
2017+
Some(FSComp.SR.optsVersion ())
2018+
)
20032019
]
20042020

20052021
let miscFlagsFsc tcConfigB =
20062022
miscFlagsBoth tcConfigB
20072023
@ [
2008-
CompilerOption("help", tagNone, OptionConsoleOnly(fun blocks -> displayHelpFsc tcConfigB blocks), None, Some(FSComp.SR.optsHelp ()))
2024+
CompilerOption(
2025+
"help",
2026+
tagNone,
2027+
OptionConsoleOnly(fun blocks ->
2028+
Console.Write(GetHelpFsc tcConfigB blocks)
2029+
exit 0),
2030+
None,
2031+
Some(FSComp.SR.optsHelp ())
2032+
)
20092033
CompilerOption("@<file>", tagNone, OptionUnit ignore, None, Some(FSComp.SR.optsResponseFile ()))
20102034
]
20112035

@@ -2061,23 +2085,29 @@ let abbreviatedFlagsFsc tcConfigB =
20612085
CompilerOption(
20622086
"?",
20632087
tagNone,
2064-
OptionConsoleOnly(fun blocks -> displayHelpFsc tcConfigB blocks),
2088+
OptionConsoleOnly(fun blocks ->
2089+
Console.Write(GetHelpFsc tcConfigB blocks)
2090+
exit 0),
20652091
None,
20662092
Some(FSComp.SR.optsShortFormOf ("--help"))
20672093
)
20682094

20692095
CompilerOption(
20702096
"help",
20712097
tagNone,
2072-
OptionConsoleOnly(fun blocks -> displayHelpFsc tcConfigB blocks),
2098+
OptionConsoleOnly(fun blocks ->
2099+
Console.Write(GetHelpFsc tcConfigB blocks)
2100+
exit 0),
20732101
None,
20742102
Some(FSComp.SR.optsShortFormOf ("--help"))
20752103
)
20762104

20772105
CompilerOption(
20782106
"full-help",
20792107
tagNone,
2080-
OptionConsoleOnly(fun blocks -> displayHelpFsc tcConfigB blocks),
2108+
OptionConsoleOnly(fun blocks ->
2109+
Console.Write(GetHelpFsc tcConfigB blocks)
2110+
exit 0),
20812111
None,
20822112
Some(FSComp.SR.optsShortFormOf ("--help"))
20832113
)

src/Compiler/Driver/CompilerOptions.fsi

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ and CompilerOptionBlock =
4343
| PublicOptions of heading: string * options: CompilerOption list
4444
| PrivateOptions of options: CompilerOption list
4545

46-
val PrintCompilerOptionBlocks: CompilerOptionBlock list -> unit // for printing usage
46+
val GetCompilerOptionBlocks: CompilerOptionBlock list -> string
4747

4848
val DumpCompilerOptionBlocks: CompilerOptionBlock list -> unit // for QA
4949

@@ -52,7 +52,11 @@ val FilterCompilerOptionBlock: (CompilerOption -> bool) -> CompilerOptionBlock -
5252
/// Parse and process a set of compiler options
5353
val ParseCompilerOptions: (string -> unit) * CompilerOptionBlock list * string list -> unit
5454

55-
val DisplayBannerText: TcConfigBuilder -> unit
55+
val GetBannerText: tcConfigB: TcConfigBuilder -> string
56+
57+
val GetHelpFsc: tcConfigB: TcConfigBuilder -> blocks: CompilerOptionBlock list -> string
58+
59+
val GetVersion: tcConfigB: TcConfigBuilder -> string
5660

5761
val GetCoreFscCompilerOptions: TcConfigBuilder -> CompilerOptionBlock list
5862

src/Compiler/Driver/fsc.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ let main1
544544

545545
// Display the banner text, if necessary
546546
if not bannerAlreadyPrinted then
547-
DisplayBannerText tcConfigB
547+
Console.Write(GetBannerText tcConfigB)
548548

549549
// Create tcGlobals and frameworkTcImports
550550
let outfile, pdbfile, assemblyName =

src/Compiler/FSComp.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ optsEmitDebugInfoInQuotations,"Emit debug information in quotations"
930930
optsPreferredUiLang,"Specify the preferred output language culture name (e.g. es-ES, ja-JP)"
931931
optsNoCopyFsharpCore,"Don't copy FSharp.Core.dll along the produced binaries"
932932
optsSignatureData,"Include F# interface information, the default is file. Essential for distributing libraries."
933-
1046,optsUnknownSignatureData,"Invalid value '%s' for --interfacedata, valid value are: none, file, compress.""
933+
1046,optsUnknownSignatureData,"Invalid value '%s' for --interfacedata, valid value are: none, file, compress."
934934
optsOptimizationData,"Specify included optimization information, the default is file. Important for distributed libraries."
935935
1047,optsUnknownOptimizationData,"Invalid value '%s' for --optimizationdata, valid value are: none, file, compress."
936936
1051,optsInvalidSubSystemVersion,"Invalid version '%s' for '--subsystemversion'. The version must be 4.00 or greater."

src/Compiler/FSharp.Compiler.Service.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<!-- The FSharp.Compiler.Service dll provides a referencable public interface for tool builders -->
3131
<PropertyGroup Condition="'$(Configuration)' != 'Proto'">
32-
<CompressMetadata>true</CompressMetadata>
32+
<CompressMetadata Condition="'$(CompressAllMetadata)' != 'true'">false</CompressMetadata>
3333
</PropertyGroup>
3434

3535
<PropertyGroup>

src/Compiler/Interactive/fsi.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,10 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig,
882882
// In the "--help", these options can be printed either before (fsiUsagePrefix) or after (fsiUsageSuffix) the core options.
883883

884884
let displayHelpFsi tcConfigB (blocks:CompilerOptionBlock list) =
885-
DisplayBannerText tcConfigB;
885+
Console.Write (GetBannerText tcConfigB)
886886
fprintfn fsiConsoleOutput.Out ""
887887
fprintfn fsiConsoleOutput.Out "%s" (FSIstrings.SR.fsiUsage(executableFileNameWithoutExtension.Value))
888-
PrintCompilerOptionBlocks blocks
888+
Console.Write (GetCompilerOptionBlocks blocks)
889889
exit 0
890890

891891
// option tags

src/Compiler/xlf/FSComp.txt.cs.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.de.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.es.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.fr.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.it.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.ja.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.ko.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.pl.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.pt-BR.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.ru.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.tr.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.zh-Hans.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/Compiler/xlf/FSComp.txt.zh-Hant.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@
533533
<note />
534534
</trans-unit>
535535
<trans-unit id="optsUnknownSignatureData">
536-
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</source>
537-
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress."</target>
536+
<source>Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</source>
537+
<target state="new">Invalid value '{0}' for --interfacedata, valid value are: none, file, compress.</target>
538538
<note />
539539
</trans-unit>
540540
<trans-unit id="optsUnrecognizedLanguageVersion">

src/FSharp.Build/FSharp.Build.fsproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
<!-- The FSharp.Build dll does not provide a referencable public interface although it's used for testing -->
2222
<PropertyGroup Condition="'$(Configuration)' != 'Proto'">
23-
<CompressMetadata>true</CompressMetadata>
23+
<CompressMetadata Condition="'$(CompressAllMetadata)' != 'true'">false</CompressMetadata>
24+
<NoOptimizationData>true</NoOptimizationData>
25+
<CompressMetadata Condition="'$(CompressAllMetadata)' != 'true'">false</CompressMetadata>
2426
</PropertyGroup>
2527

2628
<ItemGroup>

0 commit comments

Comments
 (0)