Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating Generic Options #247

Open
biqas opened this issue Aug 13, 2024 · 1 comment
Open

Generating Generic Options #247

biqas opened this issue Aug 13, 2024 · 1 comment

Comments

@biqas
Copy link

biqas commented Aug 13, 2024

Hello,

This does not work:

[Union]
public partial record Response
{
    public partial record Ok;
    public partial record Ok<T>;
}

It complains that the abstract members are not implemented.

Also this does not work:

[Union]
public partial record Response<T>
{
    public partial record Ok;
    public partial record Ok(T Data);
}

Or this:

[Union]
public partial record Response
{
    public partial record Ok;
}
[Union]
public partial record Response<T>
{
    public partial record Ok(T Data);
}
@domn1995
Copy link
Owner

domn1995 commented Dec 7, 2024

I don't see a good argument for supporting the first code snippet. Maybe if you wouldn't mind expanding on why that would be valuable?

As for the second, there's two alternative designs that I believe fulfill your needs:

  • Have a single Ok(T? Data) variant. A null property would indicate that there's no data.
  • Name the generic variant something else like OkWithContent(T Data).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants