From 7ebaaf4ae0b86f574a04b97d1f959625f96fa3a2 Mon Sep 17 00:00:00 2001 From: monojenkins Date: Mon, 30 Mar 2020 16:50:03 -0400 Subject: [PATCH] [siminstaller] Update parsing xml because Apple changed their schema. (#8231) Apparently file sizes can be real numbers now, because in the manifest of downloadable simulators there's one entry where the fileSize is a real: fileSize 2049324382 when every other file size in the manifest is an integer. So handle real file sizes too, and fix file size parsing to not throw exceptions if the number can't be parsed. Maybe we'll get imaginary file sizes too one day... Fixes this exception: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at xsiminstaller.MainClass.Main (System.String[] args) [0x00617] in /Users/rolf/work/maccore/d16-6/xamarin-macios/tools/siminstaller/Program.cs:194 Co-authored-by: Rolf Bjarne Kvinge --- tools/siminstaller/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/siminstaller/Program.cs b/tools/siminstaller/Program.cs index d20beffaea8a..426345196bb0 100644 --- a/tools/siminstaller/Program.cs +++ b/tools/siminstaller/Program.cs @@ -171,7 +171,7 @@ public static int Main (string [] args) var versionNode = downloadable.SelectSingleNode ("key[text()='version']/following-sibling::string"); var sourceNode = downloadable.SelectSingleNode ("key[text()='source']/following-sibling::string"); var identifierNode = downloadable.SelectSingleNode ("key[text()='identifier']/following-sibling::string"); - var fileSizeNode = downloadable.SelectSingleNode ("key[text()='fileSize']/following-sibling::integer"); + var fileSizeNode = downloadable.SelectSingleNode ("key[text()='fileSize']/following-sibling::integer|key[text()='fileSize']/following-sibling::real"); var installPrefixNode = downloadable.SelectSingleNode ("key[text()='userInfo']/following-sibling::dict/key[text()='InstallPrefix']/following-sibling::string"); var version = versionNode.InnerText; @@ -191,7 +191,8 @@ public static int Main (string [] args) var name = Replace (nameNode.InnerText, dict); var source = Replace (sourceNode.InnerText, dict); var installPrefix = Replace (installPrefixNode.InnerText, dict); - var fileSize = long.Parse (fileSizeNode.InnerText); + double.TryParse (fileSizeNode?.InnerText, out var parsedFileSize); + var fileSize = (long) parsedFileSize; var installed = false; var updateAvailable = false;