Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ private Constructor(Context cx, IMethodSymbol init)
.ToList();
}

protected override IMethodSymbol BodyDeclaringSymbol => Symbol.PartialImplementationPart ?? Symbol;


public override void Populate(TextWriter trapFile)
{
PopulateMethod(trapFile);
Expand Down
12 changes: 8 additions & 4 deletions csharp/extractor/Semmle.Extraction.CSharp/Entities/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ internal class Event : CachedSymbol<IEventSymbol>
private Event(Context cx, IEventSymbol init)
: base(cx, init) { }

protected override IEventSymbol BodyDeclaringSymbol => Symbol.PartialImplementationPart ?? Symbol;

public override Microsoft.CodeAnalysis.Location? ReportingLocation => BodyDeclaringSymbol.Locations.BestOrDefault();

public override void WriteId(EscapingTextWriter trapFile)
{
trapFile.WriteSubId(ContainingType!);
Expand All @@ -27,13 +31,13 @@ public override void Populate(TextWriter trapFile)
var type = Type.Create(Context, Symbol.Type);
trapFile.events(this, Symbol.GetName(), ContainingType!, type.TypeRef, Create(Context, Symbol.OriginalDefinition));

var adder = Symbol.AddMethod;
var remover = Symbol.RemoveMethod;
var adder = BodyDeclaringSymbol.AddMethod;
var remover = BodyDeclaringSymbol.RemoveMethod;

if (!(adder is null))
if (adder is not null)
Method.Create(Context, adder);

if (!(remover is null))
if (remover is not null)
Method.Create(Context, remover);

PopulateModifiers(trapFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ private EventAccessor(Context cx, IMethodSymbol init, IEventSymbol @event)
this.@event = @event;
}

public override bool NeedsPopulation =>
base.NeedsPopulation &&
!Symbol.IsPartialDefinition; // Accessors always have an implementing declaration as well.

/// <summary>
/// Gets the event symbol associated with accessor `symbol`, or `null`
/// if there is no associated symbol.
Expand Down