Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cohost OnTypeFormatting test is failing intermittently with infrastructure issues #10874

Closed
davidwengier opened this issue Sep 10, 2024 · 0 comments · Fixed by #10882 or #10885
Closed
Assignees
Milestone

Comments

@davidwengier
Copy link
Contributor

davidwengier commented Sep 10, 2024

Probably not specific to this test, but rather a race condition with the [UseExportProvider] attribute and ExportProviderCache bits, and we've just hit some threshold of tests that make it more probable to hit.

I seem to remember the WebTools code hitting this in years past, and the exception is coming from those bits.

System.InvalidOperationException : ExportProviderCache may only be used from tests marked with UseExportProviderAttribute
   at Microsoft.AspNetCore.Razor.Test.Common.Mef.ExportProviderCache.SingleExportProviderFactory.GetOrCreateExportProvider() in /_/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Mef/ExportProviderCache.cs:line 159
   at Microsoft.AspNetCore.Razor.Test.Common.Mef.ExportProviderCache.SingleExportProviderFactory.Microsoft.VisualStudio.Composition.IExportProviderFactory.CreateExportProvider() in /_/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Mef/ExportProviderCache.cs:line 219
   at Microsoft.CodeAnalysis.Razor.Formatting.HtmlFormatting.<CallWebToolsApplyFormattedEditsHandlerAsync>d__2.MoveNext() in /_/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormatting.cs:line 69
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CohostOnTypeFormattingEndpointTest.<VerifyOnTypeFormattingAsync>d__5.MoveNext() in /_/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs:line 118
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CohostOnTypeFormattingEndpointTest.<FormatsSimpleHtmlTag_OnType>d__4.MoveNext() in /_/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs:line 79
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
@phil-allen-msft phil-allen-msft added this to the 17.12 P3 milestone Sep 12, 2024
davidwengier added a commit that referenced this issue Sep 18, 2024
Fixes #10696
Fixes #10769
Fixes #10874
Needs Roslyn change: dotnet/roslyn#75102

The actual code change was quite straight foward. The test code was a
bigger pain. Previously in cohosting tests we had two MEF composition,
one for Razor and one for Roslyn. Since Roslyn diagnostics can only run,
or at least start, in devenv, we now need three MEF compositions -
Roslyn devenv, Roslyn OOP and razor OOP - and two workspaces - Roslyn
devenv and Roslyn OOP - and our previous MEF infrastructure really
didn't handle this well, as evidenced by the fact that this PR also
fixes #10874

Now our MEF infra is simpler: We still cache catalogs etc. statically
the save time, but we create an `ExportProvider` as needed and expect
consumers to dispose of it like any other `IDisposable`, though there is
also here a test fixture to share the editor composition in the
formatting tests so we don't pay a huge penalty in terms of test run
time.

Commit-at-a-time if you want to read the story from beginning to end,
but it should be reasonably okay to just review as a whole too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants