Skip to content
Merged
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b5304ae
Fix: Remove commas from numeric strings before conversion to prevent …
AbishekPonmudi Apr 21, 2025
9946284
Merge branch 'master' into patch-3
AbishekPonmudi Apr 22, 2025
1570669
Fix: Remove commas from numeric strings before conversion to prevent …
AbishekPonmudi Apr 22, 2025
82f8b7b
Fix: Remove AllowHexSpecifier in BigInteger parsing to support format…
AbishekPonmudi Apr 22, 2025
a66921a
Fix: Update BigInteger parsing to use Parse() and support thousands s…
AbishekPonmudi Apr 22, 2025
861177e
Fix: Update BigInteger parsing to use Parse() and support thousands s…
AbishekPonmudi Apr 22, 2025
8b0bf4e
Merge branch 'master' into patch-3
AbishekPonmudi Apr 24, 2025
ad2bde6
Fix: Remove commas from numeric strings before conversion to prevent …
AbishekPonmudi Apr 25, 2025
c2c1725
Remove commas from numeric strings before conversion to prevent casti…
AbishekPonmudi Apr 26, 2025
fd9cdc0
Fix: Remove commas from numeric strings before conversion to prevent …
AbishekPonmudi Apr 26, 2025
d76fcd3
Merge branch 'PowerShell:master' into patch-3
AbishekPonmudi Apr 28, 2025
1a4cc3f
Tests for BigInteger Parsing Across Cultures (#25396)
AbishekPonmudi Apr 28, 2025
c665f56
Tests for BigInteger Parsing Across Cultures (#25396)
AbishekPonmudi Apr 28, 2025
b461db9
Tests for BigInteger Parsing Across Cultures (#25396)
AbishekPonmudi Apr 28, 2025
ac4f844
Merge branch 'master' into patch-3
AbishekPonmudi May 2, 2025
15b60ec
Fix: Remove commas from numeric strings before conversion to prevent …
AbishekPonmudi May 5, 2025
332b9a1
Fix: Remove commas from numeric strings before conversion to prevent …
AbishekPonmudi May 5, 2025
fd3e07c
Fix: Remove commas from numeric strings before conversion to prevent …
AbishekPonmudi May 5, 2025
c3e8d41
Tests for BigInteger Parsing Across Cultures (PowerShell#25396)
AbishekPonmudi May 7, 2025
627c863
Merge branch 'master' into patch-3
AbishekPonmudi May 7, 2025
b5c28a3
Tests for BigInteger Parsing Across Cultures (PowerShell#25396)
AbishekPonmudi May 7, 2025
0fd3199
Merge branch 'master' into patch-3
AbishekPonmudi May 7, 2025
b9ca9fc
Tests for BigInteger Parsing Across Cultures (PowerShell#25396)
AbishekPonmudi May 7, 2025
010f04d
Tests for BigInteger Parsing Across Cultures (PowerShell#25396)
AbishekPonmudi May 7, 2025
e2bc432
Add Tests for BigInteger Parsing Across Cultures (#25396)
AbishekPonmudi May 8, 2025
c4a08ff
Delete test/powershell/engine/BigIntegerCultureHandling.test.ps1
AbishekPonmudi May 8, 2025
97ec872
Add Tests for BigInteger Parsing Across Cultures (#25396)
AbishekPonmudi May 8, 2025
c89ed59
Add Tests for BigInteger Parsing Across Cultures (#25396)
AbishekPonmudi May 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/System.Management.Automation/engine/LanguagePrimitives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,19 @@ public override bool CanConvertFrom(object sourceValue, Type destinationType)
/// <exception cref="PSInvalidCastException">When no conversion was possible.</exception>
public override object ConvertFrom(object sourceValue, Type destinationType, IFormatProvider formatProvider, bool ignoreCase)
{
string sourceAsString = (string)LanguagePrimitives.ConvertTo(sourceValue, typeof(string), formatProvider);
// Fix: Remove commas from numeric strings before conversion to prevent casting errors.
string sourceAsString = LanguagePrimitives.ConvertTo(sourceValue, typeof(string), formatProvider) as string;
Comment thread
iSazonov marked this conversation as resolved.
Outdated

if (sourceAsString != null){

string groupSeparator = formatProvider?.GetFormat(typeof(NumberFormatInfo)) is NumberFormatInfo nfi
? nfi.NumberGroupSeparator
: CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator;

sourceAsString = sourceAsString.Replace(groupSeparator, string.Empty); // Remove culture-specific group separator
}
return LanguagePrimitives.ConvertTo(sourceAsString, destinationType, formatProvider);

Comment thread
iSazonov marked this conversation as resolved.
Outdated
}

/// <summary>
Expand Down Expand Up @@ -2943,17 +2954,12 @@ private static object ConvertStringToInteger(
return result;
}

if (resultType == typeof(BigInteger))
{
// Fallback for BigInteger: manual parsing using any common format.
NumberStyles style = NumberStyles.AllowLeadingSign
| NumberStyles.AllowDecimalPoint
| NumberStyles.AllowExponent
| NumberStyles.AllowHexSpecifier;

if (resultType == typeof(BigInteger))
{
NumberStyles style = NumberStyles.Integer | NumberStyles.AllowThousands;

Comment thread
iSazonov marked this conversation as resolved.
return BigInteger.Parse(strToConvert, style, NumberFormatInfo.InvariantInfo);
}

// Fallback conversion for regular numeric types.
return GetIntegerSystemConverter(resultType).ConvertFrom(strToConvert);
}
Expand Down