Annotate ThrowTerminatingError with DoesNotReturn attribute (#15352)

This commit is contained in:
Staffan Gustafsson 2021-05-06 18:23:34 +02:00 committed by GitHub
parent 97ce36ac7f
commit efdc500ba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 9 additions and 0 deletions

View file

@ -672,6 +672,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Throw terminating error
/// </para>
/// </summary>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
internal void ThrowTerminatingError(Exception exception, string operation)
{
ErrorRecord errorRecord = new(exception, operation, ErrorCategory.InvalidOperation, this);

View file

@ -65,6 +65,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
return cmdlet.ShouldProcess(verboseDescription, verboseWarning, caption, out shouldProcessReason);
}
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public virtual void ThrowTerminatingError(ErrorRecord errorRecord)
{
cmdlet.ThrowTerminatingError(errorRecord);
@ -115,6 +116,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Throw terminating error
/// </para>
/// </summary>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
internal void ThrowTerminatingError(Exception exception, string operation)
{
ErrorRecord errorRecord = new(exception, operation, ErrorCategory.InvalidOperation, this);

View file

@ -22,6 +22,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
_command = command;
}
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
internal void ThrowTerminatingError(ErrorRecord errorRecord)
{
_command.ThrowTerminatingError(errorRecord);

View file

@ -230,6 +230,7 @@ namespace System.Management.Automation
/// 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)

View file

@ -549,6 +549,7 @@ namespace System.Management.Automation
/// 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

View file

@ -2055,6 +2055,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.Cmdlet.ProcessRecord"/>.
/// etc.
/// </remarks>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public void ThrowTerminatingError(ErrorRecord errorRecord)
{
ThrowIfStopping();

View file

@ -1714,6 +1714,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.Cmdlet.ProcessRecord"/>.
/// etc.
/// </remarks>
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public void ThrowTerminatingError(ErrorRecord errorRecord)
{
using (PSTransactionManager.GetEngineProtectionScope())

View file

@ -1417,6 +1417,7 @@ namespace System.Management.Automation.Provider
#region ThrowTerminatingError
/// <Content contentref="System.Management.Automation.Cmdlet.ThrowTerminatingError" />
[System.Diagnostics.CodeAnalysis.DoesNotReturn]
public void ThrowTerminatingError(ErrorRecord errorRecord)
{
using (PSTransactionManager.GetEngineProtectionScope())