From 985f38c696391f5c8f38f4498e3a59db66ffe3c6 Mon Sep 17 00:00:00 2001 From: Zaid Date: Sun, 6 Dec 2020 01:06:35 +0100 Subject: [PATCH] Npgsql.FSharp.Analyzer v3.16 detect and analyze top-level do expressions on modules --- RELEASE_NOTES.md | 3 +++ src/FParsec/AssemblyInfo.fs | 16 ++++++++-------- src/NpgsqlFSharpAnalyzer.Core/AssemblyInfo.fs | 16 ++++++++-------- .../SyntacticAnalysis.fs | 2 ++ src/NpgsqlFSharpAnalyzer/AssemblyInfo.fs | 16 ++++++++-------- src/NpgsqlFSharpParser/AssemblyInfo.fs | 16 ++++++++-------- src/NpgsqlFSharpVs/source.extension.vsixmanifest | 2 +- tests/NpgsqlFSharpAnalyzer.Tests/AssemblyInfo.fs | 16 ++++++++-------- tests/NpgsqlFSharpAnalyzer.Tests/Tests.fs | 8 ++++++++ tests/examples/hashing/AssemblyInfo.fs | 16 ++++++++-------- tests/examples/hashing/examples.fsproj | 3 ++- .../hashing/topLevelExpressionIsDetected.fs | 10 ++++++++++ 12 files changed, 74 insertions(+), 50 deletions(-) create mode 100644 tests/examples/hashing/topLevelExpressionIsDetected.fs diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4f2fa0b..f1c4d9f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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 diff --git a/src/FParsec/AssemblyInfo.fs b/src/FParsec/AssemblyInfo.fs index 787e303..7c0b362 100644 --- a/src/FParsec/AssemblyInfo.fs +++ b/src/FParsec/AssemblyInfo.fs @@ -4,20 +4,20 @@ open System.Reflection [] [] -[] +[] [] -[] -[] +[] +[] [] -[] +[] do () module internal AssemblyVersionInformation = let [] AssemblyTitle = "FParsec" let [] AssemblyProduct = "NpgsqlFSharpAnalyzer" - let [] AssemblyVersion = "3.15.0" + let [] AssemblyVersion = "3.16.0" let [] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000" - let [] AssemblyFileVersion = "3.15.0" - let [] AssemblyInformationalVersion = "3.15.0" + let [] AssemblyFileVersion = "3.16.0" + let [] AssemblyInformationalVersion = "3.16.0" let [] AssemblyMetadata_ReleaseChannel = "release" - let [] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda" + let [] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15" diff --git a/src/NpgsqlFSharpAnalyzer.Core/AssemblyInfo.fs b/src/NpgsqlFSharpAnalyzer.Core/AssemblyInfo.fs index cf5e8e2..b8b10da 100644 --- a/src/NpgsqlFSharpAnalyzer.Core/AssemblyInfo.fs +++ b/src/NpgsqlFSharpAnalyzer.Core/AssemblyInfo.fs @@ -4,20 +4,20 @@ open System.Reflection [] [] -[] +[] [] -[] -[] +[] +[] [] -[] +[] do () module internal AssemblyVersionInformation = let [] AssemblyTitle = "NpgsqlFSharpAnalyzer.Core" let [] AssemblyProduct = "NpgsqlFSharpAnalyzer" - let [] AssemblyVersion = "3.15.0" + let [] AssemblyVersion = "3.16.0" let [] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000" - let [] AssemblyFileVersion = "3.15.0" - let [] AssemblyInformationalVersion = "3.15.0" + let [] AssemblyFileVersion = "3.16.0" + let [] AssemblyInformationalVersion = "3.16.0" let [] AssemblyMetadata_ReleaseChannel = "release" - let [] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda" + let [] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15" diff --git a/src/NpgsqlFSharpAnalyzer.Core/SyntacticAnalysis.fs b/src/NpgsqlFSharpAnalyzer.Core/SyntacticAnalysis.fs index 4ea0887..f294823 100644 --- a/src/NpgsqlFSharpAnalyzer.Core/SyntacticAnalysis.fs +++ b/src/NpgsqlFSharpAnalyzer.Core/SyntacticAnalysis.fs @@ -736,6 +736,8 @@ module SyntacticAnalysis = | SynModuleDecl.Types(definitions, range) -> iterTypeDefs definitions + | SynModuleDecl.DoExpr(debugInfo, expression, range) -> + operations.AddRange (visitSyntacticExpression expression range) | _ -> () diff --git a/src/NpgsqlFSharpAnalyzer/AssemblyInfo.fs b/src/NpgsqlFSharpAnalyzer/AssemblyInfo.fs index e870094..8b65cf4 100644 --- a/src/NpgsqlFSharpAnalyzer/AssemblyInfo.fs +++ b/src/NpgsqlFSharpAnalyzer/AssemblyInfo.fs @@ -4,20 +4,20 @@ open System.Reflection [] [] -[] +[] [] -[] -[] +[] +[] [] -[] +[] do () module internal AssemblyVersionInformation = let [] AssemblyTitle = "NpgsqlFSharpAnalyzer" let [] AssemblyProduct = "NpgsqlFSharpAnalyzer" - let [] AssemblyVersion = "3.15.0" + let [] AssemblyVersion = "3.16.0" let [] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000" - let [] AssemblyFileVersion = "3.15.0" - let [] AssemblyInformationalVersion = "3.15.0" + let [] AssemblyFileVersion = "3.16.0" + let [] AssemblyInformationalVersion = "3.16.0" let [] AssemblyMetadata_ReleaseChannel = "release" - let [] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda" + let [] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15" diff --git a/src/NpgsqlFSharpParser/AssemblyInfo.fs b/src/NpgsqlFSharpParser/AssemblyInfo.fs index 1378839..440807a 100644 --- a/src/NpgsqlFSharpParser/AssemblyInfo.fs +++ b/src/NpgsqlFSharpParser/AssemblyInfo.fs @@ -4,20 +4,20 @@ open System.Reflection [] [] -[] +[] [] -[] -[] +[] +[] [] -[] +[] do () module internal AssemblyVersionInformation = let [] AssemblyTitle = "NpgsqlFSharpParser" let [] AssemblyProduct = "NpgsqlFSharpAnalyzer" - let [] AssemblyVersion = "3.15.0" + let [] AssemblyVersion = "3.16.0" let [] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000" - let [] AssemblyFileVersion = "3.15.0" - let [] AssemblyInformationalVersion = "3.15.0" + let [] AssemblyFileVersion = "3.16.0" + let [] AssemblyInformationalVersion = "3.16.0" let [] AssemblyMetadata_ReleaseChannel = "release" - let [] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda" + let [] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15" diff --git a/src/NpgsqlFSharpVs/source.extension.vsixmanifest b/src/NpgsqlFSharpVs/source.extension.vsixmanifest index 877e6ae..4271adc 100644 --- a/src/NpgsqlFSharpVs/source.extension.vsixmanifest +++ b/src/NpgsqlFSharpVs/source.extension.vsixmanifest @@ -3,7 +3,7 @@ xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011"> - + NpgsqlFSharpVs F# Analyzer for embedded SQL syntax analysis, type-checking for parameters and result sets and nullable column detection when writing queries using Npgsql.FSharp. https://github.com/Zaid-Ajaj/Npgsql.FSharp.Analyzer diff --git a/tests/NpgsqlFSharpAnalyzer.Tests/AssemblyInfo.fs b/tests/NpgsqlFSharpAnalyzer.Tests/AssemblyInfo.fs index 24dc1be..9f39e32 100644 --- a/tests/NpgsqlFSharpAnalyzer.Tests/AssemblyInfo.fs +++ b/tests/NpgsqlFSharpAnalyzer.Tests/AssemblyInfo.fs @@ -4,20 +4,20 @@ open System.Reflection [] [] -[] +[] [] -[] -[] +[] +[] [] -[] +[] do () module internal AssemblyVersionInformation = let [] AssemblyTitle = "NpgsqlFSharpAnalyzer.Tests" let [] AssemblyProduct = "NpgsqlFSharpAnalyzer" - let [] AssemblyVersion = "3.15.0" + let [] AssemblyVersion = "3.16.0" let [] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000" - let [] AssemblyFileVersion = "3.15.0" - let [] AssemblyInformationalVersion = "3.15.0" + let [] AssemblyFileVersion = "3.16.0" + let [] AssemblyInformationalVersion = "3.16.0" let [] AssemblyMetadata_ReleaseChannel = "release" - let [] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda" + let [] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15" diff --git a/tests/NpgsqlFSharpAnalyzer.Tests/Tests.fs b/tests/NpgsqlFSharpAnalyzer.Tests/Tests.fs index 94e2296..d25bd32 100644 --- a/tests/NpgsqlFSharpAnalyzer.Tests/Tests.fs +++ b/tests/NpgsqlFSharpAnalyzer.Tests/Tests.fs @@ -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 [] query" { match context (find "../examples/hashing/syntacticAnalysis-literalStrings.fs") with | None -> failwith "Could not crack project" diff --git a/tests/examples/hashing/AssemblyInfo.fs b/tests/examples/hashing/AssemblyInfo.fs index 2e9f850..db2cb70 100644 --- a/tests/examples/hashing/AssemblyInfo.fs +++ b/tests/examples/hashing/AssemblyInfo.fs @@ -4,20 +4,20 @@ open System.Reflection [] [] -[] +[] [] -[] -[] +[] +[] [] -[] +[] do () module internal AssemblyVersionInformation = let [] AssemblyTitle = "examples" let [] AssemblyProduct = "NpgsqlFSharpAnalyzer" - let [] AssemblyVersion = "3.15.0" + let [] AssemblyVersion = "3.16.0" let [] AssemblyMetadata_ReleaseDate = "2020-09-15T00:00:00.0000000" - let [] AssemblyFileVersion = "3.15.0" - let [] AssemblyInformationalVersion = "3.15.0" + let [] AssemblyFileVersion = "3.16.0" + let [] AssemblyInformationalVersion = "3.16.0" let [] AssemblyMetadata_ReleaseChannel = "release" - let [] AssemblyMetadata_GitHash = "b8f1eb5700564f78feb13f98df1d1228d34e4dda" + let [] AssemblyMetadata_GitHash = "9ada11966d9a0a63829dd0976addedf8d6224a15" diff --git a/tests/examples/hashing/examples.fsproj b/tests/examples/hashing/examples.fsproj index 6ffa143..c0cf653 100644 --- a/tests/examples/hashing/examples.fsproj +++ b/tests/examples/hashing/examples.fsproj @@ -5,6 +5,7 @@ + @@ -35,7 +36,7 @@ - + diff --git a/tests/examples/hashing/topLevelExpressionIsDetected.fs b/tests/examples/hashing/topLevelExpressionIsDetected.fs new file mode 100644 index 0000000..8de7da7 --- /dev/null +++ b/tests/examples/hashing/topLevelExpressionIsDetected.fs @@ -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