Skip to content

Commit c92b005

Browse files
dsymeDon Syme
and
Don Syme
authored
update FCS, allow fsdocs to roll forward to net5.0 (#621)
* roll forward to net5 * roll forward SDK * remove global.json * remove debug code * debug code * right script location * update matrix * update to 38.0.2 * fix build * fix tests on 5.0 * fix tests on 5.0 * fix tests * fix tests on 5.0 * fix tests on 5.0 Co-authored-by: Don Syme <[email protected]>
1 parent 34814bf commit c92b005

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+658
-371
lines changed

.github/workflows/pull-requests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: [ubuntu-latest, windows-latest]
15-
dotnet: [3.1.302]
15+
dotnet: [3.1.302, 5.0.100]
1616
runs-on: ${{ matrix.os }}
1717

1818
steps:

docs/apidocs.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** condition: prepare ***)
22
#nowarn "211"
3-
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
3+
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
44
#r "FSharp.Formatting.Common.dll"
55
#r "FSharp.Formatting.Markdown.dll"
66
#r "FSharp.Formatting.CodeFormat.dll"

docs/codeformat.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** condition: prepare ***)
22
#nowarn "211"
3-
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
3+
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
44
#r "FSharp.Formatting.Common.dll"
55
#r "FSharp.Formatting.Markdown.dll"
66
#r "FSharp.Formatting.CodeFormat.dll"

docs/content.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** condition: prepare ***)
22
#nowarn "211"
3-
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
3+
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
44
#r "FSharp.Formatting.Common.dll"
55
#r "FSharp.Formatting.Markdown.dll"
66
#r "FSharp.Formatting.CodeFormat.dll"

docs/evaluation.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** condition: prepare ***)
22
#nowarn "211"
3-
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
3+
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
44
#r "FSharp.Formatting.Common.dll"
55
#r "FSharp.Formatting.Markdown.dll"
66
#r "FSharp.Formatting.CodeFormat.dll"

docs/literate.fsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** condition: prepare ***)
22
#nowarn "211"
3-
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
3+
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
44
#r "FSharp.Formatting.Common.dll"
55
#r "FSharp.Formatting.Markdown.dll"
66
#r "FSharp.Formatting.CodeFormat.dll"
@@ -177,7 +177,7 @@ A header may be needed to get the code to load, a typical example is this:
177177
178178
(*** condition: prepare ***)
179179
#nowarn "211"
180-
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
180+
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
181181
#r "FSharp.Formatting.Common.dll"
182182
#r "FSharp.Formatting.Markdown.dll"
183183
#r "FSharp.Formatting.CodeFormat.dll"

docs/markdown.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** condition: prepare ***)
2-
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
2+
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
33
#r "FSharp.Formatting.Common.dll"
44
#r "FSharp.Formatting.Markdown.dll"
55
(*** condition: fsx ***)

global.json

-6
This file was deleted.

paket.dependencies

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
version 5.249.0
22
source https://api.nuget.org/v3/index.json
3+
source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
34
framework: auto-detect
45
storage: none
56

67
nuget FSharp.Core >= 4.7 lowest_matching:true
7-
nuget FSharp.Compiler.Service ~> 36.0
8+
nuget FSharp.Compiler.Service 38.0.2
89
nuget CommandLineParser ~> 2.8
10+
nuget Microsoft.Build.Framework
11+
nuget Microsoft.Build.Tasks.Core
12+
nuget Microsoft.Build.Utilities.Core
913
nuget Dotnet.ProjInfo
1014
nuget Dotnet.ProjInfo.Workspace
1115
nuget Newtonsoft.Json
@@ -31,6 +35,7 @@ group Fake
3135
source https://api.nuget.org/v3/index.json
3236
storage: none
3337

38+
nuget FSharp.Core ~> 4.7
3439
nuget Fake.Core.Target ~> 5.20.0
3540
nuget Fake.Core.ReleaseNotes ~> 5.20.0
3641
nuget Fake.DotNet.AssemblyInfoFile ~> 5.20.0

paket.lock

+565-308
Large diffs are not rendered by default.

src/FSharp.Formatting.ApiDocs/FSharp.Formatting.ApiDocs.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
</PropertyGroup>
66
<ItemGroup>
77
<None Include="paket.references" />

src/FSharp.Formatting.CSharpFormat/FSharp.Formatting.CSharpFormat.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<UsesMarkdownComments>true</UsesMarkdownComments>
66
</PropertyGroup>
77
<ItemGroup>

src/FSharp.Formatting.CodeFormat/CodeFormatAgent.fs

+25-5
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,37 @@ type CodeFormatAgent() =
117117
| SemanticClassificationType.Enumeration -> Some TokenKind.Enumeration
118118
| SemanticClassificationType.Function -> Some TokenKind.Function
119119
| SemanticClassificationType.Interface -> Some TokenKind.Interface
120+
| SemanticClassificationType.Delegate -> Some TokenKind.ReferenceType
121+
| SemanticClassificationType.DisposableLocalValue -> Some TokenKind.Disposable
122+
| SemanticClassificationType.DisposableTopLevelValue -> Some TokenKind.Disposable
123+
| SemanticClassificationType.DisposableType -> Some TokenKind.Disposable
124+
| SemanticClassificationType.Event -> Some TokenKind.Property
125+
| SemanticClassificationType.Exception -> Some TokenKind.ReferenceType
126+
| SemanticClassificationType.ExtensionMethod -> Some TokenKind.Function
127+
| SemanticClassificationType.Field -> Some TokenKind.Property
128+
| SemanticClassificationType.Literal -> Some TokenKind.Property
129+
| SemanticClassificationType.LocalValue -> Some TokenKind.Function
130+
| SemanticClassificationType.Method -> Some TokenKind.Function
131+
| SemanticClassificationType.MutableRecordField -> Some TokenKind.Property
132+
| SemanticClassificationType.NamedArgument -> Some TokenKind.Function
133+
| SemanticClassificationType.Namespace -> Some TokenKind.Identifier
134+
| SemanticClassificationType.Plaintext -> Some TokenKind.Punctuation
135+
| SemanticClassificationType.RecordField -> Some TokenKind.Property
136+
| SemanticClassificationType.RecordFieldAsFunction -> Some TokenKind.Function
137+
| SemanticClassificationType.Type -> Some TokenKind.ReferenceType
138+
| SemanticClassificationType.TypeDef -> Some TokenKind.ReferenceType
139+
| SemanticClassificationType.UnionCaseField -> Some TokenKind.Property
140+
| SemanticClassificationType.Value -> Some TokenKind.Identifier
120141
| SemanticClassificationType.Module -> Some TokenKind.Module
121142
| SemanticClassificationType.MutableVar -> Some TokenKind.MutableVar
122143
| SemanticClassificationType.Printf -> Some TokenKind.Printf
123144
| SemanticClassificationType.Property -> Some TokenKind.Property
124145
| SemanticClassificationType.ReferenceType -> Some TokenKind.ReferenceType
125146
| SemanticClassificationType.UnionCase -> Some TokenKind.UnionCase
126147
| SemanticClassificationType.ValueType -> Some TokenKind.ValueType
127-
| SemanticClassificationType.Disposable -> Some TokenKind.Disposable
128148
| SemanticClassificationType.ComputationExpression -> Some TokenKind.Keyword
149+
| SemanticClassificationType.ConstructorForReferenceType -> Some TokenKind.Function
150+
| SemanticClassificationType.ConstructorForValueType -> Some TokenKind.Function
129151
| SemanticClassificationType.TypeArgument -> Some TokenKind.TypeArgument
130152
| SemanticClassificationType.Operator -> Some TokenKind.Operator
131153
| SemanticClassificationType.IntrinsicFunction -> Some TokenKind.Keyword
@@ -178,9 +200,7 @@ type CodeFormatAgent() =
178200
if (token.TokenName = "IDENT") then
179201
let island = List.rev island
180202
let tip = checkResults.GetToolTipText(line + 1, token.LeftColumn + 1, lines.[line], island,FSharpTokenTag.IDENT)
181-
match Async.RunSynchronously tip |> fun (tooltip) ->
182-
//tooltip.
183-
ToolTipReader.tryFormatTip tooltip with
203+
match tip |> Async.RunSynchronously |> ToolTipReader.tryFormatTip with
184204
| Some(_) as res -> res
185205
| _ -> None
186206
else None
@@ -371,7 +391,7 @@ type CodeFormatAgent() =
371391
match res with
372392
| Some (_parseResults, parsedInput, checkResults) ->
373393
Log.verbf "starting to GetAllUsesOfAllSymbolsInFile from '%s'" filePath
374-
let! _symbolUses = checkResults.GetAllUsesOfAllSymbolsInFile ()
394+
let _symbolUses = checkResults.GetAllUsesOfAllSymbolsInFile ()
375395
let errors = checkResults.Errors
376396
let classifications =
377397
checkResults.GetSemanticClassification (Some parsedInput.Range)

src/FSharp.Formatting.CodeFormat/FSharp.Formatting.CodeFormat.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<UsesMarkdownComments>true</UsesMarkdownComments>
66
</PropertyGroup>
77
<ItemGroup>

src/FSharp.Formatting.CodeFormat/HtmlFormatting.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ let formatToolTipSpans spans =
9696
/// Format token spans such as tokens, omitted code etc.
9797
let rec formatTokenSpans (ctx:FormattingContext) = List.iter (function
9898
| TokenSpan.Error(_kind, message, body) when ctx.GenerateErrors ->
99-
let tip = ToolTipReader.formatMultilineString (message.Trim())
99+
let tip = ToolTipReader.formatMultilineString (message.Trim().Split('\n'))
100100
let tipAttributes = ctx.FormatTip tip true formatToolTipSpans
101101
ctx.Writer.Write("<span ")
102102
ctx.Writer.Write(tipAttributes)
@@ -113,7 +113,7 @@ let rec formatTokenSpans (ctx:FormattingContext) = List.iter (function
113113
ctx.Writer.Write("</span>")
114114

115115
| TokenSpan.Omitted(body, hidden) ->
116-
let tip = ToolTipReader.formatMultilineString (hidden.Trim())
116+
let tip = ToolTipReader.formatMultilineString (hidden.Trim().Split('\n'))
117117
let tipAttributes = ctx.FormatTip tip true formatToolTipSpans
118118
ctx.Writer.Write("<span ")
119119
ctx.Writer.Write(tipAttributes)

src/FSharp.Formatting.CodeFormat/ToolTipReader.fs

+9-7
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ open FSharp.Compiler.SourceCodeServices
1919
// --------------------------------------------------------------------------------------
2020

2121
/// Turn string into a sequence of lines interleaved with line breaks
22-
let formatMultilineString (s:string) =
23-
[ for line in s.Split('\n') do
22+
let formatMultilineString (lines:string[]) =
23+
[ for line in lines do
2424
yield HardLineBreak
2525
yield Literal line ]
2626
|> List.tail
2727

2828
/// Format comment in the tool tip
29-
let private formatComment = function
30-
| FSharpXmlDoc.Text(s) ->
31-
[ Emphasis (formatMultilineString s)
29+
let private formatComment xmlDoc =
30+
match xmlDoc with
31+
| FSharpXmlDoc.Text(unprocessedLines, _processedLines) ->
32+
[ Emphasis (formatMultilineString unprocessedLines)
3233
HardLineBreak ]
3334
| _ ->
3435
// TODO: For 'XmlCommentSignature' we could get documentation
3536
// from 'xml' files, but we don't know where to get them...
3637
[]
3738

3839
/// Format the element of a tool tip (comment, overloads, etc.)
39-
let private formatElement = function
40+
let private formatElement tooltip =
41+
match tooltip with
4042
| FSharpToolTipElement.None -> []
4143
//| FSharpToolTipElement.(it, comment) ->
4244
// [ yield! formatMultilineString it
@@ -48,7 +50,7 @@ let private formatElement = function
4850
if items.Length <= 10 then items, false
4951
else items |> Seq.take 10 |> List.ofSeq, true
5052
[ for it in items do
51-
yield! formatMultilineString it.MainDescription
53+
yield! formatMultilineString (it.MainDescription.Split('\n'))
5254
yield HardLineBreak
5355
yield! formatComment it.XmlDoc
5456

src/FSharp.Formatting.CommandTool/FSharp.Formatting.CommandTool.fsproj

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<AssemblyName>fsdocs</AssemblyName>
66
<TargetFramework>netcoreapp3.1</TargetFramework>
77
<PackageId>FSharp.Formatting.CommandTool</PackageId>
8+
<RollForward>LatestMajor</RollForward>
89
<IsPackable>true</IsPackable>
910
<PackAsTool>true</PackAsTool>
1011
<UsesMarkdownComments>true</UsesMarkdownComments>

src/FSharp.Formatting.Common/FSharp.Formatting.Common.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0; netstandard2.1</TargetFrameworks>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<DefineConstants>TRACE;YAAF_FSHARP_SCRIPTING_PUBLIC</DefineConstants>
66
<UsesMarkdownComments>true</UsesMarkdownComments>
77
</PropertyGroup>

src/FSharp.Formatting.Common/YaafFSharpScripting.fs

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ open System
44
open System.IO
55
open System.Text
66
open System.Reflection
7+
open System.Reflection.Emit
78
open System.Diagnostics
89
open System.Runtime.CompilerServices
910
open FSharp.Compiler.Interactive.Shell
@@ -27,7 +28,7 @@ module internal Env =
2728
let (=?) s1 s2 = System.String.Equals(s1, s2, System.StringComparison.OrdinalIgnoreCase)
2829
let (<>?) s1 s2 = not (s1 =? s2)
2930

30-
let isNetCoreApp = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET Core")
31+
let isNetCoreApp = true
3132

3233
open Env
3334
module internal Log =
@@ -62,6 +63,9 @@ module internal CompilerServiceExtensions =
6263

6364
let getNetCoreAppFrameworkDependencies = lazy(
6465
let options, _ = checker.GetProjectOptionsFromScript("foo.fsx", SourceText.ofString "module Foo", assumeDotNetFramework = false) |> Async.RunSynchronously
66+
printfn "isNetCoreApp = %b" isNetCoreApp
67+
//for r in options.OtherOptions do
68+
// printfn "option: %s" r
6569

6670
options.OtherOptions
6771
|> Array.filter (fun path -> path.StartsWith "-r:")
@@ -124,9 +128,6 @@ module internal CompilerServiceExtensions =
124128
if not suppressFSharpCore then
125129
yield r
126130

127-
if fsCoreLib.IsSome then
128-
yield sprintf "-r:%s" fsCoreLib.Value
129-
130131
yield "--out:" + dllName
131132
yield "--doc:" + xmlName
132133
yield "--warn:3"
@@ -137,10 +138,15 @@ module internal CompilerServiceExtensions =
137138
yield "-r:"+dllFile
138139
for libDir in libDirs do
139140
yield "-I:"+libDir
141+
if fsCoreLib.IsSome then
142+
yield sprintf "-r:%s" fsCoreLib.Value
143+
140144
yield! otherFlags
141145
yield fileName1
142146
|]
143147

148+
for arg in args do
149+
printfn "arg: %s" arg
144150
projFileName, args
145151

146152
let getProjectReferences frameworkVersion otherFlags libDirs dllFiles =
@@ -1011,7 +1017,7 @@ type internal FsiSession (fsi: obj, options: FsiOptions, reportGlobal, liveOut,
10111017
// Try to get the AssemblyBuilder
10121018
member x.DynamicAssemblyBuilder =
10131019
match x.DynamicAssembly with
1014-
| :? System.Reflection.Emit.AssemblyBuilder as builder -> builder
1020+
| :? AssemblyBuilder as builder -> builder
10151021
| _ -> failwith "The DynamicAssembly property is no AssemblyBuilder!"
10161022

10171023
type internal ScriptHost() =
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
FSharp.Core
22
FSharp.Compiler.Service
3-
System.Memory framework: netstandard2.0
3+
Microsoft.Build.Framework
4+
Microsoft.Build.Tasks.Core
5+
Microsoft.Build.Utilities.Core

src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<IsPackable>true</IsPackable>
66
</PropertyGroup>
77
<ItemGroup>

src/FSharp.Formatting.Literate/Formatting.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module internal Formatting =
6767
yield line ]
6868
|> String.concat "\n"
6969

70-
let transformDocument (doc: LiterateDocument) outputPath ctx =
70+
let transformDocument (doc: LiterateDocument) (outputPath: string) ctx =
7171

7272
// If we want to include the source code of the script, then process
7373
// the entire source and generate replacement {source} => ...some html...

src/FSharp.Formatting.Literate/Transformations.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module internal Transformations =
4343
/// (The dictionary argument is a map from original code snippets to formatted HTML snippets.)
4444
///
4545
/// Note: this processes snipppets within markdown, not snippets coming from .fsx
46-
let rec replaceCodeSnippets path (codeLookup:IDictionary<_, _>) para =
46+
let rec replaceCodeSnippets (path: string) (codeLookup:IDictionary<_, _>) para =
4747
match para with
4848
| CodeBlock (code, _executionCount, language, _, range) ->
4949
match code with
@@ -87,7 +87,7 @@ module internal Transformations =
8787
/// their formatted representation (of `LiterateParagraph` type)
8888
///
8989
/// Note: this processes snipppets within markdown, not snippets coming from .fsx
90-
let formatCodeSnippets path (ctx: CompilerContext) (doc:LiterateDocument) =
90+
let formatCodeSnippets (path: string) (ctx: CompilerContext) (doc:LiterateDocument) =
9191
let name = Path.GetFileNameWithoutExtension(path)
9292

9393
// Extract all CodeBlocks and pass them to F# snippets

src/FSharp.Formatting.Markdown/FSharp.Formatting.Markdown.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<UsesMarkdownComments>true</UsesMarkdownComments>
66
</PropertyGroup>
77
<ItemGroup>

src/FSharp.Formatting/FSharp.Formatting.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
3+
<TargetFramework>netstandard2.1</TargetFramework>
44
<IsPackable>true</IsPackable>
55
<UsesMarkdownComments>true</UsesMarkdownComments>
66
</PropertyGroup>

src/FSharp.Formatting/FSharp.Formatting.fsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#nowarn "211"
22

33
// FSharp.Formatting repo context: uncomment for intellisense
4-
//#I "bin/Release/netstandard2.0"
4+
//#I "bin/Release/netstandard2.1"
55

66
// Standard NuGet or Paket location
77
#I __SOURCE_DIRECTORY__
8-
#I "lib/netstandard2.0"
8+
#I "lib/netstandard2.1"
99

1010
// Standard Paket locations
1111
#I "../FSharp.Compiler.Service/lib/netstandard2.0"

0 commit comments

Comments
 (0)