C#: Remove expression population safeguard and guard creation of constructor initializer expressions.

This commit is contained in:
Michael Nebel
2025-11-07 15:26:07 +01:00
parent 7c670cdc3f
commit 1657dfb551
2 changed files with 2 additions and 6 deletions

View File

@@ -60,7 +60,7 @@ namespace Semmle.Extraction.CSharp.Entities
// Do not extract initializers for constructed types.
// Extract initializers for constructors with a body, primary constructors
// and default constructors for classes and structs declared in source code.
if (Block is null && ExpressionBody is null && !MakeSynthetic)
if (Block is null && ExpressionBody is null && !MakeSynthetic || Context.OnlyScaffold)
{
return;
}
@@ -113,6 +113,7 @@ namespace Semmle.Extraction.CSharp.Entities
}
var baseConstructorTarget = Create(Context, baseConstructor);
var info = new ExpressionInfo(Context,
AnnotatedTypeSymbol.CreateNotAnnotated(baseType),
Location,

View File

@@ -34,11 +34,6 @@ 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)