コード例 #1
0
        protected CustomAttribute DisableVerifier()
        {
            var host            = CciHostEnvironment.GetInstance();
            var disableVerifier = new CustomAttribute
            {
                Arguments = new List <IMetadataExpression> {
                    new MetadataConstant {
                        Value = false, Type = host.PlatformType.SystemBoolean
                    }
                },
                Constructor =
                    new MethodReference(host,
                                        host.PlatformType.SystemDiagnosticsContractsContract.ResolvedType.ContainingNamespace.GetMembersNamed(
                                            host.NameTable.GetNameFor("ContractVerificationAttribute"), false).First() as INamespaceTypeReference,
                                        CallingConvention.HasThis,
                                        host.PlatformType.SystemVoid, host.NameTable.GetNameFor(".ctor"), 0, host.PlatformType.SystemBoolean)
            };

            return(disableVerifier);
        }
コード例 #2
0
        public CciQueryAssembly(CciAssembly inputAssembly, ITypeDefinition typeToAnalyze, IReadOnlyCollection <Query> queries)
            : base(inputAssembly.Module, inputAssembly.ContractProvider)
        {
            Contract.Requires(inputAssembly != null);
            Contract.Requires(typeToAnalyze != null);
            Contract.Requires(queries.Any());

            // Clone module
            var host = CciHostEnvironment.GetInstance();

            module = new CodeAndContractDeepCopier(host).Copy(inputAssembly.Module);
            var cciQueryType = FindType(module, typeToAnalyze.Name);

            Contract.Assert(cciQueryType != null);

            // Create contract provider for the cloned module
            contractProvider = new ContractProvider(new ContractMethods(host), host.FindUnit(module.UnitIdentity));

            var cciInputType = FindType(inputAssembly.Module, typeToAnalyze.Name);

            Contract.Assert(cciInputType != null);
            var queryTypeContract = inputAssembly.ContractProvider.GetTypeContractFor(cciInputType);

            contractProvider.AssociateTypeWithContract(cciQueryType, queryTypeContract);

            // Add queries
            cciQueryType.Methods.AddRange(from a in queries select a.Method.Method);

            foreach (var query in queries)
            {
                // Find the query in the query assembly
                var method = cciQueryType.Methods.Find(m => m.GetUniqueName().Equals(query.Method.Name)) as MethodDefinition;
                Contract.Assert(method != null);

                method.ContainingTypeDefinition = cciQueryType;

                // Asociate query with its contract
                contractProvider.AssociateMethodWithContract(query.Method.Method, query.Method.Contract);
            }
        }
コード例 #3
0
 public CciAssemblyPersister()
 {
     host = CciHostEnvironment.GetInstance();
 }
コード例 #4
0
 public CciQueryGenerator()
 {
     host = CciHostEnvironment.GetInstance();
 }