From 3cf31e2394758cb1c97b04a81fe272033550c41c Mon Sep 17 00:00:00 2001 From: webwarrior Date: Wed, 20 Dec 2023 14:05:19 +0100 Subject: [PATCH] UsedUnderscorePrefixedElements: fix for _ func args Fix rule so that it doesn't produce error on `_` function arguments. --- .../UsedUnderscorePrefixedElements.fs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/FSharpLint.Core/Rules/Conventions/UsedUnderscorePrefixedElements.fs b/src/FSharpLint.Core/Rules/Conventions/UsedUnderscorePrefixedElements.fs index 6d6f1696e..2b7cab6e6 100644 --- a/src/FSharpLint.Core/Rules/Conventions/UsedUnderscorePrefixedElements.fs +++ b/src/FSharpLint.Core/Rules/Conventions/UsedUnderscorePrefixedElements.fs @@ -31,15 +31,19 @@ let runner (args: AstNodeRuleParams) = | Some checkResults -> checkResults.GetAllUsesOfAllSymbolsInFile() |> Seq.choose (fun usage -> - if not usage.IsFromDefinition && usage.Symbol.FullName.StartsWith "_" then - Some { - Range = usage.Range - Message = String.Format(Resources.GetString ("RulesUsedUnderscorePrefixedElements")) - SuggestedFix = None - TypeChecks = List.Empty - } - else - None) + match usage.Symbol with + | :? FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue as symbol -> + if not usage.IsFromDefinition && symbol.FullName.StartsWith "_" + && symbol.FullName <> "_" && not symbol.IsCompilerGenerated then + Some { + Range = usage.Range + Message = String.Format(Resources.GetString ("RulesUsedUnderscorePrefixedElements")) + SuggestedFix = None + TypeChecks = List.Empty + } + else + None + | _ -> None ) |> Seq.toArray | None -> Array.empty else