Esempio n. 1
0
 protected override void ComputeHashCodeParts(ref RoslynHashCode hashCode)
 {
     hashCode.Add(Operation.GetHashCode());
     hashCode.Add(AnalysisEntity.GetHashCodeOrDefault());
     hashCode.Add(InstanceLocation.GetHashCode());
     hashCode.Add(Value?.GetHashCode() ?? 0);
 }
Esempio n. 2
0
 protected override void ComputeHashCodeParts(Action <int> addPart)
 {
     addPart(Operation.GetHashCode());
     addPart(AnalysisEntity.GetHashCodeOrDefault());
     addPart(InstanceLocation.GetHashCode());
     addPart(Value.GetHashCodeOrDefault());
 }
Esempio n. 3
0
 protected override void ComputeHashCodeParts(ArrayBuilder <int> builder)
 {
     builder.Add(Operation.GetHashCode());
     builder.Add(AnalysisEntityOpt.GetHashCodeOrDefault());
     builder.Add(InstanceLocation.GetHashCode());
     builder.Add(Value.GetHashCode());
 }
Esempio n. 4
0
        public AnalysisEntity WithMergedInstanceLocation(AnalysisEntity analysisEntityToMerge)
        {
            Debug.Assert(EqualsIgnoringInstanceLocation(analysisEntityToMerge));
            Debug.Assert(!InstanceLocation.Equals(analysisEntityToMerge.InstanceLocation));

            var mergedInstanceLocation = PointsToAnalysis.PointsToAnalysis.PointsToAbstractValueDomainInstance.Merge(InstanceLocation, analysisEntityToMerge.InstanceLocation);

            return(new AnalysisEntity(Symbol, Indices, InstanceReferenceOperationSyntax, CaptureId, mergedInstanceLocation, Type, Parent, IsThisOrMeInstance));
        }
Esempio n. 5
0
        protected override bool ComputeEqualsByHashCodeParts(CacheBasedEquatable <ArgumentInfo <TAbstractAnalysisValue> > obj)
        {
            var other = (ArgumentInfo <TAbstractAnalysisValue>)obj;

            return(Operation.GetHashCode() == other.Operation.GetHashCode() &&
                   AnalysisEntity.GetHashCodeOrDefault() == other.AnalysisEntity.GetHashCodeOrDefault() &&
                   InstanceLocation.GetHashCode() == other.InstanceLocation.GetHashCode() &&
                   (Value?.GetHashCode() ?? 0) == (other.Value?.GetHashCode() ?? 0));
        }
        /// <summary>
        /// Converts an object to a <see cref="JsonValue"/>.
        /// </summary>
        /// <param name="serializer">The <see cref="JsonSerializer"/> instance to use for additional
        /// serialization of values.</param>
        /// <returns>The <see cref="JsonValue"/> representation of the object.</returns>
        public JsonValue ToJson(JsonSerializer serializer)
        {
            var obj = new JsonObject();

            obj["valid"] = IsValid;
            if (RelativeLocation != null)
            {
                var relativeLocation = RelativeLocation.ToString();
                obj["keywordLocation"] = relativeLocation;
                if (AbsoluteLocation != null && (AbsoluteLocation.Fragment != relativeLocation ||
                                                 RelativeLocation.Contains("$ref") ||
                                                 RelativeLocation.Contains("$recursiveRef")))
                {
                    obj["absoluteKeywordLocation"] = AbsoluteLocation.OriginalString;
                }
            }
            if (InstanceLocation != null)
            {
                obj["instanceLocation"] = InstanceLocation.ToString();
            }

            var nonNullNestedResults = NestedResults.Where(r => !ReferenceEquals(r, Null)).ToList();

            if (Keyword != null)
            {
                obj["keyword"] = Keyword;
            }
            if (IsValid)
            {
                if (AnnotationValue != null)
                {
                    obj["annotation"] = AnnotationValue;
                }
                if (nonNullNestedResults.Any())
                {
                    obj["annotations"] = nonNullNestedResults.Select(r => r.ToJson(serializer)).ToJson();
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(ErrorMessage))
                {
                    obj["error"] = ErrorMessage;
                }
                if (nonNullNestedResults.Any())
                {
                    obj["errors"] = nonNullNestedResults.Select(r => r.ToJson(serializer)).ToJson();
                }
            }
            if (IncludeAdditionalInfo && AdditionalInfo != null && AdditionalInfo.Any())
            {
                obj["additionalInfo"] = AdditionalInfo;
            }

            return(obj);
        }
 /// <summary>Serves as the default hash function. </summary>
 /// <returns>A hash code for the current object.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = IsValid.GetHashCode();
         hashCode = (hashCode * 397) ^ (RelativeLocation?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (AbsoluteLocation?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (InstanceLocation?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (AnnotationValue?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Keyword?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (AdditionalInfo?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (NestedResults?.GetCollectionHashCode() ?? 0);
         return(hashCode);
     }
 }
Esempio n. 8
0
        public void FindInstances(InstanceLocation folder)
        {
            if (!Directory.Exists(folder.Path))
            {
                Directory.CreateDirectory(folder.Path);
            }
            else
            {
                if (folder.GetType() == typeof(InstanceFolder))
                {
                    var dirs = Directory.GetDirectories(folder.Path);

                    foreach (var dir in dirs)
                    {
                        var xmlFile = GetInstanceXmlPath(dir);
                        if (!File.Exists(xmlFile))
                        {
                            continue;
                        }
                        var instance = XmlHelper.ReadConfig <Instance>(xmlFile);
                        instance.InstanceLocation = folder;
                        _instances.Add(instance);
                    }
                }
                else
                {
                    var xmlFile = GetInstanceXmlPath(folder.Path);
                    if (!File.Exists(xmlFile))
                    {
                        return;
                    }
                    var instance = XmlHelper.ReadConfig <Instance>(xmlFile);
                    instance.InstanceLocation = folder;
                    _instances.Add(instance);
                }
            }
        }
 protected override int ComputeHashCode() => HashUtilities.Combine(InstanceLocation.GetHashCode(), _lazyIgnoringLocationHashCode.Value);
Esempio n. 10
0
        public override int GetHashCode()
        {
            var hashCode = HashUtilities.Combine(SymbolOpt?.GetHashCode() ?? 0,
                                                 HashUtilities.Combine(InstanceReferenceOperationSyntaxOpt?.GetHashCode() ?? 0,
                                                                       HashUtilities.Combine(InstanceLocation.GetHashCode(),
                                                                                             HashUtilities.Combine(Type.GetHashCode(),
                                                                                                                   HashUtilities.Combine(ParentOpt?.GetHashCode() ?? 0, Indices.Length.GetHashCode())))));

            foreach (AbstractIndex index in Indices)
            {
                hashCode = HashUtilities.Combine(index.GetHashCode(), hashCode);
            }

            return(hashCode);
        }
 protected override void ComputeHashCodeParts(Action <int> addPart)
 {
     addPart(InstanceLocation.GetHashCode());
     ComputeHashCodePartsIgnoringLocation(addPart);
 }
 protected override void ComputeHashCodeParts(ArrayBuilder <int> builder)
 {
     builder.Add(InstanceLocation.GetHashCode());
     ComputeHashCodePartsIgnoringLocation(builder);
 }