/// <summary>
 /// Wraps a call to GetTypeContractFor inside of a try-catch statement.
 /// </summary>
 public static bool TryGetTypeContract(CodeContractAwareHostEnvironment host, ITypeReference type, out ITypeContract typeContract, DocTracker docTracker)
 {
     Contract.Requires(host != null);
     Contract.Requires(type != null);
     Contract.Ensures(!Contract.Result <bool>() || Contract.ValueAtReturn(out typeContract) != null);
     try {
         var unit = TypeHelper.GetDefiningUnit(type.ResolvedType);
         if (unit == null)
         {
             typeContract = null;
         }
         else
         {
             IContractProvider lcp = host.GetContractExtractor(unit.UnitIdentity);
             if (lcp == null)
             {
                 typeContract = null;
             }
             else
             {
                 typeContract = lcp.GetTypeContractFor(type);
             }
         }
     } catch (NullReferenceException) {
         docTracker.WriteLine("ERROR: NullReferenceException was thrown in CCI!");
         typeContract = null;
     }
     return(typeContract != null);
 }
Example #2
0
        /// <summary>
        ///     Traverses the children of the type definition.
        /// </summary>
        public override void TraverseChildren(ITypeDefinition typeDefinition)
        {
            base.TraverseChildren(typeDefinition);
            if (StopTraversal)
            {
                return;
            }
            if (contractProvider == null)
            {
                return;
            }
            var /*?*/ typeContract = contractProvider.GetTypeContractFor(typeDefinition);

            if (typeContract != null)
            {
                Traverse(typeContract);
            }
        }
Example #3
0
 public ITypeContract TypeContract()
 {
     return(contractProvider.GetTypeContractFor(typeDefinition));
 }