/// <summary>
 /// Deserializes a pip graph fragment from stream.
 /// </summary>
 public async Task <bool> DeserializeAsync(
     Stream stream,
     Func <PipGraphFragmentContext, PipGraphFragmentProvenance, PipId, Pip, Task <bool> > handleDeserializedPip = null,
     string fragmentDescriptionOverride = null,
     AbsolutePath filePathOrigin        = default)
 {
     using (var reader = new PipRemapReader(m_pipExecutionContext, m_pipGraphFragmentContext, stream))
     {
         try
         {
             string serializedDescription = reader.ReadNullableString();
             FragmentDescription = fragmentDescriptionOverride ?? serializedDescription;
             var  provenance             = new PipGraphFragmentProvenance(filePathOrigin, FragmentDescription);
             bool serializedUsingTopSort = reader.ReadBoolean();
             Func <PipId, Pip, Task <bool> > handleDeserializedPipInFragment = (pipId, pip) => handleDeserializedPip(m_pipGraphFragmentContext, provenance, pipId, pip);
             if (serializedUsingTopSort)
             {
                 return(await DeserializeTopSortAsync(handleDeserializedPipInFragment, reader));
             }
             else
             {
                 return(await DeserializeSeriallyAsync(handleDeserializedPipInFragment, reader));
             }
         }
         finally
         {
             Interlocked.Add(ref Stats.OptimizedSymbols, reader.OptimizedSymbols);
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Deserializes a pip graph fragment from stream.
 /// </summary>
 public bool Deserialize(
     Stream stream,
     Func <PipGraphFragmentContext, PipGraphFragmentProvenance, PipId, Pip, bool> handleDeserializedPip = null,
     string fragmentDescriptionOverride = null,
     AbsolutePath filePathOrigin        = default)
 {
     using (var reader = new PipRemapReader(m_pipExecutionContext, m_pipGraphFragmentContext, stream))
     {
         string serializedDescription = reader.ReadNullableString();
         FragmentDescription = fragmentDescriptionOverride ?? serializedDescription;
         var  provenance             = new PipGraphFragmentProvenance(filePathOrigin, FragmentDescription);
         bool serializedUsingTopSort = reader.ReadBoolean();
         Func <PipId, Pip, bool> handleDeserializedPipInFragment = (pipId, pip) => handleDeserializedPip(m_pipGraphFragmentContext, provenance, pipId, pip);
         if (serializedUsingTopSort)
         {
             return(DeserializeTopSort(handleDeserializedPipInFragment, reader));
         }
         else
         {
             return(DeserializeSerially(handleDeserializedPipInFragment, reader));
         }
     }
 }