Skip to content

Support for nuget package with multiple Roslyn version analyzers#616

Merged
JoC0de merged 11 commits intoGlitchEnzo:masterfrom
hadashiA:master
Mar 3, 2024
Merged

Support for nuget package with multiple Roslyn version analyzers#616
JoC0de merged 11 commits intoGlitchEnzo:masterfrom
hadashiA:master

Conversation

@hadashiA
Copy link
Contributor

To address the #615, I added a process to prevent the same analyzer from being enabled more than once.

It works as follows.

  • If analyzers/dotnet subfolders are not split into versions, then it remains the same.
  • If not, only newer versions that can be supported will be given the RoslynAnalyzer label.

if (!enabledRoslynVersions.Contains(assetRoslynVersion) ||
string.CompareOrdinal(assetRoslynVersion, enabledRoslynVersions.Max()) < 0)
{
AssetDatabase.SetLabels(plugin, new[] { ProcessedLabel });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting and then removing the label, just save in some bool variable if RoslynAnalyzer label should be added and then in the end just SetLabels once to proper value depending on that bool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I fixed.

@hadashiA hadashiA requested a review from igor84 January 25, 2024 06:38
@hadashiA hadashiA requested a review from JoC0de February 1, 2024 01:11
Copy link
Collaborator

@JoC0de JoC0de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.
I still don't understand why Unity doesn't handle this by itself but at least we can fix it 😃

@hadashiA hadashiA requested a review from JoC0de February 14, 2024 06:55
… add unit test for package with multiple roslyn analyzers
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

Successfully merging this pull request may close these issues.

Unintended behavior when there are analyzers for multiple Roslyn versions in one nuget package

4 participants

Comments