Skip to content

out Ref Struct Parameter Causes Issue #407

@JasonBock

Description

@JasonBock

To Reproduce
Define this class:

[assembly: Rock(typeof(ITest), Rocks.BuildType.Create | Rocks.BuildType.Make)]

public interface ITest
{
  void Perform(out ReadOnlySpan<byte> buffer);
}

Expected behavior
Mock code is generated with no issues:

Actual behavior
The following error is created:

The type 'ReadOnlySpan<byte>' may not be a ref struct or a type parameter allowing ref structs in order to use it as parameter 'T' in the generic type or method 'Arg.Any<T>()'

Additional context
This error happens because the following code is generated in the setup for Perform():

var @handler = new global::ITestCreateExpectations.Handler0
{
  @buffer = global::Rocks.Arg.Any<global::System.ReadOnlySpan<byte>>(),
};

Where @buffer is defined like this:

public global::Rocks.RefStructArgument<global::System.ReadOnlySpan<byte>> @buffer { get; set; }

So assigning it a value....is something I'm pretty positive Rocks can't do. I'm not sure what the fix is here, but I'll figure something out :)

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions