Skip to content

Pointers and Generics Are Not Handled with Projected Types #215

@JasonBock

Description

@JasonBock

To reproduce:

public interface ISurface
{
  unsafe void Create<T>(T* allocator) where T : unmanaged;
}

var expectations = Rock.Create<ISurface>();

This causes errors like:

Error - Id: CS0208, Description: Rocks\Rocks.RockCreateGenerator\IVkSurface_Rock_Create.g.cs(13,63): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('T')
Error - Id: CS0246, Description: Rocks\Rocks.RockCreateGenerator\IVkSurface_Rock_Create.g.cs(13,63): error CS0246: The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
Error - Id: CS1503, Description: Rocks\Rocks.RockCreateGenerator\IVkSurface_Rock_Create.g.cs(173,175): error CS1503: Argument 1: cannot convert from 'T* [Rocks\Rocks.RockCreateGenerator\IVkSurface_Rock_Create.g.cs(165)]' to 'T* [generator, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]'

The problem is the projected ArgumentEvaluationForTPointer delegate doesn't expose the T generic parameter, nor does it show up for ArgumentForTPointer. If that would trickle through (with the appropriate where T : unmanaged), then this should work.

Another possibility is to create UnmanagedArgument<T> where T : unmanaged, and see if that can be used when a pointer is in play with a generic (or even if it just shows up like int*, maybe....this will take some investigation).

This showed up wtih Silk.NET.Core.Contexts.IVkSurface

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions