Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Processing generators in a specific order #123

Closed
codeprogression opened this issue Mar 20, 2019 · 3 comments
Closed

Processing generators in a specific order #123

codeprogression opened this issue Mar 20, 2019 · 3 comments

Comments

@codeprogression
Copy link

Given the following attributes...

[AttributeUsage(AttributeTargets.Class)]
[CodeGenerationAttribute(typeof(Step1Generator))]
[Conditional("CodeGeneration")]
public class Step1Attribute : Attribute
{}

[AttributeUsage(AttributeTargets.Class)]
[CodeGenerationAttribute(typeof(Step2Generator))]
[Conditional("CodeGeneration")]
public class Step2Attribute : Attribute
{}

[AttributeUsage(AttributeTargets.Class)]
[CodeGenerationAttribute(typeof(Step3Generator))]
[Conditional("CodeGeneration")]
public class Step3Attribute : Attribute
{}

All classes with the Step1 attribute should be processed first, then Step2, then Step3. The output of each step would be used a later step (memoized in-memory, in temporary files, or in files to be included in compilation).

What strategy would you recommend to ensure that code is generated in a specific order? (I am not asking for a code change, just for ideas.)

@codeprogression
Copy link
Author

My initial thought is to write my own custom Engine implementation which would require me to create a custom tool implementation.

I noticed that extracting the engine into its own project was a pretty recent change. Is it possible that you were considering enabling injection of alternate engine implementations?

@amis92
Copy link
Collaborator

amis92 commented Mar 21, 2019

Sooo, in general, as you've discovered, it's not a supported scenario.

It is however an interesting idea to allow custom engine implementations.

I'll just warn you that creating such dependencies will probably result in a couple compilations.

As you might now, essentially the Engine compiles the project, and runs generators on the Compilation. If you want to re-create the Compilation after every generator runs, it's going to be quite expensive (in terms of time taken).

@amis92 amis92 self-assigned this Mar 21, 2019
@amis92
Copy link
Collaborator

amis92 commented Jun 30, 2019

Closed in favour of #137

@amis92 amis92 closed this as completed Jun 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants