public static bool HasAnyPostconditionAttribute(this BasePropertyDeclarationSyntax @this, SemanticModel model) { if (@this == null) { throw new ArgumentNullException(nameof(@this)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } var attributeTypeSymbol = typeof(ContractAttribute).GetTypeSymbol(model); return([email protected]() && @this.AllAttributes() .Any(a => model.GetTypeInfo(a).Type.InheritsFrom(attributeTypeSymbol))); }
public static IEnumerable <Contract> GetPostconditions(this BasePropertyDeclarationSyntax @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)); } var attributeTypeSymbol = typeof(ContractAttribute).GetTypeSymbol(model); return(@this.IsWriteonly() ? Enumerable.Empty <Contract>() : @this.AllAttributes() .Where(a => model.GetTypeInfo(a).Type.InheritsFrom(attributeTypeSymbol)) .Select(a => contractProvider[a.GetText().ToString().Trim()])); }