public static void RemoveSpecificAttributes( [NotNull] IAttributesOwnerDeclaration attributesOwner, [NotNull, ItemNotNull] IEnumerable <string> shortNames, [NotNull] CodeAnnotationsConfiguration codeAnnotationConfig) { var candidatesToRemove = attributesOwner.AttributesEnumerable .Where(attr => shortNames.Any(name => codeAnnotationConfig.IsAnnotationAttribute(attr.GetAttributeInstance(), name))) .ToList(); candidatesToRemove.ForEach(attributesOwner.RemoveAttribute); }
private bool IsDisplayedAnnotation([CanBeNull] IAttributeInstance attribute, [CanBeNull] string shortName, AnnotationsDisplayKind showAnnotations) { if (attribute == null || shortName == null) { return(false); } switch (showAnnotations) { case AnnotationsDisplayKind.Nullness: return(shortName == NullnessProvider.CanBeNullAttributeShortName || shortName == NullnessProvider.NotNullAttributeShortName); case AnnotationsDisplayKind.All: return(_codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, shortName)); default: return(false); } }
public bool ContainsAnyExplicitNullabilityAttributes(IEnumerable <IAttributeInstance> attributeInstances) { return(attributeInstances.Any(x => _codeAnnotationsConfiguration.IsAnnotationAttribute(x, NullnessProvider.NotNullAttributeShortName) || _codeAnnotationsConfiguration.IsAnnotationAttribute(x, NullnessProvider.CanBeNullAttributeShortName))); }