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.ApiDocs/GenerateHtml.fs b/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs index f6176fb68..ddb6ab7f4 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs @@ -5,6 +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 5a8eaa593..5c5586512 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -13,6 +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.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..92db79ba7 100644 --- a/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj +++ b/src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj @@ -1,12 +1,13 @@  - netstandard2.1 + netstandard2.0 TRACE;YAAF_FSHARP_SCRIPTING_PUBLIC true FS0025;FS1182;$(WarningsAsErrors) + diff --git a/src/FSharp.Formatting.Common/PynbModel.fs b/src/FSharp.Formatting.Common/PynbModel.fs index 3afd8cefb..2f7137882 100644 --- a/src/FSharp.Formatting.Common/PynbModel.fs +++ b/src/FSharp.Formatting.Common/PynbModel.fs @@ -1,5 +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/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..f467ecdac --- /dev/null +++ b/src/FSharp.Formatting.Common/Utils.fs @@ -0,0 +1,13 @@ +module FSharp.Formatting.Common.Utils +#if NETSTANDARD_2_1_OR_GREATER +#else +open System + +type String with + member x.StartsWith c = x.StartsWith(string c, StringComparison.Ordinal) + + member x.EndsWith c = + x.EndsWith(string c, StringComparison.Ordinal) + + member x.Contains c = x.Contains(string c) +#endif diff --git a/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj b/src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj index 25e193476..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.1 + netstandard2.0;netstandard2.1 true diff --git a/src/FSharp.Formatting.Literate/Formatting.fs b/src/FSharp.Formatting.Literate/Formatting.fs index bb7083467..a9cb9413c 100644 --- a/src/FSharp.Formatting.Literate/Formatting.fs +++ b/src/FSharp.Formatting.Literate/Formatting.fs @@ -150,8 +150,22 @@ 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, + StringComparison.Ordinal + ) + || doc.SourceFile.StartsWith(rootInputFolder + "/", StringComparison.Ordinal) + || doc.SourceFile.StartsWith(rootInputFolder + "\\", StringComparison.Ordinal) + 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/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.Markdown/MarkdownParser.fs b/src/FSharp.Formatting.Markdown/MarkdownParser.fs index 739e95674..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 // -------------------------------------------------------------------------------------- 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