From e7d385971617c7611f6a214dd5f59289b055a17c Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Sun, 3 Dec 2023 21:53:21 +0100 Subject: [PATCH 1/5] Checking if this can be netstandard2.0 project instead of netstandard2.1 --- docs/apidocs.fsx | 2 +- docs/codeformat.fsx | 2 +- docs/content.fsx | 2 +- docs/evaluation.fsx | 2 +- docs/literate.fsx | 4 ++-- docs/markdown.fsx | 2 +- .../FSharp.Formatting.ApiDocs.fsproj | 2 +- .../FSharp.Formatting.CSharpFormat.csproj | 2 +- .../FSharp.Formatting.CodeFormat.fsproj | 2 +- src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj | 2 +- .../FSharp.Formatting.Literate.fsproj | 2 +- .../FSharp.Formatting.Markdown.fsproj | 2 +- src/FSharp.Formatting/FSharp.Formatting.fsproj | 2 +- src/FSharp.Formatting/FSharp.Formatting.fsx | 4 ++-- tests/FSharp.ApiDocs.Tests/AttributeTests.fs | 2 +- .../files/AttributesTestLib/AttributesTestLib.fsproj | 2 +- tests/FSharp.ApiDocs.Tests/files/FsLib1/FsLib1.fsproj | 2 +- tests/FSharp.ApiDocs.Tests/files/FsLib2/FsLib2.fsproj | 2 +- tests/FSharp.ApiDocs.Tests/files/TestLib1/TestLib1.fsproj | 2 +- tests/FSharp.ApiDocs.Tests/files/TestLib2/TestLib2.fsproj | 2 +- tests/FSharp.ApiDocs.Tests/files/TestLib3/TestLib3.fsproj | 2 +- tests/FSharp.ApiDocs.Tests/files/crefLib1/crefLib1.fsproj | 2 +- tests/FSharp.ApiDocs.Tests/files/crefLib2/crefLib2.fsproj | 2 +- tests/FSharp.ApiDocs.Tests/files/crefLib3/crefLib3.csproj | 2 +- tests/FSharp.ApiDocs.Tests/files/crefLib4/crefLib4.csproj | 2 +- .../files/csharpSupport/csharpSupport.csproj | 2 +- .../FSharp.Formatting.TestHelpers.fsproj | 2 +- 27 files changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/apidocs.fsx b/docs/apidocs.fsx index c2ea469d4..0178ff7f0 100644 --- a/docs/apidocs.fsx +++ b/docs/apidocs.fsx @@ -8,7 +8,7 @@ index: 6 *) (*** condition: prepare ***) #nowarn "211" -#I "../src/FSharp.Formatting/bin/Release/netstandard2.1" +#I "../src/FSharp.Formatting/bin/Release/netstandard2.0" #r "FSharp.Compiler.Service" #r "FSharp.Formatting.Common.dll" #r "FSharp.Formatting.Markdown.dll" diff --git a/docs/codeformat.fsx b/docs/codeformat.fsx index 3c36b4dfb..4da131b88 100644 --- a/docs/codeformat.fsx +++ b/docs/codeformat.fsx @@ -7,7 +7,7 @@ index: 1 *) (*** condition: prepare ***) #nowarn "211" -#I "../src/FSharp.Formatting/bin/Release/netstandard2.1" +#I "../src/FSharp.Formatting/bin/Release/netstandard2.0" #r "FSharp.Formatting.Common.dll" #r "FSharp.Formatting.Markdown.dll" #r "FSharp.Formatting.CodeFormat.dll" diff --git a/docs/content.fsx b/docs/content.fsx index b686c6566..d6b0e0ced 100644 --- a/docs/content.fsx +++ b/docs/content.fsx @@ -7,7 +7,7 @@ index: 5 *) (*** condition: prepare ***) #nowarn "211" -#I "../src/FSharp.Formatting/bin/Release/netstandard2.1" +#I "../src/FSharp.Formatting/bin/Release/netstandard2.0" #r "FSharp.Formatting.Common.dll" #r "FSharp.Formatting.Markdown.dll" #r "FSharp.Formatting.CodeFormat.dll" diff --git a/docs/evaluation.fsx b/docs/evaluation.fsx index 1fe4fbb5d..0acb62f42 100644 --- a/docs/evaluation.fsx +++ b/docs/evaluation.fsx @@ -7,7 +7,7 @@ index: 7 *) (*** condition: prepare ***) #nowarn "211" -#I "../src/FSharp.Formatting/bin/Release/netstandard2.1" +#I "../src/FSharp.Formatting/bin/Release/netstandard2.0" #r "FSharp.Formatting.Common.dll" #r "FSharp.Formatting.Markdown.dll" #r "FSharp.Formatting.CodeFormat.dll" diff --git a/docs/literate.fsx b/docs/literate.fsx index ecbd7475e..be23c0d37 100644 --- a/docs/literate.fsx +++ b/docs/literate.fsx @@ -7,7 +7,7 @@ index: 3 *) (*** condition: prepare ***) #nowarn "211" -#I "../src/FSharp.Formatting/bin/Release/netstandard2.1" +#I "../src/FSharp.Formatting/bin/Release/netstandard2.0" #r "FSharp.Formatting.Common.dll" #r "FSharp.Formatting.Markdown.dll" #r "FSharp.Formatting.CodeFormat.dll" @@ -197,7 +197,7 @@ A header may be needed to get the code to load, a typical example is this: ```text (*** condition: prepare ***) #nowarn "211" - #I "../src/FSharp.Formatting/bin/Release/netstandard2.1" + #I "../src/FSharp.Formatting/bin/Release/netstandard2.0" #r "FSharp.Formatting.Common.dll" #r "FSharp.Formatting.Markdown.dll" #r "FSharp.Formatting.CodeFormat.dll" diff --git a/docs/markdown.fsx b/docs/markdown.fsx index 58dc54c36..0719e950a 100644 --- a/docs/markdown.fsx +++ b/docs/markdown.fsx @@ -6,7 +6,7 @@ index: 2 --- *) (*** condition: prepare ***) -#I "../src/FSharp.Formatting/bin/Release/netstandard2.1" +#I "../src/FSharp.Formatting/bin/Release/netstandard2.0" #r "FSharp.Formatting.Common.dll" #r "FSharp.Formatting.Markdown.dll" (*** condition: fsx ***) diff --git a/src/FSharp.Formatting.ApiDocs/FSharp.Formatting.ApiDocs.fsproj b/src/FSharp.Formatting.ApiDocs/FSharp.Formatting.ApiDocs.fsproj index 1255480ce..1ff69c10f 100644 --- a/src/FSharp.Formatting.ApiDocs/FSharp.Formatting.ApiDocs.fsproj +++ b/src/FSharp.Formatting.ApiDocs/FSharp.Formatting.ApiDocs.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 diff --git a/src/FSharp.Formatting.CSharpFormat/FSharp.Formatting.CSharpFormat.csproj b/src/FSharp.Formatting.CSharpFormat/FSharp.Formatting.CSharpFormat.csproj index c16de1446..738cfe10b 100644 --- a/src/FSharp.Formatting.CSharpFormat/FSharp.Formatting.CSharpFormat.csproj +++ b/src/FSharp.Formatting.CSharpFormat/FSharp.Formatting.CSharpFormat.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 diff --git a/src/FSharp.Formatting.CodeFormat/FSharp.Formatting.CodeFormat.fsproj b/src/FSharp.Formatting.CodeFormat/FSharp.Formatting.CodeFormat.fsproj index b6a901eea..b0dc71e91 100644 --- a/src/FSharp.Formatting.CodeFormat/FSharp.Formatting.CodeFormat.fsproj +++ b/src/FSharp.Formatting.CodeFormat/FSharp.Formatting.CodeFormat.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 diff --git a/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj b/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj index d0756aaed..cd306f3ea 100644 --- a/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj +++ b/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 TRACE;YAAF_FSHARP_SCRIPTING_PUBLIC true FS0025;FS1182;$(WarningsAsErrors) diff --git a/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj b/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj index 25e193476..8a9c05ff4 100644 --- a/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj +++ b/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 true diff --git a/src/FSharp.Formatting.Markdown/FSharp.Formatting.Markdown.fsproj b/src/FSharp.Formatting.Markdown/FSharp.Formatting.Markdown.fsproj index 2a91fe9b9..e6e9ace85 100644 --- a/src/FSharp.Formatting.Markdown/FSharp.Formatting.Markdown.fsproj +++ b/src/FSharp.Formatting.Markdown/FSharp.Formatting.Markdown.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 diff --git a/src/FSharp.Formatting/FSharp.Formatting.fsproj b/src/FSharp.Formatting/FSharp.Formatting.fsproj index 1f0f340ed..fd2b4e4f0 100644 --- a/src/FSharp.Formatting/FSharp.Formatting.fsproj +++ b/src/FSharp.Formatting/FSharp.Formatting.fsproj @@ -1,6 +1,6 @@  - netstandard2.1 + netstandard2.0 true true diff --git a/src/FSharp.Formatting/FSharp.Formatting.fsx b/src/FSharp.Formatting/FSharp.Formatting.fsx index 2b2f1b587..e16428a58 100644 --- a/src/FSharp.Formatting/FSharp.Formatting.fsx +++ b/src/FSharp.Formatting/FSharp.Formatting.fsx @@ -1,11 +1,11 @@ #nowarn "211" // FSharp.Formatting repo context: uncomment for intellisense -//#I "bin/Release/netstandard2.1" +//#I "bin/Release/netstandard2.0" // Standard NuGet or Paket location #I __SOURCE_DIRECTORY__ -#I "lib/netstandard2.1" +#I "lib/netstandard2.0" // Standard Paket locations #I "../FSharp.Compiler.Service/lib/netstandard2.0" diff --git a/tests/FSharp.ApiDocs.Tests/AttributeTests.fs b/tests/FSharp.ApiDocs.Tests/AttributeTests.fs index 02bf41d15..7b51e43e4 100644 --- a/tests/FSharp.ApiDocs.Tests/AttributeTests.fs +++ b/tests/FSharp.ApiDocs.Tests/AttributeTests.fs @@ -27,7 +27,7 @@ let configuration = "Release" #endif -let tfm = "netstandard2.1" +let tfm = "netstandard2.0" // NOTE - For these tests to run properly they require the output of all the metadata // test project to be directed to the directory below diff --git a/tests/FSharp.ApiDocs.Tests/files/AttributesTestLib/AttributesTestLib.fsproj b/tests/FSharp.ApiDocs.Tests/files/AttributesTestLib/AttributesTestLib.fsproj index c2c78bec1..634c14c8b 100644 --- a/tests/FSharp.ApiDocs.Tests/files/AttributesTestLib/AttributesTestLib.fsproj +++ b/tests/FSharp.ApiDocs.Tests/files/AttributesTestLib/AttributesTestLib.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 ..\bin\$(Configuration) FS1182 diff --git a/tests/FSharp.ApiDocs.Tests/files/FsLib1/FsLib1.fsproj b/tests/FSharp.ApiDocs.Tests/files/FsLib1/FsLib1.fsproj index 3098691d0..e48c0851b 100644 --- a/tests/FSharp.ApiDocs.Tests/files/FsLib1/FsLib1.fsproj +++ b/tests/FSharp.ApiDocs.Tests/files/FsLib1/FsLib1.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 ..\bin\$(Configuration) diff --git a/tests/FSharp.ApiDocs.Tests/files/FsLib2/FsLib2.fsproj b/tests/FSharp.ApiDocs.Tests/files/FsLib2/FsLib2.fsproj index c675160ae..fddc6f19f 100644 --- a/tests/FSharp.ApiDocs.Tests/files/FsLib2/FsLib2.fsproj +++ b/tests/FSharp.ApiDocs.Tests/files/FsLib2/FsLib2.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 ..\bin\$(Configuration) FS1182 diff --git a/tests/FSharp.ApiDocs.Tests/files/TestLib1/TestLib1.fsproj b/tests/FSharp.ApiDocs.Tests/files/TestLib1/TestLib1.fsproj index 13ebd334f..30c813b49 100644 --- a/tests/FSharp.ApiDocs.Tests/files/TestLib1/TestLib1.fsproj +++ b/tests/FSharp.ApiDocs.Tests/files/TestLib1/TestLib1.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 ..\bin\$(Configuration) diff --git a/tests/FSharp.ApiDocs.Tests/files/TestLib2/TestLib2.fsproj b/tests/FSharp.ApiDocs.Tests/files/TestLib2/TestLib2.fsproj index f55d5dd2a..ee207621b 100644 --- a/tests/FSharp.ApiDocs.Tests/files/TestLib2/TestLib2.fsproj +++ b/tests/FSharp.ApiDocs.Tests/files/TestLib2/TestLib2.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 ..\bin\$(Configuration) diff --git a/tests/FSharp.ApiDocs.Tests/files/TestLib3/TestLib3.fsproj b/tests/FSharp.ApiDocs.Tests/files/TestLib3/TestLib3.fsproj index d16b794bf..514e8e15b 100644 --- a/tests/FSharp.ApiDocs.Tests/files/TestLib3/TestLib3.fsproj +++ b/tests/FSharp.ApiDocs.Tests/files/TestLib3/TestLib3.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 ..\bin\$(Configuration) diff --git a/tests/FSharp.ApiDocs.Tests/files/crefLib1/crefLib1.fsproj b/tests/FSharp.ApiDocs.Tests/files/crefLib1/crefLib1.fsproj index 0eb463dc1..3890cc90e 100644 --- a/tests/FSharp.ApiDocs.Tests/files/crefLib1/crefLib1.fsproj +++ b/tests/FSharp.ApiDocs.Tests/files/crefLib1/crefLib1.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 ..\bin\$(Configuration) diff --git a/tests/FSharp.ApiDocs.Tests/files/crefLib2/crefLib2.fsproj b/tests/FSharp.ApiDocs.Tests/files/crefLib2/crefLib2.fsproj index 66f4b7144..a08e9f7ea 100644 --- a/tests/FSharp.ApiDocs.Tests/files/crefLib2/crefLib2.fsproj +++ b/tests/FSharp.ApiDocs.Tests/files/crefLib2/crefLib2.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 ..\bin\$(Configuration) diff --git a/tests/FSharp.ApiDocs.Tests/files/crefLib3/crefLib3.csproj b/tests/FSharp.ApiDocs.Tests/files/crefLib3/crefLib3.csproj index 1a4e7e06d..6ea53cbcc 100644 --- a/tests/FSharp.ApiDocs.Tests/files/crefLib3/crefLib3.csproj +++ b/tests/FSharp.ApiDocs.Tests/files/crefLib3/crefLib3.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 false ..\bin\$(Configuration) CS0067;CS1591;CS1574 diff --git a/tests/FSharp.ApiDocs.Tests/files/crefLib4/crefLib4.csproj b/tests/FSharp.ApiDocs.Tests/files/crefLib4/crefLib4.csproj index 54d4eef28..2f1d83b92 100644 --- a/tests/FSharp.ApiDocs.Tests/files/crefLib4/crefLib4.csproj +++ b/tests/FSharp.ApiDocs.Tests/files/crefLib4/crefLib4.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 false ..\bin\$(Configuration) CS0067;CS1591;CS1574 diff --git a/tests/FSharp.ApiDocs.Tests/files/csharpSupport/csharpSupport.csproj b/tests/FSharp.ApiDocs.Tests/files/csharpSupport/csharpSupport.csproj index 1a4e7e06d..6ea53cbcc 100644 --- a/tests/FSharp.ApiDocs.Tests/files/csharpSupport/csharpSupport.csproj +++ b/tests/FSharp.ApiDocs.Tests/files/csharpSupport/csharpSupport.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 false ..\bin\$(Configuration) CS0067;CS1591;CS1574 diff --git a/tests/FSharp.Formatting.TestHelpers/FSharp.Formatting.TestHelpers.fsproj b/tests/FSharp.Formatting.TestHelpers/FSharp.Formatting.TestHelpers.fsproj index 6d535f745..eedfc6509 100644 --- a/tests/FSharp.Formatting.TestHelpers/FSharp.Formatting.TestHelpers.fsproj +++ b/tests/FSharp.Formatting.TestHelpers/FSharp.Formatting.TestHelpers.fsproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 From 3f9b61f8e1a8820eb28a4b4c8b1763ee27a60adb Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Sun, 3 Dec 2023 22:28:21 +0100 Subject: [PATCH 2/5] adjusting code again using compat layer in FSharp.Formatting.Common.Utils, make do for Path.GetRelativePath --- src/FSharp.Formatting.ApiDocs/GenerateHtml.fs | 1 + src/FSharp.Formatting.ApiDocs/GenerateModel.fs | 1 + .../FSharp.Formatting.Common.fsproj | 1 + src/FSharp.Formatting.Common/PynbModel.fs | 1 + src/FSharp.Formatting.Common/Templating.fs | 3 ++- src/FSharp.Formatting.Common/Utils.fs | 8 ++++++++ .../FSharp.Formatting.Literate.fsproj | 2 +- src/FSharp.Formatting.Literate/Formatting.fs | 15 +++++++++++++-- src/FSharp.Formatting.Markdown/MarkdownParser.fs | 2 +- 9 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/FSharp.Formatting.Common/Utils.fs diff --git a/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs b/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs index f6176fb68..44fa2595a 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs @@ -5,6 +5,7 @@ open System.Collections.Generic open System.IO open System.Web open FSharp.Formatting.Common +open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 open FSharp.Compiler.Symbols open FSharp.Formatting.Templating open FSharp.Formatting.HtmlModel diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index 5a8eaa593..8d09c10f9 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -13,6 +13,7 @@ open FSharp.Compiler.Symbols open FSharp.Compiler.Text open FSharp.Compiler.Text.Range open FSharp.Formatting.Common +open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 open FSharp.Formatting.Internal open FSharp.Formatting.CodeFormat open FSharp.Formatting.Literate diff --git a/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj b/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj index cd306f3ea..92db79ba7 100644 --- a/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj +++ b/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj @@ -7,6 +7,7 @@ FS0025;FS1182;$(WarningsAsErrors) + diff --git a/src/FSharp.Formatting.Common/PynbModel.fs b/src/FSharp.Formatting.Common/PynbModel.fs index 3afd8cefb..37b54c958 100644 --- a/src/FSharp.Formatting.Common/PynbModel.fs +++ b/src/FSharp.Formatting.Common/PynbModel.fs @@ -1,5 +1,6 @@ module internal FSharp.Formatting.PynbModel +open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 open System.Web let escapeAndQuote (txt: string) = diff --git a/src/FSharp.Formatting.Common/Templating.fs b/src/FSharp.Formatting.Common/Templating.fs index 2656c7b40..803214a8a 100644 --- a/src/FSharp.Formatting.Common/Templating.fs +++ b/src/FSharp.Formatting.Common/Templating.fs @@ -4,6 +4,7 @@ open System open System.Collections.Generic open System.IO open System.Text +open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 /// /// A parameter key @@ -50,7 +51,7 @@ type FrontMatterFile = isBlankLine || line.Contains(":")) |> Seq.filter (String.IsNullOrWhiteSpace >> not) |> Seq.map (fun line -> - let parts = line.Split(":") + let parts = line.Split ':' parts.[0].ToLowerInvariant(), parts.[1]) |> Map.ofSeq diff --git a/src/FSharp.Formatting.Common/Utils.fs b/src/FSharp.Formatting.Common/Utils.fs new file mode 100644 index 000000000..36a1cd258 --- /dev/null +++ b/src/FSharp.Formatting.Common/Utils.fs @@ -0,0 +1,8 @@ +module FSharp.Formatting.Common.Utils +#if NETSTANDARD_2_1_OR_GREATER +#else +type System.String with + member x.StartsWith(c: char) = string c |> x.StartsWith + member x.EndsWith(c: char) = string c |> x.EndsWith + member x.Contains(c: char) = string c |> x.Contains +#endif diff --git a/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj b/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj index 8a9c05ff4..b6fa230ac 100644 --- a/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj +++ b/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;netstandard2.1 true diff --git a/src/FSharp.Formatting.Literate/Formatting.fs b/src/FSharp.Formatting.Literate/Formatting.fs index bb7083467..cff0e9d52 100644 --- a/src/FSharp.Formatting.Literate/Formatting.fs +++ b/src/FSharp.Formatting.Literate/Formatting.fs @@ -150,8 +150,19 @@ module internal Formatting = let relativeSourceFileName = match doc.RootInputFolder with | None -> Path.GetFileName(doc.SourceFile) - | Some rootInputFolder -> Path.GetRelativePath(rootInputFolder, doc.SourceFile) - + | Some rootInputFolder -> +#if NETSTANDARD2_1_OR_GREATER + Path.GetRelativePath(rootInputFolder, doc.SourceFile) +#else + if + doc.SourceFile.StartsWith(rootInputFolder + string Path.DirectorySeparatorChar) + || doc.SourceFile.StartsWith(rootInputFolder + "/") + || doc.SourceFile.StartsWith(rootInputFolder + "\\") + then + doc.SourceFile.Substring(rootInputFolder.Length + 1) + else + failwith $"need to make {doc.SourceFile} relative to {rootInputFolder}" +#endif let relativeSourceFileBaseName = Path.ChangeExtension(relativeSourceFileName, null) let relativeSourceFileName = relativeSourceFileName.Replace(@"\", "/") diff --git a/src/FSharp.Formatting.Markdown/MarkdownParser.fs b/src/FSharp.Formatting.Markdown/MarkdownParser.fs index 739e95674..0c5ef249d 100644 --- a/src/FSharp.Formatting.Markdown/MarkdownParser.fs +++ b/src/FSharp.Formatting.Markdown/MarkdownParser.fs @@ -12,7 +12,7 @@ open System.Text.RegularExpressions open FSharp.Patterns open FSharp.Collections open FSharp.Formatting.Common - +open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 // -------------------------------------------------------------------------------------- // Parsing of Markdown - first part handles inline formatting // -------------------------------------------------------------------------------------- From f02d90c52cae6bb9e8e1b916fb4aaaef2bba13a8 Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Tue, 5 Dec 2023 01:37:11 +0100 Subject: [PATCH 3/5] adjust for analyzers and reformat --- src/FSharp.Formatting.Common/Utils.fs | 10 +++++++--- src/FSharp.Formatting.Literate/Formatting.fs | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/FSharp.Formatting.Common/Utils.fs b/src/FSharp.Formatting.Common/Utils.fs index 36a1cd258..9e7154554 100644 --- a/src/FSharp.Formatting.Common/Utils.fs +++ b/src/FSharp.Formatting.Common/Utils.fs @@ -2,7 +2,11 @@ module FSharp.Formatting.Common.Utils #if NETSTANDARD_2_1_OR_GREATER #else type System.String with - member x.StartsWith(c: char) = string c |> x.StartsWith - member x.EndsWith(c: char) = string c |> x.EndsWith - member x.Contains(c: char) = string c |> x.Contains + member x.StartsWith c = + x.StartsWith(string c, false, System.Globalization.CultureInfo.InvariantCulture) + + member x.EndsWith c = + x.EndsWith(string c, false, System.Globalization.CultureInfo.InvariantCulture) + + member x.Contains c = x.Contains(string c) #endif diff --git a/src/FSharp.Formatting.Literate/Formatting.fs b/src/FSharp.Formatting.Literate/Formatting.fs index cff0e9d52..efb06bbab 100644 --- a/src/FSharp.Formatting.Literate/Formatting.fs +++ b/src/FSharp.Formatting.Literate/Formatting.fs @@ -155,9 +155,21 @@ module internal Formatting = Path.GetRelativePath(rootInputFolder, doc.SourceFile) #else if - doc.SourceFile.StartsWith(rootInputFolder + string Path.DirectorySeparatorChar) - || doc.SourceFile.StartsWith(rootInputFolder + "/") - || doc.SourceFile.StartsWith(rootInputFolder + "\\") + doc.SourceFile.StartsWith( + rootInputFolder + string Path.DirectorySeparatorChar, + false, + System.Globalization.CultureInfo.InvariantCulture + ) + || doc.SourceFile.StartsWith( + rootInputFolder + "/", + false, + System.Globalization.CultureInfo.InvariantCulture + ) + || doc.SourceFile.StartsWith( + rootInputFolder + "\\", + false, + System.Globalization.CultureInfo.InvariantCulture + ) then doc.SourceFile.Substring(rootInputFolder.Length + 1) else From fe490f46cdb2213878cfa1af2ee11d08dda8d4fb Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Wed, 6 Dec 2023 00:20:38 +0100 Subject: [PATCH 4/5] adjustments, wrapping the open .Utils under #if. --- src/FSharp.Formatting.ApiDocs/GenerateHtml.fs | 3 +++ src/FSharp.Formatting.ApiDocs/GenerateModel.fs | 3 +++ src/FSharp.Formatting.Common/PynbModel.fs | 3 +++ src/FSharp.Formatting.Common/Utils.fs | 9 +++++---- src/FSharp.Formatting.Literate/Formatting.fs | 15 +++------------ src/FSharp.Formatting.Markdown/MarkdownParser.fs | 3 +++ 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs b/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs index 44fa2595a..ddb6ab7f4 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs @@ -5,7 +5,10 @@ open System.Collections.Generic open System.IO open System.Web open FSharp.Formatting.Common +#if NETSTANDARD2_1_OR_GREATER +#else open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 +#endif open FSharp.Compiler.Symbols open FSharp.Formatting.Templating open FSharp.Formatting.HtmlModel diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index 8d09c10f9..5c5586512 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -13,7 +13,10 @@ open FSharp.Compiler.Symbols open FSharp.Compiler.Text open FSharp.Compiler.Text.Range open FSharp.Formatting.Common +#if NETSTANDARD2_1_OR_GREATER +#else open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 +#endif open FSharp.Formatting.Internal open FSharp.Formatting.CodeFormat open FSharp.Formatting.Literate diff --git a/src/FSharp.Formatting.Common/PynbModel.fs b/src/FSharp.Formatting.Common/PynbModel.fs index 37b54c958..2f7137882 100644 --- a/src/FSharp.Formatting.Common/PynbModel.fs +++ b/src/FSharp.Formatting.Common/PynbModel.fs @@ -1,6 +1,9 @@ module internal FSharp.Formatting.PynbModel +#if NETSTANDARD2_1_OR_GREATER +#else open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 +#endif open System.Web let escapeAndQuote (txt: string) = diff --git a/src/FSharp.Formatting.Common/Utils.fs b/src/FSharp.Formatting.Common/Utils.fs index 9e7154554..8501c4da3 100644 --- a/src/FSharp.Formatting.Common/Utils.fs +++ b/src/FSharp.Formatting.Common/Utils.fs @@ -1,12 +1,13 @@ module FSharp.Formatting.Common.Utils #if NETSTANDARD_2_1_OR_GREATER #else -type System.String with - member x.StartsWith c = - x.StartsWith(string c, false, System.Globalization.CultureInfo.InvariantCulture) +open System + +type String with + member x.StartsWith c = x.StartsWith(string c) member x.EndsWith c = - x.EndsWith(string c, false, System.Globalization.CultureInfo.InvariantCulture) + x.EndsWith(string c, StringComparison.Ordinal) member x.Contains c = x.Contains(string c) #endif diff --git a/src/FSharp.Formatting.Literate/Formatting.fs b/src/FSharp.Formatting.Literate/Formatting.fs index efb06bbab..a9cb9413c 100644 --- a/src/FSharp.Formatting.Literate/Formatting.fs +++ b/src/FSharp.Formatting.Literate/Formatting.fs @@ -157,19 +157,10 @@ module internal Formatting = if doc.SourceFile.StartsWith( rootInputFolder + string Path.DirectorySeparatorChar, - false, - System.Globalization.CultureInfo.InvariantCulture - ) - || doc.SourceFile.StartsWith( - rootInputFolder + "/", - false, - System.Globalization.CultureInfo.InvariantCulture - ) - || doc.SourceFile.StartsWith( - rootInputFolder + "\\", - false, - System.Globalization.CultureInfo.InvariantCulture + StringComparison.Ordinal ) + || doc.SourceFile.StartsWith(rootInputFolder + "/", StringComparison.Ordinal) + || doc.SourceFile.StartsWith(rootInputFolder + "\\", StringComparison.Ordinal) then doc.SourceFile.Substring(rootInputFolder.Length + 1) else diff --git a/src/FSharp.Formatting.Markdown/MarkdownParser.fs b/src/FSharp.Formatting.Markdown/MarkdownParser.fs index 0c5ef249d..ed9614b35 100644 --- a/src/FSharp.Formatting.Markdown/MarkdownParser.fs +++ b/src/FSharp.Formatting.Markdown/MarkdownParser.fs @@ -12,7 +12,10 @@ open System.Text.RegularExpressions open FSharp.Patterns open FSharp.Collections open FSharp.Formatting.Common +#if NETSTANDARD2_1_OR_GREATER +#else open FSharp.Formatting.Common.Utils // compat layer for netstandard2.0 +#endif // -------------------------------------------------------------------------------------- // Parsing of Markdown - first part handles inline formatting // -------------------------------------------------------------------------------------- From 679c26648627f90b271b1beda4c220520659dc66 Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Thu, 7 Dec 2023 20:13:07 +0100 Subject: [PATCH 5/5] fix for analyzers --- src/FSharp.Formatting.Common/Utils.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Formatting.Common/Utils.fs b/src/FSharp.Formatting.Common/Utils.fs index 8501c4da3..f467ecdac 100644 --- a/src/FSharp.Formatting.Common/Utils.fs +++ b/src/FSharp.Formatting.Common/Utils.fs @@ -4,7 +4,7 @@ module FSharp.Formatting.Common.Utils open System type String with - member x.StartsWith c = x.StartsWith(string c) + member x.StartsWith c = x.StartsWith(string c, StringComparison.Ordinal) member x.EndsWith c = x.EndsWith(string c, StringComparison.Ordinal)