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

Roslyn plugins (analyzers, source generators) target .NET 8 instead of .NET Standard 2.0 #7302

Closed
Sybren- opened this issue Apr 23, 2024 · 4 comments

Comments

@Sybren-
Copy link

Sybren- commented Apr 23, 2024

I'm trying to reference a .net 8.0 project but the Roslyn analyzer requires .netstandard 2.0 which makes this not possible.

Similar issue: https://developercommunity.visualstudio.com/t/Please-enable-Roslyn-plugins-analyzers/10616185?space=41&sort=newest

As far as I can find out it is not possible to reference .net 8 projects from the analyzer?

@CollinAlpert
Copy link
Contributor

Could you give a more concrete example on what you are trying to achieve and why the referenced project needs to be a net8.0 instead of a netstandard2.0 project?

@Sybren-
Copy link
Author

Sybren- commented Jun 4, 2024

I'm trying to reference a net8.0 project (by project reference) from my analyzer. This requires that my analyzer targets net8.0 instead of .netcore 3.1. The referenced project is net8.0 because this is the latest version.

The upgrade of the analyzer requires that the other projects are updated too (CodeFixes, Package, Test. VSIX). I upgraded all projects and managed to get them building, but when I add the analyzer nuget package to a project and start the code analysis, nothing happens (no errors).

@CollinAlpert
Copy link
Contributor

There are multiple issues on this matter already, e.g. dotnet/roslyn#47087 and dotnet/roslyn#45162, so unfortunately targeting net8.0 from a Roslyn component is not possible right now.

@sharwell
Copy link
Member

This is effectively a duplicate of #45162.

The referenced project is net8.0 because this is the latest version.

Many cases where we have seen this in the past, the analyzer did not need to reference the project at all, and removing the reference resolved the matter. For remaining cases, the referenced project can multi-target netstandard2.0 and net8.0 to support both scenarios it is being used for.

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

3 participants