Remove Unused Event

Hi there,

I’m seeing a False-Positive of rule csharpsquid:S3264 - it complains that an event is not invoked.
The specialty is that the event is invoked using the GetInvocationList followed by a BeginInvoke

The respective code looks as follows

private void RaiseEventAsync(LoggingEvent loggingEvent)
{
	if (MessageLogged != null)
	{
		var eventListeners = MessageLogged.GetInvocationList();

		foreach (var eventListener in eventListeners)
		{
			var methodToInvoke = (MessageLoggedEventHandler)eventListener;
			methodToInvoke.BeginInvoke(this, new LoggingEventArgs(loggingEvent.Level, loggingEvent.RenderedMessage), EndAsyncEvent, null);
		}
	}
}

I’m not sure if the rule can be amended to not trigger in such a situation.

Best regards
Norbert

Hi @norberth

We can confirm the false positive . I`ve created an issue on sonar-dotnet and you can track the progress here: https://github.com/SonarSource/sonar-dotnet/issues/3931

Thanks for your feedback!
Čaba

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.