diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/GenericTypesNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/GenericTypesNames.fs index 95cab3b41..23d0be791 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/GenericTypesNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/GenericTypesNames.fs @@ -10,16 +10,15 @@ let private getIdentifiers (args: AstNodeRuleParams) = | AstNode.TypeDefinition(SynTypeDefn(componentInfo, _typeDef, _, _, _)) -> let checkTypes types = seq { - for SynTyparDecl(_attr, synTypeDecl) in types do - match synTypeDecl with - | SynTypar(id, _, _) when not (isPascalCase id.idText) -> - yield (id, id.idText, None) - | _ -> () + for SynTyparDecl(_attr, SynTypar(id, _, _)) in types do + yield (id, id.idText, None) } match componentInfo with | SynComponentInfo(_attrs, types, _, _identifier, _, _, _, _) -> checkTypes types |> Array.ofSeq + | AstNode.Type(SynType.Var(SynTypar(id, _, _), _)) -> + (id, id.idText, None) |> Array.singleton | _ -> Array.empty let rule config = diff --git a/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/GenericTypesNames.fs b/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/GenericTypesNames.fs index 0df1fb958..d4aed4af6 100644 --- a/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/GenericTypesNames.fs +++ b/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/GenericTypesNames.fs @@ -26,7 +26,7 @@ type Foo<'T> = Option<'T> type Foo<'a> = Option<'a> """ Assert.IsTrue(this.ErrorsExist) - Assert.IsTrue(this.ErrorExistsAt(2, 9)) + Assert.IsTrue(this.ErrorExistsOnLine 2) [] member this.``generic type names shouldn't be camelCase (2 generic types)``() = @@ -34,7 +34,7 @@ type Foo<'a> = Option<'a> type Foo<'a, 'T> = Option<'a * 'T> """ Assert.IsTrue(this.ErrorsExist) - Assert.IsTrue(this.ErrorExistsAt(2, 9)) + Assert.IsTrue(this.ErrorExistsOnLine 2) [] member this.``generic type names shouldn't be camelCase (2 generic types with different order)``() = @@ -42,7 +42,7 @@ type Foo<'a, 'T> = Option<'a * 'T> type Foo<'T, 'a> = Option<'T * 'a> """ Assert.IsTrue(this.ErrorsExist) - Assert.IsTrue(this.ErrorExistsAt(2, 13)) + Assert.IsTrue(this.ErrorExistsOnLine 2) [] member this.``generic type names are PascalCase``() = @@ -57,3 +57,37 @@ type Foo<'K, 'V> = Option<'K * 'V> type Foo<'T1, 'T2, 'T3, 'T4, 'T5, 'a, 'T6> = Option<'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'a * 'T6> """ Assert.IsTrue(this.ErrorsExist) + Assert.IsTrue(this.ErrorExistsOnLine 2) + + [] + member this.``generic type names shouldn't be camelCase even for types in methods``() = + this.Parse """ +module PeerChannelEncryptorMonad = + type PeerChannelEncryptorComputation<'T> = + | PeerChannelEncryptorComputation of + (PeerChannelEncryptor -> Result<'T * PeerChannelEncryptor, PeerError>) + + let runP pcec initialState = + let (PeerChannelEncryptorComputation innerFn) = pcec + innerFn initialState + + let returnP x = + let innerFn state = + Ok(x, state) + + PeerChannelEncryptorComputation innerFn + + let bindP + (f: 'a -> PeerChannelEncryptorComputation<'b>) + (xT: PeerChannelEncryptorComputation<'a>) + : PeerChannelEncryptorComputation<'b> = + let innerFn state = + runP xT state + >>= fun (res, state2) -> + let h = runP (f res) state2 + h + + PeerChannelEncryptorComputation innerFn +""" + Assert.IsTrue(this.ErrorsExist) + Assert.IsTrue(this.ErrorExistsOnLine 18)