FixedWidthParserWriter icon indicating copy to clipboard operation
FixedWidthParserWriter copied to clipboard

Exception on Overflow

Open robertoosantos opened this issue 4 years ago • 0 comments

When I have a property value longer than the lenght, there should be an option if what to get an exception on this.

Ex.:

Property

[FixedWidthLineField(Start=1,Length=14)]
public string CNPJ { get; set; }

Program

        static void Main(string[] args)
        {
            var p = new Pagamento(){CNPJ="123456789012345"};
            var ps = new List<Pagamento>();
            ps.Add(p);
            
            p = new Pagamento(){CNPJ="12345678901234"};
            ps.Add(p);

            var ls = new FixedWidthLinesProvider<Pagamento>().Write(ps);
            
            foreach (var l in ls)
            {
                Console.WriteLine(l);
            }
        }

Result

12345678901234
12345678901234

But there is a data truncation that I may be concerned in some use case.

robertoosantos avatar Apr 25 '20 15:04 robertoosantos