private async Task <CasHash> AddPathSet(ICacheSession session, params string[] thePaths) { var pathTable = new PathTable(); ObservedPathEntry[] paths = new ObservedPathEntry[thePaths.Length]; for (int i = 0; i < thePaths.Length; i++) { AbsolutePath absPath = AbsolutePath.Create(pathTable, thePaths[i]); paths[i] = new ObservedPathEntry(absPath, false, false, false, null, false); } var emptyObservedAccessFileNames = SortedReadOnlyArray <StringId, CaseInsensitiveStringIdComparer> .FromSortedArrayUnsafe( ReadOnlyArray <StringId> .Empty, new CaseInsensitiveStringIdComparer(pathTable.StringTable)); ObservedPathSet pathSet = new ObservedPathSet( SortedReadOnlyArray <ObservedPathEntry, ObservedPathEntryExpandedPathComparer> .FromSortedArrayUnsafe( ReadOnlyArray <ObservedPathEntry> .FromWithoutCopy(paths), new ObservedPathEntryExpandedPathComparer(pathTable.ExpandedPathComparer)), emptyObservedAccessFileNames, null); using (var pathSetBuffer = new MemoryStream()) { using (var writer = new BuildXLWriter(stream: pathSetBuffer, debug: false, leaveOpen: true, logStats: false)) { pathSet.Serialize(pathTable, writer, preserveCasing: false); } pathSetBuffer.Seek(0, SeekOrigin.Begin); // Must await such that the dispose of the MemoryStream is only after the write completes return(await session.AddToCasAsync(pathSetBuffer).SuccessAsync()); } }
/// <nodoc /> public static Xldb.ObservedPathEntry ToObservedPathEntry(this ObservedPathEntry pathEntry, PathTable pathTable) { return(new Xldb.ObservedPathEntry() { Path = pathEntry.Path.ToAbsolutePath(pathTable), EnumeratePatternRegex = pathEntry.EnumeratePatternRegex ?? "" }); }
private ObservedPathEntry Convert(ObservedPathEntry observedInput) { if (AreGraphsSame) { return(observedInput); } return(new ObservedPathEntry( Convert(observedInput.Path), observedInput.Flags, observedInput.EnumeratePatternRegex)); }