mirror of
https://github.com/github/codeql.git
synced 2026-02-23 10:23:41 +01:00
C#: Support for partial event declarations.
This commit is contained in:
@@ -11,6 +11,10 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
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!);
|
||||
@@ -27,13 +31,13 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
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);
|
||||
|
||||
@@ -13,6 +13,10 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user