diff --git a/analyzers/src/SonarAnalyzer.CFG/ShimLayer/TypeDeclarationExtensions.cs b/analyzers/src/SonarAnalyzer.CFG/ShimLayer/TypeDeclarationExtensions.cs index 32634097b87..103f71dcce1 100644 --- a/analyzers/src/SonarAnalyzer.CFG/ShimLayer/TypeDeclarationExtensions.cs +++ b/analyzers/src/SonarAnalyzer.CFG/ShimLayer/TypeDeclarationExtensions.cs @@ -17,10 +17,8 @@ static TypeDeclarationExtensions() // In earlier versions, the ParameterList was only available on the derived RecordDeclarationSyntax (starting from version 3.7) // To work with version 3.7 to version 4.6 we need to special case the record declaration and access // the parameter list from the derived RecordDeclarationSyntax. - if (SyntaxWrapperHelper.GetWrappedType(typeof(RecordDeclarationSyntaxWrapper)) is { } recordDeclaration) - { - RecordDeclarationParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(recordDeclaration, nameof(ParameterList)); - } + var recordDeclaration = SyntaxWrapperHelper.GetWrappedType(typeof(RecordDeclarationSyntaxWrapper)); + RecordDeclarationParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(recordDeclaration, nameof(ParameterList)); } public static ParameterListSyntax ParameterList(this TypeDeclarationSyntax syntax) =>