Description
We have WinForms projects on .NET Framework that we are migrating to .NET 10+.
We've found that InitializeComponent throws on .NET 10:
System.ArgumentException : is not a valid value for Int32. (Parameter 'value')
----> System.IndexOutOfRangeException : Index was outside the bounds of the array.
at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.Drawing.PointConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.Resources.Extensions.DeserializingResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.Extensions.DeserializingResourceReader._LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.Extensions.DeserializingResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
[...]
This was traced back to having Points in the .resx files with leading white-space, e.g. 2, 200. This works find on .NET Framework.
Reproduction Steps
foreach (var s in new[] { "1,200", " 2, 200", " 3 , 200" })
{
Console.WriteLine(new System.Drawing.PointConverter().ConvertFrom(s));
}
PointConverterTest.zip
Expected behavior
Values with leading white-space can be converted.
All target frameworks (4.8, 10, 11) should print
{X=1,Y=200}
{X=2,Y=200}
{X=3,Y=200}
Actual behavior
Exception on 10 and 11:
System.ArgumentException
HResult=0x80070057
Message= is not a valid value for Int32. (Parameter 'value')
Source=System.ComponentModel.TypeConverter
StackTrace:
at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.Drawing.PointConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at Program.<Main>$(String[] args) in C:\slb\PointConverterTest\PointConverterTest\Program.cs:line 3
This exception was originally thrown at this call stack:
System.ComponentModel.BaseNumberConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, object)
Inner Exception 1:
IndexOutOfRangeException: Index was outside the bounds of the array.
Regression?
Yes, works on 4.8
Known Workarounds
NA
Configuration
10.x, 11.x (various versions), x64, Windows
Other information
No response
Description
We have WinForms projects on .NET Framework that we are migrating to .NET 10+.
We've found that InitializeComponent throws on .NET 10:
This was traced back to having Points in the .resx files with leading white-space, e.g.
2, 200. This works find on .NET Framework.Reproduction Steps
PointConverterTest.zip
Expected behavior
Values with leading white-space can be converted.
All target frameworks (4.8, 10, 11) should print
Actual behavior
Exception on 10 and 11:
Regression?
Yes, works on 4.8
Known Workarounds
NA
Configuration
10.x, 11.x (various versions), x64, Windows
Other information
No response