Skip to content

Commit

Permalink
netcoreapp3.0 and a simple switch for TFM
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel authored and Krzysztof-Cieslak committed Oct 6, 2019
1 parent 9d76a3d commit a88d049
Show file tree
Hide file tree
Showing 20 changed files with 591 additions and 617 deletions.
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_debug_netcore",
"program": "${workspaceFolder}/src/FsAutoComplete/bin/Debug/netcoreapp2.1/fsautocomplete.dll",
"program": "${workspaceFolder}/src/FsAutoComplete/bin/Debug/netcoreapp3.0/fsautocomplete.dll",
"args": ["--mode", "lsp"],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
Expand All @@ -33,7 +33,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_lsp_tests",
"program": "${workspaceFolder}/test/FsAutoComplete.Tests.Lsp/bin/Debug/netcoreapp2.1/FsAutoComplete.Tests.Lsp.dll",
"program": "${workspaceFolder}/test/FsAutoComplete.Tests.Lsp/bin/Debug/netcoreapp3.0/FsAutoComplete.Tests.Lsp.dll",
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"stopAtEntry": false,
Expand All @@ -43,7 +43,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_debug_netcore",
"program": "${workspaceFolder}/src/FsAutoComplete/bin/Debug/netcoreapp2.1/fsautocomplete.dll",
"program": "${workspaceFolder}/src/FsAutoComplete/bin/Debug/netcoreapp3.0/fsautocomplete.dll",
"args": ["--mode", "stdio", "-v"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
"taskName": "build_debug_netcore",
"type": "shell",
"command": "dotnet build src/FsAutoComplete -f netcoreapp2.1",
"command": "dotnet build src/FsAutoComplete -f netcoreapp3.0",
"group": {
"kind": "build",
"isDefault": true
Expand Down
4 changes: 2 additions & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ let runIntegrationTest cfg (fn: string) : bool =
match cfg.Runtime with
| FSACRuntime.NET -> "net461"
| FSACRuntime.NETCoreSCD
| FSACRuntime.NETCoreFDD -> "netcoreapp2.1"
| FSACRuntime.NETCoreFDD -> "netcoreapp3.0"
let fsiArgs = sprintf "%s -- -pub -f %s -c %s" fn framework configuration
let fsiPath = FSIHelper.fsiPath
tracefn "Running fsi '%s %s' (from dir '%s')" fsiPath fsiArgs dir
Expand Down Expand Up @@ -222,7 +222,7 @@ Target "LocalRelease" (fun _ ->
DotNetCli.Publish (fun p ->
{ p with
Output = __SOURCE_DIRECTORY__ </> "bin/release_netcore"
Framework = "netcoreapp2.1"
Framework = "netcoreapp3.0"
Project = "src/FsAutoComplete"
Configuration = configuration
AdditionalArgs = [ "/p:SourceLinkCreate=true"; sprintf "/p:Version=%s" release.AssemblyVersion ] })
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.801"
"version": "3.0.100"
}
}
4 changes: 2 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version 5.201.1

framework: net461, netstandard2.0, netcoreapp2.1
framework: net461, netstandard2.0, netcoreapp3.0
source https://api.nuget.org/v3/index.json
source ./lib
storage: none
Expand Down Expand Up @@ -37,7 +37,7 @@ group Build
nuget FAKE ~> 4

group Test
framework: net461, netstandard2.0, netcoreapp2.0, netcoreapp2.1
framework: net461, netstandard2.0, netcoreapp2.0, netcoreapp3.0
source https://api.nuget.org/v3/index.json
storage: none

Expand Down
1,098 changes: 525 additions & 573 deletions paket.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.0</TargetFrameworks>
<AssemblyName>fsautocomplete.backgroundservices</AssemblyName>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
Expand Down
6 changes: 2 additions & 4 deletions src/FsAutoComplete.BackgroundServices/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ type BackgroundServiceServer(state: State, client: FsacClient) =
if file.EndsWith ".fsx" then
state.Files.TryFind file |> Option.map (fun st ->
async {
let targetFramework = NETFrameworkInfoProvider.latestInstalledNETVersion ()
let! opts = fsxBinder.GetProjectOptionsFromScriptBy(targetFramework, file, st.Lines |> String.concat "\n")
let! (opts, _errors) = checker.GetProjectOptionsFromScript(file, SourceText.ofString (st.Lines |> String.concat "\n"), assumeDotNetFramework = true, useSdkRefs = false)
let sf = getFilesFromOpts opts

return
Expand Down Expand Up @@ -159,8 +158,7 @@ type BackgroundServiceServer(state: State, client: FsacClient) =
return ()
| Some vf, None when file.EndsWith ".fsx" ->
let txt = vf.Lines |> String.concat "\n"
let targetFramework = NETFrameworkInfoProvider.latestInstalledNETVersion ()
let! opts = fsxBinder.GetProjectOptionsFromScriptBy(targetFramework, file, txt)
let! (opts, _errors) = checker.GetProjectOptionsFromScript(file, SourceText.ofString txt, assumeDotNetFramework = true, useSdkRefs = false)
let! pr, cr = checker.ParseAndCheckFileInProject(file, defaultArg vf.Version 0, SourceText.ofString txt, opts)
match cr with
| FSharpCheckFileAnswer.Aborted ->
Expand Down
7 changes: 4 additions & 3 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ type Commands (serialize : Serializer, backgroundServiceEnabled) =
let! result = checker.ParseAndCheckFileInProject(fileName, version, text, options)
return
match result with
| ResultOrString.Error e -> [CoreResponse.ErrorRes e]
| ResultOrString.Error e ->
[CoreResponse.ErrorRes e]
| ResultOrString.Ok (parseAndCheck) ->
let parseResult = parseAndCheck.GetParseResults
let results = parseAndCheck.GetCheckResults
Expand All @@ -387,7 +388,7 @@ type Commands (serialize : Serializer, backgroundServiceEnabled) =
let text = String.concat "\n" lines

if Utils.isAScript file then
let! checkOptions = checker.GetProjectOptionsFromScript(file, text)
let! checkOptions = checker.GetProjectOptionsFromScript(file, text, TFM.NetCore)
state.AddFileTextAndCheckerOptions(file, lines, normalizeOptions checkOptions, Some version)
fileStateSet.Trigger ()
return! parse' file text checkOptions
Expand All @@ -398,7 +399,7 @@ type Commands (serialize : Serializer, backgroundServiceEnabled) =
state.SetFileVersion file version
async.Return c
| None -> async {
let! checkOptions = checker.GetProjectOptionsFromScript(file, text)
let! checkOptions = checker.GetProjectOptionsFromScript(file, text, TFM.NetFx)
state.AddFileTextAndCheckerOptions(file, lines, normalizeOptions checkOptions, Some version)
return checkOptions
}
Expand Down
45 changes: 34 additions & 11 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ type FindDeclarationResult =
| ExternalDeclaration of Decompiler.ExternalContentPosition
| Range of FSharp.Compiler.Range.range

type TFM =
| NetFx
| NetCore

type ParseAndCheckResults
(
parseResults: FSharpParseFileResults,
Expand Down Expand Up @@ -419,6 +423,7 @@ type FSharpCompilerServiceChecker(backgroundServiceEnabled) =
do checker.ImplicitlyStartBackgroundWork <- not backgroundServiceEnabled

do checker.BeforeBackgroundFileCheck.Add ignore

let fixFileName path =
if (try Path.GetFullPath path |> ignore; true with _ -> false) then path
else
Expand All @@ -441,6 +446,11 @@ type FSharpCompilerServiceChecker(backgroundServiceEnabled) =
if Debug.verbose then Debug.print "[FSharpChecker] Current Queue Length: %d" checker.CurrentQueueLength
Debug.print fmt

let patchWithMscorlib (projOptions: FSharpProjectOptions) =
let dir = projOptions.OtherOptions.[2].Substring(3) |> IO.Path.GetDirectoryName
let otherOpts = [| yield! projOptions.OtherOptions.[0..2]; yield "-r:" + dir </> "mscorlib.dll"; yield! projOptions.OtherOptions.[3..] |]
{ projOptions with OtherOptions = otherOpts }

member __.CreateFCSBinder(netFwInfo: Dotnet.ProjInfo.Workspace.NetFWInfo, loader: Dotnet.ProjInfo.Workspace.Loader) =
Dotnet.ProjInfo.Workspace.FCS.FCSBinder(netFwInfo, loader, checker)

Expand All @@ -458,17 +468,30 @@ type FSharpCompilerServiceChecker(backgroundServiceEnabled) =
|> Seq.filter (fun o -> o.ReferencedProjects |> Array.map (fun (_,v) -> Path.GetFullPath v.ProjectFileName) |> Array.contains option.ProjectFileName )
])

member __.GetProjectOptionsFromScript(file, source) = async {
#if NETCORE_FSI
logDebug "[Opts] Getting options for script file %s" file
let! (projOptions, _) = checker.GetProjectOptionsFromScript(file, SourceText.ofString source, useSdkRefs = true, assumeDotNetFramework = false, useFsiAuxLib = true)
let dir = projOptions.OtherOptions.[2].Substring(3) |> IO.Path.GetDirectoryName
let projOptions = {projOptions with OtherOptions = [| yield! projOptions.OtherOptions.[0..2]; yield "-r:" + dir </> "mscorlib.dll"; yield! projOptions.OtherOptions.[3..] |] }
logDebug "[Opts] Resolved optiosn - %A" projOptions
#else
let targetFramework = NETFrameworkInfoProvider.latestInstalledNETVersion ()
let! projOptions = fsxBinder.GetProjectOptionsFromScriptBy(targetFramework, file, source)
#endif
member private __.GetNetFxScriptOptions(file, source) =
logDebug "[Opts] Getting NetFX options for script file %s" file
checker.GetProjectOptionsFromScript(file, SourceText.ofString source, assumeDotNetFramework = true)

member private __.GetNetCoreScriptOptions(file, source) =
logDebug "[Opts] Getting NetCore options for script file %s" file
checker.GetProjectOptionsFromScript(file, SourceText.ofString source, assumeDotNetFramework = false, useSdkRefs = true)

member self.GetProjectOptionsFromScript(file, source, tfm) = async {
let! (projOptions, errors) =
match tfm with
| NetFx -> self.GetNetFxScriptOptions(file, source)
| NetCore -> self.GetNetCoreScriptOptions(file, source)

let projOptions = patchWithMscorlib projOptions

match errors with
| [] ->
let refs = projOptions.OtherOptions |> Array.filter (fun o -> o.StartsWith("-r")) |> String.concat "\n"
logDebug "[Opts] Resolved options - %A" projOptions
logDebug "[Opts] Resolved references:\n%s" refs
| errs ->
logDebug "[Opts] Resolved options with errors\n%A\n%A" projOptions errs

match FakeSupport.detectFakeScript file with
| None ->
logDebug "[Opts] %s is not a FAKE script" file
Expand Down
2 changes: 1 addition & 1 deletion src/FsAutoComplete.Core/DotnetNewTemplate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module DotnetNewTemplate =
Options =
[ { ParameterName = "--framework";
ShortName = "-f";
ParameterType = TemplateParameterType.Choice ["netcoreapp2.1 - Target netcoreapp2.1";"netstandard2.0 - Target netstandard2.0"];
ParameterType = TemplateParameterType.Choice ["netcoreapp3.0 - Target netcoreapp3.0";"netstandard2.0 - Target netstandard2.0"];
ParameterDescription = "The target framework for the project.";
DefaultValue = "netstandard2.0" };

Expand Down
12 changes: 6 additions & 6 deletions src/FsAutoComplete/FsAutoComplete.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.0</TargetFrameworks>
<AssemblyName>fsautocomplete</AssemblyName>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
Expand All @@ -24,7 +24,7 @@
<Compile Include="Program.fs" />
<None Include="FsAutoComplete.fsproj.paket.references" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<Content Include="default.win32manifest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand All @@ -38,7 +38,7 @@
<!-- do not bundle the net461 exe inside the .net core tool package -->
<PropertyGroup Condition=" '$(PackAsTool)' == 'true' ">
<TargetFrameworks></TargetFrameworks>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>dotnet-fsautocomplete</AssemblyName>
<PackageId>fsautocomplete</PackageId>

Expand All @@ -55,11 +55,11 @@

<Target Name="CopyBackgroundServiceJsonToOutputDir"
AfterTargets="ComputeFilesToPublish"
Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<ItemGroup>
<ResolvedFileToPublish Include="$(MSBuildProjectDirectory)/../FsAutoComplete.BackgroundServices\bin\$(Configuration)\netcoreapp2.1\fsautocomplete.backgroundservices.deps.json"
<ResolvedFileToPublish Include="$(MSBuildProjectDirectory)/../FsAutoComplete.BackgroundServices\bin\$(Configuration)\netcoreapp3.0\fsautocomplete.backgroundservices.deps.json"
RelativePath="fsautocomplete.backgroundservices.deps.json" />
<ResolvedFileToPublish Include="$(MSBuildProjectDirectory)/../FsAutoComplete.BackgroundServices\bin\$(Configuration)\netcoreapp2.1\fsautocomplete.backgroundservices.runtimeconfig.json"
<ResolvedFileToPublish Include="$(MSBuildProjectDirectory)/../FsAutoComplete.BackgroundServices\bin\$(Configuration)\netcoreapp3.0\fsautocomplete.backgroundservices.runtimeconfig.json"
RelativePath="fsautocomplete.backgroundservices.runtimeconfig.json" />
</ItemGroup>
</Target>
Expand Down
4 changes: 2 additions & 2 deletions test/FsAutoComplete.IntegrationTests/TestHelpers.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with
member s.Usage =
match s with
| Configuration _ -> "The configuration. The default is 'Debug'."
| Framework _ -> "The target framework. The default is 'netcoreapp2.1'"
| Framework _ -> "The target framework. The default is 'netcoreapp3.0'"
| Published -> "Test the exe published in '~/bin/' dirs instead"
| Runtime _ -> "The target runtime. If set, it will test a self-contained deployment."

Expand Down Expand Up @@ -50,7 +50,7 @@ let testConfig =
let results = parser.Parse (Array.ofList fsxArgs)

let configuration = results.GetResult (<@ Configuration @>, defaultValue = "Debug")
let framework = results.GetResult (<@ Framework @>, defaultValue = "netcoreapp2.1")
let framework = results.GetResult (<@ Framework @>, defaultValue = "netcoreapp3.0")
let rid = results.TryGetResult <@ Runtime @>
let published = results.Contains <@ Published @>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../../src/FsAutoComplete/FsAutoComplete.fsproj">
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>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
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>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
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>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
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>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/FsAutoComplete.Tests/FsAutoComplete.Tests.fsproj
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>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down

0 comments on commit a88d049

Please sign in to comment.