-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Make IDiagnosticAnalyzerService into an IWorkspaceService #78359
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
Make IDiagnosticAnalyzerService into an IWorkspaceService #78359
Conversation
| [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
| internal sealed class CSharpCodeCleanupService(ICodeFixService codeFixService, IDiagnosticAnalyzerService diagnosticAnalyzerService) : AbstractCodeCleanupService(codeFixService, diagnosticAnalyzerService) | ||
| internal sealed class CSharpCodeCleanupService(ICodeFixService codeFixService) | ||
| : AbstractCodeCleanupService(codeFixService) |
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.
most changes are just not passing the IDiagAnalzyerService along. INstead, code that needs it, requests it as a normal workspace service at the point they actually need it.
|
|
||
| // When the workspace changes what context a document is in (when a user picks a different tfm to view the | ||
| // document in), kick off a refresh so that diagnostics properly update in the task list and editor. | ||
| workspace.RegisterDocumentActiveContextChangedHandler(args => RequestDiagnosticRefresh()); |
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.
moved registration here, which is much cleaner than when we were originally creating the incremetnal analyzers.
| => _diagnosticsRefresher.RequestWorkspaceRefresh(); | ||
|
|
||
| private DiagnosticIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace) | ||
| => _map.GetValue(workspace, _createIncrementalAnalyzer); |
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.
move from deleted sibling file (which should be looked at).
| private DiagnosticIncrementalAnalyzer CreateIncrementalAnalyzerCallback(Workspace workspace) | ||
| { | ||
| // subscribe to active context changed event for new workspace | ||
| _ = workspace.RegisterDocumentActiveContextChangedHandler(args => RequestDiagnosticRefresh()); |
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.
moved to constructor.
dibarbet
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 seems reasonable. agree that it would be nice if the refresher was a workspace service too, but fine with leaving that out due to the EA restrictions
Followup to dotnet#78356. Needed so we can access IDiagAnalyzerService in OOP. Currently one cannot as it attempts to access the Workspace of a document passed into it. We block WOrkspace access like for safety/clarity concerns (we don't want a stateless OOP api call to have access to the mutable workspace API). This also cleans up some ugly initialization code IDiagAnalyzerService had.
Followup to #78356.
Needed so we can access IDiagAnalyzerService in OOP. Currently one cannot as it attempts to access the Workspace of a document passed into it. We block WOrkspace access like for safety/clarity concerns (we don't want a stateless OOP api call to have access to the mutable workspace API).
This also cleans up some ugly initialization code IDiagAnalyzerService had.