8000 Annotating ThrowTerminatingError with [DoesNotReturn] by powercode · Pull Request #15352 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Annotating ThrowTerminatingError with [DoesNotReturn] #15352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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 @@ -672,6 +672,7 @@ internal virtual CmdletOperationBase CmdletOperation
/// Throw terminating error
/// </para>
/// </summary>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
internal void ThrowTerminatingError(Exception exception, string operation)
{
ErrorRecord errorRecord = new(exception, operation, ErrorCategory.InvalidOperation, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public virtual bool ShouldProcess(string verboseDescription, string verboseWarni
return cmdlet.ShouldProcess(verboseDescription, verboseWarning, caption, out shouldProcessReason);
}

[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public virtual void ThrowTerminatingError(ErrorRecord errorRecord)
{
cmdlet.ThrowTerminatingError(errorRecord);
< 10000 tool-tip id="tooltip-77212fd5-be0c-47d6-9c53-fb69a40f28c6" for="expand-down-link-8-diff-501029fe00217ac21e55d01095bc378ae6b7e049e6b52f3efbda4808a1f3677e" popover="manual" data-direction="ne" data-type="label" data-view-component="true" class="sr-only position-absolute">Expand Down Expand Up @@ -115,6 +116,7 @@ public virtual void WriteWarning(string text)
/// Throw terminating error
/// </para>
/// </summary>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
internal void ThrowTerminatingError(Exception exception, string operation)
{
ErrorRecord errorRecord = new(exception, operation, ErrorCategory.InvalidOperation, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal TerminatingErrorContext(PSCmdlet command)
_command = command;
}

[System.Diagnostics.CodeAnalysis.DoesNotReturn]
internal void ThrowTerminatingError(ErrorRecord errorRecord)
{
_command.ThrowTerminatingError(errorRecord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public PSTransactionContext CurrentPSTransaction
/// if it exists, otherwise throw an invalid operation exception.
/// </summary>
/// <param name="errorRecord">The error record to throw.</param>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public void ThrowTerminatingError(ErrorRecord errorRecord)
{
if (errorRecord.Exception != null)
Expand Down
1 change: 1 addition & 0 deletions src/System.Management.Automation/engine/ICommandRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ public interface ICommandRuntime
/// if any information is to be added. It should encapsulate the
/// error record into an exception and then throw that exception.
/// </remarks>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
void ThrowTerminatingError(ErrorRecord errorRecord);
#endregion ThrowTerminatingError
#endregion misc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,7 @@ public PSTransactionContext CurrentPSTransaction
/// <see cref="System.Management.Automation.Cmdlet.ProcessRecord"/>.
/// etc.
/// </remarks>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public void ThrowTerminatingError(ErrorRecord errorRecord)
{
ThrowIfStopping();
Expand Down
1 change: 1 addition & 0 deletions src/System.Management.Automation/engine/cmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,7 @@ public PSTransactionContext CurrentPSTransaction
/// <see cref="System.Management.Automation.Cmdlet.ProcessRecord"/>.
/// etc.
/// </remarks>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public void ThrowTerminatingError(ErrorRecord errorRecord)
{
using (PSTransactionManager.GetEngineProtectionScope())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,7 @@ public virtual string GetResourceString(string baseName, string resourceId)

#region ThrowTerminatingError
/// <Content contentref="System.Management.Automation.Cmdlet.ThrowTerminatingError" />
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public void ThrowTerminatingError(ErrorRecord errorRecord)
{
using (PSTransactionManager.GetEngineProtectionScope())
Expand Down
0