C#: Extract partial method declaration.

This commit is contained in:
Michael Nebel
2026-02-20 13:23:18 +01:00
parent e8427a59f5
commit d3fcc2a6cc
3 changed files with 6 additions and 5 deletions

View File

@@ -14,14 +14,12 @@ namespace Semmle.Extraction.CSharp.Entities
public override string Name => Symbol.GetName();
protected override IMethodSymbol BodyDeclaringSymbol => Symbol.PartialImplementationPart ?? Symbol;
public IMethodSymbol SourceDeclaration => Symbol.OriginalDefinition;
public override Microsoft.CodeAnalysis.Location ReportingLocation =>
IsCompilerGeneratedDelegate()
? Symbol.ContainingType.GetSymbolLocation()
: BodyDeclaringSymbol.GetSymbolLocation();
: Symbol.GetSymbolLocation();
public override bool NeedsPopulation =>
(base.NeedsPopulation || IsCompilerGeneratedDelegate()) &&
@@ -77,7 +75,7 @@ namespace Semmle.Extraction.CSharp.Entities
cx.ExtractionContext.Logger.LogWarning("Reduced extension method symbols should not be directly extracted.");
}
return OrdinaryMethodFactory.Instance.CreateEntityFromSymbol(cx, method);
return OrdinaryMethodFactory.Instance.CreateEntityFromSymbol(cx, method.GetBodyDeclaringSymbol());
}
private class OrdinaryMethodFactory : CachedEntityFactory<IMethodSymbol, OrdinaryMethod>