Skip to content

The code gen is worse than ever. #35

Open

Description

@JohanLarsson

Maybe use less T4 and write a script.

Activity

  1. dzmitry-lahoda commented on Jan 16, 2019

    @dzmitry-lahoda

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

  2. JohanLarsson commented on Jan 16, 2019

    @JohanLarsson
    MemberAuthor

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

  3. dzmitry-lahoda commented on Jan 16, 2019

    @dzmitry-lahoda

    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.

  4. dzmitry-lahoda commented on Jan 16, 2019

    @dzmitry-lahoda

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions