Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use isNull for null checks #410

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading