From ca376995792d2e2a1a7f39760989496702a8f603 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 6 Dec 2017 11:21:42 -0800 Subject: Fix handling of long values and baseUri in path fields --- src/WixToolset.Data/IntermediateFieldExtensions.cs | 53 ++++++++++++++-------- 1 file changed, 34 insertions(+), 19 deletions(-) (limited to 'src/WixToolset.Data/IntermediateFieldExtensions.cs') diff --git a/src/WixToolset.Data/IntermediateFieldExtensions.cs b/src/WixToolset.Data/IntermediateFieldExtensions.cs index be225452..89a6b903 100644 --- a/src/WixToolset.Data/IntermediateFieldExtensions.cs +++ b/src/WixToolset.Data/IntermediateFieldExtensions.cs @@ -21,26 +21,15 @@ namespace WixToolset.Data { // Null is always allowed. } - else if (field.Type == IntermediateFieldType.Bool && !(value is bool)) + else if (field.Type == IntermediateFieldType.String && !(value is string)) { if (value is int) { - data = ((int)value) != 0; + data = value.ToString(); } - else if (value is string str) + else if (value is bool b) { - if (str.Equals("yes", StringComparison.OrdinalIgnoreCase) || str.Equals("true", StringComparison.OrdinalIgnoreCase)) - { - data = true; - } - else if (str.Equals("no", StringComparison.OrdinalIgnoreCase) || str.Equals("false", StringComparison.OrdinalIgnoreCase)) - { - data = false; - } - else - { - throw new ArgumentException(nameof(value)); - } + data = b ? "true" : "false"; } else { @@ -58,15 +47,26 @@ namespace WixToolset.Data throw new ArgumentException(nameof(value)); } } - else if (field.Type == IntermediateFieldType.String && !(value is string)) + else if (field.Type == IntermediateFieldType.Bool && !(value is bool)) { if (value is int) { - data = value.ToString(); + data = ((int)value) != 0; } - else if (value is bool b) + else if (value is string str) { - data = b ? "true" : "false"; + if (str.Equals("yes", StringComparison.OrdinalIgnoreCase) || str.Equals("true", StringComparison.OrdinalIgnoreCase)) + { + data = true; + } + else if (str.Equals("no", StringComparison.OrdinalIgnoreCase) || str.Equals("false", StringComparison.OrdinalIgnoreCase)) + { + data = false; + } + else + { + throw new ArgumentException(nameof(value)); + } } else { @@ -84,6 +84,21 @@ namespace WixToolset.Data throw new ArgumentException(nameof(value)); } } + else if (field.Type == IntermediateFieldType.LargeNumber && !(value is long)) + { + if (value is string str && Int64.TryParse(str, out var number)) + { + data = number; + } + else if (value is int i) + { + data = (long)i; + } + else + { + throw new ArgumentException(nameof(value)); + } + } field.Value = new IntermediateFieldValue { -- cgit v1.2.3-55-g6feb