コード例 #1
0
 /// <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);
 }
コード例 #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);
            }
        }
コード例 #3
0
 public ITypeContract TypeContract()
 {
     return(contractProvider.GetTypeContractFor(typeDefinition));
 }