Initial roll out of !! (#64720)

* Bump version of C# compiler

This should be reverted when arcade brings in a new enough compiler.

* Fix a few new warnings from updating compiler

* Enable IDE0190 to employ parameter null checking

* Initial roll out of !!

* Fix more compiler warnings from upgrade, plus some test fixes / reverts

* Fix a few more tests

* Disable profiling test
This commit is contained in:
Stephen Toub 2022-02-08 16:06:59 -05:00 committed by GitHub
parent 97fc0a45f1
commit 3ae87395f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1232 changed files with 4539 additions and 21371 deletions

View File

@ -1539,6 +1539,9 @@ dotnet_diagnostic.IDE0160.severity = silent
# IDE0161: Convert to file-scoped namespace
dotnet_diagnostic.IDE0161.severity = silent
# IDE0190: Null check can be simplified
dotnet_diagnostic.IDE0190.severity = suggestion
# IDE1005: Delegate invocation can be simplified.
dotnet_diagnostic.IDE1005.severity = suggestion

View File

@ -1536,6 +1536,9 @@ dotnet_diagnostic.IDE0160.severity = silent
# IDE0161: Convert to file-scoped namespace
dotnet_diagnostic.IDE0161.severity = silent
# IDE0190: Null check can be simplified
dotnet_diagnostic.IDE0190.severity = silent
# IDE1005: Delegate invocation can be simplified.
dotnet_diagnostic.IDE1005.severity = silent

View File

@ -20,6 +20,7 @@
<UsingToolIbcOptimization>false</UsingToolIbcOptimization>
<UsingToolXliff>false</UsingToolXliff>
<LastReleasedStableAssemblyVersion>$(AssemblyVersion)</LastReleasedStableAssemblyVersion>
<UsingToolMicrosoftNetCompilers>true</UsingToolMicrosoftNetCompilers>
</PropertyGroup>
<!--
Servicing build settings for Setup/Installer packages. Instructions:
@ -51,6 +52,8 @@
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.0.1</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisCSharpVersion>4.0.1</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>7.0.0-preview1.22102.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<!-- TODO: Remove pinned compiler version once arcade supplies runtime with a compiler capable of handling !! -->
<MicrosoftNetCompilersToolsetVersion>4.2.0-2.22105.4</MicrosoftNetCompilersToolsetVersion>
<!-- SDK dependencies -->
<MicrosoftDotNetCompatibilityVersion>2.0.0-alpha.1.21525.11</MicrosoftDotNetCompatibilityVersion>
<!-- Arcade dependencies -->

View File

@ -72,12 +72,8 @@ namespace Microsoft.Win32
* Variant and the types that CLR supports explicitly in the
* CLR Variant class.
*/
internal static Variant ChangeType(Variant source, Type targetClass, short options, CultureInfo culture)
internal static Variant ChangeType(Variant source, Type targetClass!!, short options, CultureInfo culture!!)
{
if (targetClass == null)
throw new ArgumentNullException(nameof(targetClass));
if (culture == null)
throw new ArgumentNullException(nameof(culture));
Variant result = default;
ChangeTypeEx(ref result, ref source,
culture.LCID,

View File

@ -450,14 +450,8 @@ namespace System
return GetCustomAttributes(element, attributeType, true);
}
public static Attribute[] GetCustomAttributes(MemberInfo element, Type attributeType, bool inherit)
public static Attribute[] GetCustomAttributes(MemberInfo element!!, Type attributeType!!, bool inherit)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
@ -474,11 +468,8 @@ namespace System
return GetCustomAttributes(element, true);
}
public static Attribute[] GetCustomAttributes(MemberInfo element, bool inherit)
public static Attribute[] GetCustomAttributes(MemberInfo element!!, bool inherit)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
return element.MemberType switch
{
MemberTypes.Property => InternalGetCustomAttributes((PropertyInfo)element, typeof(Attribute), inherit),
@ -492,15 +483,9 @@ namespace System
return IsDefined(element, attributeType, true);
}
public static bool IsDefined(MemberInfo element, Type attributeType, bool inherit)
public static bool IsDefined(MemberInfo element!!, Type attributeType!!, bool inherit)
{
// Returns true if a custom attribute subclass of attributeType class/interface with inheritance walk
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
@ -543,14 +528,8 @@ namespace System
return GetCustomAttributes(element, attributeType, true);
}
public static Attribute[] GetCustomAttributes(ParameterInfo element, Type attributeType, bool inherit)
public static Attribute[] GetCustomAttributes(ParameterInfo element!!, Type attributeType!!, bool inherit)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
@ -565,11 +544,8 @@ namespace System
return (element.GetCustomAttributes(attributeType, inherit) as Attribute[])!;
}
public static Attribute[] GetCustomAttributes(ParameterInfo element, bool inherit)
public static Attribute[] GetCustomAttributes(ParameterInfo element!!, bool inherit)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
if (element.Member == null)
throw new ArgumentException(SR.Argument_InvalidParameterInfo, nameof(element));
@ -586,14 +562,9 @@ namespace System
return IsDefined(element, attributeType, true);
}
public static bool IsDefined(ParameterInfo element, Type attributeType, bool inherit)
public static bool IsDefined(ParameterInfo element!!, Type attributeType!!, bool inherit)
{
// Returns true is a custom attribute subclass of attributeType class/interface with inheritance walk
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
@ -653,22 +624,13 @@ namespace System
return GetCustomAttributes(element, true);
}
public static Attribute[] GetCustomAttributes(Module element, bool inherit)
public static Attribute[] GetCustomAttributes(Module element!!, bool inherit)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
return (Attribute[])element.GetCustomAttributes(typeof(Attribute), inherit);
}
public static Attribute[] GetCustomAttributes(Module element, Type attributeType, bool inherit)
public static Attribute[] GetCustomAttributes(Module element!!, Type attributeType!!, bool inherit)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
@ -680,14 +642,9 @@ namespace System
return IsDefined(element, attributeType, false);
}
public static bool IsDefined(Module element, Type attributeType, bool inherit)
public static bool IsDefined(Module element!!, Type attributeType!!, bool inherit)
{
// Returns true is a custom attribute subclass of attributeType class/interface with no inheritance walk
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
@ -723,14 +680,8 @@ namespace System
return GetCustomAttributes(element, attributeType, true);
}
public static Attribute[] GetCustomAttributes(Assembly element, Type attributeType, bool inherit)
public static Attribute[] GetCustomAttributes(Assembly element!!, Type attributeType!!, bool inherit)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
@ -742,11 +693,8 @@ namespace System
return GetCustomAttributes(element, true);
}
public static Attribute[] GetCustomAttributes(Assembly element, bool inherit)
public static Attribute[] GetCustomAttributes(Assembly element!!, bool inherit)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
return (Attribute[])element.GetCustomAttributes(typeof(Attribute), inherit);
}
@ -755,14 +703,9 @@ namespace System
return IsDefined(element, attributeType, true);
}
public static bool IsDefined(Assembly element, Type attributeType, bool inherit)
public static bool IsDefined(Assembly element!!, Type attributeType!!, bool inherit)
{
// Returns true is a custom attribute subclass of attributeType class/interface with no inheritance walk
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);

View File

@ -33,11 +33,8 @@ namespace System.Collections
// ICollection members
public void CopyTo(Array array, int index)
public void CopyTo(Array array!!, int index)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
if (array.Rank != 1)
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported);
@ -58,23 +55,14 @@ namespace System.Collections
// IDictionary members
public object? this[object key]
public object? this[object key!!]
{
get
{
if (key == null)
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
return null;
}
set
{
if (key == null)
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
if (!key.GetType().IsSerializable)
throw new ArgumentException(SR.Argument_NotSerializable, nameof(key));
@ -94,13 +82,8 @@ namespace System.Collections
return false;
}
public void Add(object key, object? value)
public void Add(object key!!, object? value)
{
if (key == null)
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
if (!key.GetType().IsSerializable)
throw new ArgumentException(SR.Argument_NotSerializable, nameof(key));

View File

@ -34,14 +34,8 @@ namespace System
// This constructor is called from the class generated by the
// compiler generated code
[RequiresUnreferencedCode("The target method might be removed")]
protected Delegate(object target, string method)
protected Delegate(object target!!, string method!!)
{
if (target == null)
throw new ArgumentNullException(nameof(target));
if (method == null)
throw new ArgumentNullException(nameof(method));
// This API existed in v1/v1.1 and only expected to create closed
// instance delegates. Constrain the call to BindToMethodName to
// such and don't allow relaxed signature matching (which could make
@ -57,17 +51,10 @@ namespace System
// This constructor is called from a class to generate a
// delegate based upon a static method name and the Type object
// for the class defining the method.
protected Delegate([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type target, string method)
protected Delegate([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type target!!, string method!!)
{
if (target == null)
throw new ArgumentNullException(nameof(target));
if (target.ContainsGenericParameters)
throw new ArgumentException(SR.Arg_UnboundGenParam, nameof(target));
if (method == null)
throw new ArgumentNullException(nameof(method));
if (!(target is RuntimeType rtTarget))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(target));
@ -220,15 +207,8 @@ namespace System
// V1 API.
[RequiresUnreferencedCode("The target method might be removed")]
public static Delegate? CreateDelegate(Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure)
public static Delegate? CreateDelegate(Type type!!, object target!!, string method!!, bool ignoreCase, bool throwOnBindFailure)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
if (target == null)
throw new ArgumentNullException(nameof(target));
if (method == null)
throw new ArgumentNullException(nameof(method));
if (!(type is RuntimeType rtType))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type));
if (!rtType.IsDelegate())
@ -258,17 +238,10 @@ namespace System
}
// V1 API.
public static Delegate? CreateDelegate(Type type, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type target, string method, bool ignoreCase, bool throwOnBindFailure)
public static Delegate? CreateDelegate(Type type!!, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type target!!, string method!!, bool ignoreCase, bool throwOnBindFailure)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
if (target == null)
throw new ArgumentNullException(nameof(target));
if (target.ContainsGenericParameters)
throw new ArgumentException(SR.Arg_UnboundGenParam, nameof(target));
if (method == null)
throw new ArgumentNullException(nameof(method));
if (!(type is RuntimeType rtType))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type));
if (!(target is RuntimeType rtTarget))
@ -297,13 +270,9 @@ namespace System
}
// V1 API.
public static Delegate? CreateDelegate(Type type, MethodInfo method, bool throwOnBindFailure)
public static Delegate? CreateDelegate(Type type!!, MethodInfo method!!, bool throwOnBindFailure)
{
// Validate the parameters.
if (type == null)
throw new ArgumentNullException(nameof(type));
if (method == null)
throw new ArgumentNullException(nameof(method));
if (!(type is RuntimeType rtType))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type));
@ -374,11 +343,9 @@ namespace System
//
// V2 internal API.
internal static Delegate CreateDelegateNoSecurityCheck(Type type, object? target, RuntimeMethodHandle method)
internal static Delegate CreateDelegateNoSecurityCheck(Type type!!, object? target, RuntimeMethodHandle method)
{
// Validate the parameters.
if (type == null)
throw new ArgumentNullException(nameof(type));
if (method.IsNullHandle())
throw new ArgumentNullException(nameof(method));

View File

@ -303,10 +303,8 @@ namespace System
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void _SuppressFinalize(object o);
public static void SuppressFinalize(object obj)
public static void SuppressFinalize(object obj!!)
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
_SuppressFinalize(obj);
}
@ -317,10 +315,8 @@ namespace System
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void _ReRegisterForFinalize(object o);
public static void ReRegisterForFinalize(object obj)
public static void ReRegisterForFinalize(object obj!!)
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
_ReRegisterForFinalize(obj);
}
@ -609,10 +605,7 @@ namespace System
{
throw new ArgumentOutOfRangeException(nameof(lowMemoryPercent));
}
if (notification == null)
{
throw new ArgumentNullException(nameof(notification));
}
ArgumentNullException.ThrowIfNull(notification);
lock (s_notifications)
{
@ -625,13 +618,8 @@ namespace System
}
}
internal static void UnregisterMemoryLoadChangeNotification(Action notification)
internal static void UnregisterMemoryLoadChangeNotification(Action notification!!)
{
if (notification == null)
{
throw new ArgumentNullException(nameof(notification));
}
lock (s_notifications)
{
for (int i = 0; i < s_notifications.Count; ++i)

View File

@ -23,11 +23,8 @@ namespace System.Reflection
[Obsolete("Assembly.LoadWithPartialName has been deprecated. Use Assembly.Load() instead.")]
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly? LoadWithPartialName(string partialName)
public static Assembly? LoadWithPartialName(string partialName!!)
{
if (partialName == null)
throw new ArgumentNullException(nameof(partialName));
if ((partialName.Length == 0) || (partialName[0] == '\0'))
throw new ArgumentException(SR.Format_StringZeroLength, nameof(partialName));
@ -45,11 +42,8 @@ namespace System.Reflection
// Locate an assembly by its name. The name can be strong or
// weak. The assembly is loaded into the domain of the caller.
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly Load(AssemblyName assemblyRef)
public static Assembly Load(AssemblyName assemblyRef!!)
{
if (assemblyRef == null)
throw new ArgumentNullException(nameof(assemblyRef));
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeAssembly.InternalLoad(assemblyRef, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext);
}

View File

@ -57,16 +57,12 @@ namespace System.Reflection.Emit
#region Constructor
internal AssemblyBuilder(AssemblyName name,
internal AssemblyBuilder(AssemblyName name!!,
AssemblyBuilderAccess access,
Assembly? callingAssembly,
AssemblyLoadContext? assemblyLoadContext,
IEnumerable<CustomAttributeBuilder>? unsafeAssemblyAttributes)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (access != AssemblyBuilderAccess.Run && access != AssemblyBuilderAccess.RunAndCollect)
{
throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)access), nameof(access));
@ -371,17 +367,8 @@ namespace System.Reflection.Emit
/// <summary>
/// Use this function if client decides to form the custom attribute blob themselves.
/// </summary>
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
public void SetCustomAttribute(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con == null)
{
throw new ArgumentNullException(nameof(con));
}
if (binaryAttribute == null)
{
throw new ArgumentNullException(nameof(binaryAttribute));
}
lock (SyncRoot)
{
TypeBuilder.DefineCustomAttribute(
@ -395,13 +382,8 @@ namespace System.Reflection.Emit
/// <summary>
/// Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder.
/// </summary>
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
public void SetCustomAttribute(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder == null)
{
throw new ArgumentNullException(nameof(customBuilder));
}
lock (SyncRoot)
{
customBuilder.CreateCustomAttribute(_manifestModuleBuilder, AssemblyBuilderData.AssemblyDefToken);

View File

@ -48,20 +48,8 @@ namespace System.Reflection.Emit
// public constructor to form the custom attribute with constructor and constructor
// parameters.
public CustomAttributeBuilder(ConstructorInfo con, object?[] constructorArgs, PropertyInfo[] namedProperties, object?[] propertyValues, FieldInfo[] namedFields, object?[] fieldValues)
public CustomAttributeBuilder(ConstructorInfo con!!, object?[] constructorArgs!!, PropertyInfo[] namedProperties!!, object?[] propertyValues!!, FieldInfo[] namedFields!!, object?[] fieldValues!!)
{
if (con == null)
throw new ArgumentNullException(nameof(con));
if (constructorArgs == null)
throw new ArgumentNullException(nameof(constructorArgs));
if (namedProperties == null)
throw new ArgumentNullException(nameof(namedProperties));
if (propertyValues == null)
throw new ArgumentNullException(nameof(propertyValues));
if (namedFields == null)
throw new ArgumentNullException(nameof(namedFields));
if (fieldValues == null)
throw new ArgumentNullException(nameof(fieldValues));
#pragma warning disable CA2208 // Instantiate argument exceptions correctly, combination of arguments used
if (namedProperties.Length != propertyValues.Length)
throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedProperties, propertyValues");

View File

@ -32,11 +32,9 @@ namespace System.Reflection.Emit
// *** ILGenerator api ***
public override LocalBuilder DeclareLocal(Type localType, bool pinned)
public override LocalBuilder DeclareLocal(Type localType!!, bool pinned)
{
LocalBuilder localBuilder;
if (localType == null)
throw new ArgumentNullException(nameof(localType));
RuntimeType? rtType = localType as RuntimeType;
@ -55,11 +53,8 @@ namespace System.Reflection.Emit
// Token resolution calls
//
//
public override void Emit(OpCode opcode, MethodInfo meth)
public override void Emit(OpCode opcode, MethodInfo meth!!)
{
if (meth == null)
throw new ArgumentNullException(nameof(meth));
int stackchange = 0;
int token;
DynamicMethod? dynMeth = meth as DynamicMethod;
@ -110,11 +105,8 @@ namespace System.Reflection.Emit
PutInteger4(token);
}
public override void Emit(OpCode opcode, ConstructorInfo con)
public override void Emit(OpCode opcode, ConstructorInfo con!!)
{
if (con == null)
throw new ArgumentNullException(nameof(con));
RuntimeConstructorInfo? rtConstructor = con as RuntimeConstructorInfo;
if (rtConstructor == null)
throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(con));
@ -137,11 +129,8 @@ namespace System.Reflection.Emit
PutInteger4(token);
}
public override void Emit(OpCode opcode, Type type)
public override void Emit(OpCode opcode, Type type!!)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
RuntimeType? rtType = type as RuntimeType;
if (rtType == null)
@ -153,11 +142,8 @@ namespace System.Reflection.Emit
PutInteger4(token);
}
public override void Emit(OpCode opcode, FieldInfo field)
public override void Emit(OpCode opcode, FieldInfo field!!)
{
if (field == null)
throw new ArgumentNullException(nameof(field));
RuntimeFieldInfo? runtimeField = field as RuntimeFieldInfo;
if (runtimeField == null)
throw new ArgumentException(SR.Argument_MustBeRuntimeFieldInfo, nameof(field));
@ -173,11 +159,8 @@ namespace System.Reflection.Emit
PutInteger4(token);
}
public override void Emit(OpCode opcode, string str)
public override void Emit(OpCode opcode, string str!!)
{
if (str == null)
throw new ArgumentNullException(nameof(str));
int tempVal = GetTokenForString(str);
EnsureCapacity(7);
InternalEmit(opcode);
@ -264,11 +247,8 @@ namespace System.Reflection.Emit
PutInteger4(token);
}
public override void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optionalParameterTypes)
public override void EmitCall(OpCode opcode, MethodInfo methodInfo!!, Type[]? optionalParameterTypes)
{
if (methodInfo == null)
throw new ArgumentNullException(nameof(methodInfo));
if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj)))
throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode));
@ -303,11 +283,8 @@ namespace System.Reflection.Emit
PutInteger4(tk);
}
public override void Emit(OpCode opcode, SignatureHelper signature)
public override void Emit(OpCode opcode, SignatureHelper signature!!)
{
if (signature == null)
throw new ArgumentNullException(nameof(signature));
int stackchange = 0;
EnsureCapacity(7);
InternalEmit(opcode);
@ -376,8 +353,7 @@ namespace System.Reflection.Emit
else
{
// execute this branch if previous clause is Catch or Fault
if (exceptionType == null)
throw new ArgumentNullException(nameof(exceptionType));
ArgumentNullException.ThrowIfNull(exceptionType);
if (rtType == null)
throw new ArgumentException(SR.Argument_MustBeRuntimeType);
@ -895,8 +871,8 @@ namespace System.Reflection.Emit
{
if (codeSize < 0)
throw new ArgumentOutOfRangeException(nameof(codeSize), SR.ArgumentOutOfRange_GenericPositive);
if (codeSize > 0 && code == null)
throw new ArgumentNullException(nameof(code));
if (codeSize > 0)
ArgumentNullException.ThrowIfNull(code);
m_code = new Span<byte>(code, codeSize).ToArray();
m_maxStackSize = maxStackSize;
@ -913,8 +889,8 @@ namespace System.Reflection.Emit
if (exceptionsSize < 0)
throw new ArgumentOutOfRangeException(nameof(exceptionsSize), SR.ArgumentOutOfRange_GenericPositive);
if (exceptionsSize > 0 && exceptions == null)
throw new ArgumentNullException(nameof(exceptions));
if (exceptionsSize > 0)
ArgumentNullException.ThrowIfNull(exceptions);
m_exceptions = new Span<byte>(exceptions, exceptionsSize).ToArray();
}
@ -930,8 +906,8 @@ namespace System.Reflection.Emit
if (signatureSize < 0)
throw new ArgumentOutOfRangeException(nameof(signatureSize), SR.ArgumentOutOfRange_GenericPositive);
if (signatureSize > 0 && localSignature == null)
throw new ArgumentNullException(nameof(localSignature));
if (signatureSize > 0)
ArgumentNullException.ThrowIfNull(localSignature);
m_localSignature = new Span<byte>(localSignature, signatureSize).ToArray();
}

View File

@ -83,11 +83,8 @@ namespace System.Reflection.Emit
public DynamicMethod(string name,
Type? returnType,
Type[]? parameterTypes,
Module m)
Module m!!)
{
if (m == null)
throw new ArgumentNullException(nameof(m));
Init(name,
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard,
@ -102,12 +99,9 @@ namespace System.Reflection.Emit
public DynamicMethod(string name,
Type? returnType,
Type[]? parameterTypes,
Module m,
Module m!!,
bool skipVisibility)
{
if (m == null)
throw new ArgumentNullException(nameof(m));
Init(name,
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard,
@ -124,12 +118,9 @@ namespace System.Reflection.Emit
CallingConventions callingConvention,
Type? returnType,
Type[]? parameterTypes,
Module m,
Module m!!,
bool skipVisibility)
{
if (m == null)
throw new ArgumentNullException(nameof(m));
Init(name,
attributes,
callingConvention,
@ -144,11 +135,8 @@ namespace System.Reflection.Emit
public DynamicMethod(string name,
Type? returnType,
Type[]? parameterTypes,
Type owner)
Type owner!!)
{
if (owner == null)
throw new ArgumentNullException(nameof(owner));
Init(name,
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard,
@ -163,12 +151,9 @@ namespace System.Reflection.Emit
public DynamicMethod(string name,
Type? returnType,
Type[]? parameterTypes,
Type owner,
Type owner!!,
bool skipVisibility)
{
if (owner == null)
throw new ArgumentNullException(nameof(owner));
Init(name,
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard,
@ -185,12 +170,9 @@ namespace System.Reflection.Emit
CallingConventions callingConvention,
Type? returnType,
Type[]? parameterTypes,
Type owner,
Type owner!!,
bool skipVisibility)
{
if (owner == null)
throw new ArgumentNullException(nameof(owner));
Init(name,
attributes,
callingConvention,
@ -253,17 +235,17 @@ namespace System.Reflection.Emit
[MemberNotNull(nameof(m_parameterTypes))]
[MemberNotNull(nameof(m_returnType))]
[MemberNotNull(nameof(m_dynMethod))]
private void Init(string name,
MethodAttributes attributes,
CallingConventions callingConvention,
Type? returnType,
Type[]? signature,
Type? owner,
Module? m,
bool skipVisibility,
bool transparentMethod)
private void Init(string name!!,
MethodAttributes attributes,
CallingConventions callingConvention,
Type? returnType,
Type[]? signature,
Type? owner,
Module? m,
bool skipVisibility,
bool transparentMethod)
{
DynamicMethod.CheckConsistency(attributes, callingConvention);
CheckConsistency(attributes, callingConvention);
// check and store the signature
if (signature != null)
@ -329,10 +311,6 @@ namespace System.Reflection.Emit
m_ilGenerator = null;
m_fInitLocals = true;
m_methodHandle = null;
if (name == null)
throw new ArgumentNullException(nameof(name));
m_dynMethod = new RTDynamicMethod(this, name, attributes, callingConvention);
}
@ -655,11 +633,8 @@ namespace System.Reflection.Emit
return new object[] { new MethodImplAttribute((MethodImplOptions)GetMethodImplementationFlags()) };
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute)))
return true;
else

View File

@ -46,13 +46,8 @@ namespace System.Reflection.Emit
return m_evToken;
}
private void SetMethodSemantics(MethodBuilder mdBuilder, MethodSemanticsAttributes semantics)
private void SetMethodSemantics(MethodBuilder mdBuilder!!, MethodSemanticsAttributes semantics)
{
if (mdBuilder == null)
{
throw new ArgumentNullException(nameof(mdBuilder));
}
m_type.ThrowIfCreated();
ModuleBuilder module = m_module;
TypeBuilder.DefineMethodSemantics(
@ -84,12 +79,8 @@ namespace System.Reflection.Emit
// Use this function if client decides to form the custom attribute blob themselves
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
public void SetCustomAttribute(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con == null)
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
m_type.ThrowIfCreated();
TypeBuilder.DefineCustomAttribute(
@ -100,12 +91,8 @@ namespace System.Reflection.Emit
}
// Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
public void SetCustomAttribute(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder == null)
{
throw new ArgumentNullException(nameof(customBuilder));
}
m_type.ThrowIfCreated();
customBuilder.CreateCustomAttribute(m_module, m_evToken);
}

View File

@ -154,14 +154,8 @@ namespace System.Reflection.Emit
TypeBuilder.SetConstantValue(m_typeBuilder.GetModuleBuilder(), m_fieldTok, m_fieldType, defaultValue);
}
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
public void SetCustomAttribute(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con == null)
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
ModuleBuilder module = (m_typeBuilder.Module as ModuleBuilder)!;
m_typeBuilder.ThrowIfCreated();
@ -170,11 +164,8 @@ namespace System.Reflection.Emit
m_fieldTok, module.GetConstructorToken(con), binaryAttribute);
}
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
public void SetCustomAttribute(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder == null)
throw new ArgumentNullException(nameof(customBuilder));
m_typeBuilder.ThrowIfCreated();
ModuleBuilder? module = m_typeBuilder.Module as ModuleBuilder;

View File

@ -474,11 +474,8 @@ namespace System.Reflection.Emit
PutInteger4(arg);
}
public virtual void Emit(OpCode opcode, MethodInfo meth)
public virtual void Emit(OpCode opcode, MethodInfo meth!!)
{
if (meth == null)
throw new ArgumentNullException(nameof(meth));
if (opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj))
{
EmitCall(opcode, meth, null);
@ -586,11 +583,8 @@ namespace System.Reflection.Emit
PutInteger4(modBuilder.GetSignatureToken(sig));
}
public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optionalParameterTypes)
public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo!!, Type[]? optionalParameterTypes)
{
if (methodInfo == null)
throw new ArgumentNullException(nameof(methodInfo));
if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj)))
throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode));
@ -621,11 +615,8 @@ namespace System.Reflection.Emit
PutInteger4(tk);
}
public virtual void Emit(OpCode opcode, SignatureHelper signature)
public virtual void Emit(OpCode opcode, SignatureHelper signature!!)
{
if (signature == null)
throw new ArgumentNullException(nameof(signature));
int stackchange = 0;
ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module;
int sig = modBuilder.GetSignatureToken(signature);
@ -655,11 +646,8 @@ namespace System.Reflection.Emit
PutInteger4(tempVal);
}
public virtual void Emit(OpCode opcode, ConstructorInfo con)
public virtual void Emit(OpCode opcode, ConstructorInfo con!!)
{
if (con == null)
throw new ArgumentNullException(nameof(con));
int stackchange = 0;
// Constructors cannot be generic so the value of UseMethodDef doesn't matter.
@ -772,11 +760,8 @@ namespace System.Reflection.Emit
}
}
public virtual void Emit(OpCode opcode, Label[] labels)
public virtual void Emit(OpCode opcode, Label[] labels!!)
{
if (labels == null)
throw new ArgumentNullException(nameof(labels));
// Emitting a switch table
int i;
@ -818,14 +803,9 @@ namespace System.Reflection.Emit
PutInteger4(tempVal);
}
public virtual void Emit(OpCode opcode, LocalBuilder local)
public virtual void Emit(OpCode opcode, LocalBuilder local!!)
{
// Puts the opcode onto the IL stream followed by the information for local variable local.
if (local == null)
{
throw new ArgumentNullException(nameof(local));
}
int tempVal = local.GetLocalIndex();
if (local.GetMethodBuilder() != m_methodBuilder)
{
@ -1022,10 +1002,7 @@ namespace System.Reflection.Emit
else
{
// execute this branch if previous clause is Catch or Fault
if (exceptionType == null)
{
throw new ArgumentNullException(nameof(exceptionType));
}
ArgumentNullException.ThrowIfNull(exceptionType);
Emit(OpCodes.Leave, current.GetEndLabel());
}
@ -1188,18 +1165,13 @@ namespace System.Reflection.Emit
Emit(OpCodes.Callvirt, mi);
}
public virtual void EmitWriteLine(FieldInfo fld)
public virtual void EmitWriteLine(FieldInfo fld!!)
{
// Emits the IL necessary to call WriteLine with fld. It is
// an error to call EmitWriteLine with a fld which is not of
// one of the types for which Console.WriteLine implements overloads. (e.g.
// we do *not* call ToString on the fields.
if (fld == null)
{
throw new ArgumentNullException(nameof(fld));
}
Type consoleType = Type.GetType(ConsoleTypeFullName, throwOnError: true)!;
MethodInfo prop = consoleType.GetMethod("get_Out")!;
Emit(OpCodes.Call, prop);
@ -1252,10 +1224,7 @@ namespace System.Reflection.Emit
throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated);
}
if (localType == null)
{
throw new ArgumentNullException(nameof(localType));
}
ArgumentNullException.ThrowIfNull(localType);
if (methodBuilder.m_bIsBaked)
{

View File

@ -130,14 +130,10 @@ namespace System.Reflection.Emit
#region Internal Members
internal void CreateMethodBodyHelper(ILGenerator il)
internal void CreateMethodBodyHelper(ILGenerator il!!)
{
// Sets the IL of the method. An ILGenerator is passed as an argument and the method
// queries this instance to get all of the information which it needs.
if (il == null)
{
throw new ArgumentNullException(nameof(il));
}
__ExceptionInfo[] excp;
int counter = 0;
@ -517,11 +513,8 @@ namespace System.Reflection.Emit
return MethodBuilderInstantiation.MakeGenericMethod(this, typeArguments);
}
public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names)
public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names!!)
{
if (names == null)
throw new ArgumentNullException(nameof(names));
if (names.Length == 0)
throw new ArgumentException(SR.Arg_EmptyArray, nameof(names));
@ -529,8 +522,7 @@ namespace System.Reflection.Emit
throw new InvalidOperationException(SR.InvalidOperation_GenericParametersAlreadySet);
for (int i = 0; i < names.Length; i++)
if (names[i] == null)
throw new ArgumentNullException(nameof(names));
ArgumentNullException.ThrowIfNull(names[i], nameof(names));
if (m_token != 0)
throw new InvalidOperationException(SR.InvalidOperation_MethodBuilderBaked);
@ -734,13 +726,8 @@ namespace System.Reflection.Emit
return GetModuleBuilder();
}
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
public void SetCustomAttribute(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con is null)
throw new ArgumentNullException(nameof(con));
if (binaryAttribute is null)
throw new ArgumentNullException(nameof(binaryAttribute));
ThrowIfGeneric();
TypeBuilder.DefineCustomAttribute(m_module, MetadataToken,
@ -751,11 +738,8 @@ namespace System.Reflection.Emit
ParseCA(con);
}
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
public void SetCustomAttribute(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder == null)
throw new ArgumentNullException(nameof(customBuilder));
ThrowIfGeneric();
customBuilder.CreateCustomAttribute((ModuleBuilder)m_module, MetadataToken);

View File

@ -216,14 +216,9 @@ namespace System.Reflection.Emit
return GetTypeRef(new QCallModule(ref thisModule), typeName, new QCallModule(ref refedRuntimeModule), strRefedModuleFileName, tkResolution);
}
internal int InternalGetConstructorToken(ConstructorInfo con, bool usingRef)
internal int InternalGetConstructorToken(ConstructorInfo con!!, bool usingRef)
{
// Helper to get constructor token. If usingRef is true, we will never use the def token
if (con == null)
{
throw new ArgumentNullException(nameof(con));
}
int tr;
int mr;
@ -1033,13 +1028,8 @@ namespace System.Reflection.Emit
return GetTypeTokenInternal(type, getGenericDefinition: true);
}
private int GetTypeTokenWorkerNoLock(Type type, bool getGenericDefinition)
private int GetTypeTokenWorkerNoLock(Type type!!, bool getGenericDefinition)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
AssemblyBuilder.CheckContext(type);
// Return a token for the class relative to the Module. Tokens
@ -1131,15 +1121,10 @@ namespace System.Reflection.Emit
// 1. GetMethodToken
// 2. ldtoken (see ILGenerator)
// For all other occasions we should return the method on the generic type instantiated on the formal parameters.
private int GetMethodTokenNoLock(MethodInfo method, bool getGenericTypeDefinition)
private int GetMethodTokenNoLock(MethodInfo method!!, bool getGenericTypeDefinition)
{
// Return a MemberRef token if MethodInfo is not defined in this module. Or
// return the MethodDef token.
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
int tr;
int mr;
@ -1370,13 +1355,8 @@ namespace System.Reflection.Emit
}
}
private int GetFieldTokenNoLock(FieldInfo field)
private int GetFieldTokenNoLock(FieldInfo field!!)
{
if (field == null)
{
throw new ArgumentNullException(nameof(field));
}
int tr;
int mr;
@ -1448,41 +1428,26 @@ namespace System.Reflection.Emit
return mr;
}
internal int GetStringConstant(string str)
internal int GetStringConstant(string str!!)
{
if (str == null)
{
throw new ArgumentNullException(nameof(str));
}
// Returns a token representing a String constant. If the string
// value has already been defined, the existing token will be returned.
ModuleBuilder thisModule = this;
return GetStringConstant(new QCallModule(ref thisModule), str, str.Length);
}
internal int GetSignatureToken(SignatureHelper sigHelper)
internal int GetSignatureToken(SignatureHelper sigHelper!!)
{
// Define signature token given a signature helper. This will define a metadata
// token for the signature described by SignatureHelper.
if (sigHelper == null)
{
throw new ArgumentNullException(nameof(sigHelper));
}
// get the signature in byte form
// Get the signature in byte form.
byte[] sigBytes = sigHelper.InternalGetSignature(out int sigLength);
ModuleBuilder thisModule = this;
return TypeBuilder.GetTokenFromSig(new QCallModule(ref thisModule), sigBytes, sigLength);
}
internal int GetSignatureToken(byte[] sigBytes, int sigLength)
internal int GetSignatureToken(byte[] sigBytes!!, int sigLength)
{
if (sigBytes == null)
{
throw new ArgumentNullException(nameof(sigBytes));
}
byte[] localSigBytes = new byte[sigBytes.Length];
Buffer.BlockCopy(sigBytes, 0, localSigBytes, 0, sigBytes.Length);
@ -1494,17 +1459,8 @@ namespace System.Reflection.Emit
#region Other
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
public void SetCustomAttribute(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con == null)
{
throw new ArgumentNullException(nameof(con));
}
if (binaryAttribute == null)
{
throw new ArgumentNullException(nameof(binaryAttribute));
}
TypeBuilder.DefineCustomAttribute(
this,
1, // This is hard coding the module token to 1
@ -1512,13 +1468,8 @@ namespace System.Reflection.Emit
binaryAttribute);
}
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
public void SetCustomAttribute(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder == null)
{
throw new ArgumentNullException(nameof(customBuilder));
}
customBuilder.CreateCustomAttribute(this, 1); // This is hard coding the module token to 1
}

View File

@ -18,17 +18,8 @@ namespace System.Reflection.Emit
}
// Use this function if client decides to form the custom attribute blob themselves
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
public void SetCustomAttribute(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con == null)
{
throw new ArgumentNullException(nameof(con));
}
if (binaryAttribute == null)
{
throw new ArgumentNullException(nameof(binaryAttribute));
}
TypeBuilder.DefineCustomAttribute(
_methodBuilder.GetModuleBuilder(),
_token,
@ -37,12 +28,8 @@ namespace System.Reflection.Emit
}
// Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
public void SetCustomAttribute(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder == null)
{
throw new ArgumentNullException(nameof(customBuilder));
}
customBuilder.CreateCustomAttribute((ModuleBuilder)(_methodBuilder.GetModule()), _token);
}

View File

@ -67,13 +67,8 @@ namespace System.Reflection.Emit
public override Module Module => m_containingType.Module;
private void SetMethodSemantics(MethodBuilder mdBuilder, MethodSemanticsAttributes semantics)
private void SetMethodSemantics(MethodBuilder mdBuilder!!, MethodSemanticsAttributes semantics)
{
if (mdBuilder == null)
{
throw new ArgumentNullException(nameof(mdBuilder));
}
m_containingType.ThrowIfCreated();
ModuleBuilder module = m_moduleBuilder;
TypeBuilder.DefineMethodSemantics(
@ -102,13 +97,8 @@ namespace System.Reflection.Emit
// Use this function if client decides to form the custom attribute blob themselves
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
public void SetCustomAttribute(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con == null)
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
m_containingType.ThrowIfCreated();
TypeBuilder.DefineCustomAttribute(
m_moduleBuilder,
@ -118,12 +108,8 @@ namespace System.Reflection.Emit
}
// Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
public void SetCustomAttribute(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder == null)
{
throw new ArgumentNullException(nameof(customBuilder));
}
m_containingType.ThrowIfCreated();
customBuilder.CreateCustomAttribute(m_moduleBuilder, m_tkProperty);
}

View File

@ -167,14 +167,8 @@ namespace System.Reflection.Emit
return sigHelp;
}
internal static SignatureHelper GetTypeSigToken(Module module, Type type)
internal static SignatureHelper GetTypeSigToken(Module module!!, Type type!!)
{
if (module == null)
throw new ArgumentNullException(nameof(module));
if (type == null)
throw new ArgumentNullException(nameof(type));
return new SignatureHelper(module, type);
}
#endregion
@ -308,8 +302,7 @@ namespace System.Reflection.Emit
{
Type t = requiredCustomModifiers[i];
if (t == null)
throw new ArgumentNullException(nameof(requiredCustomModifiers));
ArgumentNullException.ThrowIfNull(t, nameof(requiredCustomModifiers));
if (t.HasElementType)
throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(requiredCustomModifiers));
@ -746,11 +739,8 @@ namespace System.Reflection.Emit
AddArgument(clsArgument, null, null);
}
public void AddArgument(Type argument, bool pinned)
public void AddArgument(Type argument!!, bool pinned)
{
if (argument == null)
throw new ArgumentNullException(nameof(argument));
IncrementArgCounts();
AddOneArgTypeHelper(argument, pinned);
}
@ -777,8 +767,7 @@ namespace System.Reflection.Emit
if (m_sigDone)
throw new ArgumentException(SR.Argument_SigIsFinalized);
if (argument == null)
throw new ArgumentNullException(nameof(argument));
ArgumentNullException.ThrowIfNull(argument);
IncrementArgCounts();

View File

@ -224,11 +224,8 @@ namespace System.Reflection.Emit
#endregion
#region Internal Members
internal void SetElementType(Type baseType)
internal void SetElementType(Type baseType!!)
{
if (baseType is null)
throw new ArgumentNullException(nameof(baseType));
m_baseType = baseType;
}

View File

@ -25,23 +25,14 @@ namespace System.Reflection.Emit
private readonly byte[]? m_binaryAttribute;
private readonly CustomAttributeBuilder? m_customBuilder;
public CustAttr(ConstructorInfo con, byte[] binaryAttribute)
public CustAttr(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con is null)
throw new ArgumentNullException(nameof(con));
if (binaryAttribute is null)
throw new ArgumentNullException(nameof(binaryAttribute));
m_con = con;
m_binaryAttribute = binaryAttribute;
}
public CustAttr(CustomAttributeBuilder customBuilder)
public CustAttr(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder is null)
throw new ArgumentNullException(nameof(customBuilder));
m_customBuilder = customBuilder;
}
@ -509,11 +500,8 @@ namespace System.Reflection.Emit
{
for (i = 0; i < interfaces.Length; i++)
{
if (interfaces[i] == null)
{
// cannot contain null in the interface list
throw new ArgumentNullException(nameof(interfaces));
}
// cannot contain null in the interface list
ArgumentNullException.ThrowIfNull(interfaces[i], nameof(interfaces));
}
interfaceTokens = new int[interfaces.Length + 1];
for (i = 0; i < interfaces.Length; i++)
@ -1120,8 +1108,7 @@ namespace System.Reflection.Emit
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
@ -1134,8 +1121,7 @@ namespace System.Reflection.Emit
if (!IsCreated())
throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
@ -1161,17 +1147,13 @@ namespace System.Reflection.Emit
}
}
public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names)
public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names!!)
{
if (names == null)
throw new ArgumentNullException(nameof(names));
if (names.Length == 0)
throw new ArgumentException(SR.Arg_EmptyArray, nameof(names));
for (int i = 0; i < names.Length; i++)
if (names[i] == null)
throw new ArgumentNullException(nameof(names));
ArgumentNullException.ThrowIfNull(names[i], nameof(names));
if (m_inst != null)
throw new InvalidOperationException();
@ -1214,14 +1196,8 @@ namespace System.Reflection.Emit
}
}
private void DefineMethodOverrideNoLock(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
private void DefineMethodOverrideNoLock(MethodInfo methodInfoBody!!, MethodInfo methodInfoDeclaration!!)
{
if (methodInfoBody == null)
throw new ArgumentNullException(nameof(methodInfoBody));
if (methodInfoDeclaration == null)
throw new ArgumentNullException(nameof(methodInfoDeclaration));
ThrowIfCreated();
if (!ReferenceEquals(methodInfoBody.DeclaringType, this))
@ -1700,11 +1676,8 @@ namespace System.Reflection.Emit
}
}
private FieldBuilder DefineInitializedDataNoLock(string name, byte[] data, FieldAttributes attributes)
private FieldBuilder DefineInitializedDataNoLock(string name, byte[] data!!, FieldAttributes attributes)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
// This method will define an initialized Data in .sdata.
// We will create a fake TypeDef to represent the data with size. This TypeDef
// will be the signature for the Field.
@ -2096,13 +2069,8 @@ namespace System.Reflection.Emit
}
}
public void AddInterfaceImplementation([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type interfaceType)
public void AddInterfaceImplementation([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type interfaceType!!)
{
if (interfaceType == null)
{
throw new ArgumentNullException(nameof(interfaceType));
}
AssemblyBuilder.CheckContext(interfaceType);
ThrowIfCreated();
@ -2125,23 +2093,14 @@ namespace System.Reflection.Emit
}
}
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
public void SetCustomAttribute(ConstructorInfo con!!, byte[] binaryAttribute!!)
{
if (con == null)
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
DefineCustomAttribute(m_module, m_tdType, ((ModuleBuilder)m_module).GetConstructorToken(con),
binaryAttribute);
}
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
public void SetCustomAttribute(CustomAttributeBuilder customBuilder!!)
{
if (customBuilder == null)
throw new ArgumentNullException(nameof(customBuilder));
customBuilder.CreateCustomAttribute((ModuleBuilder)m_module, m_tdType);
}

View File

@ -24,13 +24,11 @@ namespace System.Reflection.Emit
if (!type.IsGenericTypeDefinition)
throw new InvalidOperationException();
if (typeArguments == null)
throw new ArgumentNullException(nameof(typeArguments));
ArgumentNullException.ThrowIfNull(typeArguments);
foreach (Type t in typeArguments)
{
if (t == null)
throw new ArgumentNullException(nameof(typeArguments));
ArgumentNullException.ThrowIfNull(t, nameof(typeArguments));
}
return new TypeBuilderInstantiation(type, typeArguments);

View File

@ -7,11 +7,8 @@ namespace System.Reflection
{
internal virtual bool CacheEquals(object? o) { throw new NotImplementedException(); }
internal bool HasSameMetadataDefinitionAsCore<TOther>(MemberInfo other) where TOther : MemberInfo
internal bool HasSameMetadataDefinitionAsCore<TOther>(MemberInfo other!!) where TOther : MemberInfo
{
if (other is null)
throw new ArgumentNullException(nameof(other));
// Ensure that "other" is a runtime-implemented MemberInfo. Do this check before calling any methods on it!
if (!(other is TOther))
return false;

View File

@ -28,13 +28,8 @@ namespace System.Reflection.Metadata
/// <para>The caller is responsible for keeping the assembly object alive while accessing the metadata blob.</para>
/// </remarks>
[CLSCompliant(false)] // out byte* blob
public static unsafe bool TryGetRawMetadata(this Assembly assembly, out byte* blob, out int length)
public static unsafe bool TryGetRawMetadata(this Assembly assembly!!, out byte* blob, out int length)
{
if (assembly == null)
{
throw new ArgumentNullException(nameof(assembly));
}
blob = null;
length = 0;

View File

@ -36,7 +36,7 @@ namespace System.Reflection.Metadata
{
if (assembly is not RuntimeAssembly runtimeAssembly)
{
if (assembly is null) throw new ArgumentNullException(nameof(assembly));
ArgumentNullException.ThrowIfNull(assembly);
throw new ArgumentException(SR.Argument_MustBeRuntimeAssembly);
}

View File

@ -184,12 +184,10 @@ namespace System.Reflection
ObjectHandleOnStack assemblyLoadContext);
[RequiresUnreferencedCode("Types might be removed")]
public override Type? GetType(string name, bool throwOnError, bool ignoreCase)
public override Type? GetType(
string name!!, // throw on null strings regardless of the value of "throwOnError"
bool throwOnError, bool ignoreCase)
{
// throw on null strings regardless of the value of "throwOnError"
if (name == null)
throw new ArgumentNullException(nameof(name));
RuntimeType? type = null;
object? keepAlive = null;
AssemblyLoadContext? assemblyLoadContextStack = AssemblyLoadContext.CurrentContextualReflectionContext;
@ -262,8 +260,8 @@ namespace System.Reflection
// Load a resource based on the NameSpace of the type.
public override Stream? GetManifestResourceStream(Type type, string name)
{
if (type == null && name == null)
throw new ArgumentNullException(nameof(type));
if (name == null)
ArgumentNullException.ThrowIfNull(type);
string? nameSpace = type?.Namespace;
@ -304,22 +302,16 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
public override object[] GetCustomAttributes(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
@ -576,11 +568,8 @@ namespace System.Reflection
}
// Useful for binding to a very specific version of a satellite assembly
public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? version)
public override Assembly GetSatelliteAssembly(CultureInfo culture!!, Version? version)
{
if (culture == null)
throw new ArgumentNullException(nameof(culture));
return InternalGetSatelliteAssembly(culture, version, throwOnFileNotFound: true)!;
}

View File

@ -115,22 +115,16 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
public override object[] GetCustomAttributes(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));

View File

@ -679,11 +679,8 @@ namespace System.Reflection
internal static void ParseAttributeArguments(ConstArray attributeBlob,
ref CustomAttributeCtorParameter[] customAttributeCtorParameters,
ref CustomAttributeNamedParameter[] customAttributeNamedParameters,
RuntimeModule customAttributeModule)
RuntimeModule customAttributeModule!!)
{
if (customAttributeModule is null)
throw new ArgumentNullException(nameof(customAttributeModule));
Debug.Assert(customAttributeCtorParameters is not null);
Debug.Assert(customAttributeNamedParameters is not null);
@ -713,11 +710,8 @@ namespace System.Reflection
private readonly CustomAttributeType m_type;
private readonly CustomAttributeEncodedArgument m_encodedArgument;
public CustomAttributeNamedParameter(string argumentName, CustomAttributeEncoding fieldOrProperty, CustomAttributeType type)
public CustomAttributeNamedParameter(string argumentName!!, CustomAttributeEncoding fieldOrProperty, CustomAttributeType type)
{
if (argumentName is null)
throw new ArgumentNullException(nameof(argumentName));
m_argumentName = argumentName;
m_fieldOrProperty = fieldOrProperty;
m_padding = fieldOrProperty;

View File

@ -76,22 +76,16 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
public override object[] GetCustomAttributes(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));

View File

@ -61,22 +61,16 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
public override object[] GetCustomAttributes(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));

View File

@ -205,22 +205,16 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!, inherit);
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
public override object[] GetCustomAttributes(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType, inherit);
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
@ -417,12 +411,9 @@ namespace System.Reflection
DelegateBindingFlags.RelaxedSignature);
}
private Delegate CreateDelegateInternal(Type delegateType, object? firstArgument, DelegateBindingFlags bindingFlags)
private Delegate CreateDelegateInternal(Type delegateType!!, object? firstArgument, DelegateBindingFlags bindingFlags)
{
// Validate the parameters.
if (delegateType == null)
throw new ArgumentNullException(nameof(delegateType));
RuntimeType? rtType = delegateType as RuntimeType;
if (rtType == null)
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(delegateType));
@ -443,11 +434,8 @@ namespace System.Reflection
#region Generics
[RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")]
public override MethodInfo MakeGenericMethod(params Type[] methodInstantiation)
public override MethodInfo MakeGenericMethod(params Type[] methodInstantiation!!)
{
if (methodInstantiation == null)
throw new ArgumentNullException(nameof(methodInstantiation));
RuntimeType[] methodInstantionRuntimeType = new RuntimeType[methodInstantiation.Length];
if (!IsGenericMethodDefinition)
@ -457,9 +445,7 @@ namespace System.Reflection
for (int i = 0; i < methodInstantiation.Length; i++)
{
Type methodInstantiationElem = methodInstantiation[i];
if (methodInstantiationElem == null)
throw new ArgumentNullException();
ArgumentNullException.ThrowIfNull(methodInstantiationElem, null);
RuntimeType? rtMethodInstantiationElem = methodInstantiationElem as RuntimeType;

View File

@ -385,22 +385,16 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
public override object[] GetCustomAttributes(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
@ -420,12 +414,10 @@ namespace System.Reflection
}
[RequiresUnreferencedCode("Types might be removed")]
public override Type? GetType(string className, bool throwOnError, bool ignoreCase)
public override Type? GetType(
string className!!, // throw on null strings regardless of the value of "throwOnError"
bool throwOnError, bool ignoreCase)
{
// throw on null strings regardless of the value of "throwOnError"
if (className == null)
throw new ArgumentNullException(nameof(className));
RuntimeType? retType = null;
object? keepAlive = null;
RuntimeModule thisAsLocal = this;
@ -483,15 +475,9 @@ namespace System.Reflection
}
[RequiresUnreferencedCode("Fields might be removed")]
public override FieldInfo? GetField(string name, BindingFlags bindingAttr)
public override FieldInfo? GetField(string name!!, BindingFlags bindingAttr)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (RuntimeType == null)
return null;
return RuntimeType.GetField(name, bindingAttr);
return RuntimeType?.GetField(name, bindingAttr);
}
[RequiresUnreferencedCode("Methods might be removed")]

View File

@ -507,11 +507,8 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
public override object[] GetCustomAttributes(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (MdToken.IsNullToken(m_tkParamDef))
return Array.Empty<object>();
@ -521,11 +518,8 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (MdToken.IsNullToken(m_tkParamDef))
return false;

View File

@ -137,22 +137,16 @@ namespace System.Reflection
return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
public override object[] GetCustomAttributes(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
public override bool IsDefined(Type attributeType, bool inherit)
public override bool IsDefined(Type attributeType!!, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));

View File

@ -160,11 +160,7 @@ namespace System.Runtime.CompilerServices
{
if (type is not RuntimeType rt)
{
if (type is null)
{
throw new ArgumentNullException(nameof(type), SR.ArgumentNull_Type);
}
ArgumentNullException.ThrowIfNull(type);
throw new SerializationException(SR.Format(SR.Serialization_InvalidType, type));
}

View File

@ -10,9 +10,8 @@ namespace System.Runtime.CompilerServices
{
private readonly string typeName;
public TypeDependencyAttribute(string typeName)
public TypeDependencyAttribute(string typeName!!)
{
if (typeName == null) throw new ArgumentNullException(nameof(typeName));
this.typeName = typeName;
}
}

View File

@ -95,11 +95,8 @@ namespace System.Runtime.InteropServices
/// <remarks>
/// If <paramref name="impl" /> is <c>null</c>, the global instance (if registered) will be used.
/// </remarks>
private static bool TryGetOrCreateComInterfaceForObjectInternal(ComWrappers impl, object instance, CreateComInterfaceFlags flags, out IntPtr retValue)
private static bool TryGetOrCreateComInterfaceForObjectInternal(ComWrappers impl, object instance!!, CreateComInterfaceFlags flags, out IntPtr retValue)
{
if (instance == null)
throw new ArgumentNullException(nameof(instance));
return TryGetOrCreateComInterfaceForObjectInternal(ObjectHandleOnStack.Create(ref impl), impl.id, ObjectHandleOnStack.Create(ref instance), flags, out retValue);
}
@ -206,11 +203,8 @@ namespace System.Runtime.InteropServices
///
/// If the <paramref name="wrapper"/> instance already has an associated external object a <see cref="System.NotSupportedException"/> will be thrown.
/// </remarks>
public object GetOrRegisterObjectForComInstance(IntPtr externalComObject, CreateObjectFlags flags, object wrapper, IntPtr inner)
public object GetOrRegisterObjectForComInstance(IntPtr externalComObject, CreateObjectFlags flags, object wrapper!!, IntPtr inner)
{
if (wrapper == null)
throw new ArgumentNullException(nameof(wrapper));
object? obj;
if (!TryGetOrCreateObjectForComInstanceInternal(this, externalComObject, inner, flags, wrapper, out obj))
throw new ArgumentNullException(nameof(externalComObject));
@ -239,8 +233,7 @@ namespace System.Runtime.InteropServices
object? wrapperMaybe,
out object? retValue)
{
if (externalComObject == IntPtr.Zero)
throw new ArgumentNullException(nameof(externalComObject));
ArgumentNullException.ThrowIfNull(externalComObject);
// If the inner is supplied the Aggregation flag should be set.
if (innerMaybe != IntPtr.Zero && !flags.HasFlag(CreateObjectFlags.Aggregation))
@ -269,11 +262,8 @@ namespace System.Runtime.InteropServices
/// Scenarios where this global instance may be used are:
/// * Object tracking via the <see cref="CreateComInterfaceFlags.TrackerSupport" /> and <see cref="CreateObjectFlags.TrackerObject" /> flags.
/// </remarks>
public static void RegisterForTrackerSupport(ComWrappers instance)
public static void RegisterForTrackerSupport(ComWrappers instance!!)
{
if (instance == null)
throw new ArgumentNullException(nameof(instance));
if (null != Interlocked.CompareExchange(ref s_globalInstanceForTrackerSupport, instance, null))
{
throw new InvalidOperationException(SR.InvalidOperation_ResetGlobalComWrappersInstance);
@ -301,11 +291,8 @@ namespace System.Runtime.InteropServices
/// * COM activation
/// </remarks>
[SupportedOSPlatform("windows")]
public static void RegisterForMarshalling(ComWrappers instance)
public static void RegisterForMarshalling(ComWrappers instance!!)
{
if (instance == null)
throw new ArgumentNullException(nameof(instance));
if (null != Interlocked.CompareExchange(ref s_globalInstanceForMarshalling, instance, null))
{
throw new InvalidOperationException(SR.InvalidOperation_ResetGlobalComWrappersInstance);

View File

@ -8,13 +8,8 @@ namespace System.Runtime.InteropServices.CustomMarshalers
{
internal sealed class EnumVariantViewOfEnumerator : ComTypes.IEnumVARIANT, ICustomAdapter
{
public EnumVariantViewOfEnumerator(IEnumerator enumerator)
public EnumVariantViewOfEnumerator(IEnumerator enumerator!!)
{
if (enumerator is null)
{
throw new ArgumentNullException(nameof(enumerator));
}
Enumerator = enumerator;
}

View File

@ -32,22 +32,14 @@ namespace System.Runtime.InteropServices.CustomMarshalers
return -1;
}
public IntPtr MarshalManagedToNative(object ManagedObj)
public IntPtr MarshalManagedToNative(object ManagedObj!!)
{
if (ManagedObj == null)
{
throw new ArgumentNullException(nameof(ManagedObj));
}
return Marshal.GetComInterfaceForObject<object, IEnumerable>(ManagedObj);
}
public object MarshalNativeToManaged(IntPtr pNativeData)
{
if (pNativeData == IntPtr.Zero)
{
throw new ArgumentNullException(nameof(pNativeData));
}
ArgumentNullException.ThrowIfNull(pNativeData);
object comObject = Marshal.GetObjectForIUnknown(pNativeData);

View File

@ -33,13 +33,8 @@ namespace System.Runtime.InteropServices.CustomMarshalers
return -1;
}
public IntPtr MarshalManagedToNative(object ManagedObj)
public IntPtr MarshalManagedToNative(object ManagedObj!!)
{
if (ManagedObj == null)
{
throw new ArgumentNullException(nameof(ManagedObj));
}
if (ManagedObj is EnumeratorViewOfEnumVariant view)
{
return Marshal.GetComInterfaceForObject<object, ComTypes.IEnumVARIANT>(view.GetUnderlyingObject());
@ -52,10 +47,7 @@ namespace System.Runtime.InteropServices.CustomMarshalers
public object MarshalNativeToManaged(IntPtr pNativeData)
{
if (pNativeData == IntPtr.Zero)
{
throw new ArgumentNullException(nameof(pNativeData));
}
ArgumentNullException.ThrowIfNull(pNativeData);
object comObject = Marshal.GetObjectForIUnknown(pNativeData);

View File

@ -28,13 +28,8 @@ namespace System.Runtime.InteropServices
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern",
Justification = "Trimming doesn't affect types eligible for marshalling. Different exception for invalid inputs doesn't matter.")]
public static IntPtr OffsetOf(Type t, string fieldName)
public static IntPtr OffsetOf(Type t!!, string fieldName)
{
if (t is null)
{
throw new ArgumentNullException(nameof(t));
}
FieldInfo? f = t.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (f is null)
@ -235,13 +230,8 @@ namespace System.Runtime.InteropServices
/// Returns the HInstance for this module. Returns -1 if the module doesn't have
/// an HInstance. In Memory (Dynamic) Modules won't have an HInstance.
/// </summary>
public static IntPtr GetHINSTANCE(Module m)
public static IntPtr GetHINSTANCE(Module m!!)
{
if (m is null)
{
throw new ArgumentNullException(nameof(m));
}
if (m is RuntimeModule rtModule)
{
return GetHINSTANCE(new QCallModule(ref rtModule));
@ -271,13 +261,8 @@ namespace System.Runtime.InteropServices
/// Given a managed object that wraps an ITypeInfo, return its name.
/// </summary>
[SupportedOSPlatform("windows")]
public static string GetTypeInfoName(ITypeInfo typeInfo)
public static string GetTypeInfoName(ITypeInfo typeInfo!!)
{
if (typeInfo is null)
{
throw new ArgumentNullException(nameof(typeInfo));
}
typeInfo.GetDocumentation(-1, out string strTypeLibName, out _, out _, out _);
return strTypeLibName;
}
@ -309,13 +294,8 @@ namespace System.Runtime.InteropServices
/// where the RCW was first seen. Will return null otherwise.
/// </summary>
[SupportedOSPlatform("windows")]
public static IntPtr /* IUnknown* */ GetIUnknownForObject(object o)
public static IntPtr /* IUnknown* */ GetIUnknownForObject(object o!!)
{
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
return GetIUnknownForObjectNative(o);
}
@ -326,13 +306,8 @@ namespace System.Runtime.InteropServices
/// Return the IDispatch* for an Object.
/// </summary>
[SupportedOSPlatform("windows")]
public static IntPtr /* IDispatch */ GetIDispatchForObject(object o)
public static IntPtr /* IDispatch */ GetIDispatchForObject(object o!!)
{
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
return GetIDispatchForObjectNative(o);
}
@ -344,18 +319,8 @@ namespace System.Runtime.InteropServices
/// Object o should support Type T
/// </summary>
[SupportedOSPlatform("windows")]
public static IntPtr /* IUnknown* */ GetComInterfaceForObject(object o, Type T)
public static IntPtr /* IUnknown* */ GetComInterfaceForObject(object o!!, Type T!!)
{
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
if (T is null)
{
throw new ArgumentNullException(nameof(T));
}
return GetComInterfaceForObjectNative(o, T, true);
}
@ -368,18 +333,8 @@ namespace System.Runtime.InteropServices
/// invoke customized QueryInterface or not.
/// </summary>
[SupportedOSPlatform("windows")]
public static IntPtr /* IUnknown* */ GetComInterfaceForObject(object o, Type T, CustomQueryInterfaceMode mode)
public static IntPtr /* IUnknown* */ GetComInterfaceForObject(object o!!, Type T!!, CustomQueryInterfaceMode mode)
{
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
if (T is null)
{
throw new ArgumentNullException(nameof(T));
}
bool bEnableCustomizedQueryInterface = ((mode == CustomQueryInterfaceMode.Allow) ? true : false);
return GetComInterfaceForObjectNative(o, T, bEnableCustomizedQueryInterface);
}
@ -393,10 +348,7 @@ namespace System.Runtime.InteropServices
[SupportedOSPlatform("windows")]
public static object GetObjectForIUnknown(IntPtr /* IUnknown* */ pUnk)
{
if (pUnk == IntPtr.Zero)
{
throw new ArgumentNullException(nameof(pUnk));
}
ArgumentNullException.ThrowIfNull(pUnk);
return GetObjectForIUnknownNative(pUnk);
}
@ -407,10 +359,7 @@ namespace System.Runtime.InteropServices
[SupportedOSPlatform("windows")]
public static object GetUniqueObjectForIUnknown(IntPtr unknown)
{
if (unknown == IntPtr.Zero)
{
throw new ArgumentNullException(nameof(unknown));
}
ArgumentNullException.ThrowIfNull(unknown);
return GetUniqueObjectForIUnknownNative(unknown);
}
@ -466,13 +415,8 @@ namespace System.Runtime.InteropServices
/// <summary>
/// Checks if the object is classic COM component.
/// </summary>
public static bool IsComObject(object o)
public static bool IsComObject(object o!!)
{
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
return o is __ComObject;
}
@ -516,10 +460,7 @@ namespace System.Runtime.InteropServices
throw new NotSupportedException(SR.NotSupported_COM);
}
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
ArgumentNullException.ThrowIfNull(o);
if (!(o is __ComObject co))
{
throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(o));
@ -540,14 +481,8 @@ namespace System.Runtime.InteropServices
throw new NotSupportedException(SR.NotSupported_COM);
}
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
if (key is null)
{
throw new ArgumentNullException(nameof(key));
}
ArgumentNullException.ThrowIfNull(obj);
ArgumentNullException.ThrowIfNull(key);
if (!(obj is __ComObject co))
{
throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(obj));
@ -571,14 +506,8 @@ namespace System.Runtime.InteropServices
throw new NotSupportedException(SR.NotSupported_COM);
}
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
if (key is null)
{
throw new ArgumentNullException(nameof(key));
}
ArgumentNullException.ThrowIfNull(obj);
ArgumentNullException.ThrowIfNull(key);
if (!(obj is __ComObject co))
{
throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(obj));
@ -601,10 +530,7 @@ namespace System.Runtime.InteropServices
throw new NotSupportedException(SR.NotSupported_COM);
}
if (t is null)
{
throw new ArgumentNullException(nameof(t));
}
ArgumentNullException.ThrowIfNull(t);
if (!t.IsCOMObject)
{
throw new ArgumentException(SR.Argument_TypeNotComObject, nameof(t));

View File

@ -81,10 +81,8 @@ namespace System.Runtime.Loader
/// </summary>
internal Assembly LoadFromInMemoryModule(IntPtr moduleHandle)
{
if (moduleHandle == IntPtr.Zero)
{
throw new ArgumentNullException(nameof(moduleHandle));
}
ArgumentNullException.ThrowIfNull(moduleHandle);
lock (_unloadLock)
{
VerifyIsAlive();
@ -138,18 +136,12 @@ namespace System.Runtime.Loader
private static partial IntPtr GetLoadContextForAssembly(QCallAssembly assembly);
// Returns the load context in which the specified assembly has been loaded
public static AssemblyLoadContext? GetLoadContext(Assembly assembly)
public static AssemblyLoadContext? GetLoadContext(Assembly assembly!!)
{
if (assembly == null)
{
throw new ArgumentNullException(nameof(assembly));
}
AssemblyLoadContext? loadContextForAssembly = null;
RuntimeAssembly? rtAsm = GetRuntimeAssembly(assembly);
// We only support looking up load context for runtime assemblies.
AssemblyLoadContext? loadContextForAssembly = null;
if (rtAsm != null)
{
RuntimeAssembly runtimeAssembly = rtAsm;

View File

@ -1719,12 +1719,9 @@ namespace System
#region Static Members
#region Internal
internal static RuntimeType? GetType(string typeName, bool throwOnError, bool ignoreCase,
internal static RuntimeType? GetType(string typeName!!, bool throwOnError, bool ignoreCase,
ref StackCrawlMark stackMark)
{
if (typeName == null)
throw new ArgumentNullException(nameof(typeName));
return RuntimeTypeHandle.GetTypeByName(
typeName, throwOnError, ignoreCase, ref stackMark);
}
@ -2669,8 +2666,7 @@ namespace System
if (IsGenericParameter)
throw new InvalidOperationException(SR.Arg_GenericParameter);
if (ifaceType is null)
throw new ArgumentNullException(nameof(ifaceType));
ArgumentNullException.ThrowIfNull(ifaceType);
RuntimeType? ifaceRtType = ifaceType as RuntimeType;
@ -2812,10 +2808,8 @@ namespace System
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)]
protected override PropertyInfo? GetPropertyImpl(
string name, BindingFlags bindingAttr, Binder? binder, Type? returnType, Type[]? types, ParameterModifier[]? modifiers)
string name!!, BindingFlags bindingAttr, Binder? binder, Type? returnType, Type[]? types, ParameterModifier[]? modifiers)
{
if (name == null) throw new ArgumentNullException(nameof(name));
ListBuilder<PropertyInfo> candidates = GetPropertyCandidates(name, bindingAttr, types, false);
if (candidates.Count == 0)
@ -2849,10 +2843,8 @@ namespace System
}
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents | DynamicallyAccessedMemberTypes.NonPublicEvents)]
public override EventInfo? GetEvent(string name, BindingFlags bindingAttr)
public override EventInfo? GetEvent(string name!!, BindingFlags bindingAttr)
{
if (name is null) throw new ArgumentNullException(nameof(name));
FilterHelper(bindingAttr, ref name, out _, out MemberListType listType);
RuntimeEventInfo[] cache = Cache.GetEventList(listType, name);
@ -2876,10 +2868,8 @@ namespace System
}
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)]
public override FieldInfo? GetField(string name, BindingFlags bindingAttr)
public override FieldInfo? GetField(string name!!, BindingFlags bindingAttr)
{
if (name is null) throw new ArgumentNullException();
FilterHelper(bindingAttr, ref name, out _, out MemberListType listType);
RuntimeFieldInfo[] cache = Cache.GetFieldList(listType, name);
@ -2915,10 +2905,8 @@ namespace System
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
public override Type? GetInterface(string fullname, bool ignoreCase)
public override Type? GetInterface(string fullname!!, bool ignoreCase)
{
if (fullname is null) throw new ArgumentNullException(nameof(fullname));
BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.NonPublic;
bindingAttr &= ~BindingFlags.Static;
@ -2950,10 +2938,8 @@ namespace System
}
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicNestedTypes | DynamicallyAccessedMemberTypes.NonPublicNestedTypes)]
public override Type? GetNestedType(string fullname, BindingFlags bindingAttr)
public override Type? GetNestedType(string fullname!!, BindingFlags bindingAttr)
{
if (fullname is null) throw new ArgumentNullException(nameof(fullname));
bindingAttr &= ~BindingFlags.Static;
string name, ns;
SplitName(fullname, out name!, out ns!);
@ -2979,10 +2965,8 @@ namespace System
}
[DynamicallyAccessedMembers(GetAllMembers)]
public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
public override MemberInfo[] GetMember(string name!!, MemberTypes type, BindingFlags bindingAttr)
{
if (name is null) throw new ArgumentNullException(nameof(name));
ListBuilder<MethodInfo> methods = default;
ListBuilder<ConstructorInfo> constructors = default;
ListBuilder<PropertyInfo> properties = default;
@ -3061,10 +3045,8 @@ namespace System
return compressMembers;
}
public override MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberInfo member)
public override MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberInfo member!!)
{
if (member is null) throw new ArgumentNullException(nameof(member));
RuntimeType? runtimeType = this;
while (runtimeType != null)
{
@ -3217,10 +3199,8 @@ namespace System
#region Hierarchy
public override bool IsSubclassOf(Type type)
public override bool IsSubclassOf(Type type!!)
{
if (type is null)
throw new ArgumentNullException(nameof(type));
RuntimeType? rtType = type as RuntimeType;
if (rtType == null)
return false;
@ -3352,11 +3332,8 @@ namespace System
}
[RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")]
public override Type MakeGenericType(Type[] instantiation)
public override Type MakeGenericType(Type[] instantiation!!)
{
if (instantiation == null)
throw new ArgumentNullException(nameof(instantiation));
if (!IsGenericTypeDefinition)
throw new InvalidOperationException(SR.Format(SR.Arg_NotGenericTypeDefinition, this));

View File

@ -24,23 +24,13 @@ namespace System
[MethodImpl(MethodImplOptions.InternalCall)]
private extern string? IsInterned();
public static string Intern(string str)
public static string Intern(string str!!)
{
if (str == null)
{
throw new ArgumentNullException(nameof(str));
}
return str.Intern();
}
public static string? IsInterned(string str)
public static string? IsInterned(string str!!)
{
if (str == null)
{
throw new ArgumentNullException(nameof(str));
}
return str.IsInterned();
}

View File

@ -545,10 +545,7 @@ namespace System.StubHelpers
throw new InvalidOperationException(SR.Interop_Marshal_SafeHandle_InvalidOperation);
}
if (handle is null)
{
throw new ArgumentNullException(nameof(handle));
}
ArgumentNullException.ThrowIfNull(handle);
return StubHelpers.AddToCleanupList(ref cleanupWorkList, handle);
}

View File

@ -71,11 +71,8 @@ namespace System.Threading
/// <see cref="ThreadPoolBoundHandle"/> does not take ownership of <paramref name="handle"/>,
/// it remains the responsibility of the caller to call <see cref="SafeHandle.Dispose()"/>.
/// </remarks>
public static ThreadPoolBoundHandle BindHandle(SafeHandle handle)
public static ThreadPoolBoundHandle BindHandle(SafeHandle handle!!)
{
if (handle == null)
throw new ArgumentNullException(nameof(handle));
if (handle.IsClosed || handle.IsInvalid)
throw new ArgumentException(SR.Argument_InvalidHandle, nameof(handle));
@ -175,11 +172,8 @@ namespace System.Threading
public unsafe NativeOverlapped* UnsafeAllocateNativeOverlapped(IOCompletionCallback callback, object? state, object? pinData) =>
AllocateNativeOverlapped(callback, state, pinData, flowExecutionContext: false);
private unsafe NativeOverlapped* AllocateNativeOverlapped(IOCompletionCallback callback, object? state, object? pinData, bool flowExecutionContext)
private unsafe NativeOverlapped* AllocateNativeOverlapped(IOCompletionCallback callback!!, object? state, object? pinData, bool flowExecutionContext)
{
if (callback == null)
throw new ArgumentNullException(nameof(callback));
EnsureNotDisposed();
ThreadPoolBoundHandleOverlapped overlapped = new ThreadPoolBoundHandleOverlapped(callback, state, pinData, preAllocated: null, flowExecutionContext);
@ -216,11 +210,8 @@ namespace System.Threading
/// </exception>
/// <seealso cref="PreAllocatedOverlapped"/>
[CLSCompliant(false)]
public unsafe NativeOverlapped* AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated)
public unsafe NativeOverlapped* AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated!!)
{
if (preAllocated == null)
throw new ArgumentNullException(nameof(preAllocated));
EnsureNotDisposed();
preAllocated.AddRef();
@ -266,11 +257,8 @@ namespace System.Threading
/// This method was called after the <see cref="ThreadPoolBoundHandle"/> was disposed.
/// </exception>
[CLSCompliant(false)]
public unsafe void FreeNativeOverlapped(NativeOverlapped* overlapped)
public unsafe void FreeNativeOverlapped(NativeOverlapped* overlapped!!)
{
if (overlapped == null)
throw new ArgumentNullException(nameof(overlapped));
// Note: we explicitly allow FreeNativeOverlapped calls after the ThreadPoolBoundHandle has been Disposed.
ThreadPoolBoundHandleOverlapped wrapper = GetOverlappedWrapper(overlapped);
@ -301,11 +289,8 @@ namespace System.Threading
/// <paramref name="overlapped"/> is <see langword="null"/>.
/// </exception>
[CLSCompliant(false)]
public static unsafe object? GetNativeOverlappedState(NativeOverlapped* overlapped)
public static unsafe object? GetNativeOverlappedState(NativeOverlapped* overlapped!!)
{
if (overlapped == null)
throw new ArgumentNullException(nameof(overlapped));
ThreadPoolBoundHandleOverlapped wrapper = GetOverlappedWrapper(overlapped);
Debug.Assert(wrapper._boundHandle != null);
return wrapper._userState;

View File

@ -91,11 +91,8 @@ namespace System.Threading
public static PreAllocatedOverlapped UnsafeCreate(IOCompletionCallback callback, object? state, object? pinData) =>
new PreAllocatedOverlapped(callback, state, pinData, flowExecutionContext: false);
private PreAllocatedOverlapped(IOCompletionCallback callback, object? state, object? pinData, bool flowExecutionContext)
private PreAllocatedOverlapped(IOCompletionCallback callback!!, object? state, object? pinData, bool flowExecutionContext)
{
if (callback == null)
throw new ArgumentNullException(nameof(callback));
_overlapped = new ThreadPoolBoundHandleOverlapped(callback, state, pinData, this, flowExecutionContext);
}

View File

@ -125,11 +125,8 @@ namespace System.Threading
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void ReliableEnterTimeout(object obj, int timeout, ref bool lockTaken);
public static bool IsEntered(object obj)
public static bool IsEntered(object obj!!)
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
return IsEnteredNative(obj);
}
@ -167,13 +164,8 @@ namespace System.Threading
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void ObjPulse(object obj);
public static void Pulse(object obj)
public static void Pulse(object obj!!)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
ObjPulse(obj);
}
/*========================================================================
@ -182,13 +174,8 @@ namespace System.Threading
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void ObjPulseAll(object obj);
public static void PulseAll(object obj)
public static void PulseAll(object obj!!)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
ObjPulseAll(obj);
}

View File

@ -243,20 +243,14 @@ namespace System.Threading
* Unpins the native Overlapped struct
====================================================================*/
[CLSCompliant(false)]
public static unsafe Overlapped Unpack(NativeOverlapped* nativeOverlappedPtr)
public static unsafe Overlapped Unpack(NativeOverlapped* nativeOverlappedPtr!!)
{
if (nativeOverlappedPtr == null)
throw new ArgumentNullException(nameof(nativeOverlappedPtr));
return OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr)._overlapped;
}
[CLSCompliant(false)]
public static unsafe void Free(NativeOverlapped* nativeOverlappedPtr)
public static unsafe void Free(NativeOverlapped* nativeOverlappedPtr!!)
{
if (nativeOverlappedPtr == null)
throw new ArgumentNullException(nameof(nativeOverlappedPtr));
OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr)._overlapped._overlappedData = null;
OverlappedData.FreeNativeOverlapped(nativeOverlappedPtr);
}

View File

@ -351,20 +351,13 @@ namespace System.Threading
private static extern long GetPendingUnmanagedWorkItemCount();
private static RegisteredWaitHandle RegisterWaitForSingleObject(
WaitHandle? waitObject,
WaitOrTimerCallback? callBack,
WaitHandle waitObject!!,
WaitOrTimerCallback callBack!!,
object? state,
uint millisecondsTimeOutInterval,
bool executeOnlyOnce,
bool flowExecutionContext)
{
if (waitObject == null)
throw new ArgumentNullException(nameof(waitObject));
if (callBack == null)
throw new ArgumentNullException(nameof(callBack));
RegisteredWaitHandle registeredWaitHandle = new RegisteredWaitHandle(
waitObject,
new _ThreadPoolWaitOrTimerCallback(callBack, state, flowExecutionContext),
@ -552,11 +545,8 @@ namespace System.Threading
}
[SupportedOSPlatform("windows")]
public static bool BindHandle(SafeHandle osHandle)
public static bool BindHandle(SafeHandle osHandle!!)
{
if (osHandle == null)
throw new ArgumentNullException(nameof(osHandle));
bool ret = false;
bool mustReleaseSafeHandle = false;
try

View File

@ -56,15 +56,13 @@ namespace System
#region Static Members
[RequiresUnreferencedCode("The type might be removed")]
internal static Type? GetType(
string typeName,
string typeName!!,
Func<AssemblyName, Assembly?>? assemblyResolver,
Func<Assembly?, string, bool, Type?>? typeResolver,
bool throwOnError,
bool ignoreCase,
ref StackCrawlMark stackMark)
{
if (typeName == null)
throw new ArgumentNullException(nameof(typeName));
if (typeName.Length > 0 && typeName[0] == '\0')
throw new ArgumentException(SR.Format_StringZeroLength);

View File

@ -11,13 +11,8 @@ namespace Microsoft.Extensions.Internal
// everywhere we use timers to avoid rooting any values stored in asynclocals.
internal static class NonCapturingTimer
{
public static Timer Create(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period)
public static Timer Create(TimerCallback callback!!, object state, TimeSpan dueTime, TimeSpan period)
{
if (callback == null)
{
throw new ArgumentNullException(nameof(callback));
}
// Don't capture the current ExecutionContext and its AsyncLocals onto the timer
bool restoreFlow = false;
try

View File

@ -12,15 +12,13 @@ namespace Internal.Cryptography
internal abstract class HashProvider : IDisposable
{
// Adds new data to be hashed. This can be called repeatedly in order to hash data from noncontiguous sources.
public void AppendHashData(byte[] data, int offset, int count)
public void AppendHashData(byte[] data!!, int offset, int count)
{
// AppendHashData can be called via exposed APIs (e.g. a type that derives from
// HMACSHA1 and calls HashCore) and could be passed bad data from there. It could
// also receive a bad count from HashAlgorithm reading from a Stream that returns
// an invalid number of bytes read. Since our implementations of AppendHashDataCore
// end up using unsafe code, we want to be sure the arguments are valid.
if (data == null)
throw new ArgumentNullException(nameof(data));
if (offset < 0)
throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);
if (count < 0)

View File

@ -150,7 +150,7 @@ namespace Internal.Cryptography
public static int GetPaddingLength(ReadOnlySpan<byte> block, PaddingMode paddingMode, int blockSize)
{
int padBytes = 0;
int padBytes;
// See PadBlock for a description of the padding modes.
switch (paddingMode)

View File

@ -91,10 +91,8 @@ namespace Internal.Cryptography
return numBytesWritten;
}
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
public byte[] TransformFinalBlock(byte[] inputBuffer!!, int inputOffset, int inputCount)
{
if (inputBuffer == null)
throw new ArgumentNullException(nameof(inputBuffer));
if (inputOffset < 0)
throw new ArgumentOutOfRangeException(nameof(inputOffset));
if (inputCount < 0)

View File

@ -34,30 +34,30 @@ internal static partial class Interop
// From sys/_sigset.h
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct sigset_t
internal unsafe struct @sigset_t
{
private fixed int bits[4];
}
[StructLayout(LayoutKind.Sequential)]
internal struct uid_t
internal struct @uid_t
{
public uint id;
}
[StructLayout(LayoutKind.Sequential)]
internal struct gid_t
internal struct @gid_t
{
public uint id;
}
[StructLayout(LayoutKind.Sequential)]
public struct timeval
public struct @timeval
{
public IntPtr tv_sec;
public IntPtr tv_usec;
}
[StructLayout(LayoutKind.Sequential)]
private struct vnode
private struct @vnode
{
public long tv_sec;
public long tv_usec;
@ -65,7 +65,7 @@ internal static partial class Interop
// sys/resource.h
[StructLayout(LayoutKind.Sequential)]
internal struct rusage
internal struct @rusage
{
public timeval ru_utime; /* user time used */
public timeval ru_stime; /* system time used */
@ -87,7 +87,7 @@ internal static partial class Interop
// From sys/user.h
[StructLayout(LayoutKind.Sequential)]
public unsafe struct kinfo_proc
public unsafe struct @kinfo_proc
{
public int ki_structsize; /* size of this structure */
private int ki_layout; /* reserved: layout identifier */

View File

@ -11,7 +11,7 @@ using System.Text;
internal static partial class Interop
{
internal static partial class procfs
internal static partial class @procfs
{
private const string MapsFileName = "/maps";

View File

@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class libc
internal static partial class @libc
{
[StructLayout(LayoutKind.Sequential)]
internal struct AttrList

View File

@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class libobjc
internal static partial class @libobjc
{
[StructLayout(LayoutKind.Sequential)]
private struct NSOperatingSystemVersion

View File

@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class libproc
internal static partial class @libproc
{
// Constants from sys\param.h
private const int MAXCOMLEN = 16;

View File

@ -11,7 +11,7 @@ using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class libproc
internal static partial class @libproc
{
// Constants from sys\param.h
private const int MAXPATHLEN = 1024;

View File

@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class procfs
internal static partial class @procfs
{
/// <summary>
/// Attempts to get status info for the specified process ID.

View File

@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class libc
internal static partial class @libc
{
[GeneratedDllImport(Libraries.Libc, EntryPoint = "getppid")]
internal static partial int GetParentPid();

View File

@ -348,10 +348,7 @@ namespace System.Net.Security
ref SecurityBuffer outSecBuffer,
ref Interop.SspiCli.ContextFlags outFlags)
{
if (inCredentials == null)
{
throw new ArgumentNullException(nameof(inCredentials));
}
ArgumentNullException.ThrowIfNull(inCredentials);
Debug.Assert(inSecBuffers.Count <= 3);
Interop.SspiCli.SecBufferDesc inSecurityBufferDescriptor = new Interop.SspiCli.SecBufferDesc(inSecBuffers.Count);
@ -665,10 +662,7 @@ namespace System.Net.Security
ref SecurityBuffer outSecBuffer,
ref Interop.SspiCli.ContextFlags outFlags)
{
if (inCredentials == null)
{
throw new ArgumentNullException(nameof(inCredentials));
}
ArgumentNullException.ThrowIfNull(inCredentials);
Debug.Assert(inSecBuffers.Count <= 3);
Interop.SspiCli.SecBufferDesc inSecurityBufferDescriptor = new Interop.SspiCli.SecBufferDesc(inSecBuffers.Count);

View File

@ -17,11 +17,8 @@ namespace Microsoft.Win32.SafeHandles
public SafeCertContextHandle() { }
public SafeCertContextHandle(SafeCertContextHandle parent)
public SafeCertContextHandle(SafeCertContextHandle parent!!)
{
if (parent == null)
throw new ArgumentNullException(nameof(parent));
Debug.Assert(!parent.IsInvalid);
Debug.Assert(!parent.IsClosed);

View File

@ -42,13 +42,8 @@ namespace System.Runtime.Serialization
ArrayElementType = null;
}
public CodeTypeReference(Type type)
public CodeTypeReference(Type type!!)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
if (type.IsArray)
{
ArrayRank = type.GetArrayRank();

View File

@ -39,26 +39,16 @@ namespace System.Runtime.Serialization
public void Add(Type value) => Add(new CodeTypeReference(value));
public void AddRange(CodeTypeReference[] value)
public void AddRange(CodeTypeReference[] value!!)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
for (int i = 0; i < value.Length; i++)
{
Add(value[i]);
}
}
public void AddRange(CodeTypeReferenceCollection value)
public void AddRange(CodeTypeReferenceCollection value!!)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
int currentCount = value.Count;
for (int i = 0; i < currentCount; i++)
{

View File

@ -33,18 +33,8 @@ namespace System.Composition.Diagnostics
}
}
public static void Registration_MemberExportConventionOverridden(Type type, MemberInfo member)
public static void Registration_MemberExportConventionOverridden(Type type!!, MemberInfo member!!)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
if (member == null)
{
throw new ArgumentNullException(nameof(member));
}
if (CompositionTraceSource.CanWriteWarning)
{
CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_MemberExportConventionOverridden,
@ -53,18 +43,8 @@ namespace System.Composition.Diagnostics
}
}
public static void Registration_MemberImportConventionOverridden(Type type, MemberInfo member)
public static void Registration_MemberImportConventionOverridden(Type type!!, MemberInfo member!!)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
if (member == null)
{
throw new ArgumentNullException(nameof(member));
}
if (CompositionTraceSource.CanWriteWarning)
{
CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_MemberImportConventionOverridden,
@ -73,18 +53,8 @@ namespace System.Composition.Diagnostics
}
}
public static void Registration_OnSatisfiedImportNotificationOverridden(Type type, MemberInfo member)
public static void Registration_OnSatisfiedImportNotificationOverridden(Type type!!, MemberInfo member!!)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
if (member == null)
{
throw new ArgumentNullException(nameof(member));
}
if (CompositionTraceSource.CanWriteWarning)
{
CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_OnSatisfiedImportNotificationOverridden,
@ -93,13 +63,8 @@ namespace System.Composition.Diagnostics
}
}
public static void Registration_PartCreationConventionOverridden(Type type)
public static void Registration_PartCreationConventionOverridden(Type type!!)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
if (CompositionTraceSource.CanWriteWarning)
{
CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_PartCreationConventionOverridden,
@ -108,18 +73,8 @@ namespace System.Composition.Diagnostics
}
}
public static void Registration_MemberImportConventionMatchedTwice(Type type, MemberInfo member)
public static void Registration_MemberImportConventionMatchedTwice(Type type!!, MemberInfo member!!)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
if (member == null)
{
throw new ArgumentNullException(nameof(member));
}
if (CompositionTraceSource.CanWriteWarning)
{
CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_MemberImportConventionMatchedTwice,
@ -128,13 +83,8 @@ namespace System.Composition.Diagnostics
}
}
public static void Registration_PartMetadataConventionOverridden(Type type)
public static void Registration_PartMetadataConventionOverridden(Type type!!)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
if (CompositionTraceSource.CanWriteWarning)
{
CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_PartMetadataConventionOverridden,
@ -143,18 +93,8 @@ namespace System.Composition.Diagnostics
}
}
public static void Registration_ParameterImportConventionOverridden(ParameterInfo parameter, ConstructorInfo constructor)
public static void Registration_ParameterImportConventionOverridden(ParameterInfo parameter!!, ConstructorInfo constructor!!)
{
if (parameter == null)
{
throw new ArgumentNullException(nameof(parameter));
}
if (constructor == null)
{
throw new ArgumentNullException(nameof(constructor));
}
if (CompositionTraceSource.CanWriteWarning)
{
CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_ParameterImportConventionOverridden,

View File

@ -188,13 +188,8 @@ namespace System.IO
}
#if NETFRAMEWORK || NETSTANDARD2_0
private static void ValidateBufferArguments(byte[] buffer, int offset, int count)
private static void ValidateBufferArguments(byte[] buffer!!, int offset, int count)
{
if (buffer is null)
{
throw new ArgumentNullException(nameof(buffer));
}
if (offset < 0)
{
throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);

View File

@ -7,13 +7,8 @@ namespace System.IO
internal static partial class StreamHelpers
{
/// <summary>Validate the arguments to CopyTo, as would Stream.CopyTo.</summary>
public static void ValidateCopyToArgs(Stream source, Stream destination, int bufferSize)
public static void ValidateCopyToArgs(Stream source, Stream destination!!, int bufferSize)
{
if (destination == null)
{
throw new ArgumentNullException(nameof(destination));
}
if (bufferSize <= 0)
{
throw new ArgumentOutOfRangeException(nameof(bufferSize), bufferSize, SR.ArgumentOutOfRange_NeedPosNum);

View File

@ -30,12 +30,8 @@ namespace System.IO
/// <param name="buffer">The string to parse.</param>
/// <param name="separator">The separator character used to separate subcomponents of <paramref name="buffer"/>.</param>
/// <param name="skipEmpty">true if empty subcomponents should be skipped; false to treat them as valid entries. Defaults to false.</param>
public StringParser(string buffer, char separator, bool skipEmpty = false)
public StringParser(string buffer!!, char separator, bool skipEmpty = false)
{
if (buffer == null)
{
throw new ArgumentNullException(nameof(buffer));
}
_buffer = buffer;
_separator = separator;
_skipEmpty = skipEmpty;

View File

@ -16,10 +16,7 @@ namespace System.Net
public static void ValidateSegment(ArraySegment<byte> segment)
{
// ArraySegment<byte> is not nullable.
if (segment.Array == null)
{
throw new ArgumentNullException(nameof(segment));
}
ArgumentNullException.ThrowIfNull(segment.Array, nameof(segment));
// Length zero is explicitly allowed
if (segment.Offset < 0 || segment.Count < 0 || segment.Count > (segment.Array.Length - segment.Offset))

View File

@ -149,13 +149,8 @@ namespace System.Net.WebSockets
}
}
internal static void ValidateBuffer(byte[] buffer, int offset, int count)
internal static void ValidateBuffer(byte[] buffer!!, int offset, int count)
{
if (buffer == null)
{
throw new ArgumentNullException(nameof(buffer));
}
if (offset < 0 || offset > buffer.Length)
{
throw new ArgumentOutOfRangeException(nameof(offset));

View File

@ -43,14 +43,11 @@ namespace System.Resources
public
#if RESOURCES_EXTENSIONS
PreserializedResourceWriter(string fileName)
PreserializedResourceWriter(string fileName!!)
#else
ResourceWriter(string fileName)
ResourceWriter(string fileName!!)
#endif
{
if (fileName == null)
throw new ArgumentNullException(nameof(fileName));
_output = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
_resourceList = new SortedDictionary<string, object?>(FastResourceComparer.Default);
_caseInsensitiveDups = new Dictionary<string, object?>(StringComparer.OrdinalIgnoreCase);
@ -58,13 +55,11 @@ namespace System.Resources
public
#if RESOURCES_EXTENSIONS
PreserializedResourceWriter(Stream stream)
PreserializedResourceWriter(Stream stream!!)
#else
ResourceWriter(Stream stream)
ResourceWriter(Stream stream!!)
#endif
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
if (!stream.CanWrite)
throw new ArgumentException(SR.Argument_StreamNotWritable);
@ -76,11 +71,8 @@ namespace System.Resources
// Adds a string resource to the list of resources to be written to a file.
// They aren't written until Generate() is called.
//
public void AddResource(string name, string? value)
public void AddResource(string name!!, string? value)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (_resourceList == null)
throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved);
@ -92,11 +84,8 @@ namespace System.Resources
// Adds a resource of type Object to the list of resources to be
// written to a file. They aren't written until Generate() is called.
//
public void AddResource(string name, object? value)
public void AddResource(string name!!, object? value)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (_resourceList == null)
throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved);
@ -117,11 +106,8 @@ namespace System.Resources
// written to a file. They aren't written until Generate() is called.
// closeAfterWrite parameter indicates whether to close the stream when done.
//
public void AddResource(string name, Stream? value, bool closeAfterWrite = false)
public void AddResource(string name!!, Stream? value, bool closeAfterWrite = false)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (_resourceList == null)
throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved);
@ -153,11 +139,8 @@ namespace System.Resources
// Adds a named byte array as a resource to the list of resources to
// be written to a file. They aren't written until Generate() is called.
//
public void AddResource(string name, byte[]? value)
public void AddResource(string name!!, byte[]? value)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (_resourceList == null)
throw new InvalidOperationException(SR.InvalidOperation_ResourceWriterSaved);

View File

@ -5,13 +5,8 @@ namespace System.Security.Cryptography.Asn1
{
internal partial struct AttributeAsn
{
public AttributeAsn(AsnEncodedData attribute)
public AttributeAsn(AsnEncodedData attribute!!)
{
if (attribute == null)
{
throw new ArgumentNullException(nameof(attribute));
}
AttrType = attribute.Oid!.Value!;
AttrValues = new[] { new ReadOnlyMemory<byte>(attribute.RawData) };
}

View File

@ -7,13 +7,8 @@ namespace System.Security.Cryptography.Asn1
{
internal partial struct X509ExtensionAsn
{
public X509ExtensionAsn(X509Extension extension)
public X509ExtensionAsn(X509Extension extension!!)
{
if (extension == null)
{
throw new ArgumentNullException(nameof(extension));
}
ExtnId = extension.Oid!.Value!;
Critical = extension.Critical;
ExtnValue = extension.RawData;

View File

@ -34,13 +34,8 @@ namespace System.Security.Cryptography
internal static byte[] ExportEncryptedPkcs8PrivateKey(
AsymmetricAlgorithm key,
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
{
throw new ArgumentNullException(nameof(pbeParameters));
}
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
ReadOnlySpan<char>.Empty,

View File

@ -206,11 +206,8 @@ namespace System.Security.Cryptography
protected override bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten) =>
AsymmetricAlgorithmHelpers.TryHashData(data, destination, hashAlgorithm, out bytesWritten);
public override byte[] CreateSignature(byte[] rgbHash)
public override byte[] CreateSignature(byte[] rgbHash!!)
{
if (rgbHash == null)
throw new ArgumentNullException(nameof(rgbHash));
SafeDsaHandle key = GetKey();
int signatureSize = Interop.AndroidCrypto.DsaEncodedSignatureSize(key);
int signatureFieldSize = Interop.AndroidCrypto.DsaSignatureFieldSize(key) * BitsPerByte;
@ -318,13 +315,8 @@ namespace System.Security.Cryptography
return destination.Slice(0, actualLength);
}
public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
public override bool VerifySignature(byte[] rgbHash!!, byte[] rgbSignature!!)
{
if (rgbHash == null)
throw new ArgumentNullException(nameof(rgbHash));
if (rgbSignature == null)
throw new ArgumentNullException(nameof(rgbSignature));
return VerifySignature((ReadOnlySpan<byte>)rgbHash, (ReadOnlySpan<byte>)rgbSignature);
}

View File

@ -75,11 +75,8 @@ namespace System.Security.Cryptography
public override byte[] ExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
return CngPkcs8.ExportEncryptedPkcs8PrivateKey(
this,
passwordBytes,
@ -88,13 +85,8 @@ namespace System.Security.Cryptography
public override byte[] ExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<char> password,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
{
throw new ArgumentNullException(nameof(pbeParameters));
}
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
password,
@ -113,13 +105,10 @@ namespace System.Security.Cryptography
public override bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters,
PbeParameters pbeParameters!!,
Span<byte> destination,
out int bytesWritten)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
ReadOnlySpan<char>.Empty,
@ -135,13 +124,10 @@ namespace System.Security.Cryptography
public override bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<char> password,
PbeParameters pbeParameters,
PbeParameters pbeParameters!!,
Span<byte> destination,
out int bytesWritten)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
password,

View File

@ -17,13 +17,8 @@ namespace System.Security.Cryptography
// https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_dsa_key_blob_v2
private const int WindowsMaxQSize = 32;
public override byte[] CreateSignature(byte[] rgbHash)
public override byte[] CreateSignature(byte[] rgbHash!!)
{
if (rgbHash == null)
{
throw new ArgumentNullException(nameof(rgbHash));
}
Span<byte> stackBuf = stackalloc byte[WindowsMaxQSize];
ReadOnlySpan<byte> source = AdjustHashSizeIfNecessary(rgbHash, stackBuf);
@ -73,17 +68,8 @@ namespace System.Security.Cryptography
out bytesWritten);
}
public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
public override bool VerifySignature(byte[] rgbHash!!, byte[] rgbSignature!!)
{
if (rgbHash == null)
{
throw new ArgumentNullException(nameof(rgbHash));
}
if (rgbSignature == null)
{
throw new ArgumentNullException(nameof(rgbSignature));
}
return VerifySignatureCore(rgbHash, rgbSignature, DSASignatureFormat.IeeeP1363FixedFieldConcatenation);
}

View File

@ -210,11 +210,8 @@ namespace System.Security.Cryptography
protected override bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten) =>
AsymmetricAlgorithmHelpers.TryHashData(data, destination, hashAlgorithm, out bytesWritten);
public override byte[] CreateSignature(byte[] rgbHash)
public override byte[] CreateSignature(byte[] rgbHash!!)
{
if (rgbHash == null)
throw new ArgumentNullException(nameof(rgbHash));
SafeDsaHandle key = GetKey();
int signatureSize = Interop.Crypto.DsaEncodedSignatureSize(key);
int signatureFieldSize = Interop.Crypto.DsaSignatureFieldSize(key) * BitsPerByte;
@ -323,17 +320,11 @@ namespace System.Security.Cryptography
return destination.Slice(0, actualLength);
}
public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
public override bool VerifySignature(byte[] rgbHash!!, byte[] rgbSignature!!)
{
if (rgbHash == null)
throw new ArgumentNullException(nameof(rgbHash));
if (rgbSignature == null)
throw new ArgumentNullException(nameof(rgbSignature));
return VerifySignature((ReadOnlySpan<byte>)rgbHash, (ReadOnlySpan<byte>)rgbSignature);
}
public override bool VerifySignature(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature) =>
VerifySignatureCore(hash, signature, DSASignatureFormat.IeeeP1363FixedFieldConcatenation);

View File

@ -66,11 +66,8 @@ namespace System.Security.Cryptography
}
}
public override byte[] CreateSignature(byte[] rgbHash)
public override byte[] CreateSignature(byte[] rgbHash!!)
{
if (rgbHash == null)
throw new ArgumentNullException(nameof(rgbHash));
SecKeyPair keys = GetKeys();
if (keys.PrivateKey == null)
@ -93,13 +90,8 @@ namespace System.Security.Cryptography
return ieeeFormatSignature;
}
public override bool VerifySignature(byte[] hash, byte[] signature)
public override bool VerifySignature(byte[] hash!!, byte[] signature!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
if (signature == null)
throw new ArgumentNullException(nameof(signature));
return VerifySignature((ReadOnlySpan<byte>)hash, (ReadOnlySpan<byte>)signature);
}

View File

@ -18,12 +18,11 @@ namespace System.Security.Cryptography
DeriveKeyFromHash(otherPartyPublicKey, HashAlgorithmName.SHA256, null, null);
public override byte[] DeriveKeyFromHash(
ECDiffieHellmanPublicKey otherPartyPublicKey,
ECDiffieHellmanPublicKey otherPartyPublicKey!!,
HashAlgorithmName hashAlgorithm,
byte[]? secretPrepend,
byte[]? secretAppend)
{
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));
ThrowIfDisposed();
@ -37,13 +36,12 @@ namespace System.Security.Cryptography
}
public override byte[] DeriveKeyFromHmac(
ECDiffieHellmanPublicKey otherPartyPublicKey,
ECDiffieHellmanPublicKey otherPartyPublicKey!!,
HashAlgorithmName hashAlgorithm,
byte[]? hmacKey,
byte[]? secretPrepend,
byte[]? secretAppend)
{
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));
ThrowIfDisposed();
@ -57,15 +55,8 @@ namespace System.Security.Cryptography
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
}
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey!!, byte[] prfLabel!!, byte[] prfSeed!!)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (prfLabel == null)
throw new ArgumentNullException(nameof(prfLabel));
if (prfSeed == null)
throw new ArgumentNullException(nameof(prfSeed));
ThrowIfDisposed();
return ECDiffieHellmanDerivation.DeriveKeyTls(

View File

@ -11,10 +11,8 @@ namespace System.Security.Cryptography
{
private ECAndroid _key;
internal ECDiffieHellmanAndroidPublicKey(SafeEcKeyHandle ecKeyHandle)
internal ECDiffieHellmanAndroidPublicKey(SafeEcKeyHandle ecKeyHandle!!)
{
if (ecKeyHandle == null)
throw new ArgumentNullException(nameof(ecKeyHandle));
if (ecKeyHandle.IsInvalid)
throw new ArgumentException(SR.Cryptography_OpenInvalidHandle, nameof(ecKeyHandle));

View File

@ -165,11 +165,8 @@ namespace System.Security.Cryptography
public override byte[] ExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
return CngPkcs8.ExportEncryptedPkcs8PrivateKey(
this,
passwordBytes,
@ -178,13 +175,8 @@ namespace System.Security.Cryptography
public override byte[] ExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<char> password,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
{
throw new ArgumentNullException(nameof(pbeParameters));
}
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
password,
@ -203,13 +195,10 @@ namespace System.Security.Cryptography
public override bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters,
PbeParameters pbeParameters!!,
Span<byte> destination,
out int bytesWritten)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
ReadOnlySpan<char>.Empty,
@ -225,13 +214,10 @@ namespace System.Security.Cryptography
public override bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<char> password,
PbeParameters pbeParameters,
PbeParameters pbeParameters!!,
Span<byte> destination,
out int bytesWritten)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
password,

View File

@ -71,12 +71,11 @@ namespace System.Security.Cryptography
}
public override byte[] DeriveKeyFromHash(
ECDiffieHellmanPublicKey otherPartyPublicKey,
ECDiffieHellmanPublicKey otherPartyPublicKey!!,
HashAlgorithmName hashAlgorithm,
byte[]? secretPrepend,
byte[]? secretAppend)
{
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));
using (SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey))
@ -91,13 +90,12 @@ namespace System.Security.Cryptography
}
public override byte[] DeriveKeyFromHmac(
ECDiffieHellmanPublicKey otherPartyPublicKey,
ECDiffieHellmanPublicKey otherPartyPublicKey!!,
HashAlgorithmName hashAlgorithm,
byte[]? hmacKey,
byte[]? secretPrepend,
byte[]? secretAppend)
{
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));
using (SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey))
@ -116,15 +114,8 @@ namespace System.Security.Cryptography
}
}
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey!!, byte[] prfLabel!!, byte[] prfSeed!!)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (prfLabel == null)
throw new ArgumentNullException(nameof(prfLabel));
if (prfSeed == null)
throw new ArgumentNullException(nameof(prfSeed));
using (SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey))
{
return Interop.NCrypt.DeriveKeyMaterialTls(

View File

@ -15,12 +15,11 @@ namespace System.Security.Cryptography
DeriveKeyFromHash(otherPartyPublicKey, HashAlgorithmName.SHA256, null, null);
public override byte[] DeriveKeyFromHash(
ECDiffieHellmanPublicKey otherPartyPublicKey,
ECDiffieHellmanPublicKey otherPartyPublicKey!!,
HashAlgorithmName hashAlgorithm,
byte[]? secretPrepend,
byte[]? secretAppend)
{
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));
ThrowIfDisposed();
@ -34,13 +33,12 @@ namespace System.Security.Cryptography
}
public override byte[] DeriveKeyFromHmac(
ECDiffieHellmanPublicKey otherPartyPublicKey,
ECDiffieHellmanPublicKey otherPartyPublicKey!!,
HashAlgorithmName hashAlgorithm,
byte[]? hmacKey,
byte[]? secretPrepend,
byte[]? secretAppend)
{
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));
ThrowIfDisposed();
@ -54,15 +52,8 @@ namespace System.Security.Cryptography
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
}
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey!!, byte[] prfLabel!!, byte[] prfSeed!!)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (prfLabel == null)
throw new ArgumentNullException(nameof(prfLabel));
if (prfSeed == null)
throw new ArgumentNullException(nameof(prfSeed));
ThrowIfDisposed();
return ECDiffieHellmanDerivation.DeriveKeyTls(

View File

@ -9,10 +9,8 @@ namespace System.Security.Cryptography
{
private ECOpenSsl _key;
internal ECDiffieHellmanOpenSslPublicKey(SafeEvpPKeyHandle pkeyHandle)
internal ECDiffieHellmanOpenSslPublicKey(SafeEvpPKeyHandle pkeyHandle!!)
{
if (pkeyHandle == null)
throw new ArgumentNullException(nameof(pkeyHandle));
if (pkeyHandle.IsInvalid)
throw new ArgumentException(SR.Cryptography_OpenInvalidHandle, nameof(pkeyHandle));

View File

@ -121,12 +121,11 @@ namespace System.Security.Cryptography
DeriveKeyFromHash(otherPartyPublicKey, HashAlgorithmName.SHA256, null, null);
public override byte[] DeriveKeyFromHash(
ECDiffieHellmanPublicKey otherPartyPublicKey,
ECDiffieHellmanPublicKey otherPartyPublicKey!!,
HashAlgorithmName hashAlgorithm,
byte[]? secretPrepend,
byte[]? secretAppend)
{
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));
ThrowIfDisposed();
@ -140,13 +139,12 @@ namespace System.Security.Cryptography
}
public override byte[] DeriveKeyFromHmac(
ECDiffieHellmanPublicKey otherPartyPublicKey,
ECDiffieHellmanPublicKey otherPartyPublicKey!!,
HashAlgorithmName hashAlgorithm,
byte[]? hmacKey,
byte[]? secretPrepend,
byte[]? secretAppend)
{
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));
ThrowIfDisposed();
@ -160,16 +158,8 @@ namespace System.Security.Cryptography
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
}
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel,
byte[] prfSeed)
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey!!, byte[] prfLabel!!, byte[] prfSeed!!)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (prfLabel == null)
throw new ArgumentNullException(nameof(prfLabel));
if (prfSeed == null)
throw new ArgumentNullException(nameof(prfSeed));
ThrowIfDisposed();
return ECDiffieHellmanDerivation.DeriveKeyTls(

View File

@ -79,11 +79,8 @@ namespace System.Security.Cryptography
}
}
public override byte[] SignHash(byte[] hash)
public override byte[] SignHash(byte[] hash!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
ThrowIfDisposed();
SafeEcKeyHandle key = _key.Value;
int signatureLength = Interop.AndroidCrypto.EcDsaSize(key);
@ -187,13 +184,8 @@ namespace System.Security.Cryptography
return destination.Slice(0, actualLength);
}
public override bool VerifyHash(byte[] hash, byte[] signature)
public override bool VerifyHash(byte[] hash!!, byte[] signature!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
if (signature == null)
throw new ArgumentNullException(nameof(signature));
return VerifyHash((ReadOnlySpan<byte>)hash, (ReadOnlySpan<byte>)signature);
}

View File

@ -182,11 +182,8 @@ namespace System.Security.Cryptography
public override byte[] ExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
return CngPkcs8.ExportEncryptedPkcs8PrivateKey(
this,
passwordBytes,
@ -195,13 +192,8 @@ namespace System.Security.Cryptography
public override byte[] ExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<char> password,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
{
throw new ArgumentNullException(nameof(pbeParameters));
}
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
password,
@ -220,13 +212,10 @@ namespace System.Security.Cryptography
public override bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters,
PbeParameters pbeParameters!!,
Span<byte> destination,
out int bytesWritten)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
ReadOnlySpan<char>.Empty,
@ -242,13 +231,10 @@ namespace System.Security.Cryptography
public override bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<char> password,
PbeParameters pbeParameters,
PbeParameters pbeParameters!!,
Span<byte> destination,
out int bytesWritten)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
password,

View File

@ -16,11 +16,8 @@ namespace System.Security.Cryptography
/// <summary>
/// Computes the signature of a hash that was produced by the hash algorithm specified by "hashAlgorithm."
/// </summary>
public override byte[] SignHash(byte[] hash)
public override byte[] SignHash(byte[] hash!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
int estimatedSize = KeySize switch
{
256 => 64,
@ -87,13 +84,8 @@ namespace System.Security.Cryptography
/// <summary>
/// Verifies that alleged signature of a hash is, in fact, a valid signature of that hash.
/// </summary>
public override bool VerifyHash(byte[] hash, byte[] signature)
public override bool VerifyHash(byte[] hash!!, byte[] signature!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
if (signature == null)
throw new ArgumentNullException(nameof(signature));
return VerifyHashCore(hash, signature, DSASignatureFormat.IeeeP1363FixedFieldConcatenation);
}

View File

@ -89,11 +89,8 @@ namespace System.Security.Cryptography
}
}
public override byte[] SignHash(byte[] hash)
public override byte[] SignHash(byte[] hash!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
ThrowIfDisposed();
SafeEcKeyHandle key = _key.Value;
int signatureLength = Interop.Crypto.EcDsaSize(key);
@ -197,13 +194,8 @@ namespace System.Security.Cryptography
return destination.Slice(0, actualLength);
}
public override bool VerifyHash(byte[] hash, byte[] signature)
public override bool VerifyHash(byte[] hash!!, byte[] signature!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
if (signature == null)
throw new ArgumentNullException(nameof(signature));
return VerifyHash((ReadOnlySpan<byte>)hash, (ReadOnlySpan<byte>)signature);
}

View File

@ -57,11 +57,8 @@ namespace System.Security.Cryptography
}
}
public override byte[] SignHash(byte[] hash)
public override byte[] SignHash(byte[] hash!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
SecKeyPair keys = GetKeys();
if (keys.PrivateKey == null)
@ -111,13 +108,8 @@ namespace System.Security.Cryptography
}
}
public override bool VerifyHash(byte[] hash, byte[] signature)
public override bool VerifyHash(byte[] hash!!, byte[] signature!!)
{
if (hash == null)
throw new ArgumentNullException(nameof(hash));
if (signature == null)
throw new ArgumentNullException(nameof(signature));
return VerifyHash((ReadOnlySpan<byte>)hash, (ReadOnlySpan<byte>)signature);
}

View File

@ -73,13 +73,8 @@ namespace System.Security.Cryptography
}
}
public override byte[] Decrypt(byte[] data, RSAEncryptionPadding padding)
public override byte[] Decrypt(byte[] data!!, RSAEncryptionPadding padding!!)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
if (padding == null)
throw new ArgumentNullException(nameof(padding));
Interop.AndroidCrypto.RsaPadding rsaPadding = GetInteropPadding(padding, out RsaPaddingProcessor? oaepProcessor);
SafeRsaHandle key = GetKey();
@ -109,14 +104,9 @@ namespace System.Security.Cryptography
public override bool TryDecrypt(
ReadOnlySpan<byte> data,
Span<byte> destination,
RSAEncryptionPadding padding,
RSAEncryptionPadding padding!!,
out int bytesWritten)
{
if (padding == null)
{
throw new ArgumentNullException(nameof(padding));
}
Interop.AndroidCrypto.RsaPadding rsaPadding = GetInteropPadding(padding, out RsaPaddingProcessor? oaepProcessor);
SafeRsaHandle key = GetKey();
@ -243,13 +233,8 @@ namespace System.Security.Cryptography
}
}
public override byte[] Encrypt(byte[] data, RSAEncryptionPadding padding)
public override byte[] Encrypt(byte[] data!!, RSAEncryptionPadding padding!!)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
if (padding == null)
throw new ArgumentNullException(nameof(padding));
Interop.AndroidCrypto.RsaPadding rsaPadding = GetInteropPadding(padding, out RsaPaddingProcessor? oaepProcessor);
SafeRsaHandle key = GetKey();
@ -272,13 +257,8 @@ namespace System.Security.Cryptography
return buf;
}
public override bool TryEncrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding, out int bytesWritten)
public override bool TryEncrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding!!, out int bytesWritten)
{
if (padding == null)
{
throw new ArgumentNullException(nameof(padding));
}
Interop.AndroidCrypto.RsaPadding rsaPadding = GetInteropPadding(padding, out RsaPaddingProcessor? oaepProcessor);
SafeRsaHandle key = GetKey();
@ -789,20 +769,11 @@ namespace System.Security.Cryptography
}
public override bool VerifyHash(
byte[] hash,
byte[] signature,
byte[] hash!!,
byte[] signature!!,
HashAlgorithmName hashAlgorithm,
RSASignaturePadding padding)
{
if (hash == null)
{
throw new ArgumentNullException(nameof(hash));
}
if (signature == null)
{
throw new ArgumentNullException(nameof(signature));
}
return VerifyHash(new ReadOnlySpan<byte>(hash), new ReadOnlySpan<byte>(signature), hashAlgorithm, padding);
}

View File

@ -34,17 +34,8 @@ namespace System.Security.Cryptography
// Conveniently, Encrypt() and Decrypt() are identical save for the actual P/Invoke call to CNG. Thus, both
// array-based APIs invoke this common helper with the "encrypt" parameter determining whether encryption or decryption is done.
private unsafe byte[] EncryptOrDecrypt(byte[] data, RSAEncryptionPadding padding, bool encrypt)
private unsafe byte[] EncryptOrDecrypt(byte[] data!!, RSAEncryptionPadding padding!!, bool encrypt)
{
if (data == null)
{
throw new ArgumentNullException(nameof(data));
}
if (padding == null)
{
throw new ArgumentNullException(nameof(padding));
}
int modulusSizeInBytes = RsaPaddingProcessor.BytesRequiredForBitCount(KeySize);
if (!encrypt && data.Length != modulusSizeInBytes)
@ -126,13 +117,8 @@ namespace System.Security.Cryptography
// Conveniently, Encrypt() and Decrypt() are identical save for the actual P/Invoke call to CNG. Thus, both
// span-based APIs invoke this common helper with the "encrypt" parameter determining whether encryption or decryption is done.
private unsafe bool TryEncryptOrDecrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding, bool encrypt, out int bytesWritten)
private unsafe bool TryEncryptOrDecrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding!!, bool encrypt, out int bytesWritten)
{
if (padding == null)
{
throw new ArgumentNullException(nameof(padding));
}
int modulusSizeInBytes = RsaPaddingProcessor.BytesRequiredForBitCount(KeySize);
if (!encrypt && data.Length != modulusSizeInBytes)

View File

@ -191,11 +191,8 @@ namespace System.Security.Cryptography
public override byte[] ExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
return CngPkcs8.ExportEncryptedPkcs8PrivateKey(
this,
passwordBytes,
@ -204,13 +201,8 @@ namespace System.Security.Cryptography
public override byte[] ExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<char> password,
PbeParameters pbeParameters)
PbeParameters pbeParameters!!)
{
if (pbeParameters == null)
{
throw new ArgumentNullException(nameof(pbeParameters));
}
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
password,
@ -229,13 +221,10 @@ namespace System.Security.Cryptography
public override bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes,
PbeParameters pbeParameters,
PbeParameters pbeParameters!!,
Span<byte> destination,
out int bytesWritten)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
ReadOnlySpan<char>.Empty,
@ -251,13 +240,10 @@ namespace System.Security.Cryptography
public override bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<char> password,
PbeParameters pbeParameters,
PbeParameters pbeParameters!!,
Span<byte> destination,
out int bytesWritten)
{
if (pbeParameters == null)
throw new ArgumentNullException(nameof(pbeParameters));
PasswordBasedEncryption.ValidatePbeParameters(
pbeParameters,
password,

View File

@ -40,13 +40,8 @@ namespace System.Security.Cryptography
/// <summary>
/// Computes the signature of a hash that was produced by the hash algorithm specified by "hashAlgorithm."
/// </summary>
public override byte[] SignHash(byte[] hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
public override byte[] SignHash(byte[] hash!!, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
{
if (hash == null)
{
throw new ArgumentNullException(nameof(hash));
}
string? hashAlgorithmName = hashAlgorithm.Name;
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithmName, nameof(hashAlgorithm));
@ -127,17 +122,8 @@ namespace System.Security.Cryptography
/// <summary>
/// Verifies that alleged signature of a hash is, in fact, a valid signature of that hash.
/// </summary>
public override bool VerifyHash(byte[] hash, byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
public override bool VerifyHash(byte[] hash!!, byte[] signature!!, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
{
if (hash == null)
{
throw new ArgumentNullException(nameof(hash));
}
if (signature == null)
{
throw new ArgumentNullException(nameof(signature));
}
return VerifyHash((ReadOnlySpan<byte>)hash, (ReadOnlySpan<byte>)signature, hashAlgorithm, padding);
}

Some files were not shown because too many files have changed in this diff Show More