Skip to content

Commit

Permalink
update FCS, allow fsdocs to roll forward to net5.0 (#621)
Browse files Browse the repository at this point in the history
* 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 <donsyme@fastmail.com>
  • Loading branch information
dsyme and Don Syme authored Jan 11, 2021
1 parent 34814bf commit c92b005
Show file tree
Hide file tree
Showing 42 changed files with 658 additions and 371 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
dotnet: [3.1.302]
dotnet: [3.1.302, 5.0.100]
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion docs/apidocs.fsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(*** condition: prepare ***)
#nowarn "211"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
#r "FSharp.Formatting.Common.dll"
#r "FSharp.Formatting.Markdown.dll"
#r "FSharp.Formatting.CodeFormat.dll"
Expand Down
2 changes: 1 addition & 1 deletion docs/codeformat.fsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(*** condition: prepare ***)
#nowarn "211"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
#r "FSharp.Formatting.Common.dll"
#r "FSharp.Formatting.Markdown.dll"
#r "FSharp.Formatting.CodeFormat.dll"
Expand Down
2 changes: 1 addition & 1 deletion docs/content.fsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(*** condition: prepare ***)
#nowarn "211"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
#r "FSharp.Formatting.Common.dll"
#r "FSharp.Formatting.Markdown.dll"
#r "FSharp.Formatting.CodeFormat.dll"
Expand Down
2 changes: 1 addition & 1 deletion docs/evaluation.fsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(*** condition: prepare ***)
#nowarn "211"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
#r "FSharp.Formatting.Common.dll"
#r "FSharp.Formatting.Markdown.dll"
#r "FSharp.Formatting.CodeFormat.dll"
Expand Down
4 changes: 2 additions & 2 deletions docs/literate.fsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(*** condition: prepare ***)
#nowarn "211"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
#r "FSharp.Formatting.Common.dll"
#r "FSharp.Formatting.Markdown.dll"
#r "FSharp.Formatting.CodeFormat.dll"
Expand Down Expand Up @@ -177,7 +177,7 @@ A header may be needed to get the code to load, a typical example is this:
(*** condition: prepare ***)
#nowarn "211"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
#r "FSharp.Formatting.Common.dll"
#r "FSharp.Formatting.Markdown.dll"
#r "FSharp.Formatting.CodeFormat.dll"
Expand Down
2 changes: 1 addition & 1 deletion docs/markdown.fsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*** condition: prepare ***)
#I "../src/FSharp.Formatting/bin/Release/netstandard2.0"
#I "../src/FSharp.Formatting/bin/Release/netstandard2.1"
#r "FSharp.Formatting.Common.dll"
#r "FSharp.Formatting.Markdown.dll"
(*** condition: fsx ***)
Expand Down
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

7 changes: 6 additions & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
version 5.249.0
source https://api.nuget.org/v3/index.json
source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
framework: auto-detect
storage: none

nuget FSharp.Core >= 4.7 lowest_matching:true
nuget FSharp.Compiler.Service ~> 36.0
nuget FSharp.Compiler.Service 38.0.2
nuget CommandLineParser ~> 2.8
nuget Microsoft.Build.Framework
nuget Microsoft.Build.Tasks.Core
nuget Microsoft.Build.Utilities.Core
nuget Dotnet.ProjInfo
nuget Dotnet.ProjInfo.Workspace
nuget Newtonsoft.Json
Expand All @@ -31,6 +35,7 @@ group Fake
source https://api.nuget.org/v3/index.json
storage: none

nuget FSharp.Core ~> 4.7
nuget Fake.Core.Target ~> 5.20.0
nuget Fake.Core.ReleaseNotes ~> 5.20.0
nuget Fake.DotNet.AssemblyInfoFile ~> 5.20.0
Expand Down
873 changes: 565 additions & 308 deletions paket.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Include="paket.references" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<UsesMarkdownComments>true</UsesMarkdownComments>
</PropertyGroup>
<ItemGroup>
Expand Down
30 changes: 25 additions & 5 deletions src/FSharp.Formatting.CodeFormat/CodeFormatAgent.fs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,37 @@ type CodeFormatAgent() =
| SemanticClassificationType.Enumeration -> Some TokenKind.Enumeration
| SemanticClassificationType.Function -> Some TokenKind.Function
| SemanticClassificationType.Interface -> Some TokenKind.Interface
| SemanticClassificationType.Delegate -> Some TokenKind.ReferenceType
| SemanticClassificationType.DisposableLocalValue -> Some TokenKind.Disposable
| SemanticClassificationType.DisposableTopLevelValue -> Some TokenKind.Disposable
| SemanticClassificationType.DisposableType -> Some TokenKind.Disposable
| SemanticClassificationType.Event -> Some TokenKind.Property
| SemanticClassificationType.Exception -> Some TokenKind.ReferenceType
| SemanticClassificationType.ExtensionMethod -> Some TokenKind.Function
| SemanticClassificationType.Field -> Some TokenKind.Property
| SemanticClassificationType.Literal -> Some TokenKind.Property
| SemanticClassificationType.LocalValue -> Some TokenKind.Function
| SemanticClassificationType.Method -> Some TokenKind.Function
| SemanticClassificationType.MutableRecordField -> Some TokenKind.Property
| SemanticClassificationType.NamedArgument -> Some TokenKind.Function
| SemanticClassificationType.Namespace -> Some TokenKind.Identifier
| SemanticClassificationType.Plaintext -> Some TokenKind.Punctuation
| SemanticClassificationType.RecordField -> Some TokenKind.Property
| SemanticClassificationType.RecordFieldAsFunction -> Some TokenKind.Function
| SemanticClassificationType.Type -> Some TokenKind.ReferenceType
| SemanticClassificationType.TypeDef -> Some TokenKind.ReferenceType
| SemanticClassificationType.UnionCaseField -> Some TokenKind.Property
| SemanticClassificationType.Value -> Some TokenKind.Identifier
| SemanticClassificationType.Module -> Some TokenKind.Module
| SemanticClassificationType.MutableVar -> Some TokenKind.MutableVar
| SemanticClassificationType.Printf -> Some TokenKind.Printf
| SemanticClassificationType.Property -> Some TokenKind.Property
| SemanticClassificationType.ReferenceType -> Some TokenKind.ReferenceType
| SemanticClassificationType.UnionCase -> Some TokenKind.UnionCase
| SemanticClassificationType.ValueType -> Some TokenKind.ValueType
| SemanticClassificationType.Disposable -> Some TokenKind.Disposable
| SemanticClassificationType.ComputationExpression -> Some TokenKind.Keyword
| SemanticClassificationType.ConstructorForReferenceType -> Some TokenKind.Function
| SemanticClassificationType.ConstructorForValueType -> Some TokenKind.Function
| SemanticClassificationType.TypeArgument -> Some TokenKind.TypeArgument
| SemanticClassificationType.Operator -> Some TokenKind.Operator
| SemanticClassificationType.IntrinsicFunction -> Some TokenKind.Keyword
Expand Down Expand Up @@ -178,9 +200,7 @@ type CodeFormatAgent() =
if (token.TokenName = "IDENT") then
let island = List.rev island
let tip = checkResults.GetToolTipText(line + 1, token.LeftColumn + 1, lines.[line], island,FSharpTokenTag.IDENT)
match Async.RunSynchronously tip |> fun (tooltip) ->
//tooltip.
ToolTipReader.tryFormatTip tooltip with
match tip |> Async.RunSynchronously |> ToolTipReader.tryFormatTip with
| Some(_) as res -> res
| _ -> None
else None
Expand Down Expand Up @@ -371,7 +391,7 @@ type CodeFormatAgent() =
match res with
| Some (_parseResults, parsedInput, checkResults) ->
Log.verbf "starting to GetAllUsesOfAllSymbolsInFile from '%s'" filePath
let! _symbolUses = checkResults.GetAllUsesOfAllSymbolsInFile ()
let _symbolUses = checkResults.GetAllUsesOfAllSymbolsInFile ()
let errors = checkResults.Errors
let classifications =
checkResults.GetSemanticClassification (Some parsedInput.Range)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<UsesMarkdownComments>true</UsesMarkdownComments>
</PropertyGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Formatting.CodeFormat/HtmlFormatting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ let formatToolTipSpans spans =
/// Format token spans such as tokens, omitted code etc.
let rec formatTokenSpans (ctx:FormattingContext) = List.iter (function
| TokenSpan.Error(_kind, message, body) when ctx.GenerateErrors ->
let tip = ToolTipReader.formatMultilineString (message.Trim())
let tip = ToolTipReader.formatMultilineString (message.Trim().Split('\n'))
let tipAttributes = ctx.FormatTip tip true formatToolTipSpans
ctx.Writer.Write("<span ")
ctx.Writer.Write(tipAttributes)
Expand All @@ -113,7 +113,7 @@ let rec formatTokenSpans (ctx:FormattingContext) = List.iter (function
ctx.Writer.Write("</span>")

| TokenSpan.Omitted(body, hidden) ->
let tip = ToolTipReader.formatMultilineString (hidden.Trim())
let tip = ToolTipReader.formatMultilineString (hidden.Trim().Split('\n'))
let tipAttributes = ctx.FormatTip tip true formatToolTipSpans
ctx.Writer.Write("<span ")
ctx.Writer.Write(tipAttributes)
Expand Down
16 changes: 9 additions & 7 deletions src/FSharp.Formatting.CodeFormat/ToolTipReader.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@ open FSharp.Compiler.SourceCodeServices
// --------------------------------------------------------------------------------------

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

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

/// Format the element of a tool tip (comment, overloads, etc.)
let private formatElement = function
let private formatElement tooltip =
match tooltip with
| FSharpToolTipElement.None -> []
//| FSharpToolTipElement.(it, comment) ->
// [ yield! formatMultilineString it
Expand All @@ -48,7 +50,7 @@ let private formatElement = function
if items.Length <= 10 then items, false
else items |> Seq.take 10 |> List.ofSeq, true
[ for it in items do
yield! formatMultilineString it.MainDescription
yield! formatMultilineString (it.MainDescription.Split('\n'))
yield HardLineBreak
yield! formatComment it.XmlDoc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AssemblyName>fsdocs</AssemblyName>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>FSharp.Formatting.CommandTool</PackageId>
<RollForward>LatestMajor</RollForward>
<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>
<UsesMarkdownComments>true</UsesMarkdownComments>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks>netstandard2.0; netstandard2.1</TargetFrameworks>
<TargetFramework>netstandard2.1</TargetFramework>
<DefineConstants>TRACE;YAAF_FSHARP_SCRIPTING_PUBLIC</DefineConstants>
<UsesMarkdownComments>true</UsesMarkdownComments>
</PropertyGroup>
Expand Down
16 changes: 11 additions & 5 deletions src/FSharp.Formatting.Common/YaafFSharpScripting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ open System
open System.IO
open System.Text
open System.Reflection
open System.Reflection.Emit
open System.Diagnostics
open System.Runtime.CompilerServices
open FSharp.Compiler.Interactive.Shell
Expand All @@ -27,7 +28,7 @@ module internal Env =
let (=?) s1 s2 = System.String.Equals(s1, s2, System.StringComparison.OrdinalIgnoreCase)
let (<>?) s1 s2 = not (s1 =? s2)

let isNetCoreApp = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET Core")
let isNetCoreApp = true

open Env
module internal Log =
Expand Down Expand Up @@ -62,6 +63,9 @@ module internal CompilerServiceExtensions =

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

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

if fsCoreLib.IsSome then
yield sprintf "-r:%s" fsCoreLib.Value

yield "--out:" + dllName
yield "--doc:" + xmlName
yield "--warn:3"
Expand All @@ -137,10 +138,15 @@ module internal CompilerServiceExtensions =
yield "-r:"+dllFile
for libDir in libDirs do
yield "-I:"+libDir
if fsCoreLib.IsSome then
yield sprintf "-r:%s" fsCoreLib.Value

yield! otherFlags
yield fileName1
|]

for arg in args do
printfn "arg: %s" arg
projFileName, args

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

type internal ScriptHost() =
Expand Down
4 changes: 3 additions & 1 deletion src/FSharp.Formatting.Common/paket.references
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FSharp.Core
FSharp.Compiler.Service
System.Memory framework: netstandard2.0
Microsoft.Build.Framework
Microsoft.Build.Tasks.Core
Microsoft.Build.Utilities.Core
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<IsPackable>true</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Formatting.Literate/Formatting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module internal Formatting =
yield line ]
|> String.concat "\n"

let transformDocument (doc: LiterateDocument) outputPath ctx =
let transformDocument (doc: LiterateDocument) (outputPath: string) ctx =

// If we want to include the source code of the script, then process
// the entire source and generate replacement {source} => ...some html...
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Formatting.Literate/Transformations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module internal Transformations =
/// (The dictionary argument is a map from original code snippets to formatted HTML snippets.)
///
/// Note: this processes snipppets within markdown, not snippets coming from .fsx
let rec replaceCodeSnippets path (codeLookup:IDictionary<_, _>) para =
let rec replaceCodeSnippets (path: string) (codeLookup:IDictionary<_, _>) para =
match para with
| CodeBlock (code, _executionCount, language, _, range) ->
match code with
Expand Down Expand Up @@ -87,7 +87,7 @@ module internal Transformations =
/// their formatted representation (of `LiterateParagraph` type)
///
/// Note: this processes snipppets within markdown, not snippets coming from .fsx
let formatCodeSnippets path (ctx: CompilerContext) (doc:LiterateDocument) =
let formatCodeSnippets (path: string) (ctx: CompilerContext) (doc:LiterateDocument) =
let name = Path.GetFileNameWithoutExtension(path)

// Extract all CodeBlocks and pass them to F# snippets
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<UsesMarkdownComments>true</UsesMarkdownComments>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Formatting/FSharp.Formatting.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<IsPackable>true</IsPackable>
<UsesMarkdownComments>true</UsesMarkdownComments>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Formatting/FSharp.Formatting.fsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#nowarn "211"

// FSharp.Formatting repo context: uncomment for intellisense
//#I "bin/Release/netstandard2.0"
//#I "bin/Release/netstandard2.1"

// Standard NuGet or Paket location
#I __SOURCE_DIRECTORY__
#I "lib/netstandard2.0"
#I "lib/netstandard2.1"

// Standard Paket locations
#I "../FSharp.Compiler.Service/lib/netstandard2.0"
Expand Down
Loading

0 comments on commit c92b005

Please sign in to comment.