diff --git a/.vsconfig b/.vsconfig new file mode 100644 index 00000000000..0be88d0ab81 --- /dev/null +++ b/.vsconfig @@ -0,0 +1,30 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Component.CoreEditor", + "Microsoft.VisualStudio.Workload.CoreEditor", + "Microsoft.VisualStudio.Component.NuGet", + "Microsoft.Net.Component.4.6.1.TargetingPack", + "Microsoft.VisualStudio.Component.Roslyn.Compiler", + "Microsoft.VisualStudio.Component.Roslyn.LanguageServices", + "Microsoft.VisualStudio.Component.FSharp", + "Microsoft.Net.Core.Component.SDK.2.1", + "Microsoft.NetCore.ComponentGroup.DevelopmentTools.2.1", + "Microsoft.Net.Component.4.7.2.SDK", + "Microsoft.Net.Component.4.7.2.TargetingPack", + "Microsoft.Net.ComponentGroup.DevelopmentPrerequisites", + "Microsoft.Component.MSBuild", + "Microsoft.VisualStudio.Component.TextTemplating", + "Microsoft.VisualStudio.Component.SQL.CLR", + "Microsoft.VisualStudio.Component.ManagedDesktop.Core", + "Microsoft.Net.Component.4.6.TargetingPack", + "Component.Microsoft.VisualStudio.LiveShare", + "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites", + "Microsoft.VisualStudio.Component.Debugger.JustInTime", + "Microsoft.VisualStudio.Component.FSharp.Desktop", + "Microsoft.VisualStudio.Workload.ManagedDesktop", + "Microsoft.VisualStudio.Component.VSSDK", + "Microsoft.VisualStudio.ComponentGroup.VisualStudioExtension.Prerequisites", + "Microsoft.VisualStudio.Workload.VisualStudioExtension" + ] +} \ No newline at end of file diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 6e3d12f0e0a..6b85aaef9cf 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -46,9 +46,10 @@ param ( [switch]$warnAsError = $true, [switch][Alias('test')]$testDesktop, [switch]$testCoreClr, - [switch]$testFSharpCompiler, - [switch]$testFSharpQA, + [switch]$testCambridge, + [switch]$testCompiler, [switch]$testFSharpCore, + [switch]$testFSharpQA, [switch]$testVs, [switch]$testAll, @@ -76,11 +77,12 @@ function Print-Usage() { Write-Host "" Write-Host "Test actions" Write-Host " -testAll Run all tests" + Write-Host " -testCambridge Run Cambridge tests" + Write-Host " -testCompiler Run FSharpCompiler unit tests" Write-Host " -testDesktop Run tests against full .NET Framework" Write-Host " -testCoreClr Run tests against CoreCLR" - Write-Host " -testFSharpCompiler Run F# Compiler unit tests" - Write-Host " -testFSharpQA Run F# Cambridge tests" Write-Host " -testFSharpCore Run FSharpCore unit tests" + Write-Host " -testFSharpQA Run F# Cambridge tests" Write-Host " -testVs Run F# editor unit tests" Write-Host "" Write-Host "Advanced settings:" @@ -285,11 +287,16 @@ try { TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework } - if ($testFSharpCompiler) { + if ($testCompiler) { TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework } + if ($testCambridge) { + TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework + TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework + } + if ($testVs) { TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\GetTypesVS.UnitTests\GetTypesVS.UnitTests.fsproj" -targetFramework $desktopTargetFramework TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $desktopTargetFramework diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs index 0a9768f1b3a..404ebf81b0c 100644 --- a/src/absil/ilreflect.fs +++ b/src/absil/ilreflect.fs @@ -1500,18 +1500,18 @@ let enablePInvoke = true // but we can run on Netcoreapp3.0 so ... use reflection to invoke the api, when we are executing on netcoreapp3.0 let definePInvokeMethod = typeof.GetMethod("DefinePInvokeMethod", [| - typeof; - typeof; - typeof; - typeof; - typeof; - typeof; - typeof; - typeof; - typeof; - typeof; - typeof; - typeof; + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof typeof |]) let enablePInvoke = definePInvokeMethod <> null diff --git a/tests/fsharp/core/pinvoke/test.fsx b/tests/fsharp/core/pinvoke/test.fsx index 3d8a4831c58..26f09b83e5d 100644 --- a/tests/fsharp/core/pinvoke/test.fsx +++ b/tests/fsharp/core/pinvoke/test.fsx @@ -1,138 +1,20 @@ // #Conformance #Interop #PInvoke #Structs +#if TESTS_AS_APP +module Core_csext +#endif #nowarn "9" open System open System.Runtime.InteropServices -open System.Windows.Forms open System.Drawing +let failures = ref [] -[] -let cdtInit((width: IntPtr), (height: IntPtr)) : unit = () - -let pinned (obj: obj) f = - let gch = GCHandle.Alloc(obj,GCHandleType.Pinned) in - try f(gch.AddrOfPinnedObject()) - finally - gch.Free() - -//The following types from the System namespace are blittable types: -// -//System.Byte -//System.SByte -//System.Int16 -//System.UInt16 -//System.Int32 -//System.UInt32 -//System.Int64 -//System.IntPtr -//System.UIntPtr -//The following complex types are also blittable types: -//One-dimensional arrays of blittable types, such as an array of integers. -//Formatted value types that contain only blittable types (and classes if they are marshaled as formatted types). - -// -// assert ((typeof<'a>) == (typeof) or -// (typeof<'a>) == (typeof) or -// etc. - -type PinBox<'a> = - { v : obj } - static member Create(x) = { v = box(x) } - member x.Value = (unbox x.v : 'a) - member x.Pin(f) = pinned(x.v) f - -let card_init () = - let width = PinBox<_>.Create(300) in - let height = PinBox<_>.Create(400) in - width.Pin (fun widthAddress -> - height.Pin (fun heightAddress -> - cdtInit (widthAddress, heightAddress))); - Printf.printf "width = %d\n" width.Value; - Printf.printf "height = %d\n" height.Value; - () - -do card_init() - -let asciiz (pBytes: nativeptr) = new System.String(pBytes) - -#nowarn "0044";; -#nowarn "0051";; - -open System -open System.Runtime.InteropServices -open Microsoft.FSharp.NativeInterop - -type voidptr = System.IntPtr - -//int (*derivs)(double, double [], double [], void *), -type DerivsFunction = delegate of double * double nativeptr * double nativeptr * voidptr -> int - -//int (*outputFn)(double, double*, void*) ); -type OutputFunction = delegate of double * double nativeptr * voidptr -> int - -[] -// Wrap the C function with the following signature: -// -extern int SolveODE2(double *ystart, int nvar, double x1, double x2, double eps, double h1, - double hmin, double hmax, int *nok, int *nbad, double dx, void *info, - DerivsFunction derivs, - OutputFunction outputFn); -module Array = - let inline pinObjUnscoped (obj: obj) = GCHandle.Alloc(obj,GCHandleType.Pinned) - - let inline pinObj (obj: obj) f = - let gch = pinObjUnscoped obj - try f gch - finally - gch.Free() - - [] - let inline pin (arr: 'T []) (f : nativeptr<'T> -> 'U) = - pinObj (box arr) (fun _ -> f (&&arr.[0])) - - -type NativeArray<'T when 'T : unmanaged>(ptr : nativeptr<'T>, len: int) = - member x.Ptr = ptr - [] - member inline x.Item - with get n = NativePtr.get x.Ptr n - and set n v = NativePtr.set x.Ptr n v - member x.Length = len -// Provide a nicer wrapper for use from F# code. This takes an F# array as input, -// and when the callbacks happen wraps up the returned native arrays in the -// F# NativeArray thin wrapper which lets you use nice syntax arr.[n] for getting and -// setting values of these arrays. -let solveODE ystart (x1,x2,eps,h1,hmin,hmax) (nok,nbad) dx derivs outputFn = - Array.pin ystart (fun ystartAddr -> - let nvar = Array.length ystart in - let mutable nok = nok in - let mutable nbad = nbad in - let info = 0n in - let derivsF = new DerivsFunction(fun x arr1 arr2 _ -> derivs x (new NativeArray<_>(arr1,nvar)) (new NativeArray<_>(arr2,nvar))) in - let outputFnF = new OutputFunction(fun x pY _ -> outputFn x) in - SolveODE2(ystartAddr,nvar,x1,x2,eps,h1,hmin,hmax,&&nok,&&nbad,dx,info,derivsF,outputFnF)) - -let example1() = - solveODE - // initial values - [| 1.0; 2.0 |] - // settings - (1.0,2.0,0.0001,1.0,1.0,1.0) - // nok,nbad - (10,20) - // dx - 0.05 - // Compute the derivatives. Note outp and inp are both NativeArrays, passed to us from C. - // So there is no bounds checking on these assignments - be careful! - // If it turns out that these arrays are of static known size then we can do better here. - (fun x inp outp -> - outp.[0] <- inp.[0] + 0.05; 1) - // output - (fun v -> printf "v = %G\n" v; 5) - - +let report_failure (s : string) = + stderr.Write" NO: " + stderr.WriteLine s + failures := !failures @ [s] module GetSystemTimeTest = open System @@ -241,3 +123,22 @@ module MemoryStatusTest2 = main() +(*--------------------*) + +#if TESTS_AS_APP +let RUN() = !failures +#else +let aa = + match !failures with + | [] -> + stdout.WriteLine "Test Passed" + System.IO.File.WriteAllText("test.ok","ok") + exit 0 + | messages -> + printfn "%A" messages + stdout.WriteLine "Test Failed" + exit 1 +#endif + + + diff --git a/tests/fsharp/single-test.fs b/tests/fsharp/single-test.fs index f593a721232..26b257d9449 100644 --- a/tests/fsharp/single-test.fs +++ b/tests/fsharp/single-test.fs @@ -206,6 +206,7 @@ let generateProjectArtifacts (pc:ProjectConfiguration) outputType (targetFramewo generateProjBody +let lockObj = obj() let singleTestBuildAndRunCore cfg copyFiles p = let sources = [] let loadSources = [] @@ -222,7 +223,19 @@ let singleTestBuildAndRunCore cfg copyFiles p = // optimize = true or false let executeSingleTestBuildAndRun outputType compilerType targetFramework optimize = let mutable result = false - let directory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() ) + let directory = + let mutable result = "" + lock lockObj <| (fun () -> + let rec loop () = + let dir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()) + if Directory.Exists(dir) then + loop () + else + Directory.CreateDirectory(dir) |>ignore + dir + result <- loop()) + result + let pc = { OutputType = outputType Framework = framework diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index 85339e4e6e9..e6ef7520a1c 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -59,18 +59,18 @@ module CoreTests = [] let ``comprehensionshw-FSI_BASIC`` () = singleTestBuildAndRun "core/comprehensions-hw" FSI_BASIC - [] - let ``genericmeasures-FSI_BASIC`` () = singleTestBuildAndRun "core/genericmeasures" FSI_BASIC - [] let ``genericmeasures-FSC_BASIC`` () = singleTestBuildAndRun "core/genericmeasures" FSC_BASIC [] - let ``innerpoly-FSI_BASIC`` () = singleTestBuildAndRun "core/innerpoly" FSI_BASIC + let ``genericmeasures-FSI_BASIC`` () = singleTestBuildAndRun "core/genericmeasures" FSI_BASIC [] let ``innerpoly-FSC_BASIC`` () = singleTestBuildAndRun "core/innerpoly" FSC_BASIC + [] + let ``innerpoly-FSI_BASIC`` () = singleTestBuildAndRun "core/innerpoly" FSI_BASIC + [] let ``namespaceAttributes-FSC_BASIC`` () = singleTestBuildAndRun "core/namespaces" FSC_BASIC @@ -216,7 +216,7 @@ module CoreTests = let ``test int32-FSI_BASIC`` () = singleTestBuildAndRun "core/int32" FSI_BASIC [] - let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun "core/quotes" FSC_BASIC // TODO: fails on coreclr + let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun "core/quotes" FSC_BASIC [] let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun "core/quotes" FSI_BASIC @@ -1313,6 +1313,40 @@ module CoreTests = // [] // let ``patterns-FSI_BASIC`` () = singleTestBuildAndRun "core/patterns" FSI_BASIC + [] + let ``pinvoke-FSC_BASIC`` () = singleTestBuildAndRun "core/pinvoke" FSC_BASIC + + [] + let ``pinvoke-FSI_BASIC`` () = + // We currently build targeting netcoreapp2_1, and will continue to do so through this VS cycle + // but we can run on Netcoreapp3.0 so ... use reflection to invoke the api, when we are executing on netcoreapp3.0 + let definePInvokeMethod = + typeof.GetMethod("DefinePInvokeMethod", [| + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof + typeof |]) + + let enablePInvokeOnCoreClr = definePInvokeMethod <> null + + if enablePInvokeOnCoreClr then + singleTestBuildAndRun "core/pinvoke" FSI_BASIC + + [] + let ``fsi_load-FSC_BASIC`` () = singleTestBuildAndRun "core/fsi-load" FSC_BASIC + + [] + let ``fsi_load-FSI_BASIC`` () = singleTestBuildAndRun "core/fsi-load" FSI_BASIC + #if !FSHARP_SUITE_DRIVES_CORECLR_TESTS [] let ``measures-AS_DLL`` () = singleTestBuildAndRun "core/measures" AS_DLL @@ -1341,24 +1375,6 @@ module CoreTests = [] let ``members-incremental-hw-mutrec-FSC_BASIC`` () = singleTestBuildAndRun "core/members/incremental-hw-mutrec" FSC_BASIC - [] - let pinvoke () = - let cfg = testConfig "core/pinvoke" - - fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"] - - peverifyWithArgs cfg "/nologo /MD" "test.exe" - - [] - let fsi_load () = - let cfg = testConfig "core/fsi-load" - - use testOkFile = fileguard cfg "test.ok" - - fsi cfg "%s" cfg.fsi_flags ["test.fsx"] - - testOkFile.CheckExists() - [] let queriesLeafExpressionConvert () = let cfg = testConfig "core/queriesLeafExpressionConvert"