cezarypiatek / cezarypiatek.github.io

Personal blog https://cezarypiatek.github.io
2 stars 0 forks source link

Code generators #19

Open cezarypiatek opened 6 years ago

cezarypiatek commented 6 years ago
Christopher Haws @ChristopherHaws lut 25 22:41
Does anyone know why I cant seem to find the type SourceGenerator in the Microsoft.CodeAnalysis nuget package? http://source.roslyn.io/#Microsoft.CodeAnalysis/SourceGenerator/SourceGenerator.cs

Neme12 @Neme12 lut 25 22:48
how did you find the file? it doesn't seem to be in the project
that's weird

Christopher Haws @ChristopherHaws lut 25 22:49
I was looking at this md doc: https://github.com/dotnet/roslyn/blob/master/docs/features/generators.md
and searched google for Microsoft.CodeAnalysis.SourceGenerator

Robin Sue @Suchiman lut 25 22:50
@ChristopherHaws this feature has been pulled from public bits due to outstanding unresolved design issues

Neme12 @Neme12 lut 25 22:50
that's just an experimental feature i think
it's in features/source-generators
https://github.com/dotnet/roslyn/blob/features/source-generators/src/Compilers/Core/Portable/SourceGenerator/SourceGenerator.cs

Christopher Haws @ChristopherHaws lut 25 22:52
ah, ok. Is there a recommended approach for doing something similar this? We need to generate code from a file included in the project.

Robin Sue @Suchiman lut 25 22:53
@ChristopherHaws either write a custom tool or use something like https://github.com/daveaglick/Scripty

Christopher Haws @ChristopherHaws lut 25 22:55
ok. So we still need to have msbuild generate the code prior to csc running. Any idea if the SourceGenerator feature will ever make it into master or is it a dead feature?

Robin Sue @Suchiman lut 25 22:57
@ChristopherHaws its on indefinite hold currently until the design issues are resolved (primarily around performance and caching, e.g. how not to run all generators on every keystroke...)

Christopher Haws @ChristopherHaws lut 25 22:58
ok
thanks 

Jonathon Marolf @jmarolf 16:59
@ChristopherHaws I would also look at https://github.com/AArnott/CodeGeneration.Roslyn
ChristopherHaws commented 6 years ago

To give you some background, this is for the SpecFlow project. I am trying to get gherkin feature files (a simple DSL for behavior driven development) to generate unit tests for a specified language/unit test adapter. I would like to avoid using the Visual Studio "Custom Tools" feature, which is how it currently works, as this method doesn't work outside of Visual Studio. Custom MSBuild tasks for generating code works ok, but it is error prone (having to work with incremental builds, renames, deletions, etc).

cezarypiatek commented 6 years ago

Thanks for clarification. I save this excerpt of discussion because it very valuable and I have idea for applying this feature.

cezarypiatek commented 5 years ago

https://github.com/AArnott/CodeGeneration.Roslyn#how-to-write-your-own-code-generator