public NodeVisitor(IMetadataHost host, CommonSemanticModel semanticModel, ISourceLocationProvider /*?*/ sourceLocationProvider)
        {
            this.host                   = host;
            this.nameTable              = host.NameTable;
            this.semanticModel          = semanticModel;
            this.sourceLocationProvider = sourceLocationProvider;

            this.contractMethods = new ContractMethods(host);
            // translate the entire metadata model for the assembly
            // the actual visit is just to get method bodies for any methods
            // defined in the cone that is visited.
            this.mapper = ReferenceMapper.TranslateAssembly(host, semanticModel.Compilation.Assembly);
        }
        private IUnit unit; // the module this is a lazy provider for

        /// <summary>
        /// Allocates an object that can be used to query for contracts by asking questions about specific methods/types, etc.
        /// </summary>
        /// <param name="host">The host that loaded the unit for which this is to be a contract provider.</param>
        /// <param name="unit">The unit to retrieve the contracts from.</param>
        /// <param name="contractMethods">A collection of methods that can be called in a way that provides tools with information about contracts.</param>
        /// <param name="usePdb">Whether to use the PDB file (and possibly the source files if available) during extraction.</param>
        public LazyContractExtractor(IContractAwareHost host, IUnit unit, IContractMethods contractMethods, bool usePdb)
        {
            this.host = host;
            this.underlyingContractProvider = new ContractProvider(contractMethods, unit);
            if (usePdb)
            {
                string pdbFile = Path.ChangeExtension(unit.Location, "pdb");
                if (File.Exists(pdbFile))
                {
                    using (var pdbStream = File.OpenRead(pdbFile)) {
                        this.pdbReader = new PdbReader(pdbStream, host);
                    }
                }
            }
            this.unit = unit;
        }
Example #3
0
 /// <summary>
 /// Allocates an object that associates contracts, such as preconditions and postconditions, with methods, types and loops. 
 /// </summary>
 /// <param name="contractMethods">A collection of methods that can be called in a way that provides tools with information about contracts.</param>
 /// <param name="unit">The unit for which this is a contract provider.</param>
 public SourceContractProvider(IContractMethods contractMethods, IUnit unit)
     : base(contractMethods, unit)
 {
 }
Example #4
0
 /// <summary>
 /// Allocates an object that associates contracts, such as preconditions and postconditions, with methods, types and loops. 
 /// If the object is already associated with a contract, that association will be lost as a result of this call.
 /// </summary>
 /// <param name="contractMethods">A collection of methods that can be called in a way that provides tools with information about contracts.</param>
 /// <param name="unit">The unit that this is a contract provider for.</param>
 public ContractProvider(IContractMethods contractMethods, IUnit unit) {
   this.contractMethods = contractMethods;
   this.unit = unit;
 }
Example #5
0
        private IUnit unit; // the module this is a lazy provider for

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Allocates an object that can be used to query for contracts by asking questions about specific methods/types, etc.
        /// </summary>
        /// <param name="host">The host that loaded the unit for which this is to be a contract provider.</param>
        /// <param name="unit">The unit to retrieve the contracts from.</param>
        /// <param name="contractMethods">A collection of methods that can be called in a way that provides tools with information about contracts.</param>
        /// <param name="usePdb">Whether to use the PDB file (and possibly the source files if available) during extraction.</param>
        public LazyContractExtractor(IContractAwareHost host, IUnit unit, IContractMethods contractMethods, bool usePdb)
        {
            this.host = host;
              this.underlyingContractProvider = new ContractProvider(contractMethods, unit);
              if (usePdb) {
            string pdbFile = Path.ChangeExtension(unit.Location, "pdb");
            if (File.Exists(pdbFile)) {
              using (var pdbStream = File.OpenRead(pdbFile)) {
            this.pdbReader = new PdbReader(pdbStream, host);
              }
            }
              }
              this.unit = unit;
        }
Example #6
0
 /// <summary>
 /// Allocates an object that associates contracts, such as preconditions and postconditions, with methods, types and loops.
 /// If the object is already associated with a contract, that association will be lost as a result of this call.
 /// </summary>
 /// <param name="contractMethods">A collection of methods that can be called in a way that provides tools with information about contracts.</param>
 /// <param name="unit">The unit that this is a contract provider for.</param>
 public ContractProvider(IContractMethods contractMethods, IUnit unit)
 {
     this.contractMethods = contractMethods;
     this.unit            = unit;
 }