Skip to content

Commit

Permalink
Merge pull request #16776 from tamasvajk/fix/source-generator-folder
Browse files Browse the repository at this point in the history
C#: Make sure no file is added twice to the compilation
  • Loading branch information
tamasvajk committed Jun 19, 2024
2 parents 7adfa6b + 6c8e391 commit 45ece48
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public static IEnumerable<Action> ReadSyntaxTrees(IEnumerable<string> sources, A
}
return ReadSyntaxTrees(
paths.Select(analyser.PathCache.GetCanonicalPath),
paths.Select(analyser.PathCache.GetCanonicalPath).ToHashSet(),
analyser,
compilerArguments.ParseOptions,
compilerArguments.Encoding,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import csharp
import semmle.code.csharp.commons.Diagnostics

query predicate test2(CompilerError e) { any() }
Original file line number Diff line number Diff line change
@@ -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 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import csharp

from File f
where f.fromSource()
select f
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// File added to the Generated folder. This is not a source generator output file.
class X
{
}
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "8.0.101"
}
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from create_database_utils import *

run_codeql_database_create(['dotnet build'], lang="csharp")

0 comments on commit 45ece48

Please sign in to comment.