RegisterHostOutputs #74753
Labels
api-approved
API was approved in API review, it can be implemented
Concept-API
This issue involves adding, removing, clarification, or modification of an API.
Feature Request
Background and Motivation
This is a re-working of a previous proposal: #63291
The basic idea is to allow generators to specify a 'host specific' output. That is, something that doesn't contribute to the compilation, or even do anything other than appear in the run result for the generator.
Razor would like to use this to store the intermediate state that was used to generate documents, which is needed for the tooling.
It would also be useful in testing scenarios. We have lots of places today where we want to check something was called, or some operation produced some output, and we 'smuggle' the result out by adding some source with a content like
// {result.ToString()}
. Host outputs would allow us an easy mechanism to do this sort of result-based testing.Proposed API
Implementation PR: #74750
Usage Examples
Alternative Designs
In the previous design discussion we talked about if it should be
object
orstring
. We decided onstring
because there were worries about things like serialization and how we would handle that. This proposal switches back toobject
as the seralization overhead for Razor is going to be far too much and we've explicitly designed co-hosting to live in the same process.For third party usage, I think we should just make it clear that it's entirely up to the host what happens with these outputs, and there is no defined expectation.
Risks
The text was updated successfully, but these errors were encountered: