NetTopologySuite / NetTopologySuite.IO.ShapeFile

The ShapeFile IO module for NTS.
33 stars 25 forks source link

Fix DbaseFileReader enumerator #67

Closed KubaSzostak closed 3 years ago

KubaSzostak commented 3 years ago

Fix NullReferenceException while reading DBF file:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=NetTopologySuite.IO.ShapeFile
  StackTrace:
   at NetTopologySuite.IO.DbaseFileReader.DbaseFileEnumerator..ctor(DbaseFileReader parent) in D:\Work.Dev\VS\Coordinatus.NET\NetTopologySuite.IO.ShapeFile\src\NetTopologySuite.IO.ShapeFile\Dbase\DbaseFileReader.FullFat.cs:line 20

Code raising exception:

var dbfReader = new DbaseFileReader(dbfPath, Encoding.UTF8);
foreach (var dbf in dbfReader)
{
    Debug.WriteLine(dbf);
}
DGuidi commented 3 years ago

a test that reproduces the error will be helpful

KubaSzostak commented 3 years ago

This issue will be resolved by #48.

airbreather commented 3 years ago

This issue will be resolved by #48.

I would advise not holding your breath on that issue. It's quite a tall order to rewrite all this code, and I haven't really had enough free time to put into doing that.

I think this change would probably be fine, but like @DGuidi said, I'd like to see a specific test that fails before the change and passes afterward, so that we can better understand the issue that raises it and avoid raising it again.