Skip to content
Merged
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 @@ -16,7 +16,7 @@ namespace Microsoft.PowerShell.Commands
/// This command converts an object to a Json string representation.
/// </summary>
[Cmdlet(VerbsData.ConvertTo, "Json", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=2096925", RemotingCapability = RemotingCapability.None)]
public class ConvertToJsonCommand : PSCmdlet
public class ConvertToJsonCommand : PSCmdlet, IDisposable
{
/// <summary>
/// Gets or sets the InputObject property.
Expand Down Expand Up @@ -77,6 +77,29 @@ public int Depth
[Parameter]
public StringEscapeHandling EscapeHandling { get; set; } = StringEscapeHandling.Default;

/// <summary>
/// IDisposable implementation, dispose of any disposable resources created by the cmdlet.
/// </summary>
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}

/// <summary>
/// Implementation of IDisposable for both manual Dispose() and finalizer-called disposal of resources.
/// </summary>
/// <param name="disposing">
/// Specified as true when Dispose() was called, false if this is called from the finalizer.
/// </param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_cancellationSource.Dispose();
}
}

/// <summary>
/// Prerequisite checks.
/// </summary>
Expand Down