Skip to content

Fix S1144 FP: Event with a concrete sender #6990

@IeuanWalker

Description

@IeuanWalker

Description

If I create an event with a concreate sender it gives the warning S1144 (remove unused code)
i.e. this is gives a warning -

void CustomSwitch_SwitchPanUpdate(CustomSwitch customSwitch, SwitchPanUpdatedEventArgs e)

but this is fine -

void CustomSwitch_SwitchPanUpdate(object customSwitch, SwitchPanUpdatedEventArgs e)

Repro steps

In the CustomSwitch class i have this -

public delegate void CustomSwitchPanUpdatedEventHandler(CustomSwitch customSwitch, SwitchPanUpdatedEventArgs e);
public event CustomSwitchPanUpdatedEventHandler? SwitchPanUpdate;

And I trigger it like this -

SwitchPanUpdate?.Invoke(this, ev);

Then in a consuming class I have this -

void CustomSwitch_SwitchPanUpdate(CustomSwitch customSwitch, SwitchPanUpdatedEventArgs e)
{
	// Logic
}

Expected behaviour

No warning, first parament should be ignored and can be anything not just object

Actual behaviour

Warning

Known workarounds

Setting the first parameter as object

Metadata

Metadata

Labels

False PositiveRule IS triggered when it shouldn't be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions