Watfaq / PowerSession

Record a Session in PowerShell
MIT License
152 stars 9 forks source link

Use Convert.ToDouble rather than a cast to get the Timestamp #15

Closed craigminihan closed 3 years ago

craigminihan commented 3 years ago

Post-processing tools (between rec and play/upload) can serialize timestamps as integers which cause PowerSession to throw when casting to double. Rather than forcing decimal places use Convert to mitigate the cast exception.

ibigbug commented 3 years ago

FYI: the failure of casting from Int to Double was due to the number is in an List where object is involved during the casting and the Exception message it throws just doesn't make too much sense.

@craigminihan

craigminihan commented 3 years ago

@ibigbug IMHO Convert should be used unless you explicity know the underlying type, with JSON.NET you can't guarantee the type unless you intervene in the deserialization process

ibigbug commented 3 years ago

It makes sense - considering the casts can be "post-processed" or so. Thanks anyways for contributing.