-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
When trying to write to a file with a class that has a decimal? property and a format like 0;00 or 0;000, the values to the right of and including the decimal seem to be getting dropped.
Setup for Reproduction (.NET 6)
- Create a file that has a number value (one field should do)
a) Example:0000002340 - Create a class that has a
decimal?property:
public record TestClass
{
[FixedWidthLineField(Start = 1, Length = 10, Pad = '0', PadSide = PadSide.Left, Format = "0;00")]
public decimal? TestProperty { get; init; } = default;
}- Read the file into memory, then write the file again.
List<string> readData = File.ReadAllLines(@"PATH_TO_TEST_FILE").ToList();
TestClass testClass = new FixedWidthLinesProvider<TestClass>().Parse(readData).First();
// `testClass.TestProperty` should equal `23.4` after parsing the readData
var writeData = new FixedWidthLinesProvider<TestClass>().Write(new() { testClass });
File.WriteAllLines(@"PATH_TO_NEW_FILE");- Check the newly created file and notice it's
0000000023instead of the expected0000002340
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels