Ejemplo n.º 1
0
        public static ObservedInput Deserialize(BuildXLReader reader)
        {
            ObservedInputType type      = (ObservedInputType)reader.ReadInt32Compact();
            ObservedPathEntry pathEntry = ObservedPathEntry.Deserialize(reader);
            ContentHash?      hash      = HasPredefinedHash(type)
                ? (ContentHash?)null
                : ContentHashingUtilities.CreateFrom(reader); // don't specific explicit hash for predefined hash input types

            return(new ObservedInput(type, hash, pathEntry));
        }
Ejemplo n.º 2
0
        internal ObservedInput(
            ObservedInputType type,
            ContentHash?hash,
            ObservedPathEntry pathEntry)
        {
            Contract.Requires(hash.HasValue || HasPredefinedHash(type));
            Contract.Requires(hash == null || hash.Value.HashType != HashType.Unknown);

            Type      = type;
            Hash      = hash ?? GetPredefinedHash(type);
            PathEntry = pathEntry;
        }
Ejemplo n.º 3
0
        public static bool HasPredefinedHash(ObservedInputType type)
        {
            switch (type)
            {
            case ObservedInputType.AbsentPathProbe:
            case ObservedInputType.ExistingDirectoryProbe:
            case ObservedInputType.ExistingFileProbe:
                return(true);

            case ObservedInputType.FileContentRead:
            case ObservedInputType.DirectoryEnumeration:
                return(false);

            default:
                throw Contract.AssertFailure("Unknown ObservedInputType");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the predefined hash for the observed input type. This should only be called if
        /// <see cref="HasPredefinedHash(ObservedInputType)"/> returns true.
        /// </summary>
        public static ContentHash GetPredefinedHash(ObservedInputType type)
        {
            Contract.Requires(HasPredefinedHash(type), "ObservedInput type does not have predefined hash");

            switch (type)
            {
            case ObservedInputType.AbsentPathProbe:
                return(WellKnownContentHashes.AbsentFile);

            case ObservedInputType.ExistingDirectoryProbe:
            case ObservedInputType.ExistingFileProbe:
                return(ContentHashingUtilities.ZeroHash);

            default:
                throw Contract.AssertFailure("Unexpected ObservedInputType");
            }
        }
Ejemplo n.º 5
0
 private ObservedInput(
     ObservedInputType type,
     AbsolutePath path,
     ContentHash?hash             = null,
     bool isSearchPath            = false,
     bool isDirectoryPath         = false,
     bool directoryEnumeration    = false,
     bool isFileProbe             = false,
     string enumeratePatternRegex = null)
     :
     this(type, hash, new ObservedPathEntry(path,
                                            isSearchPathEnumeration : isSearchPath,
                                            isDirectoryPath : isDirectoryPath,
                                            isDirectoryEnumeration : directoryEnumeration,
                                            enumeratePatternRegex : enumeratePatternRegex,
                                            isFileProbe : isFileProbe))
 {
     Contract.Requires(path.IsValid);
 }