4 ms·
A more in-depth reply :) > Do you know if it's widely used yet? Not sure which project you mean? * Roslyn code-gen - not many * LanguageExt.Core - yes, lots
by louthy 7y ago
A more in-depth reply :)
> Do you know if it's widely used yet?
Not sure which project you mean?
* Roslyn code-gen - not many
* LanguageExt.Core - yes, lots - 1.6 million downloads on nuget and counting
* LanguageExt.CodeGen - not much from what I can tell, but that might be because there's the runtime Record system that makes a type have structural equality/ordering/hashing and serialisation by just deriving it from Record<TYPE>, i.e.
public class Person : Record<Person>
{
public readonly string Name;
public readonly string Surname;
public Person(string name, surname) =>
(Name, Surname) = (name, surname)
}
It builds the IL and compiles it on first-use, so it's code-gen without any of the hassle of setting up the tool chain.
Some of the additional benefits of using the CodeGen instead is that the With function and lenses are built automatically, but that might not be enough to make people use it. Also, things like [Union] and [Free] (monad) are relatively new, so perhaps it wasn't compelling enough until recently. There's obviously benefits to compiling the code up-front rather than generating the IL, so I'd expect it to pick up over time.
I and my team certainly use it a lot ;)
> Any insights/gotchas to share? I see it's using CodeGeneration.Roslyn.BuildTime
None really, the CodeGeneration.Roslyn.BuildTime hasn't had much love, and a new version they built (to support plugins) just fundamentally didn't work, so it clearly wasn't tested properly. But, the version I'm using is stable right now, I just can't migrate to .NET Standard 2.1 until they bring the new one out, so that is a limiting factor for me at the moment.
- balfirevic 7y ago> LanguageExt.CodeGen - not much from what I can tell Yes, I meant that one. > None really, the CodeGeneration.Roslyn.BuildTime hasn't had much love, and a new version they built (to support plugins) just fundamentally didn't work, so it clearly wasn't tested properly. But, the version I'm using is stable right now, I just can't migrate to .NET Standard 2.1 until they bring the new one out, so that is a limiting factor for me at the moment. Ah, that's too bad. Visual Studio 2019 finally has a really nice and frictionless way to do code generation, but it is pretty complicated to bootstrap all the stuff that CodeGeneration.Rosylin takes care of. I wish Microsoft sponsored or supported it in some way. There is also a fork of it at https://github.com/mwpowellhtx/Code.Generation.Roslyn https://github.com/mwpowellhtx/Code.Generation.Roslyn, but I don't know how well it works. Thanks for all the answers!