/// <summary> /// Deserializes /// </summary> public static MutableDirectedGraph Deserialize(BuildXLReader reader) { Contract.Requires(reader != null); MutableDirectedGraph graph = new MutableDirectedGraph(); graph.Load(reader); return(graph); }
/// <nodoc /> public static ProcessMemoryCounters Deserialize(BuildXLReader reader) { int peakVirtualMemoryUsageMb = reader.ReadInt32(); int peakWorkingSetMb = reader.ReadInt32(); int peakCommitUsageMb = reader.ReadInt32(); return(new ProcessMemoryCounters(peakVirtualMemoryUsageMb, peakWorkingSetMb, peakCommitUsageMb)); }
/// <nodoc /> public static RootJailInfo Deserialize(BuildXLReader reader) { return(new RootJailInfo( rootJail: reader.ReadString(), userId: reader.ReadNullableStruct(r => r.ReadInt32Compact()), groupId: reader.ReadNullableStruct(r => r.ReadInt32Compact()), disableSandboxing: reader.ReadBoolean())); }
internal static MutablePipState Deserialize(BuildXLReader reader, PipType pipType, long semiStableHash, PageableStoreId storeId) { ServiceInfo serviceInfo = reader.ReadNullable(ServiceInfo.InternalDeserialize); int options = reader.ReadInt32(); int priority = reader.ReadInt32(); return(new ProcessMutablePipState(pipType, semiStableHash, storeId, serviceInfo, (Process.Options)options, priority)); }
private IUnsafeSandboxConfiguration DeserializeFromByteArray(byte[] bytes) { using (var stream = new MemoryStream(bytes)) using (var reader = new BuildXLReader(debug: true, stream: stream, leaveOpen: true)) { return(UnsafeSandboxConfigurationExtensions.Deserialize(reader)); } }
internal static MachineIdSet DeserializeCore(BuildXLReader reader) { var count = reader.ReadInt32Compact(); var data = reader.ReadBytes(count); return(new BitMachineIdSet(data, 0)); }
internal static bool HasMachineIdCore(BuildXLReader reader, int index) { var count = reader.ReadInt32Compact(); var data = reader.ReadBytes(count); return(GetValue(data, 0, index)); }
private static HistoricTableSizes Deserialize(byte[] serializedBytes) { using (var stream = new MemoryStream(serializedBytes)) using (var reader = new BuildXLReader(debug: Debug, stream: stream, leaveOpen: false)) { return(HistoricTableSizes.Deserialize(reader)); } }
public WorkspaceBindingSnapshot TryLoadFrontEndSnapshot(int expectedSpecCount) { try { return(ExceptionUtilities.HandleRecoverableIOException( () => DoLoadFrontEndSnapshot(), e => throw new BuildXLException(string.Empty, e))); } catch (BuildXLException e) { // Recoverable exceptions should not break BuildXL. m_logger.FailToReuseFrontEndSnapshot(m_loggingContext, I($"IO exception occurred: {e.InnerException}")); return(null); } WorkspaceBindingSnapshot DoLoadFrontEndSnapshot() { if (!File.Exists(m_cacheFileName)) { // Can't reuse the snapshot because the file does not exist. m_logger.FailToReuseFrontEndSnapshot(m_loggingContext, I($"File '{m_cacheFileName}' does not exist")); return(null); } var sw = Stopwatch.StartNew(); using (var file = FileUtilities.CreateFileStream(m_cacheFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.Delete)) { var reader = new BuildXLReader(debug: false, stream: file, leaveOpen: true); var version = reader.ReadInt32Compact(); if (version != Version) { // Version mismatch. Can't reuse the file. m_logger.FailToReuseFrontEndSnapshot( m_loggingContext, I($"Cache version '{version}' does not match an expected version '{Version}'")); return(null); } var specCount = reader.ReadInt32Compact(); if (expectedSpecCount != specCount) { // Can't use the cache, because it has different amount of specs in there. m_logger.FailToReuseFrontEndSnapshot( m_loggingContext, I($"Cache contains the data for '{specCount}' specs but current execution requires '{expectedSpecCount}' specs")); return(null); } var specs = FrontEndSnapshotSerializer.DeserializeSpecStates(reader, m_pathTable, specCount); m_frontEndStatistics.FrontEndSnapshotLoadingDuration = sw.Elapsed; m_logger.LoadFrontEndSnapshot(m_loggingContext, specs.Length, (int)sw.ElapsedMilliseconds); return(new WorkspaceBindingSnapshot(specs, m_pathTable)); } } }
/// <summary> /// Deserializes an instance of <see cref="SandboxedProcessResult"/>. /// </summary> public static SandboxedProcessResult Deserialize(BuildXLReader reader, Func <BuildXLReader, AbsolutePath> readPath = null) { int exitCode = reader.ReadInt32(); bool killed = reader.ReadBoolean(); bool timedOut = reader.ReadBoolean(); bool hasDetoursInjectionFailures = reader.ReadBoolean(); IReadOnlyList <ReportedProcess> allReportedProcesses = reader.ReadReadOnlyList(r => ReportedProcess.Deserialize(r)); IReadOnlyList <ReportedProcess> survivingChildProcesses = reader.ReadNullable(r => r.ReadReadOnlyList(r2 => allReportedProcesses[r2.ReadInt32()])); ProcessTimes primaryProcessTimes = reader.ReadNullable(r => ProcessTimes.Deserialize(r)); JobObject.AccountingInformation? jobAccountingInformation = reader.ReadNullableStruct(r => JobObject.AccountingInformation.Deserialize(r)); SandboxedProcessOutput standardOutput = reader.ReadNullable(r => SandboxedProcessOutput.Deserialize(r)); SandboxedProcessOutput standardError = reader.ReadNullable(r => SandboxedProcessOutput.Deserialize(r)); IReadOnlyList <ReportedFileAccess> fileAccesses = reader.ReadNullable(r => r.ReadReadOnlyList(r2 => ReportedFileAccess.Deserialize(r2, allReportedProcesses, readPath: readPath))); IReadOnlyList <ReportedFileAccess> explicitlyReportedFileAccesses = reader.ReadNullable(r => r.ReadReadOnlyList(r2 => ReportedFileAccess.Deserialize(r2, allReportedProcesses, readPath: readPath))); IReadOnlyList <ReportedFileAccess> allUnexpectedFileAccesses = reader.ReadNullable(r => r.ReadReadOnlyList(r2 => ReportedFileAccess.Deserialize(r2, allReportedProcesses, readPath: readPath))); IReadOnlyList <ReportedProcess> processes = reader.ReadNullable(r => r.ReadReadOnlyList(r2 => allReportedProcesses[r2.ReadInt32()])); IReadOnlyList <ProcessDetouringStatusData> detouringStatuses = reader.ReadNullable(r => r.ReadReadOnlyList(r2 => ProcessDetouringStatusData.Deserialize(r2))); string dumpFileDirectory = reader.ReadNullableString(); string dumpCreationExceptionMessage = reader.ReadNullableString(); string standardInputExceptionMessage = reader.ReadNullableString(); bool hasReadWriteToReadFileAccessRequest = reader.ReadBoolean(); string messageProcessingFailureMessage = reader.ReadNullableString(); long processStartTime = reader.ReadInt64(); int warningCount = reader.ReadInt32(); long detoursMaxHeapSize = reader.ReadInt64(); int lastMessageCount = reader.ReadInt32(); bool messageCountSemaphoreCreated = reader.ReadBoolean(); return(new SandboxedProcessResult() { ExitCode = exitCode, Killed = killed, TimedOut = timedOut, HasDetoursInjectionFailures = hasDetoursInjectionFailures, SurvivingChildProcesses = survivingChildProcesses, PrimaryProcessTimes = primaryProcessTimes, JobAccountingInformation = jobAccountingInformation, StandardOutput = standardOutput, StandardError = standardError, FileAccesses = fileAccesses != null ? new HashSet <ReportedFileAccess>(fileAccesses) : null, ExplicitlyReportedFileAccesses = explicitlyReportedFileAccesses != null ? new HashSet <ReportedFileAccess>(explicitlyReportedFileAccesses) : null, AllUnexpectedFileAccesses = allUnexpectedFileAccesses != null ? new HashSet <ReportedFileAccess>(allUnexpectedFileAccesses) : null, Processes = processes, DetouringStatuses = detouringStatuses, DumpFileDirectory = dumpFileDirectory, DumpCreationException = dumpCreationExceptionMessage != null ? new Exception(dumpCreationExceptionMessage) : null, StandardInputException = standardInputExceptionMessage != null ? new Exception(standardInputExceptionMessage) : null, HasReadWriteToReadFileAccessRequest = hasReadWriteToReadFileAccessRequest, MessageProcessingFailure = messageProcessingFailureMessage != null ? new Failure <string>(messageProcessingFailureMessage) : null, ProcessStartTime = processStartTime, WarningCount = warningCount, DetoursMaxHeapSize = detoursMaxHeapSize, LastMessageCount = lastMessageCount, MessageCountSemaphoreCreated = messageCountSemaphoreCreated }); }
/// <summary> /// Initializes a new instance of the <see cref="ContentHashList" /> class from its binary representation. /// </summary> public static ContentHashList Deserialize(BuildXLReader reader) { Contract.Requires(reader != null); var contentHashes = reader.ReadArray(r => new ContentHash(r)); var payload = ReadNullableArray(reader); return(new ContentHashList(contentHashes, payload)); }
/// <summary> /// Initializes a new instance of the <see cref="Selector" /> struct. /// </summary> public static Selector Deserialize(BuildXLReader reader) { Contract.Requires(reader != null); var contentHash = new ContentHash(reader); var output = ContentHashList.ReadNullableArray(reader); return(new Selector(contentHash, output)); }
/// <summary> /// Deserializes an instance of <see cref="SandboxedProcessStandardFiles"/>. /// </summary> public static SandboxedProcessStandardFiles Deserialize(BuildXLReader reader) { Contract.Requires(reader != null); string output = reader.ReadString(); string error = reader.ReadString(); return(new SandboxedProcessStandardFiles(output, error)); }
/// <summary> /// Initializes a new instance of the <see cref="StrongFingerprint" /> struct from its binary /// representation. /// </summary> public static StrongFingerprint Deserialize(BuildXLReader reader) { Contract.Requires(reader != null); var weakFingerprint = Fingerprint.Deserialize(reader); var selector = Selector.Deserialize(reader); return(new StrongFingerprint(weakFingerprint, selector)); }
/// <nodoc /> public SidebandReader(string sidebandFile) { Contract.Requires(File.Exists(sidebandFile)); m_bxlReader = new BuildXLReader( stream: new FileStream(sidebandFile, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete), debug: false, leaveOpen: false); }
public static void Read <T>(this BuildXLReader reader, ICollection <T> collection, Func <BuildXLReader, T> readItem) { var count = reader.ReadInt32(); for (int i = 0; i < count; i++) { collection.Add(readItem(reader)); } }
/// <summary> /// Deserializes /// </summary> public static Task <DeserializedDirectedGraph> DeserializeAsync(BuildXLReader reader) { Contract.Requires(reader != null); DeserializedDirectedGraph result = new DeserializedDirectedGraph(); result.Load(reader); return(Task.FromResult(result)); }
/// <summary> /// Deserializes into an instance of <see cref="UnsafeOptions"/>. /// </summary> public static UnsafeOptions Deserialize(BuildXLReader reader) { Contract.Requires(reader != null); var unsafeConfiguration = UnsafeSandboxConfigurationExtensions.Deserialize(reader); var preserveOutputsInfo = reader.ReadNullableStruct(r => new PreserveOutputsInfo(r)); return(new UnsafeOptions(unsafeConfiguration, preserveOutputsInfo)); }
internal static MutablePipState Deserialize(BuildXLReader reader, PipType pipType, long semiStableHash, PageableStoreId storeId) { var sealDirectoryKind = (SealDirectoryKind)reader.ReadByte(); var patterns = reader.ReadReadOnlyArray(reader1 => reader1.ReadStringId()); var isComposite = reader.ReadBoolean(); var scrub = reader.ReadBoolean(); return(new SealDirectoryMutablePipState(pipType, semiStableHash, storeId, sealDirectoryKind, patterns, isComposite, scrub)); }
/// <nodoc /> internal FileModuleLiteral( BuildXLReader reader, PathTable pathTable, GlobalModuleLiteral outerScope, ModuleRegistry moduleRegistry, LineMap lineMap) : this(reader, pathTable, reader.ReadAbsolutePath(), ReadPackage(reader, pathTable), outerScope, moduleRegistry, lineMap) { }
/// <nodoc /> public static ProcessMemoryCounters Deserialize(BuildXLReader reader) { int peakWorkingSetMb = reader.ReadInt32(); int averageWorkingSetMb = reader.ReadInt32(); int peakCommitSizeMb = reader.ReadInt32(); int averageCommitSizeMb = reader.ReadInt32(); return(new ProcessMemoryCounters(peakWorkingSetMb, averageWorkingSetMb, peakCommitSizeMb, averageCommitSizeMb)); }
private static string ReadNullableString(BuildXLReader reader) { if (!reader.ReadBoolean()) { return(null); } return(reader.ReadString()); }
/// <nodoc /> public static Qualifier Deserialize(BuildXLReader reader) { Contract.RequiresNotNull(reader); var keys = reader.ReadArray(r => r.ReadStringId()); var values = reader.ReadArray(r => r.ReadStringId()); return(new Qualifier(keys, values)); }
public static SpecBindingSymbols DeserializeBindingFingerprint([NotNull] BuildXLReader reader) { var declaredSymbols = ReadBindingSymbols(reader); var referencedSymbols = ReadBindingSymbols(reader); var declaredSymbolsFingerprint = reader.ReadString(); var referencedSymbolsFingerprint = reader.ReadString(); return(new SpecBindingSymbols(declaredSymbols.ToReadOnlySet(), referencedSymbols.ToReadOnlySet(), declaredSymbolsFingerprint, referencedSymbolsFingerprint)); }
public static Command Deserialize(BuildXLReader reader) { CommandType commandType = (CommandType)reader.ReadByte(); var key = reader.ReadNullableByteArray(); Command?command = null; switch (commandType) { case CommandType.Get: command = new GetCommand(); break; case CommandType.Set: command = new SetCommand() { Value = reader.ReadNullableByteArray(), ExpiryTimeUtc = reader.ReadNullableStruct(r => r.ReadDateTime()), Overwrite = reader.ReadBoolean(), }; break; case CommandType.CompareExchange: command = new CompareExchangeCommand() { Value = reader.ReadNullableByteArray(), CompareKey = reader.ReadNullableByteArray(), CompareKeyValue = reader.ReadNullableByteArray(), Comparand = reader.ReadNullableByteArray(), ExpiryTimeUtc = reader.ReadNullableStruct(r => r.ReadDateTime()), }; break; case CommandType.CompareRemove: command = new CompareRemoveCommand() { Comparand = reader.ReadNullableByteArray(), }; break; case CommandType.Remove: command = new RemoveCommand(); break; case CommandType.PrefixEnumerate: command = new PrefixEnumerateCommand(); break; } Contract.Assert(command != null); command.Key = key; return(command); }
public static CommandResult Deserialize(BuildXLReader reader) { CommandType commandType = (CommandType)reader.ReadByte(); CommandResult?result = null; switch (commandType) { case CommandType.Get: result = new GetResult() { Value = reader.ReadNullableByteArray(), }; break; case CommandType.Set: result = new SetResult() { Set = reader.ReadBoolean(), }; break; case CommandType.CompareExchange: result = new CompareExchangeResult() { Previous = reader.ReadNullableByteArray(), Exchanged = reader.ReadBoolean(), }; break; case CommandType.CompareRemove: result = new CompareRemoveResult() { Value = reader.ReadNullableByteArray(), }; break; case CommandType.Remove: result = new RemoveResult(); break; case CommandType.PrefixEnumerate: result = new PrefixEnumerateResult(reader.ReadReadOnlyList(r => { var key = r.ReadNullableByteArray(); var value = r.ReadNullableByteArray(); return(new KeyValuePair <ByteString, ByteString>(key, value)); })); break; } Contract.AssertNotNull(result); return(result); }
public async Task Serialization() { var st = new StringTable(); var pt = new PathTable(st); string path1 = A("c", "a", "b", "c"); var ap1 = AbsolutePath.Create(pt, path1); string path2 = A("c", "d", "c", "a"); var ap2 = AbsolutePath.Create(pt, path2); string path3 = A("d", "a", "c", "a"); var ap3 = AbsolutePath.Create(pt, path3); string path3Caps = A("D", "A", "c", "a"); var ap3Caps = AbsolutePath.Create(pt, path3Caps); PathTable pt2; using (MemoryStream ms = new MemoryStream()) { using (BuildXLWriter writer = new BuildXLWriter(true, ms, true, logStats: true)) { pt.Serialize(writer); } ms.Position = 0; using (BuildXLReader reader = new BuildXLReader(true, ms, true)) { pt2 = await PathTable.DeserializeAsync(reader, Task.FromResult(st)); } } // Retrieve AbsolutePaths created with the original table from the deserialized one XAssert.AreEqual(path1, ap1.ToString(pt)); XAssert.AreEqual(path1, ap1.ToString(pt2)); XAssert.AreEqual(path2, ap2.ToString(pt2)); XAssert.AreEqual(path3, ap3.ToString(pt2)); // Recreate the paths and make sure they match the originals var ap1Recreated = AbsolutePath.Create(pt2, path1); var ap2Recreated = AbsolutePath.Create(pt2, path2); var ap3Recreated = AbsolutePath.Create(pt2, path3); var ap3CapsRecreated = AbsolutePath.Create(pt2, path3Caps); XAssert.AreEqual(ap1, ap1Recreated); XAssert.AreEqual(ap2, ap2Recreated); XAssert.AreEqual(ap3, ap3Recreated); XAssert.AreEqual(ap3, ap3CapsRecreated); // Make sure a new path can be added string path4 = A("c", "a", "s", "d"); var ap4 = AbsolutePath.Create(pt2, path4); XAssert.AreEqual(path4, ap4.ToString(pt2)); }
/// <summary> /// Builds an instance from a binary stream. /// </summary> public static ContentLocationEntry Deserialize(BuildXLReader reader) { var size = reader.ReadInt64Compact(); var locations = MachineIdSet.Deserialize(reader); var creationTimeUtc = reader.ReadUnixTime(); var lastAccessTimeOffset = reader.ReadInt64Compact(); var lastAccessTime = new UnixTime(creationTimeUtc.Value + lastAccessTimeOffset); return(Create(locations, size, lastAccessTime, creationTimeUtc)); }
/// <nodoc /> public UninstantiatedModuleInfo ReadModuleInfo(ModuleRegistry registry, BuildXLReader reader) { var module = FileModuleLiteral.Read(reader, m_pathTable, m_globalModule, registry); var qualifierSpaceId = reader.ReadQualifierSpaceId(); var uninstantiatedModule = new UninstantiatedModuleInfo(null, module, qualifierSpaceId); return(uninstantiatedModule); }
/// <summary> /// Deserializes an instance of <see cref="DirtyNodeTrackerSerializedState"/> using an instance of <see cref="BuildXLReader"/>. /// </summary> /// <param name="reader"></param> public static DirtyNodeTrackerSerializedState Deserialize(BuildXLReader reader) { Contract.Requires(reader != null); RangedNodeSet dirtyNodes = RangedNodeSet.Deserialize(reader); RangedNodeSet materializedNodes = RangedNodeSet.Deserialize(reader); RangedNodeSet perpetualDirtyNodes = RangedNodeSet.Deserialize(reader); return(new DirtyNodeTrackerSerializedState(dirtyNodes, materializedNodes, perpetualDirtyNodes)); }