Open sandboxFocus

Class BaseReferenceValidator

Abstract base class for validator of code references.

Inheritance
BaseReferenceValidator
Namespace: Metalama.Framework.Validation
Assembly: Metalama.Framework.dll
Syntax
public abstract class BaseReferenceValidator : ICompileTimeSerializable

Properties

Name Description
Granularity

Gets level of declarations at which the analysis should be performed. For instance, if the ValidateReferences(ReferenceValidationContext) method only depends on the namespace of the referencing syntax (as opposed to its declaring member or type), then Granularity should be set to Namespace, and ValidateReferences(ReferenceValidationContext) will be invoked a single time per namespace.

IncludeDerivedTypes

Gets a value indicating whether references to derived types should also be visited by the ValidateReferences(ReferenceValidationContext) method. This property is only evaluated when the validated declaration is an INamedType.

ValidatedEndRole

Gets the direction (Destination or Origin) of to the validated reference ends. If the ValidatedEndRole is set to Origin, the validator must be added to the destination (i.e. referenced) declaration, and the ValidateReferences(ReferenceValidationContext) method will be called with references on the origin (referencing) ends.

ValidatedReferenceKinds

Gets the kinds of references for which the ValidateReferences(ReferenceValidationContext) method should be invoked. For optimal performance, the set should be restricted to its required minimum. Flags that are not compatible with the validated kind of declarations are automatically ignored.

Methods

Name Description
ValidateReferences(ReferenceValidationContext)

Validates the references in the given context. The context may contain several references, all grouped according to the validator Granularity. The implementation is reponsible for reporting diagnostics as necessary.

Extension Methods