From cf9b1fb41a9ab2a37d15be08de631621a1ffa012 Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:10:28 +0700 Subject: [PATCH 1/9] touch --- test-app/test-app/TestCodeAnalyzer/RawSql.cs | 2 +- test-app/test-app/TestCodeAnalyzer/RequiredProperties.cs | 2 +- test-app/test-app/TestCodeAnalyzer/TaskBlocking.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test-app/test-app/TestCodeAnalyzer/RawSql.cs b/test-app/test-app/TestCodeAnalyzer/RawSql.cs index c513e5d..b7c22e7 100644 --- a/test-app/test-app/TestCodeAnalyzer/RawSql.cs +++ b/test-app/test-app/TestCodeAnalyzer/RawSql.cs @@ -27,7 +27,7 @@ public RawSql(Microsoft.EntityFrameworkCore.DbContext context) public void Execute() { - _context.Set().FromSqlRaw("SELECT * FROM Entity"); // Should have warning + _context.Set().FromSqlRaw("SELECT * FROM Entity"); // Should have warning } } diff --git a/test-app/test-app/TestCodeAnalyzer/RequiredProperties.cs b/test-app/test-app/TestCodeAnalyzer/RequiredProperties.cs index 6ea4563..abb552e 100644 --- a/test-app/test-app/TestCodeAnalyzer/RequiredProperties.cs +++ b/test-app/test-app/TestCodeAnalyzer/RequiredProperties.cs @@ -35,7 +35,7 @@ public class SampleService private readonly IDataHandler _mockDataHandler = new DataHandler(); public void SampleMethod() { - _mockDataHandler.FindList(m => m.Name == "Test"); // Should warning + _mockDataHandler.FindList(m => m.Name == "Test"); // Should warning } } } \ No newline at end of file diff --git a/test-app/test-app/TestCodeAnalyzer/TaskBlocking.cs b/test-app/test-app/TestCodeAnalyzer/TaskBlocking.cs index ad42c99..96f35c6 100644 --- a/test-app/test-app/TestCodeAnalyzer/TaskBlocking.cs +++ b/test-app/test-app/TestCodeAnalyzer/TaskBlocking.cs @@ -8,7 +8,7 @@ void Example() { Task task1 = Task.CompletedTask; Task task2 = Task.FromResult(42); - task1.Wait(); // Should have warning - var result = task2.Result; // Should have warning + task1.Wait(); // Should have warning + var result = task2.Result; // Should have warning } } From 0d9e3fb17ef29f0d046bb6cd28763c44e53ecfde Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:14:05 +0700 Subject: [PATCH 2/9] test --- .github/workflows/analyzer.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/analyzer.yaml b/.github/workflows/analyzer.yaml index 4d7006e..3a37a79 100644 --- a/.github/workflows/analyzer.yaml +++ b/.github/workflows/analyzer.yaml @@ -99,6 +99,7 @@ jobs: logContent.split("\n").forEach((line) => { patterns.some(({ pattern, type }) => { + console.log(pattern); const match = line.match(pattern); if (match) { foundMatch = true; From 7fb07d965745c3def83bc1a6f757c4bd544b5fed Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:15:30 +0700 Subject: [PATCH 3/9] add - --- .github/workflows/analyzer.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analyzer.yaml b/.github/workflows/analyzer.yaml index 3a37a79..43f40e6 100644 --- a/.github/workflows/analyzer.yaml +++ b/.github/workflows/analyzer.yaml @@ -41,7 +41,7 @@ jobs: const rulePatterns = { Warning: { ids: ['FAWRN\\d+'], type: 'Warning' }, Information: { ids: ['FAINF\\d+'], type: 'Information' }, - Error: { ids: [], type: 'Error' } + Error: { ids: ['-'], type: 'Error' } }; // Example match: `MyFile.cs(12,4): warning AB1234: 'Foo' is obsolete (http://example.com)` const patterns = Object.values(rulePatterns).map(({ ids, type }) => ({ From 82c36f3e91aadce2d4c0dec5da33d56b209c49f3 Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:20:46 +0700 Subject: [PATCH 4/9] test --- .github/workflows/analyzer.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analyzer.yaml b/.github/workflows/analyzer.yaml index 43f40e6..b1465d5 100644 --- a/.github/workflows/analyzer.yaml +++ b/.github/workflows/analyzer.yaml @@ -24,7 +24,7 @@ jobs: 9.x - name: Build Solution - run: dotnet build test-app | tee build.log # Output to both build.log and stdout, required for `Extract warning` step + run: dotnet build ./test-app/test-app.sln | tee build.log # Output to both build.log and stdout, required for `Extract warning` step - name: Extract warning uses: actions/github-script@v7 From 0a7bf090986739de3cafadbe181b63a975712317 Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:24:29 +0700 Subject: [PATCH 5/9] Update analyzer.yaml --- .github/workflows/analyzer.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/analyzer.yaml b/.github/workflows/analyzer.yaml index b1465d5..3cbd95d 100644 --- a/.github/workflows/analyzer.yaml +++ b/.github/workflows/analyzer.yaml @@ -24,7 +24,7 @@ jobs: 9.x - name: Build Solution - run: dotnet build ./test-app/test-app.sln | tee build.log # Output to both build.log and stdout, required for `Extract warning` step + run: dotnet build ./test-app/test-app.sln > build.log # Output to both build.log and stdout, required for `Extract warning` step - name: Extract warning uses: actions/github-script@v7 @@ -146,4 +146,4 @@ jobs: } }); } - console.log(mdComment); \ No newline at end of file + console.log(mdComment); From 36b5e5d683e68117e5b1a5ab0dd5f57ee6092c2f Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:26:07 +0700 Subject: [PATCH 6/9] Update analyzer.yaml --- .github/workflows/analyzer.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/analyzer.yaml b/.github/workflows/analyzer.yaml index 3cbd95d..b369708 100644 --- a/.github/workflows/analyzer.yaml +++ b/.github/workflows/analyzer.yaml @@ -99,7 +99,6 @@ jobs: logContent.split("\n").forEach((line) => { patterns.some(({ pattern, type }) => { - console.log(pattern); const match = line.match(pattern); if (match) { foundMatch = true; From c684e9cbcc897c8a1d5f3575ada75b4100dc2efb Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:52:08 +0700 Subject: [PATCH 7/9] Create RawSql2.cs (#24) --- test-app/test-app/TestCodeAnalyzer/RawSql2.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test-app/test-app/TestCodeAnalyzer/RawSql2.cs diff --git a/test-app/test-app/TestCodeAnalyzer/RawSql2.cs b/test-app/test-app/TestCodeAnalyzer/RawSql2.cs new file mode 100644 index 0000000..3799fbc --- /dev/null +++ b/test-app/test-app/TestCodeAnalyzer/RawSql2.cs @@ -0,0 +1,34 @@ +namespace Microsoft.EntityFrameworkCore +{ + public class DbContext + { + public DbSet Set() => default; + } + public class DbSet + { + public void FromSqlRaw(string sql) { } + public void SqlQueryRaw(string sql) { } + } +} + +public class Entity { } + +namespace test_app.TestCodeAnalyzer +{ + + public class RawSql + { + private Microsoft.EntityFrameworkCore.DbContext _context; + + public RawSql(Microsoft.EntityFrameworkCore.DbContext context) + { + _context = context; + } + + public void Execute() + { + _context.Set().FromSqlRaw("SELECT * FROM Entity"); // Should have warning + } + + } +} From 1d8153dedec34808be28c2729ca415b2ac148e18 Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:53:12 +0700 Subject: [PATCH 8/9] Update RawSql2.cs --- test-app/test-app/TestCodeAnalyzer/RawSql2.cs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/test-app/test-app/TestCodeAnalyzer/RawSql2.cs b/test-app/test-app/TestCodeAnalyzer/RawSql2.cs index 3799fbc..da67e7f 100644 --- a/test-app/test-app/TestCodeAnalyzer/RawSql2.cs +++ b/test-app/test-app/TestCodeAnalyzer/RawSql2.cs @@ -1,34 +1,34 @@ -namespace Microsoft.EntityFrameworkCore -{ - public class DbContext - { - public DbSet Set() => default; - } - public class DbSet - { - public void FromSqlRaw(string sql) { } - public void SqlQueryRaw(string sql) { } - } -} +// namespace Microsoft.EntityFrameworkCore +// { +// public class DbContext +// { +// public DbSet Set() => default; +// } +// public class DbSet +// { +// public void FromSqlRaw(string sql) { } +// public void SqlQueryRaw(string sql) { } +// } +// } -public class Entity { } +// public class Entity { } -namespace test_app.TestCodeAnalyzer -{ +// namespace test_app.TestCodeAnalyzer +// { - public class RawSql - { - private Microsoft.EntityFrameworkCore.DbContext _context; +// public class RawSql +// { +// private Microsoft.EntityFrameworkCore.DbContext _context; - public RawSql(Microsoft.EntityFrameworkCore.DbContext context) - { - _context = context; - } +// public RawSql(Microsoft.EntityFrameworkCore.DbContext context) +// { +// _context = context; +// } - public void Execute() - { - _context.Set().FromSqlRaw("SELECT * FROM Entity"); // Should have warning - } +// public void Execute() +// { +// _context.Set().FromSqlRaw("SELECT * FROM Entity"); // Should have warning +// } - } -} +// } +// } From bd0a638254d773a5dbfaa9eeb58c90336aee7492 Mon Sep 17 00:00:00 2001 From: fordpatsakorn Date: Mon, 21 Jul 2025 14:53:43 +0700 Subject: [PATCH 9/9] Create TaskBlocking2.cs --- .../test-app/TestCodeAnalyzer/TaskBlocking2.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test-app/test-app/TestCodeAnalyzer/TaskBlocking2.cs diff --git a/test-app/test-app/TestCodeAnalyzer/TaskBlocking2.cs b/test-app/test-app/TestCodeAnalyzer/TaskBlocking2.cs new file mode 100644 index 0000000..fe96e7e --- /dev/null +++ b/test-app/test-app/TestCodeAnalyzer/TaskBlocking2.cs @@ -0,0 +1,15 @@ +using System.Threading.Tasks; + +namespace test_app.TestCodeAnalyzer; + +public class TaskBlocking2 +{ + void Example() + { + Task task1 = Task.CompletedTask; + Task task2 = Task.FromResult(42); + task1.Wait(); // Should have warning + var result = task2.Result; // Should have warning + + } +}