Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The code gen is worse than ever. #35

Open
JohanLarsson opened this issue Dec 10, 2017 · 4 comments
Open

The code gen is worse than ever. #35

JohanLarsson opened this issue Dec 10, 2017 · 4 comments

Comments

@JohanLarsson
Copy link
Member

Maybe use less T4 and write a script.

@dzmitry-lahoda
Copy link

Use MS Build. Right now many and even more parse with Roslyn local definitions in cs and generate code.

@JohanLarsson
Copy link
Member Author

I have never thought of using MSBuild fore code gen, do you have a doc link for how it is done?

@dzmitry-lahoda
Copy link

dzmitry-lahoda commented Jan 16, 2019

https://github.com/dotnet/orleans/tree/master/src/Orleans.CodeGenerator.MSBuild

How does it work?

  1. Add package to MyProject

  2. Mark any interface as IGrainWithGuidKey.

  3. During build, before compilation, task will generate into MyProject\obj\Debug\netcoreapp2.1\MyProject.orleans.g.cs. That cs will compiled into dll with all manually typed cs.

  4. There is obj\Debug\netcoreapp2.1\codegen folder either, which seems used to cache some parts to speed up regeneration.

Also XUnit has some kind of task.

This way you may nuget provider which, as soon as attached, will allow to do custom units as part of dev work.

I hope web search will reveal some tutorials of doing so.

My case. Sometimes I want units with custom validations, e.g. from -100 to 100, or from 1 to 100, or from 0 to 100, or from 0 to 1024. So I may quantize them and store-wire them in most efficient manner and same time have typed logic in my code. And same time use generator to generate all fancy stuff. I want limited sizes, percentages, fractions, limited speeds, etc.

@dzmitry-lahoda
Copy link

dzmitry-lahoda commented Jan 16, 2019

There are various attempts to do codegen (run csx files on prebuild as part of task, t4, customization of roslyn with forks and proposals, writing new F# language:) ). But I guess custom MSBuild task is most production ready (with know path to nuget it, good versatile integration into build system), with DSL to describe units in Csharp and errors in build if wrong DSL usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants