Example #1
0
        public static bool HasAnyPrecondition(this IPropertySymbol @this, SemanticModel model)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            return([email protected] &&
                   @this.DeclaredAndInheritedAttributes()
                   .Any(a => a.IsContractAttribute(model)));
        }
Example #2
0
        public static bool HasPostcondition(this IPropertySymbol @this, SemanticModel model, Contract contract)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (contract == null)
            {
                throw new ArgumentNullException(nameof(contract));
            }

            var attributeSymbol = contract.AttributeType.GetTypeSymbol(model);

            return([email protected] &&
                   @this.DeclaredAndInheritedAttributes()
                   .Any(a => a.IsExactType(contract.AttributeType, model)));
        }
Example #3
0
        public static IEnumerable <Contract> GetPostconditions(this IPropertySymbol @this, SemanticModel model, IContractProvider contractProvider)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (contractProvider == null)
            {
                throw new ArgumentNullException(nameof(contractProvider));
            }

            return(@this.IsWriteOnly
                ? Enumerable.Empty <Contract>()
                : @this
                   .DeclaredAndInheritedAttributes()
                   .Where(a => a.IsContractAttribute(model))
                   .Select(a => contractProvider[a.AttributeClass.Name.ToString().Trim()]));
        }