Examples of errors detected by the V3084 diagnostic
V3084. Anonymous function is used to unsubscribe from event. No handlers will be unsubscribed, as a separate delegate instance is created for each anonymous function declaration.
PixiEditor
V3084 Anonymous function is used to unsubscribe from 'OnLanguageChanged' event. No handlers will be unsubscribed, as a separate delegate instance is created for each anonymous function declaration. Translator.cs 78
private static void UseLanguageFlowDirectionPropertyChanged(....)
{
....
if (!obj.NewValue.Value)
{
obj.Sender.SetValue(Control.FlowDirectionProperty,
FlowDirection.LeftToRight);
ILocalizationProvider.Current.OnLanguageChanged -=
(lang) => OnLanguageChangedFlowDirection(obj.Sender);
}
else
{
OnLanguageChangedFlowDirection(obj.Sender);
ILocalizationProvider.Current.OnLanguageChanged +=
(lang) => OnLanguageChangedFlowDirection(obj.Sender);
}
}
MSBuild
V3084 Anonymous function is used to unsubscribe from 'OnImmutablePathsInitialized' event. No handlers will be unsubscribed, as a separate delegate instance is created for each anonymous function declaration. CheckScopeClassifier.cs 67
private static void SubscribeImmutablePathsInitialized()
{
NotifyOnScopingReadiness?.Invoke();
FileClassifier.Shared.OnImmutablePathsInitialized -= () =>
NotifyOnScopingReadiness?.Invoke();
}