From db17c382a8c98f737723f2fec344e305d1ee8b6e Mon Sep 17 00:00:00 2001 From: Torsten Hoffmann Date: Wed, 27 Nov 2024 12:35:26 +0100 Subject: [PATCH] Fix - Serialization of type `System.Decimal` is missing 'd' suffix To ensure PowerShell parses a floating-point number representation as `System.Decimal`, append the suffix 'd'. Without this suffix, the representation will be parsed as `System.Double`, which can lead to a loss of precision. --- Source/Public/ConvertTo-Metadata.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Public/ConvertTo-Metadata.ps1 b/Source/Public/ConvertTo-Metadata.ps1 index e0c4fb5..c81d38c 100644 --- a/Source/Public/ConvertTo-Metadata.ps1 +++ b/Source/Public/ConvertTo-Metadata.ps1 @@ -91,9 +91,10 @@ function ConvertTo-Metadata { $InputObject -is [Int32] -or $InputObject -is [Int64] -or $InputObject -is [Double] -or - $InputObject -is [Decimal] -or $InputObject -is [Byte] ) { "$InputObject" + } elseif ($InputObject -is [Decimal]) { + "${InputObject}d" } elseif ($InputObject -is [String]) { "'{0}'" -f $InputObject.ToString().Replace("'", "''") } elseif ($InputObject -is [Collections.IDictionary]) {