Skip to content

Commit 45ece48

Browse files
authored
Merge pull request github#16776 from tamasvajk/fix/source-generator-folder
C#: Make sure no file is added twice to the compilation
2 parents 7adfa6b + 6c8e391 commit 45ece48

File tree

10 files changed

+50
-1
lines changed

10 files changed

+50
-1
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Extractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ private static ExitCode AnalyseTracing(
398398
}
399399

400400
return ReadSyntaxTrees(
401-
paths.Select(analyser.PathCache.GetCanonicalPath),
401+
paths.Select(analyser.PathCache.GetCanonicalPath).ToHashSet(),
402402
analyser,
403403
compilerArguments.ParseOptions,
404404
compilerArguments.Encoding,

csharp/ql/integration-tests/all-platforms/source_generator/Diag.expected

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import csharp
2+
import semmle.code.csharp.commons.Diagnostics
3+
4+
query predicate test2(CompilerError e) { any() }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| 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 |
2+
| Generated/x.cs:0:0:0:0 | Generated/x.cs |
3+
| Program.cs:0:0:0:0 | Program.cs |
4+
| obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs:0:0:0:0 | obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs |
5+
| obj/Debug/net8.0/test.AssemblyInfo.cs:0:0:0:0 | obj/Debug/net8.0/test.AssemblyInfo.cs |
6+
| obj/Debug/net8.0/test.GlobalUsings.g.cs:0:0:0:0 | obj/Debug/net8.0/test.GlobalUsings.g.cs |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import csharp
2+
3+
from File f
4+
where f.fromSource()
5+
select f
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// File added to the Generated folder. This is not a source generator output file.
2+
class X
3+
{
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Text.RegularExpressions;
2+
3+
Console.WriteLine("Hello, World!");
4+
5+
partial class Test
6+
{
7+
[GeneratedRegex("abc|def", RegexOptions.IgnoreCase, "en-US")]
8+
private static partial Regex AbcOrDefGeneratedRegex();
9+
}
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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
9+
<!-- Add source generated files into the Generated folder. -->
10+
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
11+
</PropertyGroup>
12+
13+
</Project>
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(['dotnet build'], lang="csharp")

0 commit comments

Comments
 (0)