GeometryGym / GeometryGymIFC

C# classes to generate and parse OpenBIM IFC files
Other
269 stars 97 forks source link

GeometryGymIFC_Core: 0.1.24: Exception when calling DatabaseIfc.WriteStream #59

Open talanc opened 2 years ago

talanc commented 2 years ago

Message:  Test method threw exception: System.ObjectDisposedException: Cannot write to a closed TextWriter.

Stack Trace:  __Error.WriterClosed() StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) StreamWriter.Flush() DatabaseIfc.WriteStream(Stream stream, String filename) ....

This issue was introduced in version 0.1.24 (the latest version).

SerializationIfcSTEP.WriteSTEP now calls TextWriter.Close before returning to the caller, then DatabaseIfc.WriteStream calls Flush on that closed TextWriter.

My suggestion to fix would be to remove the Close line in WriteSTEP. The TextWriter is a parameter, so it should be left up the caller to clean it up.

(Also the WriteSTEPFile introduced a Close, but that's OK because it's closing a local variable)

I would submit a PR to fix but it's an issue with GeometryGymIFC_Core, and I think you haven't pushed your (great) .NET Standard version to GitHub.

jmirtsch commented 2 years ago

Thanks, you're absolutely right. I've just made a commit with a fix, https://github.com/GeometryGym/GeometryGymIFC/commit/a2677af05ae074bd717b024910b7b778fe4ae92a

The project for the core dll is in the solution, https://github.com/GeometryGym/GeometryGymIFC/tree/master/DLL%20Projects/GeometryGymIFCcore The code is common to all projects as referenced into each project in a "link" role. Let me know if that doesn't make sense.

I'll be pushing an update to nuget very soon.