C#: Extract source files generated by source generators

This commit is contained in:
Tamas Vajk
2023-05-25 15:52:56 +02:00
parent 5de8934525
commit 74a585222c
2 changed files with 15 additions and 5 deletions

View File

@@ -381,8 +381,17 @@ namespace Semmle.Extraction.CSharp
references => ResolveReferences(compilerArguments, analyser, canonicalPathCache, references),
(analyser, syntaxTrees) =>
{
var paths = compilerArguments.SourceFiles
.Select(src => src.Path)
.ToList();
if (compilerArguments.GeneratedFilesOutputDirectory is not null)
{
paths.AddRange(Directory.GetFiles(compilerArguments.GeneratedFilesOutputDirectory, "*.cs", SearchOption.AllDirectories));
}
return ReadSyntaxTrees(
compilerArguments.SourceFiles.Select(src => canonicalPathCache.GetCanonicalPath(src.Path)),
paths.Select(canonicalPathCache.GetCanonicalPath),
analyser,
compilerArguments.ParseOptions,
compilerArguments.Encoding,

View File

@@ -63,7 +63,7 @@ function RegisterExtractorPack(id)
end
end
if match then
local injections = { '-p:UseSharedCompilation=false' }
local injections = { '-p:UseSharedCompilation=false', '-p:EmitCompilerGeneratedFiles=true' }
if dotnetRunNeedsSeparator then
table.insert(injections, '--')
end
@@ -118,7 +118,8 @@ function RegisterExtractorPack(id)
compilerArguments,
nil, {
'/p:UseSharedCompilation=false',
'/p:MvcBuildViews=true'
'/p:MvcBuildViews=true',
'/p:EmitCompilerGeneratedFiles=true',
})
}
@@ -154,7 +155,7 @@ function RegisterExtractorPack(id)
if seenCompilerCall then
return {
order = ORDER_BEFORE,
order = ORDER_AFTER,
invocation = {
path = AbsolutifyExtractorPath(id, extractor),
arguments = {
@@ -194,7 +195,7 @@ function RegisterExtractorPack(id)
if seenCompilerCall then
return {
order = ORDER_BEFORE,
order = ORDER_AFTER,
invocation = {
path = AbsolutifyExtractorPath(id, extractor),
arguments = {