3 ms·
Hey, when did language-ext get roslyn-based code generation? That's awesome! Do you know if it's widely used yet? Any insights/gotchas to share? I see it's usi
by balfirevic 7y ago
Hey, when did language-ext get roslyn-based code generation? That's awesome!
Do you know if it's widely used yet? Any insights/gotchas to share? I see it's using CodeGeneration.Roslyn.BuildTime, I wanted to use it to make my own sum types library for c# for some time now, but never got around to it.
- louthy 7y agoI guess about a year or so. I have some docs on the wiki re the code-gen features. I’m writing this on my phone atm, so I’ll do a fuller reply to your qs when I’m back in front of my PC https://github.com/louthy/language-ext/wiki/Code-generation https://github.com/louthy/language-ext/wiki/Code-generation
- louthy 7y agoA 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!