Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@filipw
Copy link
Contributor

@filipw filipw commented Sep 22, 2020

This PR is based on the feedback I submitted in Teams. Hopefully it will be useful.
Tagging @bettinaheim

Problem

At the moment the only way to provide rewrite steps into the compiler is to use a plugin DLL. The problem is that in this case the compiler arbitrarily discovers all IRewriteStep types there, initializes them and uses in the compilation pipeline. This works fine in command line scenarios, but is severely limiting when hosting the compiler in own application ("compiler-as-a-service").

This PR

This PR adds a possibility to pass in RewriteStepTypes and RewriteStepInstances to the configuration of the CompilationLoader. To make things consistent, it also renames the existing RewriteSteps option to RewriteStepAssemblies, which is technically a breaking change (hopefully not a problem). It is technically not needed, but it makes sense IMHO.

The existing logic of loading assemblies, instantiating types and so on is 100% reused. Since the existing RewriteSteps.cs was already very big, adding more stuff to it was probably not the best idea, so I ended up splitting the logic into more (again, IMHO) manageable separate pieces.

Benefits

Step instances can now be provided by the host application as types or instances, allowing the host to communicate with the step. One example use case would be capturing the rewritten C# code into in-memory representation, ratherthan having it output into the files on disk.

@bamarsha
Copy link
Contributor

Thanks for the PR! Just wanted to mention that it looks like the PR builds are broken on our end here as well (same problem as #632), we'll try to get that fixed soon...

@filipw
Copy link
Contributor Author

filipw commented Sep 25, 2020

no problem! I will rebase this once #648 is merged

@filipw
Copy link
Contributor Author

filipw commented Oct 5, 2020

I rebased on top of the latest main, due to changes in #648 there were quite a few conflicts 😀

@bamarsha
Copy link
Contributor

bamarsha commented Oct 5, 2020

Sorry about that. :)

Copy link
Contributor

@bettinaheim bettinaheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much better structured. Thanks, @filipw!

Copy link
Contributor

@bettinaheim bettinaheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thank you!

@bettinaheim
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants