Skip to content

Commit

Permalink
add sdk 2.0 support (#166)
Browse files Browse the repository at this point in the history
sdk 2.0 use path relative to projectFile for Compile items

So if a path is not absolute, then mean is relative to fsproj directory
  • Loading branch information
enricosada authored Jun 10, 2017
1 parent 13a2f30 commit 6de0fdb
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ TestResult.xml

fsautocomplete.zip
fsautocomplete.suave.zip
.dotnetsdk2_0
8 changes: 7 additions & 1 deletion src/FsAutoComplete.Core/ProjectCoreCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@ module ProjectCoreCracker =
| Some t -> t
| None -> failwith "error, 'TargetPath' property not found"

let compileFilesToAbsolutePath (f: string) =
if f.EndsWith(".fs") then
if Path.IsPathRooted f then f else Path.Combine(projDir, f)
else
f

let po =
{
ProjectFileName = file
ProjectFileNames = [||]
OtherOptions = rsp |> Array.ofList
OtherOptions = rsp |> List.map compileFilesToAbsolutePath |> Array.ofList
ReferencedProjects = p2pProjects |> Array.ofList
IsIncompleteTypeCheckEnvironment = false
UseScriptResolutionRules = false
Expand Down
57 changes: 57 additions & 0 deletions test/FsAutoComplete.IntegrationTests/DotNetSdk2.0/Runner.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#load "../TestHelpers.fsx"
open TestHelpers
open System.IO
open System

Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
File.Delete "output.json"

let sdkDir =
let isWindows = Environment.OSVersion.Platform = PlatformID.Win32NT
let file = if isWindows then "dotnet-install.ps1" else "dotnet-install.sh"
let repoDir = Path.Combine(__SOURCE_DIRECTORY__, "..", "..", "..")
let sdkDir = Path.Combine(repoDir, ".dotnetsdk2_0") |> Path.GetFullPath

if not <| Directory.Exists(sdkDir) then
printfn ".net core sdk not found in '%s'" sdkDir

Directory.CreateDirectory(sdkDir) |> ignore

printfn "downloading .net core sdk install script"
use client = new System.Net.WebClient()
let installScriptPath = Path.Combine(sdkDir, file)
client.DownloadFile("https://raw.githubusercontent.com/dotnet/cli/release/2.0.0/scripts/obtain/" + file, installScriptPath)

printfn "installing .net core sdk to '%s'" sdkDir

if isWindows then
let powershell script args = runProcess __SOURCE_DIRECTORY__ "powershell" (sprintf """-NoProfile -ExecutionPolicy unrestricted -File "%s" %s """ script args) |> ignore
powershell installScriptPath (sprintf "-InstallDir %s -Channel release/2.0.0" sdkDir)
else
let bash script args = runProcess __SOURCE_DIRECTORY__ "bash" (sprintf """ "%s" %s """ script args) |> ignore
bash installScriptPath (sprintf "--install-dir %s -channel release/2.0.0" sdkDir)

sdkDir

let withPath dir f =
let pathvar = System.Environment.GetEnvironmentVariable("PATH");
try
System.Environment.SetEnvironmentVariable("PATH", dir + Path.PathSeparator.ToString() + pathvar)
f ()
with _ ->
System.Environment.SetEnvironmentVariable("PATH", pathvar)

let doIt () =
runProcess __SOURCE_DIRECTORY__ "dotnet" "restore sample1/c1"
|> ignore

let p = new FsAutoCompleteWrapper()

p.project "sample1/c1/c1.fsproj"
p.parse "sample1/c1/Program.fs"

p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "output.json"

withPath sdkDir doIt
169 changes: 169 additions & 0 deletions test/FsAutoComplete.IntegrationTests/DotNetSdk2.0/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"Kind": "project",
"Data": {
"Project": "<absolute path removed>/FsAutoComplete.IntegrationTests/DotNetSdk2.0/sample1/c1/c1.fsproj",
"Files": [
"<absolute path removed>/FsAutoComplete.IntegrationTests/DotNetSdk2.0/sample1/c1/Program.fs"
],
"Output": "null",
"References": [
"<absolute path removed>/FSharp.Core.dll",
"<absolute path removed>/Microsoft.CSharp.dll",
"<absolute path removed>/Microsoft.VisualBasic.dll",
"<absolute path removed>/Microsoft.Win32.Primitives.dll",
"<absolute path removed>/Newtonsoft.Json.dll",
"<absolute path removed>/System.AppContext.dll",
"<absolute path removed>/System.Buffers.dll",
"<absolute path removed>/System.Collections.Concurrent.dll",
"<absolute path removed>/System.Collections.Immutable.dll",
"<absolute path removed>/System.Collections.NonGeneric.dll",
"<absolute path removed>/System.Collections.Specialized.dll",
"<absolute path removed>/System.Collections.dll",
"<absolute path removed>/System.ComponentModel.Annotations.dll",
"<absolute path removed>/System.ComponentModel.Composition.dll",
"<absolute path removed>/System.ComponentModel.DataAnnotations.dll",
"<absolute path removed>/System.ComponentModel.EventBasedAsync.dll",
"<absolute path removed>/System.ComponentModel.Primitives.dll",
"<absolute path removed>/System.ComponentModel.TypeConverter.dll",
"<absolute path removed>/System.ComponentModel.dll",
"<absolute path removed>/System.Configuration.dll",
"<absolute path removed>/System.Console.dll",
"<absolute path removed>/System.Core.dll",
"<absolute path removed>/System.Data.Common.dll",
"<absolute path removed>/System.Data.dll",
"<absolute path removed>/System.Diagnostics.Contracts.dll",
"<absolute path removed>/System.Diagnostics.Debug.dll",
"<absolute path removed>/System.Diagnostics.DiagnosticSource.dll",
"<absolute path removed>/System.Diagnostics.FileVersionInfo.dll",
"<absolute path removed>/System.Diagnostics.Process.dll",
"<absolute path removed>/System.Diagnostics.StackTrace.dll",
"<absolute path removed>/System.Diagnostics.TextWriterTraceListener.dll",
"<absolute path removed>/System.Diagnostics.Tools.dll",
"<absolute path removed>/System.Diagnostics.TraceSource.dll",
"<absolute path removed>/System.Diagnostics.Tracing.dll",
"<absolute path removed>/System.Drawing.Primitives.dll",
"<absolute path removed>/System.Drawing.dll",
"<absolute path removed>/System.Dynamic.Runtime.dll",
"<absolute path removed>/System.Globalization.Calendars.dll",
"<absolute path removed>/System.Globalization.Extensions.dll",
"<absolute path removed>/System.Globalization.dll",
"<absolute path removed>/System.IO.Compression.FileSystem.dll",
"<absolute path removed>/System.IO.Compression.ZipFile.dll",
"<absolute path removed>/System.IO.Compression.dll",
"<absolute path removed>/System.IO.FileSystem.DriveInfo.dll",
"<absolute path removed>/System.IO.FileSystem.Primitives.dll",
"<absolute path removed>/System.IO.FileSystem.Watcher.dll",
"<absolute path removed>/System.IO.FileSystem.dll",
"<absolute path removed>/System.IO.IsolatedStorage.dll",
"<absolute path removed>/System.IO.MemoryMappedFiles.dll",
"<absolute path removed>/System.IO.Pipes.dll",
"<absolute path removed>/System.IO.UnmanagedMemoryStream.dll",
"<absolute path removed>/System.IO.dll",
"<absolute path removed>/System.Linq.Expressions.dll",
"<absolute path removed>/System.Linq.Parallel.dll",
"<absolute path removed>/System.Linq.Queryable.dll",
"<absolute path removed>/System.Linq.dll",
"<absolute path removed>/System.Net.Http.dll",
"<absolute path removed>/System.Net.HttpListener.dll",
"<absolute path removed>/System.Net.Mail.dll",
"<absolute path removed>/System.Net.NameResolution.dll",
"<absolute path removed>/System.Net.NetworkInformation.dll",
"<absolute path removed>/System.Net.Ping.dll",
"<absolute path removed>/System.Net.Primitives.dll",
"<absolute path removed>/System.Net.Requests.dll",
"<absolute path removed>/System.Net.Security.dll",
"<absolute path removed>/System.Net.ServicePoint.dll",
"<absolute path removed>/System.Net.Sockets.dll",
"<absolute path removed>/System.Net.WebClient.dll",
"<absolute path removed>/System.Net.WebHeaderCollection.dll",
"<absolute path removed>/System.Net.WebProxy.dll",
"<absolute path removed>/System.Net.WebSockets.Client.dll",
"<absolute path removed>/System.Net.WebSockets.dll",
"<absolute path removed>/System.Net.dll",
"<absolute path removed>/System.Numerics.Vectors.dll",
"<absolute path removed>/System.Numerics.dll",
"<absolute path removed>/System.ObjectModel.dll",
"<absolute path removed>/System.Reflection.DispatchProxy.dll",
"<absolute path removed>/System.Reflection.Emit.ILGeneration.dll",
"<absolute path removed>/System.Reflection.Emit.Lightweight.dll",
"<absolute path removed>/System.Reflection.Emit.dll",
"<absolute path removed>/System.Reflection.Extensions.dll",
"<absolute path removed>/System.Reflection.Metadata.dll",
"<absolute path removed>/System.Reflection.Primitives.dll",
"<absolute path removed>/System.Reflection.TypeExtensions.dll",
"<absolute path removed>/System.Reflection.dll",
"<absolute path removed>/System.Resources.Reader.dll",
"<absolute path removed>/System.Resources.ResourceManager.dll",
"<absolute path removed>/System.Resources.Writer.dll",
"<absolute path removed>/System.Runtime.CompilerServices.VisualC.dll",
"<absolute path removed>/System.Runtime.Extensions.dll",
"<absolute path removed>/System.Runtime.Handles.dll",
"<absolute path removed>/System.Runtime.InteropServices.RuntimeInformation.dll",
"<absolute path removed>/System.Runtime.InteropServices.WindowsRuntime.dll",
"<absolute path removed>/System.Runtime.InteropServices.dll",
"<absolute path removed>/System.Runtime.Loader.dll",
"<absolute path removed>/System.Runtime.Numerics.dll",
"<absolute path removed>/System.Runtime.Serialization.Formatters.dll",
"<absolute path removed>/System.Runtime.Serialization.Json.dll",
"<absolute path removed>/System.Runtime.Serialization.Primitives.dll",
"<absolute path removed>/System.Runtime.Serialization.Xml.dll",
"<absolute path removed>/System.Runtime.Serialization.dll",
"<absolute path removed>/System.Runtime.dll",
"<absolute path removed>/System.Security.Claims.dll",
"<absolute path removed>/System.Security.Cryptography.Algorithms.dll",
"<absolute path removed>/System.Security.Cryptography.Csp.dll",
"<absolute path removed>/System.Security.Cryptography.Encoding.dll",
"<absolute path removed>/System.Security.Cryptography.Primitives.dll",
"<absolute path removed>/System.Security.Cryptography.X509Certificates.dll",
"<absolute path removed>/System.Security.Principal.dll",
"<absolute path removed>/System.Security.SecureString.dll",
"<absolute path removed>/System.Security.dll",
"<absolute path removed>/System.ServiceModel.Web.dll",
"<absolute path removed>/System.ServiceProcess.dll",
"<absolute path removed>/System.Text.Encoding.Extensions.dll",
"<absolute path removed>/System.Text.Encoding.dll",
"<absolute path removed>/System.Text.RegularExpressions.dll",
"<absolute path removed>/System.Threading.Overlapped.dll",
"<absolute path removed>/System.Threading.Tasks.Dataflow.dll",
"<absolute path removed>/System.Threading.Tasks.Extensions.dll",
"<absolute path removed>/System.Threading.Tasks.Parallel.dll",
"<absolute path removed>/System.Threading.Tasks.dll",
"<absolute path removed>/System.Threading.Thread.dll",
"<absolute path removed>/System.Threading.ThreadPool.dll",
"<absolute path removed>/System.Threading.Timer.dll",
"<absolute path removed>/System.Threading.dll",
"<absolute path removed>/System.Transactions.Local.dll",
"<absolute path removed>/System.Transactions.dll",
"<absolute path removed>/System.ValueTuple.dll",
"<absolute path removed>/System.Web.HttpUtility.dll",
"<absolute path removed>/System.Web.dll",
"<absolute path removed>/System.Windows.dll",
"<absolute path removed>/System.Xml.Linq.dll",
"<absolute path removed>/System.Xml.ReaderWriter.dll",
"<absolute path removed>/System.Xml.Serialization.dll",
"<absolute path removed>/System.Xml.XDocument.dll",
"<absolute path removed>/System.Xml.XPath.XDocument.dll",
"<absolute path removed>/System.Xml.XPath.dll",
"<absolute path removed>/System.Xml.XmlDocument.dll",
"<absolute path removed>/System.Xml.XmlSerializer.dll",
"<absolute path removed>/System.Xml.dll",
"<absolute path removed>/System.dll",
"<absolute path removed>/WindowsBase.dll",
"<absolute path removed>/FsAutoComplete.IntegrationTests/DotNetSdk2.0/sample1/l1/bin/Debug/netstandard1.6/l1.dll",
"<absolute path removed>/mscorlib.dll",
"<absolute path removed>/netstandard.dll"
],
"Logs": {}
}
}
{
"Kind": "info",
"Data": "Synchronous parsing started"
}
{
"Kind": "errors",
"Data": {
"File": "<absolute path removed>/FsAutoComplete.IntegrationTests/DotNetSdk2.0/sample1/c1/Program.fs",
"Errors": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
l1.Say.hello "F#!"
l1.Say.jsonstuff()
0 // return an integer exit code
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\l1\l1.fsproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace l1

open Newtonsoft.Json

type Movie = {
Name : string
Year: int
}

module Say =
let hello name =
printfn "Hello %s" name

let jsonstuff () =

let movies = [
{ Name = "Bad Boys"; Year = 1995 };
{ Name = "Bad Boys 2"; Year = 2003 }
]

let json = JsonConvert.SerializeObject(movies)
printfn "%s" json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<MyCustomProp>custom value</MyCustomProp>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>

0 comments on commit 6de0fdb

Please sign in to comment.