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

Enable TestPreviewDiagnosticTaggerInPreviewPane #24783

Merged
merged 2 commits into from
Feb 13, 2018

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Feb 12, 2018

Fixes #14444

@heejaechang Can this test be updated following the work for #24690? In other words, is there now an event that the test can listen to and know that the diagnostics are updated?

@sharwell sharwell requested a review from a team as a code owner February 12, 2018 14:02
@heejaechang
Copy link
Contributor

looks good. might be fixed by this - #24512 - since it is using WpfFact

@sharwell
Copy link
Member Author

@heejaechang I rewrote this to no longer rely on hacks. Please review again. 😄

@sharwell
Copy link
Member Author

@Pilchie for ask mode since it includes a change to shipping code


[ImportingConstructor]
public PreviewSolutionCrawlerRegistrationServiceFactory(IDiagnosticAnalyzerService analyzerService)
public PreviewSolutionCrawlerRegistrationServiceFactory(IDiagnosticAnalyzerService analyzerService, IAsynchronousOperationListenerProvider listenerProvider)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is workspace service specific to Preview Kind. the test doesn't create PreviewKind workspace. if you want this, you should create PreviewKind workspace.

Copy link
Member Author

Choose a reason for hiding this comment

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

➡️ It's already created in PreviewFactoryService.CreateChangedDocumentPreviewViewAsync.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I see good then.

@@ -249,16 +237,8 @@ public void TestPreviewDiagnostic()
var rightTagger = rightProvider.CreateTagger<IErrorTag>(rightBuffer);
using (var rightDisposable = rightTagger as IDisposable)
{
// wait up to 20 seconds for diagnostics
taskSource.Task.Wait(20000);
if (!taskSource.Task.IsCompleted)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this okay? it was waiting for analysis to actually happen. I think your approach seems good. just that TestWorkspace the test creates, you need to set the workspace kind as preview. and it needs to use its own ExportProvider otherwise, listener will get messed up since it got shared with all other tests. and nit, but use FeatureAttributes.SolutionCrawler rather than DiagnosticService.

Copy link
Member Author

@sharwell sharwell Feb 13, 2018

Choose a reason for hiding this comment

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

➡️ It's waiting for DiagnosticService because that's the feature reported by PreviewSolutionCrawlerRegistrationService. Previously it was not possible to directly wait on the task created by PreviewSolutionCrawlerRegistrationService.Service.Register, but now it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

yea. I got it. the CreateChangedDocumentPreviewViewAsync internally creates the PreviewWorkspace.

@Pilchie
Copy link
Member

Pilchie commented Feb 13, 2018

Waiting for @heejaechang to sign off again on the new set of changes.

// wait taggers
await listenerProvider.GetWaiter(FeatureAttribute.ErrorSquiggles).CreateWaitTask();
// wait for diagnostics and taggers
await listenerProvider.WaitAllDispatcherOperationAndTasksAsync(FeatureAttribute.DiagnosticService, FeatureAttribute.ErrorSquiggles);
Copy link
Contributor

Choose a reason for hiding this comment

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

listener....WaitAsync accepts multiple waiter but, ones that given together is expected not have dependency each other. for DiagnosticService, SolutionCrawler, ErrorSquiggle has dependency each other. like SolutionCrawler must run and finish first, then DiagnosticService and then ErrorSquiggle. so probably better to have things in order

WaitAll...(SolutionCrawler);
WaitAl...(Diagnostic...)
..

like that

Copy link
Member Author

@sharwell sharwell Feb 13, 2018

Choose a reason for hiding this comment

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

We should fix this. The operation should complete when none of the listed items are scheduled or in progress, which even handles cycles provided termination occurs.

Copy link
Member Author

Choose a reason for hiding this comment

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

@heejaechang The implementation of WaitAllAsync already behaves like I described. If anything, using a single call here should be better able to ensure the work is complete before proceeding. It will catch (and wait for) cases where FeatureAttribute.ErrorSquiggles causes a new task to start for FeatureAttribute.DiagnosticService.

Copy link
Contributor

Choose a reason for hiding this comment

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

he he, you are right :)

@@ -236,7 +224,7 @@ public void TestPreviewDiagnostic()
{
var foregroundService = workspace.GetService<IForegroundNotificationService>();

var listenerProvider = new AsynchronousOperationListenerProvider();
var listenerProvider = workspace.ExportProvider.GetExportedValue<AsynchronousOperationListenerProvider>();
Copy link
Contributor

Choose a reason for hiding this comment

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

again, to test like this, it must have its own ExportProvider rather than sharing common one with other test. ExportProvider.Create....

Copy link
Member Author

Choose a reason for hiding this comment

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

➡️ Fixed in d57cc19

@Pilchie
Copy link
Member

Pilchie commented Feb 13, 2018

Approved pending Jenkins.

@sharwell sharwell added this to the 15.7 milestone Feb 13, 2018
@sharwell sharwell merged commit 56044ac into dotnet:dev15.7.x Feb 13, 2018
@sharwell sharwell deleted the fix-14444 branch February 13, 2018 23:04
@sharwell sharwell self-assigned this Feb 13, 2018
sharwell added a commit to sharwell/roslyn that referenced this pull request Feb 14, 2018
The underlying requirement that diagnostics be waitable through
FeatureAttribute.DiagnosticService was recently implemented (dotnet#24783),
so these tests should be reliable again.

Fixes dotnet#17393
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants