Entitas-csharp: Roslyn based code generator

Created on 6 Mar 2016  路  15Comments  路  Source: sschmid/Entitas-CSharp

The current code generator relies on reflection which means it produces source code based on a compiled dll. Compile errors in your code prevent you from building a new dll which means recent changes in the code cannot be picked up by the code generator since it will process the previous dll.

A new code generator which doesn't use reflection could enable us to generate even if there compile errors.

The .NET Compiler Platform Roslyn provides open-source C# and Visual Basic compilers which could be used to analyze the source code.

feature request

Most helpful comment

Wooooot!

mono Entitas.CodeGenerator.Roslyn.exe Entitas.properties

Just generated the very first time!

All 15 comments

@rollkoffer

Just wonder if using Antlr will be a good solotion?

Maybe yes, I heard of it before. Current efforts are going into a solution with roslyn though. But if you have any input for us why Antlr should be considered, let me know, I'm always open for new ideas :)

Antlr is a just a "hammer" pop in my head(so the rest of world becime a nail?), Roslyn sounds promising, I'll looking into that:)

Prepared implementation on branch feature/roslyn_code_generator. Progress can also be viewed in pull request https://github.com/sschmid/Entitas-CSharp/pull/104/.

Awesome!

fyi, I talked to @cedricdg, apparently not all required features to work on all platforms are implemented in mono yet. Proof of concept works on windows but still needs some work to work on Mac OS X and Linux.

The original DSL (or JSON + schema) still sounds like a solid idea to me. That would also set Entitas up so that it could down the line use T4 templates (*.tt's) so the code generation into a standard c# build process. MS uses T4's internally for some of the new dotnet core stuff:

https://github.com/dotnet/corefx/tree/master/src/System.Numerics.Vectors/src/System/Numerics

I'm not sure if other's components are more complicated in some way, or include logic, but mine would all be representable with:

{
  "MyNamespace.MyComponent" : {
     "pools": ["core"],
     "properties": {
         "position": "UnityEngine.Vector3",
         "facing": "UnityEngine.Vector3"
     }
  },
  "MyNamespace.MyOtherComponent" : {
  }
}

fyi, last december I created an issue at github.com/Microsoft/msbuild
https://github.com/Microsoft/msbuild/issues/1469

This was basically preventing me from developing the roslyn based code generator. If anyone of you guys knows how to make it work on a mac, let me know.

Bye roslyn, was nice to meet you. Hello DSL

There is hope.... 馃懟

entitas-roslyn

@sschmid What was the solution?

Surprised you didn't just crack and buy a PC :)

Wooooot!

mono Entitas.CodeGenerator.Roslyn.exe Entitas.properties

Just generated the very first time!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sschmid picture sschmid  路  4Comments

moixxsyc picture moixxsyc  路  4Comments

CuriousHub picture CuriousHub  路  5Comments

xkyii picture xkyii  路  3Comments

CCludts picture CCludts  路  3Comments