Skip to content

Commit

Permalink
Inverted IsAssignableFrom and use unbound generic for Attribute<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Jul 18, 2024
1 parent ebfc86e commit 729501d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/xunit.analyzers/X1000/EnsureFixturesHaveASource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void AnalyzeCompilation(
Guard.ArgumentNotNull(xunitContext);

var collectionAttributeType = xunitContext.Core.CollectionAttributeType;
var collectionAttributeOfTType = xunitContext.V3Core?.CollectionAttributeOfTType;
var collectionAttributeOfTType = xunitContext.V3Core?.CollectionAttributeOfTType?.ConstructUnboundGenericType();
var collectionDefinitionAttributeType = xunitContext.Core.CollectionDefinitionAttributeType;

context.RegisterSymbolAction(context =>
Expand Down Expand Up @@ -51,7 +51,7 @@ public override void AnalyzeCompilation(
collectionDefinition =
type
.GetAttributes()
.FirstOrDefault(a => a.AttributeClass.IsAssignableFrom(collectionAttributeType))
.FirstOrDefault(a => collectionAttributeType.IsAssignableFrom(a.AttributeClass))
?.ConstructorArguments
.FirstOrDefault()
.Value;
Expand All @@ -61,7 +61,7 @@ public override void AnalyzeCompilation(
collectionDefinition =
type
.GetAttributes()
.FirstOrDefault(a => a.AttributeClass.IsAssignableFrom(collectionAttributeOfTType))
.FirstOrDefault(a => collectionAttributeOfTType.IsAssignableFrom(a.AttributeClass))
?.AttributeClass
?.TypeArguments
.FirstOrDefault();
Expand Down

0 comments on commit 729501d

Please sign in to comment.