From 45ede2698eb240ffaace831de7098f1b4b7a6ff5 Mon Sep 17 00:00:00 2001 From: OwnageIsMagic Date: Sun, 1 Oct 2023 08:47:47 +0300 Subject: [PATCH 1/7] do not use Unicode aware API; fix some typos --- src/Compiler/AbstractIL/ilnativeres.fs | 2 +- src/Compiler/AbstractIL/ilreflect.fs | 2 +- src/Compiler/Checking/CheckDeclarations.fs | 2 +- src/Compiler/Checking/CheckFormatStrings.fs | 10 +++++----- src/Compiler/Checking/NameResolution.fs | 2 +- src/Compiler/Checking/NicePrint.fs | 4 ++-- src/Compiler/Driver/CompilerConfig.fs | 2 +- src/Compiler/Driver/CreateILModule.fs | 2 +- .../Legacy/LegacyHostedCompilerForTesting.fs | 6 +++--- src/Compiler/Service/QuickParse.fs | 2 +- src/Compiler/Service/ServiceAssemblyContent.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTreeOps.fs | 4 ++-- src/Compiler/TypedTree/TypedTreeOps.fs | 4 ++-- src/Compiler/Utilities/illib.fs | 8 +++++--- src/Compiler/Utilities/illib.fsi | 5 ++++- src/Compiler/Utilities/sformat.fs | 6 +++--- src/Compiler/Utilities/sformat.fsi | 2 +- src/Compiler/lex.fsl | 2 +- src/FSharp.Core/printf.fs | 14 ++++++++------ 19 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/Compiler/AbstractIL/ilnativeres.fs b/src/Compiler/AbstractIL/ilnativeres.fs index b37ae327c40..d7a4c48ea2a 100644 --- a/src/Compiler/AbstractIL/ilnativeres.fs +++ b/src/Compiler/AbstractIL/ilnativeres.fs @@ -434,7 +434,7 @@ type VersionHelper() = let mutable breakLoop = false while (idx < elements[i].Length) && not breakLoop do - if not (Char.IsDigit elements[i].[idx]) then + if not (isDigit elements[i].[idx]) then invalidFormat <- true VersionHelper.TryGetValue((elements[ i ].Substring(0, idx)), ref values[i]) diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 0d56377e36a..ac30122cce5 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -284,7 +284,7 @@ type TypeBuilder with type OpCode with member opcode.RefEmitName = - (string (Char.ToUpper(opcode.Name[0])) + opcode.Name[1..]) + (string (Char.ToUpperInvariant(opcode.Name[0])) + opcode.Name[1..]) .Replace(".", "_") .Replace("_i4", "_I4") diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 8f41152c420..0eb1ff35774 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -267,7 +267,7 @@ let TryStripPrefixPath (g: TcGlobals) (enclosingNamespacePath: Ident list) = g.isInteractive && not (isNil rest) && p.idText.StartsWithOrdinal FsiDynamicModulePrefix && - p.idText[FsiDynamicModulePrefix.Length..] |> String.forall Char.IsDigit + p.idText[FsiDynamicModulePrefix.Length..] |> String.forall isDigit -> Some(p, rest) | _ -> None diff --git a/src/Compiler/Checking/CheckFormatStrings.fs b/src/Compiler/Checking/CheckFormatStrings.fs index e32d073cbd1..6b676272f6c 100644 --- a/src/Compiler/Checking/CheckFormatStrings.fs +++ b/src/Compiler/Checking/CheckFormatStrings.fs @@ -139,13 +139,13 @@ module internal Parse = let rec digitsPrecision (fmt: string) (fmtPos: int) = if fmtPos >= fmt.Length then failwith (FSComp.SR.forBadPrecision()) match fmt[fmtPos] with - | c when System.Char.IsDigit c -> digitsPrecision fmt (fmtPos+1) + | c when isDigit c -> digitsPrecision fmt (fmtPos+1) | _ -> fmtPos let precision (info: FormatInfoRegister) (fmt: string) (fmtPos: int) = if fmtPos >= fmt.Length then failwith (FSComp.SR.forBadWidth()) match fmt[fmtPos] with - | c when System.Char.IsDigit c -> info.precision <- true; false,digitsPrecision fmt (fmtPos+1) + | c when isDigit c -> info.precision <- true; false,digitsPrecision fmt (fmtPos+1) | '*' -> info.precision <- true; true,(fmtPos+1) | _ -> failwith (FSComp.SR.forPrecisionMissingAfterDot()) @@ -160,14 +160,14 @@ module internal Parse = let rec go pos n = if pos >= len then failwith (FSComp.SR.forBadPrecision()) match fmt[pos] with - | c when System.Char.IsDigit c -> go (pos+1) (n*10 + int c - int '0') + | c when isDigit c -> go (pos+1) (n*10 + int c - int '0') | _ -> Some n, optionalDotAndPrecision info fmt pos go fmtPos intAcc let widthAndPrecision (info: FormatInfoRegister) (fmt: string) (fmtPos: int) = if fmtPos >= fmt.Length then failwith (FSComp.SR.forBadPrecision()) match fmt[fmtPos] with - | c when System.Char.IsDigit c -> false,digitsWidthAndPrecision info fmt fmtPos 0 + | c when isDigit c -> false,digitsWidthAndPrecision info fmt fmtPos 0 | '*' -> true, (None, optionalDotAndPrecision info fmt (fmtPos+1)) | _ -> false, (None, optionalDotAndPrecision info fmt fmtPos) @@ -177,7 +177,7 @@ module internal Parse = let rec digitsPosition n pos = if pos >= len then failwith (FSComp.SR.forBadPrecision()) match fmt[pos] with - | c when System.Char.IsDigit c -> digitsPosition (n*10 + int c - int '0') (pos+1) + | c when isDigit c -> digitsPosition (n*10 + int c - int '0') (pos+1) | '$' -> Some n, pos+1 | _ -> None, pos diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 292343dd223..e2074b18380 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3245,7 +3245,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa not newDef && warnOnUpper = WarnOnUpperCase && id.idText.Length >= 3 - && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] + && System.Char.IsLower id.idText[0] then warning(UpperCaseIdentifierInPattern m) diff --git a/src/Compiler/Checking/NicePrint.fs b/src/Compiler/Checking/NicePrint.fs index 381c3789acf..e8c723aeb28 100644 --- a/src/Compiler/Checking/NicePrint.fs +++ b/src/Compiler/Checking/NicePrint.fs @@ -58,7 +58,7 @@ module internal PrintUtilities = let isDiscard (name: string) = name.StartsWith("_") let ensureFloat (s: string) = - if String.forall (fun c -> Char.IsDigit c || c = '-') s then + if String.forall (fun c -> isDigit c || c = '-') s then s + ".0" else s @@ -925,7 +925,7 @@ module PrintTypes = if not denv.includeStaticParametersInTypeNames then None, args else - let regex = System.Text.RegularExpressions.Regex(@"\`\d+") + let regex = System.Text.RegularExpressions.Regex(@"\`\d+", System.Text.RegularExpressions.RegexOptions.ECMAScript) let path, skip = (0, tc.CompilationPath.DemangledPath) ||> List.mapFold (fun skip path -> diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index 78131431041..bd3ef1d840f 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -97,7 +97,7 @@ let GetWarningNumber (m, warningNumber: string) = // #pragma strips FS of the #pragma "FS0004" and validates the warning number // therefore if we have warning id that starts with a numeric digit we convert it to Some (int32) // anything else is ignored None - if Char.IsDigit(warningNumber[0]) then + if isDigit(warningNumber[0]) then Some(int32 warningNumber) elif warningNumber.StartsWithOrdinal("FS") = true then raise (ArgumentException()) diff --git a/src/Compiler/Driver/CreateILModule.fs b/src/Compiler/Driver/CreateILModule.fs index 45d9791ffd9..9649b7e09c2 100644 --- a/src/Compiler/Driver/CreateILModule.fs +++ b/src/Compiler/Driver/CreateILModule.fs @@ -267,7 +267,7 @@ module MainModuleBuilder = ((false, ""), v) ||> Seq.fold (fun (finished, v) c -> match finished with - | false when Char.IsDigit(c) -> false, v + c.ToString() + | false when isDigit(c) -> false, v + c.ToString() | _ -> true, v) |> snd diff --git a/src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs b/src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs index 87ec46483fe..4fc8a171919 100644 --- a/src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs +++ b/src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs @@ -185,21 +185,21 @@ type internal FscCompiler(legacyReferenceResolver) = /// test if --test:ErrorRanges flag is set let errorRangesArg = let regex = - Regex(@"^(/|--)test:ErrorRanges$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase) + Regex(@"^(/|--)test:ErrorRanges$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase ||| RegexOptions.CultureInvariant) fun arg -> regex.IsMatch(arg) /// test if --vserrors flag is set let vsErrorsArg = let regex = - Regex(@"^(/|--)vserrors$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase) + Regex(@"^(/|--)vserrors$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase ||| RegexOptions.CultureInvariant) fun arg -> regex.IsMatch(arg) /// test if an arg is a path to fsc.exe let fscExeArg = let regex = - Regex(@"fsc(\.exe)?$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase) + Regex(@"fsc(\.exe)?$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase ||| RegexOptions.CultureInvariant) fun arg -> regex.IsMatch(arg) diff --git a/src/Compiler/Service/QuickParse.fs b/src/Compiler/Service/QuickParse.fs index 381ba6a865d..a1a5a38de03 100644 --- a/src/Compiler/Service/QuickParse.fs +++ b/src/Compiler/Service/QuickParse.fs @@ -415,7 +415,7 @@ module QuickParse = let partialLongName = AtStartOfIdentifier(0, [], false, None) match List.rev partialLongName.QualifyingIdents with - | s :: _ when s.Length > 0 && Char.IsDigit(s[0]) -> PartialLongName.Empty(index) // "2.0" is not a longId (this might not be right for ``2.0`` but good enough for common case) + | s :: _ when s.Length > 0 && isDigit(s[0]) -> PartialLongName.Empty(index) // "2.0" is not a longId (this might not be right for ``2.0`` but good enough for common case) | plid -> { partialLongName with QualifyingIdents = plid diff --git a/src/Compiler/Service/ServiceAssemblyContent.fs b/src/Compiler/Service/ServiceAssemblyContent.fs index 2b54ed7f229..e55a9a52180 100644 --- a/src/Compiler/Service/ServiceAssemblyContent.fs +++ b/src/Compiler/Service/ServiceAssemblyContent.fs @@ -72,7 +72,7 @@ type Parent = let removeGenericParamsCount (idents: ShortIdents) = idents |> Array.map (fun ident -> - if ident.Length > 0 && Char.IsDigit ident[ident.Length - 1] then + if ident.Length > 0 && isDigit ident[ident.Length - 1] then let lastBacktickIndex = ident.LastIndexOf '`' if lastBacktickIndex <> -1 then ident.Substring(0, lastBacktickIndex) diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index bb53d5fd739..8fc537db5ab 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -1034,10 +1034,10 @@ let getTypeFromTuplePath (path: SynTupleTypeSegment list) : SynType list = let (|MultiDimensionArrayType|_|) (t: SynType) = match t with | SynType.App (StripParenTypes (SynType.LongIdent (SynLongIdent ([ identifier ], _, _))), _, [ elementType ], _, _, true, m) -> - if System.Text.RegularExpressions.Regex.IsMatch(identifier.idText, "^array\d\d?d$") then + if System.Text.RegularExpressions.Regex.IsMatch(identifier.idText, "^array\d\d?d$", System.Text.RegularExpressions.RegexOptions.ECMAScript) then let rank = identifier.idText - |> Seq.filter System.Char.IsDigit + |> Seq.filter isDigit |> Seq.toArray |> System.String |> int diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index cc13376b8a6..a97558c0ef9 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -4194,12 +4194,12 @@ module DebugPrint = | Const.UIntPtr x -> (x |> string)+"un" | Const.Single d -> (let s = d.ToString("g12", System.Globalization.CultureInfo.InvariantCulture) - if String.forall (fun c -> System.Char.IsDigit c || c = '-') s + if String.forall (fun c -> isDigit c || c = '-') s then s + ".0" else s) + "f" | Const.Double d -> let s = d.ToString("g12", System.Globalization.CultureInfo.InvariantCulture) - if String.forall (fun c -> System.Char.IsDigit c || c = '-') s + if String.forall (fun c -> isDigit c || c = '-') s then s + ".0" else s | Const.Char c -> "'" + c.ToString() + "'" diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index a0db105d145..b1b400da64e 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -78,6 +78,8 @@ module internal PervasiveAutoOpens = member inline x.EndsWithOrdinalIgnoreCase value = x.EndsWith(value, StringComparison.OrdinalIgnoreCase) + let inline isDigit (c: char) = (uint)(c - '0') <= (uint)('9' - '0'); + /// Get an initialization hole let getHole (r: _ ref) = match r.Value with @@ -526,7 +528,7 @@ module List = | [] -> failwith "headAndTail" | h :: t -> (h, t) - // WARNING: not tail-recursive + /// WARNING: not tail-recursive let mapHeadTail fhead ftail = function | [] -> [] @@ -710,13 +712,13 @@ module String = match Array.tryHead strArr with | None -> str | Some c -> - strArr[0] <- Char.ToLower c + strArr[0] <- Char.ToLowerInvariant c String strArr let extractTrailingIndex (str: string) = let charr = str.ToCharArray() Array.revInPlace charr - let digits = Array.takeWhile Char.IsDigit charr + let digits = Array.takeWhile isDigit charr Array.revInPlace digits String digits diff --git a/src/Compiler/Utilities/illib.fsi b/src/Compiler/Utilities/illib.fsi index bb41d9c490f..b6b06e60914 100644 --- a/src/Compiler/Utilities/illib.fsi +++ b/src/Compiler/Utilities/illib.fsi @@ -61,6 +61,9 @@ module internal PervasiveAutoOpens = member inline EndsWithOrdinalIgnoreCase: value: string -> bool + /// Returns true if the argument is ASCII digit (0-9). + val inline isDigit : c: char -> bool + type Async with /// Runs the computation synchronously, always starting on the current thread. @@ -182,7 +185,7 @@ module internal List = val headAndTail: l: 'a list -> 'a * 'a list - // WARNING: not tail-recursive + /// WARNING: not tail-recursive val mapHeadTail: fhead: ('a -> 'b) -> ftail: ('a -> 'b) -> _arg1: 'a list -> 'b list val collectFold: f: ('a -> 'b -> 'c list * 'a) -> s: 'a -> l: 'b list -> 'c list * 'a diff --git a/src/Compiler/Utilities/sformat.fs b/src/Compiler/Utilities/sformat.fs index 7281286dfd6..a74c81f780b 100644 --- a/src/Compiler/Utilities/sformat.fs +++ b/src/Compiler/Utilities/sformat.fs @@ -1135,10 +1135,10 @@ module Display = let openingBracketIndex = postTextMatch.Groups["prop"].Index - 1 buildObjMessageL remainingPropertyText[openingBracketIndex..] newLayouts - | remaingPropertyText -> + | remainingPropertyText -> // make sure we don't have any stray brackets let strayClosingMatch = - System.Text.RegularExpressions.Regex.IsMatch(remaingPropertyText, illFormedBracketPattern) + System.Text.RegularExpressions.Regex.IsMatch(remainingPropertyText, illFormedBracketPattern) if strayClosingMatch then None @@ -1149,7 +1149,7 @@ module Display = spaceListL ( List.rev ( (sepL (tagText preText) - ^^ alternativeObjL ^^ sepL (tagText (replaceEscapedBrackets (remaingPropertyText)))) + ^^ alternativeObjL ^^ sepL (tagText (replaceEscapedBrackets (remainingPropertyText)))) :: layouts ) ) diff --git a/src/Compiler/Utilities/sformat.fsi b/src/Compiler/Utilities/sformat.fsi index e4e8412495f..09db484077c 100644 --- a/src/Compiler/Utilities/sformat.fsi +++ b/src/Compiler/Utilities/sformat.fsi @@ -391,7 +391,7 @@ module internal Display = val output_layout_tagged: options: FormatOptions -> writer: TaggedTextWriter -> layout: Layout -> unit #else - // Most functions aren't needed in FSharp.Core.dll, but we add one inernal entry for printf + // Most functions aren't needed in FSharp.Core.dll, but we add one internal entry for printf val anyToStringForPrintf: options: FormatOptions -> bindingFlags: System.Reflection.BindingFlags -> value: 'T * Type -> string #endif diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index e8edd3086c1..5f89b122e51 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -94,7 +94,7 @@ let parseInt32 (s:string) = let mutable p = 0 let sign = getSign32 s &p l let specifier = get0OXB s &p l - match Char.ToLower(specifier,CultureInfo.InvariantCulture) with + match Char.ToLowerInvariant(specifier) with | 'x' -> sign * (int32 (Convert.ToUInt32(UInt64.Parse(s.Substring(p), NumberStyles.AllowHexSpecifier,CultureInfo.InvariantCulture)))) | 'b' -> sign * (int32 (Convert.ToUInt32(parseBinaryUInt64 (s.Substring(p))))) | 'o' -> sign * (int32 (Convert.ToUInt32(parseOctalUInt64 (s.Substring(p))))) diff --git a/src/FSharp.Core/printf.fs b/src/FSharp.Core/printf.fs index 58cab425d1f..310753ca37e 100644 --- a/src/FSharp.Core/printf.fs +++ b/src/FSharp.Core/printf.fs @@ -56,7 +56,7 @@ module internal PrintfImpl = /// 1. Final pieces (1..5) - set of functions with arguments number 1..5. /// Primary characteristic - these functions produce final result of the *printf* operation /// 2. Chained pieces (1..5) - set of functions with arguments number 1..5. - /// Primary characteristic - these functions doesn not produce final result by itself, instead they tailed with some another piece (chained or final). + /// Primary characteristic - these functions does not produce final result by itself, instead they tailed with some another piece (chained or final). /// Plain parts correspond to simple format specifiers (that are projected to just one parameter of the function, say %d or %s). However we also have /// format specifiers that can be projected to more than one argument (i.e %a, %t or any simple format specified with * width or precision). /// For them we add special cases (both chained and final to denote that they can either return value themselves or continue with some other piece) @@ -84,6 +84,8 @@ module internal PrintfImpl = let inline isPlusForPositives flags = hasFlag flags FormatFlags.PlusForPositives let inline isSpaceForPositives flags = hasFlag flags FormatFlags.SpaceForPositives + let inline isDigit (c: char) = (uint)(c - '0') <= (uint)('9' - '0'); + /// Used for width and precision to denote that user has specified '*' flag [] let StarValue = -1 @@ -146,15 +148,15 @@ module internal PrintfImpl = padChar, prefix member spec.IsGFormat = - spec.IsDecimalFormat || System.Char.ToLower(spec.TypeChar) = 'g' + spec.IsDecimalFormat || spec.TypeChar = 'g' || spec.TypeChar = 'G' + - /// Set of helpers to parse format string module private FormatString = let intFromString (s: string) (i: byref) = let mutable res = 0 - while (Char.IsDigit s.[i]) do + while (isDigit s[i]) do let n = int s.[i] - int '0' res <- res * 10 + n i <- i + 1 @@ -185,7 +187,7 @@ module internal PrintfImpl = if s.[i] = '*' then i <- i + 1 StarValue - elif Char.IsDigit s.[i] then + elif isDigit s[i] then intFromString s (&i) else NotSpecifiedValue @@ -195,7 +197,7 @@ module internal PrintfImpl = if s.[i + 1] = '*' then i <- i + 2 StarValue - elif Char.IsDigit s.[i + 1] then + elif isDigit s[i + 1] then i <- i + 1 intFromString s (&i) else raise (ArgumentException("invalid precision value")) From bd9461c0bb75d0d7ebd80be5c2944512046f0916 Mon Sep 17 00:00:00 2001 From: OwnageIsMagic Date: Sun, 1 Oct 2023 15:19:50 +0300 Subject: [PATCH 2/7] use ordinal string comparassions; string micro optimizations --- src/Compiler/AbstractIL/ilwritepdb.fs | 2 +- src/Compiler/Checking/CheckFormatStrings.fs | 2 +- src/Compiler/Checking/NameResolution.fs | 16 ++++++++-------- src/Compiler/Checking/NicePrint.fs | 2 +- .../DependencyManager/DependencyProvider.fs | 2 +- src/Compiler/Driver/CompilerConfig.fs | 10 +++++----- src/Compiler/Driver/CompilerImports.fs | 17 ++++------------- src/Compiler/Driver/CompilerOptions.fs | 2 +- src/Compiler/Driver/FxResolver.fs | 6 +++--- src/Compiler/Driver/ScriptClosure.fs | 3 +-- src/Compiler/Driver/fsc.fs | 2 +- src/Compiler/Facilities/CompilerLocation.fs | 2 +- src/Compiler/Facilities/prim-lexing.fs | 4 ++-- src/Compiler/Interactive/fsi.fs | 16 ++++++++-------- src/Compiler/Service/FSharpCheckerResults.fs | 2 +- src/Compiler/Service/FSharpParseFileResults.fs | 4 +--- src/Compiler/Service/IncrementalBuild.fs | 4 ++-- src/Compiler/Service/QuickParse.fs | 2 +- .../Service/ServiceInterfaceStubGenerator.fs | 2 +- src/Compiler/Service/ServiceLexing.fs | 2 +- src/Compiler/Service/ServiceParsedInputOps.fs | 4 +--- src/Compiler/Service/service.fs | 4 ++-- src/Compiler/Symbols/Symbols.fs | 6 +++--- src/Compiler/SyntaxTree/PrettyNaming.fs | 2 +- src/Compiler/SyntaxTree/XmlDoc.fs | 4 ++-- src/Compiler/TypedTree/TypeProviders.fs | 2 +- src/Compiler/Utilities/illib.fs | 3 +++ src/Compiler/Utilities/illib.fsi | 2 ++ src/Compiler/Utilities/range.fs | 2 +- src/FSharp.Core/printf.fs | 2 +- src/FSharp.Core/string.fs | 5 +++-- 31 files changed, 65 insertions(+), 73 deletions(-) diff --git a/src/Compiler/AbstractIL/ilwritepdb.fs b/src/Compiler/AbstractIL/ilwritepdb.fs index 9b969bae098..f3f7311d540 100644 --- a/src/Compiler/AbstractIL/ilwritepdb.fs +++ b/src/Compiler/AbstractIL/ilwritepdb.fs @@ -402,7 +402,7 @@ type PortablePdbGenerator let includeSource file = let isInList = embedSourceList - |> List.exists (fun f -> String.Compare(file, f, StringComparison.OrdinalIgnoreCase) = 0) + |> List.exists (fun f -> String.Equals(file, f, StringComparison.OrdinalIgnoreCase)) if not embedAllSource && not isInList || not (FileSystem.FileExistsShim file) then None diff --git a/src/Compiler/Checking/CheckFormatStrings.fs b/src/Compiler/Checking/CheckFormatStrings.fs index 6b676272f6c..6258620d0d0 100644 --- a/src/Compiler/Checking/CheckFormatStrings.fs +++ b/src/Compiler/Checking/CheckFormatStrings.fs @@ -370,7 +370,7 @@ let parseFormatStringInternal // type checker. They should always have '(...)' after for format string. let requireAndSkipInterpolationHoleFormat i = if i < len && fmt[i] = '(' then - let i2 = fmt.IndexOf(")", i+1) + let i2 = fmt.IndexOf(')', i+1) if i2 = -1 then failwith (FSComp.SR.forFormatInvalidForInterpolated3()) else diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index e2074b18380..29ebfcc012c 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -4345,7 +4345,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso if methsWithStaticParams.IsEmpty then minfos else minfos |> List.filter (fun minfo -> let nm = minfo.LogicalName - not (nm.Contains "," && methsWithStaticParams |> List.exists (fun m -> nm.StartsWithOrdinal m))) + not (nm.Contains ',' && methsWithStaticParams |> List.exists (fun m -> nm.StartsWithOrdinal m))) #endif minfos @@ -4552,7 +4552,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is | [] -> let tycons = mty.TypeDefinitions |> List.filter (fun tcref -> - not (tcref.LogicalName.Contains ",") && + not (tcref.LogicalName.Contains ',') && not (IsTyconUnseen ad g ncenv.amap m (modref.NestedTyconRef tcref))) // Collect up the accessible values in the module, excluding the members @@ -4680,7 +4680,7 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE let tycons = nenv.TyconsByDemangledNameAndArity(fullyQualified).Values |> Seq.filter (fun tcref -> - not (tcref.LogicalName.Contains ",") && + not (tcref.LogicalName.Contains ',') && not tcref.IsFSharpException && not (IsTyconUnseen ad g ncenv.amap m tcref)) |> Seq.map (ItemOfTyconRef ncenv m) @@ -4760,7 +4760,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameRe let tycons = mty.TypeDefinitions |> List.filter (fun tcref -> - not (tcref.LogicalName.Contains ",") && + not (tcref.LogicalName.Contains ',') && tcref.IsRecordTycon && not (IsTyconUnseen ad g ncenv.amap m (modref.NestedTyconRef tcref))) @@ -4834,7 +4834,7 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv: let recdTyCons = nenv.TyconsByDemangledNameAndArity(fullyQualified).Values |> Seq.filter (fun tcref -> - not (tcref.LogicalName.Contains ",") && + not (tcref.LogicalName.Contains ',') && tcref.IsRecordTycon && not (IsTyconUnseen ad g ncenv.amap m tcref)) |> Seq.map (ItemOfTyconRef ncenv m) @@ -5038,7 +5038,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty ( if methsWithStaticParams.IsEmpty then minfos else minfos |> List.filter (fun minfo -> let nm = minfo.LogicalName - not (nm.Contains "," && methsWithStaticParams |> List.exists (fun m -> nm.StartsWithOrdinal m))) + not (nm.Contains ',' && methsWithStaticParams |> List.exists (fun m -> nm.StartsWithOrdinal m))) #endif minfos @@ -5156,7 +5156,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver) let tycons = mty.TypeDefinitions |> List.filter (fun tcref -> - not (tcref.LogicalName.Contains ",") && + not (tcref.LogicalName.Contains ',') && not (IsTyconUnseen ad g ncenv.amap m (modref.NestedTyconRef tcref))) // Get all the types and .NET constructor groups accessible from here @@ -5230,7 +5230,7 @@ let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m a | Item.Types _ -> for tcref in nenv.TyconsByDemangledNameAndArity(OpenQualified).Values do if not tcref.IsFSharpException - && not (tcref.LogicalName.Contains ",") + && not (tcref.LogicalName.Contains ',') && not (IsTyconUnseen ad g ncenv.amap m tcref) then yield ItemOfTyconRef ncenv m tcref diff --git a/src/Compiler/Checking/NicePrint.fs b/src/Compiler/Checking/NicePrint.fs index e8c723aeb28..ba45d03018f 100644 --- a/src/Compiler/Checking/NicePrint.fs +++ b/src/Compiler/Checking/NicePrint.fs @@ -1959,7 +1959,7 @@ module TastDefinitionPrinting = not (impliedNames.Contains minfo.DisplayName) && IsMethInfoAccessible amap m ad minfo && // Discard method impls such as System.IConvertible.ToBoolean - not (minfo.IsILMethod && minfo.DisplayName.Contains(".")) && + not (minfo.IsILMethod && minfo.DisplayName.Contains('.')) && not (minfo.DisplayName.Split('.') |> Array.exists (fun part -> isDiscard part))) let ilFields = diff --git a/src/Compiler/DependencyManager/DependencyProvider.fs b/src/Compiler/DependencyManager/DependencyProvider.fs index f80969b3880..ba0a9a426b6 100644 --- a/src/Compiler/DependencyManager/DependencyProvider.fs +++ b/src/Compiler/DependencyManager/DependencyProvider.fs @@ -612,7 +612,7 @@ type DependencyProvider path: string ) : string MaybeNull * IDependencyManagerProvider MaybeNull = try - if path.Contains ":" && not (Path.IsPathRooted path) then + if path.Contains ':' && not (Path.IsPathRooted path) then let managers = RegisteredDependencyManagers compilerTools (Option.ofString outputDir) reportError diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index bd3ef1d840f..d7e2efbdd49 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -274,11 +274,11 @@ type AssemblyReference = member x.ProjectReference = (let (AssemblyReference (_, _, contents)) = x in contents) member x.SimpleAssemblyNameIs name = - (String.Compare(FileSystemUtils.fileNameWithoutExtensionWithValidate false x.Text, name, StringComparison.OrdinalIgnoreCase) = 0) - || not (x.Text.Contains "/") - && not (x.Text.Contains "\\") - && not (x.Text.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase)) - && not (x.Text.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) + (String.Equals(FileSystemUtils.fileNameWithoutExtensionWithValidate false x.Text, name, StringComparison.OrdinalIgnoreCase)) + || not (x.Text.Contains '/') + && not (x.Text.Contains '\\') + && not (x.Text.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) + && not (x.Text.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) && (try let aname = System.Reflection.AssemblyName x.Text in aname.Name = name with _ -> diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs index db6330e2bf9..57df52dbbbb 100644 --- a/src/Compiler/Driver/CompilerImports.fs +++ b/src/Compiler/Driver/CompilerImports.fs @@ -365,17 +365,11 @@ let isHashRReference (r: range) = && not (equals r rangeCmdArgs) && FileSystem.IsPathRootedShim r.FileName -let IsNetModule fileName = - let ext = Path.GetExtension fileName - String.Compare(ext, ".netmodule", StringComparison.OrdinalIgnoreCase) = 0 +let IsNetModule (fileName: string) = fileName.EndsWithOrdinalIgnoreCase ".netmodule" -let IsDLL fileName = - let ext = Path.GetExtension fileName - String.Compare(ext, ".dll", StringComparison.OrdinalIgnoreCase) = 0 +let IsDLL (fileName: string) = fileName.EndsWithOrdinalIgnoreCase ".dll" -let IsExe fileName = - let ext = Path.GetExtension fileName - String.Compare(ext, ".exe", StringComparison.OrdinalIgnoreCase) = 0 +let IsExe (fileName: string) = fileName.EndsWithOrdinalIgnoreCase ".exe" type TcConfig with @@ -2380,10 +2374,7 @@ and [] TcImports |> List.tryFind (fun dll -> let baseName = Path.GetFileNameWithoutExtension(dll.resolvedPath) - let res = - String.Compare(baseName, tcConfig.primaryAssembly.Name, StringComparison.OrdinalIgnoreCase) - - res = 0) + String.Equals(baseName, tcConfig.primaryAssembly.Name, StringComparison.OrdinalIgnoreCase)) match path with | Some p -> AssemblyReference(range0, p.resolvedPath, None) diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index 8c93995833e..a0bfab22e0f 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -224,7 +224,7 @@ let DumpCompilerOptionBlocks blocks = List.iter dumpCompilerOptionBlock blocks let isSlashOpt (opt: string) = - opt[0] = '/' && (opt.Length = 1 || not (opt[ 1.. ].Contains "/")) + opt[0] = '/' && (opt.Length = 1 || not (opt[ 1.. ].Contains '/')) module ResponseFile = diff --git a/src/Compiler/Driver/FxResolver.fs b/src/Compiler/Driver/FxResolver.fs index db0b6c3d756..2501eb4aebb 100644 --- a/src/Compiler/Driver/FxResolver.fs +++ b/src/Compiler/Driver/FxResolver.fs @@ -238,7 +238,7 @@ type internal FxResolver dotnetConfig.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) + pattern.Length - let endPos = dotnetConfig.IndexOf("\"", startPos) + let endPos = dotnetConfig.IndexOf('\"', startPos) let ver = dotnetConfig[startPos .. endPos - 1] let path = @@ -427,7 +427,7 @@ type internal FxResolver let name = netcoreApp.Name try - if name.StartsWith(tfmPrefix, StringComparison.InvariantCultureIgnoreCase) then + if name.StartsWithOrdinal(tfmPrefix) then Some( Double.Parse(name.Substring(tfmPrefix.Length), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture) ) @@ -560,7 +560,7 @@ type internal FxResolver dotnetConfig.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) + pattern.Length - let endPos = dotnetConfig.IndexOf("\"", startPos) + let endPos = dotnetConfig.IndexOf('\"', startPos) let tfm = dotnetConfig[startPos .. endPos - 1] tfm with _ -> diff --git a/src/Compiler/Driver/ScriptClosure.fs b/src/Compiler/Driver/ScriptClosure.fs index 83af161b353..ec34fa5d00a 100644 --- a/src/Compiler/Driver/ScriptClosure.fs +++ b/src/Compiler/Driver/ScriptClosure.fs @@ -603,8 +603,7 @@ module ScriptPreprocessClosure = (codeContext <> CodeContext.Editing) && (equals m range0 || equals m rangeStartup || equals m rangeCmdArgs) - let isThisFileName = - (0 = String.Compare(rootFilename, m.FileName, StringComparison.OrdinalIgnoreCase)) + let isThisFileName = String.Equals(rootFilename, m.FileName, StringComparison.OrdinalIgnoreCase) isArgParameterWhileNotEditing || isThisFileName | None -> true diff --git a/src/Compiler/Driver/fsc.fs b/src/Compiler/Driver/fsc.fs index 6a537c62d64..83c6d2f9467 100644 --- a/src/Compiler/Driver/fsc.fs +++ b/src/Compiler/Driver/fsc.fs @@ -428,7 +428,7 @@ let CopyFSharpCore (outFile: string, referencedDlls: AssemblyReference list) = let TryFindVersionAttribute g attrib attribName attribs deterministic = match AttributeHelpers.TryFindStringAttribute g attrib attribs with | Some versionString -> - if deterministic && versionString.Contains("*") then + if deterministic && versionString.Contains('*') then errorR (Error(FSComp.SR.fscAssemblyWildcardAndDeterminism (attribName, versionString), rangeStartup)) try diff --git a/src/Compiler/Facilities/CompilerLocation.fs b/src/Compiler/Facilities/CompilerLocation.fs index 7bee5f1c92a..42e57f7b67a 100644 --- a/src/Compiler/Facilities/CompilerLocation.fs +++ b/src/Compiler/Facilities/CompilerLocation.fs @@ -41,7 +41,7 @@ module internal FSharpEnvironment = let FSharpBinaryMetadataFormatRevision = "2.0.0.0" let isRunningOnCoreClr = - typeof.Assembly.FullName.StartsWith ("System.Private.CoreLib", StringComparison.InvariantCultureIgnoreCase) + typeof.Assembly.FullName.StartsWith ("System.Private.CoreLib", StringComparison.OrdinalIgnoreCase) module Option = /// Convert string into Option string where null and String.Empty result in None diff --git a/src/Compiler/Facilities/prim-lexing.fs b/src/Compiler/Facilities/prim-lexing.fs index 785b7fbdf6f..f6e5c322c4e 100644 --- a/src/Compiler/Facilities/prim-lexing.fs +++ b/src/Compiler/Facilities/prim-lexing.fs @@ -41,7 +41,7 @@ type StringText(str: string) = yield line line <- reader.ReadLine() - if str.EndsWith("\n", StringComparison.Ordinal) then + if str.Length > 0 && str[str.Length - 1] = '\n' then // last trailing space not returned // http://stackoverflow.com/questions/19365404/stringreader-omits-trailing-linebreak yield String.Empty @@ -96,7 +96,7 @@ type StringText(str: string) = if lastIndex <= startIndex || lastIndex >= str.Length then invalidArg "target" "Too big." - str.IndexOf(target, startIndex, target.Length) <> -1 + str.IndexOf(target, startIndex, target.Length, StringComparison.Ordinal) <> -1 member _.Length = str.Length diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 6eaa8a713e5..43100716f43 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -999,7 +999,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s | PlatformID.Unix -> StringComparison.Ordinal | _ -> StringComparison.OrdinalIgnoreCase - if String.Compare(processFileName, commandLineExecutableFileName, stringComparison) = 0 then + if String.Equals(processFileName, commandLineExecutableFileName, stringComparison) then processFileName else sprintf "%s %s" processFileName commandLineExecutableFileName @@ -1537,7 +1537,7 @@ let ConvReflectionTypeToILTypeRef (reflectionTy: Type) = let scoref = ILScopeRef.Assembly aref let fullName = reflectionTy.FullName - let index = fullName.IndexOf("[") + let index = fullName.IndexOf('[') let fullName = if index = -1 then @@ -3361,16 +3361,16 @@ type internal MagicAssemblyResolution() = assemblyReference.Text if - String.Compare( + String.Equals( FileSystemUtils.fileNameOfPath assemblyReference.Text, assemblyReferenceTextDll, StringComparison.OrdinalIgnoreCase - ) = 0 - || String.Compare( + ) + || String.Equals( FileSystemUtils.fileNameOfPath assemblyReference.Text, assemblyReferenceTextExe, StringComparison.OrdinalIgnoreCase - ) = 0 + ) then Some( tcImports.TryResolveAssemblyReference( @@ -3557,7 +3557,7 @@ type FsiStdinLexerProvider match str with | Null -> str | NonNull str -> - if str.Contains("\000") then + if str.Contains('\000') then String(str |> Seq.filter (fun c -> c <> '\000') |> Seq.toArray) else str @@ -4353,7 +4353,7 @@ type FsiInteractionProcessor member _.CompletionsForPartialLID(istate, prefix: string) = let lid, stem = - if prefix.IndexOf(".", StringComparison.Ordinal) >= 0 then + if prefix.Contains '.' then let parts = prefix.Split('.') let n = parts.Length Array.sub parts 0 (n - 1) |> Array.toList, parts[n - 1] diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index b526c09a796..efcfa8b0c08 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -2760,7 +2760,7 @@ module internal ParseAndCheckFile = let sameFile file hashLoadInFile = match file with | None -> false - | Some file -> (0 = String.Compare(hashLoadInFile, file, StringComparison.OrdinalIgnoreCase)) + | Some file -> (String.Equals(hashLoadInFile, file, StringComparison.OrdinalIgnoreCase)) // walk the list of #loads and keep the ones for this file. let hashLoadsInFile = diff --git a/src/Compiler/Service/FSharpParseFileResults.fs b/src/Compiler/Service/FSharpParseFileResults.fs index 427a01b3c4a..61fb9838693 100644 --- a/src/Compiler/Service/FSharpParseFileResults.fs +++ b/src/Compiler/Service/FSharpParseFileResults.fs @@ -15,9 +15,7 @@ open FSharp.Compiler.Text open FSharp.Compiler.Text.Range module SourceFileImpl = - let IsSignatureFile file = - let ext = Path.GetExtension file - 0 = String.Compare(".fsi", ext, StringComparison.OrdinalIgnoreCase) + let IsSignatureFile (file: string) = file.EndsWithOrdinalIgnoreCase ".fsi" /// Additional #defines that should be in place when editing a file in a file editor such as VS. let GetImplicitConditionalDefinesForEditing (isInteractive: bool) = diff --git a/src/Compiler/Service/IncrementalBuild.fs b/src/Compiler/Service/IncrementalBuild.fs index a76b51d9199..abe8742864e 100644 --- a/src/Compiler/Service/IncrementalBuild.fs +++ b/src/Compiler/Service/IncrementalBuild.fs @@ -1317,8 +1317,8 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc // Get the slot of the given file and force it to build. let CompareFileNames f = let result = - String.Compare(fileName, f.Source.FilePath, StringComparison.CurrentCultureIgnoreCase)=0 - || String.Compare(FileSystem.GetFullPathShim fileName, FileSystem.GetFullPathShim f.Source.FilePath, StringComparison.CurrentCultureIgnoreCase)=0 + String.Equals(fileName, f.Source.FilePath, StringComparison.OrdinalIgnoreCase) + || String.Equals(FileSystem.GetFullPathShim fileName, FileSystem.GetFullPathShim f.Source.FilePath, StringComparison.OrdinalIgnoreCase) result match fileNames |> List.tryFindIndex CompareFileNames with | Some slot -> Some slot diff --git a/src/Compiler/Service/QuickParse.fs b/src/Compiler/Service/QuickParse.fs index a1a5a38de03..64a14b3e10c 100644 --- a/src/Compiler/Service/QuickParse.fs +++ b/src/Compiler/Service/QuickParse.fs @@ -427,7 +427,7 @@ module QuickParse = | NonNull lineStr -> GetPartialLongNameExAux(lineStr, index) let TokenNameEquals (tokenInfo: FSharpTokenInfo) (token2: string) = - String.Compare(tokenInfo.TokenName, token2, StringComparison.OrdinalIgnoreCase) = 0 + String.Equals(tokenInfo.TokenName, token2, StringComparison.OrdinalIgnoreCase) // The prefix of the sequence of token names to look for in TestMemberOrOverrideDeclaration, in reverse order let private expected = [ [| "dot" |]; [| "ident" |]; [| "member"; "override" |] ] diff --git a/src/Compiler/Service/ServiceInterfaceStubGenerator.fs b/src/Compiler/Service/ServiceInterfaceStubGenerator.fs index cc56ba41494..89452bf10c4 100644 --- a/src/Compiler/Service/ServiceInterfaceStubGenerator.fs +++ b/src/Compiler/Service/ServiceInterfaceStubGenerator.fs @@ -186,7 +186,7 @@ module InterfaceStubGenerator = (if typar.IsSolveAtCompileTime then "^" else "'") + typar.Name let internal bracket (str: string) = - if str.Contains(" ") then "(" + str + ")" else str + if str.Contains(' ') then "(" + str + ")" else str let internal formatType ctx (ty: FSharpType) = let genericDefinition = diff --git a/src/Compiler/Service/ServiceLexing.fs b/src/Compiler/Service/ServiceLexing.fs index 13be7d68ffe..d940a066025 100644 --- a/src/Compiler/Service/ServiceLexing.fs +++ b/src/Compiler/Service/ServiceLexing.fs @@ -873,7 +873,7 @@ type FSharpLineTokenizer(lexbuf: UnicodeLexing.Lexbuf, maxLength: int option, fi // Process: anywhite* # let processDirective (str: string) directiveLength delay cont = - let hashIdx = str.IndexOf("#", StringComparison.Ordinal) + let hashIdx = str.IndexOf('#') if (hashIdx <> 0) then delay (WHITESPACE cont, 0, hashIdx - 1) diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index 9a94a3626b0..f6dcd44e0e3 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -17,9 +17,7 @@ open FSharp.Compiler.Text.Position open FSharp.Compiler.Text.Range module SourceFileImpl = - let IsSignatureFile file = - let ext = Path.GetExtension file - 0 = String.Compare(".fsi", ext, StringComparison.OrdinalIgnoreCase) + let IsSignatureFile (file: string) = file.EndsWithOrdinalIgnoreCase ".fsi" /// Additional #defines that should be in place when editing a file in a file editor such as VS. let GetImplicitConditionalDefinesForEditing (isInteractive: bool) = diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index f4ecaad9355..eeec102e410 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -1847,11 +1847,11 @@ type CompilerEnvironment() = let ext = Path.GetExtension file compilableExtensions - |> List.exists (fun e -> 0 = String.Compare(e, ext, StringComparison.OrdinalIgnoreCase)) + |> List.exists (fun e -> String.Equals(e, ext, StringComparison.OrdinalIgnoreCase)) /// Whether or not this file should be a single-file project static member MustBeSingleFileProject file = let ext = Path.GetExtension file singleFileProjectExtensions - |> List.exists (fun e -> 0 = String.Compare(e, ext, StringComparison.OrdinalIgnoreCase)) + |> List.exists (fun e -> String.Equals(e, ext, StringComparison.OrdinalIgnoreCase)) diff --git a/src/Compiler/Symbols/Symbols.fs b/src/Compiler/Symbols/Symbols.fs index e59caf2c6d4..f7eba231637 100644 --- a/src/Compiler/Symbols/Symbols.fs +++ b/src/Compiler/Symbols/Symbols.fs @@ -817,7 +817,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) = match fullName with | Some fullName -> match Option.attempt (fun _ -> x.DisplayName) with - | Some shortDisplayName when not (shortDisplayName.Contains ".") -> + | Some shortDisplayName when not (shortDisplayName.Contains '.') -> Some (fullName |> Array.replace (fullName.Length - 1) shortDisplayName) | _ -> Some fullName | None -> None @@ -831,7 +831,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) = match fullName with | Some fullName -> match Option.attempt (fun _ -> x.CompiledName) with - | Some shortCompiledName when not (shortCompiledName.Contains ".") -> + | Some shortCompiledName when not (shortCompiledName.Contains '.') -> Some (fullName |> Array.replace (fullName.Length - 1) shortCompiledName) | _ -> Some fullName | None -> None @@ -2427,7 +2427,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match fullName with | Some fullName -> match Option.attempt (fun _ -> x.DisplayName) with - | Some shortDisplayName when not (shortDisplayName.Contains ".") -> + | Some shortDisplayName when not (shortDisplayName.Contains '.') -> Some (fullName |> Array.replace (fullName.Length - 1) shortDisplayName) | _ -> Some fullName | None -> None diff --git a/src/Compiler/SyntaxTree/PrettyNaming.fs b/src/Compiler/SyntaxTree/PrettyNaming.fs index ddaf129df18..fa27663d774 100755 --- a/src/Compiler/SyntaxTree/PrettyNaming.fs +++ b/src/Compiler/SyntaxTree/PrettyNaming.fs @@ -1010,7 +1010,7 @@ exception InvalidMangledStaticArg of string /// Demangle the static parameters let DemangleProvidedTypeName (typeLogicalName: string) = - if typeLogicalName.Contains "," then + if typeLogicalName.Contains ',' then let pieces = splitAroundQuotation typeLogicalName ',' match pieces with diff --git a/src/Compiler/SyntaxTree/XmlDoc.fs b/src/Compiler/SyntaxTree/XmlDoc.fs index ee92eae9a02..06252345e12 100644 --- a/src/Compiler/SyntaxTree/XmlDoc.fs +++ b/src/Compiler/SyntaxTree/XmlDoc.fs @@ -320,14 +320,14 @@ type XmlDocumentationInfo private (tryGetXmlDocument: unit -> XmlDocument option ) let tryGetSummaryNode (xmlDocSig: string) = - if xmlDocSig.Contains "'" && xmlDocSig.Contains "\"" then + if xmlDocSig.Contains ''' && xmlDocSig.Contains '\"' then // No easy way to find this signature with XPath None else tryGetXmlDocument () |> Option.bind (fun doc -> let name = - if xmlDocSig.Contains "'" then + if xmlDocSig.Contains '\'' then $"\"{xmlDocSig}\"" else $"'{xmlDocSig}'" diff --git a/src/Compiler/TypedTree/TypeProviders.fs b/src/Compiler/TypedTree/TypeProviders.fs index dff177e296f..3204a0fd528 100644 --- a/src/Compiler/TypedTree/TypeProviders.fs +++ b/src/Compiler/TypedTree/TypeProviders.fs @@ -183,7 +183,7 @@ let GetTypeProvidersOfAssembly ( // Check if the attribute is pointing to the file being compiled, in which case ignore it // This checks seems like legacy but is included for compat. | Some designTimeAssemblyName, Some path - when String.Compare(designTimeAssemblyName.Name, Path.GetFileNameWithoutExtension path, StringComparison.OrdinalIgnoreCase) = 0 -> + when String.Equals(designTimeAssemblyName.Name, Path.GetFileNameWithoutExtension path, StringComparison.OrdinalIgnoreCase) -> () | Some _, _ -> diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index b1b400da64e..7ad761bdbc1 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -68,6 +68,9 @@ module internal PervasiveAutoOpens = let LOH_SIZE_THRESHOLD_BYTES = 80_000 type String with + // char overload + member inline x.Contains (value: char) = + x.IndexOf value <> -1 member inline x.StartsWithOrdinal value = x.StartsWith(value, StringComparison.Ordinal) diff --git a/src/Compiler/Utilities/illib.fsi b/src/Compiler/Utilities/illib.fsi index b6b06e60914..6351c11a214 100644 --- a/src/Compiler/Utilities/illib.fsi +++ b/src/Compiler/Utilities/illib.fsi @@ -55,6 +55,8 @@ module internal PervasiveAutoOpens = type String with + member inline Contains: value: char -> bool + member inline StartsWithOrdinal: value: string -> bool member inline EndsWithOrdinal: value: string -> bool diff --git a/src/Compiler/Utilities/range.fs b/src/Compiler/Utilities/range.fs index 0a91bb1a2c3..9dc240d944c 100755 --- a/src/Compiler/Utilities/range.fs +++ b/src/Compiler/Utilities/range.fs @@ -365,7 +365,7 @@ type Range(code1: int64, code2: int64) = |> Seq.skip (m.StartLine - 1) |> Seq.take (m.EndLine - m.StartLine + 1) |> String.concat "\n" - |> fun s -> s.Substring(startCol + 1, s.LastIndexOf("\n", StringComparison.Ordinal) + 1 - startCol + endCol) + |> fun s -> s.Substring(startCol + 1, s.LastIndexOf('\n') + 1 - startCol + endCol) with e -> e.ToString() diff --git a/src/FSharp.Core/printf.fs b/src/FSharp.Core/printf.fs index 310753ca37e..8ec1db01fe1 100644 --- a/src/FSharp.Core/printf.fs +++ b/src/FSharp.Core/printf.fs @@ -212,7 +212,7 @@ module internal PrintfImpl = let parseInterpolatedHoleDotNetFormat typeChar (s: string) (i: byref) = if typeChar = 'P' then if i < s.Length && s.[i] = '(' then - let i2 = s.IndexOf(")", i) + let i2 = s.IndexOf(')', i) if i2 = -1 then ValueNone else diff --git a/src/FSharp.Core/string.fs b/src/FSharp.Core/string.fs index 8580c6451d2..64c5523386b 100644 --- a/src/FSharp.Core/string.fs +++ b/src/FSharp.Core/string.fs @@ -29,8 +29,9 @@ module String = let concatArray sep (strings: string[]) = match length sep with | 0 -> String.Concat strings - // following line should be used when this overload becomes part of .NET Standard (it's only in .NET Core) - //| 1 -> String.Join(sep.[0], strings, 0, strings.Length) +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER + | 1 -> String.Join(sep[0], strings, 0, strings.Length) +#endif | _ -> String.Join(sep, strings, 0, strings.Length) match strings with From 539be602d1b39a20f492ff55f077ad519a3c3cd4 Mon Sep 17 00:00:00 2001 From: OwnageIsMagic Date: Sun, 1 Oct 2023 15:20:07 +0300 Subject: [PATCH 3/7] fix bugs --- src/Compiler/AbstractIL/il.fs | 8 ++++---- src/Compiler/AbstractIL/ilwrite.fs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 2c96d10f528..4322eeb2818 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -55,10 +55,10 @@ type PrimaryAssembly = static member IsPossiblePrimaryAssembly(fileName: string) = let name = System.IO.Path.GetFileNameWithoutExtension(fileName) - String.Compare(name, "mscorlib", true) <> 0 - || String.Compare(name, "System.Runtime", true) <> 0 - || String.Compare(name, "netstandard", true) <> 0 - || String.Compare(name, "System.Private.CoreLib", true) <> 0 + String.Equals(name, "mscorlib", StringComparison.OrdinalIgnoreCase) + || String.Equals(name, "System.Runtime", StringComparison.OrdinalIgnoreCase) + || String.Equals(name, "netstandard", StringComparison.OrdinalIgnoreCase) + || String.Equals(name, "System.Private.CoreLib", StringComparison.OrdinalIgnoreCase) // -------------------------------------------------------------------- // Utilities: type names diff --git a/src/Compiler/AbstractIL/ilwrite.fs b/src/Compiler/AbstractIL/ilwrite.fs index ecddf2460d8..fde0646f3fd 100644 --- a/src/Compiler/AbstractIL/ilwrite.fs +++ b/src/Compiler/AbstractIL/ilwrite.fs @@ -3739,7 +3739,7 @@ let writePdb ( let pdbfileInfo = FileInfo(pdbfile).FullName // If pdbfilepath matches output filepath then error - if String.Compare(outfileInfo, pdbfileInfo, StringComparison.InvariantCulture) = 0 then + if outfileInfo = pdbfileInfo then errorR(Error(FSComp.SR.optsPdbMatchesOutputFileName(), rangeStartup)) try FileSystem.FileDeleteShim pdbfile with _ -> () use fs = FileSystem.OpenFileForWriteShim(pdbfile, fileMode = FileMode.Create, fileAccess = FileAccess.ReadWrite) From 7f7f3fd38151082a03610b03de5e691ddaedfda4 Mon Sep 17 00:00:00 2001 From: OwnageIsMagic Date: Sun, 1 Oct 2023 16:44:12 +0300 Subject: [PATCH 4/7] fixup --- src/Compiler/Checking/NameResolution.fs | 2 +- src/Compiler/Driver/CompilerConfig.fs | 2 +- src/Compiler/SyntaxTree/XmlDoc.fs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 29ebfcc012c..ddb256c1b70 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3245,7 +3245,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa not newDef && warnOnUpper = WarnOnUpperCase && id.idText.Length >= 3 - && System.Char.IsLower id.idText[0] + && System.Char.IsUpper id.idText[0] then warning(UpperCaseIdentifierInPattern m) diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index d7e2efbdd49..97c7a2e4d77 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -274,7 +274,7 @@ type AssemblyReference = member x.ProjectReference = (let (AssemblyReference (_, _, contents)) = x in contents) member x.SimpleAssemblyNameIs name = - (String.Equals(FileSystemUtils.fileNameWithoutExtensionWithValidate false x.Text, name, StringComparison.OrdinalIgnoreCase)) + String.Equals(FileSystemUtils.fileNameWithoutExtensionWithValidate false x.Text, name, StringComparison.OrdinalIgnoreCase) || not (x.Text.Contains '/') && not (x.Text.Contains '\\') && not (x.Text.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) diff --git a/src/Compiler/SyntaxTree/XmlDoc.fs b/src/Compiler/SyntaxTree/XmlDoc.fs index 06252345e12..8d7c638cd09 100644 --- a/src/Compiler/SyntaxTree/XmlDoc.fs +++ b/src/Compiler/SyntaxTree/XmlDoc.fs @@ -320,7 +320,7 @@ type XmlDocumentationInfo private (tryGetXmlDocument: unit -> XmlDocument option ) let tryGetSummaryNode (xmlDocSig: string) = - if xmlDocSig.Contains ''' && xmlDocSig.Contains '\"' then + if xmlDocSig.Contains '\'' && xmlDocSig.Contains '\"' then // No easy way to find this signature with XPath None else From 4bd39ebb5b835fca71f7d71e19c44e50d16a5371 Mon Sep 17 00:00:00 2001 From: OwnageIsMagic Date: Sun, 1 Oct 2023 18:48:19 +0300 Subject: [PATCH 5/7] formating --- src/Compiler/Driver/CompilerConfig.fs | 2 +- src/Compiler/Driver/CreateILModule.fs | 2 +- src/Compiler/Driver/ScriptClosure.fs | 3 ++- .../Legacy/LegacyHostedCompilerForTesting.fs | 21 ++++++++++++++++--- src/Compiler/Service/QuickParse.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTreeOps.fs | 14 +++++++------ src/Compiler/Utilities/illib.fs | 5 ++--- src/Compiler/Utilities/illib.fsi | 2 +- src/Compiler/Utilities/sformat.fs | 3 ++- 9 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index 97c7a2e4d77..70598e5497f 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -97,7 +97,7 @@ let GetWarningNumber (m, warningNumber: string) = // #pragma strips FS of the #pragma "FS0004" and validates the warning number // therefore if we have warning id that starts with a numeric digit we convert it to Some (int32) // anything else is ignored None - if isDigit(warningNumber[0]) then + if isDigit (warningNumber[0]) then Some(int32 warningNumber) elif warningNumber.StartsWithOrdinal("FS") = true then raise (ArgumentException()) diff --git a/src/Compiler/Driver/CreateILModule.fs b/src/Compiler/Driver/CreateILModule.fs index 9649b7e09c2..2fa6a80eaa0 100644 --- a/src/Compiler/Driver/CreateILModule.fs +++ b/src/Compiler/Driver/CreateILModule.fs @@ -267,7 +267,7 @@ module MainModuleBuilder = ((false, ""), v) ||> Seq.fold (fun (finished, v) c -> match finished with - | false when isDigit(c) -> false, v + c.ToString() + | false when isDigit (c) -> false, v + c.ToString() | _ -> true, v) |> snd diff --git a/src/Compiler/Driver/ScriptClosure.fs b/src/Compiler/Driver/ScriptClosure.fs index ec34fa5d00a..c883408c174 100644 --- a/src/Compiler/Driver/ScriptClosure.fs +++ b/src/Compiler/Driver/ScriptClosure.fs @@ -603,7 +603,8 @@ module ScriptPreprocessClosure = (codeContext <> CodeContext.Editing) && (equals m range0 || equals m rangeStartup || equals m rangeCmdArgs) - let isThisFileName = String.Equals(rootFilename, m.FileName, StringComparison.OrdinalIgnoreCase) + let isThisFileName = + String.Equals(rootFilename, m.FileName, StringComparison.OrdinalIgnoreCase) isArgParameterWhileNotEditing || isThisFileName | None -> true diff --git a/src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs b/src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs index 4fc8a171919..1c818a840c6 100644 --- a/src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs +++ b/src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs @@ -185,21 +185,36 @@ type internal FscCompiler(legacyReferenceResolver) = /// test if --test:ErrorRanges flag is set let errorRangesArg = let regex = - Regex(@"^(/|--)test:ErrorRanges$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase ||| RegexOptions.CultureInvariant) + Regex( + @"^(/|--)test:ErrorRanges$", + RegexOptions.Compiled + ||| RegexOptions.IgnoreCase + ||| RegexOptions.CultureInvariant + ) fun arg -> regex.IsMatch(arg) /// test if --vserrors flag is set let vsErrorsArg = let regex = - Regex(@"^(/|--)vserrors$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase ||| RegexOptions.CultureInvariant) + Regex( + @"^(/|--)vserrors$", + RegexOptions.Compiled + ||| RegexOptions.IgnoreCase + ||| RegexOptions.CultureInvariant + ) fun arg -> regex.IsMatch(arg) /// test if an arg is a path to fsc.exe let fscExeArg = let regex = - Regex(@"fsc(\.exe)?$", RegexOptions.Compiled ||| RegexOptions.IgnoreCase ||| RegexOptions.CultureInvariant) + Regex( + @"fsc(\.exe)?$", + RegexOptions.Compiled + ||| RegexOptions.IgnoreCase + ||| RegexOptions.CultureInvariant + ) fun arg -> regex.IsMatch(arg) diff --git a/src/Compiler/Service/QuickParse.fs b/src/Compiler/Service/QuickParse.fs index 64a14b3e10c..e70ea1b86b5 100644 --- a/src/Compiler/Service/QuickParse.fs +++ b/src/Compiler/Service/QuickParse.fs @@ -415,7 +415,7 @@ module QuickParse = let partialLongName = AtStartOfIdentifier(0, [], false, None) match List.rev partialLongName.QualifyingIdents with - | s :: _ when s.Length > 0 && isDigit(s[0]) -> PartialLongName.Empty(index) // "2.0" is not a longId (this might not be right for ``2.0`` but good enough for common case) + | s :: _ when s.Length > 0 && isDigit (s[0]) -> PartialLongName.Empty(index) // "2.0" is not a longId (this might not be right for ``2.0`` but good enough for common case) | plid -> { partialLongName with QualifyingIdents = plid diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index 8fc537db5ab..dd52b257b51 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -1034,13 +1034,15 @@ let getTypeFromTuplePath (path: SynTupleTypeSegment list) : SynType list = let (|MultiDimensionArrayType|_|) (t: SynType) = match t with | SynType.App (StripParenTypes (SynType.LongIdent (SynLongIdent ([ identifier ], _, _))), _, [ elementType ], _, _, true, m) -> - if System.Text.RegularExpressions.Regex.IsMatch(identifier.idText, "^array\d\d?d$", System.Text.RegularExpressions.RegexOptions.ECMAScript) then + if + System.Text.RegularExpressions.Regex.IsMatch( + identifier.idText, + "^array\d\d?d$", + System.Text.RegularExpressions.RegexOptions.ECMAScript + ) + then let rank = - identifier.idText - |> Seq.filter isDigit - |> Seq.toArray - |> System.String - |> int + identifier.idText |> Seq.filter isDigit |> Seq.toArray |> System.String |> int Some(rank, elementType, m) else diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index 7ad761bdbc1..ebc41260c0f 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -69,8 +69,7 @@ module internal PervasiveAutoOpens = type String with // char overload - member inline x.Contains (value: char) = - x.IndexOf value <> -1 + member inline x.Contains(value: char) = x.IndexOf value <> -1 member inline x.StartsWithOrdinal value = x.StartsWith(value, StringComparison.Ordinal) @@ -81,7 +80,7 @@ module internal PervasiveAutoOpens = member inline x.EndsWithOrdinalIgnoreCase value = x.EndsWith(value, StringComparison.OrdinalIgnoreCase) - let inline isDigit (c: char) = (uint)(c - '0') <= (uint)('9' - '0'); + let inline isDigit (c: char) = (uint) (c - '0') <= (uint) ('9' - '0') /// Get an initialization hole let getHole (r: _ ref) = diff --git a/src/Compiler/Utilities/illib.fsi b/src/Compiler/Utilities/illib.fsi index 6351c11a214..7a9678bc059 100644 --- a/src/Compiler/Utilities/illib.fsi +++ b/src/Compiler/Utilities/illib.fsi @@ -64,7 +64,7 @@ module internal PervasiveAutoOpens = member inline EndsWithOrdinalIgnoreCase: value: string -> bool /// Returns true if the argument is ASCII digit (0-9). - val inline isDigit : c: char -> bool + val inline isDigit: c: char -> bool type Async with diff --git a/src/Compiler/Utilities/sformat.fs b/src/Compiler/Utilities/sformat.fs index a74c81f780b..4f340ff6ead 100644 --- a/src/Compiler/Utilities/sformat.fs +++ b/src/Compiler/Utilities/sformat.fs @@ -1149,7 +1149,8 @@ module Display = spaceListL ( List.rev ( (sepL (tagText preText) - ^^ alternativeObjL ^^ sepL (tagText (replaceEscapedBrackets (remainingPropertyText)))) + ^^ alternativeObjL + ^^ sepL (tagText (replaceEscapedBrackets (remainingPropertyText)))) :: layouts ) ) From 60da59797040392d7a4ba709d52baaa8bbe4dc4d Mon Sep 17 00:00:00 2001 From: OwnageIsMagic Date: Wed, 4 Oct 2023 12:31:59 +0300 Subject: [PATCH 6/7] add comment --- src/Compiler/Checking/NameResolution.fs | 2 +- src/Compiler/Utilities/illib.fs | 3 ++- src/FSharp.Core/printf.fs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index ddb256c1b70..5d5e841e1fb 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -3245,7 +3245,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv: NameResolver) fullyQualified wa not newDef && warnOnUpper = WarnOnUpperCase && id.idText.Length >= 3 - && System.Char.IsUpper id.idText[0] + && System.Char.ToLowerInvariant id.idText[0] <> id.idText[0] then warning(UpperCaseIdentifierInPattern m) diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index ebc41260c0f..e48a610554c 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -80,7 +80,8 @@ module internal PervasiveAutoOpens = member inline x.EndsWithOrdinalIgnoreCase value = x.EndsWith(value, StringComparison.OrdinalIgnoreCase) - let inline isDigit (c: char) = (uint) (c - '0') <= (uint) ('9' - '0') + // Backport of Char.IsAsciiDigit. Do not use Char.IsDigit + let inline isDigit (c: char) = uint (c - '0') <= uint ('9' - '0') /// Get an initialization hole let getHole (r: _ ref) = diff --git a/src/FSharp.Core/printf.fs b/src/FSharp.Core/printf.fs index 8ec1db01fe1..d24cfceeeb9 100644 --- a/src/FSharp.Core/printf.fs +++ b/src/FSharp.Core/printf.fs @@ -84,7 +84,8 @@ module internal PrintfImpl = let inline isPlusForPositives flags = hasFlag flags FormatFlags.PlusForPositives let inline isSpaceForPositives flags = hasFlag flags FormatFlags.SpaceForPositives - let inline isDigit (c: char) = (uint)(c - '0') <= (uint)('9' - '0'); + // Backport of Char.IsAsciiDigit. Do not use Char.IsDigit + let inline isDigit (c: char) = uint (c - '0') <= uint ('9' - '0') /// Used for width and precision to denote that user has specified '*' flag [] From b4afa997c703f2ed3e29ab4da1815b0090ecf514 Mon Sep 17 00:00:00 2001 From: OwnageIsMagic Date: Thu, 21 Dec 2023 06:06:19 +0300 Subject: [PATCH 7/7] fix formatting; fix typo --- src/Compiler/Facilities/CompilerLocation.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTreeOps.fs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Facilities/CompilerLocation.fs b/src/Compiler/Facilities/CompilerLocation.fs index 314746453e5..150de84676e 100644 --- a/src/Compiler/Facilities/CompilerLocation.fs +++ b/src/Compiler/Facilities/CompilerLocation.fs @@ -299,7 +299,7 @@ module internal FSharpEnvironment = // How to find dotnet.exe --- woe is me; probing rules make me sad. // Algorithm: // 1. Look for DOTNET_HOST_PATH environment variable - // this is the main user programable override .. provided by user to find a specific dotnet.exe + // this is the main user programmable override .. provided by user to find a specific dotnet.exe // 2. Probe for are we part of an .NetSDK install // In an sdk install we are always installed in: sdk\3.0.100-rc2-014234\FSharp // dotnet or dotnet.exe will be found in the directory that contains the sdk directory diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index 194813dfc47..0ae22b8127b 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -1028,7 +1028,13 @@ let getTypeFromTuplePath (path: SynTupleTypeSegment list) : SynType list = let (|MultiDimensionArrayType|_|) (t: SynType) = match t with | SynType.App(StripParenTypes(SynType.LongIdent(SynLongIdent([ identifier ], _, _))), _, [ elementType ], _, _, true, m) -> - if System.Text.RegularExpressions.Regex.IsMatch(identifier.idText, "^array\d\d?d$", System.Text.RegularExpressions.RegexOptions.ECMAScript) then + if + System.Text.RegularExpressions.Regex.IsMatch( + identifier.idText, + "^array\d\d?d$", + System.Text.RegularExpressions.RegexOptions.ECMAScript + ) + then let rank = identifier.idText |> Seq.filter isDigit |> Seq.toArray |> System.String |> int