-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Cannot load Analyzers programatically from MSBuildWorkspace #31797
Comments
@shaggygi what is |
@jmarolf sorry for not showing that. It is a path to a .csproj file. I’ve tried console and wpf projects with same result. |
@shaggygi and the project pointed to in |
@jmarolf The app that runs the code includes Microsoft.CodeAnalysis and StyleCop.Analyzers and the project the code is check only has StyleCop.Analyzers added. |
@jmarolf I just published a sample here if this helps. https://github.com/shaggygi/TryingAnalyzerReferences Just need to update the path of where the other project is located. |
Not sure if this is related. I noticed when I do thing following emit, the only diagnostics returned are with Hidden severity that point to things like .g. files. It seems like you would also get diagnostics that come from StyleCop.Analyzers.
|
Any updates on this? |
Analyzers should be loading; this was probably some sort of binding redirect issue or something else specific to that setup. |
Unresolved analyzers are represented as So, if it need to detect unresolved analyzers. foreach (var unresolvedAnalyzer in project.AnalyzerReferences.OfType<UnresolvedAnalyzerReference>())
{
Console.WriteLine($"Failed to resolve analyzer: {unresolvedAnalyzer.FullPath}");
} |
@filzrev I wouldn't expect unresolved analyzers to be happening unless we ended up with a file path that doesn't exist. If you're seeing that then maybe we have a new bug (and please file one!) |
Yes, that's right, it happens when the analyzer DLL is not found. On some use cases. analyzer silently failed to load. (dotnet/docfx#9619 and #77255) |
Version Used:
VS 2017 (15.9.4)
Scenario:
Create a new .NET command-line project.
Add latest Microsoft.Build.Locator Nuget to project.
Add latest Microsoft.CodeAnalysis and StyleCop.Analyzers Nuget to project.
Project now has 4 Analyzer references:
Where projectPath is the path to this project.
Expectations:
allLanguageAnalyzers is not empty
languageSpecificAnalyzers is not empty
Actual Results:
allLanguageAnalyzers is empty
languageSpecificAnalyzers is empty
This might be similar to this older issue, but not sure, so I'm pinging the following for help.
@yaakov-h
@jmarolf
@davkean
@sharwell
The text was updated successfully, but these errors were encountered: