From 0e2ffa46548bde050a04ef562229cd68e6c6541a Mon Sep 17 00:00:00 2001 From: Jan Kristian Bjerke Date: Mon, 20 Mar 2017 13:49:16 +0100 Subject: [PATCH] Fix rect conversion Rect returned from automation as array can return negative width/height which is not supported by Rect. --- UiaComWrapper/InternalSchema.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/UiaComWrapper/InternalSchema.cs b/UiaComWrapper/InternalSchema.cs index 5b05f3f..274b133 100644 --- a/UiaComWrapper/InternalSchema.cs +++ b/UiaComWrapper/InternalSchema.cs @@ -273,7 +273,15 @@ private static object ConvertToRect(object value) double x = numArray[0]; double y = numArray[1]; double width = numArray[2]; - return new Rect(x, y, width, numArray[3]); + double height = numArray[3]; + + if (width < 0) + width = 0; + + if (height < 0) + height = 0; + + return new Rect(x, y, width, height); } private static object ConvertToRowOrColumnMajor(object value)