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

MSBuildWorkspace (or the workspaces API) should have a simple way to get all diagnostics for a project #77980

Open
jasonmalinowski opened this issue Apr 3, 2025 · 0 comments

Comments

@jasonmalinowski
Copy link
Member

jasonmalinowski commented Apr 3, 2025

This bug illustrated another problem with our workspaces API: if you're using MSBuildWorkspace, it's really hard to get "all the diagnostics" which might mean your analysis is broken. I can think of at least four kinds of diagnostics we have, and the different ways to get them:

  1. Compiler diagnostics. These are easy -- call GetCompilationAsync().GetDiagnostics().
  2. Analyzer loading diagnostics. These are hard. You can manually subscribe to all the AnalyzerFileReferences to hook an event that will be raised it loaded. But you better do that right away before you miss the event. You also need to deal with analyzer file references that couldn't be resolved at all.
  3. Source generator execution diagnostics. We have these...in an internal API. I think we have no option here short of reflection to get them!
  4. Analyzer diagnostics. You could create your own CompilationWithAnalyzers and run the analyzers here, but it's odd we don't have a shortcut.
  5. MSBuildWorkspace diagnostics. These you get via subscribing to WorkspaceFailed.

We probably need to do some combination of:

  1. Making analyzer loading diagnostics also get raised to WorkspaceFailed, or
  2. Add a simple API like Project.GetDiagnosticsAsync() that just returns all the various things here concatenated together.

The goal not being that the API has to be high performance....it should just be possible.

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

No branches or pull requests

1 participant