From 09c0cf7dd3d8e096cb2af47ed4b01d5747abd6e7 Mon Sep 17 00:00:00 2001 From: Manigandan Jegannathan Date: Mon, 8 Jun 2020 19:27:50 +0400 Subject: [PATCH] Remove unnecessary casting --- Rules/ReviewUnusedParameter.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Rules/ReviewUnusedParameter.cs b/Rules/ReviewUnusedParameter.cs index 2f3a842db..a1336aed7 100644 --- a/Rules/ReviewUnusedParameter.cs +++ b/Rules/ReviewUnusedParameter.cs @@ -90,20 +90,16 @@ private static bool IsBoundParametersReference(Ast ast) && memberAst.Member is StringConstantExpressionAst memberStringAst && memberStringAst.Value.Equals("BoundParameters", StringComparison.OrdinalIgnoreCase)) { - MemberExpressionAst meAst = (MemberExpressionAst)ast; - // $MyInvocation.BoundParameters - if (meAst.Expression is VariableExpressionAst veAst + if (memberAst.Expression is VariableExpressionAst veAst && veAst.VariablePath.UserPath.Equals("MyInvocation", StringComparison.OrdinalIgnoreCase)) { return true; } // $PSCmdlet.MyInvocation.BoundParameters - if (meAst.Expression is MemberExpressionAst) + if (memberAst.Expression is MemberExpressionAst meAstNested) { - MemberExpressionAst meAstNested = (MemberExpressionAst)meAst.Expression; - if (meAstNested.Expression is VariableExpressionAst veAstNested && veAstNested.VariablePath.UserPath.Equals("PSCmdlet", StringComparison.OrdinalIgnoreCase) && meAstNested.Member is StringConstantExpressionAst sceAstNested