Support for nuget package with multiple Roslyn version analyzers by hadashiA · Pull Request #616 · GlitchEnzo/NuGetForUnity (original) (raw)
Conversation
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/dotnetsubfolders are not split into versions, then it remains the same. - If not, only newer versions that can be supported will be given the
RoslynAnalyzerlabel.
| if (!enabledRoslynVersions.Contains(assetRoslynVersion) || | | --------------------------------------------------------------------------- | | string.CompareOrdinal(assetRoslynVersion, enabledRoslynVersions.Max()) < 0) | | { | | AssetDatabase.SetLabels(plugin, new[] { ProcessedLabel }); |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I fixed.
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 😃
JoC0de linked an issue
that may beclosed by this pull request
… add unit test for package with multiple roslyn analyzers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})