From 01022cbaa9805d6e78a722dc2f939dcab6441cd0 Mon Sep 17 00:00:00 2001 From: ncave Date: Thu, 28 Apr 2016 10:02:51 -0700 Subject: [PATCH 01/17] dotnet cli tests --- src/fsharp/CompileOps.fs | 5 +- .../project.json | 4 +- .../NuGet.Config | 12 ++++ .../Program.fs | 14 ++++ .../ReshapedReflection.fs | 9 +++ .../project.json | 67 +++++++++++++++++++ tests/service/Common.fs | 12 ++++ tests/service/FsUnit.fs | 2 - tests/service/FscTests.fs | 14 +++- tests/service/FsiTests.fs | 2 +- 10 files changed, 132 insertions(+), 9 deletions(-) create mode 100644 tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config create mode 100644 tests/FSharp.Compiler.Service.Tests.netcore/Program.fs create mode 100644 tests/FSharp.Compiler.Service.Tests.netcore/ReshapedReflection.fs create mode 100644 tests/FSharp.Compiler.Service.Tests.netcore/project.json diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 3fa4fe3ca4..97f7f7ca62 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -1543,7 +1543,6 @@ let OutputErrorOrWarningContext prefix fileLineFn os err = let GetFSharpCoreLibraryName () = "FSharp.Core" -type internal TypeInThisAssembly = class end let GetFSharpCoreReferenceUsedByCompiler(useMonoResolution) = // On Mono, there is no good reference resolution if useMonoResolution then @@ -1555,10 +1554,10 @@ let GetFSharpCoreReferenceUsedByCompiler(useMonoResolution) = // So use the fsharp.core.dll from alongside the fsc compiler. // This can also be used for the out of gac work on DEV15 let fscCoreLocation = - let fscLocation = typeof.Assembly.Location + let fscLocation = typeof.Assembly.Location Path.Combine(Path.GetDirectoryName(fscLocation), fsCoreName + ".dll") if File.Exists(fscCoreLocation) then fsCoreName + ".dll" - else failwithf "Internal error: Could not find %s" fsCoreName + else failwithf "Internal error: Could not find %s" fscCoreLocation #else // check if FSharp.Core can be found from the hosting environment let foundReference = diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.netcore/project.json index bf2ada1235..58cdd2cca7 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/project.json +++ b/src/fsharp/FSharp.Compiler.Service.netcore/project.json @@ -1,7 +1,7 @@ { "version": "1.0.0-*", - "compilerName": "fsc", - "compilationOptions": { + "buildOptions": { + "compilerName": "fsc", "define": [ "BUILDING_WITH_LKG", "COMPILED_AS_LANGUAGE_SERVICE_DLL", diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config new file mode 100644 index 0000000000..72e620e289 --- /dev/null +++ b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/Program.fs b/tests/FSharp.Compiler.Service.Tests.netcore/Program.fs new file mode 100644 index 0000000000..7922386aa0 --- /dev/null +++ b/tests/FSharp.Compiler.Service.Tests.netcore/Program.fs @@ -0,0 +1,14 @@ +open System +open System.IO +open System.Reflection +open NUnitLite +open NUnit.Common + +type private TypeInThisAssembly = class end + +[] +let main argv = + printfn "Testing...Testing...1...2...3..." + let writer = new ExtendedTextWrapper(Console.Out) + let runner = new AutoRun(typeof.GetTypeInfo().Assembly) + runner.Execute(argv, writer, Console.In) diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/ReshapedReflection.fs b/tests/FSharp.Compiler.Service.Tests.netcore/ReshapedReflection.fs new file mode 100644 index 0000000000..3b1ba07ce8 --- /dev/null +++ b/tests/FSharp.Compiler.Service.Tests.netcore/ReshapedReflection.fs @@ -0,0 +1,9 @@ +namespace FSharp.Compiler.Service.Tests + +#if FX_RESHAPED_REFLECTION +module internal ReflectionAdapters = + open System.Reflection + + type System.Type with + member this.Assembly = this.GetTypeInfo().Assembly +#endif diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/project.json b/tests/FSharp.Compiler.Service.Tests.netcore/project.json new file mode 100644 index 0000000000..1cf58efada --- /dev/null +++ b/tests/FSharp.Compiler.Service.Tests.netcore/project.json @@ -0,0 +1,67 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "compilerName": "fsc", + "emitEntryPoint": true, + "define": [ + "FX_ATLEAST_PORTABLE", + "FX_NO_RUNTIMEENVIRONMENT", + "FX_RESHAPED_REFLECTION", + "TRACE", + ], + "nowarn": [ + "44", + ], + "xmlDoc": true, + "delaySign": true, + "warningsAsErrors": true, + "additionalArguments": [ + "--warn:3", + "--fullpaths", + "--flaterrors", + ] + }, + "namedResource": {}, + "compileFiles": [ + "ReshapedReflection.fs", + "../service/FsUnit.fs", + "../service/Common.fs", + "../service/EditorTests.fs", + + "Program.fs", + ], + "compileFiles_not_used": [ + "../service/FsiTests.fs", + "../service/FscTests.fs", + "../service/TokenizerTests.fs", + "../service/ProjectAnalysisTests.fs", + "../service/ProjectOptionsTests.fs", + "../service/MultiProjectAnalysisTests.fs", + "../service/PerfTests.fs", + "../service/InteractiveCheckerTests.fs", + "../service/ExprTests.fs", + + "../service/FileSystemTests.fs", + "../service/CSharpProjectAnalysis.fs", + ], + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0-rc2-*" + }, + "Microsoft.FSharp.Core.netcore": "1.0.0-*", + "FSharp.Compiler.Service.netcore": "1.0.0-*", + "NUnitLite": "3.2.1", + }, + "tools": { + "dotnet-compile-fsc": "1.0.0-*" + }, + "frameworks": { + "netstandard1.5": { + "imports": [ + "portable-net45+win8", + "dnxcore50" + ] + } + } +} \ No newline at end of file diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 372f4b10cd..d6c9ed05d0 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -5,6 +5,10 @@ open System.Collections.Generic open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.SourceCodeServices +#if FX_RESHAPED_REFLECTION +open ReflectionAdapters +#endif + // Create one global interactive checker instance let checker = FSharpChecker.Create() @@ -37,10 +41,16 @@ let getBackgroundCheckResultsForScriptText (input) = let sysLib nm = +#if !FX_ATLEAST_PORTABLE if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\" + nm + ".dll" else +#endif +#if FX_NO_RUNTIMEENVIRONMENT + let sysDir = System.AppContext.BaseDirectory +#else let sysDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() +#endif let (++) a b = System.IO.Path.Combine(a,b) sysDir ++ nm + ".dll" @@ -51,9 +61,11 @@ module Helpers = let PathRelativeToTestAssembly p = Path.Combine(Path.GetDirectoryName(Uri(typeof.Assembly.CodeBase).LocalPath), p) let fsCoreDefaultReference() = +#if !FX_ATLEAST_PORTABLE if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows @"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.4.0.0\FSharp.Core.dll" else +#endif sysLib "FSharp.Core" diff --git a/tests/service/FsUnit.fs b/tests/service/FsUnit.fs index fb26db3519..497b492cc5 100644 --- a/tests/service/FsUnit.fs +++ b/tests/service/FsUnit.fs @@ -38,8 +38,6 @@ let Empty = new EmptyConstraint() let EmptyString = new EmptyStringConstraint() -let NullOrEmptyString = new NullOrEmptyStringConstraint() - let True = new TrueConstraint() let False = new FalseConstraint() diff --git a/tests/service/FscTests.fs b/tests/service/FscTests.fs index e968dfccd4..93c2d9852a 100644 --- a/tests/service/FscTests.fs +++ b/tests/service/FscTests.fs @@ -21,6 +21,10 @@ open FSharp.Compiler.Service.Tests.Common open NUnit.Framework +#if FX_RESHAPED_REFLECTION +open ReflectionAdapters +#endif + exception VerificationException of (*assembly:*)string * (*errorCode:*)int * (*output:*)string with override e.Message = sprintf "Verification of '%s' failed with code %d, message <<<%s>>>" e.Data0 e.Data1 e.Data2 @@ -38,6 +42,9 @@ type PEVerifier () = static let runsOnMono = try System.Type.GetType("Mono.Runtime") <> null with _ -> false let verifierInfo = +#if FX_ATLEAST_PORTABLE + None +#else if runsOnMono then Some ("pedump", "--verify all") else @@ -67,12 +74,13 @@ type PEVerifier () = match tryFindFile "peverify.exe" sdkDir with | None -> None | Some pe -> Some (pe, "/UNIQUE /IL /NOLOGO") +#endif static let execute (fileName : string, arguments : string) = printfn "executing '%s' with arguments %s" fileName arguments let psi = new ProcessStartInfo(fileName, arguments) psi.UseShellExecute <- false - psi.ErrorDialog <- false + //psi.ErrorDialog <- false psi.CreateNoWindow <- true psi.RedirectStandardOutput <- true psi.RedirectStandardError <- true @@ -108,12 +116,16 @@ let compiler = new SimpleSourceCodeServices() /// Ensures the default FSharp.Core referenced by the F# compiler service (if none is /// provided explicitly) is available in the output directory. let ensureDefaultFSharpCoreAvailable tmpDir = +#if FX_ATLEAST_PORTABLE + ignore tmpDir +#else // FSharp.Compiler.Service references FSharp.Core 4.3.0.0 by default. That's wrong? But the output won't verify // or run on a system without FSharp.Core 4.3.0.0 in the GAC or in the same directory, or with a binding redirect in place. // // So just copy the FSharp.Core 4.3.0.0 to the tmp directory. Only need to do this on Windows. if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows File.Copy(fsCoreDefaultReference(), Path.Combine(tmpDir, Path.GetFileName(fsCoreDefaultReference())), overwrite = true) +#endif let compile isDll debugMode (assemblyName : string) (code : string) (dependencies : string list) = let tmp = Path.Combine(Path.GetTempPath(),"test"+string(hash (isDll,debugMode,assemblyName,code,dependencies))) diff --git a/tests/service/FsiTests.fs b/tests/service/FsiTests.fs index 5ebc67b720..69ff9e4770 100644 --- a/tests/service/FsiTests.fs +++ b/tests/service/FsiTests.fs @@ -27,7 +27,7 @@ let errStream = new CompilerOutputStream() let argv = [| "C:\\fsi.exe" |] let allArgs = Array.append argv [|"--noninteractive"|] -let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration(fsi) +let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration() //(fsi) let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, new StreamWriter(outStream), new StreamWriter(errStream)) /// Evaluate expression & return the result From 3f9414da6adf334abffaa75441ea1525f9f5e739 Mon Sep 17 00:00:00 2001 From: ncave Date: Sun, 1 May 2016 19:12:52 -0700 Subject: [PATCH 02/17] Added netcore test project --- build.fsx | 31 +++++---- src/fsharp/CompileOps.fs | 8 ++- .../NuGet.Config | 5 +- .../project.json | 11 ++-- src/fsharp/ReferenceResolution.fs | 2 +- src/fsharp/vs/service.fs | 6 +- .../NuGet.Config | 2 +- .../Program.fs | 2 +- .../project.json | 13 ++-- tests/service/Common.fs | 48 +++++++++++++- tests/service/EditorTests.fs | 66 ++++++++----------- 11 files changed, 122 insertions(+), 72 deletions(-) diff --git a/build.fsx b/build.fsx index 49d02dda3d..fd6595656c 100644 --- a/build.fsx +++ b/build.fsx @@ -232,21 +232,26 @@ Target "DotnetCliBuild" (fun _ -> let open3 = @" --open Microsoft.FSharp.Compiler" let options = " --configuration Release" - let outPath = @"src/fsharp/FSharp.Compiler.Service.netcore/" - Shell.Exec("dotnet", "restore", outPath) |> ignore //assertExitCodeZero - - Shell.Exec("dotnet", "fssrgen ../FSComp.txt ./FSComp.fs ./FSComp.resx", outPath) |> assertExitCodeZero - Shell.Exec("dotnet", "fssrgen ../fsi/FSIstrings.txt ./FSIstrings.fs ./FSIstrings.resx", outPath) |> assertExitCodeZero - Shell.Exec(fsLex, @"../lex.fsl --unicode" + lexArgs + " -o lex.fs", outPath) |> assertExitCodeZero - Shell.Exec(fsLex, @"../pplex.fsl --unicode" + lexArgs + " -o pplex.fs", outPath) |> assertExitCodeZero - Shell.Exec(fsLex, @"../../absil/illex.fsl --unicode" + lexArgs + " -o illex.fs", outPath) |> assertExitCodeZero - Shell.Exec(fsYacc, @"../../absil/ilpars.fsy" + lexArgs + yaccArgs + module1 + open1 + " -o ilpars.fs", outPath) |> assertExitCodeZero - Shell.Exec(fsYacc, @"../pars.fsy" + lexArgs + yaccArgs + module2 + open2 + " -o pars.fs", outPath) |> assertExitCodeZero - Shell.Exec(fsYacc, @"../pppars.fsy" + lexArgs + yaccArgs + module3 + open3 + " -o pppars.fs", outPath) |> assertExitCodeZero - - Shell.Exec("dotnet", "--verbose pack" + options, outPath) |> assertExitCodeZero + let workDir = @"src/fsharp/FSharp.Compiler.Service.netcore/" + Shell.Exec("dotnet", "restore", workDir) |> ignore //assertExitCodeZero + + Shell.Exec("dotnet", "fssrgen ../FSComp.txt ./FSComp.fs ./FSComp.resx", workDir) |> assertExitCodeZero + Shell.Exec("dotnet", "fssrgen ../fsi/FSIstrings.txt ./FSIstrings.fs ./FSIstrings.resx", workDir) |> assertExitCodeZero + Shell.Exec(fsLex, @"../lex.fsl --unicode" + lexArgs + " -o lex.fs", workDir) |> assertExitCodeZero + Shell.Exec(fsLex, @"../pplex.fsl --unicode" + lexArgs + " -o pplex.fs", workDir) |> assertExitCodeZero + Shell.Exec(fsLex, @"../../absil/illex.fsl --unicode" + lexArgs + " -o illex.fs", workDir) |> assertExitCodeZero + Shell.Exec(fsYacc, @"../../absil/ilpars.fsy" + lexArgs + yaccArgs + module1 + open1 + " -o ilpars.fs", workDir) |> assertExitCodeZero + Shell.Exec(fsYacc, @"../pars.fsy" + lexArgs + yaccArgs + module2 + open2 + " -o pars.fs", workDir) |> assertExitCodeZero + Shell.Exec(fsYacc, @"../pppars.fsy" + lexArgs + yaccArgs + module3 + open3 + " -o pppars.fs", workDir) |> assertExitCodeZero + + Shell.Exec("dotnet", "--verbose pack" + options, workDir) |> assertExitCodeZero ) +Target "DotnetCliTests" (fun _ -> + let workDir = @"tests/FSharp.Compiler.Service.Tests.netcore/" + Shell.Exec("dotnet", "restore", workDir) |> ignore //assertExitCodeZero + Shell.Exec("dotnet", "run", workDir) |> assertExitCodeZero +) // -------------------------------------------------------------------------------------- // Run all targets by default. Invoke 'build ' to override diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 97f7f7ca62..e197b3a7d0 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -2118,7 +2118,12 @@ type TcConfigBuilder = System.Diagnostics.Debug.Assert(FileSystem.IsPathRootedShim(implicitIncludeDir), sprintf "implicitIncludeDir should be absolute: '%s'" implicitIncludeDir) if (String.IsNullOrEmpty(defaultFSharpBinariesDir)) then failwith "Expected a valid defaultFSharpBinariesDir" - { primaryAssembly = PrimaryAssembly.Mscorlib; // defaut value, can be overridden using the command line switch + { +#if TODO_REWORK_ASSEMBLY_LOAD + primaryAssembly = PrimaryAssembly.DotNetCore; // defaut value, can be overridden using the command line switch +#else + primaryAssembly = PrimaryAssembly.Mscorlib; // defaut value, can be overridden using the command line switch +#endif light = None; noFeedback=false; stackReserveSize=None; @@ -4843,6 +4848,7 @@ module private ScriptPreprocessClosure = #else | CodeContext.Compilation | CodeContext.Evaluation -> MSBuildResolver.CompileTimeLike #endif + tcConfigB.useMonoResolution <- useMonoResolution tcConfigB.framework <- false // Indicates that there are some references not in BasicReferencesForScriptLoadClosure which should // be added conditionally once the relevant version of mscorlib.dll has been detected. diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config b/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config index 5ac1dd9fdc..e6b6a3baff 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config +++ b/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config @@ -3,9 +3,10 @@ - + + + - diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.netcore/project.json index 58cdd2cca7..ae3a70c1a3 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/project.json +++ b/src/fsharp/FSharp.Compiler.Service.netcore/project.json @@ -59,7 +59,6 @@ "PREFERRED_UI_LANG", "PUT_TYPE_PROVIDERS_IN_FSCORE", "QUERIES_IN_FSLIB", - "RESHAPED_MSBUILD", "SIGNED", "STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY", "TODO_REWORK_ASSEMBLY_LOAD", @@ -97,7 +96,6 @@ "FSComp.fs", "FSIstrings.fs", "../../utils/reshapedreflection.fs", - "../../utils/reshapedmsbuild.fs", "../../utils/sformat.fsi", "../../utils/sformat.fs", "../sr.fsi", @@ -258,11 +256,14 @@ "../fsi/fsi.fs" ], "dependencies": { - "Microsoft.FSharp.Core.netcore": "1.0.0-*", "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002471" - } + "version": "1.0.0-rc2-3002543" + }, + "Microsoft.Build.Framework": "0.1.0-*", + "Microsoft.Build.Tasks.Core": "0.1.0-*", + "Microsoft.Build.Utilities.Core": "0.1.0-*", + "Microsoft.FSharp.Core.netcore": "1.0.0-*", }, "tools": { "dotnet-fssrgen": "3.0.1", diff --git a/src/fsharp/ReferenceResolution.fs b/src/fsharp/ReferenceResolution.fs index e8e826a89b..7daa7ea16e 100644 --- a/src/fsharp/ReferenceResolution.fs +++ b/src/fsharp/ReferenceResolution.fs @@ -40,7 +40,7 @@ module internal MSBuildResolver = open Microsoft.Build.Tasks open Microsoft.Build.Utilities open Microsoft.Build.Framework - open Microsoft.Build.BuildEngine + //open Microsoft.Build.BuildEngine open System.IO open System.Reflection diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 397ea0eef2..db8c55bb9c 100644 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -2530,10 +2530,12 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun let otherFlags = defaultArg otherFlags [| |] let useMonoResolution = #if ENABLE_MONO_SUPPORT - runningOnMono || otherFlags |> Array.exists (fun x -> x = "--simpleresolution") + runningOnMono #else - true + false #endif + || otherFlags |> Array.exists (fun x -> x = "--simpleresolution") + let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading let applyCompilerOptions tcConfigB = let collect _name = () diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config index 72e620e289..c42ff92628 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config +++ b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config @@ -4,8 +4,8 @@ - + diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/Program.fs b/tests/FSharp.Compiler.Service.Tests.netcore/Program.fs index 7922386aa0..45d9a34337 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/Program.fs +++ b/tests/FSharp.Compiler.Service.Tests.netcore/Program.fs @@ -8,7 +8,7 @@ type private TypeInThisAssembly = class end [] let main argv = - printfn "Testing...Testing...1...2...3..." + printfn "Dotnet Core NUnit Tests..." let writer = new ExtendedTextWrapper(Console.Out) let runner = new AutoRun(typeof.GetTypeInfo().Assembly) runner.Execute(argv, writer, Console.In) diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/project.json b/tests/FSharp.Compiler.Service.Tests.netcore/project.json index 1cf58efada..2b642a379f 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/project.json +++ b/tests/FSharp.Compiler.Service.Tests.netcore/project.json @@ -4,9 +4,12 @@ "compilerName": "fsc", "emitEntryPoint": true, "define": [ + "DOTNETCORE", + "FX_ATLEAST_45", "FX_ATLEAST_PORTABLE", "FX_NO_RUNTIMEENVIRONMENT", "FX_RESHAPED_REFLECTION", + "TODO_REWORK_ASSEMBLY_LOAD", "TRACE", ], "nowarn": [ @@ -27,27 +30,27 @@ "../service/FsUnit.fs", "../service/Common.fs", "../service/EditorTests.fs", + "../service/TokenizerTests.fs", "Program.fs", ], - "compileFiles_not_used": [ + "compileFiles_not_included_yet": [ "../service/FsiTests.fs", "../service/FscTests.fs", - "../service/TokenizerTests.fs", "../service/ProjectAnalysisTests.fs", "../service/ProjectOptionsTests.fs", - "../service/MultiProjectAnalysisTests.fs", "../service/PerfTests.fs", "../service/InteractiveCheckerTests.fs", - "../service/ExprTests.fs", + "../service/ExprTests.fs", "../service/FileSystemTests.fs", "../service/CSharpProjectAnalysis.fs", + "../service/MultiProjectAnalysisTests.fs", ], "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-*" + "version": "1.0.0-rc2-3002543" }, "Microsoft.FSharp.Core.netcore": "1.0.0-*", "FSharp.Compiler.Service.netcore": "1.0.0-*", diff --git a/tests/service/Common.fs b/tests/service/Common.fs index d6c9ed05d0..eaa3344e88 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -13,8 +13,52 @@ open ReflectionAdapters let checker = FSharpChecker.Create() let parseAndCheckScript (file, input) = - let checkOptions = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously - let parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, input, checkOptions) |> Async.RunSynchronously + +#if TODO_REWORK_ASSEMBLY_LOAD + let projectOptions = + + let references = [ + typeof.Assembly.Location; // mscorlib + typeof.Assembly.Location; // System.Runtime + typeof.Assembly.Location; // FSharp.Core + ] + + //printfn "references = %A" references + + let allFlags = [| + yield "--noframework"; + yield "--warn:3"; + //yield "--simpleresolution"; + //yield "--debug:full"; + //yield "--define:DEBUG"; + //yield "--optimize-"; + //yield "--doc:test.xml"; + //yield "--fullpaths"; + //yield "--flaterrors"; + //yield "--target:library"; + //yield "--targetprofile:netcore"; + for r in references do + yield "-r:" + r + |] + + { ProjectFileName = file + ".fsproj" + ProjectFileNames = [| file |] + OtherOptions = allFlags + ReferencedProjects = [| |]; + IsIncompleteTypeCheckEnvironment = false + UseScriptResolutionRules = true + LoadTime = System.DateTime.MaxValue // Not 'now', we don't want to force reloading + UnresolvedReferences = None } +#else + let projectOptions = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously +#endif + + let parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, input, projectOptions) |> Async.RunSynchronously + + // if parseResult.Errors.Length > 0 then + // printfn "---> Parse Input = %A" input + // printfn "---> Parse Error = %A" parseResult.Errors + match typedRes with | FSharpCheckFileAnswer.Succeeded(res) -> parseResult, res | res -> failwithf "Parsing did not finish... (%A)" res diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 85f5be6b69..407f7e56bc 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -34,6 +34,22 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open Microsoft.FSharp.Compiler.SimpleSourceCodeServices open FSharp.Compiler.Service.Tests.Common +let stringMethods = +#if DOTNETCORE + ["Chars"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith"; "Equals"; + "GetHashCode"; "GetType"; "GetTypeCode"; "IndexOf"; + "IndexOfAny"; "Insert"; "LastIndexOf"; "LastIndexOfAny"; + "Length"; "PadLeft"; "PadRight"; "Remove"; "Replace"; "Split"; + "StartsWith"; "Substring"; "ToCharArray"; "ToLower"; "ToLowerInvariant"; + "ToString"; "ToUpper"; "ToUpperInvariant"; "Trim"; "TrimEnd"; "TrimStart"] +#else + ["Chars"; "Clone"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith"; "Equals"; + "GetEnumerator"; "GetHashCode"; "GetType"; "GetTypeCode"; "IndexOf"; + "IndexOfAny"; "Insert"; "IsNormalized"; "LastIndexOf"; "LastIndexOfAny"; + "Length"; "Normalize"; "PadLeft"; "PadRight"; "Remove"; "Replace"; "Split"; + "StartsWith"; "Substring"; "ToCharArray"; "ToLower"; "ToLowerInvariant"; + "ToString"; "ToUpper"; "ToUpperInvariant"; "Trim"; "TrimEnd"; "TrimStart"] +#endif let input = """ @@ -69,13 +85,8 @@ let ``Intro test`` () = (sprintf "%A" tip).Replace("\n","") |> shouldEqual """FSharpToolTipText [Single ("val foo : unit -> unitFull name: Test.foo",None)]""" // Get declarations (autocomplete) for a location let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, 23, inputLines.[6], [], "msg", fun _ -> false)|> Async.RunSynchronously - [ for item in decls.Items -> item.Name ] |> shouldEqual - ["Chars"; "Clone"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith"; "Equals"; - "GetEnumerator"; "GetHashCode"; "GetType"; "GetTypeCode"; "IndexOf"; - "IndexOfAny"; "Insert"; "IsNormalized"; "LastIndexOf"; "LastIndexOfAny"; - "Length"; "Normalize"; "PadLeft"; "PadRight"; "Remove"; "Replace"; "Split"; - "StartsWith"; "Substring"; "ToCharArray"; "ToLower"; "ToLowerInvariant"; - "ToString"; "ToUpper"; "ToUpperInvariant"; "Trim"; "TrimEnd"; "TrimStart"] + [ for item in decls.Items -> item.Name ] |> shouldEqual stringMethods + // Get overloads of the String.Concat method let methods = typeCheckResults.GetMethodsAlternate(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously @@ -247,14 +258,8 @@ let ``Expression typing test`` () = // for col in 42..43 do let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 2, col, inputLines.[1], [], "", fun _ -> false)|> Async.RunSynchronously - set [ for item in decls.Items -> item.Name ] |> shouldEqual - (set - ["Chars"; "Clone"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith"; "Equals"; - "GetEnumerator"; "GetHashCode"; "GetType"; "GetTypeCode"; "IndexOf"; - "IndexOfAny"; "Insert"; "IsNormalized"; "LastIndexOf"; "LastIndexOfAny"; - "Length"; "Normalize"; "PadLeft"; "PadRight"; "Remove"; "Replace"; "Split"; - "StartsWith"; "Substring"; "ToCharArray"; "ToLower"; "ToLowerInvariant"; - "ToString"; "ToUpper"; "ToUpperInvariant"; "Trim"; "TrimEnd"; "TrimStart"]) + let autoCompleteSet = set [ for item in decls.Items -> item.Name ] + autoCompleteSet |> shouldEqual (set stringMethods) // The underlying problem is that the parser error recovery doesn't include _any_ information for // the incomplete member: @@ -274,11 +279,7 @@ type Test() = let parseResult, typeCheckResults = parseAndCheckScript(file, input) let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, 21, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously - let item = decls.Items |> Array.tryFind (fun d -> d.Name = "abc") - match item with - | Some item -> - printf "%s" item.Name - | _ -> () + //decls.Items |> Array.map (fun d -> d.Name) |> printfn "---> decls.Items = %A" decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true [] @@ -295,11 +296,7 @@ type Test() = let parseResult, typeCheckResults = parseAndCheckScript(file, input) let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, 22, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously - let item = decls.Items |> Array.tryFind (fun d -> d.Name = "abc") - match item with - | Some item -> - printf "%s" item.Name - | _ -> () + //decls.Items |> Array.map (fun d -> d.Name) |> printfn "---> decls.Items = %A" decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true [] @@ -316,6 +313,7 @@ type Test() = let parseResult, typeCheckResults = parseAndCheckScript(file, input) let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, 15, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously + //decls.Items |> Array.map (fun d -> d.Name) |> printfn "---> decls.Items = %A" decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true [] @@ -332,12 +330,7 @@ type Test() = let parseResult, typeCheckResults = parseAndCheckScript(file, input) let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, 21, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously - let item = decls |> List.tryFind (fun d -> d.Head.Symbol.DisplayName = "abc") - match item with - | Some items -> - for symbolUse in items do - printf "%s" symbolUse.Symbol.DisplayName - | _ -> () + //decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A" decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true [] @@ -354,14 +347,8 @@ type Test() = let parseResult, typeCheckResults = parseAndCheckScript(file, input) let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, 22, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously - let item = decls |> List.tryFind (fun d -> d.Head.Symbol.DisplayName = "abc") - match item with - | Some items -> - for symbolUse in items do - printf "%s" symbolUse.Symbol.DisplayName - | _ -> () + //decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A" decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true - true |> should equal true [] let ``Symbol based find function from var`` () = @@ -377,7 +364,8 @@ type Test() = let parseResult, typeCheckResults = parseAndCheckScript(file, input) let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, 15, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously - decls|> Seq .exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true + //decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A" + decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true [] let ``Printf specifiers for regular and verbatim strings`` () = From b134b1f5de6a681e1d5d727482c144b9eb9b5a44 Mon Sep 17 00:00:00 2001 From: ncave Date: Sun, 1 May 2016 21:32:49 -0700 Subject: [PATCH 03/17] Revert change --- src/fsharp/CompileOps.fs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index e197b3a7d0..04af230c0a 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -4848,7 +4848,6 @@ module private ScriptPreprocessClosure = #else | CodeContext.Compilation | CodeContext.Evaluation -> MSBuildResolver.CompileTimeLike #endif - tcConfigB.useMonoResolution <- useMonoResolution tcConfigB.framework <- false // Indicates that there are some references not in BasicReferencesForScriptLoadClosure which should // be added conditionally once the relevant version of mscorlib.dll has been detected. From da9c67b346bfca60100602758fb19655fcb0a864 Mon Sep 17 00:00:00 2001 From: ncave Date: Sun, 1 May 2016 23:10:21 -0700 Subject: [PATCH 04/17] Revert change --- src/fsharp/vs/service.fs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index db8c55bb9c..397ea0eef2 100644 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -2530,12 +2530,10 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun let otherFlags = defaultArg otherFlags [| |] let useMonoResolution = #if ENABLE_MONO_SUPPORT - runningOnMono + runningOnMono || otherFlags |> Array.exists (fun x -> x = "--simpleresolution") #else - false + true #endif - || otherFlags |> Array.exists (fun x -> x = "--simpleresolution") - let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading let applyCompilerOptions tcConfigB = let collect _name = () From 74c74a6c668c5d9716ddb7a7afc6d1cf28067a23 Mon Sep 17 00:00:00 2001 From: ncave Date: Sun, 1 May 2016 23:51:06 -0700 Subject: [PATCH 05/17] Revert change --- tests/service/FsiTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/service/FsiTests.fs b/tests/service/FsiTests.fs index 69ff9e4770..5ebc67b720 100644 --- a/tests/service/FsiTests.fs +++ b/tests/service/FsiTests.fs @@ -27,7 +27,7 @@ let errStream = new CompilerOutputStream() let argv = [| "C:\\fsi.exe" |] let allArgs = Array.append argv [|"--noninteractive"|] -let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration() //(fsi) +let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration(fsi) let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, new StreamWriter(outStream), new StreamWriter(errStream)) /// Evaluate expression & return the result From b3d4bcc496d94ee4bf990fa6f270e4a4c0bcfca5 Mon Sep 17 00:00:00 2001 From: ncave Date: Mon, 2 May 2016 01:30:01 -0700 Subject: [PATCH 06/17] Test Common update --- src/fsharp/ReferenceResolution.fs | 1 - .../project.json | 8 +- tests/service/Common.fs | 91 +++++++------------ 3 files changed, 38 insertions(+), 62 deletions(-) diff --git a/src/fsharp/ReferenceResolution.fs b/src/fsharp/ReferenceResolution.fs index 7daa7ea16e..353badb8ac 100644 --- a/src/fsharp/ReferenceResolution.fs +++ b/src/fsharp/ReferenceResolution.fs @@ -40,7 +40,6 @@ module internal MSBuildResolver = open Microsoft.Build.Tasks open Microsoft.Build.Utilities open Microsoft.Build.Framework - //open Microsoft.Build.BuildEngine open System.IO open System.Reflection diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/project.json b/tests/FSharp.Compiler.Service.Tests.netcore/project.json index 2b642a379f..26a724ef67 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/project.json +++ b/tests/FSharp.Compiler.Service.Tests.netcore/project.json @@ -31,18 +31,18 @@ "../service/Common.fs", "../service/EditorTests.fs", "../service/TokenizerTests.fs", - + "../service/ProjectAnalysisTests.fs", + "../service/InteractiveCheckerTests.fs", + "Program.fs", ], "compileFiles_not_included_yet": [ "../service/FsiTests.fs", "../service/FscTests.fs", - "../service/ProjectAnalysisTests.fs", "../service/ProjectOptionsTests.fs", "../service/PerfTests.fs", - "../service/InteractiveCheckerTests.fs", - "../service/ExprTests.fs", + "../service/FileSystemTests.fs", "../service/CSharpProjectAnalysis.fs", "../service/MultiProjectAnalysisTests.fs", diff --git a/tests/service/Common.fs b/tests/service/Common.fs index eaa3344e88..7c0108a2ab 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -9,46 +9,46 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open ReflectionAdapters #endif +let mkProjectCommandLineArgs (dllName, fileNames) = + [| yield "--simpleresolution" + yield "--noframework" + yield "--debug:full" + yield "--define:DEBUG" + yield "--optimize-" + yield "--out:" + dllName + yield "--doc:test.xml" + yield "--warn:3" + yield "--fullpaths" + yield "--flaterrors" + yield "--target:library" + for x in fileNames do + yield x + let references = +#if TODO_REWORK_ASSEMBLY_LOAD + [ yield typeof.Assembly.Location; // mscorlib + yield typeof.Assembly.Location; // System.Runtime + yield typeof.Assembly.Location; // FSharp.Core + ] +#else + [ yield sysLib "mscorlib" + yield sysLib "System" + yield sysLib "System.Core" + yield fsCoreDefaultReference() ] +#endif + for r in references do + yield "-r:" + r + |] + // Create one global interactive checker instance let checker = FSharpChecker.Create() let parseAndCheckScript (file, input) = #if TODO_REWORK_ASSEMBLY_LOAD - let projectOptions = - - let references = [ - typeof.Assembly.Location; // mscorlib - typeof.Assembly.Location; // System.Runtime - typeof.Assembly.Location; // FSharp.Core - ] - - //printfn "references = %A" references - - let allFlags = [| - yield "--noframework"; - yield "--warn:3"; - //yield "--simpleresolution"; - //yield "--debug:full"; - //yield "--define:DEBUG"; - //yield "--optimize-"; - //yield "--doc:test.xml"; - //yield "--fullpaths"; - //yield "--flaterrors"; - //yield "--target:library"; - //yield "--targetprofile:netcore"; - for r in references do - yield "-r:" + r - |] - - { ProjectFileName = file + ".fsproj" - ProjectFileNames = [| file |] - OtherOptions = allFlags - ReferencedProjects = [| |]; - IsIncompleteTypeCheckEnvironment = false - UseScriptResolutionRules = true - LoadTime = System.DateTime.MaxValue // Not 'now', we don't want to force reloading - UnresolvedReferences = None } + let dllName = Path.ChangeExtension(file, ".dll") + let projName = Path.ChangeExtension(file, ".fsproj") + let args = mkProjectCommandLineArgs (dllName, [file]) + let projectOptions = checker.GetProjectOptionsFromCommandLineArgs (projName, args) #else let projectOptions = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously #endif @@ -112,29 +112,6 @@ let fsCoreDefaultReference() = #endif sysLib "FSharp.Core" - -let mkProjectCommandLineArgs (dllName, fileNames) = - [| yield "--simpleresolution" - yield "--noframework" - yield "--debug:full" - yield "--define:DEBUG" - yield "--optimize-" - yield "--out:" + dllName - yield "--doc:test.xml" - yield "--warn:3" - yield "--fullpaths" - yield "--flaterrors" - yield "--target:library" - for x in fileNames do - yield x - let references = - [ yield sysLib "mscorlib" - yield sysLib "System" - yield sysLib "System.Core" - yield fsCoreDefaultReference() ] - for r in references do - yield "-r:" + r |] - /// Extract range info let tups (m:Range.range) = (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn) From bf23e71ced86f617a4e7484834ee72cd3dc2fb4e Mon Sep 17 00:00:00 2001 From: ncave Date: Mon, 2 May 2016 01:47:24 -0700 Subject: [PATCH 07/17] Test Common update --- tests/service/Common.fs | 102 ++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 7c0108a2ab..5936b5edfd 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -9,60 +9,9 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open ReflectionAdapters #endif -let mkProjectCommandLineArgs (dllName, fileNames) = - [| yield "--simpleresolution" - yield "--noframework" - yield "--debug:full" - yield "--define:DEBUG" - yield "--optimize-" - yield "--out:" + dllName - yield "--doc:test.xml" - yield "--warn:3" - yield "--fullpaths" - yield "--flaterrors" - yield "--target:library" - for x in fileNames do - yield x - let references = -#if TODO_REWORK_ASSEMBLY_LOAD - [ yield typeof.Assembly.Location; // mscorlib - yield typeof.Assembly.Location; // System.Runtime - yield typeof.Assembly.Location; // FSharp.Core - ] -#else - [ yield sysLib "mscorlib" - yield sysLib "System" - yield sysLib "System.Core" - yield fsCoreDefaultReference() ] -#endif - for r in references do - yield "-r:" + r - |] - // Create one global interactive checker instance let checker = FSharpChecker.Create() -let parseAndCheckScript (file, input) = - -#if TODO_REWORK_ASSEMBLY_LOAD - let dllName = Path.ChangeExtension(file, ".dll") - let projName = Path.ChangeExtension(file, ".fsproj") - let args = mkProjectCommandLineArgs (dllName, [file]) - let projectOptions = checker.GetProjectOptionsFromCommandLineArgs (projName, args) -#else - let projectOptions = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously -#endif - - let parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, input, projectOptions) |> Async.RunSynchronously - - // if parseResult.Errors.Length > 0 then - // printfn "---> Parse Input = %A" input - // printfn "---> Parse Error = %A" parseResult.Errors - - match typedRes with - | FSharpCheckFileAnswer.Succeeded(res) -> parseResult, res - | res -> failwithf "Parsing did not finish... (%A)" res - type TempFile(ext, contents) = let tmpFile = Path.ChangeExtension(System.IO.Path.GetTempFileName() , ext) do File.WriteAllText(tmpFile, contents) @@ -112,6 +61,57 @@ let fsCoreDefaultReference() = #endif sysLib "FSharp.Core" +let mkProjectCommandLineArgs (dllName, fileNames) = + [| yield "--simpleresolution" + yield "--noframework" + yield "--debug:full" + yield "--define:DEBUG" + yield "--optimize-" + yield "--out:" + dllName + yield "--doc:test.xml" + yield "--warn:3" + yield "--fullpaths" + yield "--flaterrors" + yield "--target:library" + for x in fileNames do + yield x + let references = +#if TODO_REWORK_ASSEMBLY_LOAD + [ yield typeof.Assembly.Location; // mscorlib + yield typeof.Assembly.Location; // System.Runtime + yield typeof.Assembly.Location; // FSharp.Core + ] +#else + [ yield sysLib "mscorlib" + yield sysLib "System" + yield sysLib "System.Core" + yield fsCoreDefaultReference() ] +#endif + for r in references do + yield "-r:" + r + |] + +let parseAndCheckScript (file, input) = + +#if TODO_REWORK_ASSEMBLY_LOAD + let dllName = Path.ChangeExtension(file, ".dll") + let projName = Path.ChangeExtension(file, ".fsproj") + let args = mkProjectCommandLineArgs (dllName, [file]) + let projectOptions = checker.GetProjectOptionsFromCommandLineArgs (projName, args) +#else + let projectOptions = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously +#endif + + let parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, input, projectOptions) |> Async.RunSynchronously + + // if parseResult.Errors.Length > 0 then + // printfn "---> Parse Input = %A" input + // printfn "---> Parse Error = %A" parseResult.Errors + + match typedRes with + | FSharpCheckFileAnswer.Succeeded(res) -> parseResult, res + | res -> failwithf "Parsing did not finish... (%A)" res + /// Extract range info let tups (m:Range.range) = (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn) From 5b37b4276a89fa82c070bab252ab84c219462637 Mon Sep 17 00:00:00 2001 From: ncave Date: Tue, 3 May 2016 09:39:39 -0700 Subject: [PATCH 08/17] Added ExprTests --- src/fsharp/FSharp.Compiler.Service.netcore/project.json | 2 +- tests/FSharp.Compiler.Service.Tests.netcore/project.json | 4 ++-- tests/service/ExprTests.fs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.netcore/project.json index ae3a70c1a3..6ae0b4d620 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/project.json +++ b/src/fsharp/FSharp.Compiler.Service.netcore/project.json @@ -258,7 +258,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002543" + "version": "1.0.0-rc2-*" }, "Microsoft.Build.Framework": "0.1.0-*", "Microsoft.Build.Tasks.Core": "0.1.0-*", diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/project.json b/tests/FSharp.Compiler.Service.Tests.netcore/project.json index 26a724ef67..f0987cbd64 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/project.json +++ b/tests/FSharp.Compiler.Service.Tests.netcore/project.json @@ -30,6 +30,7 @@ "../service/FsUnit.fs", "../service/Common.fs", "../service/EditorTests.fs", + "../service/ExprTests.fs", "../service/TokenizerTests.fs", "../service/ProjectAnalysisTests.fs", "../service/InteractiveCheckerTests.fs", @@ -41,7 +42,6 @@ "../service/FscTests.fs", "../service/ProjectOptionsTests.fs", "../service/PerfTests.fs", - "../service/ExprTests.fs", "../service/FileSystemTests.fs", "../service/CSharpProjectAnalysis.fs", @@ -50,7 +50,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002543" + "version": "1.0.0-rc2-*" }, "Microsoft.FSharp.Core.netcore": "1.0.0-*", "FSharp.Compiler.Service.netcore": "1.0.0-*", diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index e3da4bf9c2..b870541091 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -741,6 +741,8 @@ let ``Test expressions of declarations stress big expressions`` () = printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> ignore +#if SELF_HOST_STRESS + #if FX_ATLEAST_45 [] @@ -792,8 +794,6 @@ let ``Check use of type provider that provides calls to F# code`` () = #endif -#if SELF_HOST_STRESS - [] let ``Test Declarations selfhost`` () = let projectFile = __SOURCE_DIRECTORY__ + @"/FSharp.Compiler.Service.Tests.fsproj" From 3712b2c16c5d56d461e415a350ed6e112c601162 Mon Sep 17 00:00:00 2001 From: ncave Date: Thu, 5 May 2016 04:15:51 -0700 Subject: [PATCH 09/17] Added build matrix --- appveyor.yml | 28 +++++++++++++++++-- build.fsx | 7 ++++- .../NuGet.Config | 1 + .../project.json | 14 +++++++--- .../NuGet.Config | 1 + .../project.json | 14 +++++++--- 6 files changed, 54 insertions(+), 11 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index cab243c517..9aa73a54aa 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,32 @@ -os: Windows Server 2012 R2 init: - git config --global core.autocrlf input + +environment: + CLI_VERSION: 1.0.0-rc2-002673 + #CLI_VERSION: Latest + matrix: + - BUILD_TARGET: DotnetCliTests + - BUILD_TARGET: NuGet + +matrix: + allow_failures: + - BUILD_TARGET: DotnetCliTests + +install: + # Download install script to install .NET cli in .dotnet dir + - ps: mkdir -Force ".\scripts\obtain\" | Out-Null + - ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1" -OutFile ".\scripts\obtain\install.ps1" + - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli" + - ps: '& .\scripts\obtain\install.ps1 -Channel "preview" -version "Latest" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath' + # add dotnet to PATH + - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" + # show dotnet info + - ps: 'echo "Dotnet: $( (gcm dotnet).Path )"' + - ps: dotnet --info + build_script: - - cmd: build.cmd NuGet + - cmd: build.cmd %BUILD_TARGET% + test: off version: '{build}' artifacts: diff --git a/build.fsx b/build.fsx index fd6595656c..17dba5c4bf 100644 --- a/build.fsx +++ b/build.fsx @@ -252,6 +252,7 @@ Target "DotnetCliTests" (fun _ -> Shell.Exec("dotnet", "restore", workDir) |> ignore //assertExitCodeZero Shell.Exec("dotnet", "run", workDir) |> assertExitCodeZero ) + // -------------------------------------------------------------------------------------- // Run all targets by default. Invoke 'build ' to override @@ -259,13 +260,17 @@ Target "Prepare" DoNothing Target "PrepareRelease" DoNothing Target "All" DoNothing Target "Release" DoNothing +Target "AllDotnetCli" DoNothing + +"AllDotnetCli" + =?> ("DotnetCliBuild", isDotnetCliInstalled) + =?> ("DotnetCliTests", isDotnetCliInstalled) "Clean" =?> ("BuildVersion", isAppVeyorBuild) ==> "AssemblyInfo" ==> "GenerateFSIStrings" ==> "Prepare" - =?> ("DotnetCliBuild", isDotnetCliInstalled) ==> "Build" ==> "RunTests" ==> "All" diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config b/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config index e6b6a3baff..bc88667e08 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config +++ b/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config @@ -7,6 +7,7 @@ + diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.netcore/project.json index 6ae0b4d620..2b6adce9f4 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/project.json +++ b/src/fsharp/FSharp.Compiler.Service.netcore/project.json @@ -256,23 +256,29 @@ "../fsi/fsi.fs" ], "dependencies": { + "Microsoft.FSharp.Core.netcore": "1.0.0-*", "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-*" + "version": "1.0.0-rc2-3002673" }, "Microsoft.Build.Framework": "0.1.0-*", "Microsoft.Build.Tasks.Core": "0.1.0-*", "Microsoft.Build.Utilities.Core": "0.1.0-*", - "Microsoft.FSharp.Core.netcore": "1.0.0-*", }, "tools": { "dotnet-fssrgen": "3.0.1", - "dotnet-compile-fsc": "1.0.0-*" + "dotnet-compile-fsc": { + "version": "1.0.0-rc2-*", + "imports": [ + "dnxcore50", + "portable-net45+win81", + "netstandard1.3" + ] + } }, "frameworks": { "netstandard1.5": { "imports": [ - "portable-net45+win8", "dnxcore50" ] } diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config index c42ff92628..9d4bfde0b9 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config +++ b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config @@ -6,6 +6,7 @@ + diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/project.json b/tests/FSharp.Compiler.Service.Tests.netcore/project.json index f0987cbd64..dfaf907ac4 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/project.json +++ b/tests/FSharp.Compiler.Service.Tests.netcore/project.json @@ -48,21 +48,27 @@ "../service/MultiProjectAnalysisTests.fs", ], "dependencies": { + "Microsoft.FSharp.Core.netcore": "1.0.0-*", "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-*" + "version": "1.0.0-rc2-3002673" }, - "Microsoft.FSharp.Core.netcore": "1.0.0-*", "FSharp.Compiler.Service.netcore": "1.0.0-*", "NUnitLite": "3.2.1", }, "tools": { - "dotnet-compile-fsc": "1.0.0-*" + "dotnet-compile-fsc": { + "version": "1.0.0-rc2-*", + "imports": [ + "dnxcore50", + "portable-net45+win81", + "netstandard1.3" + ] + } }, "frameworks": { "netstandard1.5": { "imports": [ - "portable-net45+win8", "dnxcore50" ] } From 593cae8d6039f8bfda84388f36627345e422d313 Mon Sep 17 00:00:00 2001 From: ncave Date: Thu, 5 May 2016 08:10:12 -0700 Subject: [PATCH 10/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93e2b25191..93ad38cd35 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Build Status Head (branch ``master``), Mono 3.x, OSX + unit tests (Travis) [![Build Status](https://travis-ci.org/fsharp/FSharp.Compiler.Service.png?branch=master)](https://travis-ci.org/fsharp/FSharp.Compiler.Service/branches) -Head (branch ``master``), Windows Server 2012 R2 + unit tests (AppVeyor) [![Build status](https://ci.appveyor.com/api/projects/status/3yllu2qh19brk61d)](https://ci.appveyor.com/project/fsgit/fsharp-compiler-service) +Head (branch ``master``), Windows Server 2012 R2 + unit tests (AppVeyor) [![Build status](https://ci.appveyor.com/api/projects/status/3yllu2qh19brk61d?svg=true)](https://ci.appveyor.com/project/fsgit/fsharp-compiler-service) NuGet Feed [![NuGet Badge](https://buildstats.info/nuget/FSharp.Compiler.Service)](https://www.nuget.org/packages/FSharp.Compiler.Service) From 8f49e3dd60009fedeb5f3918bece0095f888f6f8 Mon Sep 17 00:00:00 2001 From: ncave Date: Tue, 10 May 2016 13:08:52 -0700 Subject: [PATCH 11/17] Added ProjectCracker --- appveyor.yml | 2 +- build.fsx | 15 +- .../NuGet.Config | 13 + .../Program.fs | 21 + .../ProjectCracker.fs | 47 +++ .../ProjectCrackerOptions.fs | 10 + .../ProjectCrackerTool.fs | 361 ++++++++++++++++++ .../project.json | 60 +++ .../project.json | 351 ++++++++--------- src/fsharp/vs/Reactor.fs | 7 - .../NuGet.Config | 5 +- .../project.json | 57 +-- tests/service/EditorTests.fs | 10 +- tests/service/ExprTests.fs | 4 +- tests/service/FileSystemTests.fs | 4 + tests/service/FsiTests.fs | 4 + tests/service/ProjectOptionsTests.fs | 2 +- 17 files changed, 752 insertions(+), 221 deletions(-) create mode 100644 src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/NuGet.Config create mode 100644 src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/Program.fs create mode 100644 src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs create mode 100644 src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerOptions.fs create mode 100644 src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerTool.fs create mode 100644 src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json diff --git a/appveyor.yml b/appveyor.yml index 9aa73a54aa..285321c274 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ init: - git config --global core.autocrlf input environment: - CLI_VERSION: 1.0.0-rc2-002673 + CLI_VERSION: 1.0.0-rc2-002678 #CLI_VERSION: Latest matrix: - BUILD_TARGET: DotnetCliTests diff --git a/build.fsx b/build.fsx index 17dba5c4bf..ae56334879 100644 --- a/build.fsx +++ b/build.fsx @@ -230,10 +230,10 @@ Target "DotnetCliBuild" (fun _ -> let open1 = @" --open Microsoft.FSharp.Compiler.AbstractIL" let open2 = @" --open Microsoft.FSharp.Compiler" let open3 = @" --open Microsoft.FSharp.Compiler" - let options = " --configuration Release" - + + // FSharp.Compiler.Service let workDir = @"src/fsharp/FSharp.Compiler.Service.netcore/" - Shell.Exec("dotnet", "restore", workDir) |> ignore //assertExitCodeZero + Shell.Exec("dotnet", "restore -v Minimal", workDir) |> assertExitCodeZero Shell.Exec("dotnet", "fssrgen ../FSComp.txt ./FSComp.fs ./FSComp.resx", workDir) |> assertExitCodeZero Shell.Exec("dotnet", "fssrgen ../fsi/FSIstrings.txt ./FSIstrings.fs ./FSIstrings.resx", workDir) |> assertExitCodeZero @@ -244,12 +244,17 @@ Target "DotnetCliBuild" (fun _ -> Shell.Exec(fsYacc, @"../pars.fsy" + lexArgs + yaccArgs + module2 + open2 + " -o pars.fs", workDir) |> assertExitCodeZero Shell.Exec(fsYacc, @"../pppars.fsy" + lexArgs + yaccArgs + module3 + open3 + " -o pppars.fs", workDir) |> assertExitCodeZero - Shell.Exec("dotnet", "--verbose pack" + options, workDir) |> assertExitCodeZero + Shell.Exec("dotnet", "pack -c Release", workDir) |> assertExitCodeZero + + // FSharp.Compiler.Service.ProjectCracker + let workDir = @"src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/" + Shell.Exec("dotnet", "restore -v Minimal", workDir) |> assertExitCodeZero + Shell.Exec("dotnet", "pack -c Release", workDir) |> assertExitCodeZero ) Target "DotnetCliTests" (fun _ -> let workDir = @"tests/FSharp.Compiler.Service.Tests.netcore/" - Shell.Exec("dotnet", "restore", workDir) |> ignore //assertExitCodeZero + Shell.Exec("dotnet", "restore -v Minimal", workDir) |> assertExitCodeZero Shell.Exec("dotnet", "run", workDir) |> assertExitCodeZero ) diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/NuGet.Config b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/NuGet.Config new file mode 100644 index 0000000000..3868a20e87 --- /dev/null +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/NuGet.Config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/Program.fs b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/Program.fs new file mode 100644 index 0000000000..ed8a8b1599 --- /dev/null +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/Program.fs @@ -0,0 +1,21 @@ +namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool + +open System +open System.IO +open System.Runtime.Serialization.Json + +module Program = + + [] + let main argv = + let text = Array.exists (fun (s: string) -> s = "--text") argv + let argv = Array.filter (fun (s: string) -> s <> "--text") argv + + let ret, opts = ProjectCrackerTool.crackOpen argv + + if text then + printfn "%A" opts + else + let ser = new DataContractJsonSerializer(typeof) + ser.WriteObject(Console.OpenStandardOutput(), opts) + ret diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs new file mode 100644 index 0000000000..bb5eccabb3 --- /dev/null +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs @@ -0,0 +1,47 @@ +namespace Microsoft.FSharp.Compiler.SourceCodeServices + +open System +open System.IO +open System.Text +open Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool + + +type ProjectCracker = + + static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) = + let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading + let properties = defaultArg properties [] + let enableLogging = defaultArg enableLogging true + let logMap = ref Map.empty + + let rec convert (opts: ProjectOptions) : FSharpProjectOptions = + let referencedProjects = Array.map (fun (a, b) -> a, convert b) opts.ReferencedProjectOptions + logMap := Map.add opts.ProjectFile opts.LogOutput !logMap + { + ProjectFileName = opts.ProjectFile + ProjectFileNames = [| |] + OtherOptions = opts.Options + ReferencedProjects = referencedProjects + IsIncompleteTypeCheckEnvironment = false + UseScriptResolutionRules = false + LoadTime = loadedTimeStamp + UnresolvedReferences = None + } + + let arguments = [| + yield @"""" + projectFileName + @"""" + yield enableLogging.ToString() + for k, v in properties do + yield k + yield v + |] + + let ret, opts = ProjectCrackerTool.crackOpen arguments + convert opts, !logMap + + static member GetProjectOptionsFromProjectFile(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp) = + fst (ProjectCracker.GetProjectOptionsFromProjectFileLogged( + projectFileName, + ?properties=properties, + ?loadedTimeStamp=loadedTimeStamp, + enableLogging=false)) diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerOptions.fs b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerOptions.fs new file mode 100644 index 0000000000..34f3aa16e7 --- /dev/null +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerOptions.fs @@ -0,0 +1,10 @@ +namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool + +[] +type ProjectOptions = + { + ProjectFile: string + Options: string[] + ReferencedProjectOptions: (string * ProjectOptions)[] + LogOutput: string + } diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerTool.fs b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerTool.fs new file mode 100644 index 0000000000..1d2f5ee4aa --- /dev/null +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerTool.fs @@ -0,0 +1,361 @@ +namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool + +open System +open System.IO +open System.Reflection +open System.Text +open Microsoft.Build.Framework +open Microsoft.Build.Utilities + +module internal ProjectCrackerTool = + + type internal BasicStringLogger() = + inherit Logger() + + let sb = new StringBuilder() + + let log (e: BuildEventArgs) = + sb.Append(e.Message) |> ignore + sb.AppendLine() |> ignore + + override x.Initialize(eventSource:IEventSource) = + sb.Clear() |> ignore + eventSource.AnyEventRaised.Add(log) + + member x.Log = sb.ToString() + + type internal HostCompile() = + member th.Compile(_:obj, _:obj, _:obj) = 0 + interface ITaskHost + + //---------------------------------------------------------------------------- + // FSharpProjectFileInfo + // + [] + type FSharpProjectFileInfo (fsprojFileName:string, ?properties, ?enableLogging) = + + let properties = defaultArg properties [] + let enableLogging = defaultArg enableLogging false + let mkAbsolute dir v = + if Path.IsPathRooted v then v + else Path.Combine(dir, v) + + let mkAbsoluteOpt dir v = Option.map (mkAbsolute dir) v + + let logOpt = + if enableLogging then + let log = new BasicStringLogger() + do log.Verbosity <- Microsoft.Build.Framework.LoggerVerbosity.Diagnostic + Some log + else + None + + let vs = + let programFiles = + let getEnv v = + let result = System.Environment.GetEnvironmentVariable(v) + match result with + | null -> None + | _ -> Some result + + match List.tryPick getEnv [ "ProgramFiles(x86)"; "ProgramFiles" ] with + | Some r -> r + | None -> "C:\\Program Files (x86)" + + let vsVersions = ["14.0"; "12.0"] + let msbuildBin v = IO.Path.Combine(programFiles, "MSBuild", v, "Bin", "MSBuild.exe") + List.tryFind (fun v -> IO.File.Exists(msbuildBin v)) vsVersions + + let CrackProjectUsingNewBuildAPI(fsprojFile) = + let fsprojFullPath = try Path.GetFullPath(fsprojFile) with _ -> fsprojFile + let fsprojAbsDirectory = Path.GetDirectoryName fsprojFullPath + + use _pwd = + let dir = Directory.GetCurrentDirectory() + Directory.SetCurrentDirectory(fsprojAbsDirectory) + { new System.IDisposable with + member x.Dispose() = Directory.SetCurrentDirectory(dir) } + use engine = new Microsoft.Build.Evaluation.ProjectCollection() + let host = new HostCompile() + engine.HostServices.RegisterHostObject(fsprojFullPath, "CoreCompile", "Fsc", host) + + + let projectInstanceFromFullPath (fsprojFullPath: string) = + use file = new FileStream(fsprojFullPath,FileMode.Open,FileAccess.Read,FileShare.ReadWrite) + use stream = new StreamReader(file) + use xmlReader = System.Xml.XmlReader.Create(stream) + + let project = engine.LoadProject(xmlReader, FullPath=fsprojFullPath) + + project.SetGlobalProperty("BuildingInsideVisualStudio", "true") |> ignore + if not (List.exists (fun (p,_) -> p = "VisualStudioVersion") properties) then + match vs with + | Some version -> project.SetGlobalProperty("VisualStudioVersion", version) |> ignore + | None -> () + project.SetGlobalProperty("ShouldUnsetParentConfigurationAndPlatform", "false") |> ignore + for (prop, value) in properties do + project.SetGlobalProperty(prop, value) |> ignore + + project.CreateProjectInstance() + + let project = projectInstanceFromFullPath fsprojFullPath + let directory = project.Directory + + let getprop (p: Microsoft.Build.Execution.ProjectInstance) s = + let v = p.GetPropertyValue s + if String.IsNullOrWhiteSpace v then None + else Some v + + let outFileOpt = getprop project "TargetPath" + + let log = match logOpt with + | None -> [] + | Some l -> [l :> ILogger] + + project.Build([| "Build" |], log) |> ignore + + let getItems s = [ for f in project.GetItems(s) -> mkAbsolute directory f.EvaluatedInclude ] + + let projectReferences = + [ for cp in project.GetItems("ProjectReference") do + yield cp.GetMetadataValue("FullPath") + ] + + let references = + [ for i in project.GetItems("ReferencePath") do + yield i.EvaluatedInclude + for i in project.GetItems("ChildProjectReferences") do + yield i.EvaluatedInclude ] + + outFileOpt, directory, getItems, references, projectReferences, getprop project, project.FullPath + + let outFileOpt, directory, getItems, references, projectReferences, getProp, fsprojFullPath = + try + CrackProjectUsingNewBuildAPI(fsprojFileName) + with + | :? ArgumentException as e -> raise (IO.FileNotFoundException(e.Message)) + + let logOutput = match logOpt with None -> "" | Some l -> l.Log + let pages = getItems "Page" + let embeddedResources = getItems "EmbeddedResource" + let files = getItems "Compile" + let resources = getItems "Resource" + let noaction = getItems "None" + let content = getItems "Content" + + let split (s : string option) (cs : char []) = + match s with + | None -> [||] + | Some s -> + if String.IsNullOrWhiteSpace s then [||] + else s.Split(cs, StringSplitOptions.RemoveEmptyEntries) + + let getbool (s : string option) = + match s with + | None -> false + | Some s -> + match (Boolean.TryParse s) with + | (true, result) -> result + | (false, _) -> false + + let fxVer = getProp "TargetFrameworkVersion" + let optimize = getProp "Optimize" |> getbool + let assemblyNameOpt = getProp "AssemblyName" + let tailcalls = getProp "Tailcalls" |> getbool + let outputPathOpt = getProp "OutputPath" + let docFileOpt = getProp "DocumentationFile" + let outputTypeOpt = getProp "OutputType" + let debugTypeOpt = getProp "DebugType" + let baseAddressOpt = getProp "BaseAddress" + let sigFileOpt = getProp "GenerateSignatureFile" + let keyFileOpt = getProp "KeyFile" + let pdbFileOpt = getProp "PdbFile" + let platformOpt = getProp "Platform" + let targetTypeOpt = getProp "TargetType" + let versionFileOpt = getProp "VersionFile" + let targetProfileOpt = getProp "TargetProfile" + let warnLevelOpt = getProp "Warn" + let subsystemVersionOpt = getProp "SubsystemVersion" + let win32ResOpt = getProp "Win32ResourceFile" + let heOpt = getProp "HighEntropyVA" |> getbool + let win32ManifestOpt = getProp "Win32ManifestFile" + let debugSymbols = getProp "DebugSymbols" |> getbool + let prefer32bit = getProp "Prefer32Bit" |> getbool + let warnAsError = getProp "TreatWarningsAsErrors" |> getbool + let defines = split (getProp "DefineConstants") [| ';'; ','; ' ' |] + let nowarn = split (getProp "NoWarn") [| ';'; ','; ' ' |] + let warningsAsError = split (getProp "WarningsAsErrors") [| ';'; ','; ' ' |] + let libPaths = split (getProp "ReferencePath") [| ';'; ',' |] + let otherFlags = split (getProp "OtherFlags") [| ' ' |] + let isLib = (outputTypeOpt = Some "Library") + + let docFileOpt = + match docFileOpt with + | None -> None + | Some docFile -> Some(mkAbsolute directory docFile) + + + let options = + [ yield "--simpleresolution" + yield "--noframework" + match outFileOpt with + | None -> () + | Some outFile -> yield "--out:" + outFile + match docFileOpt with + | None -> () + | Some docFile -> yield "--doc:" + docFile + match baseAddressOpt with + | None -> () + | Some baseAddress -> yield "--baseaddress:" + baseAddress + match keyFileOpt with + | None -> () + | Some keyFile -> yield "--keyfile:" + keyFile + match sigFileOpt with + | None -> () + | Some sigFile -> yield "--sig:" + sigFile + match pdbFileOpt with + | None -> () + | Some pdbFile -> yield "--pdb:" + pdbFile + match versionFileOpt with + | None -> () + | Some versionFile -> yield "--versionfile:" + versionFile + match warnLevelOpt with + | None -> () + | Some warnLevel -> yield "--warn:" + warnLevel + match subsystemVersionOpt with + | None -> () + | Some s -> yield "--subsystemversion:" + s + if heOpt then yield "--highentropyva+" + match win32ResOpt with + | None -> () + | Some win32Res -> yield "--win32res:" + win32Res + match win32ManifestOpt with + | None -> () + | Some win32Manifest -> yield "--win32manifest:" + win32Manifest + match targetProfileOpt with + | None -> () + | Some targetProfile -> yield "--targetprofile:" + targetProfile + yield "--fullpaths" + yield "--flaterrors" + if warnAsError then yield "--warnaserror" + yield + if isLib then "--target:library" + else "--target:exe" + for symbol in defines do + if not (String.IsNullOrWhiteSpace symbol) then yield "--define:" + symbol + for nw in nowarn do + if not (String.IsNullOrWhiteSpace nw) then yield "--nowarn:" + nw + for nw in warningsAsError do + if not (String.IsNullOrWhiteSpace nw) then yield "--warnaserror:" + nw + yield if debugSymbols then "--debug+" + else "--debug-" + yield if optimize then "--optimize+" + else "--optimize-" + yield if tailcalls then "--tailcalls+" + else "--tailcalls-" + match debugTypeOpt with + | None -> () + | Some debugType -> + match debugType.ToUpperInvariant() with + | "NONE" -> () + | "PDBONLY" -> yield "--debug:pdbonly" + | "FULL" -> yield "--debug:full" + | _ -> () + match platformOpt |> Option.map (fun o -> o.ToUpperInvariant()), prefer32bit, + targetTypeOpt |> Option.map (fun o -> o.ToUpperInvariant()) with + | Some "ANYCPU", true, Some "EXE" | Some "ANYCPU", true, Some "WINEXE" -> yield "--platform:anycpu32bitpreferred" + | Some "ANYCPU", _, _ -> yield "--platform:anycpu" + | Some "X86", _, _ -> yield "--platform:x86" + | Some "X64", _, _ -> yield "--platform:x64" + | Some "ITANIUM", _, _ -> yield "--platform:Itanium" + | _ -> () + match targetTypeOpt |> Option.map (fun o -> o.ToUpperInvariant()) with + | Some "LIBRARY" -> yield "--target:library" + | Some "EXE" -> yield "--target:exe" + | Some "WINEXE" -> yield "--target:winexe" + | Some "MODULE" -> yield "--target:module" + | _ -> () + yield! otherFlags + for f in resources do + yield "--resource:" + f + for i in libPaths do + yield "--lib:" + mkAbsolute directory i + for r in references do + yield "-r:" + r + yield! files ] + + member x.Options = options + member x.FrameworkVersion = fxVer + member x.ProjectReferences = projectReferences + member x.References = references + member x.CompileFiles = files + member x.ResourceFiles = resources + member x.EmbeddedResourceFiles = embeddedResources + member x.ContentFiles = content + member x.OtherFiles = noaction + member x.PageFiles = pages + member x.OutputFile = outFileOpt + member x.Directory = directory + member x.AssemblyName = assemblyNameOpt + member x.OutputPath = outputPathOpt + member x.FullPath = fsprojFullPath + member x.LogOutput = logOutput + static member Parse(fsprojFileName:string, ?properties, ?enableLogging) = new FSharpProjectFileInfo(fsprojFileName, ?properties=properties, ?enableLogging=enableLogging) + + let getOptions file enableLogging properties = + let rec getOptions file : Option * ProjectOptions = + let parsedProject = FSharpProjectFileInfo.Parse(file, properties=properties, enableLogging=enableLogging) + let referencedProjectOptions = + [| for file in parsedProject.ProjectReferences do + if Path.GetExtension(file) = ".fsproj" then + match getOptions file with + | Some outFile, opts -> yield outFile, opts + | None, _ -> () |] + + let options = { ProjectFile = file + Options = Array.ofSeq (parsedProject.Options) + ReferencedProjectOptions = referencedProjectOptions + LogOutput = parsedProject.LogOutput } + + parsedProject.OutputFile, options + + snd (getOptions file) + +// let addMSBuildv14BackupResolution () = +// let onResolveEvent = new ResolveEventHandler(fun sender evArgs -> +// let requestedAssembly = AssemblyName(evArgs.Name) +// if requestedAssembly.Name.StartsWith("Microsoft.Build") && +// not (requestedAssembly.Name.EndsWith(".resources")) then +// requestedAssembly.Version <- Version("14.0.0.0") +// Assembly.Load (requestedAssembly) +// else +// null) +// AppDomain.CurrentDomain.add_AssemblyResolve(onResolveEvent) + + let rec pairs l = + match l with + | [] | [_] -> [] + | x::y::rest -> (x,y) :: pairs rest + + let crackOpen (argv: string[])= + if argv.Length >= 2 then + let projectFile = argv.[0] + let enableLogging = match Boolean.TryParse(argv.[1]) with + | true, true -> true + | _ -> false + try + //addMSBuildv14BackupResolution () + let props = pairs (List.ofArray argv.[2..]) + let opts = getOptions argv.[0] enableLogging props + 0, opts + with e -> + 2, { ProjectFile = projectFile; + Options = [||]; + ReferencedProjectOptions = [||]; + LogOutput = e.ToString() } + else + 1, { ProjectFile = ""; + Options = [||]; + ReferencedProjectOptions = [||]; + LogOutput = "At least two arguments required." } + diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json new file mode 100644 index 0000000000..1b8937248f --- /dev/null +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json @@ -0,0 +1,60 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "compilerName": "fsc", + "emitEntryPoint": true, + "compile": { + "includeFiles": [ + "ProjectCrackerOptions.fs", + "ProjectCrackerTool.fs", + "ProjectCracker.fs", + "Program.fs", + ], + }, + "define": [ + "TRACE", + ], + "nowarn": [ + "44", + ], + "xmlDoc": true, + "delaySign": true, + "warningsAsErrors": true, + "additionalArguments": [ + "--warn:3", + "--fullpaths", + "--flaterrors", + ], + }, + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0-rc2-3002700" + }, + "Microsoft.Build": "0.1.0-*", + "Microsoft.Build.Framework": "0.1.0-*", + "Microsoft.Build.Tasks.Core": "0.1.0-*", + "Microsoft.Build.Utilities.Core": "0.1.0-*", + "System.Runtime.Serialization.Json": "4.0.2-rc2-*", + "Microsoft.FSharp.Core.netcore": "1.0.0-*", + "FSharp.Compiler.Service.netcore": "1.0.0-*", + }, + "tools": { + "dotnet-compile-fsc": { + "version": "1.0.0-rc2-002678", + "imports": [ + "dnxcore50", + "portable-net45+win81", + "netstandard1.3" + ] + } + }, + "frameworks": { + "netstandard1.5": { + "imports": [ + "portable-net45+win81", + "dnxcore50" + ] + } + } +} \ No newline at end of file diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.netcore/project.json index 2b6adce9f4..53074c8ec3 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/project.json +++ b/src/fsharp/FSharp.Compiler.Service.netcore/project.json @@ -2,6 +2,178 @@ "version": "1.0.0-*", "buildOptions": { "compilerName": "fsc", + "compile": { + "includeFiles": [ + "../../assemblyinfo/assemblyinfo.FSharp.Compiler.Service.dll.fs", + "FSComp.fs", + "FSIstrings.fs", + "../../utils/reshapedreflection.fs", + "../../utils/sformat.fsi", + "../../utils/sformat.fs", + "../sr.fsi", + "../sr.fs", + "../../utils/prim-lexing.fsi", + "../../utils/prim-lexing.fs", + "../../utils/prim-parsing.fsi", + "../../utils/prim-parsing.fs", + "../../utils/ResizeArray.fsi", + "../../utils/ResizeArray.fs", + "../../utils/HashMultiMap.fsi", + "../../utils/HashMultiMap.fs", + "../../utils/TaggedCollections.fsi", + "../../utils/TaggedCollections.fs", + "../FlatList.fs", + "../QueueList.fs", + "../../absil/ildiag.fsi", + "../../absil/ildiag.fs", + "../../absil/illib.fs", + "../../utils/filename.fsi", + "../../utils/filename.fs", + "../../absil/zmap.fsi", + "../../absil/zmap.fs", + "../../absil/zset.fsi", + "../../absil/zset.fs", + "../../absil/bytes.fsi", + "../../absil/bytes.fs", + "../lib.fs", + "../InternalCollections.fsi", + "../InternalCollections.fs", + "../rational.fsi", + "../rational.fs", + "../TraceCall.fsi", + "../TraceCall.fs", + "../range.fsi", + "../range.fs", + "../ErrorLogger.fs", + "../ReferenceResolution.fsi", + "../ReferenceResolution.fs", + "../../absil/il.fsi", + "../../absil/il.fs", + "../../absil/ilx.fsi", + "../../absil/ilx.fs", + "../../absil/ilascii.fsi", + "../../absil/ilascii.fs", + "../../absil/ilprint.fsi", + "../../absil/ilprint.fs", + "../../absil/ilmorph.fsi", + "../../absil/ilmorph.fs", + "../../absil/ilsign.fs", + "../../absil/ilsupp.fsi", + "../../absil/ilsupp.fs", + "ilpars.fs", + "illex.fs", + "../../absil/ilbinary.fsi", + "../../absil/ilbinary.fs", + "../../absil/ilread.fsi", + "../../absil/ilread.fs", + "../../absil/ilwritepdb.fsi", + "../../absil/ilwritepdb.fs", + "../../absil/ilwrite.fsi", + "../../absil/ilwrite.fs", + "../../absil/ilreflect.fs", + "../../utils/CompilerLocationUtils.fs", + "../PrettyNaming.fs", + "../../ilx/ilxsettings.fs", + "../../ilx/EraseClosures.fsi", + "../../ilx/EraseClosures.fs", + "../../ilx/EraseUnions.fsi", + "../../ilx/EraseUnions.fs", + "../UnicodeLexing.fsi", + "../UnicodeLexing.fs", + "../layout.fsi", + "../layout.fs", + "../ast.fs", + "pppars.fs", + "pars.fs", + "../lexhelp.fsi", + "../lexhelp.fs", + "pplex.fs", + "lex.fs", + "../LexFilter.fs", + "../tainted.fsi", + "../tainted.fs", + "../ExtensionTyping.fsi", + "../ExtensionTyping.fs", + "../QuotationPickler.fsi", + "../QuotationPickler.fs", + "../tast.fs", + "../TcGlobals.fs", + "../TastOps.fsi", + "../TastOps.fs", + "../TastPickle.fsi", + "../TastPickle.fs", + "../import.fsi", + "../import.fs", + "../infos.fs", + "../NicePrint.fs", + "../AugmentWithHashCompare.fsi", + "../AugmentWithHashCompare.fs", + "../NameResolution.fsi", + "../NameResolution.fs", + "../TypeRelations.fs", + "../PatternMatchCompilation.fsi", + "../PatternMatchCompilation.fs", + "../ConstraintSolver.fsi", + "../ConstraintSolver.fs", + "../CheckFormatStrings.fsi", + "../CheckFormatStrings.fs", + "../FindUnsolved.fs", + "../QuotationTranslator.fsi", + "../QuotationTranslator.fs", + "../PostInferenceChecks.fsi", + "../PostInferenceChecks.fs", + "../TypeChecker.fsi", + "../TypeChecker.fs", + "../Optimizer.fsi", + "../Optimizer.fs", + "../DetupleArgs.fsi", + "../DetupleArgs.fs", + "../InnerLambdasToTopLevelFuncs.fsi", + "../InnerLambdasToTopLevelFuncs.fs", + "../LowerCallsAndSeqs.fs", + "../autobox.fs", + "../IlxGen.fsi", + "../IlxGen.fs", + "../CompileOps.fsi", + "../CompileOps.fs", + "../CompileOptions.fsi", + "../CompileOptions.fs", + "../fsc.fsi", + "../fsc.fs", + "../vs/IncrementalBuild.fsi", + "../vs/IncrementalBuild.fs", + "../vs/Reactor.fsi", + "../vs/Reactor.fs", + "../vs/ServiceConstants.fs", + "../vs/ServiceDeclarations.fsi", + "../vs/ServiceDeclarations.fs", + "../vs/Symbols.fsi", + "../vs/Symbols.fs", + "../vs/Exprs.fsi", + "../vs/Exprs.fs", + "../vs/ServiceLexing.fsi", + "../vs/ServiceLexing.fs", + "../vs/ServiceParseTreeWalk.fs", + "../vs/ServiceNavigation.fsi", + "../vs/ServiceNavigation.fs", + "../vs/ServiceParamInfoLocations.fsi", + "../vs/ServiceParamInfoLocations.fs", + "../vs/ServiceUntypedParse.fsi", + "../vs/ServiceUntypedParse.fs", + "../vs/service.fsi", + "../vs/service.fs", + "../vs/SimpleServices.fsi", + "../vs/SimpleServices.fs", + "../fsi/fsi.fsi", + "../fsi/fsi.fs" + ] + }, + "embed": { + "mappings": { + "FSComp": "FSComp.resx", + "FSStrings": "../FSStrings.resx" + } + }, "define": [ "BUILDING_WITH_LKG", "COMPILED_AS_LANGUAGE_SERVICE_DLL", @@ -85,190 +257,24 @@ "--flaterrors", "--times", "--warnon:1182" - ] - }, - "namedResource": { - "FSComp": "FSComp.resx", - "FSStrings": "../FSStrings.resx" + ], }, - "compileFiles": [ - "../../assemblyinfo/assemblyinfo.FSharp.Compiler.Service.dll.fs", - "FSComp.fs", - "FSIstrings.fs", - "../../utils/reshapedreflection.fs", - "../../utils/sformat.fsi", - "../../utils/sformat.fs", - "../sr.fsi", - "../sr.fs", - "../../utils/prim-lexing.fsi", - "../../utils/prim-lexing.fs", - "../../utils/prim-parsing.fsi", - "../../utils/prim-parsing.fs", - "../../utils/ResizeArray.fsi", - "../../utils/ResizeArray.fs", - "../../utils/HashMultiMap.fsi", - "../../utils/HashMultiMap.fs", - "../../utils/TaggedCollections.fsi", - "../../utils/TaggedCollections.fs", - "../FlatList.fs", - "../QueueList.fs", - "../../absil/ildiag.fsi", - "../../absil/ildiag.fs", - "../../absil/illib.fs", - "../../utils/filename.fsi", - "../../utils/filename.fs", - "../../absil/zmap.fsi", - "../../absil/zmap.fs", - "../../absil/zset.fsi", - "../../absil/zset.fs", - "../../absil/bytes.fsi", - "../../absil/bytes.fs", - "../lib.fs", - "../InternalCollections.fsi", - "../InternalCollections.fs", - "../rational.fsi", - "../rational.fs", - "../TraceCall.fsi", - "../TraceCall.fs", - "../range.fsi", - "../range.fs", - "../ErrorLogger.fs", - "../ReferenceResolution.fsi", - "../ReferenceResolution.fs", - "../../absil/il.fsi", - "../../absil/il.fs", - "../../absil/ilx.fsi", - "../../absil/ilx.fs", - "../../absil/ilascii.fsi", - "../../absil/ilascii.fs", - "../../absil/ilprint.fsi", - "../../absil/ilprint.fs", - "../../absil/ilmorph.fsi", - "../../absil/ilmorph.fs", - "../../absil/ilsign.fs", - "../../absil/ilsupp.fsi", - "../../absil/ilsupp.fs", - "ilpars.fs", - "illex.fs", - "../../absil/ilbinary.fsi", - "../../absil/ilbinary.fs", - "../../absil/ilread.fsi", - "../../absil/ilread.fs", - "../../absil/ilwritepdb.fsi", - "../../absil/ilwritepdb.fs", - "../../absil/ilwrite.fsi", - "../../absil/ilwrite.fs", - "../../absil/ilreflect.fs", - "../../utils/CompilerLocationUtils.fs", - "../PrettyNaming.fs", - "../../ilx/ilxsettings.fs", - "../../ilx/EraseClosures.fsi", - "../../ilx/EraseClosures.fs", - "../../ilx/EraseUnions.fsi", - "../../ilx/EraseUnions.fs", - "../UnicodeLexing.fsi", - "../UnicodeLexing.fs", - "../layout.fsi", - "../layout.fs", - "../ast.fs", - "pppars.fs", - "pars.fs", - "../lexhelp.fsi", - "../lexhelp.fs", - "pplex.fs", - "lex.fs", - "../LexFilter.fs", - "../tainted.fsi", - "../tainted.fs", - "../ExtensionTyping.fsi", - "../ExtensionTyping.fs", - "../QuotationPickler.fsi", - "../QuotationPickler.fs", - "../tast.fs", - "../TcGlobals.fs", - "../TastOps.fsi", - "../TastOps.fs", - "../TastPickle.fsi", - "../TastPickle.fs", - "../import.fsi", - "../import.fs", - "../infos.fs", - "../NicePrint.fs", - "../AugmentWithHashCompare.fsi", - "../AugmentWithHashCompare.fs", - "../NameResolution.fsi", - "../NameResolution.fs", - "../TypeRelations.fs", - "../PatternMatchCompilation.fsi", - "../PatternMatchCompilation.fs", - "../ConstraintSolver.fsi", - "../ConstraintSolver.fs", - "../CheckFormatStrings.fsi", - "../CheckFormatStrings.fs", - "../FindUnsolved.fs", - "../QuotationTranslator.fsi", - "../QuotationTranslator.fs", - "../PostInferenceChecks.fsi", - "../PostInferenceChecks.fs", - "../TypeChecker.fsi", - "../TypeChecker.fs", - "../Optimizer.fsi", - "../Optimizer.fs", - "../DetupleArgs.fsi", - "../DetupleArgs.fs", - "../InnerLambdasToTopLevelFuncs.fsi", - "../InnerLambdasToTopLevelFuncs.fs", - "../LowerCallsAndSeqs.fs", - "../autobox.fs", - "../IlxGen.fsi", - "../IlxGen.fs", - "../CompileOps.fsi", - "../CompileOps.fs", - "../CompileOptions.fsi", - "../CompileOptions.fs", - "../fsc.fsi", - "../fsc.fs", - "../vs/IncrementalBuild.fsi", - "../vs/IncrementalBuild.fs", - "../vs/Reactor.fsi", - "../vs/Reactor.fs", - "../vs/ServiceConstants.fs", - "../vs/ServiceDeclarations.fsi", - "../vs/ServiceDeclarations.fs", - "../vs/Symbols.fsi", - "../vs/Symbols.fs", - "../vs/Exprs.fsi", - "../vs/Exprs.fs", - "../vs/ServiceLexing.fsi", - "../vs/ServiceLexing.fs", - "../vs/ServiceParseTreeWalk.fs", - "../vs/ServiceNavigation.fsi", - "../vs/ServiceNavigation.fs", - "../vs/ServiceParamInfoLocations.fsi", - "../vs/ServiceParamInfoLocations.fs", - "../vs/ServiceUntypedParse.fsi", - "../vs/ServiceUntypedParse.fs", - "../vs/service.fsi", - "../vs/service.fs", - "../vs/SimpleServices.fsi", - "../vs/SimpleServices.fs", - "../fsi/fsi.fsi", - "../fsi/fsi.fs" - ], "dependencies": { - "Microsoft.FSharp.Core.netcore": "1.0.0-*", "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002673" + "version": "1.0.0-rc2-3002700" }, + "Microsoft.Build": "0.1.0-*", "Microsoft.Build.Framework": "0.1.0-*", "Microsoft.Build.Tasks.Core": "0.1.0-*", "Microsoft.Build.Utilities.Core": "0.1.0-*", + "System.Diagnostics.TraceSource": "4.0.0-rc2-*", + "Microsoft.FSharp.Core.netcore": "1.0.0-*", }, "tools": { "dotnet-fssrgen": "3.0.1", "dotnet-compile-fsc": { - "version": "1.0.0-rc2-*", + "version": "1.0.0-rc2-002678", "imports": [ "dnxcore50", "portable-net45+win81", @@ -279,6 +285,7 @@ "frameworks": { "netstandard1.5": { "imports": [ + "portable-net45+win81", "dnxcore50" ] } diff --git a/src/fsharp/vs/Reactor.fs b/src/fsharp/vs/Reactor.fs index bb748b55c3..6c5c27d2a9 100644 --- a/src/fsharp/vs/Reactor.fs +++ b/src/fsharp/vs/Reactor.fs @@ -9,13 +9,6 @@ open Microsoft.FSharp.Control open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.Lib -// TODO: not sure why Trace is not defined in System.Diagnostics, why do we have to redefine it here -type internal Trace() = - [] - static member TraceInformation(format: string, [] args: obj []) = - let s = String.Format(format, args) - ignore s - /// Represents the capability to schedule work in the compiler service operations queue for the compilation thread type internal IReactorOperations = abstract EnqueueAndAwaitOpAsync : string * (CancellationToken -> 'T) -> Async<'T> diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config index 9d4bfde0b9..cb5d625d04 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config +++ b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config @@ -3,7 +3,10 @@ - + + + + diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/project.json b/tests/FSharp.Compiler.Service.Tests.netcore/project.json index dfaf907ac4..aa1afa5dc3 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/project.json +++ b/tests/FSharp.Compiler.Service.Tests.netcore/project.json @@ -3,6 +3,30 @@ "buildOptions": { "compilerName": "fsc", "emitEntryPoint": true, + "compile": { + "includeFiles": [ + "ReshapedReflection.fs", + "../service/FsUnit.fs", + "../service/Common.fs", + "../service/EditorTests.fs", + "../service/ExprTests.fs", + "../service/TokenizerTests.fs", + + "Program.fs", + ], + "excludeFiles": [ + "../service/ProjectAnalysisTests.fs", + "../service/InteractiveCheckerTests.fs", + "../service/FscTests.fs", + "../service/ProjectOptionsTests.fs", + "../service/PerfTests.fs", + "../service/FileSystemTests.fs", + + "../service/FsiTests.fs", + "../service/MultiProjectAnalysisTests.fs", + "../service/CSharpProjectAnalysis.fs", + ], + }, "define": [ "DOTNETCORE", "FX_ATLEAST_45", @@ -22,43 +46,21 @@ "--warn:3", "--fullpaths", "--flaterrors", - ] + ], }, - "namedResource": {}, - "compileFiles": [ - "ReshapedReflection.fs", - "../service/FsUnit.fs", - "../service/Common.fs", - "../service/EditorTests.fs", - "../service/ExprTests.fs", - "../service/TokenizerTests.fs", - "../service/ProjectAnalysisTests.fs", - "../service/InteractiveCheckerTests.fs", - - "Program.fs", - ], - "compileFiles_not_included_yet": [ - "../service/FsiTests.fs", - "../service/FscTests.fs", - "../service/ProjectOptionsTests.fs", - "../service/PerfTests.fs", - - "../service/FileSystemTests.fs", - "../service/CSharpProjectAnalysis.fs", - "../service/MultiProjectAnalysisTests.fs", - ], "dependencies": { - "Microsoft.FSharp.Core.netcore": "1.0.0-*", "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002673" + "version": "1.0.0-rc2-3002700" }, + "Microsoft.FSharp.Core.netcore": "1.0.0-*", "FSharp.Compiler.Service.netcore": "1.0.0-*", + "FSharp.Compiler.Service.ProjectCracker.netcore": "1.0.0-*", "NUnitLite": "3.2.1", }, "tools": { "dotnet-compile-fsc": { - "version": "1.0.0-rc2-*", + "version": "1.0.0-rc2-002678", "imports": [ "dnxcore50", "portable-net45+win81", @@ -69,6 +71,7 @@ "frameworks": { "netstandard1.5": { "imports": [ + "portable-net45+win81", "dnxcore50" ] } diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 407f7e56bc..2f28610c4d 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -54,7 +54,7 @@ let stringMethods = let input = """ open System - + let foo() = let msg = String.Concat("Hello"," ","world") if true then @@ -370,11 +370,11 @@ type Test() = [] let ``Printf specifiers for regular and verbatim strings`` () = let input = - """ + """let os = System.Text.StringBuilder() let _ = Microsoft.FSharp.Core.Printf.printf "%A" 0 let _ = Printf.printf "%A" 0 let _ = Printf.kprintf (fun _ -> ()) "%A" 1 -let _ = Printf.bprintf null "%A" 1 +let _ = Printf.bprintf os "%A" 1 let _ = sprintf "%*d" 1 let _ = sprintf "%7.1f" 1.0 let _ = sprintf "%-8.1e+567" 1.0 @@ -403,7 +403,7 @@ let _ = sprintf " %*.1f" 3 4.5 let _ = sprintf " %6.*f" 3 4.5 let _ = sprintf " %6.*%" 3 let _ = printf " %a" (fun _ _ -> ()) 2 -let _ = printf " %*a" 3 (fun _ _ -> ()) 2 +let _ = printf " %*a" 3 (fun _ _ -> ()) 2 //TODO: this fails in coreclr """ let file = "/home/user/Test.fsx" @@ -415,7 +415,7 @@ let _ = printf " %*a" 3 (fun _ _ -> ()) 2 |> shouldEqual [|(2, 45, 2, 46, 1); (3, 23, 3, 24, 1); (4, 38, 4, 39, 1); - (5, 29, 5, 30, 1); + (5, 27, 5, 28, 1); (6, 17, 6, 19, 2); (7, 17, 7, 21, 1); (8, 17, 8, 22, 1); diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index b870541091..6cb1609f6b 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -813,7 +813,7 @@ let ``Test Declarations selfhost`` () = [] let ``Test Declarations selfhost whole compiler`` () = - Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ + @"/../../src/fsharp/FSharp.Compiler.Service" + Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__ + @"/../../src/fsharp/FSharp.Compiler.Service") let projectFile = __SOURCE_DIRECTORY__ + @"/../../src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj" //let v = FSharpProjectFileInfo.Parse(projectFile, [("Configuration", "Debug"); ("NoFsSrGenTask", "true")],enableLogging=true) @@ -852,7 +852,7 @@ let ``Test Declarations selfhost whole compiler`` () = [] let ``Test Declarations selfhost FSharp.Core`` () = - Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ + @"/../../../fsharp/src/fsharp/FSharp.Core" + Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__ + @"/../../../fsharp/src/fsharp/FSharp.Core") let projectFile = __SOURCE_DIRECTORY__ + @"/../../../fsharp/src/fsharp/FSharp.Core/FSharp.Core.fsproj" let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")]) diff --git a/tests/service/FileSystemTests.fs b/tests/service/FileSystemTests.fs index 94ecd4bd12..1e7758f7ce 100644 --- a/tests/service/FileSystemTests.fs +++ b/tests/service/FileSystemTests.fs @@ -72,6 +72,8 @@ let UseMyFileSystem() = Shim.FileSystem <- myFileSystem { new IDisposable with member x.Dispose() = Shim.FileSystem <- myFileSystem } +#if !FX_ATLEAST_PORTABLE + [] let ``FileSystem compilation test``() = if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows @@ -110,3 +112,5 @@ let ``FileSystem compilation test``() = results.AssemblySignature.Entities.Count |> shouldEqual 2 results.AssemblySignature.Entities.[0].MembersFunctionsAndValues.Count |> shouldEqual 1 results.AssemblySignature.Entities.[0].MembersFunctionsAndValues.[0].DisplayName |> shouldEqual "B" + +#endif \ No newline at end of file diff --git a/tests/service/FsiTests.fs b/tests/service/FsiTests.fs index 5ebc67b720..4f054ea523 100644 --- a/tests/service/FsiTests.fs +++ b/tests/service/FsiTests.fs @@ -27,7 +27,11 @@ let errStream = new CompilerOutputStream() let argv = [| "C:\\fsi.exe" |] let allArgs = Array.append argv [|"--noninteractive"|] +#if DOTNETCORE +let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration() +#else let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration(fsi) +#endif let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, new StreamWriter(outStream), new StreamWriter(errStream)) /// Evaluate expression & return the result diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index 284bbdd507..e6377a0fe3 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -66,7 +66,7 @@ let ``Project file parsing example 1 Release Configuration`` () = [] let ``Project file parsing example 1 Default configuration relative path`` () = let projectFile = "FSharp.Compiler.Service.Tests.fsproj" - Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ + Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__) let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile) From 37219dae83d91c55f0e6fd1709d620b9b5d826fe Mon Sep 17 00:00:00 2001 From: ncave Date: Sat, 28 May 2016 15:29:43 -0700 Subject: [PATCH 12/17] Tests update --- appveyor.yml | 2 +- .../NuGet.Config | 4 ++-- .../ProjectCracker.fs | 1 + .../ProjectCrackerTool.fs | 2 +- .../project.json | 19 ++++++++-------- .../NuGet.Config | 2 +- .../project.json | 22 +++++++++---------- .../NuGet.Config | 11 ++++------ .../project.json | 20 ++++++++--------- tests/global.json | 3 +++ tests/service/Common.fs | 19 +++++++++++++++- tests/service/EditorTests.fs | 4 ++++ tests/service/ExprTests.fs | 16 +++++++------- tests/service/FscTests.fs | 17 ++------------ tests/service/InteractiveCheckerTests.fs | 12 +++------- 15 files changed, 77 insertions(+), 77 deletions(-) create mode 100644 tests/global.json diff --git a/appveyor.yml b/appveyor.yml index 285321c274..a57622b0b7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ init: - git config --global core.autocrlf input environment: - CLI_VERSION: 1.0.0-rc2-002678 + CLI_VERSION: 1.0.0-rc2-002702 #CLI_VERSION: Latest matrix: - BUILD_TARGET: DotnetCliTests diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/NuGet.Config b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/NuGet.Config index 3868a20e87..69c8d170b6 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/NuGet.Config +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/NuGet.Config @@ -3,11 +3,11 @@ + + - - diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs index bb5eccabb3..3680d98401 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs @@ -37,6 +37,7 @@ type ProjectCracker = |] let ret, opts = ProjectCrackerTool.crackOpen arguments + ignore ret convert opts, !logMap static member GetProjectOptionsFromProjectFile(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp) = diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerTool.fs b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerTool.fs index 1d2f5ee4aa..937c4da6db 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerTool.fs +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCrackerTool.fs @@ -40,7 +40,7 @@ module internal ProjectCrackerTool = if Path.IsPathRooted v then v else Path.Combine(dir, v) - let mkAbsoluteOpt dir v = Option.map (mkAbsolute dir) v + //let mkAbsoluteOpt dir v = Option.map (mkAbsolute dir) v let logOpt = if enableLogging then diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json index 1b8937248f..6d6bf19da5 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json @@ -1,8 +1,9 @@ { "version": "1.0.0-*", "buildOptions": { - "compilerName": "fsc", + "debugType": "portable", "emitEntryPoint": true, + "compilerName": "fsc", "compile": { "includeFiles": [ "ProjectCrackerOptions.fs", @@ -21,27 +22,27 @@ "delaySign": true, "warningsAsErrors": true, "additionalArguments": [ - "--warn:3", "--fullpaths", "--flaterrors", + "--warnon:1182", ], }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002700" + "version": "1.0.0-rc2-3002702" }, - "Microsoft.Build": "0.1.0-*", - "Microsoft.Build.Framework": "0.1.0-*", - "Microsoft.Build.Tasks.Core": "0.1.0-*", - "Microsoft.Build.Utilities.Core": "0.1.0-*", + "Microsoft.Build": "0.1.0-preview-00022", + "Microsoft.Build.Framework": "0.1.0-preview-00022", + "Microsoft.Build.Tasks.Core": "0.1.0-preview-00022", + "Microsoft.Build.Utilities.Core": "0.1.0-preview-00022", "System.Runtime.Serialization.Json": "4.0.2-rc2-*", "Microsoft.FSharp.Core.netcore": "1.0.0-*", "FSharp.Compiler.Service.netcore": "1.0.0-*", }, "tools": { "dotnet-compile-fsc": { - "version": "1.0.0-rc2-002678", + "version": "1.0.0-rc2-*", "imports": [ "dnxcore50", "portable-net45+win81", @@ -52,7 +53,7 @@ "frameworks": { "netstandard1.5": { "imports": [ - "portable-net45+win81", + "portable-net45+win8", "dnxcore50" ] } diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config b/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config index bc88667e08..69c8d170b6 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config +++ b/src/fsharp/FSharp.Compiler.Service.netcore/NuGet.Config @@ -3,11 +3,11 @@ + - diff --git a/src/fsharp/FSharp.Compiler.Service.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.netcore/project.json index 53074c8ec3..d42bd1e354 100644 --- a/src/fsharp/FSharp.Compiler.Service.netcore/project.json +++ b/src/fsharp/FSharp.Compiler.Service.netcore/project.json @@ -1,6 +1,7 @@ { "version": "1.0.0-*", "buildOptions": { + "debugType": "portable", "compilerName": "fsc", "compile": { "includeFiles": [ @@ -248,33 +249,30 @@ "9" ], "xmlDoc": true, - "keyFile": "../msft.pubkey", "delaySign": true, "warningsAsErrors": true, "additionalArguments": [ - "--warn:3", "--fullpaths", "--flaterrors", - "--times", - "--warnon:1182" - ], + "--warnon:1182", + ] }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002700" + "version": "1.0.0-rc2-3002702" }, - "Microsoft.Build": "0.1.0-*", - "Microsoft.Build.Framework": "0.1.0-*", - "Microsoft.Build.Tasks.Core": "0.1.0-*", - "Microsoft.Build.Utilities.Core": "0.1.0-*", + "Microsoft.Build": "0.1.0-preview-00022", + "Microsoft.Build.Framework": "0.1.0-preview-00022", + "Microsoft.Build.Tasks.Core": "0.1.0-preview-00022", + "Microsoft.Build.Utilities.Core": "0.1.0-preview-00022", "System.Diagnostics.TraceSource": "4.0.0-rc2-*", "Microsoft.FSharp.Core.netcore": "1.0.0-*", }, "tools": { "dotnet-fssrgen": "3.0.1", "dotnet-compile-fsc": { - "version": "1.0.0-rc2-002678", + "version": "1.0.0-rc2-*", "imports": [ "dnxcore50", "portable-net45+win81", @@ -285,7 +283,7 @@ "frameworks": { "netstandard1.5": { "imports": [ - "portable-net45+win81", + "portable-net45+win8", "dnxcore50" ] } diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config index cb5d625d04..a8966794f2 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config +++ b/tests/FSharp.Compiler.Service.Tests.netcore/NuGet.Config @@ -3,14 +3,11 @@ - - - - - - - + + + + diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/project.json b/tests/FSharp.Compiler.Service.Tests.netcore/project.json index aa1afa5dc3..1a0c73a989 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/project.json +++ b/tests/FSharp.Compiler.Service.Tests.netcore/project.json @@ -1,8 +1,9 @@ { "version": "1.0.0-*", "buildOptions": { - "compilerName": "fsc", + "debugType": "portable", "emitEntryPoint": true, + "compilerName": "fsc", "compile": { "includeFiles": [ "ReshapedReflection.fs", @@ -11,17 +12,15 @@ "../service/EditorTests.fs", "../service/ExprTests.fs", "../service/TokenizerTests.fs", - + "../service/PerfTests.fs", + "../service/InteractiveCheckerTests.fs", "Program.fs", ], "excludeFiles": [ "../service/ProjectAnalysisTests.fs", - "../service/InteractiveCheckerTests.fs", "../service/FscTests.fs", "../service/ProjectOptionsTests.fs", - "../service/PerfTests.fs", - "../service/FileSystemTests.fs", - + "../service/FileSystemTests.fs", "../service/FsiTests.fs", "../service/MultiProjectAnalysisTests.fs", "../service/CSharpProjectAnalysis.fs", @@ -43,7 +42,6 @@ "delaySign": true, "warningsAsErrors": true, "additionalArguments": [ - "--warn:3", "--fullpaths", "--flaterrors", ], @@ -51,16 +49,16 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002700" + "version": "1.0.0-rc2-3002702" }, "Microsoft.FSharp.Core.netcore": "1.0.0-*", + "NUnitLite": "3.2.1", "FSharp.Compiler.Service.netcore": "1.0.0-*", "FSharp.Compiler.Service.ProjectCracker.netcore": "1.0.0-*", - "NUnitLite": "3.2.1", }, "tools": { "dotnet-compile-fsc": { - "version": "1.0.0-rc2-002678", + "version": "1.0.0-rc2-*", "imports": [ "dnxcore50", "portable-net45+win81", @@ -71,7 +69,7 @@ "frameworks": { "netstandard1.5": { "imports": [ - "portable-net45+win81", + "portable-net45+win8", "dnxcore50" ] } diff --git a/tests/global.json b/tests/global.json new file mode 100644 index 0000000000..79d6b2fcf1 --- /dev/null +++ b/tests/global.json @@ -0,0 +1,3 @@ +{ + "projects": [ "../src/fsharp" ] +} \ No newline at end of file diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 5936b5edfd..085ced3c08 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -79,6 +79,11 @@ let mkProjectCommandLineArgs (dllName, fileNames) = #if TODO_REWORK_ASSEMBLY_LOAD [ yield typeof.Assembly.Location; // mscorlib yield typeof.Assembly.Location; // System.Runtime + yield typeof.Assembly.Location; // System.IO + yield typeof.Assembly.Location; // System.Linq + yield typeof.Assembly.Location; // System.Net.Requests + yield typeof.Assembly.Location; // System.Runtime.Numerics + yield typeof.Assembly.Location; // System.Threading.Tasks yield typeof.Assembly.Location; // FSharp.Core ] #else @@ -91,13 +96,25 @@ let mkProjectCommandLineArgs (dllName, fileNames) = yield "-r:" + r |] +let parseSourceCode (name: string, code: string) = + let location = Path.Combine(Path.GetTempPath(),"test"+string(hash (name, code))) + try Directory.CreateDirectory(location) |> ignore with _ -> () + + let projPath = Path.Combine(location, name + ".fsproj") + let filePath = Path.Combine(location, name + ".fs") + let dllPath = Path.Combine(location, name + ".dll") + let args = mkProjectCommandLineArgs(dllPath, [filePath]) + let options = checker.GetProjectOptionsFromCommandLineArgs(projPath, args) + let parseResults = checker.ParseFileInProject(filePath, code, options) |> Async.RunSynchronously + parseResults.ParseTree + let parseAndCheckScript (file, input) = #if TODO_REWORK_ASSEMBLY_LOAD let dllName = Path.ChangeExtension(file, ".dll") let projName = Path.ChangeExtension(file, ".fsproj") let args = mkProjectCommandLineArgs (dllName, [file]) - let projectOptions = checker.GetProjectOptionsFromCommandLineArgs (projName, args) + let projectOptions = checker.GetProjectOptionsFromCommandLineArgs (projName, args) #else let projectOptions = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously #endif diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 2f28610c4d..98a2424a17 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -104,7 +104,9 @@ let ``Intro test`` () = ("Concat", ["str0: string"; "str1: string"]); ("Concat", ["arg0: obj"; "arg1: obj"; "arg2: obj"]); ("Concat", ["str0: string"; "str1: string"; "str2: string"]); +#if !DOTNETCORE ("Concat", ["arg0: obj"; "arg1: obj"; "arg2: obj"; "arg3: obj"]); +#endif ("Concat", ["str0: string"; "str1: string"; "str2: string"; "str3: string"])] [] @@ -138,7 +140,9 @@ let ``GetMethodsAsSymbols should return all overloads of a method as FSharpSymbo ("Concat", [("str0", "string"); ("str1", "string")]); ("Concat", [("arg0", "obj"); ("arg1", "obj"); ("arg2", "obj")]); ("Concat", [("str0", "string"); ("str1", "string"); ("str2", "string")]); +#if !DOTNETCORE ("Concat", [("arg0", "obj"); ("arg1", "obj"); ("arg2", "obj"); ("arg3", "obj")]); +#endif ("Concat", [("str0", "string"); ("str1", "string"); ("str2", "string"); ("str3", "string")])] | None -> failwith "No symbols returned" diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index 6cb1609f6b..1b1d58d1a6 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -106,7 +106,7 @@ module Utils = if not v.IsCompilerGenerated && not (match excludes with None -> false | Some t -> t.Contains v.CompiledName) then let text = - printfn "%s" v.CompiledName + //printfn "%s" v.CompiledName //try if v.IsMember then sprintf "member %s%s = %s @ %s" v.CompiledName (printCurriedParams vs) (printExpr 0 e) (e.Range.ToShortString()) @@ -174,7 +174,7 @@ let genericFuncEx1 (x:'T) = x let (topPair1a, topPair1b) = (1,2) let tyfuncEx1<'T> = typeof<'T> let testILCall1 = new obj() -let testILCall2 = System.Console.WriteLine(176) +let testILCall2 = System.Console.WriteLine("176") // Test recursive values in a module let rec recValNeverUsedAtRuntime = recFuncIgnoresFirstArg (fun _ -> recValNeverUsedAtRuntime) 1 @@ -246,7 +246,7 @@ type ClassWithEventsAndProperties() = let c = ClassWithEventsAndProperties() let v = c.InstanceProperty -System.Console.WriteLine(777) // do a top-levl action +System.Console.WriteLine("777") // do a top-levl action let functionWithSubmsumption(x:obj) = x :?> string let functionWithCoercion(x:string) = (x :> obj) :?> string |> functionWithSubmsumption |> functionWithSubmsumption @@ -313,7 +313,7 @@ let testFunctionThatUsesTryFinally() = try testFunctionThatUsesWhileLoop() finally - System.Console.WriteLine(8888) + System.Console.WriteLine("8888") type System.Console with static member WriteTwoLines() = System.Console.WriteLine(); System.Console.WriteLine() @@ -421,7 +421,7 @@ let bool2 = false [] let ``Test Declarations project1`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously - + wholeProjectResults.Errors.Length |> shouldEqual 3 // recursive value warning wholeProjectResults.Errors.[0].Severity |> shouldEqual FSharpErrorSeverity.Warning wholeProjectResults.Errors.[1].Severity |> shouldEqual FSharpErrorSeverity.Warning @@ -447,7 +447,7 @@ let ``Test Declarations project1`` () = "let topPair1a = M.patternInput@25 ().Item0 @ (25,4--25,26)"; "let tyfuncEx1 = Operators.TypeOf<'T> () @ (26,20--26,26)"; "let testILCall1 = new Object() @ (27,18--27,27)"; - "let testILCall2 = Console.WriteLine (176) @ (28,18--28,47)"; + "let testILCall2 = Console.WriteLine (\"176\") @ (28,18--28,49)"; "let recFuncIgnoresFirstArg(g) (v) = v @ (32,33--32,34)"; "let recValNeverUsedAtRuntime = recValNeverUsedAtRuntime@31.Force(()) @ (31,8--31,32)"; "let testFun4(unitVar0) = let rec ... in recValNeverUsedAtRuntime @ (36,4--39,28)"; @@ -476,7 +476,7 @@ let ``Test Declarations project1`` () = "member get_StaticEvent(x) (unitVar1) = sev.get_Publish(()) @ (95,27--95,38)"; "let c = new ClassWithEventsAndProperties(()) @ (97,8--97,38)"; "let v = M.c ().get_InstanceProperty(()) @ (98,8--98,26)"; - "do Console.WriteLine (777)"; + "do Console.WriteLine (\"777\")"; "let functionWithSubmsumption(x) = IntrinsicFunctions.UnboxGeneric (x) @ (102,40--102,52)"; "let functionWithCoercion(x) = Operators.op_PipeRight (Operators.op_PipeRight (IntrinsicFunctions.UnboxGeneric (x :> Microsoft.FSharp.Core.obj),fun x -> M.functionWithSubmsumption (x :> Microsoft.FSharp.Core.obj)),fun x -> M.functionWithSubmsumption (x :> Microsoft.FSharp.Core.obj)) @ (103,39--103,116)"; "type MultiArgMethods"; @@ -492,7 +492,7 @@ let ``Test Declarations project1`` () = "let testFunctionThatUsesStructs2(unitVar0) = let dt1: System.DateTime = DateTime.get_Now () in let mutable dt2: System.DateTime = DateTime.get_Now () in let dt3: System.TimeSpan = Operators.op_Subtraction (dt1,dt2) in let dt4: System.DateTime = dt1.AddDays(3) in let dt5: Microsoft.FSharp.Core.int = dt1.get_Millisecond() in let dt6: Microsoft.FSharp.Core.byref = &dt2 in let dt7: System.TimeSpan = Operators.op_Subtraction (dt6,dt4) in dt7 @ (142,7--142,10)"; "let testFunctionThatUsesWhileLoop(unitVar0) = let mutable x: Microsoft.FSharp.Core.int = 1 in (while Operators.op_LessThan (x,100) do x <- Operators.op_Addition (x,1) done; x) @ (152,15--152,16)"; "let testFunctionThatUsesTryWith(unitVar0) = try M.testFunctionThatUsesWhileLoop (()) with matchValue -> match (if matchValue :? System.ArgumentException then $0 else $1) targets ... @ (158,3--160,60)"; - "let testFunctionThatUsesTryFinally(unitVar0) = try M.testFunctionThatUsesWhileLoop (()) finally Console.WriteLine (8888) @ (164,3--167,35)"; + "let testFunctionThatUsesTryFinally(unitVar0) = try M.testFunctionThatUsesWhileLoop (()) finally Console.WriteLine (\"8888\") @ (164,3--167,37)"; "member Console.WriteTwoLines.Static(unitVar0) = (Console.WriteLine (); Console.WriteLine ()) @ (170,36--170,90)"; "member DateTime.get_TwoMinute(x) (unitVar1) = Operators.op_Addition (x.get_Minute(),x.get_Minute()) @ (173,25--173,44)"; "let testFunctionThatUsesExtensionMembers(unitVar0) = (M.Console.WriteTwoLines.Static (()); let v: Microsoft.FSharp.Core.int = DateTime.get_Now ().DateTime.get_TwoMinute(()) in M.Console.WriteTwoLines.Static (())) @ (176,3--178,33)"; diff --git a/tests/service/FscTests.fs b/tests/service/FscTests.fs index 93c2d9852a..d64ee918ab 100644 --- a/tests/service/FscTests.fs +++ b/tests/service/FscTests.fs @@ -178,19 +178,6 @@ let compileAndVerify isDll debugMode assemblyName code dependencies = verifier.Verify outFile outFile -let parseSourceCode (name : string, code : string) = - let location = Path.Combine(Path.GetTempPath(),"test"+string(hash (name, code))) - try Directory.CreateDirectory(location) |> ignore with _ -> () - - let projPath = Path.Combine(location, name + ".fsproj") - let filePath = Path.Combine(location, name + ".fs") - let dllPath = Path.Combine(location, name + ".dll") - let args = Common.mkProjectCommandLineArgs(dllPath, [filePath]) - let options = checker.GetProjectOptionsFromCommandLineArgs(projPath, args) - let parseResults = checker.ParseFileInProject(filePath, code, options) |> Async.RunSynchronously - parseResults.ParseTree |> Option.toList - - let compileAndVerifyAst (name : string, ast : Ast.ParsedInput list, references : string list) = let outDir = Path.Combine(Path.GetTempPath(),"test"+string(hash (name, references))) try Directory.CreateDirectory(outDir) |> ignore with _ -> () @@ -270,7 +257,7 @@ module Foo printfn "done!" // make the code have some initialization effect """ - let ast = parseSourceCode("foo", code) + let ast = parseSourceCode("foo", code) |> Option.toList compileAndVerifyAst("foo", ast, []) [] @@ -293,7 +280,7 @@ module Bar printfn "done!" // make the code have some initialization effect """ let serviceAssembly = typeof.Assembly.Location - let ast = parseSourceCode("bar", code) + let ast = parseSourceCode("bar", code) |> Option.toList compileAndVerifyAst("bar", ast, [serviceAssembly]) diff --git a/tests/service/InteractiveCheckerTests.fs b/tests/service/InteractiveCheckerTests.fs index 8789062827..07bdfc46e0 100644 --- a/tests/service/InteractiveCheckerTests.fs +++ b/tests/service/InteractiveCheckerTests.fs @@ -13,6 +13,7 @@ open FsUnit open System open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Service.Tests.Common let longIdentToString (longIdent: Ast.LongIdent) = String.Join(".", longIdent |> List.map (fun ident -> ident.ToString())) @@ -53,15 +54,8 @@ let identsAndRanges (input: Ast.ParsedInput) = | Ast.ParsedInput.SigFile _ -> [] let parseAndExtractRanges code = - let file = "/home/user/Test.fsx" - let checker = FSharpChecker.Create() - let result = - async { - let! projectOptions = checker.GetProjectOptionsFromScript(file, code) - let! input = checker.ParseFileInProject(file, code, projectOptions) - return input.ParseTree - } - |> Async.RunSynchronously + let file = "Test" + let result = parseSourceCode (file, code) match result with | Some tree -> tree |> identsAndRanges | None -> failwith "fail to parse..." From 17c279d12a946d86cbe2fc0a4520bad792227342 Mon Sep 17 00:00:00 2001 From: ncave Date: Sat, 28 May 2016 16:48:36 -0700 Subject: [PATCH 13/17] Dotnet Core RC2 --- appveyor.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a57622b0b7..20588b8bc0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,9 @@ +os: Visual Studio 2015 + init: - git config --global core.autocrlf input environment: - CLI_VERSION: 1.0.0-rc2-002702 - #CLI_VERSION: Latest matrix: - BUILD_TARGET: DotnetCliTests - BUILD_TARGET: NuGet @@ -12,19 +12,8 @@ matrix: allow_failures: - BUILD_TARGET: DotnetCliTests -install: - # Download install script to install .NET cli in .dotnet dir - - ps: mkdir -Force ".\scripts\obtain\" | Out-Null - - ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1" -OutFile ".\scripts\obtain\install.ps1" - - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli" - - ps: '& .\scripts\obtain\install.ps1 -Channel "preview" -version "Latest" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath' - # add dotnet to PATH - - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" - # show dotnet info - - ps: 'echo "Dotnet: $( (gcm dotnet).Path )"' - - ps: dotnet --info - build_script: + - ps: dotnet --info - cmd: build.cmd %BUILD_TARGET% test: off From 5a028e03f61974dfd84c1a8a08cf55dcc0e52c5a Mon Sep 17 00:00:00 2001 From: ncave Date: Mon, 30 May 2016 00:49:54 -0700 Subject: [PATCH 14/17] Added build artifacts --- build.fsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.fsx b/build.fsx index ae56334879..b5bbf1cbd3 100644 --- a/build.fsx +++ b/build.fsx @@ -244,12 +244,12 @@ Target "DotnetCliBuild" (fun _ -> Shell.Exec(fsYacc, @"../pars.fsy" + lexArgs + yaccArgs + module2 + open2 + " -o pars.fs", workDir) |> assertExitCodeZero Shell.Exec(fsYacc, @"../pppars.fsy" + lexArgs + yaccArgs + module3 + open3 + " -o pppars.fs", workDir) |> assertExitCodeZero - Shell.Exec("dotnet", "pack -c Release", workDir) |> assertExitCodeZero + Shell.Exec("dotnet", "pack -c Release -o ../../../" + buildDir, workDir) |> assertExitCodeZero // FSharp.Compiler.Service.ProjectCracker let workDir = @"src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/" Shell.Exec("dotnet", "restore -v Minimal", workDir) |> assertExitCodeZero - Shell.Exec("dotnet", "pack -c Release", workDir) |> assertExitCodeZero + Shell.Exec("dotnet", "pack -c Release -o ../../../" + buildDir, workDir) |> assertExitCodeZero ) Target "DotnetCliTests" (fun _ -> From 84e5756d379a2d11b953776f1ddf6c65b3d3003b Mon Sep 17 00:00:00 2001 From: ncave Date: Mon, 30 May 2016 05:08:22 -0700 Subject: [PATCH 15/17] Added ProjectAnalysisTests --- .../project.json | 2 +- tests/service/Common.fs | 5 +- tests/service/ProjectAnalysisTests.fs | 54 +++++++++++++++---- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/tests/FSharp.Compiler.Service.Tests.netcore/project.json b/tests/FSharp.Compiler.Service.Tests.netcore/project.json index 1a0c73a989..103debafec 100644 --- a/tests/FSharp.Compiler.Service.Tests.netcore/project.json +++ b/tests/FSharp.Compiler.Service.Tests.netcore/project.json @@ -14,10 +14,10 @@ "../service/TokenizerTests.fs", "../service/PerfTests.fs", "../service/InteractiveCheckerTests.fs", + "../service/ProjectAnalysisTests.fs", "Program.fs", ], "excludeFiles": [ - "../service/ProjectAnalysisTests.fs", "../service/FscTests.fs", "../service/ProjectOptionsTests.fs", "../service/FileSystemTests.fs", diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 085ced3c08..3a94ba47f3 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -78,9 +78,12 @@ let mkProjectCommandLineArgs (dllName, fileNames) = let references = #if TODO_REWORK_ASSEMBLY_LOAD [ yield typeof.Assembly.Location; // mscorlib + yield typeof.Assembly.Location; // System.Console yield typeof.Assembly.Location; // System.Runtime + yield typeof.Assembly.Location; // System.ObjectModel yield typeof.Assembly.Location; // System.IO yield typeof.Assembly.Location; // System.Linq + yield typeof.Assembly.Location; // System.Xml.Linq yield typeof.Assembly.Location; // System.Net.Requests yield typeof.Assembly.Location; // System.Runtime.Numerics yield typeof.Assembly.Location; // System.Threading.Tasks @@ -112,7 +115,7 @@ let parseAndCheckScript (file, input) = #if TODO_REWORK_ASSEMBLY_LOAD let dllName = Path.ChangeExtension(file, ".dll") - let projName = Path.ChangeExtension(file, ".fsproj") + let projName = Path.ChangeExtension(file, ".fsproj") let args = mkProjectCommandLineArgs (dllName, [file]) let projectOptions = checker.GetProjectOptionsFromCommandLineArgs (projName, args) #else diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index aef8766457..785d8c70e2 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -2185,7 +2185,9 @@ let ``Test Project13 all symbols`` () = ["type System.IComparable"; "type System.IFormattable"; "type System.IConvertible"; +#if !DOTNETCORE "type System.Runtime.Serialization.ISerializable"; +#endif "type System.IComparable"; "type System.IEquatable"]) @@ -3587,14 +3589,22 @@ let _ = XmlProvider<"13">.GetSample() yield @"-r:" + sysLib "System.Xml.Linq" |] let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) +#if DOTNETCORE +[] +#else [] +#endif let ``Test Project25 whole project errors`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project25.options) |> Async.RunSynchronously for e in wholeProjectResults.Errors do printfn "Project25 error: <<<%s>>>" e.Message wholeProjectResults.Errors.Length |> shouldEqual 0 +#if DOTNETCORE +[] +#else [] +#endif let ``Test symbol uses of type-provided members`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project25.options) |> Async.RunSynchronously let backgroundParseResults1, backgroundTypedParse1 = @@ -3647,7 +3657,11 @@ let ``Test symbol uses of type-provided members`` () = usesOfGetSampleSymbol |> shouldEqual [|("file1", ((5, 8), (5, 25))); ("file1", ((10, 8), (10, 78)))|] +#if DOTNETCORE +[] +#else [] +#endif let ``Test symbol uses of type-provided types`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project25.options) |> Async.RunSynchronously let backgroundParseResults1, backgroundTypedParse1 = @@ -4074,9 +4088,14 @@ let ``Test project31 C# type attributes`` () = yield output.Replace("\r\n", "\n").Replace("\n", "") ] |> set |> shouldEqual - (set ["(DebuggerTypeProxyAttribute, [], [])"; - """(DebuggerDisplayAttribute, [(type Microsoft.FSharp.Core.string, "Count = {Count}")], [])"""; - """(DefaultMemberAttribute, [(type Microsoft.FSharp.Core.string, "Item")], [])"""]) + (set [ + "(DebuggerTypeProxyAttribute, [], [])"; + """(DebuggerDisplayAttribute, [(type Microsoft.FSharp.Core.string, "Count = {Count}")], [])"""; + """(DefaultMemberAttribute, [(type Microsoft.FSharp.Core.string, "Item")], [])"""; +#if DOTNETCORE + "(__DynamicallyInvokableAttribute, [], [])"; +#endif + ]) [] let ``Test project31 C# method attributes`` () = @@ -4096,8 +4115,11 @@ let ``Test project31 C# method attributes`` () = objMethodsAttributes |> set |> shouldEqual - (set ["(SecuritySafeCriticalAttribute, [], [])"; - "(CLSCompliantAttribute, [(type Microsoft.FSharp.Core.bool, false)], [])"]) + (set [ +#if !DOTNETCORE + "(SecuritySafeCriticalAttribute, [], [])"; +#endif + "(CLSCompliantAttribute, [(type Microsoft.FSharp.Core.bool, false)], [])"]) [] let ``Test project31 Format C# type attributes`` () = @@ -4112,7 +4134,11 @@ let ``Test project31 Format C# type attributes`` () = |> shouldEqual (set ["[>)>]"; """[]"""; - """[]"""]) + """[]"""; +#if DOTNETCORE + "[<__DynamicallyInvokableAttribute ()>]"; +#endif + ]) [] let ``Test project31 Format C# method attributes`` () = @@ -4130,7 +4156,10 @@ let ``Test project31 Format C# method attributes`` () = |> set |> shouldEqual (set ["[]"; - "[]"]) +#if !DOTNETCORE + "[]"; +#endif + ]) module Project32 = open System.IO @@ -4398,8 +4427,15 @@ module Project35b = let cleanFileName a = if a = fileName1 then "file1" else "??" let fileNames = [fileName1] - let options = checker.GetProjectOptionsFromScript(fileName1, fileSource1) |> Async.RunSynchronously - +#if TODO_REWORK_ASSEMBLY_LOAD + let projPath = Path.ChangeExtension(fileName1, ".fsproj") + let dllPath = Path.ChangeExtension(fileName1, ".dll") + let args = mkProjectCommandLineArgs(dllPath, fileNames) + let args2 = Array.append args [| "-r: notexist.dll" |] + let options = checker.GetProjectOptionsFromCommandLineArgs (projPath, args2) +#else + let options = checker.GetProjectOptionsFromScript(fileName1, fileSource1) |> Async.RunSynchronously +#endif [] let ``Test project35b Dependency files for ParseFileInProject`` () = From 3faa129c0017a7e0667fdb9b34617566cbb65b72 Mon Sep 17 00:00:00 2001 From: ncave Date: Mon, 30 May 2016 19:12:45 -0700 Subject: [PATCH 16/17] Updated MSBuild version --- .../ProjectCracker.fs | 2 +- .../project.json | 9 +++++---- tests/service/ProjectAnalysisTests.fs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs index 3680d98401..a0f0462e2a 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/ProjectCracker.fs @@ -29,7 +29,7 @@ type ProjectCracker = } let arguments = [| - yield @"""" + projectFileName + @"""" + yield projectFileName yield enableLogging.ToString() for k, v in properties do yield k diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json index 6d6bf19da5..9f981fc823 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json +++ b/src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/project.json @@ -32,10 +32,11 @@ "type": "platform", "version": "1.0.0-rc2-3002702" }, - "Microsoft.Build": "0.1.0-preview-00022", - "Microsoft.Build.Framework": "0.1.0-preview-00022", - "Microsoft.Build.Tasks.Core": "0.1.0-preview-00022", - "Microsoft.Build.Utilities.Core": "0.1.0-preview-00022", + "Microsoft.Build": "0.1.0-preview-*", + "Microsoft.Build.Framework": "0.1.0-preview-*", + "Microsoft.Build.Targets": "0.1.0-preview-*", + "Microsoft.Build.Tasks.Core": "0.1.0-preview-*", + "Microsoft.Build.Utilities.Core": "0.1.0-preview-*", "System.Runtime.Serialization.Json": "4.0.2-rc2-*", "Microsoft.FSharp.Core.netcore": "1.0.0-*", "FSharp.Compiler.Service.netcore": "1.0.0-*", diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 785d8c70e2..e87526bd1e 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -4431,7 +4431,7 @@ module Project35b = let projPath = Path.ChangeExtension(fileName1, ".fsproj") let dllPath = Path.ChangeExtension(fileName1, ".dll") let args = mkProjectCommandLineArgs(dllPath, fileNames) - let args2 = Array.append args [| "-r: notexist.dll" |] + let args2 = Array.append args [| "-r:notexist.dll" |] let options = checker.GetProjectOptionsFromCommandLineArgs (projPath, args2) #else let options = checker.GetProjectOptionsFromScript(fileName1, fileSource1) |> Async.RunSynchronously From ee55c1048c7a506ea8ac4e032bba9a411c51f16a Mon Sep 17 00:00:00 2001 From: ncave Date: Tue, 31 May 2016 09:43:56 -0700 Subject: [PATCH 17/17] Removed old comment --- tests/service/EditorTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 98a2424a17..7064370cde 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -407,7 +407,7 @@ let _ = sprintf " %*.1f" 3 4.5 let _ = sprintf " %6.*f" 3 4.5 let _ = sprintf " %6.*%" 3 let _ = printf " %a" (fun _ _ -> ()) 2 -let _ = printf " %*a" 3 (fun _ _ -> ()) 2 //TODO: this fails in coreclr +let _ = printf " %*a" 3 (fun _ _ -> ()) 2 """ let file = "/home/user/Test.fsx"