// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-
-using System;
+#nullable enable
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
// Cached multicast delegate which will invoke all of the currently registered delegates. This
// will be accessed frequently in common coding paterns, so we don't want to calculate it repeatedly.
- private volatile T m_invokeList;
+ private volatile T m_invokeList = null!; // TODO-NULLABLE-GENERIC
public EventRegistrationTokenTable()
{
{
// The value being set replaces any of the existing values
m_tokens.Clear();
- m_invokeList = null;
+ m_invokeList = null!; // TODO-NULLABLE-GENERIC
if (value != null)
{
m_tokens[token] = handler;
// Update the current invocation list to include the newly added delegate
- Delegate invokeList = (Delegate)(object)m_invokeList;
+ Delegate? invokeList = (Delegate?)(object?)m_invokeList;
invokeList = MulticastDelegate.Combine(invokeList, (Delegate)(object)handler);
- m_invokeList = (T)(object)invokeList;
+ m_invokeList = (T)(object?)invokeList!; // TODO-NULLABLE-GENERIC
return token;
}
m_tokens.Remove(token);
// Update the current invocation list to remove the delegate
- Delegate invokeList = (Delegate)(object)m_invokeList;
- invokeList = MulticastDelegate.Remove(invokeList, (Delegate)(object)handler);
- m_invokeList = (T)(object)invokeList;
+ Delegate? invokeList = (Delegate?)(object?)m_invokeList;
+ invokeList = MulticastDelegate.Remove(invokeList, (Delegate?)(object?)handler);
+ m_invokeList = (T)(object?)invokeList!; // TODO-NULLABLE-GENERIC
}
}
- public static EventRegistrationTokenTable<T> GetOrCreateEventRegistrationTokenTable(ref EventRegistrationTokenTable<T> refEventTable)
+ public static EventRegistrationTokenTable<T> GetOrCreateEventRegistrationTokenTable(ref EventRegistrationTokenTable<T>? refEventTable)
{
if (refEventTable == null)
{
Interlocked.CompareExchange(ref refEventTable, new EventRegistrationTokenTable<T>(), null);
}
- return refEventTable;
+ return refEventTable!; // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
}
}
}