public static FileHash CalculateFileHash(this ICakeContext context, FilePath filePath, HashAlgorithm hashAlgorithm)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var fileHashCalculator = new FileHashCalculator(context.FileSystem, new HashAlgorithmBuilder());

            return(fileHashCalculator.Calculate(filePath, hashAlgorithm));
        }
        private FileHash CalculateFileContentAndNameHash(
            FilePath filePath,
            DirectoryPath directoryPath,
            HashAlgorithm hashAlgorithm)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            if (directoryPath == null)
            {
                throw new ArgumentNullException(nameof(directoryPath));
            }

            using (var incrementalFileHash = _hashAlgorithmBuilder.CreateHashAlgorithm(hashAlgorithm))
            {
                // Calculate file content hash
                var fileContentHash = _fileHashCalculator.Calculate(filePath, hashAlgorithm);

                // Combine file content hash
                incrementalFileHash.TransformBlock(
                    fileContentHash.ComputedHash, 0,
                    fileContentHash.ComputedHash.Length,
                    fileContentHash.ComputedHash, 0);

                // combine filename hash
                var relativeFilePath  = filePath.GetRelativePath(directoryPath);
                var fileFullNameArray = Encoding.ASCII.GetBytes(filePath.GetFilename().FullPath);
                using (var hashAlgorithmInstance = _hashAlgorithmBuilder.CreateHashAlgorithm(hashAlgorithm))
                {
                    var filenameHash = hashAlgorithmInstance.ComputeHash(fileFullNameArray);
                    incrementalFileHash.TransformFinalBlock(
                        filenameHash, 0,
                        filenameHash.Length);
                }
                var fileContentAndNameHash = incrementalFileHash.Hash;

                return(new FileHash(filePath, fileContentAndNameHash, hashAlgorithm));
            }
        }