Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
10 changes: 10 additions & 0 deletions src/NuGetForUnity/Editor/Helper/AnalyzerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ internal static class AnalyzerHelper
/// </summary>
private const string AnalyzersFolderName = "analyzers";

/// <summary>
/// File name suffix used by assemblies that provide IDE code fixes instead of compiler analyzers.
/// </summary>
private const string CodeFixAssemblySuffix = ".CodeFixes.dll";

/// <summary>
/// Name of the root folder containing dotnet analyzers.
/// </summary>
Expand All @@ -33,6 +38,11 @@ internal static class AnalyzerHelper
/// <returns>True if the label should be added, false otherwise.</returns>
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);
Expand Down
Loading