C#: Add integration test with file added multiple times in the same compilation

This commit is contained in:
Tamas Vajk
2024-06-18 11:34:50 +02:00
parent 2c4a95bb5e
commit 5170585515
9 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1 @@
| Generated/x.cs:2:7:2:7 | CS0101: The namespace '<global namespace>' already contains a definition for 'X' |

View File

@@ -0,0 +1,4 @@
import csharp
import semmle.code.csharp.commons.Diagnostics
query predicate test2(CompilerError e) { any() }

View File

@@ -0,0 +1,6 @@
| Generated/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs:0:0:0:0 | Generated/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs |
| Generated/x.cs:0:0:0:0 | Generated/x.cs |
| Program.cs:0:0:0:0 | Program.cs |
| obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs:0:0:0:0 | obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs |
| obj/Debug/net8.0/test.AssemblyInfo.cs:0:0:0:0 | obj/Debug/net8.0/test.AssemblyInfo.cs |
| obj/Debug/net8.0/test.GlobalUsings.g.cs:0:0:0:0 | obj/Debug/net8.0/test.GlobalUsings.g.cs |

View File

@@ -0,0 +1,5 @@
import csharp
from File f
where f.fromSource()
select f

View File

@@ -0,0 +1,4 @@
// File added to the Generated folder. This is not a source generator output file.
class X
{
}

View File

@@ -0,0 +1,9 @@
using System.Text.RegularExpressions;
Console.WriteLine("Hello, World!");
partial class Test
{
[GeneratedRegex("abc|def", RegexOptions.IgnoreCase, "en-US")]
private static partial Regex AbcOrDefGeneratedRegex();
}

View File

@@ -0,0 +1,5 @@
{
"sdk": {
"version": "8.0.101"
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Add source generated files into the Generated folder. -->
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,3 @@
from create_database_utils import *
run_codeql_database_create(['dotnet build'], lang="csharp")