From a4d5f533a3934658d252f5699c855463b0f20d7b Mon Sep 17 00:00:00 2001 From: Arthur van de Vondervoort Date: Fri, 8 Dec 2023 14:02:00 +0100 Subject: [PATCH] Resolve System.InvalidCastException --- Design/Rule0043SecretText.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Design/Rule0043SecretText.cs b/Design/Rule0043SecretText.cs index 52a048be..104235a0 100644 --- a/Design/Rule0043SecretText.cs +++ b/Design/Rule0043SecretText.cs @@ -36,11 +36,7 @@ private void AnalyzeHttpObjects(OperationAnalysisContext ctx) { case MethodKind.BuiltInMethod: if (!buildInMethodNames.Contains(operation.TargetMethod.Name.ToLowerInvariant())) return; - - // We need to verify that the method is called from a HttpHeaders or HttpClient object - if (!ctx.Operation.DescendantsAndSelf().Where(x => x.GetSymbol() != null) - .Where(x => x.Type.GetNavTypeKindSafe() == NavTypeKind.HttpHeaders || x.Type.GetNavTypeKindSafe() == NavTypeKind.HttpClient) - .Any()) return; + if (!(operation.Instance?.GetSymbol().GetTypeSymbol().GetNavTypeKindSafe() == NavTypeKind.HttpHeaders || operation.Instance?.GetSymbol().GetTypeSymbol().GetNavTypeKindSafe() == NavTypeKind.HttpClient)) return; break; case MethodKind.Method: if (operation.TargetMethod.ContainingType.GetNavTypeKindSafe() != NavTypeKind.Codeunit) return;