Skip to content

Commit

Permalink
Merge pull request #1 from AndyGerlicher/fixevaluation
Browse files Browse the repository at this point in the history
Fix serialization on Core
  • Loading branch information
smera authored Dec 7, 2017
2 parents ffb51d8 + 3e616fc commit 7159d5a
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/Shared/NodePacketTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ public void Translate(INodePacketTranslator translator)
var val = (ProfilerResult?)FieldValue;
if (translator.TranslateNullable(val))
{
var profilerResult = val.Value;
var profilerResult = val ?? default(ProfilerResult);
ProfilerResultTranslator.Translate(translator, ref profilerResult);
val = profilerResult;
}
Expand Down Expand Up @@ -1488,22 +1488,19 @@ public static class ProfilerResultTranslator
{
public static void Translate(INodePacketTranslator translator, ref ProfilerResult profilerResult)
{
if (translator.TranslateNullable(profilerResult))
IDictionary<EvaluationLocation, ProfiledLocation> profiledLocations = new Dictionary<EvaluationLocation, ProfiledLocation>();
if (translator.Mode == TranslationDirection.WriteToStream)
{
IDictionary<EvaluationLocation, ProfiledLocation> profiledLocations = new Dictionary<EvaluationLocation, ProfiledLocation>();
if (translator.Mode == TranslationDirection.WriteToStream)
{
profiledLocations = profilerResult.ProfiledLocations.ToDictionary(kv => kv.Key, kv => kv.Value);
}
profiledLocations = profilerResult.ProfiledLocations.ToDictionary(kv => kv.Key, kv => kv.Value);
}

translator.TranslateDictionary(ref profiledLocations,
TranslatorForEvaluationLocation, TranslatorForProfiledLocation,
count => new Dictionary<EvaluationLocation, ProfiledLocation>());
translator.TranslateDictionary(ref profiledLocations,
TranslatorForEvaluationLocation, TranslatorForProfiledLocation,
count => new Dictionary<EvaluationLocation, ProfiledLocation>());

if (translator.Mode == TranslationDirection.ReadFromStream)
{
profilerResult = new ProfilerResult(new ReadOnlyDictionary<EvaluationLocation, ProfiledLocation>(profiledLocations));
}
if (translator.Mode == TranslationDirection.ReadFromStream)
{
profilerResult = new ProfilerResult(new ReadOnlyDictionary<EvaluationLocation, ProfiledLocation>(profiledLocations));
}
}

Expand Down

0 comments on commit 7159d5a

Please sign in to comment.