Skip to content

Commit 5b1a3ae

Browse files
authored
apply formatting (fix build) (#13209)
* preformat * apply formatting
1 parent 36af364 commit 5b1a3ae

File tree

16 files changed

+484
-162
lines changed

16 files changed

+484
-162
lines changed

src/FSharp.Core/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
# FSharp.Core uses more "conservative" settings - more lines etc.
2+
13
[*.fs]
4+
max_line_length=120
25
fsharp_max_function_binding_width=1
6+
fsharp_max_if_then_else_short_width=40

src/FSharp.Core/QueryExtensions.fs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,33 @@ open Microsoft.FSharp.Quotations
1111
open Microsoft.FSharp.Quotations.DerivedPatterns
1212
open Microsoft.FSharp.Reflection
1313
open Microsoft.FSharp.Linq.RuntimeHelpers
14+
open System.Collections
15+
open System.Collections.Concurrent
1416
open System.Collections.Generic
1517
open System.Linq
1618
open System.Linq.Expressions
19+
open System.Reflection
1720

1821
// ----------------------------------------------------------------------------
1922

2023
/// A type used to reconstruct a grouping after applying a mutable->immutable mapping transformation
2124
/// on a result of a query.
2225
type Grouping<'K, 'T>(key: 'K, values: seq<'T>) =
23-
interface System.Linq.IGrouping<'K, 'T> with
26+
interface IGrouping<'K, 'T> with
2427
member _.Key = key
2528

26-
interface System.Collections.IEnumerable with
29+
interface IEnumerable with
2730
member _.GetEnumerator() =
28-
values.GetEnumerator() :> System.Collections.IEnumerator
31+
values.GetEnumerator() :> IEnumerator
2932

30-
interface System.Collections.Generic.IEnumerable<'T> with
33+
interface Generic.IEnumerable<'T> with
3134
member _.GetEnumerator() =
3235
values.GetEnumerator()
3336

3437
module internal Adapters =
3538

3639
let memoize f =
37-
let d =
38-
new System.Collections.Concurrent.ConcurrentDictionary<Type, 'b>(HashIdentity.Structural)
40+
let d = new ConcurrentDictionary<Type, 'b>(HashIdentity.Structural)
3941

4042
fun x -> d.GetOrAdd(x, (fun r -> f r))
4143

@@ -46,13 +48,13 @@ module internal Adapters =
4648

4749
let MemberInitializationHelperMeth =
4850
methodhandleof (fun x -> LeafExpressionConverter.MemberInitializationHelper x)
49-
|> System.Reflection.MethodInfo.GetMethodFromHandle
50-
:?> System.Reflection.MethodInfo
51+
|> MethodInfo.GetMethodFromHandle
52+
:?> MethodInfo
5153

5254
let NewAnonymousObjectHelperMeth =
5355
methodhandleof (fun x -> LeafExpressionConverter.NewAnonymousObjectHelper x)
54-
|> System.Reflection.MethodInfo.GetMethodFromHandle
55-
:?> System.Reflection.MethodInfo
56+
|> MethodInfo.GetMethodFromHandle
57+
:?> MethodInfo
5658

5759
// The following patterns are used to recognize object construction
5860
// using the 'new O(Prop1 = <e>, Prop2 = <e>)' syntax
@@ -73,7 +75,8 @@ module internal Adapters =
7375
let rec propSetList acc x =
7476
match x with
7577
// detect " v.X <- y"
76-
| ((Patterns.PropertySet (Some (Patterns.Var var), _, _, _)) as p) :: xs when var = varArg -> propSetList (p :: acc) xs
78+
| ((Patterns.PropertySet (Some (Patterns.Var var), _, _, _)) as p) :: xs when var = varArg ->
79+
propSetList (p :: acc) xs
7780
// skip unit values
7881
| (Patterns.Value (v, _)) :: xs when v = null -> propSetList acc xs
7982
// detect "v"
@@ -190,8 +193,7 @@ module internal Adapters =
190193
let fields =
191194
Microsoft.FSharp.Reflection.FSharpType.GetRecordFields(
192195
typ,
193-
System.Reflection.BindingFlags.Public
194-
||| System.Reflection.BindingFlags.NonPublic
196+
BindingFlags.Public ||| BindingFlags.NonPublic
195197
)
196198

197199
match fields |> Array.tryFindIndex (fun p -> p = propInfo) with
@@ -223,18 +225,19 @@ module internal Adapters =
223225

224226
match convs with
225227
| x1 :: x2 :: x3 :: x4 :: x5 :: x6 :: x7 :: x8 :: tail ->
226-
RewriteTupleType ty (List.map2 ConvImmutableTypeToMutableType [ x1; x2; x3; x4; x5; x6; x7; TupleConv(x8 :: tail) ])
228+
let els = [ x1; x2; x3; x4; x5; x6; x7; TupleConv(x8 :: tail) ]
229+
RewriteTupleType ty (List.map2 ConvImmutableTypeToMutableType els)
227230
| _ -> RewriteTupleType ty (List.map2 ConvImmutableTypeToMutableType convs)
228231
| RecordConv (_, convs) ->
229232
assert (isPartiallyImmutableRecord ty)
230233
let types = [| for f in FSharpType.GetRecordFields ty -> f.PropertyType |]
231234
ConvImmutableTypeToMutableType (TupleConv convs) (FSharpType.MakeTupleType types)
232235
| GroupingConv (_keyTy, _elemTy, conv) ->
233236
assert ty.IsGenericType
234-
assert (ty.GetGenericTypeDefinition() = typedefof<System.Linq.IGrouping<_, _>>)
237+
assert (ty.GetGenericTypeDefinition() = typedefof<IGrouping<_, _>>)
235238
let keyt1 = ty.GetGenericArguments().[0]
236239
let valt1 = ty.GetGenericArguments().[1]
237-
typedefof<System.Linq.IGrouping<_, _>>.MakeGenericType [| keyt1; ConvImmutableTypeToMutableType conv valt1 |]
240+
typedefof<IGrouping<_, _>>.MakeGenericType [| keyt1; ConvImmutableTypeToMutableType conv valt1 |]
238241
| SeqConv conv ->
239242
assert ty.IsGenericType
240243
let isIQ = ty.GetGenericTypeDefinition() = typedefof<IQueryable<_>>
@@ -256,14 +259,14 @@ module internal Adapters =
256259
let mhandle =
257260
(methodhandleof (fun x -> LeafExpressionConverter.NewAnonymousObjectHelper x))
258261

259-
let minfo =
260-
(System.Reflection.MethodInfo.GetMethodFromHandle mhandle) :?> System.Reflection.MethodInfo
262+
let minfo = (MethodInfo.GetMethodFromHandle mhandle) :?> MethodInfo
261263

262264
let gmd = minfo.GetGenericMethodDefinition()
263265

264266
(fun tm ->
265267
match tm with
266-
| Patterns.Call (_obj, minfo2, _args) -> minfo2.IsGenericMethod && (gmd = minfo2.GetGenericMethodDefinition())
268+
| Patterns.Call (_obj, minfo2, _args) ->
269+
minfo2.IsGenericMethod && (gmd = minfo2.GetGenericMethodDefinition())
267270
| _ -> false)
268271

269272
/// Cleanup the use of property-set object constructions in leaf expressions that form parts of F# queries.
@@ -305,7 +308,8 @@ module internal Adapters =
305308
// rewrite bottom-up
306309
let e =
307310
match e with
308-
| ExprShape.ShapeCombination (comb, args) -> ExprShape.RebuildShapeCombination(comb, List.map SimplifyConsumingExpr args)
311+
| ExprShape.ShapeCombination (comb, args) ->
312+
ExprShape.RebuildShapeCombination(comb, List.map SimplifyConsumingExpr args)
309313
| ExprShape.ShapeLambda (v, body) -> Expr.Lambda(v, SimplifyConsumingExpr body)
310314
| ExprShape.ShapeVar _ -> e
311315

src/FSharp.Core/array.fs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ module Array =
244244

245245
// Wrap a StructBox around all keys in case the key type is itself a type using null as a representation
246246
let countByRefType (projection: 'T -> 'Key) (array: 'T[]) =
247-
countByImpl RuntimeHelpers.StructBox<'Key>.Comparer (fun t -> RuntimeHelpers.StructBox(projection t)) (fun sb -> sb.Value) array
247+
countByImpl
248+
RuntimeHelpers.StructBox<'Key>.Comparer
249+
(fun t -> RuntimeHelpers.StructBox(projection t))
250+
(fun sb -> sb.Value)
251+
array
248252

249253
[<CompiledName("CountBy")>]
250254
let countBy (projection: 'T -> 'Key) (array: 'T[]) =
@@ -570,7 +574,11 @@ module Array =
570574

571575
// Wrap a StructBox around all keys in case the key type is itself a type using null as a representation
572576
let groupByRefType (keyf: 'T -> 'Key) (array: 'T[]) =
573-
groupByImpl RuntimeHelpers.StructBox<'Key>.Comparer (fun t -> RuntimeHelpers.StructBox(keyf t)) (fun sb -> sb.Value) array
577+
groupByImpl
578+
RuntimeHelpers.StructBox<'Key>.Comparer
579+
(fun t -> RuntimeHelpers.StructBox(keyf t))
580+
(fun sb -> sb.Value)
581+
array
574582

575583
[<CompiledName("GroupBy")>]
576584
let groupBy (projection: 'T -> 'Key) (array: 'T[]) =
@@ -822,7 +830,12 @@ module Array =
822830

823831
count
824832

825-
let private createMask<'a> (f: 'a -> bool) (src: array<'a>) (maskArrayOut: byref<array<uint32>>) (leftoverMaskOut: byref<uint32>) =
833+
let private createMask<'a>
834+
(f: 'a -> bool)
835+
(src: array<'a>)
836+
(maskArrayOut: byref<array<uint32>>)
837+
(leftoverMaskOut: byref<uint32>)
838+
=
826839
let maskArrayLength = src.Length / 0x20
827840

828841
// null when there are less than 32 items in src array.
@@ -1208,7 +1221,10 @@ module Array =
12081221

12091222
if len % chunkSize <> 0 then
12101223
res.[chunkCount - 1] <-
1211-
Microsoft.FSharp.Primitives.Basics.Array.subUnchecked ((chunkCount - 1) * chunkSize) (len % chunkSize) array
1224+
Microsoft.FSharp.Primitives.Basics.Array.subUnchecked
1225+
((chunkCount - 1) * chunkSize)
1226+
(len % chunkSize)
1227+
array
12121228

12131229
res
12141230

@@ -1776,7 +1792,11 @@ module Array =
17761792

17771793
for j in 1 .. len - 1 do
17781794
if lenInner <> array.[j].Length then
1779-
invalidArgDifferentArrayLength "array.[0]" lenInner (String.Format("array.[{0}]", j)) array.[j].Length
1795+
invalidArgDifferentArrayLength
1796+
"array.[0]"
1797+
lenInner
1798+
(String.Format("array.[{0}]", j))
1799+
array.[j].Length
17801800

17811801
let result: 'T[][] =
17821802
Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked lenInner

src/FSharp.Core/async.fs

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -870,13 +870,15 @@ module AsyncPrimitives =
870870
/// - Create Thread and call Start() with exception protection. We don't expect this
871871
/// to fail but protect nevertheless.
872872
let CreateSwitchToNewThreadAsync () =
873-
MakeAsyncWithCancelCheck(fun ctxt -> ctxt.ProtectCode(fun () -> ctxt.trampolineHolder.StartThreadWithTrampoline ctxt.cont))
873+
MakeAsyncWithCancelCheck(fun ctxt ->
874+
ctxt.ProtectCode(fun () -> ctxt.trampolineHolder.StartThreadWithTrampoline ctxt.cont))
874875

875876
/// - Initial cancellation check
876877
/// - Call ThreadPool.QueueUserWorkItem with exception protection. We don't expect this
877878
/// to fail but protect nevertheless.
878879
let CreateSwitchToThreadPoolAsync () =
879-
MakeAsyncWithCancelCheck(fun ctxt -> ctxt.ProtectCode(fun () -> ctxt.trampolineHolder.QueueWorkItemWithTrampoline ctxt.cont))
880+
MakeAsyncWithCancelCheck(fun ctxt ->
881+
ctxt.ProtectCode(fun () -> ctxt.trampolineHolder.QueueWorkItemWithTrampoline ctxt.cont))
880882

881883
/// Post back to the sync context regardless of which continuation is taken
882884
/// - Call syncCtxt.Post with exception protection
@@ -917,7 +919,8 @@ module AsyncPrimitives =
917919
// This logic was added in F# 2.0 though is incorrect from the perspective of
918920
// how SynchronizationContext is meant to work. However the logic works for
919921
// mainline scenarios (WinForms/WPF) and for compatibility reasons we won't change it.
920-
| _ when Object.Equals(syncCtxt, currentSyncCtxt) && thread.Equals Thread.CurrentThread -> executeImmediately ()
922+
| _ when Object.Equals(syncCtxt, currentSyncCtxt) && thread.Equals Thread.CurrentThread ->
923+
executeImmediately ()
921924
| _ -> trampolineHolder.PostOrQueueWithTrampoline syncCtxt action
922925

923926
member _.PostOrQueueWithTrampoline res =
@@ -1074,7 +1077,7 @@ module AsyncPrimitives =
10741077
(typeof<FuncDelegate<'T>>)
10751078
.GetMethod("Invoke", BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Instance)
10761079

1077-
System.Delegate.CreateDelegate(typeof<'Delegate>, obj, invokeMeth) :?> 'Delegate
1080+
Delegate.CreateDelegate(typeof<'Delegate>, obj, invokeMeth) :?> 'Delegate
10781081

10791082
[<DebuggerHidden>]
10801083
let QueueAsync cancellationToken cont econt ccont computation =
@@ -1429,7 +1432,9 @@ type Async =
14291432
static member CancelCheck() =
14301433
unitAsync
14311434

1432-
static member FromContinuations(callback: ('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) : Async<'T> =
1435+
static member FromContinuations
1436+
(callback: ('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit)
1437+
: Async<'T> =
14331438
MakeAsyncWithCancelCheck(fun ctxt ->
14341439
let mutable underCurrentThreadStack = true
14351440
let mutable contToTailCall = None
@@ -1451,7 +1456,11 @@ type Async =
14511456
ctxt.trampolineHolder.ExecuteWithTrampoline(fun () -> cont x) |> unfake
14521457

14531458
try
1454-
callback (once ctxt.cont, (fun exn -> once ctxt.econt (ExceptionDispatchInfo.RestoreOrCapture exn)), once ctxt.ccont)
1459+
callback (
1460+
once ctxt.cont,
1461+
(fun exn -> once ctxt.econt (ExceptionDispatchInfo.RestoreOrCapture exn)),
1462+
once ctxt.ccont
1463+
)
14551464
with exn ->
14561465
if not (latch.Enter()) then
14571466
invalidOp (SR.GetString(SR.controlContinuationInvokedMultipleTimes))
@@ -1518,7 +1527,12 @@ type Async =
15181527
static member Parallel(computations: seq<Async<'T>>, ?maxDegreeOfParallelism: int) =
15191528
match maxDegreeOfParallelism with
15201529
| Some x when x < 1 ->
1521-
raise (System.ArgumentException(String.Format(SR.GetString(SR.maxDegreeOfParallelismNotPositive), x), "maxDegreeOfParallelism"))
1530+
raise (
1531+
System.ArgumentException(
1532+
String.Format(SR.GetString(SR.maxDegreeOfParallelismNotPositive), x),
1533+
"maxDegreeOfParallelism"
1534+
)
1535+
)
15221536
| _ -> ()
15231537

15241538
MakeAsyncWithCancelCheck(fun ctxt ->
@@ -1547,8 +1561,10 @@ type Async =
15471561

15481562
match firstExn with
15491563
| None -> ctxt.trampolineHolder.ExecuteWithTrampoline(fun () -> ctxt.cont results)
1550-
| Some (Choice1Of2 exn) -> ctxt.trampolineHolder.ExecuteWithTrampoline(fun () -> ctxt.econt exn)
1551-
| Some (Choice2Of2 cexn) -> ctxt.trampolineHolder.ExecuteWithTrampoline(fun () -> ctxt.ccont cexn)
1564+
| Some (Choice1Of2 exn) ->
1565+
ctxt.trampolineHolder.ExecuteWithTrampoline(fun () -> ctxt.econt exn)
1566+
| Some (Choice2Of2 cexn) ->
1567+
ctxt.trampolineHolder.ExecuteWithTrampoline(fun () -> ctxt.ccont cexn)
15521568
else
15531569
fake ()
15541570

@@ -1724,7 +1740,12 @@ type Async =
17241740
let cancellationToken =
17251741
defaultArg cancellationToken defaultCancellationTokenSource.Token
17261742

1727-
AsyncPrimitives.StartWithContinuations cancellationToken computation continuation exceptionContinuation cancellationContinuation
1743+
AsyncPrimitives.StartWithContinuations
1744+
cancellationToken
1745+
computation
1746+
continuation
1747+
exceptionContinuation
1748+
cancellationContinuation
17281749

17291750
static member StartWithContinuations
17301751
(
@@ -1781,7 +1802,8 @@ type Async =
17811802
DisposeCancellationRegistration &registration
17821803
DisposeTimer &timer
17831804

1784-
ctxt.trampolineHolder.ExecuteWithTrampoline(fun () -> ctxt.ccont (OperationCanceledException(ctxt.token)))
1805+
ctxt.trampolineHolder.ExecuteWithTrampoline(fun () ->
1806+
ctxt.ccont (OperationCanceledException(ctxt.token)))
17851807
|> unfake)
17861808
)
17871809
|> Some
@@ -1847,7 +1869,8 @@ type Async =
18471869
UnregisterWaitHandle &rwh
18481870

18491871
// Call the cancellation continuation
1850-
ctxt.trampolineHolder.ExecuteWithTrampoline(fun () -> ctxt.ccont (OperationCanceledException(ctxt.token)))
1872+
ctxt.trampolineHolder.ExecuteWithTrampoline(fun () ->
1873+
ctxt.ccont (OperationCanceledException(ctxt.token)))
18511874
|> unfake)
18521875
)
18531876
|> Some
@@ -1929,7 +1952,11 @@ type Async =
19291952
let res = resultCell.GrabResult()
19301953
return res.Commit()
19311954
else
1932-
let! ok = Async.AwaitWaitHandle(resultCell.GetWaitHandle(), ?millisecondsTimeout = millisecondsTimeout)
1955+
let! ok =
1956+
Async.AwaitWaitHandle(
1957+
resultCell.GetWaitHandle(),
1958+
?millisecondsTimeout = millisecondsTimeout
1959+
)
19331960

19341961
if ok then
19351962
let res = resultCell.GrabResult()
@@ -2009,10 +2036,18 @@ type Async =
20092036
Async.FromBeginEnd((fun (iar, state) -> beginAction (arg, iar, state)), endAction, ?cancelAction = cancelAction)
20102037

20112038
static member FromBeginEnd(arg1, arg2, beginAction, endAction, ?cancelAction) : Async<'T> =
2012-
Async.FromBeginEnd((fun (iar, state) -> beginAction (arg1, arg2, iar, state)), endAction, ?cancelAction = cancelAction)
2039+
Async.FromBeginEnd(
2040+
(fun (iar, state) -> beginAction (arg1, arg2, iar, state)),
2041+
endAction,
2042+
?cancelAction = cancelAction
2043+
)
20132044

20142045
static member FromBeginEnd(arg1, arg2, arg3, beginAction, endAction, ?cancelAction) : Async<'T> =
2015-
Async.FromBeginEnd((fun (iar, state) -> beginAction (arg1, arg2, arg3, iar, state)), endAction, ?cancelAction = cancelAction)
2046+
Async.FromBeginEnd(
2047+
(fun (iar, state) -> beginAction (arg1, arg2, arg3, iar, state)),
2048+
endAction,
2049+
?cancelAction = cancelAction
2050+
)
20162051

20172052
static member AsBeginEnd<'Arg, 'T>
20182053
(computation: ('Arg -> Async<'T>))
@@ -2267,7 +2302,9 @@ module WebExtensions =
22672302
)
22682303
|> CreateTryWithFilterAsync(fun exn ->
22692304
match exn with
2270-
| :? System.Net.WebException as webExn when webExn.Status = System.Net.WebExceptionStatus.RequestCanceled && canceled ->
2305+
| :? System.Net.WebException as webExn when
2306+
webExn.Status = System.Net.WebExceptionStatus.RequestCanceled && canceled
2307+
->
22712308

22722309
Some(CreateAsyncResultAsync(AsyncResult.Canceled(OperationCanceledException webExn.Message)))
22732310
| _ -> None)

src/FSharp.Core/collections.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ module ComparisonIdentity =
5050
let inline Structural<'T when 'T: comparison> : IComparer<'T> =
5151
LanguagePrimitives.FastGenericComparer<'T>
5252

53-
let inline NonStructural<'T when 'T: (static member (<): 'T * 'T -> bool) and 'T: (static member (>): 'T * 'T -> bool)> : IComparer<'T> =
53+
let inline NonStructural<'T
54+
when 'T: (static member (<): 'T * 'T -> bool) and 'T: (static member (>): 'T * 'T -> bool)> : IComparer<'T> =
5455
{ new IComparer<'T> with
5556
member _.Compare(x, y) =
5657
NonStructuralComparison.compare x y

0 commit comments

Comments
 (0)