Exemplo n.º 1
0
    public override MethodContract VisitMethodContract(MethodContract contract){
      if (contract == null) return null;
      if (contract.DeclaringMethod == null) return contract;
      // No point normalizing contracts on interfaces; no code should be generated.
      if (contract.DeclaringMethod.DeclaringType is Interface) return contract;

      Duplicator duplicator = new Duplicator(this.currentModule, this.currentType);      
      MethodContract copy = duplicator.VisitMethodContract(contract);            

      if (this.currentMethod.IsVisibleOutsideAssembly
        ? !(this.currentCompilation != null && this.currentCompilation.CompilerParameters is CompilerOptions && ((CompilerOptions)this.currentCompilation.CompilerParameters).DisableDefensiveChecks)
        : !(this.currentCompilation != null && this.currentCompilation.CompilerParameters is CompilerOptions && ((CompilerOptions)this.currentCompilation.CompilerParameters).DisableInternalChecks))
        contract.Requires = this.VisitRequiresList(contract.Requires);
      if (!(this.currentCompilation != null && this.currentCompilation.CompilerParameters is CompilerOptions && ((CompilerOptions)this.currentCompilation.CompilerParameters).DisableInternalChecks))
        contract.Ensures = this.VisitEnsuresList(contract.Ensures);
      // don't visit the Modifies clause since no code is generated for it
      //      contract.Modifies = this.VisitExpressionList(contract.Modifies);
      //      contract = base.VisitMethodContract(contract); don't let base visit it!

      contract.Requires = copy.Requires;
      contract.Ensures = copy.Ensures;

      return contract;

    }