Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,7 @@ public ModuleBuilder DefineDynamicModule(string name)

private ModuleBuilder DefineDynamicModuleInternalNoLock(string name)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (name.Length == 0)
{
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
}
ArgumentException.ThrowIfNullOrEmpty(name);
if (name[0] == '\0')
{
throw new ArgumentException(SR.Argument_InvalidName, nameof(name));
Expand Down Expand Up @@ -467,14 +460,7 @@ public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? vers
/// <param name="name">The name of module for the look up.</param>
private ModuleBuilder? GetDynamicModuleNoLock(string name)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (name.Length == 0)
{
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
}
ArgumentException.ThrowIfNullOrEmpty(name);

for (int i = 0; i < _assemblyData._moduleBuilderList.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,12 @@ public sealed class FieldBuilder : FieldInfo
internal FieldBuilder(TypeBuilder typeBuilder, string fieldName, Type type,
Type[]? requiredCustomModifiers, Type[]? optionalCustomModifiers, FieldAttributes attributes)
{
if (fieldName == null)
throw new ArgumentNullException(nameof(fieldName));

if (fieldName.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(fieldName));
ArgumentException.ThrowIfNullOrEmpty(fieldName);

if (fieldName[0] == '\0')
throw new ArgumentException(SR.Argument_IllegalName, nameof(fieldName));

if (type == null)
throw new ArgumentNullException(nameof(type));
ArgumentNullException.ThrowIfNull(type);

if (type == typeof(void))
throw new ArgumentException(SR.Argument_BadFieldType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1273,11 +1273,7 @@ public virtual void UsingNamespace(string usingNamespace)
// Specifying the namespace to be used in evaluating locals and watches
// for the current active lexical scope.

if (usingNamespace == null)
throw new ArgumentNullException(nameof(usingNamespace));

if (usingNamespace.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(usingNamespace));
ArgumentException.ThrowIfNullOrEmpty(usingNamespace);

MethodBuilder? methodBuilder = m_methodBuilder as MethodBuilder;
if (methodBuilder == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,18 @@ internal MethodBuilder(string name, MethodAttributes attributes, CallingConventi
Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers,
ModuleBuilder mod, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TypeBuilder type)
{
if (name == null)
throw new ArgumentNullException(nameof(name));

if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
ArgumentException.ThrowIfNullOrEmpty(name);

if (name[0] == '\0')
throw new ArgumentException(SR.Argument_IllegalName, nameof(name));

if (mod == null)
throw new ArgumentNullException(nameof(mod));
ArgumentNullException.ThrowIfNull(mod);

if (parameterTypes != null)
{
foreach (Type t in parameterTypes)
{
if (t == null)
throw new ArgumentNullException(nameof(parameterTypes));
ArgumentNullException.ThrowIfNull(t, nameof(parameterTypes));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,14 +948,7 @@ private MethodBuilder DefineGlobalMethodNoLock(string name, MethodAttributes att
{
throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated);
}
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (name.Length == 0)
{
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
}
ArgumentException.ThrowIfNullOrEmpty(name);
if ((attributes & MethodAttributes.Static) == 0)
{
throw new ArgumentException(SR.Argument_GlobalFunctionHasToBeStatic);
Expand Down Expand Up @@ -1352,18 +1345,8 @@ internal int GetArrayMethodToken(Type arrayClass, string methodName, CallingConv
private int GetArrayMethodTokenNoLock(Type arrayClass, string methodName, CallingConventions callingConvention,
Type? returnType, Type[]? parameterTypes)
{
if (arrayClass == null)
{
throw new ArgumentNullException(nameof(arrayClass));
}
if (methodName == null)
{
throw new ArgumentNullException(nameof(methodName));
}
if (methodName.Length == 0)
{
throw new ArgumentException(SR.Argument_EmptyName, nameof(methodName));
}
ArgumentNullException.ThrowIfNull(arrayClass);
ArgumentException.ThrowIfNullOrEmpty(methodName);
if (!arrayClass.IsArray)
{
throw new ArgumentException(SR.Argument_HasToBeArrayClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ internal PropertyBuilder(
int prToken, // the metadata token for this property
TypeBuilder containingType) // the containing type
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
ArgumentException.ThrowIfNullOrEmpty(name);
if (name[0] == '\0')
throw new ArgumentException(SR.Argument_IllegalName, nameof(name));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,7 @@ internal TypeBuilder(
string fullname, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent, Type[]? interfaces, ModuleBuilder module,
PackingSize iPackingSize, int iTypeSize, TypeBuilder? enclosingType)
{
if (fullname == null)
throw new ArgumentNullException(nameof(fullname));

if (fullname.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(fullname));
ArgumentException.ThrowIfNullOrEmpty(fullname);

if (fullname[0] == '\0')
throw new ArgumentException(SR.Argument_IllegalName, nameof(fullname));
Expand Down Expand Up @@ -581,11 +577,7 @@ private FieldBuilder DefineDataHelper(string name, byte[]? data, int size, Field
FieldBuilder fdBuilder;
TypeAttributes typeAttributes;

if (name == null)
throw new ArgumentNullException(nameof(name));

if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
ArgumentException.ThrowIfNullOrEmpty(name);

if (size <= 0 || size >= 0x003f0000)
throw new ArgumentException(SR.Argument_BadSizeForData);
Expand Down Expand Up @@ -1282,11 +1274,7 @@ private MethodBuilder DefineMethodNoLock(string name, MethodAttributes attribute
Type? returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers,
Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers)
{
if (name == null)
throw new ArgumentNullException(nameof(name));

if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
ArgumentException.ThrowIfNullOrEmpty(name);

AssemblyBuilder.CheckContext(returnType);
AssemblyBuilder.CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
Expand Down Expand Up @@ -1374,23 +1362,9 @@ private MethodBuilder DefinePInvokeMethodHelper(

lock (SyncRoot)
{
if (name == null)
throw new ArgumentNullException(nameof(name));

if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));

if (dllName == null)
throw new ArgumentNullException(nameof(dllName));

if (dllName.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(dllName));

if (importName == null)
throw new ArgumentNullException(nameof(importName));

if (importName.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(importName));
ArgumentException.ThrowIfNullOrEmpty(name);
ArgumentException.ThrowIfNullOrEmpty(dllName);
ArgumentException.ThrowIfNullOrEmpty(importName);

if ((attributes & MethodAttributes.Abstract) != 0)
throw new ArgumentException(SR.Argument_BadPInvokeMethod);
Expand Down Expand Up @@ -1792,10 +1766,7 @@ private PropertyBuilder DefinePropertyNoLock(string name, PropertyAttributes att
Type returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers,
Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
ArgumentException.ThrowIfNullOrEmpty(name);

AssemblyBuilder.CheckContext(returnType);
AssemblyBuilder.CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
Expand Down Expand Up @@ -1847,10 +1818,7 @@ public EventBuilder DefineEvent(string name, EventAttributes attributes, Type ev

private EventBuilder DefineEventNoLock(string name, EventAttributes attributes, Type eventtype)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
ArgumentException.ThrowIfNullOrEmpty(name);
if (name[0] == '\0')
throw new ArgumentException(SR.Argument_IllegalName, nameof(name));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,7 @@ private static partial void GetTypeByName(string name, bool throwOnError, bool i

internal static RuntimeType GetTypeByNameUsingCARules(string name, RuntimeModule scope)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentException(null, nameof(name));
ArgumentException.ThrowIfNullOrEmpty(name);

RuntimeType? type = null;
GetTypeByNameUsingCARules(name, new QCallModule(ref scope), ObjectHandleOnStack.Create(ref type));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ public override byte[] DeriveKeyFromHash(
byte[]? secretPrepend,
byte[]? secretAppend)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (string.IsNullOrEmpty(hashAlgorithm.Name))
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));

ThrowIfDisposed();

Expand All @@ -45,10 +43,8 @@ public override byte[] DeriveKeyFromHmac(
byte[]? secretPrepend,
byte[]? secretAppend)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (string.IsNullOrEmpty(hashAlgorithm.Name))
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));

ThrowIfDisposed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ public override byte[] DeriveKeyFromHash(
byte[]? secretPrepend,
byte[]? secretAppend)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (string.IsNullOrEmpty(hashAlgorithm.Name))
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));

using (SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey))
{
Expand All @@ -99,10 +97,8 @@ public override byte[] DeriveKeyFromHmac(
byte[]? secretPrepend,
byte[]? secretAppend)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (string.IsNullOrEmpty(hashAlgorithm.Name))
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));

using (SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ public override byte[] DeriveKeyFromHash(
byte[]? secretPrepend,
byte[]? secretAppend)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (string.IsNullOrEmpty(hashAlgorithm.Name))
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));

ThrowIfDisposed();

Expand All @@ -46,10 +44,8 @@ public override byte[] DeriveKeyFromHmac(
byte[]? secretPrepend,
byte[]? secretAppend)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (string.IsNullOrEmpty(hashAlgorithm.Name))
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));

ThrowIfDisposed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ public override byte[] DeriveKeyFromHash(
byte[]? secretPrepend,
byte[]? secretAppend)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (string.IsNullOrEmpty(hashAlgorithm.Name))
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));

ThrowIfDisposed();

Expand All @@ -143,10 +141,8 @@ public override byte[] DeriveKeyFromHmac(
byte[]? secretPrepend,
byte[]? secretAppend)
{
if (otherPartyPublicKey == null)
throw new ArgumentNullException(nameof(otherPartyPublicKey));
if (string.IsNullOrEmpty(hashAlgorithm.Name))
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
ArgumentNullException.ThrowIfNull(otherPartyPublicKey);
ArgumentException.ThrowIfNullOrEmpty(hashAlgorithm.Name, nameof(hashAlgorithm));

ThrowIfDisposed();

Expand Down
Loading