You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Retry running generators if the project config looks good, but the source generator doesn't produce host outputs (#12228)
Fixes the startup issue we have if Razor loses the race condition, and
Roslyn caches the generator run result while it's in "cohosting off"
mode.
Essentially our snapshot manager, which is our first port of call for "I
would like to run this OOP service for this solution snapshot" will not
sometimes redirect calls to a forked snapshot, that ensures the
generator will have had a chance to re-run after it has seen the
cohosting flag turn on. Some minor changes to solution and project
snapshots because this could happen while code is in-flight, but after
the first requests are done, subsequent requests flow through the system
as normal (albeit being silently redirected to the fork) and once almost
any change to the project or additional files has happened, the whole
"retry project" notion becomes unnecessary.
Val build:
https://dev.azure.com/dnceng/internal/_build/results?buildId=2793362&view=results
Test insertion:
https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/670224
#pragma warning disable RSEXPERIMENTAL004// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning restore RSEXPERIMENTAL004// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
83
+
{
84
+
// We know the generator is referenced, or we wouldn't have gotten past the above checks. We also know cohosting is turned on, since we got here.
85
+
// There is a race condition that can happen where if Roslyn runs the generator before Razor has a chance to initialize, then Roslyn will have
86
+
// cached the fact that cohosting was off, and any subsequent runs of the generator will not produce a host output. We can work around this by
87
+
// making an innocuous change to the project, and trying again. The snapshot manager makes this change inside a lock, and if we're not the first
88
+
// ones to try, we'll get the updated project which may have already had generators run on it. We recurse back into ourselves here with the updated
89
+
// project to try again. TryGetRetryProject also protects against infinite recursion.
#pragma warning disable RSEXPERIMENTAL004// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning restore RSEXPERIMENTAL004// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
0 commit comments