public CciAttributeAdder(CciAssembly inputAssembly, ITypeDefinition typeToAnalyze, IReadOnlyCollection <Query> queries) : base(inputAssembly, typeToAnalyze, queries) { Contract.Requires(inputAssembly != null); Contract.Requires(typeToAnalyze != null); Contract.Requires(queries.Any()); AddVerifierAttribute(typeToAnalyze, queries); }
public void Save(CciAssembly assembly, string path) { Contract.Requires(assembly != null); Contract.Requires(!string.IsNullOrEmpty(path)); var sourceLocationProvider = GetPdbReader(assembly.Module); lock (turnstile) { ContractHelper.InjectContractCalls(host, assembly.Module, assembly.ContractProvider, sourceLocationProvider); } using (var peStream = File.Create(path)) { lock (turnstile) { PeWriter.WritePeToStream(assembly.Module, host, peStream); } } }
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); } }