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

How to handle supported version of Roslyn, Visual Studio, and the .NET SDK #5458

Open
jmarolf opened this issue May 26, 2021 · 4 comments
Open
Assignees
Milestone

Comments

@jmarolf
Copy link
Contributor

jmarolf commented May 26, 2021

If the user sets <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> then they will load in the Roslyn code style assemblies.

The CodeStyle layer references the latest version of the roslyn compiler. This has worked great for now. .NET SDK 5.0.300 is only compatible with Visual Studio 16.11 so the compiler versions match in both the SDK and Visual Studio.

The question is: what should happen if the user installs a newer SDK and uses them with an older Visual Studio. Today if the user installs a .NET 6 preview SDK that will contain the 4.0 compiler, but no versions of Visual Studio exist that ship with that compiler today.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@jmarolf
Copy link
Contributor Author

jmarolf commented Jul 12, 2021

Options

  1. The compiler adopts MSBuild loading behavior. Meaning that if an Analyzer targets a higher version (like say 5.0) but does not actually use any APIs from that version then it can be loaded and uses on older versions (such as 4.0). You only get loading errors when the analyzer uses an API that does not exist in the compiler that it is running under. This would still cause loading errors but cases that we see today for Code Style analyzers in the SDK are mostly caused by a version mis-match not actual missing apis.
  2. Allow analyzers to multi-target different versions of the roslyn API so the compiler can fall back to a compatible version. This would add complexity on our end to the roslyn build but is otherwise an ideal solution from the custom side.
  3. Have a policy that analyzers in pre-release SDKs will only work in the latest preview of visual studio and any other combination is unsupported

Proposal

I propose we work with the compiler team on option number 1.

@vatsalyaagrawal
Copy link

Design meeting conclusion: We should provide more meaningful errors to cusotmers when such a scenario occurs.

@Youssef1313
Copy link
Member

@jmarolf Is this considered fixed with dotnet/roslyn#61261 ?

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

No branches or pull requests

3 participants