Skip to content

Commit

Permalink
Npgsql.FSharp.Analyzer v3.16 detect and analyze top-level do expressi…
Browse files Browse the repository at this point in the history
…ons on modules
  • Loading branch information
Zaid-Ajaj committed Dec 6, 2020
1 parent 9ada119 commit 985f38c
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 50 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 3.16.0 - 2020-09-15
* Analyze top level do expressions

### 3.15.0 - 2020-09-15
* Analyze transaction parameter sets
* Allow for literal queries on transactions
Expand Down
16 changes: 8 additions & 8 deletions src/FParsec/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("FParsec")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.15.0")>]
[<assembly: AssemblyVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2020-09-15T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.15.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.15.0")>]
[<assembly: AssemblyFileVersionAttribute("3.16.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","b8f1eb5700564f78feb13f98df1d1228d34e4dda")>]
[<assembly: AssemblyMetadataAttribute("GitHash","9ada11966d9a0a63829dd0976addedf8d6224a15")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "FParsec"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.15.0"
let [<Literal>] AssemblyVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.15.0"
let [<Literal>] AssemblyInformationalVersion = "3.15.0"
let [<Literal>] AssemblyFileVersion = "3.16.0"
let [<Literal>] AssemblyInformationalVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda"
let [<Literal>] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15"
16 changes: 8 additions & 8 deletions src/NpgsqlFSharpAnalyzer.Core/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("NpgsqlFSharpAnalyzer.Core")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.15.0")>]
[<assembly: AssemblyVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2020-09-15T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.15.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.15.0")>]
[<assembly: AssemblyFileVersionAttribute("3.16.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","b8f1eb5700564f78feb13f98df1d1228d34e4dda")>]
[<assembly: AssemblyMetadataAttribute("GitHash","9ada11966d9a0a63829dd0976addedf8d6224a15")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "NpgsqlFSharpAnalyzer.Core"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.15.0"
let [<Literal>] AssemblyVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.15.0"
let [<Literal>] AssemblyInformationalVersion = "3.15.0"
let [<Literal>] AssemblyFileVersion = "3.16.0"
let [<Literal>] AssemblyInformationalVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda"
let [<Literal>] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15"
2 changes: 2 additions & 0 deletions src/NpgsqlFSharpAnalyzer.Core/SyntacticAnalysis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,8 @@ module SyntacticAnalysis =
| SynModuleDecl.Types(definitions, range) ->
iterTypeDefs definitions

| SynModuleDecl.DoExpr(debugInfo, expression, range) ->
operations.AddRange (visitSyntacticExpression expression range)
| _ ->
()

Expand Down
16 changes: 8 additions & 8 deletions src/NpgsqlFSharpAnalyzer/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.15.0")>]
[<assembly: AssemblyVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2020-09-15T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.15.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.15.0")>]
[<assembly: AssemblyFileVersionAttribute("3.16.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","b8f1eb5700564f78feb13f98df1d1228d34e4dda")>]
[<assembly: AssemblyMetadataAttribute("GitHash","9ada11966d9a0a63829dd0976addedf8d6224a15")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.15.0"
let [<Literal>] AssemblyVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.15.0"
let [<Literal>] AssemblyInformationalVersion = "3.15.0"
let [<Literal>] AssemblyFileVersion = "3.16.0"
let [<Literal>] AssemblyInformationalVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda"
let [<Literal>] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15"
16 changes: 8 additions & 8 deletions src/NpgsqlFSharpParser/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("NpgsqlFSharpParser")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.15.0")>]
[<assembly: AssemblyVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2020-09-15T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.15.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.15.0")>]
[<assembly: AssemblyFileVersionAttribute("3.16.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","b8f1eb5700564f78feb13f98df1d1228d34e4dda")>]
[<assembly: AssemblyMetadataAttribute("GitHash","9ada11966d9a0a63829dd0976addedf8d6224a15")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "NpgsqlFSharpParser"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.15.0"
let [<Literal>] AssemblyVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.15.0"
let [<Literal>] AssemblyInformationalVersion = "3.15.0"
let [<Literal>] AssemblyFileVersion = "3.16.0"
let [<Literal>] AssemblyInformationalVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda"
let [<Literal>] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15"
2 changes: 1 addition & 1 deletion src/NpgsqlFSharpVs/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011"
xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="FSharpLintVs.ef00bfc3-a899-45fc-aae8-afecf8673aaf" Version="3.14.0" Language="en-US" Publisher="Zaid Ajaj" />
<Identity Id="FSharpLintVs.ef00bfc3-a899-45fc-aae8-afecf8673aaf" Version="3.16.0" Language="en-US" Publisher="Zaid Ajaj" />
<DisplayName>NpgsqlFSharpVs</DisplayName>
<Description xml:space="preserve">F# Analyzer for embedded SQL syntax analysis, type-checking for parameters and result sets and nullable column detection when writing queries using Npgsql.FSharp.</Description>
<MoreInfo>https://github.com/Zaid-Ajaj/Npgsql.FSharp.Analyzer</MoreInfo>
Expand Down
16 changes: 8 additions & 8 deletions tests/NpgsqlFSharpAnalyzer.Tests/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("NpgsqlFSharpAnalyzer.Tests")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.15.0")>]
[<assembly: AssemblyVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2020-09-15T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.15.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.15.0")>]
[<assembly: AssemblyFileVersionAttribute("3.16.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","b8f1eb5700564f78feb13f98df1d1228d34e4dda")>]
[<assembly: AssemblyMetadataAttribute("GitHash","9ada11966d9a0a63829dd0976addedf8d6224a15")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "NpgsqlFSharpAnalyzer.Tests"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.15.0"
let [<Literal>] AssemblyVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.15.0"
let [<Literal>] AssemblyInformationalVersion = "3.15.0"
let [<Literal>] AssemblyFileVersion = "3.16.0"
let [<Literal>] AssemblyInformationalVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda"
let [<Literal>] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15"
8 changes: 8 additions & 0 deletions tests/NpgsqlFSharpAnalyzer.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ let tests =
Expect.isEmpty operations "There should be no syntactic blocks"
}

test "Syntactic analysis: SQL block found from top-level expression in module" {
match context (find "../examples/hashing/topLevelExpressionIsDetected.fs") with
| None -> failwith "Could not crack project"
| Some context ->
let operations = SyntacticAnalysis.findSqlOperations context
Expect.equal 1 operations.Length "There should be one syntactic block found"
}

test "Syntactic Analysis: reading queries with [<Literal>] query" {
match context (find "../examples/hashing/syntacticAnalysis-literalStrings.fs") with
| None -> failwith "Could not crack project"
Expand Down
16 changes: 8 additions & 8 deletions tests/examples/hashing/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("examples")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.15.0")>]
[<assembly: AssemblyVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2020-09-15T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.15.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.15.0")>]
[<assembly: AssemblyFileVersionAttribute("3.16.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.16.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","b8f1eb5700564f78feb13f98df1d1228d34e4dda")>]
[<assembly: AssemblyMetadataAttribute("GitHash","9ada11966d9a0a63829dd0976addedf8d6224a15")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "examples"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.15.0"
let [<Literal>] AssemblyVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.15.0"
let [<Literal>] AssemblyInformationalVersion = "3.15.0"
let [<Literal>] AssemblyFileVersion = "3.16.0"
let [<Literal>] AssemblyInformationalVersion = "3.16.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda"
let [<Literal>] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15"
3 changes: 2 additions & 1 deletion tests/examples/hashing/examples.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="topLevelExpressionIsDetected.fs" />
<Compile Include="usingLiteralQueriesWithTransactions.fs" />
<Compile Include="detectingDynamicListsInTransactions.fs" />
<Compile Include="detectingEmptyParameterSet.fs" />
Expand Down Expand Up @@ -35,7 +36,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Npgsql.FSharp" Version="3.7.0" />
<PackageReference Include="Npgsql.FSharp" Version="3.12.2" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions tests/examples/hashing/topLevelExpressionIsDetected.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module TopLevelExpressionIsDetected

open Npgsql.FSharp

"some connection string"
|> Sql.connect
|> Sql.query "SELECT * FROM users WHERE user_id = @user_id"
|> Sql.parameters [ "@user_id", Sql.int 42 ]
|> Sql.execute (fun read -> read.int "user_id")
|> ignore

0 comments on commit 985f38c

Please sign in to comment.