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

Use Roslyn components multi-targeting #5816

Open
Youssef1313 opened this issue Jan 25, 2022 · 8 comments
Open

Use Roslyn components multi-targeting #5816

Youssef1313 opened this issue Jan 25, 2022 · 8 comments

Comments

@Youssef1313
Copy link
Member

Youssef1313 commented Jan 25, 2022

We're using an old version of Roslyn to allow consumption in old VS versions. But this comes with some issues where a given Roslyn API had a bug that was fixed in a later version, and updating to new version of Roslyn is blocked.

Another benefit is we'll have more up-to-date nullable annotations, which can help prevent bugs (e.g #5802).

As of dotnet/sdk#20793, there is now a support for targeting multiple versions of Roslyn, where the highest version that can work will be picked. I think it would be useful if we used that in roslyn-analyzers.

@Youssef1313
Copy link
Member Author

YairHalberstadt/stronginject@40c2721 for an example where this was done.

@Youssef1313
Copy link
Member Author

This may help reduce the amount of reflection we do, ie, in Lightup we'll need to only use reflection if the API we need isn't available. That seems like a good addition. @mavasani What do you think?

@Youssef1313
Copy link
Member Author

Actually we might completely get rid of Lightup with this.

@sharwell
Copy link
Member

sharwell commented Feb 1, 2022

There are two big problems with Roslyn component versioning today:

  1. All projects prior to SDK 6.0.100 do not understand component versions, and will include all versions of the assembly in the build. Supporting multi-targeting while also supporting Roslyn 3.x or earlier requires custom build logic inside the analyzer package.
  2. Only SDK-style projects define SupportsRoslynComponentVersioning, so build logic relying on this property to work around (1) will force new projects to use older analyzers if they aren't SDK-style projects

@Youssef1313
Copy link
Member Author

@sharwell I thought the SDK version requirement would be for roslyn-analyzers repository, not consumers. But looks like my assumption was wrong?

@sharwell
Copy link
Member

sharwell commented Feb 1, 2022

Component versioning is a consumer/client feature implemented by NuGet and/or the SDK.

@Youssef1313
Copy link
Member Author

@sharwell Is it expected that it can (at some point in future) be a good fit to use? If it's not a good fit, we can probably close this issue?

@sharwell
Copy link
Member

sharwell commented Feb 1, 2022

I guess it depends on what versions of the compiler need to be supported over time. There are some partial workarounds available to handle cases where the feature is/is not supported.

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

2 participants