/// <summary> /// Renders valid scalar pip data entries, i.e., those that do not correspond to <see cref="PipFragmentType.NestedFragment"/>. /// </summary> /// <remarks> /// If a <see cref="HashLookup"/> function is not provided, entries corresponding to <see cref="PipFragmentType.VsoHash"/> /// are rendered as a sequence of zeros (<see cref="s_unknownLengthFileInfoString"/>); otherwise, they are rendered as /// the return value of the <see cref="FileContentInfo.Render"/> method. /// </remarks> public string Render(PipFragment fragment) { Contract.Requires(fragment.FragmentType != PipFragmentType.Invalid); Contract.Requires(fragment.FragmentType != PipFragmentType.NestedFragment); switch (fragment.FragmentType) { case PipFragmentType.StringLiteral: return(Render(fragment.GetStringIdValue())); case PipFragmentType.AbsolutePath: return(PathExpander(fragment.GetPathValue())); case PipFragmentType.VsoHash: return(HashLookup != null ? HashLookup(fragment.GetFileValue()).Render() : s_unknownLengthFileInfoString); case PipFragmentType.FileId: { var file = fragment.GetFileValue(); return(file.Path.RawValue.ToString() + ":" + file.RewriteCount.ToString()); } case PipFragmentType.DirectoryId: var directory = fragment.GetDirectoryValue(); return(DirectoryId.ToString(directory)); case PipFragmentType.IpcMoniker: string monikerId = fragment.GetIpcMonikerValue().ToString(StringTable); var result = IpcMonikerRenderer != null ? IpcMonikerRenderer(monikerId) : monikerId; if (result.Length > MaxIpcMonikerLength) { throw new BuildXLException(I($"Moniker with id '{monikerId}' was rendered to string '{result}' which is longer than the max length for moniker fragments ({MaxIpcMonikerLength})")); } return(result); default: Contract.Assert(false, "Can't render fragment type " + fragment.FragmentType); return(null); } }
/// <summary> /// Renders valid scalar pip data entries, i.e., those that do not correspond to <see cref="PipFragmentType.NestedFragment"/>. /// </summary> public string Render(PipFragment fragment) { Contract.Requires(fragment.FragmentType != PipFragmentType.Invalid); Contract.Requires(fragment.FragmentType != PipFragmentType.NestedFragment); switch (fragment.FragmentType) { case PipFragmentType.StringLiteral: return(Render(fragment.GetStringIdValue())); case PipFragmentType.AbsolutePath: return(PathExpander(fragment.GetPathValue())); default: Contract.Assert(false, "Can't render fragment type " + fragment.FragmentType); return(null); } }