Skip to content

Commit

Permalink
Merge pull request #805 from nunit/fix/dont-fail-on-multiple-references
Browse files Browse the repository at this point in the history
fix(BaseAssertionAnalyzer): Don't fail if there are multiple references to NUnit
  • Loading branch information
mikkelbu authored Dec 13, 2024
2 parents 260d60d + ec10381 commit f1329ad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/nunit.analyzers/BaseAssertionAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
using NUnit.Analyzers.Constants;
using NUnit.Analyzers.Extensions;

namespace NUnit.Analyzers
Expand Down Expand Up @@ -50,7 +51,8 @@ private void AnalyzeCompilationStart(CompilationStartAnalysisContext context)
{
IEnumerable<AssemblyIdentity> referencedAssemblies = context.Compilation.ReferencedAssemblyNames;

AssemblyIdentity? nunit = referencedAssemblies.SingleOrDefault(a => a.Name.Equals("nunit.framework", StringComparison.OrdinalIgnoreCase));
AssemblyIdentity? nunit = referencedAssemblies.FirstOrDefault(a =>
a.Name.Equals(NUnitFrameworkConstants.NUnitFrameworkAssemblyName, StringComparison.OrdinalIgnoreCase));

if (nunit is null)
{
Expand Down

0 comments on commit f1329ad

Please sign in to comment.