diff --git a/src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs b/src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs index 33680a7e..5cdc34af 100644 --- a/src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs +++ b/src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs @@ -52,6 +52,13 @@ public void SimpleRestoreTest() Assert.Pass(); } + [TestCase("MessagePack.Analyzers.CodeFixes.dll")] + [TestCase("messagepack.analyzers.codefixes.DLL")] + public void CodeFixAssemblyIsNotEnabledAsRoslynAnalyzerTest(string assemblyPath) + { + Assert.IsFalse(AnalyzerHelper.ShouldEnableRoslynAnalyzer(assemblyPath)); + } + [Test] public void LoadConfigFileTest() { diff --git a/src/NuGetForUnity/Editor/Helper/AnalyzerHelper.cs b/src/NuGetForUnity/Editor/Helper/AnalyzerHelper.cs index ac4a143d..a60f55e8 100644 --- a/src/NuGetForUnity/Editor/Helper/AnalyzerHelper.cs +++ b/src/NuGetForUnity/Editor/Helper/AnalyzerHelper.cs @@ -16,6 +16,11 @@ internal static class AnalyzerHelper /// private const string AnalyzersFolderName = "analyzers"; + /// + /// File name suffix used by assemblies that provide IDE code fixes instead of compiler analyzers. + /// + private const string CodeFixAssemblySuffix = ".CodeFixes.dll"; + /// /// Name of the root folder containing dotnet analyzers. /// @@ -33,6 +38,11 @@ internal static class AnalyzerHelper /// True if the label should be added, false otherwise. public static bool ShouldEnableRoslynAnalyzer(string path) { + if (path.EndsWith(CodeFixAssemblySuffix, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + // The nuget package can contain analyzers for multiple Roslyn versions. // In that case, for the same package, the most recent version must be chosen out of those available for the current Unity version. var assetPath = Path.GetFullPath(path);