Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ public DuplicateMemberHashSet(int capacity)
}
}

/// <summary>
/// Exception used for cancellation.
/// </summary>
private class StoppingException : System.Exception
{
}

#endregion HelperTypes

#region ConvertFromJson
Expand Down Expand Up @@ -465,7 +458,7 @@ public static string ConvertToJson(object objectToProcess, in ConvertToJsonConte

return JsonConvert.SerializeObject(preprocessedObject, jsonSettings);
}
catch (StoppingException)
catch (OperationCanceledException)
{
return null;
}
Expand All @@ -482,10 +475,7 @@ public static string ConvertToJson(object objectToProcess, in ConvertToJsonConte
/// <returns>An object suitable for serializing to JSON.</returns>
private static object ProcessValue(object obj, int currentDepth, in ConvertToJsonContext context)
{
if (context.CancellationToken.IsCancellationRequested)
{
throw new StoppingException();
}
context.CancellationToken.ThrowIfCancellationRequested();

PSObject pso = obj as PSObject;

Expand Down
1 change: 1 addition & 0 deletions src/System.Management.Automation/engine/serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6714,6 +6714,7 @@ public override object ConvertFrom(PSObject sourceValue, Type destinationType, I
null,
ExtendedTypeSystem.InvalidCastException,
sourceValue,
typeof(PSObject),
destinationType);
}

Expand Down