From 2ffa02e17687369aa143f1716c540fb1fd08378d Mon Sep 17 00:00:00 2001 From: sukreshmanda <34400639+sukreshmanda@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:33:12 +0530 Subject: [PATCH] Fix CA0162 warning (#2250) Fix CA0162 warning about unreachable code. --- test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs b/test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs index 910037550e4..76e4431c8f7 100644 --- a/test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs +++ b/test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs @@ -192,6 +192,8 @@ public class PolicyWrapTResultContextAndKeyAsyncSpecs { #region PolicyKey and execution Context tests + private static void ThrowException() => throw new Exception(); + [Fact] public async Task Should_pass_PolicyKey_to_execution_context_of_outer_policy_as_PolicyWrapKey() { @@ -296,11 +298,8 @@ public async Task Should_restore_PolicyKey_of_outer_policy_to_execution_context_ await policyWrap.ExecuteAsync(async () => await Task.Run(() => // Regression test for issue 510 { - throw new Exception(); -#pragma warning disable 0162 // unreachable code detected + ThrowException(); return ResultPrimitive.WhateverButTooLate; -#pragma warning restore 0162 - })); }