Skip to content

[Feature]: Accept non-seekable streams in ReqIFDeserializer and ReqIFLoaderService  #91

Open

Description

@samatstariongroup

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the reqifsharp
  • I have searched open and closed issues to ensure it has not already been reported

Description

ReqIFDeserializer.Deserialize(Stream, ...) and DeserializeAsync read stream.Length in their argument check and then call stream.Seek(0, SeekOrigin.Begin); ReqIFLoaderService.LoadAsync also seeks on the stream it receives. Non-seekable streams support neither. Network streams, HTTP response streams and browser upload streams are not seekable, so callers have to copy them into a MemoryStream first. This is documented in the wiki now, but it is easy to miss.

Proposal

  • When stream.CanSeek is false, buffer the stream internally (or read it once without seeking) instead of failing; when it is seekable, keep the current behaviour.

Acceptance criteria

  • Deserializing from a non-seekable wrapper around a .reqif and a .reqifz file gives the same result as from a FileStream, for the sync and async methods and for ReqIFLoaderService.LoadAsync.

Steps to Reproduce

Pass a stream with CanSeek == false (for example an HTTP response stream, or a GZipStream in decompress mode around a compressed .reqif) to Deserialize: it throws NotSupportedException from the argument check (StreamBasedSerializerArgumentValidation, which reads stream.Length).

System Configuration

  • reqifsharp version: ReqIFSharp 10.1.2, ReqIFSharp.Extensions 5.2.2
  • Environment (Operating system, version and so on): Windows 11
  • .NET Framework version: .NET 10
  • Additional information: Found while planning editing and export in the ReqIF Viewer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions