Skip to content

Commit 7792f38

Browse files
committed
Merge branch 'main' into provided-types-update
2 parents 15c7606 + 69dfe0e commit 7792f38

12 files changed

Lines changed: 45 additions & 42 deletions

File tree

src/FSharp.Data.DesignTime/CommonProviderImplementation/AssemblyResolver.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let init () =
2020
if not initialized then
2121
initialized <- true
2222

23-
if WebRequest.DefaultWebProxy <> null then
23+
if not (isNull WebRequest.DefaultWebProxy) then
2424
WebRequest.DefaultWebProxy.Credentials <- CredentialCache.DefaultNetworkCredentials
2525

2626
ProvidedTypes.ProvidedTypeDefinition.Logger

src/FSharp.Data.DesignTime/CommonProviderImplementation/Helpers.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ module internal ReflectionHelpers =
8080
type DisposableTypeProviderForNamespaces(config, ?assemblyReplacementMap) as x =
8181
inherit TypeProviderForNamespaces(config, ?assemblyReplacementMap = assemblyReplacementMap)
8282

83+
let lockObj = Object()
8384
let disposeActions = ResizeArray()
8485

8586
static let mutable idCount = 0
@@ -90,7 +91,7 @@ type DisposableTypeProviderForNamespaces(config, ?assemblyReplacementMap) as x =
9091
do idCount <- idCount + 1
9192

9293
let dispose typeNameOpt =
93-
lock disposeActions (fun () ->
94+
lock lockObj (fun () ->
9495
for i = disposeActions.Count - 1 downto 0 do
9596
let disposeAction = disposeActions.[i]
9697
let discard = disposeAction typeNameOpt
@@ -115,7 +116,7 @@ type DisposableTypeProviderForNamespaces(config, ?assemblyReplacementMap) as x =
115116
| _ -> None)
116117

117118
member _.AddDisposeAction action =
118-
lock disposeActions (fun () -> disposeActions.Add action)
119+
lock lockObj (fun () -> disposeActions.Add action)
119120

120121
member _.InvalidateOneType typeName =
121122
(use _holder = logTime "InvalidateOneType" (sprintf "%s in %O [%d]" typeName x id)
@@ -296,7 +297,7 @@ module internal ProviderHelpers =
296297
while max > 0 do
297298
let line = reader.ReadLine()
298299

299-
if line = null then
300+
if isNull line then
300301
max <- 0
301302
else
302303
line |> sb.AppendLine |> ignore

src/FSharp.Data.DesignTime/CommonProviderImplementation/QuotationBuilder.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2011-2015, Tomas Petricek (http://tomasp.net), Gustavo Guerra (http://functionalflow.co.uk), and other contributors
1+
// Copyright 2011-2015, Tomas Petricek (http://tomasp.net), Gustavo Guerra (http://functionalflow.co.uk), and other contributors
22
// Licensed under the Apache License, Version 2.0, see LICENSE.md in this project
33
//
44
// Utilities for building F# quotations without quotation literals
@@ -61,7 +61,7 @@ let (?) (typ: Type) (operation: string) (args1: 'T) (args2: 'U) : Expr =
6161
match typ.GetMember(operation, MemberTypes.All, flags) with
6262
| [| :? MethodInfo as mi |] ->
6363
let mi =
64-
if tyargs = [] then
64+
if List.isEmpty tyargs then
6565
mi
6666
else
6767
mi.MakeGenericMethod(tyargs |> Array.ofList)

src/FSharp.Data.Html.Core/HtmlOperations.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ module HtmlNode =
326326
let rec selectElements' level acc source =
327327

328328
// if we already have an empty list, terminate early
329-
if acc = [] then
329+
if List.isEmpty acc then
330330
[]
331331
else
332332

src/FSharp.Data.Html.Core/HtmlRuntime.fs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,7 @@ module HtmlRuntime =
267267

268268
let rowLengths =
269269
cells
270-
|> List.map (fun row ->
271-
row
272-
|> List.map (fun (_, col) -> colSpan col)
273-
|> List.fold (+) 0)
270+
|> List.map (fun row -> row |> List.sumBy (snd >> colSpan))
274271

275272
let numberOfColumns = List.max rowLengths
276273

src/FSharp.Data.Http/Http.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ module internal HttpHelpers =
16201620

16211621
let runningOnMono =
16221622
try
1623-
System.Type.GetType("Mono.Runtime") <> null
1623+
not (isNull (System.Type.GetType "Mono.Runtime"))
16241624
with e ->
16251625
false
16261626

@@ -1637,7 +1637,7 @@ module internal HttpHelpers =
16371637
let remoteStackTraceString =
16381638
typeof<exn>.GetField ("_remoteStackTraceString", BindingFlags.Instance ||| BindingFlags.NonPublic)
16391639

1640-
if remoteStackTraceString <> null then
1640+
if not (isNull remoteStackTraceString) then
16411641
remoteStackTraceString.SetValue(e, e.StackTrace + Environment.NewLine)
16421642
with _ ->
16431643
()
@@ -1651,7 +1651,7 @@ module internal HttpHelpers =
16511651
with
16521652
// If an exception happens, augment the message with the response
16531653
| :? WebException as exn ->
1654-
if exn.Response = null then reraisePreserveStackTrace exn
1654+
if isNull exn.Response then reraisePreserveStackTrace exn
16551655

16561656
let responseExn =
16571657
try
@@ -1749,12 +1749,12 @@ module internal HttpHelpers =
17491749
| "pragma" -> req.Headers.[HeaderEnum.Pragma] <- value
17501750
| "range" ->
17511751
if not (value.StartsWith("bytes=")) then
1752-
failwith "Invalid value for the Range header"
1752+
failwithf "Invalid value for the Range header (%O)" value
17531753

17541754
let bytes = value.Substring("bytes=".Length).Split('-')
17551755

17561756
if bytes.Length <> 2 then
1757-
failwith "Invalid value for the Range header"
1757+
failwithf "Invalid value for the Range header (%O)" bytes
17581758

17591759
req.AddRange(int64 bytes.[0], int64 bytes.[1])
17601760
| "proxy-authorization" -> req.Headers.[HeaderEnum.ProxyAuthorization] <- value
@@ -1803,7 +1803,7 @@ module internal HttpHelpers =
18031803
try
18041804
return! getResponseAsync req
18051805
with :? WebException as exc ->
1806-
if exc.Response <> null then
1806+
if not (isNull exc.Response) then
18071807
return exc.Response
18081808
else
18091809
reraisePreserveStackTrace exc
@@ -2164,7 +2164,7 @@ type Http private () =
21642164
(defaultArg silentCookieErrors false)
21652165

21662166
let contentType =
2167-
if resp.ContentType = null then
2167+
if isNull resp.ContentType then
21682168
"application/octet-stream"
21692169
else
21702170
resp.ContentType
@@ -2174,7 +2174,7 @@ type Http private () =
21742174
| :? HttpWebResponse as resp -> int resp.StatusCode, resp.CharacterSet
21752175
| _ -> 0, ""
21762176

2177-
let characterSet = if characterSet = null then "" else characterSet
2177+
let characterSet = if isNull characterSet then "" else characterSet
21782178

21792179
let stream = resp.GetResponseStream()
21802180

src/FSharp.Data.Json.Core/JsonValue.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ type private JsonParser(jsonText: string) =
300300
ensure (i + 9 < s.Length)
301301

302302
let unicodeChar (s: string) =
303-
if s.Length <> 8 then failwith "unicodeChar"
304-
if s.[0..1] <> "00" then failwith "unicodeChar"
303+
if s.Length <> 8 then failwithf "unicodeChar (%O)" s
304+
if s.[0..1] <> "00" then failwithf "unicodeChar (%O)" s
305305

306306
UnicodeHelper.getUnicodeSurrogatePair
307307
<| System.UInt32.Parse(s, NumberStyles.HexNumber)

src/FSharp.Data.Runtime.Utilities/StructuralInference.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ let parseUnitOfMeasure (provider: IUnitsOfMeasureProvider) (str: string) =
411411
let baseUnitStr = str.[.. str.Length - suffix.Length - 1]
412412
let baseUnit = provider.SI baseUnitStr
413413

414-
if baseUnit = null then
414+
if isNull baseUnit then
415415
None
416416
else
417417
baseUnit |> trans provider |> Some
@@ -422,7 +422,7 @@ let parseUnitOfMeasure (provider: IUnitsOfMeasureProvider) (str: string) =
422422
| Some _ -> unit
423423
| None ->
424424
let unit = provider.SI str
425-
if unit = null then None else Some unit
425+
if isNull unit then None else Some unit
426426

427427
/// The inferred types may be set explicitly via inline schemas.
428428
/// This table specifies the mapping from (the names that users can use) to (the types used).

src/FSharp.Data.Runtime.Utilities/TextRuntime.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type TextRuntime =
2020
else
2121
let mutable cache = TextRuntime.cultureInfoCache
2222

23-
if cache = null then
23+
if isNull cache then
2424
cache <- Dictionary<string, CultureInfo>()
2525
TextRuntime.cultureInfoCache <- cache
2626

src/FSharp.Data.WorldBank.Core/WorldBankRuntime.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module Implementation =
7373
Debug.WriteLine(
7474
sprintf
7575
"[WorldBank] got text: %s"
76-
(if doc = null then "null"
76+
(if isNull doc then "null"
7777
elif doc.Length > 50 then doc.[0..49] + "..."
7878
else doc)
7979
)
@@ -122,7 +122,7 @@ module Implementation =
122122
let name = ind?name.AsString().Trim([| '"' |]).Trim()
123123
let sourceName = ind?source?value.AsString()
124124

125-
if sources = []
125+
if List.isEmpty sources
126126
|| sources
127127
|> List.exists (fun source ->
128128
String.Compare(source, sourceName, StringComparison.OrdinalIgnoreCase) = 0) then

0 commit comments

Comments
 (0)