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

            return(@this
                   .DeclaredAndInheritedAttributes()
                   .Any(a => a.IsContractAttribute(model)));
        }
Example #2
0
        public static IEnumerable <Contract> GetPreconditions(this IParameterSymbol @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
                   .DeclaredAndInheritedAttributes()
                   .Where(a => a.IsContractAttribute(model))
                   .Select(a => contractProvider[a.AttributeClass.Name.ToString().Trim()]));
        }