From adb8c39cefdf00024745d487847eced656a85566 Mon Sep 17 00:00:00 2001 From: Ignacio Inglese Date: Thu, 20 Jun 2024 17:21:54 +0100 Subject: [PATCH] Use pattern matching to cast exception --- .../Validation/AudienceValidationResult.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.IdentityModel.Tokens/Validation/AudienceValidationResult.cs b/src/Microsoft.IdentityModel.Tokens/Validation/AudienceValidationResult.cs index bb1573c1ab..024cca68ba 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validation/AudienceValidationResult.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validation/AudienceValidationResult.cs @@ -48,8 +48,7 @@ public override Exception Exception HasValidOrExceptionWasRead = true; _exception = ExceptionDetail.GetException(); - SecurityTokenInvalidAudienceException securityTokenInvalidAudienceException = _exception as SecurityTokenInvalidAudienceException; - if (securityTokenInvalidAudienceException != null) + if (_exception is SecurityTokenInvalidAudienceException securityTokenInvalidAudienceException) { securityTokenInvalidAudienceException.InvalidAudience = Audience; securityTokenInvalidAudienceException.ExceptionDetail = ExceptionDetail;