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

Hi @norberth

We can confirm the false positive . I`ve created an issue on sonar-dotnet and you can track the progress here:

Thanks for your feedback!

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