Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned an empty value. The custom attributes can be added to locations of type string (where empty means zero characters), or ICollection, ICollection<T>, IReadOnlyCollection<T>, arrays or ImmutableArray<T> (where empty means zero items). Null references or default ImmutableArray<T> instances are accepted and do not throw an exception.
Implements
Namespace: Metalama.Patterns.Contracts
Assembly: Metalama.Patterns.Contracts.dll
Syntax
public sealed class NotEmptyAttribute : ContractBaseAttribute, IAspect<IParameter>, IEligible<IParameter>, IAspect<IFieldOrPropertyOrIndexer>, IEligible<IFieldOrPropertyOrIndexer>, IConditionallyInheritableAspect, IAspect, ICompileTimeSerializable, ITemplateProviderConstructors
| Name | Description |
|---|---|
| NotEmptyAttribute() | Initializes a new instance of the NotEmptyAttribute class. |
Methods
| Name | Description |
|---|---|
| BuildEligibility(IEligibilityBuilder<IFieldOrPropertyOrIndexer>) | Configures the eligibility of the aspect or attribute by defining rules that determine which declarations the aspect can be applied to. |
| Validate(dynamic?) | The template method that validates or normalizes the value of a field, property, indexer, or parameter. |