From 183919853f40c9f6886dec825f4b7e877f4d7bb7 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 18 Dec 2015 10:55:54 +0100 Subject: [PATCH] Proper null checks in C# operator == --- renderdocui/Code/FormatElement.cs | 4 ++-- renderdocui/Interop/FetchInfo.cs | 3 +++ renderdocui/Interop/Shader.cs | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/renderdocui/Code/FormatElement.cs b/renderdocui/Code/FormatElement.cs index 65185ae14..29efacd23 100644 --- a/renderdocui/Code/FormatElement.cs +++ b/renderdocui/Code/FormatElement.cs @@ -80,8 +80,8 @@ namespace renderdocui.Code } public static bool operator ==(FormatElement x, FormatElement y) { - if ((object)x == null) return false; - if ((object)y == null) return false; + if ((object)x == null) return (object)y == null; + if ((object)y == null) return (object)x == null; return x.name == y.name && x.buffer == y.buffer && diff --git a/renderdocui/Interop/FetchInfo.cs b/renderdocui/Interop/FetchInfo.cs index c253660a8..b66680168 100644 --- a/renderdocui/Interop/FetchInfo.cs +++ b/renderdocui/Interop/FetchInfo.cs @@ -146,6 +146,9 @@ namespace renderdoc } public static bool operator ==(ResourceFormat x, ResourceFormat y) { + if ((object)x == null) return (object)y == null; + if ((object)y == null) return (object)x == null; + if (x.special || y.special) return x.special == y.special && x.specialFormat == y.specialFormat; diff --git a/renderdocui/Interop/Shader.cs b/renderdocui/Interop/Shader.cs index be5a3bfdc..3f13a93af 100644 --- a/renderdocui/Interop/Shader.cs +++ b/renderdocui/Interop/Shader.cs @@ -482,6 +482,9 @@ namespace renderdoc } public static bool operator ==(BindpointMap x, BindpointMap y) { + if ((object)x == null) return (object)y == null; + if ((object)y == null) return (object)x == null; + return x.bindset == y.bindset && x.bind == y.bind; }