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

Consider Implementing IParseable in .NET 6 #314

Open
RehanSaeed opened this issue Aug 11, 2021 · 3 comments
Open

Consider Implementing IParseable in .NET 6 #314

RehanSaeed opened this issue Aug 11, 2021 · 3 comments
Labels
enhancement Issues describing an enhancement or pull requests adding an enhancement.

Comments

@RehanSaeed
Copy link
Owner

RehanSaeed commented Aug 11, 2021

Describe the feature

See https://devblogs.microsoft.com/dotnet/preview-features-in-net-6-generic-math/#static-abstracts-in-interfaces

public interface IParseable<TSelf>
    where TSelf : IParseable<TSelf>
{
    static abstract TSelf Parse(string s, IFormatProvider? provider);

    static abstract bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out TSelf result);
}
@RehanSaeed RehanSaeed added the enhancement Issues describing an enhancement or pull requests adding an enhancement. label Aug 11, 2021
@Turnerj
Copy link
Collaborator

Turnerj commented Aug 11, 2021

Interesting - you thinking have this on Thing or maybe each of our derived types implements it? Should mostly be able to pass it off to the SchemaSerializer class.

@RehanSaeed
Copy link
Owner Author

I was thinking it would be nice to have it on Thing as just a convenience method.

@Turnerj
Copy link
Collaborator

Turnerj commented Aug 18, 2021

If we can't make use of #310 (source generators from S.T.J), we could even use these methods to output custom serialization for a type from our own source generator. That is to say, we'd generate it ourselves when we generate the model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues describing an enhancement or pull requests adding an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants