This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
Added support for rewrite steps as Types and as IRewriteStep instances #635
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... |
Contributor
Author
|
no problem! I will rebase this once #648 is merged |
Contributor
Author
|
I rebased on top of the latest |
Contributor
|
Sorry about that. :) |
bettinaheim
reviewed
Oct 15, 2020
Contributor
bettinaheim
left a comment
There was a problem hiding this 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!
bettinaheim
reviewed
Oct 15, 2020
src/QsCompiler/Compiler/RewriteSteps/AbstractRewriteStepsLoader.cs
Outdated
Show resolved
Hide resolved
bettinaheim
approved these changes
Oct 16, 2020
Contributor
bettinaheim
left a comment
There was a problem hiding this 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!
Contributor
|
/azp run |
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
IRewriteSteptypes 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
RewriteStepTypesandRewriteStepInstancesto the configuration of theCompilationLoader. To make things consistent, it also renames the existingRewriteStepsoption toRewriteStepAssemblies, 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.cswas 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.