Skip to content

IStream.Seek has optional parameter plibNewPosition, yet is defined as non-optional output parameter #1040

@Sebtous

Description

@Sebtous

Actual behavior

In CSWin32's IStream definition, Seek is defined as follows (in the c# version at least):

void Seek(long dlibMove, global::System.IO.SeekOrigin dwOrigin, out ulong plibNewPosition)

According to the official documentation however, plibNewPosition can be set to NULL if the caller is not interested in the new position.

At the moment, if you implement the IStream interface in managed code, and the caller chooses to set plibNewPosition to NULL, the managed implementation throws a System.NullReferenceException when you set the plibNewPosition, with no way to handle this case correctly as far as I can tell.

Expected behavior

IStream.Seek should probably be defined as follows:

unsafe void Seek(long dlibMove, global::System.IO.SeekOrigin dwOrigin, ulong* plibNewPosition)

Repro steps

  1. NativeMethods.txt content:
IStream
  1. NativeMethods.json content (if present):
{
  "$schema": "https://aka.ms/CsWin32.schema.json",
  "public": false,
  "allowMarshaling": true
}

Context

  • CsWin32 version: 0.3.18-beta
  • Win32Metadata version (if explicitly set by project): n/a
  • Target Framework: net7.0
  • LangVersion: n/a

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions