Skip to content

Commit

Permalink
Use isNull for null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Numpsy committed Mar 28, 2024
1 parent ad77e06 commit e843f15
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Avalonia.FuncUI.Diagnostics/InspectorState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module internal InspectorState =

let removed = Set.difference last next
for item in removed do
if item.Ref <> null then
if not (isNull (item.Ref)) then
ComponentHighlightAdorner.Remove item.Ref

shared.Components.Set next
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.FuncUI.Diagnostics/Lib/Lib.ComponentAdorner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type internal ComponentHighlightAdorner (adornedElement: Component) =

let layer = AdornerLayer.GetAdornerLayer adornedElement

if layer <> null then
if not (isNull layer) then
let alreadyAttached =
layer.Children
|> Seq.toList // copy to be safe
Expand All @@ -39,7 +39,7 @@ type internal ComponentHighlightAdorner (adornedElement: Component) =
static member Remove (adornedElement: Component) =
let layer = AdornerLayer.GetAdornerLayer adornedElement

if layer <> null then
if not (isNull layer) then
layer.Children
|> Seq.toList // copy to be safe
|> Seq.filter (fun c -> c.GetType() = typeof<ComponentHighlightAdorner>)
Expand Down
6 changes: 3 additions & 3 deletions src/Avalonia.FuncUI/Components/Lib/Lib.Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ module internal ComponentHelpers =
let ao: obj = a :> _
let bo: obj = b :> _

if ao <> null then
if bo <> null then
if not (isNull ao) then
if not (isNull bo) then
ao.Equals(bo)
else
false
else
bo = null
isNull bo

[<RequireQualifiedAccess>]
module internal String =
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.FuncUI/Components/Lib/Lib.DisposableBag.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ open System
type internal DisposableBag () =
let items = ResizeArray<IDisposable>()
member this.Add (item: IDisposable) =
if item <> null then
if not (isNull item) then
items.Add item

interface IDisposable with
member this.Dispose () =
for item in items do
if item <> null then
if not (isNull item) then
item.Dispose ()


4 changes: 2 additions & 2 deletions src/Avalonia.FuncUI/VirtualDom/VirtualDom.Patcher.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module internal rec Patcher =
open System.Threading

let private shouldPatch (value: obj, viewElement: ViewDelta) =
value <> null
not (isNull value)
&& value.GetType() = viewElement.ViewType
&& not viewElement.KeyDidChange

Expand Down Expand Up @@ -226,7 +226,7 @@ module internal rec Patcher =

let create (viewElement: ViewDelta) : AvaloniaObject =
let control =
if viewElement.ConstructorArgs <> null && viewElement.ConstructorArgs.Length > 0 then
if not (isNull (viewElement.ConstructorArgs)) && viewElement.ConstructorArgs.Length > 0 then
(viewElement.ViewType, viewElement.ConstructorArgs)
|> Activator.CreateInstance
|> Utils.cast<AvaloniaObject>
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.FuncUI/VirtualDom/VirtualDom.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module rec VirtualDom =

let updateRoot (host: ContentControl, last: IView option, next: IView option) =
let root : Control voption =
if host.Content <> null then
if not (isNull (host.Content)) then
match host.Content with
| :? Control as control -> ValueSome control
| _ -> ValueNone
Expand Down Expand Up @@ -54,7 +54,7 @@ module rec VirtualDom =
// TODO: share code with updateRoot
let internal updateBorderRoot (host: Border, last: IView option, next: IView option) =
let root : Control voption =
if host.Child <> null then
if not (isNull (host.Child)) then
ValueSome host.Child
else
ValueNone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Views =
StrokeLineCap = PenLineCap.Round
)

if canvasOutlet.Current <> null then
if not (isNull (canvasOutlet.Current)) then
canvasOutlet.Current.Children.Add line

| None ->
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/Component Examples/Examples.EnvApp/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Views =
StrokeLineCap = PenLineCap.Round
)

if canvasOutlet.Current <> null then
if not (isNull (canvasOutlet.Current)) then
canvasOutlet.Current.Children.Add line

| None ->
Expand Down

0 comments on commit e843f15

Please sign in to comment.