Skip to content

Commit 702e12f

Browse files
author
dotnet-automerge-bot
authored
Merge pull request #6637 from Microsoft/merges/master-to-nullness
Merge master to nullness
2 parents 36a37fd + 454764b commit 702e12f

File tree

6 files changed

+134
-167
lines changed

6 files changed

+134
-167
lines changed

.vsconfig

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Component.CoreEditor",
5+
"Microsoft.VisualStudio.Workload.CoreEditor",
6+
"Microsoft.VisualStudio.Component.NuGet",
7+
"Microsoft.Net.Component.4.6.1.TargetingPack",
8+
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
9+
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
10+
"Microsoft.VisualStudio.Component.FSharp",
11+
"Microsoft.Net.Core.Component.SDK.2.1",
12+
"Microsoft.NetCore.ComponentGroup.DevelopmentTools.2.1",
13+
"Microsoft.Net.Component.4.7.2.SDK",
14+
"Microsoft.Net.Component.4.7.2.TargetingPack",
15+
"Microsoft.Net.ComponentGroup.DevelopmentPrerequisites",
16+
"Microsoft.Component.MSBuild",
17+
"Microsoft.VisualStudio.Component.TextTemplating",
18+
"Microsoft.VisualStudio.Component.SQL.CLR",
19+
"Microsoft.VisualStudio.Component.ManagedDesktop.Core",
20+
"Microsoft.Net.Component.4.6.TargetingPack",
21+
"Component.Microsoft.VisualStudio.LiveShare",
22+
"Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites",
23+
"Microsoft.VisualStudio.Component.Debugger.JustInTime",
24+
"Microsoft.VisualStudio.Component.FSharp.Desktop",
25+
"Microsoft.VisualStudio.Workload.ManagedDesktop",
26+
"Microsoft.VisualStudio.Component.VSSDK",
27+
"Microsoft.VisualStudio.ComponentGroup.VisualStudioExtension.Prerequisites",
28+
"Microsoft.VisualStudio.Workload.VisualStudioExtension"
29+
]
30+
}

eng/Build.ps1

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ param (
4646
[switch]$warnAsError = $true,
4747
[switch][Alias('test')]$testDesktop,
4848
[switch]$testCoreClr,
49-
[switch]$testFSharpCompiler,
50-
[switch]$testFSharpQA,
49+
[switch]$testCambridge,
50+
[switch]$testCompiler,
5151
[switch]$testFSharpCore,
52+
[switch]$testFSharpQA,
5253
[switch]$testVs,
5354
[switch]$testAll,
5455

@@ -77,11 +78,12 @@ function Print-Usage() {
7778
Write-Host ""
7879
Write-Host "Test actions"
7980
Write-Host " -testAll Run all tests"
81+
Write-Host " -testCambridge Run Cambridge tests"
82+
Write-Host " -testCompiler Run FSharpCompiler unit tests"
8083
Write-Host " -testDesktop Run tests against full .NET Framework"
8184
Write-Host " -testCoreClr Run tests against CoreCLR"
82-
Write-Host " -testFSharpCompiler Run F# Compiler unit tests"
83-
Write-Host " -testFSharpQA Run F# Cambridge tests"
8485
Write-Host " -testFSharpCore Run FSharpCore unit tests"
86+
Write-Host " -testFSharpQA Run F# Cambridge tests"
8587
Write-Host " -testVs Run F# editor unit tests"
8688
Write-Host ""
8789
Write-Host "Advanced settings:"
@@ -286,11 +288,16 @@ try {
286288
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework
287289
}
288290

289-
if ($testFSharpCompiler) {
291+
if ($testCompiler) {
290292
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework
291293
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework
292294
}
293295

296+
if ($testCambridge) {
297+
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework
298+
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework
299+
}
300+
294301
if ($testVs) {
295302
TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\GetTypesVS.UnitTests\GetTypesVS.UnitTests.fsproj" -targetFramework $desktopTargetFramework
296303
TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $desktopTargetFramework

src/absil/ilreflect.fs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,18 +1516,18 @@ let enablePInvoke = true
15161516
// but we can run on Netcoreapp3.0 so ... use reflection to invoke the api, when we are executing on netcoreapp3.0
15171517
let definePInvokeMethod =
15181518
typeof<TypeBuilder>.GetMethod("DefinePInvokeMethod", [|
1519-
typeof<string>;
1520-
typeof<string>;
1521-
typeof<string>;
1522-
typeof<System.Reflection.MethodAttributes>;
1523-
typeof<System.Reflection.CallingConventions>;
1524-
typeof<Type>;
1525-
typeof<Type[]>;
1526-
typeof<Type[]>;
1527-
typeof<Type[]>;
1528-
typeof<Type[][]>;
1529-
typeof<Type[][]>;
1530-
typeof<System.Runtime.InteropServices.CallingConvention>;
1519+
typeof<string>
1520+
typeof<string>
1521+
typeof<string>
1522+
typeof<System.Reflection.MethodAttributes>
1523+
typeof<System.Reflection.CallingConventions>
1524+
typeof<Type>
1525+
typeof<Type[]>
1526+
typeof<Type[]>
1527+
typeof<Type[]>
1528+
typeof<Type[][]>
1529+
typeof<Type[][]>
1530+
typeof<System.Runtime.InteropServices.CallingConvention>
15311531
typeof<System.Runtime.InteropServices.CharSet> |])
15321532

15331533
let enablePInvoke = definePInvokeMethod <> null

tests/fsharp/core/pinvoke/test.fsx

Lines changed: 27 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,20 @@
11
// #Conformance #Interop #PInvoke #Structs
22

3+
#if TESTS_AS_APP
4+
module Core_csext
5+
#endif
36

47
#nowarn "9"
58
open System
69
open System.Runtime.InteropServices
7-
open System.Windows.Forms
810
open System.Drawing
911

12+
let failures = ref []
1013

11-
[<DllImport("cards.dll")>]
12-
let cdtInit((width: IntPtr), (height: IntPtr)) : unit = ()
13-
14-
let pinned (obj: obj) f =
15-
let gch = GCHandle.Alloc(obj,GCHandleType.Pinned) in
16-
try f(gch.AddrOfPinnedObject())
17-
finally
18-
gch.Free()
19-
20-
//The following types from the System namespace are blittable types:
21-
//
22-
//System.Byte
23-
//System.SByte
24-
//System.Int16
25-
//System.UInt16
26-
//System.Int32
27-
//System.UInt32
28-
//System.Int64
29-
//System.IntPtr
30-
//System.UIntPtr
31-
//The following complex types are also blittable types:
32-
//One-dimensional arrays of blittable types, such as an array of integers.
33-
//Formatted value types that contain only blittable types (and classes if they are marshaled as formatted types).
34-
35-
//
36-
// assert ((typeof<'a>) == (typeof<int>) or
37-
// (typeof<'a>) == (typeof<int64>) or
38-
// etc.
39-
40-
type PinBox<'a> =
41-
{ v : obj }
42-
static member Create(x) = { v = box(x) }
43-
member x.Value = (unbox x.v : 'a)
44-
member x.Pin(f) = pinned(x.v) f
45-
46-
let card_init () =
47-
let width = PinBox<_>.Create(300) in
48-
let height = PinBox<_>.Create(400) in
49-
width.Pin (fun widthAddress ->
50-
height.Pin (fun heightAddress ->
51-
cdtInit (widthAddress, heightAddress)));
52-
Printf.printf "width = %d\n" width.Value;
53-
Printf.printf "height = %d\n" height.Value;
54-
()
55-
56-
do card_init()
57-
58-
let asciiz (pBytes: nativeptr<sbyte>) = new System.String(pBytes)
59-
60-
#nowarn "0044";;
61-
#nowarn "0051";;
62-
63-
open System
64-
open System.Runtime.InteropServices
65-
open Microsoft.FSharp.NativeInterop
66-
67-
type voidptr = System.IntPtr
68-
69-
//int (*derivs)(double, double [], double [], void *),
70-
type DerivsFunction = delegate of double * double nativeptr * double nativeptr * voidptr -> int
71-
72-
//int (*outputFn)(double, double*, void*) );
73-
type OutputFunction = delegate of double * double nativeptr * voidptr -> int
74-
75-
[<DllImport("PopDyn.dll")>]
76-
// Wrap the C function with the following signature:
77-
//
78-
extern int SolveODE2(double *ystart, int nvar, double x1, double x2, double eps, double h1,
79-
double hmin, double hmax, int *nok, int *nbad, double dx, void *info,
80-
DerivsFunction derivs,
81-
OutputFunction outputFn);
82-
module Array =
83-
let inline pinObjUnscoped (obj: obj) = GCHandle.Alloc(obj,GCHandleType.Pinned)
84-
85-
let inline pinObj (obj: obj) f =
86-
let gch = pinObjUnscoped obj
87-
try f gch
88-
finally
89-
gch.Free()
90-
91-
[<NoDynamicInvocation>]
92-
let inline pin (arr: 'T []) (f : nativeptr<'T> -> 'U) =
93-
pinObj (box arr) (fun _ -> f (&&arr.[0]))
94-
95-
96-
type NativeArray<'T when 'T : unmanaged>(ptr : nativeptr<'T>, len: int) =
97-
member x.Ptr = ptr
98-
[<NoDynamicInvocation>]
99-
member inline x.Item
100-
with get n = NativePtr.get x.Ptr n
101-
and set n v = NativePtr.set x.Ptr n v
102-
member x.Length = len
103-
// Provide a nicer wrapper for use from F# code. This takes an F# array as input,
104-
// and when the callbacks happen wraps up the returned native arrays in the
105-
// F# NativeArray thin wrapper which lets you use nice syntax arr.[n] for getting and
106-
// setting values of these arrays.
107-
let solveODE ystart (x1,x2,eps,h1,hmin,hmax) (nok,nbad) dx derivs outputFn =
108-
Array.pin ystart (fun ystartAddr ->
109-
let nvar = Array.length ystart in
110-
let mutable nok = nok in
111-
let mutable nbad = nbad in
112-
let info = 0n in
113-
let derivsF = new DerivsFunction(fun x arr1 arr2 _ -> derivs x (new NativeArray<_>(arr1,nvar)) (new NativeArray<_>(arr2,nvar))) in
114-
let outputFnF = new OutputFunction(fun x pY _ -> outputFn x) in
115-
SolveODE2(ystartAddr,nvar,x1,x2,eps,h1,hmin,hmax,&&nok,&&nbad,dx,info,derivsF,outputFnF))
116-
117-
let example1() =
118-
solveODE
119-
// initial values
120-
[| 1.0; 2.0 |]
121-
// settings
122-
(1.0,2.0,0.0001,1.0,1.0,1.0)
123-
// nok,nbad
124-
(10,20)
125-
// dx
126-
0.05
127-
// Compute the derivatives. Note outp and inp are both NativeArrays, passed to us from C.
128-
// So there is no bounds checking on these assignments - be careful!
129-
// If it turns out that these arrays are of static known size then we can do better here.
130-
(fun x inp outp ->
131-
outp.[0] <- inp.[0] + 0.05; 1)
132-
// output
133-
(fun v -> printf "v = %G\n" v; 5)
134-
135-
14+
let report_failure (s : string) =
15+
stderr.Write" NO: "
16+
stderr.WriteLine s
17+
failures := !failures @ [s]
13618

13719
module GetSystemTimeTest =
13820
open System
@@ -241,3 +123,22 @@ module MemoryStatusTest2 =
241123

242124
main()
243125

126+
(*--------------------*)
127+
128+
#if TESTS_AS_APP
129+
let RUN() = !failures
130+
#else
131+
let aa =
132+
match !failures with
133+
| [] ->
134+
stdout.WriteLine "Test Passed"
135+
System.IO.File.WriteAllText("test.ok","ok")
136+
exit 0
137+
| messages ->
138+
printfn "%A" messages
139+
stdout.WriteLine "Test Failed"
140+
exit 1
141+
#endif
142+
143+
144+

tests/fsharp/single-test.fs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ let generateProjectArtifacts (pc:ProjectConfiguration) outputType (targetFramewo
206206

207207
generateProjBody
208208

209+
let lockObj = obj()
209210
let singleTestBuildAndRunCore cfg copyFiles p =
210211
let sources = []
211212
let loadSources = []
@@ -222,7 +223,19 @@ let singleTestBuildAndRunCore cfg copyFiles p =
222223
// optimize = true or false
223224
let executeSingleTestBuildAndRun outputType compilerType targetFramework optimize =
224225
let mutable result = false
225-
let directory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() )
226+
let directory =
227+
let mutable result = ""
228+
lock lockObj <| (fun () ->
229+
let rec loop () =
230+
let dir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())
231+
if Directory.Exists(dir) then
232+
loop ()
233+
else
234+
Directory.CreateDirectory(dir) |>ignore
235+
dir
236+
result <- loop())
237+
result
238+
226239
let pc = {
227240
OutputType = outputType
228241
Framework = framework

0 commit comments

Comments
 (0)