Skip to content

Commit 7fc1e13

Browse files
committed
C#: Add buildless integration test with Windows Forms application
1 parent 31a5a7a commit 7fc1e13

File tree

10 files changed

+127
-0
lines changed

10 files changed

+127
-0
lines changed

csharp/ql/integration-tests/all-platforms/standalone_winforms/Assemblies.expected

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import csharp
2+
3+
private string getPath(Assembly a) {
4+
not a.getCompilation().getOutputAssembly() = a and
5+
exists(string s | s = a.getFile().getAbsolutePath() |
6+
result = "[...]" + s.substring(s.indexOf("microsoft.windowsdesktop.app.ref") - 1, s.length())
7+
)
8+
}
9+
10+
from Assembly a
11+
select getPath(a)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
| All Nuget feeds reachable | 1.0 |
2+
| Failed project restore with package source error | 0.0 |
3+
| Failed solution restore with package source error | 0.0 |
4+
| NuGet feed responsiveness checked | 1.0 |
5+
| Project files on filesystem | 1.0 |
6+
| Reachable fallback Nuget feed count | 1.0 |
7+
| Resource extraction enabled | 0.0 |
8+
| Restored .NET framework variants | 0.0 |
9+
| Restored projects through solution files | 0.0 |
10+
| Solution files on filesystem | 0.0 |
11+
| Source files generated | 1.0 |
12+
| Source files on filesystem | 3.0 |
13+
| Successfully restored project files | 0.0 |
14+
| Successfully restored solution files | 0.0 |
15+
| Unresolved references | 0.0 |
16+
| UseWPF set | 0.0 |
17+
| UseWindowsForms set | 1.0 |
18+
| WebView extraction enabled | 1.0 |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import csharp
2+
import semmle.code.csharp.commons.Diagnostics
3+
4+
query predicate compilationInfo(string key, float value) {
5+
key != "Resolved references" and
6+
key != "Resolved assembly conflicts" and
7+
not key.matches("Compiler diagnostic count for%") and
8+
exists(Compilation c, string infoKey, string infoValue | infoValue = c.getInfo(infoKey) |
9+
key = infoKey and
10+
value = infoValue.toFloat()
11+
or
12+
not exists(infoValue.toFloat()) and
13+
key = infoKey + ": " + infoValue and
14+
value = 1
15+
)
16+
}

csharp/ql/integration-tests/all-platforms/standalone_winforms/Form1.Designer.cs

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace winforms;
2+
3+
public partial class Form1 : Form
4+
{
5+
public Form1()
6+
{
7+
InitializeComponent();
8+
}
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace winforms;
2+
3+
static class Program
4+
{
5+
/// <summary>
6+
/// The main entry point for the application.
7+
/// </summary>
8+
[STAThread]
9+
static void Main()
10+
{
11+
// To customize application configuration such as set high DPI settings or default font,
12+
// see https://aka.ms/applicationconfiguration.
13+
ApplicationConfiguration.Initialize();
14+
Application.Run(new Form1());
15+
}
16+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.101"
4+
}
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from create_database_utils import *
2+
3+
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<UseWindowsForms>true</UseWindowsForms>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
</PropertyGroup>
10+
11+
</Project>

0 commit comments

Comments
 (0)