andrewlock / StronglyTypedId

A Rosyln-powered generator for strongly-typed IDs
MIT License
1.52k stars 79 forks source link

port to C# 9 source generators #16

Closed dzmitry-lahoda closed 2 years ago

andrewlock commented 4 years ago

I've done some experimenting with this, and I don't think source generators really give us that much 🤷‍♂️

dzmitry-lahoda commented 4 years ago

Msbuild tasks and t4 are more far from compiler than source generators. The closes stuff to compiler the faster the more versatile and more brodly supported it becames. E.g.what if I want adding custom limits on ctor of values like being 15 bit size? Or use generator from projectless flow? I bet source generators are target of being best at these.

andrewlock commented 4 years ago

I disagree, from the point of view of the library, I can't find any significant difference in implementation from using CodeGeneration.Roslyn vs source generators. Frankly, the tooling support is worse with source generators at the moment too.

The custom constructor arguments is an interesting request, but not one that is related to source generators. The projectless target may be a limitation, I don't know to be honest.

A far more interesting feature in c#9 is records, as these make the library obsolete. That's all the strongly typed IDs are really records, and you get that for free in c#9!

3GDXC commented 3 years ago

@andrewlock great work; you also mention that C# 9.0 record types would be a better option in your blog; any plans to show how/what the record type brings to the table and do a comparison

andrewlock commented 3 years ago

Hi @3GDXC, yes I plan to look at this, bit haven't got round to it yet!

andrewlock commented 3 years ago

I've released a beta version of a major update to the library that converts to using Source generators. There's quite a few breaking changes in the release, so please make sure to check the release notes for how to update, but I'd appreciate any feedback you have before I do a final release!

I've also written a blog post announcing the update that goes into a bit more details: https://andrewlock.net/rebuilding-stongly-typed-id-as-a-source-generator-1-0-0-beta-release

Thanks! 🙂

andrewlock commented 2 years ago

Closing this now as I've merged the source generators spike