Closed hankovich closed 10 months ago
I just tried out 1.0.0-beta1 and thought the same thing. It would help a lot not to have to write new WhateverId(Guid.Parse("???"))
and just do WhateverId.Parse("???")
. For now you can do something along the lines of, so at least it's in one place:
[StronglyTypedId]
public partial struct WhateverId {
public static WhateverId Parse(
string value) => new(Guid.Parse(value));
}
This wold help to use the Id in aspnet minimal api route parameter
I opened a PR with an implementation proposal for this https://github.com/andrewlock/StronglyTypedId/pull/85
I'm very late to this, but I've included it in the big redesign of the library in this PR:
The main idea is to make the library much more maintainable while also giving people a mechanism to customise the generated IDs as much as they like.
Hi, thanks for the handy library. I think it would be rather nice to have
Parse
method to doinstead of
And I'd like to also see
TryParse
to make my parsing safer.