Exemplo n.º 1
0
        /// <inheritdoc />
        public void WriteFingerprintInputs(IFingerprinter writer)
        {
            writer.AddNested(ObservedPathSet.Labels.UnsafeOptions, UnsafeOptions.ComputeFingerprint);

            var thisRef = this;

            writer.AddNested(ObservedPathSet.Labels.Paths, w =>
            {
                foreach (var p in thisRef.PathEntries)
                {
                    w.Add(ObservedPathEntryConstants.Path, p.Path);
                    if (p.Flags != ObservedPathEntryFlags.None)
                    {
                        w.Add(ObservedPathEntryConstants.Flags, p.Flags.ToString());
                    }
                    if (p.EnumeratePatternRegex != null)
                    {
                        w.Add(ObservedPathEntryConstants.EnumeratePatternRegex, p.EnumeratePatternRegex);
                    }
                }
            });

            writer.AddCollection <StringId, ReadOnlyArray <StringId> >(
                ObservedPathSet.Labels.ObservedAccessedFileNames,
                ObservedAccessedFileNames,
                (w, v) => w.Add(v));

            // Observed inputs are included directly into the strong fingerprint hash computation,
            // so they do not need to be serialized here
        }
Exemplo n.º 2
0
        private static void BuildStringHelper(JsonNode root, IFingerprinter wr)
        {
            if (root.Children.Count == 1 && root.Values.Count == 0)
            {
                wr.AddNested(root.Name, nestedWr =>
                {
                    BuildStringHelper(root.Children.First.Value, nestedWr);
                });
            }
            else if (root.Children.Count == 0 && root.Values.Count == 1)
            {
                wr.Add(root.Name, root.Values[0]);
            }
            else
            {
                // Adding a collection is typically used to add a homogeneous collection of objects.
                // In this case, the values of the node and the children of the node both need to be added within the same nested collection.
                // To get around this without adding two collections associated with the same node, use just the current root node as the collection and
                // manually add the node's values and node's children.
                wr.AddCollection <JsonNode, IEnumerable <JsonNode> >(root.Name, new JsonNode[] { root }, (collectionWriter, n) =>
                {
                    foreach (var value in n.Values)
                    {
                        collectionWriter.Add(value);
                    }

                    for (var it = n.Children.First; it != null; it = it.Next)
                    {
                        BuildStringHelper(it.Value, collectionWriter);
                    }
                });
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public void WriteFingerprintInputs(IFingerprinter writer)
        {
            using (var stream = new MemoryStream())
            {
                using (var buildXLWriter = new BuildXLWriter(
                           debug: false,
                           stream: stream,
                           leaveOpen: false,
                           logStats: false))
                {
                    UnsafeOptions.Serialize(buildXLWriter);
                    writer.Add("SerializedUnsafeOptions", System.BitConverter.ToString(stream.ToArray()));
                }
            }

            var thisRef = this;

            writer.AddNested(ObservedPathEntryConstants.PathSet, w =>
            {
                foreach (var p in thisRef.PathEntries)
                {
                    w.Add(ObservedPathEntryConstants.Path, p.Path);
                    if (p.Flags != ObservedPathEntryFlags.None)
                    {
                        w.Add(ObservedPathEntryConstants.Flags, p.Flags.ToString());
                    }
                    if (p.EnumeratePatternRegex != null)
                    {
                        w.Add(ObservedPathEntryConstants.EnumeratePatternRegex, p.EnumeratePatternRegex);
                    }
                }
            });

            writer.AddCollection <StringId, ReadOnlyArray <StringId> >(
                "ObservedAccessedFileNames",
                ObservedAccessedFileNames,
                (w, v) => w.Add(v));

            // Observed inputs are included directly into the strong fingerprint hash computation,
            // so they do not need to be serialized here
        }