public bool TryGetMethodModelForHash(ByteArray hash, out Method result)
    {
      Contract.Requires(hash != null);
      Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn(out result) != null);

      throw new NotImplementedException();
    }
    public void AddOrUpdateMethod(Method methodModel, ByteArray methodId)
    {
      Contract.Requires(methodModel != null);
      Contract.Requires(methodId != null);

      throw new NotImplementedException();
    }
        public static InferredExpr <Field, Method> GetInferredExpr <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(
            this Microsoft.Research.CodeAnalysis.Caching.Models.Method @this,
            Method currentMethod,
            IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder,
            IDecodeContracts <Local, Parameter, Method, Field, Type> contractDecoder,
            bool trace
            )
        {
            if (@this.InferredExpr == null)
            {
                return(default(InferredExpr <Field, Method>));
            }
            if (@this.InferredExprHash == null)
            {
                throw new SerializationException("Cannot check deserialization, hash null");
            }

            var state             = StreamingContextStates.File | StreamingContextStates.Persistence;
            var streamingContext  = new StreamingContext(state);
            var surrogateSelector = Serializers.SurrogateSelectorFor(streamingContext, currentMethod, mdDecoder, contractDecoder, trace);
            var formatter         = new BinaryFormatter(surrogateSelector, streamingContext);
            var stream            = new System.IO.MemoryStream(@this.InferredExpr);

            try
            {
                // Fix for SerializationException below. Somehow deserialization does not find certain assemblies, so we help out
                // the resolver to find currently loaded assemblies.
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(DeserializeAssemblyResolve);
                var result  = (InferredExpr <Field, Method>)formatter.Deserialize(stream);
                var newHash = DummyExpressionHasher.Hash(result, trace);
                if (@this.InferredExprHash.ContentEquals(newHash))
                {
                    return(result);
                }
                throw new SerializationException(String.Format("Deserialization failed: hash differs. Expected '{0}', got '{1}'.", @this.InferredExprString, result.ToString()));
            }
            catch (SerializationException)
            {
                // "Unable to find assembly 'ClousotMain, Version=1.1.1.1, Culture=neutral, PublicKeyToken=188286aac86319f9'." just means the Clousot has been recompiled (its version number should have changed)
                // must not happen, please, please, please! ('cause the method hasn't changed)

                // this happens because there are some types in ClousotMain that get serialized. But when we build an installer, these types are actually in cccheck.exe
                // so a cache populated using Clousot does not interact well with a cache used with cccheck.
                throw;
            }
            catch (NotImplementedException e)
            {
                throw new SerializationException("Some deserialization implementation is missing, see inner exception", e);
            }
            catch (Exception e)
            {
                // ArgumentException "Object of type '<type>' cannot be converted to type '<type>'." just means the type has changed
                throw new SerializationException("Random exception while deserializing, see inner exception", e);
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(DeserializeAssemblyResolve);
            }
        }
    public void AddOrUpdateBaseline(string fullname, string baselineId, Method baseline)
    {
      Contract.Requires(fullname != null);
      Contract.Requires(baselineId != null);
      Contract.Requires(baseline != null);

      throw new NotImplementedException();
    }
    public bool TryGetBaselineModel(string methodFullName, string baselineId, out Method result)
    {
      Contract.Requires(methodFullName != null);
      Contract.Requires(baselineId != null);

      Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn(out result) != null);

      throw new NotImplementedException();
    }
        public static void SetInferredExpr <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(
            this Microsoft.Research.CodeAnalysis.Caching.Models.Method @this,
            InferredExpr <Field, Method> value,
            Method currentMethod,
            IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder,
            IDecodeContracts <Local, Parameter, Method, Field, Type> contractDecoder,
            bool trace,
            bool traceHashing)
        {
            // To make the serialization happy
            var state            = StreamingContextStates.File | StreamingContextStates.Persistence;
            var streamingContext = new StreamingContext(state);

            // We do not want to serialize CCI types directly. We want the Serialization to call us and ask if we have a better way of serializing
            var surrogateSelector = Serializers.SurrogateSelectorFor(streamingContext, currentMethod, mdDecoder, contractDecoder, trace);

            // Create the serializer
            var formatter = new BinaryFormatter(surrogateSelector, streamingContext);
            var stream    = new System.IO.MemoryStream();

            try
            {
                // Now do the work!
                formatter.Serialize(stream, value);
            }
            catch (SerializationException)
            {
                throw;
            }
            catch (NotImplementedException e)
            {
                throw new SerializationException("Some serialization implementation is missing, see inner exception", e);
            }
            catch (Exception e)
            {
                throw new SerializationException("Random exception while serializing, see inner exception", e);
            }
            @this.InferredExpr     = stream.ToArray();
            @this.InferredExprHash = DummyExpressionHasher.Hash(value, traceHashing);
            if (trace)
            {
                @this.InferredExprString = value.ToString();
            }
        }
    public Suggestion AddNewSuggestion(Method method, string message, string kind, ClousotSuggestion.Kind type, ClousotSuggestion.ExtraSuggestionInfo extraInfo)
    {
      if (!this.IsValid) return null;

      var res = this.model.NewSuggestion(method);
      res.Message = message;
      res.Type= (byte)type;
      res.Kind = kind;
      res.ExtraInfo = extraInfo.Serialize();

      return res;
    }
 [ContractVerification(false)] // cccheck does not understand exceptional block
 public void AddAssemblyBinding(Method methodModel, AssemblyInfo assemblyInfo)
 {
   Contract.Assume(this.model != null);
   this.model.AddOrUpdate(methodModel, assemblyInfo);
 }
    public void AddOrUpdateBaseline(string fullname, string baselineId, Method baseline)
    {
      if (!this.IsValid) return;

      this.model.AddOrUpdate(new BaselineMethod { MethodFullNameHash = fullname.MD5Encode(), BaselineId = baselineId, Method = baseline });
    }
示例#10
0
    public Outcome AddNewOutcome(Method method, string message, bool related)
    {
      if (!this.IsValid) return null;

      var res = this.model.NewOutcome(method);
      res.Message = message;
      res.Related = related;
      return res;
    }
 public Suggestion AddNewSuggestion(Method method, string suggestion, string kind, ClousotSuggestion.Kind type, ClousotSuggestion.ExtraSuggestionInfo extraInfo)
 {
   return underlying.AddNewSuggestion(method, suggestion, kind, type, extraInfo);
 }
示例#12
0
 public void DeleteMethodModel(Method methodModel)
 {
   if (!this.IsValid) return;
   this.model.DeleteMethodModel(methodModel);
 }
示例#13
0
    public Outcome AddNewOutcome(Method method, string message, bool related)
    {
      Contract.Requires(method != null);
      Contract.Requires(message != null);
      Contract.Ensures(Contract.Result<Outcome>() != null);

      throw new NotImplementedException();
    }
 public void AddOrUpdateMethod(Method methodModel, DataStructures.ByteArray methodId)
 {
   underlying.AddOrUpdateMethod(methodModel, methodId);
 }
示例#15
0
 public void AddOrUpdate(Method methodModel)
 {
     Contract.Requires(methodModel != null);
     throw new NotImplementedException();
 }
示例#16
0
        public IdHashTimeToMethod NewHashDateBindingForNow(ByteArray methodIdHash, Method methodModel)
        {
            Contract.Requires(methodIdHash != null);
            Contract.Requires(methodModel != null);
            Contract.Ensures(Contract.Result<IdHashTimeToMethod>() != null);

            throw new NotImplementedException();
        }
示例#17
0
        public void DeleteMethodModel(Method methodModel)
        {
            Contract.Requires(methodModel != null);

            throw new NotImplementedException();
        }
示例#18
0
        public Suggestion NewSuggestion(Method method)
        {
            Contract.Ensures(Contract.Result<Suggestion>() != null);

            throw new NotImplementedException();
        }
示例#19
0
        public Outcome NewOutcome(Method method)
        {
            Contract.Ensures(Contract.Result<Outcome>() != null);

            throw new NotImplementedException();
        }
示例#20
0
    public void AddAssemblyBinding(Method methodModel, AssemblyInfo assemblyInfo)
    {
      Contract.Requires(methodModel != null);
      Contract.Requires(assemblyInfo != null);

      throw new NotImplementedException();
    }
 public bool TryGetBaselineModel(string methodFullname, string baselineId, out Method result)
 {
   return underlying.TryGetBaselineModel(methodFullname, baselineId, out result);
 }
示例#22
0
 public void DeleteMethodModel(Method methodModel)
 {
   Contract.Requires(methodModel != null);
 }
 public void DeleteMethodModel(Method methodModel)
 {
   this.underlying.DeleteMethodModel(methodModel);
 }
 public bool TryGetMethodModelForHash(DataStructures.ByteArray hash, out Method result)
 {
   return underlying.TryGetMethodModelForHash(hash, out result);
 }
 public Outcome AddNewOutcome(Method method, string message, bool related)
 {
   return underlying.AddNewOutcome(method, message, related);
 }
示例#26
0
 public bool TryGetMethodModelForHash(ByteArray hash, out Method result)
 {
   if (!this.IsValid) { result = null; return false; }
   Contract.Assume(hash.Bytes != null);
   result = this.model.MethodByHash(hash.Bytes);
   return result != null;
 }
 public void AddOrUpdateBaseline(string fullname, string baselineId, Method baseline)
 {
   this.underlying.AddOrUpdateBaseline(fullname, baselineId, baseline);
 }
示例#28
0
    public Suggestion AddNewSuggestion(Method method, string suggestion, string kind, ClousotSuggestion.Kind type, ClousotSuggestion.ExtraSuggestionInfo extraInfo)
    {
      Contract.Requires(method != null);
      Contract.Requires(suggestion != null);
      Contract.Ensures(Contract.Result<Suggestion>() != null);

      throw new NotImplementedException();
    }
示例#29
0
 public bool TryGetBaselineModel(string methodFullname, string baselineId, out Method result)
 {
   if (!this.IsValid) { result = null; return false; }
   result = this.model.BaselineByName(methodFullname.MD5Encode(), baselineId);
   return result != null;
 }
示例#30
0
    public void AddOrUpdateMethod(Method methodModel, ByteArray methodId)
    {
      if (!this.IsValid) return;

      this.model.AddOrUpdate(methodModel);
      var idhash = model.NewHashDateBindingForNow(methodId, methodModel);
      model.AddOrUpdate(idhash);
    }
 public void AddAssemblyBinding(Method methodModel, AssemblyInfo assemblyInfo)
 {
     underlying.AddAssemblyBinding(methodModel, assemblyInfo);
 }