Skip to content

Commit

Permalink
Merge pull request #94 from NeVeSpl/correctionOfPR86
Browse files Browse the repository at this point in the history
correction Of #86 and #85
  • Loading branch information
BenMorris authored May 18, 2021
2 parents ef91e25 + 9dd79da commit 5908725
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,16 @@ private void CheckMethodBodyInstructions(MethodDefinition methodToCheck)
}
break;
case FieldReference fieldReference:
if (!fieldReference.Resolve().CustomAttributes.IsCompilerGenerated())
if (fieldReference.DeclaringType != _typeToCheck)
{
CheckTypeReference(fieldReference.DeclaringType);
}
break;
case MethodReference methodReference:
CheckTypeReference( methodReference.DeclaringType);
if (methodReference.DeclaringType != _typeToCheck)
{
CheckTypeReference(methodReference.DeclaringType);
}
break;
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/NetArchTest.Rules/Extensions/TypeDefinitionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ public static bool HasNullableMembers(this TypeDefinition typeDefinition)

public static bool IsCompilerGenerated(this TypeDefinition typeDefinition)
{
return typeDefinition.CustomAttributes.IsCompilerGenerated();
}

public static bool IsCompilerGenerated(this Collection<CustomAttribute> customAttributes)
{
return customAttributes.Any(x => x?.AttributeType?.FullName == typeof(CompilerGeneratedAttribute).FullName);
return typeDefinition.CustomAttributes.Any(x => x?.AttributeType?.FullName == typeof(CompilerGeneratedAttribute).FullName);
}

/// <summary>
Expand Down

0 comments on commit 5908725

Please sign in to comment.