Cysharp / PrivateProxy

Source Generator and .NET 8 UnsafeAccessor based high-performance strongly-typed private accessor for unit testing and runtime.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support constructors

latonz opened this issue · comments

commented

Pretty much the title. It would be nice to have support for constructors. However, this may not fit the current extension method approach... but extern method could be exposed directly.

using PrivateProxy;

public class Sample
{
    private Sample(int x) {}
}

[GeneratePrivateProxy(typeof(Sample))]
partial struct SampleProxy;

// Generated
partial struct SampleProxy(Sample target)
{
    [UnsafeAccessor(UnsafeAccessorKind.Constructor)]
    public static extern Sample CreateSample(int x);
}

BTW thank you for this nice source generator!

Okay, that suggestion sounds good!