Skip to content

Commit 504bb9c

Browse files
committed
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.
1 parent 1d2f154 commit 504bb9c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ public sealed override void WriteQuotedId(EscapingTextWriter trapFile)
5757

5858
public override void Populate(TextWriter trapFile)
5959
{
60+
// In this case, we don't extract the attribute again, as it was extracted using * ID
61+
// originally and we re-use that.
62+
if (Context.OnlyScaffold && (ReportingLocation is null || !ReportingLocation.IsInSource))
63+
{
64+
return;
65+
}
66+
6067
var type = Type.Create(Context, Symbol.AttributeClass);
6168
trapFile.attributes(this, kind, type.TypeRef, entity);
6269

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expression.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ internal Expression(IExpressionInfo info, bool shouldPopulate = true)
3434

3535
protected sealed override void Populate(TextWriter trapFile)
3636
{
37+
if (Context.OnlyScaffold)
38+
{
39+
return;
40+
}
41+
3742
var type = Type.HasValue ? Entities.Type.Create(Context, Type.Value) : NullType.Create(Context);
3843
trapFile.expressions(this, Kind, type.TypeRef);
3944
if (info.Parent.IsTopLevelParent)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,9 @@ public Context(ExtractionContext extractionContext, Compilation c, TrapWriter tr
536536
ShouldAddAssemblyTrapPrefix = shouldAddAssemblyTrapPrefix;
537537
Compilation = c;
538538
this.scope = scope;
539-
OnlyScaffold = overlayInfo.IsOverlayMode && scope is SourceScope ss && overlayInfo.OnlyMakeScaffold(ss.SourceTree.FilePath);
539+
OnlyScaffold = overlayInfo.IsOverlayMode && (
540+
IsAssemblyScope
541+
|| (scope is SourceScope ss && overlayInfo.OnlyMakeScaffold(ss.SourceTree.FilePath)));
540542
}
541543

542544
public bool FromSource => scope is SourceScope;

0 commit comments

Comments
 (0)