Skip to content

Commit

Permalink
Allow non-IMemberDefinition sources to be origin for event methods (d…
Browse files Browse the repository at this point in the history
…otnet#102613)

There are some cases where an event may be marked by something that is not an IMemberDefinition, for example, an assembly level attribute. dotnet#102528 made an assumption that this was not possible and threw in those cases. This reverts the change related to that assumption.

Co-authored-by: Sven Boemer <[email protected]>
  • Loading branch information
2 people authored and Ruihan-Yin committed May 30, 2024
1 parent fb4484e commit 1282966
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/tools/illink/src/linker/Linker.Steps/MarkStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3508,9 +3508,7 @@ protected internal void MarkProperty (PropertyDefinition prop, in DependencyInfo

protected internal virtual void MarkEvent (EventDefinition evt, in DependencyInfo reason, MessageOrigin origin)
{
Debug.Assert (reason.Source is IMemberDefinition or null);
// Use reason as the origin for the event methods unless it's from a descriptor
origin = reason.Source is null ? origin : new MessageOrigin ((IMemberDefinition)reason.Source);
origin = reason.Source is IMemberDefinition member ? new MessageOrigin (member) : origin;
DependencyKind dependencyKind = DependencyKind.EventMethod;

MarkMethodIfNotNull (evt.AddMethod, new DependencyInfo (dependencyKind, evt), origin);
Expand Down

0 comments on commit 1282966

Please sign in to comment.