Skip to content

Commit 7a8d83e

Browse files
committed
C#: Add integration test with asp.net core view generation on dotnet 6
Source generators are needed for asp.net core view generation. Dotnet 6 is the first version where we support view generation. This commit adds an integration test for this.
1 parent 92fec66 commit 7a8d83e

File tree

7 files changed

+56
-0
lines changed

7 files changed

+56
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| Program.cs |
2+
| Views/Home/Index.cshtml |
3+
| _semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_net6_Views_Home_Index_cshtml.g.cs |
4+
| test-db/working/implicitUsings/GlobalUsings.g.cs |
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import csharp
2+
3+
private string getPath(File f) {
4+
result = f.getRelativePath() and
5+
not exists(
6+
result
7+
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_")
8+
)
9+
or
10+
exists(int index |
11+
index =
12+
f.getRelativePath()
13+
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
14+
result = f.getRelativePath().substring(index, f.getRelativePath().length())
15+
)
16+
}
17+
18+
from File f
19+
where f.fromSource() or f.getExtension() = "cshtml"
20+
select getPath(f)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var dummy = "dummy";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@{
2+
ViewData["Title"] = "Home Page";
3+
}
4+
5+
<div class="text-center">
6+
<h1 class="display-4">Welcome</h1>
7+
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
8+
</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<Target Name="DeleteBinObjFolders" BeforeTargets="Clean">
11+
<RemoveDir Directories=".\bin" />
12+
<RemoveDir Directories=".\obj" />
13+
</Target>
14+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "6.0.418"
4+
}
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import os
2+
from create_database_utils import *
3+
4+
run_codeql_database_create(lang="csharp", extra_args=["--extractor-option=buildless=true", "--extractor-option=cil=false"])

0 commit comments

Comments
 (0)