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
23 changes: 12 additions & 11 deletions src/System.Management.Automation/engine/ICommandRuntime.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#nullable enable

using System.Management.Automation.Host;

namespace System.Management.Automation
Expand All @@ -26,7 +28,7 @@ public interface ICommandRuntime
/// <summary>
/// Returns an instance of the PSHost implementation for this environment.
/// </summary>
PSHost Host { get; }
PSHost? Host { get; }
#region Write
/// <summary>
/// Display debug information.
Expand Down Expand Up @@ -65,7 +67,7 @@ public interface ICommandRuntime
/// When the cmdlet wants to write a single object out, it will call this
/// API. It is up to the implementation to decide what to do with these objects.
/// </remarks>
void WriteObject(object sendToPipeline);
void WriteObject(object? sendToPipeline);

/// <summary>
/// Called to write one or more objects to the output pipe.
Expand All @@ -83,7 +85,7 @@ public interface ICommandRuntime
/// When the cmdlet wants to write multiple objects out, it will call this
/// API. It is up to the implementation to decide what to do with these objects.
/// </remarks>
void WriteObject(object sendToPipeline, bool enumerateCollection);
void WriteObject(object? sendToPipeline, bool enumerateCollection);

/// <summary>
/// Called by the cmdlet to display progress information.
Expand Down Expand Up @@ -219,7 +221,7 @@ public interface ICommandRuntime
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string,string,string, out ShouldProcessReason)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldContinue(string,string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldContinue(string,string,ref bool,ref bool)"/>
bool ShouldProcess(string target);
bool ShouldProcess(string? target);

/// <summary>
/// Called by a cmdlet to confirm the operation with the user. Cmdlets which make changes
Expand Down Expand Up @@ -265,7 +267,7 @@ public interface ICommandRuntime
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string,string,string, out ShouldProcessReason)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldContinue(string,string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldContinue(string,string,ref bool,ref bool)"/>
bool ShouldProcess(string target, string action);
bool ShouldProcess(string? target, string? action);

/// <summary>
/// Called by a cmdlet to confirm the operation with the user. Cmdlets which make changes
Expand Down Expand Up @@ -319,7 +321,7 @@ public interface ICommandRuntime
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string,string,string, out ShouldProcessReason)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldContinue(string,string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldContinue(string,string,ref bool,ref bool)"/>
bool ShouldProcess(string verboseDescription, string verboseWarning, string caption);
bool ShouldProcess(string? verboseDescription, string? verboseWarning, string? caption);

/// <summary>
/// Called by a cmdlet to confirm the operation with the user. Cmdlets which make changes
Expand Down Expand Up @@ -379,7 +381,7 @@ public interface ICommandRuntime
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string,string,string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldContinue(string,string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldContinue(string,string,ref bool,ref bool)"/>
bool ShouldProcess(string verboseDescription, string verboseWarning, string caption, out ShouldProcessReason shouldProcessReason);
bool ShouldProcess(string? verboseDescription, string? verboseWarning, string? caption, out ShouldProcessReason shouldProcessReason);

/// <summary>
/// Called by a cmdlet to confirm an operation or grouping of operations with the user.
Expand Down Expand Up @@ -436,7 +438,7 @@ public interface ICommandRuntime
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string,string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string,string,string)"/>
bool ShouldContinue(string query, string caption);
bool ShouldContinue(string? query, string? caption);

/// <summary>
/// Called to confirm an operation or grouping of operations with the user.
Expand Down Expand Up @@ -501,7 +503,7 @@ public interface ICommandRuntime
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string,string)"/>
/// <seealso cref="System.Management.Automation.ICommandRuntime.ShouldProcess(string,string,string)"/>
bool ShouldContinue(string query, string caption, ref bool yesToAll, ref bool noToAll);
bool ShouldContinue(string? query, string? caption, ref bool yesToAll, ref bool noToAll);

#endregion Should

Expand All @@ -515,7 +517,7 @@ public interface ICommandRuntime
/// Gets an object that surfaces the current PowerShell transaction.
/// When this object is disposed, PowerShell resets the active transaction.
/// </summary>
PSTransactionContext CurrentPSTransaction { get; }
PSTransactionContext? CurrentPSTransaction { get; }
#endregion Transaction Support

#region Misc
Expand Down Expand Up @@ -561,7 +563,6 @@ public interface ICommandRuntime
/// execute an instance of a Cmdlet. ICommandRuntime2 extends the ICommandRuntime interface
/// by adding support for the informational data stream.
/// </summary>
#nullable enable
public interface ICommandRuntime2 : ICommandRuntime
{
/// <summary>
Expand Down