Skip to content

Commit e2168fa

Browse files
authored
Enable preferreduilang for fsi (#4253)
* Add support for --preferreduilang in fsi.exe * Prefereduiculture for fsi * Remove dead code
1 parent 5728b68 commit e2168fa

8 files changed

Lines changed: 6 additions & 60 deletions

File tree

src/FSharpSource.Profiles.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
44

55
<PropertyGroup Condition="'$(TargetDotnetProfile)'=='net40'">
6-
<DefineConstants>$(DefineConstants);PREFERRED_UI_LANG</DefineConstants>
76
<DefineConstants>$(DefineConstants);ENABLE_MONO_SUPPORT</DefineConstants>
87
<DefineConstants>$(DefineConstants);BE_SECURITY_TRANSPARENT</DefineConstants>
98
<DefineConstants>$(DefineConstants);FX_LCIDFROMCODEPAGE</DefineConstants>
@@ -15,7 +14,6 @@
1514
<PropertyGroup Condition="'$(TargetDotnetProfile)'=='coreclr'">
1615
<DefineConstants>$(DefineConstants);FX_PORTABLE_OR_NETSTANDARD</DefineConstants>
1716
<DefineConstants>$(DefineConstants);NETSTANDARD1_6</DefineConstants>
18-
<DefineConstants>$(DefineConstants);PREFERRED_UI_LANG</DefineConstants>
1917
<DefineConstants>$(DefineConstants);FX_NO_APP_DOMAINS</DefineConstants>
2018
<DefineConstants>$(DefineConstants);FX_NO_ARRAY_LONG_LENGTH</DefineConstants>
2119
<DefineConstants>$(DefineConstants);FX_NO_BEGINEND_READWRITE</DefineConstants>

src/fsharp/CompileOps.fs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,9 +2287,7 @@ type TcConfigBuilder =
22872287
mutable optSettings : Optimizer.OptimizationSettings
22882288
mutable emitTailcalls : bool
22892289
mutable deterministic : bool
2290-
#if PREFERRED_UI_LANG
22912290
mutable preferredUiLang: string option
2292-
#endif
22932291
mutable lcid : int option
22942292
mutable productNameForBannerText : string
22952293
/// show the MS (c) notice, e.g. with help or fsi?
@@ -2448,9 +2446,7 @@ type TcConfigBuilder =
24482446
optSettings = Optimizer.OptimizationSettings.Defaults
24492447
emitTailcalls = true
24502448
deterministic = false
2451-
#if PREFERRED_UI_LANG
24522449
preferredUiLang = None
2453-
#endif
24542450
lcid = None
24552451
// See bug 6071 for product banner spec
24562452
productNameForBannerText = FSComp.SR.buildProductName(FSharpEnvironment.FSharpBannerVersion)
@@ -2914,9 +2910,7 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) =
29142910
member x.optSettings = data.optSettings
29152911
member x.emitTailcalls = data.emitTailcalls
29162912
member x.deterministic = data.deterministic
2917-
#if PREFERRED_UI_LANG
29182913
member x.preferredUiLang = data.preferredUiLang
2919-
#endif
29202914
member x.lcid = data.lcid
29212915
member x.optsOn = data.optsOn
29222916
member x.productNameForBannerText = data.productNameForBannerText

src/fsharp/CompileOps.fsi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,7 @@ type TcConfigBuilder =
331331
mutable optSettings : Optimizer.OptimizationSettings
332332
mutable emitTailcalls: bool
333333
mutable deterministic: bool
334-
#if PREFERRED_UI_LANG
335334
mutable preferredUiLang: string option
336-
#endif
337335
mutable lcid : int option
338336
mutable productNameForBannerText: string
339337
mutable showBanner : bool
@@ -481,11 +479,7 @@ type TcConfig =
481479
member optSettings : Optimizer.OptimizationSettings
482480
member emitTailcalls: bool
483481
member deterministic: bool
484-
#if PREFERRED_UI_LANG
485482
member preferredUiLang: string option
486-
#else
487-
member lcid : int option
488-
#endif
489483
member optsOn : bool
490484
member productNameForBannerText: string
491485
member showBanner : bool

src/fsharp/CompileOptions.fs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,8 @@ let codePageFlag (tcConfigB : TcConfigBuilder) =
739739
tcConfigB.inputCodePage <- Some(n)), None,
740740
Some (FSComp.SR.optsCodepage()))
741741

742-
#if PREFERRED_UI_LANG
743742
let preferredUiLang (tcConfigB: TcConfigBuilder) =
744743
CompilerOption("preferreduilang", tagString, OptionString (fun s -> tcConfigB.preferredUiLang <- Some(s)), None, Some(FSComp.SR.optsPreferredUiLang()))
745-
#endif
746744

747745
let utf8OutputFlag (tcConfigB: TcConfigBuilder) =
748746
CompilerOption("utf8output", tagNone, OptionUnit (fun () -> tcConfigB.utf8output <- true), None,
@@ -771,9 +769,7 @@ let advancedFlagsBoth tcConfigB =
771769
[
772770
yield codePageFlag tcConfigB
773771
yield utf8OutputFlag tcConfigB
774-
#if PREFERRED_UI_LANG
775772
yield preferredUiLang tcConfigB
776-
#endif
777773
yield fullPathsFlag tcConfigB
778774
yield libFlag tcConfigB
779775
yield CompilerOption("simpleresolution",
@@ -849,11 +845,7 @@ let testFlag tcConfigB =
849845
let vsSpecificFlags (tcConfigB: TcConfigBuilder) =
850846
[ CompilerOption("vserrors", tagNone, OptionUnit (fun () -> tcConfigB.errorStyle <- ErrorStyle.VSErrors), None, None)
851847
CompilerOption("validate-type-providers", tagNone, OptionUnit (id), None, None) // preserved for compatibility's sake, no longer has any effect
852-
#if PREFERRED_UI_LANG
853848
CompilerOption("LCID", tagInt, OptionInt (fun _n -> ()), None, None)
854-
#else
855-
CompilerOption("LCID", tagInt, OptionInt (fun n -> tcConfigB.lcid <- Some(n)), None, None)
856-
#endif
857849
CompilerOption("flaterrors", tagNone, OptionUnit (fun () -> tcConfigB.flatErrors <- true), None, None)
858850
CompilerOption("sqmsessionguid", tagNone, OptionString (fun s -> tcConfigB.sqmSessionGuid <- try System.Guid(s) |> Some with e -> None), None, None)
859851
CompilerOption("gccerrors", tagNone, OptionUnit (fun () -> tcConfigB.errorStyle <- ErrorStyle.GccErrors), None, None)

src/fsharp/fsc.fs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,19 +1635,13 @@ let main0(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, openBinarie
16351635
let directoryBuildingFrom = Directory.GetCurrentDirectory()
16361636
let setProcessThreadLocals tcConfigB =
16371637
tcConfigB.openBinariesInMemory <- openBinariesInMemory
1638-
#if PREFERRED_UI_LANG
16391638
match tcConfigB.preferredUiLang with
16401639
#if FX_RESHAPED_GLOBALIZATION
16411640
| Some s -> System.Globalization.CultureInfo.CurrentUICulture <- new System.Globalization.CultureInfo(s)
16421641
#else
16431642
| Some s -> Thread.CurrentThread.CurrentUICulture <- new System.Globalization.CultureInfo(s)
16441643
#endif
16451644
| None -> ()
1646-
#else
1647-
match tcConfigB.lcid with
1648-
| Some n -> Thread.CurrentThread.CurrentUICulture <- new CultureInfo(n)
1649-
| None -> ()
1650-
#endif
16511645
if tcConfigB.utf8output then
16521646
Console.OutputEncoding <- Encoding.UTF8
16531647

src/fsharp/fsi/fsi.fs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,19 +2419,6 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
24192419
// We later switch to doing interaction-by-interaction processing on the "event loop" thread.
24202420
let ctokStartup = AssumeCompilationThreadWithoutEvidence ()
24212421

2422-
#if FX_LCIDFROMCODEPAGE
2423-
2424-
// See Bug 735819
2425-
let lcidFromCodePage =
2426-
if (Console.OutputEncoding.CodePage <> 65001) &&
2427-
(Console.OutputEncoding.CodePage <> Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage) &&
2428-
(Console.OutputEncoding.CodePage <> Thread.CurrentThread.CurrentUICulture.TextInfo.ANSICodePage) then
2429-
Thread.CurrentThread.CurrentUICulture <- new CultureInfo("en-US")
2430-
Some 1033
2431-
else
2432-
None
2433-
#endif
2434-
24352422
let timeReporter = FsiTimeReporter(outWriter)
24362423

24372424
#if !FX_RESHAPED_CONSOLE
@@ -2494,19 +2481,14 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
24942481
let fsiOptions = FsiCommandLineOptions(fsi, argv, tcConfigB, fsiConsoleOutput)
24952482
let fsiConsolePrompt = FsiConsolePrompt(fsiOptions, fsiConsoleOutput)
24962483

2497-
// Check if we have a codepage from the console
2498-
#if FX_LCIDFROMCODEPAGE
24992484
do
2500-
match fsiOptions.FsiLCID with
2501-
| Some _ -> ()
2502-
| None -> tcConfigB.lcid <- lcidFromCodePage
2503-
2504-
// Set the ui culture
2505-
do
2506-
match fsiOptions.FsiLCID with
2507-
| Some(n) -> Thread.CurrentThread.CurrentUICulture <- new CultureInfo(n)
2508-
| None -> ()
2485+
match tcConfigB.preferredUiLang with
2486+
#if FX_RESHAPED_GLOBALIZATION
2487+
| Some s -> System.Globalization.CultureInfo.CurrentUICulture <- new System.Globalization.CultureInfo(s)
2488+
#else
2489+
| Some s -> Thread.CurrentThread.CurrentUICulture <- new System.Globalization.CultureInfo(s)
25092490
#endif
2491+
| None -> ()
25102492

25112493
#if !FX_NO_SERVERCODEPAGES
25122494
do

vsintegration/src/FSharp.ProjectSystem.Base/Project/ProjectNode.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,16 +3277,9 @@ internal virtual BuildSubmission DoMSBuildSubmission(BuildKind buildKind, string
32773277

32783278
projectInstance.SetProperty("UTFOutput", "true");
32793279

3280-
#if FX_PREFERRED_UI_LANG
32813280
// The CoreCLR build of FSC will use the CultureName since lcid doesn't apply very well
32823281
// so that the errors reported by fsc.exe are in the right locale
32833282
projectInstance.SetProperty("PREFERREDUILANG", System.Threading.Thread.CurrentThread.CurrentUICulture.Name);
3284-
#else
3285-
// When building, we need to set the flags for the fsc.exe that we spawned
3286-
// so that the errors reported by fsc.exe are in the right locale
3287-
projectInstance.SetProperty("LCID", System.Threading.Thread.CurrentThread.CurrentUICulture.LCID.ToString());
3288-
#endif
3289-
32903283
this.BuildProject.ProjectCollection.HostServices.SetNodeAffinity(projectInstance.FullPath, NodeAffinity.InProc);
32913284
BuildRequestData requestData = new BuildRequestData(projectInstance, targetsToBuild, this.BuildProject.ProjectCollection.HostServices, BuildRequestDataFlags.ReplaceExistingProjectInstance);
32923285
submission = BuildManager.DefaultBuildManager.PendBuildRequest(requestData);

vsintegration/src/FSharp.ProjectSystem.Base/Project/ProjectSystem.Base.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
<DefineConstants>$(DefineConstants);CODE_ANALYSIS</DefineConstants>
2323
<AsmmetaDependsOnMSBuildInVS>true</AsmmetaDependsOnMSBuildInVS>
2424
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
25-
<DefineConstants>$(DefineConstants);FX_PREFERRED_UI_LANG</DefineConstants>
2625
<TargetFrameworkProfile>
2726
</TargetFrameworkProfile>
2827
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

0 commit comments

Comments
 (0)