Skip to content

Commit a4b0558

Browse files
committed
Find the declaration's line without String.Contains(StringComparison), absent on net472
The Desktop legs could not compile FSharp.Compiler.ComponentTests: the .NET Framework BCL has no `String.Contains(string, StringComparison)`, so the arguments were read as a tuple (FS0001 in PathMap.fs). `IndexOf(name, StringComparison.Ordinal) >= 0` exists on every target. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent d89f6dc commit a4b0558

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎docs/release-notes/.FSharp.Compiler.Service/11.0.200.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
* Fix false IDE type-mismatch diagnostics for interpolated strings with multiple formatted holes. ([Issue #20752](https://github.com/dotnet/fsharp/issues/20752), [PR #20775](https://github.com/dotnet/fsharp/pull/20775))
1414
* Checker: report Bind resolution failures at the bound expression ([PR #20747](https://github.com/dotnet/fsharp/pull/20747))
1515
* A project reusing cached framework imports is checked with its own `--pathmap` instead of the map of the project that filled the cache, so the ranges of its in-memory reference data name its real files. ([Issue #20474](https://github.com/dotnet/fsharp/issues/20474), [PR #20476](https://github.com/dotnet/fsharp/pull/20476))
16-
* A project reusing cached framework imports is checked with its own `--pathmap` instead of the map of the project that filled the cache, so the ranges of its in-memory reference data name its real files. ([Issue #20474](https://github.com/dotnet/fsharp/issues/20474), [PR #20476](https://github.com/dotnet/fsharp/pull/20476))
1716
* `GetDeclarationLocation` no longer names the compile-time directory twice for a declaration in an assembly built with a relative `--pathmap`. Such a build maps the directory it compiled in along with its file names, so a file from under that directory already starts with it, and joining the two left a path that matches no file. Other relative names, such as the `#line` names that compilers before F# 10 wrote, are still resolved against that directory. ([PR #20518](https://github.com/dotnet/fsharp/pull/20518))
18-
* A project reusing cached framework imports is checked with its own `--pathmap` instead of the map of the project that filled the cache, so the ranges of its in-memory reference data name its real files. ([Issue #20474](https://github.com/dotnet/fsharp/issues/20474), [PR #20476](https://github.com/dotnet/fsharp/pull/20476))
1917
* Split Linux CoreCLR CI into two parallel test batches to reduce test turnaround time. ([PR #20587](https://github.com/dotnet/fsharp/pull/20587))
2018
* Fix wrong results or non-terminating loops in optimized code when an integer `for` loop's start or end expression binds a local. ([Issue #20732](https://github.com/dotnet/fsharp/issues/20732), [PR #20733](https://github.com/dotnet/fsharp/pull/20733))
2119
* Checker: resolve named arguments of failed and unfinished method calls ([PR #20749](https://github.com/dotnet/fsharp/pull/20749))

‎tests/FSharp.Compiler.ComponentTests/FSharpChecker/PathMap.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ let private checkAgainst (library: string) (source: string) =
135135

136136
let private locate (source: string) (name: string) =
137137
let lines = source.Split '\n'
138-
let index = lines |> Array.findIndex (fun line -> line.Contains(name, System.StringComparison.Ordinal))
138+
let index = lines |> Array.findIndex (fun line -> line.IndexOf(name, System.StringComparison.Ordinal) >= 0)
139139
let line = lines[index]
140140
struct (index + 1, line.IndexOf(name, System.StringComparison.Ordinal) + name.Length, line, List.ofArray (name.Split '.'))
141141

‎tests/FSharp.Test.Utilities/Compiler.fs‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,14 +2551,25 @@ $ code --diff {outFile} {expectedFile}
25512551
/// Result type for CLI subprocess execution (runFsiProcess / runFscProcess).
25522552
type ProcessResult = { ExitCode: int; StdOut: string; StdErr: string }
25532553

2554+
/// Quote an argument that contains whitespace so the child process's command line
2555+
/// parser sees it as a single token. Arguments routinely embed paths with spaces,
2556+
/// e.g. a temp directory under "C:\Users\First Last", or the .NET Framework
2557+
/// reference assemblies under "C:\Program Files (x86)".
2558+
let private quoteArg (arg: string) =
2559+
if arg |> Seq.exists Char.IsWhiteSpace && not (arg.StartsWith("\"", StringComparison.Ordinal)) then
2560+
"\"" + arg + "\""
2561+
else
2562+
arg
2563+
25542564
/// Run an F# tool (FSI or FSC) as a subprocess. Shared helper for runFsiProcess / runFscProcess.
25552565
let private runToolProcess (toolPath: string) (workingDirectory: string) (args: string list) : ProcessResult =
2566+
let quotedArgs = args |> List.map quoteArg |> String.concat " "
25562567
#if NETCOREAPP
25572568
let exe = TestFramework.initialConfig.DotNetExe
2558-
let arguments = toolPath + " " + (args |> String.concat " ")
2569+
let arguments = quoteArg toolPath + " " + quotedArgs
25592570
#else
25602571
let exe = toolPath
2561-
let arguments = args |> String.concat " "
2572+
let arguments = quotedArgs
25622573
#endif
25632574
let exitCode, stdout, stderr = Commands.executeProcess exe arguments workingDirectory
25642575
{ ExitCode = exitCode; StdOut = stdout; StdErr = stderr }

0 commit comments

Comments
 (0)