AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 59 forks source link

Efforts to streamline or simplify the code generation process #120

Closed mwpowellhtx closed 5 years ago

mwpowellhtx commented 5 years ago

Hello,

Apologies if this is not the best forum. I was just on Gitter earlier and that wasn't the greatest responses, but to be fair, my memory is somewhat vague.

Are you aware of any efforts to streamline or simplify the code generation process, through this or similar Roslyn based projects?

In particular, I seem to recall discussion around alternatives not involving, for instance, the dotnet-codegen CLI references, for instance.

For what I am doing, I'm not sure that I need a full on analyzer. I will probe a Git (or other) repository for a set of file(s), parse those files, and do some boilerplate code generation in response. But for the mechanics of doing so, it is pretty cut and dry, I think.

I expect to carry not only development reference assets, but also run-time ones to boot, for instance my parser bits, as well as any run-time plugin bits.

Oh, and I do expect to be able to support a range of targets, from Framework to Standard to Core, etc, which is seems as though that may constrain the field somewhat.

Thanks for any insights!

AArnott commented 5 years ago

Are you aware of any efforts to streamline or simplify the code generation process, through this or similar Roslyn based projects?

That is the point of this project, yes. I wish Roslyn would add proper support for such a use case since it's very difficult to do it "right". There is at least one other project like this one. See #100.

In particular, I seem to recall discussion around alternatives not involving, for instance, the dotnet-codegen CLI references, for instance.

I've personally tried a variety of techniques, and this project settled on dotnet codegen as the only way that worked cross-plat, on dotnet and msbuild.

I'm not sure that I need a full on analyzer.

An analyzer is a very different use case than code generation, which is what this project is about.

But for the mechanics of doing so, it is pretty cut and dry, I think.

I find the tricky part is getting good IDE integration, with incremental build, language services noticing your generated files, etc. This project automates all that so you can focus on the actual code gen.

Oh, and I do expect to be able to support a range of targets, from Framework to Standard to Core, etc,

Pretty irrelevant, actually. For code gen, everything is from the compiler's perspective, which doesn't even see target frameworks. It just sees code and reference assemblies. So your code generator can easily support all the target frameworks provided it generates code that can compile in them.

mwpowellhtx commented 5 years ago

That is the point of this project, yes. I wish Roslyn would add proper support for such a use case since it's very difficult to do it "right". There is at least one other project like this one. See #100.

Ah, yes, thanks for recalling that.

I've personally tried a variety of techniques, and this project settled on dotnet codegen as the only way that worked cross-plat, on dotnet and msbuild.

Yes, fair enough.

I find the tricky part is getting good IDE integration, with incremental build, language services noticing your generated files, etc. This project automates all that so you can focus on the actual code gen.

Agreed. Excellent point.

Thanks for the feedback! :+1: