mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
C#: Only scaffold assemblies in overlay mode, only extract expressions when not scaffolding and only extract attributes when they are in source code in overlay mode.
This commit is contained in:
@@ -57,6 +57,13 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
// In this case, we don't extract the attribute again, as it was extracted using * ID
|
||||
// originally and we re-use that.
|
||||
if (Context.OnlyScaffold && (ReportingLocation is null || !ReportingLocation.IsInSource))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var type = Type.Create(Context, Symbol.AttributeClass);
|
||||
trapFile.attributes(this, kind, type.TypeRef, entity);
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
protected sealed override void Populate(TextWriter trapFile)
|
||||
{
|
||||
if (Context.OnlyScaffold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var type = Type.HasValue ? Entities.Type.Create(Context, Type.Value) : NullType.Create(Context);
|
||||
trapFile.expressions(this, Kind, type.TypeRef);
|
||||
if (info.Parent.IsTopLevelParent)
|
||||
|
||||
@@ -536,7 +536,9 @@ namespace Semmle.Extraction.CSharp
|
||||
ShouldAddAssemblyTrapPrefix = shouldAddAssemblyTrapPrefix;
|
||||
Compilation = c;
|
||||
this.scope = scope;
|
||||
OnlyScaffold = overlayInfo.IsOverlayMode && scope is SourceScope ss && overlayInfo.OnlyMakeScaffold(ss.SourceTree.FilePath);
|
||||
OnlyScaffold = overlayInfo.IsOverlayMode && (
|
||||
IsAssemblyScope
|
||||
|| (scope is SourceScope ss && overlayInfo.OnlyMakeScaffold(ss.SourceTree.FilePath)));
|
||||
}
|
||||
|
||||
public bool FromSource => scope is SourceScope;
|
||||
|
||||
Reference in New Issue
Block a user