Apollo3zehn / PureHDF

A pure .NET library that makes reading and writing of HDF5 files (groups, datasets, attributes, ...) very easy.
MIT License
47 stars 16 forks source link

Setting an entry on a H5Group to null breaks writing #90

Closed Blackclaws closed 1 week ago

Blackclaws commented 1 month ago

I've done something unexpected that is I've set an entry to null as it was set by the return of a function.

This breaks in the NativeWriter.EncodeGroup function as this:

            else if (entry.Value is object objectDataset)

does not match null objects.

My suggestion would be to either explicitly check for null and handle that differently (possibly by skipping the value alltogether) or is there something like a Null Dataset?

Apollo3zehn commented 1 month ago

Could you send me some simple sample to reproduce the issue? Setting an entry to null should give you a compile time warning (in case <Nullable>enable</Nullable> is set in the project properties).

There is no null dataset, only null dataspace. The entries always need to be either a non-null value or be of type H5Dataset<T>, otherwise all type information is lost (null carries no runtime type information) and then PureHDF has no way to create the dataset in the HDF5 file.

Apollo3zehn commented 1 week ago

I will close this issue for now because I am preparing a v1 release. Feel free to reopen it (or open a new one) if the problem is not yet solved for you.