Skip to content

Entitas with Roslyn Code Generation via dotnet IIncrementalGenerator #1005

@studentutu

Description

@studentutu

[ EDIT by @sschmid ]

I edited the issue description because this issue is now the main issue for the new code generator

dotnet's source generators, specially IIncrementalGenerator may be a valid alternative to the current approach with Jenny

Learn about dotnet Incremental Generators:

While migrating to dotnet source generators, I will use the opportunity to update and improve the generated code:

  • add namespaces support for components and contexts
  • support multiple projects and multiple Unity asmdef

I already made good progress but it's still in research state. Any help from the community is greatly appreciated! Please feel free to engage and help in the conversation if you can! 🙏


Tasks

Generators

  • Component ContextApi Generator (Unique, Normal, Flag)
  • Component EntityApi Generator (Normal, Flag)
  • OBSOLETE Component EntityApiInterface Generator (Multiple Contexts)
  • OBSOLETE Component Generator
  • Component Lookup Generator
  • Component MatcherApi Generator
  • ContextAttribute Generator
  • Context Generator
  • ContextMatcher Generator
  • OBSOLETE Contexts Generator
  • Entity Generator
  • EntityIndex Generator
  • Event EntityApi Generator
  • Event ListenerComponent Generator
  • Event ListenerInterface Generator
  • Event System Generator
  • Event Systems Generator
  • OBSOLETE ContextObserver Generator
  • OBSOLETE FeatureClass Generator

Attributes

  • CleanupAttribute
  • ContextAttribute
  • OBSOLETE CustomEntityIndexAttribute
  • EntityIndexAttribute
  • OBSOLETE EntityIndexGetMethodAttribute
  • EventAttribute
  • OBSOLETE ComponentNameAttribute
  • OBSOLETE DontGenerateAttribute
  • OBSOLETE FlagPrefixAttribute
  • OBSOLETE PostConstructorAttribute
  • OBSOLETE PrimaryEntityIndexAttribute
  • UniqueAttribute

original message from issue author:

Hi,

I have a suggestion and would want to contribute.
As in official code generation guide by Unity - https://docs.unity3d.com/Manual/roslyn-analyzers.html - we can use separate project and create dll which unity will use right in it's code compilation steps.

We already have a separate project for it - Jehny, all we need is to make sure that code gen is done by Microsoft Roslyn Source Generators, and put a label “RoslynAnalyzer” for the DLL inside the release branch (create a Unity package)

This way we don't need to use Jehny Server for constant monitoring of changes, and it will help clean up the workflow.

Here's some code that we need to use for Roslyn Source Generators

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using System.Text

[Generator]
public class ExampleSourceGenerator : ISourceGenerator
{
}

Hope it will be helpful.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions