Open sandboxFocus

Class ContractOptions

Options for all aspects of the Metalama.Patterns.Contracts namespace. You can configure these options using the ConfigureContracts(IAspectReceiver<ICompilation>, ContractOptions) method.

Inheritance
ContractOptions
Namespace: Metalama.Patterns.Contracts
Assembly: Metalama.Patterns.Contracts.dll
Syntax
public sealed class ContractOptions : IHierarchicalOptions<ICompilation>, IHierarchicalOptions<INamespace>, IHierarchicalOptions<INamedType>, IHierarchicalOptions<IFieldOrPropertyOrIndexer>, IHierarchicalOptions<IMethod>, IHierarchicalOptions<IParameter>, IHierarchicalOptions, IIncrementalObject, ICompileTimeSerializable

Constructors

Name Description
ContractOptions()

Properties

Name Description
AreInvariantsEnabled

Gets or sets a value indicating whether invariants are being enforced. This option is true by default.

ArePostconditionsEnabled

Gets or sets a value indicating whether postcondition contracts are being enforced. This option is true by default.

ArePreconditionsEnabled

Gets or sets a value indicating whether precondition contracts are being enforced. This option is true by default.

DefaultInequalityStrictness

Gets or sets a value determining the meaning of inequalities whose strictness is not explicitly specified i.e. GreaterThanAttribute, LessThanAttribute, PositiveAttribute and NegativeAttribute.

Direction

Gets or sets the default direction of contracts. The default value is Default, which has a different behavior according to the declaration to which it is applied. This option can also be configured for each aspect using the Direction property of the aspect class.

IsInheritable

Gets or sets a value indicating whether the contracts are inheritable by default. The default value is true. This option can also be configured for each aspect using the IsInheritable property of the aspect class.

IsInvariantSuspensionSupported

Gets or sets a value indicating whether the InvariantAttribute aspect should generate the code that supports the SuspendInvariantsAttribute, including the SuspendInvariants and AreInvariantsSuspended methods. The option is false by default.

Templates

Gets or sets the code templates that are used by the aspects. You can set this property to an instance of a class that derives from ContractTemplates and overrides some of the virtual methods.

WarnOnNotNullableOnNullable

Gets or sets a value indicating whether the LAMA5002 warning should be reported when attempting to add a NotNullAttribute or RequiredAttribute contract on a nullable parameter, field or property. This option is true by default.

See Also