using System.Collections.Generic;
using System.Reflection;
-using System.Security;
+
+// This type is obsolete, and is expected to be used in very specific ways or it may
+// throw null reference exceptions.
+#pragma warning disable CS8610
namespace System.Runtime.InteropServices
{
public ComAwareEventInfo(Type type, string eventName)
{
- _innerEventInfo = type.GetEvent(eventName);
+ _innerEventInfo = type.GetEvent(eventName)!;
}
public override void AddEventHandler(object target, Delegate handler)
public override EventAttributes Attributes => _innerEventInfo.Attributes;
- public override MethodInfo GetAddMethod(bool nonPublic) => _innerEventInfo.GetAddMethod(nonPublic);
+ public override MethodInfo? GetAddMethod(bool nonPublic) => _innerEventInfo.GetAddMethod(nonPublic);
- public override MethodInfo[] GetOtherMethods(bool nonPublic) => _innerEventInfo.GetOtherMethods(nonPublic);
+ public override MethodInfo[]? GetOtherMethods(bool nonPublic) => _innerEventInfo.GetOtherMethods(nonPublic);
- public override MethodInfo GetRaiseMethod(bool nonPublic) => _innerEventInfo.GetRaiseMethod(nonPublic);
+ public override MethodInfo? GetRaiseMethod(bool nonPublic) => _innerEventInfo.GetRaiseMethod(nonPublic);
- public override MethodInfo GetRemoveMethod(bool nonPublic) => _innerEventInfo.GetRemoveMethod(nonPublic);
+ public override MethodInfo? GetRemoveMethod(bool nonPublic) => _innerEventInfo.GetRemoveMethod(nonPublic);
- public override Type DeclaringType => _innerEventInfo.DeclaringType;
+ public override Type? DeclaringType => _innerEventInfo.DeclaringType;
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
public override string Name => _innerEventInfo.Name;
- public override Type ReflectedType => _innerEventInfo.ReflectedType;
+ public override Type? ReflectedType => _innerEventInfo.ReflectedType;
private static void GetDataForComInvocation(EventInfo eventInfo, out Guid sourceIid, out int dispid)
{
- object[] comEventInterfaces = eventInfo.DeclaringType.GetCustomAttributes(typeof(ComEventInterfaceAttribute), inherit: false);
+ object[] comEventInterfaces = eventInfo.DeclaringType!.GetCustomAttributes(typeof(ComEventInterfaceAttribute), inherit: false);
if (comEventInterfaces == null || comEventInterfaces.Length == 0)
{
Type sourceInterface = ((ComEventInterfaceAttribute)comEventInterfaces[0]).SourceInterface;
Guid guid = sourceInterface.GUID;
- MethodInfo methodInfo = sourceInterface.GetMethod(eventInfo.Name);
- Attribute dispIdAttribute = Attribute.GetCustomAttribute(methodInfo, typeof(DispIdAttribute));
+ MethodInfo methodInfo = sourceInterface.GetMethod(eventInfo.Name)!;
+ Attribute? dispIdAttribute = Attribute.GetCustomAttribute(methodInfo, typeof(DispIdAttribute));
if (dispIdAttribute == null)
{
throw new InvalidOperationException(SR.InvalidOperation_NoDispIdAttribute);
private int[] _gcCounts = new int[3];
private int _gcGeneration = 0;
- public HandleCollector(string name, int initialThreshold) :
+ public HandleCollector(string? name, int initialThreshold) :
this(name, initialThreshold, int.MaxValue)
{
}
- public HandleCollector(string name, int initialThreshold, int maximumThreshold)
+ public HandleCollector(string? name, int initialThreshold, int maximumThreshold)
{
if (initialThreshold < 0)
{