1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-12 02:30:29 +09:00

Enable new analyzers CA1510/11/12/13 and CA1856/57/58 (#80149)

* Enable new analyzers CA1510/11/12/13 and CA1856/57/58

CA1510: Use ArgumentNullException throw helper
CA1511: Use ArgumentException throw helper
CA1512: Use ArgumentOutOfRangeException throw helper
CA1513: Use ObjectDisposedException throw helper
CA1856: Incorrect usage of ConstantExpected attribute
CA1857: A constant is expected for the parameter
CA1858: Use 'StartsWith' instead of 'IndexOf'

* More fixes

* Address PR feedback
This commit is contained in:
Stephen Toub 2023-01-07 15:48:01 -05:00 committed by GitHub
parent ca5e54a040
commit 699acfac91
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
139 changed files with 393 additions and 724 deletions

View file

@ -238,6 +238,18 @@ dotnet_diagnostic.CA1508.severity = none
# CA1509: Invalid entry in code metrics rule specification file
dotnet_diagnostic.CA1509.severity = none
# CA1510: Use ArgumentNullException throw helper
dotnet_diagnostic.CA1510.severity = warning
# CA1511: Use ArgumentException throw helper
dotnet_diagnostic.CA1511.severity = warning
# CA1512: Use ArgumentOutOfRangeException throw helper
dotnet_diagnostic.CA1512.severity = warning
# CA1513: Use ObjectDisposedException throw helper
dotnet_diagnostic.CA1513.severity = warning
# CA1700: Do not name enum values 'Reserved'
dotnet_diagnostic.CA1700.severity = none
@ -420,6 +432,15 @@ dotnet_diagnostic.CA1854.severity = warning
# CA1855: Prefer 'Clear' over 'Fill'
dotnet_diagnostic.CA1855.severity = warning
# CA1856: Incorrect usage of ConstantExpected attribute
dotnet_diagnostic.CA1856.severity = error
# CA1857: A constant is expected for the parameter
dotnet_diagnostic.CA1857.severity = warning
# CA1858: Use 'StartsWith' instead of 'IndexOf'
dotnet_diagnostic.CA1858.severity = warning
# CA2000: Dispose objects before losing scope
dotnet_diagnostic.CA2000.severity = none
@ -471,9 +492,6 @@ dotnet_diagnostic.CA2100.severity = none
# CA2101: Specify marshaling for P/Invoke string arguments
dotnet_diagnostic.CA2101.severity = none
# CA2109: Review visible event handlers
dotnet_diagnostic.CA2109.severity = none
# CA2119: Seal methods that satisfy private interfaces
dotnet_diagnostic.CA2119.severity = none

View file

@ -237,6 +237,18 @@ dotnet_diagnostic.CA1508.severity = none
# CA1509: Invalid entry in code metrics rule specification file
dotnet_diagnostic.CA1509.severity = none
# CA1510: Use ArgumentNullException throw helper
dotnet_diagnostic.CA1510.severity = none
# CA1511: Use ArgumentException throw helper
dotnet_diagnostic.CA1511.severity = none
# CA1512: Use ArgumentOutOfRangeException throw helper
dotnet_diagnostic.CA1512.severity = none
# CA1513: Use ObjectDisposedException throw helper
dotnet_diagnostic.CA1513.severity = none
# CA1700: Do not name enum values 'Reserved'
dotnet_diagnostic.CA1700.severity = none
@ -417,6 +429,15 @@ dotnet_diagnostic.CA1854.severity = none
# CA1855: Prefer 'Clear' over 'Fill'
dotnet_diagnostic.CA1855.severity = none
# CA1856: Incorrect usage of ConstantExpected attribute
dotnet_diagnostic.CA1856.severity = none
# CA1857: A constant is expected for the parameter
dotnet_diagnostic.CA1857.severity = none
# CA1858: Use 'StartsWith' instead of 'IndexOf'
dotnet_diagnostic.CA1858.severity = none
# CA2000: Dispose objects before losing scope
dotnet_diagnostic.CA2000.severity = none
@ -468,9 +489,6 @@ dotnet_diagnostic.CA2100.severity = none
# CA2101: Specify marshaling for P/Invoke string arguments
dotnet_diagnostic.CA2101.severity = none
# CA2109: Review visible event handlers
dotnet_diagnostic.CA2109.severity = none
# CA2119: Seal methods that satisfy private interfaces
dotnet_diagnostic.CA2119.severity = none

View file

@ -62,7 +62,7 @@ namespace System.Collections.Generic
//
public LowLevelList(int capacity)
{
if (capacity < 0) throw new ArgumentOutOfRangeException(nameof(capacity));
ArgumentOutOfRangeException.ThrowIfNegative(capacity);
if (capacity == 0)
_items = s_emptyArray;
@ -76,8 +76,7 @@ namespace System.Collections.Generic
//
public LowLevelList(IEnumerable<T> collection)
{
if (collection == null)
throw new ArgumentNullException(nameof(collection));
ArgumentNullException.ThrowIfNull(collection);
ICollection<T>? c = collection as ICollection<T>;
if (c != null)
@ -123,10 +122,7 @@ namespace System.Collections.Generic
}
set
{
if (value < _size)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
ArgumentOutOfRangeException.ThrowIfLessThan(value, _size);
if (value != _items.Length)
{
@ -160,19 +156,13 @@ namespace System.Collections.Generic
get
{
// Following trick can reduce the range check by one
if ((uint)index >= (uint)_size)
{
throw new ArgumentOutOfRangeException();
}
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, (uint)_size, nameof(index));
return _items[index];
}
set
{
if ((uint)index >= (uint)_size)
{
throw new ArgumentOutOfRangeException();
}
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, (uint)_size, nameof(index));
_items[index] = value;
_version++;
}
@ -298,8 +288,7 @@ namespace System.Collections.Generic
//
public int IndexOf(T item, int index)
{
if (index > _size)
throw new ArgumentOutOfRangeException(nameof(index));
ArgumentOutOfRangeException.ThrowIfGreaterThan(index, _size);
return Array.IndexOf(_items, item, index, _size - index);
}
@ -310,10 +299,8 @@ namespace System.Collections.Generic
public void Insert(int index, T item)
{
// Note that insertions at the end are legal.
if ((uint)index > (uint)_size)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)index, (uint)_size, nameof(index));
if (_size == _items.Length) EnsureCapacity(_size + 1);
if (index < _size)
{
@ -331,15 +318,8 @@ namespace System.Collections.Generic
//
public void InsertRange(int index, IEnumerable<T> collection)
{
if (collection == null)
{
throw new ArgumentNullException(nameof(collection));
}
if ((uint)index > (uint)_size)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
ArgumentNullException.ThrowIfNull(collection);
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)index, (uint)_size, nameof(index));
ICollection<T>? c = collection as ICollection<T>;
if (c != null)
@ -402,10 +382,7 @@ namespace System.Collections.Generic
// The complexity is O(n).
public int RemoveAll(Predicate<T> match)
{
if (match == null)
{
throw new ArgumentNullException(nameof(match));
}
ArgumentNullException.ThrowIfNull(match);
int freeIndex = 0; // the first free slot in items array
@ -438,10 +415,7 @@ namespace System.Collections.Generic
//
public void RemoveAt(int index)
{
if ((uint)index >= (uint)_size)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, (uint)_size, nameof(index));
_size--;
if (index < _size)
{

View file

@ -41,8 +41,7 @@ namespace Internal.Reflection.Core.Execution
//
public Type GetType(string typeName, Func<AssemblyName, Assembly> assemblyResolver, Func<Assembly, string, bool, Type> typeResolver, bool throwOnError, bool ignoreCase, IList<string> defaultAssemblyNames)
{
if (typeName == null)
throw new ArgumentNullException(nameof(typeName));
ArgumentNullException.ThrowIfNull(typeName);
if (typeName.Length == 0)
{

View file

@ -72,8 +72,7 @@ namespace Internal.Reflection.Extensions.NonPortable
return EventCustomAttributeSearcher.Default.GetMatchingCustomAttributes(eventInfo, optionalAttributeTypeFilter, inherit, skipTypeValidation: skipTypeValidation);
}
if (element == null)
throw new ArgumentNullException();
ArgumentNullException.ThrowIfNull(element);
throw new NotSupportedException(); // Shouldn't get here.
}

View file

@ -33,14 +33,12 @@ namespace Internal.Reflection.Extensions.NonPortable
{
// Do all parameter validation here before we enter the iterator function (so that exceptions from validations
// show up immediately rather than on the first MoveNext()).
if (element == null)
throw new ArgumentNullException(nameof(element));
ArgumentNullException.ThrowIfNull(element);
bool typeFilterKnownToBeSealed = false;
if (!skipTypeValidation)
{
if (optionalAttributeTypeFilter == null)
throw new ArgumentNullException("type");
ArgumentNullException.ThrowIfNull(optionalAttributeTypeFilter, "type");
if (!(optionalAttributeTypeFilter == typeof(Attribute) ||
optionalAttributeTypeFilter.IsSubclassOf(typeof(Attribute))))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);

View file

@ -19,8 +19,7 @@ namespace System
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)]
Type type, bool nonPublic)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
ArgumentNullException.ThrowIfNull(type);
type = type.UnderlyingSystemType;
CreateInstanceCheckType(type);
@ -46,8 +45,7 @@ namespace System
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)]
Type type, BindingFlags bindingAttr, Binder binder, object?[]? args, CultureInfo? culture, object?[]? activationAttributes)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
ArgumentNullException.ThrowIfNull(type);
// If they didn't specify a lookup, then we will provide the default lookup.
const BindingFlags LookupMask = (BindingFlags)0x000000FF;

View file

@ -65,10 +65,7 @@ namespace System
{
public static int GetGeneration(object obj)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
ArgumentNullException.ThrowIfNull(obj);
return RuntimeImports.RhGetGeneration(obj);
}
@ -389,18 +386,14 @@ namespace System
public static void SuppressFinalize(object obj)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
ArgumentNullException.ThrowIfNull(obj);
RuntimeImports.RhSuppressFinalize(obj);
}
public static void ReRegisterForFinalize(object obj)
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
ArgumentNullException.ThrowIfNull(obj);
RuntimeImports.RhReRegisterForFinalize(obj);
}

View file

@ -29,8 +29,7 @@ namespace System.Reflection
public static Assembly Load(string assemblyString)
{
if (assemblyString == null)
throw new ArgumentNullException(nameof(assemblyString));
ArgumentNullException.ThrowIfNull(assemblyString);
AssemblyName name = new AssemblyName(assemblyString);
return Load(name);
@ -39,8 +38,7 @@ namespace System.Reflection
[Obsolete("Assembly.LoadWithPartialName has been deprecated. Use Assembly.Load() instead.")]
public static Assembly LoadWithPartialName(string partialName)
{
if (partialName == null)
throw new ArgumentNullException(nameof(partialName));
ArgumentNullException.ThrowIfNull(partialName);
if ((partialName.Length == 0) || (partialName[0] == '\0'))
throw new ArgumentException(SR.Format_StringZeroLength, nameof(partialName));

View file

@ -18,10 +18,7 @@ namespace System.Reflection.Metadata
[CLSCompliant(false)] // out byte* blob
public static unsafe bool TryGetRawMetadata(this Assembly assembly, out byte* blob, out int length)
{
if (assembly == null)
{
throw new ArgumentNullException(nameof(assembly));
}
ArgumentNullException.ThrowIfNull(assembly);
blob = null;
length = 0;

View file

@ -71,10 +71,7 @@ namespace System.Reflection.Runtime.Assemblies
[RequiresUnreferencedCode("Types might be removed")]
public sealed override Type GetType(string name, bool throwOnError, bool ignoreCase)
{
if (name == null)
throw new ArgumentNullException();
if (name.Length == 0)
throw new ArgumentException();
ArgumentException.ThrowIfNullOrEmpty(name);
TypeName typeName = TypeParser.ParseAssemblyQualifiedTypeName(name, throwOnError: throwOnError);
if (typeName == null)

View file

@ -103,8 +103,7 @@ namespace System.Reflection.Runtime.EventInfos.NativeFormat
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
if (!(other is NativeFormatRuntimeEventInfo otherEvent))
return false;

View file

@ -94,8 +94,7 @@ namespace System.Reflection.Runtime.FieldInfos.NativeFormat
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
if (!(other is NativeFormatRuntimeFieldInfo otherField))
return false;

View file

@ -32,16 +32,14 @@ namespace System.Reflection.Runtime.Assemblies
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, skipTypeValidation: true); // inherit is meaningless for Assemblies
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, skipTypeValidation: true); // inherit is meaningless for Assemblies
return cads.Any();
}
@ -57,16 +55,14 @@ namespace System.Reflection.Runtime.MethodInfos
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: inherit, skipTypeValidation: true);
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: inherit, skipTypeValidation: true);
return cads.Any();
}
@ -82,16 +78,14 @@ namespace System.Reflection.Runtime.EventInfos
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: false, skipTypeValidation: true); // Desktop compat: for events, this form of the api ignores "inherit"
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: false, skipTypeValidation: true); // Desktop compat: for events, this form of the api ignores "inherit"
return cads.Any();
}
@ -107,16 +101,14 @@ namespace System.Reflection.Runtime.FieldInfos
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: inherit, skipTypeValidation: true);
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: inherit, skipTypeValidation: true);
return cads.Any();
}
@ -132,16 +124,14 @@ namespace System.Reflection.Runtime.MethodInfos
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: inherit, skipTypeValidation: true);
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: inherit, skipTypeValidation: true);
return cads.Any();
}
@ -157,16 +147,14 @@ namespace System.Reflection.Runtime.Modules
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, skipTypeValidation: true); // inherit is meaningless for Modules
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, skipTypeValidation: true); // inherit is meaningless for Modules
return cads.Any();
}
@ -182,16 +170,14 @@ namespace System.Reflection.Runtime.ParameterInfos
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: false, skipTypeValidation: true); // Desktop compat: for parameters, this form of the api ignores "inherit"
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: false, skipTypeValidation: true); // Desktop compat: for parameters, this form of the api ignores "inherit"
return cads.Any();
}
@ -207,16 +193,14 @@ namespace System.Reflection.Runtime.PropertyInfos
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: false, skipTypeValidation: true); // Desktop compat: for properties, this form of the api ignores "inherit"
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: false, skipTypeValidation: true); // Desktop compat: for properties, this form of the api ignores "inherit"
return cads.Any();
}
@ -232,16 +216,14 @@ namespace System.Reflection.Runtime.TypeInfos
public sealed override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: inherit, skipTypeValidation: true);
return cads.InstantiateAsArray(attributeType);
}
public sealed override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
ArgumentNullException.ThrowIfNull(attributeType);
IEnumerable<CustomAttributeData> cads = this.GetMatchingCustomAttributes(attributeType, inherit: inherit, skipTypeValidation: true);
return cads.Any();
}

View file

@ -32,8 +32,8 @@ namespace System.Reflection.Runtime.General
public sealed override Assembly Load(AssemblyName assemblyRef, bool throwOnFileNotFound)
{
if (assemblyRef == null)
throw new ArgumentNullException(nameof(assemblyRef));
ArgumentNullException.ThrowIfNull(assemblyRef);
if (throwOnFileNotFound)
return RuntimeAssemblyInfo.GetRuntimeAssembly(assemblyRef.ToRuntimeAssemblyName());
else
@ -50,8 +50,7 @@ namespace System.Reflection.Runtime.General
public sealed override Assembly Load(string assemblyPath)
{
if (assemblyPath == null)
throw new ArgumentNullException(nameof(assemblyPath));
ArgumentNullException.ThrowIfNull(assemblyPath);
return RuntimeAssemblyInfo.GetRuntimeAssemblyFromPath(assemblyPath);
}
@ -209,10 +208,8 @@ namespace System.Reflection.Runtime.General
private static Delegate CreateDelegateWorker(Type type, object firstArgument, MethodInfo method, bool throwOnBindFailure, bool allowClosed)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
if (method == null)
throw new ArgumentNullException(nameof(method));
ArgumentNullException.ThrowIfNull(type);
ArgumentNullException.ThrowIfNull(method);
if (!(type is RuntimeTypeInfo runtimeDelegateType))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type));
@ -237,12 +234,9 @@ namespace System.Reflection.Runtime.General
[RequiresUnreferencedCode("The target method might be removed")]
public sealed override 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));
ArgumentNullException.ThrowIfNull(type);
ArgumentNullException.ThrowIfNull(target);
ArgumentNullException.ThrowIfNull(method);
if (!(type is RuntimeTypeInfo runtimeDelegateType))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type));
@ -263,14 +257,11 @@ namespace System.Reflection.Runtime.General
// V1 api: Creates open delegates to static methods only, relaxed signature checking disallowed.
public sealed override 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));
ArgumentNullException.ThrowIfNull(type);
ArgumentNullException.ThrowIfNull(target);
if (target.ContainsGenericParameters)
throw new ArgumentException(SR.Arg_UnboundGenParam, nameof(target));
if (method == null)
throw new ArgumentNullException(nameof(method));
ArgumentNullException.ThrowIfNull(method);
if (!(type is RuntimeTypeInfo runtimeDelegateType))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type));
@ -367,10 +358,8 @@ namespace System.Reflection.Runtime.General
public sealed override void MakeTypedReference(object target, FieldInfo[] flds, out Type type, out int offset)
{
if (target == null)
throw new ArgumentNullException(nameof(target));
if (flds == null)
throw new ArgumentNullException(nameof(flds));
ArgumentNullException.ThrowIfNull(target);
ArgumentNullException.ThrowIfNull(flds);
if (flds.Length == 0)
throw new ArgumentException(SR.Arg_ArrayZeroError, nameof(flds));

View file

@ -36,8 +36,7 @@ namespace System.Reflection.Runtime.Assemblies
StringBuilder sb = new StringBuilder();
if (type == null)
{
if (name == null)
throw new ArgumentNullException(nameof(type));
ArgumentNullException.ThrowIfNull(name, nameof(type));
}
else
{
@ -178,8 +177,7 @@ namespace System.Reflection.Runtime.TypeInfos
Justification = "The returned interface is one of the interfaces implemented by this type and does have DynamicallyAccessedMemberTypes.Interfaces")]
public sealed override Type? GetInterface(string name, bool ignoreCase)
{
if (name == null)
throw new ArgumentNullException("fullname" /* Yep, CoreCLR names this different than the ref assembly */);
ArgumentNullException.ThrowIfNull(name, "fullname" /* Yep, CoreCLR names this different than the ref assembly */);
string simpleName;
string ns;

View file

@ -32,8 +32,7 @@ namespace System.Reflection.Runtime.MethodInfos
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
// This logic is written to match CoreCLR's behavior.
return other is RuntimeCLSIDNullaryConstructorInfo;

View file

@ -72,8 +72,7 @@ namespace System.Reflection.Runtime.MethodInfos
private Delegate CreateDelegateWorker(Type delegateType, object target, bool allowClosed)
{
if (delegateType == null)
throw new ArgumentNullException(nameof(delegateType));
ArgumentNullException.ThrowIfNull(delegateType);
if (!(delegateType is RuntimeTypeInfo runtimeDelegateType))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(delegateType));

View file

@ -123,8 +123,7 @@ namespace System.Reflection.Runtime.MethodInfos
[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 sealed override MethodInfo MakeGenericMethod(params Type[] typeArguments)
{
if (typeArguments == null)
throw new ArgumentNullException(nameof(typeArguments));
ArgumentNullException.ThrowIfNull(typeArguments);
if (GenericTypeParameters.Length == 0)
throw new InvalidOperationException(SR.Format(SR.Arg_NotGenericMethodDefinition, this));
RuntimeTypeInfo[] genericTypeArguments = new RuntimeTypeInfo[typeArguments.Length];
@ -196,8 +195,7 @@ namespace System.Reflection.Runtime.MethodInfos
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
// Do not rewrite as a call to IsConstructedGenericMethod - we haven't yet established that "other" is a runtime-implemented member yet!
if (other is RuntimeConstructedGenericMethodInfo otherConstructedGenericMethod)

View file

@ -122,8 +122,7 @@ namespace System.Reflection.Runtime.MethodInfos
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
if (!(other is RuntimePlainConstructorInfo<TRuntimeMethodCommon> otherConstructor))
return false;

View file

@ -102,8 +102,7 @@ namespace System.Reflection.Runtime.MethodInfos
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
// This logic is written to match CoreCLR's behavior.
return other is ConstructorInfo && other is IRuntimeMemberInfoWithNoMetadataDefinition;

View file

@ -56,8 +56,7 @@ namespace System.Reflection.Runtime.MethodInfos
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
// This logic is written to match CoreCLR's behavior.
return other is MethodInfo && other is IRuntimeMemberInfoWithNoMetadataDefinition;

View file

@ -77,8 +77,7 @@ namespace System.Reflection.Runtime.PropertyInfos.NativeFormat
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
if (!(other is NativeFormatRuntimePropertyInfo otherProperty))
return false;

View file

@ -45,8 +45,7 @@ namespace System.Reflection.Runtime.TypeInfos
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
// This logic is written to match CoreCLR's behavior.
return other is RuntimeCLSIDTypeInfo;

View file

@ -71,8 +71,7 @@ namespace System.Reflection.Runtime.TypeInfos
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
// Unlike most other MemberInfo objects, generic parameter types never get cloned due to containing generic types being instantiated.
// That is, their DeclaringType is always the generic type definition. As a Type, the ReflectedType property is always equal to the DeclaringType.

View file

@ -102,8 +102,7 @@ namespace System.Reflection.Runtime.TypeInfos
public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
// This logic is written to match CoreCLR's behavior.
return other is Type && other is IRuntimeMemberInfoWithNoMetadataDefinition;

View file

@ -46,8 +46,7 @@ namespace System.Reflection.Runtime.TypeInfos
// Left unsealed as RuntimeCLSIDTypeInfo has special behavior and needs to override.
public override bool HasSameMetadataDefinitionAs(MemberInfo other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
ArgumentNullException.ThrowIfNull(other);
// Do not rewrite as a call to IsConstructedGenericType - we haven't yet established that "other" is a runtime-implemented member yet!
if (other is RuntimeConstructedGenericTypeInfo otherConstructedGenericType)

View file

@ -186,8 +186,7 @@ namespace System.Reflection.Runtime.TypeInfos
private QueryResult<M> Query<M>(string name, BindingFlags bindingAttr) where M : MemberInfo
{
if (name == null)
throw new ArgumentNullException(nameof(name));
ArgumentNullException.ThrowIfNull(name);
return Query<M>(name, bindingAttr, null);
}

View file

@ -16,16 +16,14 @@ namespace System.Reflection.Runtime.TypeInfos
[DynamicallyAccessedMembers(GetAllMembers)]
public sealed override MemberInfo[] GetMember(string name, BindingFlags bindingAttr)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
ArgumentNullException.ThrowIfNull(name);
return GetMemberImpl(name, MemberTypes.All, bindingAttr);
}
[DynamicallyAccessedMembers(GetAllMembers)]
public sealed override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
ArgumentNullException.ThrowIfNull(name);
return GetMemberImpl(name, type, bindingAttr);
}
@ -120,8 +118,7 @@ namespace System.Reflection.Runtime.TypeInfos
public sealed override MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberInfo member)
{
if (member is null)
throw new ArgumentNullException(nameof(member));
ArgumentNullException.ThrowIfNull(member);
// Need to walk up the inheritance chain if member is not found
// Leverage the existing cache mechanism on per type to store members

View file

@ -92,8 +92,7 @@ namespace System.Reflection.Runtime.TypeInfos
bindingFlags |= BindingFlags.SetProperty;
#region Name
if (name == null)
throw new ArgumentNullException(nameof(name));
ArgumentNullException.ThrowIfNull(name);
if (name.Length == 0 || name.Equals(@"[DISPID=0]"))
{
@ -123,8 +122,7 @@ namespace System.Reflection.Runtime.TypeInfos
{
Debug.Assert(IsSetField);
if (providedArgs == null)
throw new ArgumentNullException(nameof(providedArgs));
ArgumentNullException.ThrowIfNull(providedArgs);
if ((bindingFlags & BindingFlags.GetProperty) != 0)
// "Can not specify both SetField and GetProperty."

View file

@ -199,8 +199,7 @@ namespace System.Reflection.Runtime.TypeInfos
if (IsGenericParameter)
throw new InvalidOperationException(SR.Arg_GenericParameter);
if (interfaceType is null)
throw new ArgumentNullException(nameof(interfaceType));
ArgumentNullException.ThrowIfNull(interfaceType);
if (!(interfaceType is RuntimeTypeInfo))
throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(interfaceType));
@ -440,8 +439,7 @@ namespace System.Reflection.Runtime.TypeInfos
[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 sealed override Type MakeGenericType(params Type[] typeArguments)
{
if (typeArguments == null)
throw new ArgumentNullException(nameof(typeArguments));
ArgumentNullException.ThrowIfNull(typeArguments);
if (!IsGenericTypeDefinition)
throw new InvalidOperationException(SR.Format(SR.Arg_NotGenericTypeDefinition, this));

View file

@ -272,8 +272,7 @@ namespace System.Runtime.CompilerServices
if (type is not RuntimeType)
throw new ArgumentException(SR.Arg_MustBeType, nameof(type));
if (size < 0)
throw new ArgumentOutOfRangeException(nameof(size));
ArgumentOutOfRangeException.ThrowIfNegative(size);
// We don't support unloading; the memory will never be freed.
return (IntPtr)NativeMemory.Alloc((uint)size);

View file

@ -350,8 +350,7 @@ namespace System.Runtime.InteropServices
/// </remarks>
public unsafe IntPtr GetOrCreateComInterfaceForObject(object instance, CreateComInterfaceFlags flags)
{
if (instance == null)
throw new ArgumentNullException(nameof(instance));
ArgumentNullException.ThrowIfNull(instance);
ManagedObjectWrapperHolder? ccwValue;
if (_ccwTable.TryGetValue(instance, out ccwValue))
@ -471,8 +470,7 @@ namespace System.Runtime.InteropServices
/// </remarks>
public object GetOrRegisterObjectForComInstance(IntPtr externalComObject, CreateObjectFlags flags, object wrapper, IntPtr inner)
{
if (wrapper == null)
throw new ArgumentNullException(nameof(wrapper));
ArgumentNullException.ThrowIfNull(wrapper);
object? obj;
if (!TryGetOrCreateObjectForComInstanceInternal(externalComObject, inner, flags, wrapper, out obj))
@ -612,8 +610,7 @@ namespace System.Runtime.InteropServices
/// </remarks>
public static void RegisterForTrackerSupport(ComWrappers instance)
{
if (instance == null)
throw new ArgumentNullException(nameof(instance));
ArgumentNullException.ThrowIfNull(instance);
if (null != Interlocked.CompareExchange(ref s_globalInstanceForTrackerSupport, instance, null))
{
@ -637,8 +634,7 @@ namespace System.Runtime.InteropServices
[SupportedOSPlatformAttribute("windows")]
public static void RegisterForMarshalling(ComWrappers instance)
{
if (instance == null)
throw new ArgumentNullException(nameof(instance));
ArgumentNullException.ThrowIfNull(instance);
if (null != Interlocked.CompareExchange(ref s_globalInstanceForMarshalling, instance, null))
{

View file

@ -77,15 +77,8 @@ namespace System.Runtime.InteropServices
[EditorBrowsable(EditorBrowsableState.Never)]
public static IntPtr GetComInterfaceForObject(object o, Type T)
{
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
if (T is null)
{
throw new ArgumentNullException(nameof(T));
}
ArgumentNullException.ThrowIfNull(o);
ArgumentNullException.ThrowIfNull(T);
return ComWrappers.ComInterfaceForObject(o, T.GUID);
}
@ -112,10 +105,7 @@ namespace System.Runtime.InteropServices
[SupportedOSPlatform("windows")]
public static IntPtr GetIDispatchForObject(object o)
{
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
ArgumentNullException.ThrowIfNull(o);
return ComWrappers.ComInterfaceForObject(o, new Guid(0x00020400, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) /* IID_IDispatch */);
}
@ -130,10 +120,7 @@ namespace System.Runtime.InteropServices
[EditorBrowsable(EditorBrowsableState.Never)]
public static unsafe void GetNativeVariantForObject(object? obj, IntPtr pDstNativeVariant)
{
if (pDstNativeVariant == IntPtr.Zero)
{
throw new ArgumentNullException(nameof(pDstNativeVariant));
}
ArgumentNullException.ThrowIfNull(pDstNativeVariant);
Variant* data = (Variant*)pDstNativeVariant;
if (obj == null)
@ -315,10 +302,7 @@ namespace System.Runtime.InteropServices
[EditorBrowsable(EditorBrowsableState.Never)]
public static unsafe object? GetObjectForNativeVariant(IntPtr pSrcNativeVariant)
{
if (pSrcNativeVariant == IntPtr.Zero)
{
throw new ArgumentNullException(nameof(pSrcNativeVariant));
}
ArgumentNullException.ThrowIfNull(pSrcNativeVariant);
Variant* data = (Variant*)pSrcNativeVariant;
@ -412,20 +396,13 @@ namespace System.Runtime.InteropServices
public static bool IsComObject(object o)
{
if (o is null)
{
throw new ArgumentNullException(nameof(o));
}
ArgumentNullException.ThrowIfNull(o);
return false;
}
public static bool IsTypeVisibleFromCom(Type t)
{
if (t is null)
{
throw new ArgumentNullException(nameof(t));
}
ArgumentNullException.ThrowIfNull(t);
return false;
}

View file

@ -34,8 +34,7 @@ namespace System.Runtime.InteropServices
[EditorBrowsable(EditorBrowsableState.Never)]
public static IntPtr OffsetOf(Type t, string fieldName)
{
if (t == null)
throw new ArgumentNullException(nameof(t));
ArgumentNullException.ThrowIfNull(t);
if (string.IsNullOrEmpty(fieldName))
throw new ArgumentNullException(nameof(fieldName));
@ -55,11 +54,8 @@ namespace System.Runtime.InteropServices
private static void PtrToStructureHelper(IntPtr ptr, object structure, bool allowValueClasses)
{
if (ptr == IntPtr.Zero)
throw new ArgumentNullException(nameof(ptr));
if (structure == null)
throw new ArgumentNullException(nameof(structure));
ArgumentNullException.ThrowIfNull(ptr);
ArgumentNullException.ThrowIfNull(structure);
if (!allowValueClasses && structure.GetEETypePtr().IsValueType)
{
@ -109,11 +105,8 @@ namespace System.Runtime.InteropServices
[EditorBrowsable(EditorBrowsableState.Never)]
public static unsafe void DestroyStructure(IntPtr ptr, Type structuretype)
{
if (ptr == IntPtr.Zero)
throw new ArgumentNullException(nameof(ptr));
if (structuretype == null)
throw new ArgumentNullException("structureType");
ArgumentNullException.ThrowIfNull(ptr);
ArgumentNullException.ThrowIfNull(structuretype, "structureType");
RuntimeTypeHandle structureTypeHandle = structuretype.TypeHandle;
@ -147,11 +140,8 @@ namespace System.Runtime.InteropServices
[EditorBrowsable(EditorBrowsableState.Never)]
public static unsafe void StructureToPtr(object structure, IntPtr ptr, bool fDeleteOld)
{
if (structure == null)
throw new ArgumentNullException(nameof(structure));
if (ptr == IntPtr.Zero)
throw new ArgumentNullException(nameof(ptr));
ArgumentNullException.ThrowIfNull(structure);
ArgumentNullException.ThrowIfNull(ptr);
if (fDeleteOld)
{

View file

@ -459,8 +459,7 @@ namespace System.Runtime.InteropServices
return;
// Desktop CLR crash (AV at runtime) - we can do better in .NET Native
if (managedArray == null)
throw new ArgumentNullException(nameof(managedArray));
ArgumentNullException.ThrowIfNull(managedArray);
// COMPAT: Use the managed array length as the maximum length of native buffer
// This obviously doesn't make sense but desktop CLR does that

View file

@ -12,8 +12,8 @@ namespace System
{
public sealed override string? GetEnumName(object value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));
ArgumentNullException.ThrowIfNull(value);
ulong rawValue;
if (!Enum.TryGetUnboxedValueOfEnumOrInteger(value, out rawValue))
throw new ArgumentException(SR.Arg_MustBeEnumBaseTypeOrEnum, nameof(value));
@ -48,8 +48,7 @@ namespace System
public sealed override bool IsEnumDefined(object value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));
ArgumentNullException.ThrowIfNull(value);
if (!IsActualEnum)
throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");

View file

@ -10,16 +10,14 @@ namespace System
{
public static string Intern(string str)
{
if (str == null)
throw new ArgumentNullException(nameof(str));
ArgumentNullException.ThrowIfNull(str);
return InternTable.GetOrCreateValue(str);
}
public static string IsInterned(string str)
{
if (str == null)
throw new ArgumentNullException(nameof(str));
ArgumentNullException.ThrowIfNull(str);
string canonicalString;
if (!InternTable.TryGetValue(str, out canonicalString))

View file

@ -90,8 +90,7 @@ namespace System.Threading
public Condition(Lock @lock)
{
if (@lock == null)
throw new ArgumentNullException(nameof(@lock));
ArgumentNullException.ThrowIfNull(@lock);
_lock = @lock;
}

View file

@ -149,20 +149,14 @@ namespace System.Threading
public static void Pulse(object obj)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
ArgumentNullException.ThrowIfNull(obj);
GetCondition(obj).SignalOne();
}
public static void PulseAll(object obj)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
ArgumentNullException.ThrowIfNull(obj);
GetCondition(obj).SignalAll();
}

View file

@ -401,11 +401,8 @@ namespace System.Threading
bool executeOnlyOnce,
bool flowExecutionContext)
{
if (waitObject == null)
throw new ArgumentNullException(nameof(waitObject));
if (callBack == null)
throw new ArgumentNullException(nameof(callBack));
ArgumentNullException.ThrowIfNull(waitObject);
ArgumentNullException.ThrowIfNull(callBack);
var callbackHelper = new _ThreadPoolWaitOrTimerCallback(callBack, state, flowExecutionContext);
var registeredWaitHandle = new RegisteredWaitHandle(waitObject.SafeWaitHandle, callbackHelper, millisecondsTimeOutInterval, !executeOnlyOnce);

View file

@ -32,8 +32,7 @@ namespace System.Threading
public static unsafe ThreadPoolBoundHandle BindHandle(SafeHandle handle)
{
if (handle == null)
throw new ArgumentNullException(nameof(handle));
ArgumentNullException.ThrowIfNull(handle);
if (handle.IsClosed || handle.IsInvalid)
throw new ArgumentException(SR.Argument_InvalidHandle, nameof(handle));
@ -64,8 +63,7 @@ namespace System.Threading
private unsafe NativeOverlapped* AllocateNativeOverlapped(IOCompletionCallback callback, object state, object pinData, bool flowExecutionContext)
{
if (callback == null)
throw new ArgumentNullException(nameof(callback));
ArgumentNullException.ThrowIfNull(callback);
AddRef();
try
@ -87,8 +85,7 @@ namespace System.Threading
[CLSCompliant(false)]
public unsafe NativeOverlapped* AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated)
{
if (preAllocated == null)
throw new ArgumentNullException(nameof(preAllocated));
ArgumentNullException.ThrowIfNull(preAllocated);
bool addedRefToThis = false;
bool addedRefToPreAllocated = false;
@ -120,8 +117,7 @@ namespace System.Threading
[CLSCompliant(false)]
public unsafe void FreeNativeOverlapped(NativeOverlapped* overlapped)
{
if (overlapped == null)
throw new ArgumentNullException(nameof(overlapped));
ArgumentNullException.ThrowIfNull(overlapped);
Win32ThreadPoolNativeOverlapped* threadPoolOverlapped = Win32ThreadPoolNativeOverlapped.FromNativeOverlapped(overlapped);
Win32ThreadPoolNativeOverlapped.OverlappedData data = GetOverlappedData(threadPoolOverlapped, this);
@ -144,8 +140,7 @@ namespace System.Threading
[CLSCompliant(false)]
public static unsafe object GetNativeOverlappedState(NativeOverlapped* overlapped)
{
if (overlapped == null)
throw new ArgumentNullException(nameof(overlapped));
ArgumentNullException.ThrowIfNull(overlapped);
Win32ThreadPoolNativeOverlapped* threadPoolOverlapped = Win32ThreadPoolNativeOverlapped.FromNativeOverlapped(overlapped);
Win32ThreadPoolNativeOverlapped.OverlappedData data = GetOverlappedData(threadPoolOverlapped, null);

View file

@ -22,8 +22,7 @@ namespace System.Threading
private unsafe PreAllocatedOverlapped(IOCompletionCallback callback, object? state, object? pinData, bool flowExecutionContext)
{
if (callback == null)
throw new ArgumentNullException(nameof(callback));
ArgumentNullException.ThrowIfNull(callback);
_overlapped = Win32ThreadPoolNativeOverlapped.Allocate(callback, state, pinData, this, flowExecutionContext);
}

View file

@ -47,9 +47,7 @@ namespace Internal.Reflection.Execution
public sealed override Stream GetManifestResourceStream(Assembly assembly, string name)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
ArgumentNullException.ThrowIfNull(name);
// This was most likely an embedded resource which the toolchain should have embedded
// into an assembly.

View file

@ -511,8 +511,7 @@ namespace Internal.Runtime.TypeLoader
/// <param name="offset">The offset at which we need to write the bitfield.</param>
public void WriteToBitfield(LowLevelList<bool> bitfield, int offset)
{
if (bitfield == null)
throw new ArgumentNullException(nameof(bitfield));
ArgumentNullException.ThrowIfNull(bitfield);
if (IsNone)
return;

View file

@ -367,8 +367,12 @@ namespace Internal.TypeSystem
private TValue AddOrGetExistingInner(TValue value, out bool addedValue)
{
#if NET5_0_OR_GREATER
ArgumentNullException.ThrowIfNull(value);
#else
if (value == null)
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(value));
#endif
if (_entryInProcessOfWritingSentinel == null)
{
@ -592,8 +596,12 @@ namespace Internal.TypeSystem
/// <returns>Value from the hashtable if found, otherwise null.</returns>
public TValue GetValueIfExists(TValue value)
{
#if NET5_0_OR_GREATER
ArgumentNullException.ThrowIfNull(value);
#else
if (value == null)
throw new ArgumentNullException(nameof(value));
#endif
TValue[] hashTableLocal = GetCurrentHashtable();
Debug.Assert(hashTableLocal.Length > 0);

View file

@ -8,11 +8,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Delegate | AttributeTargets.Struct | AttributeTargets.Enum, AllowMultiple = true, Inherited = false)]
public sealed class CreatedMemberAttribute : BaseExpectedLinkedBehaviorAttribute
{
public CreatedMemberAttribute (string name)
{
if (string.IsNullOrEmpty (name))
throw new ArgumentException ("Value cannot be null or empty.", nameof (name));
ArgumentException.ThrowIfNullOrEmpty (name);
}
}
}

View file

@ -10,11 +10,8 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public DependencyRecordedAttribute (string source, string target, string marked = null)
{
if (string.IsNullOrEmpty (source))
throw new ArgumentException ("Value cannot be null or empty.", nameof (source));
if (string.IsNullOrEmpty (target))
throw new ArgumentException ("Value cannot be null or empty.", nameof (target));
ArgumentException.ThrowIfNullOrEmpty (source);
ArgumentException.ThrowIfNullOrEmpty (target);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public ExpectedInstructionSequenceAttribute (string[] opCodes)
{
if (opCodes == null)
throw new ArgumentNullException (nameof (opCodes));
ArgumentNullException.ThrowIfNull (opCodes);
}
}
}

View file

@ -10,26 +10,18 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFileName, Type type, string memberName, string[] opCodes)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (type == null)
throw new ArgumentNullException (nameof (type));
if (string.IsNullOrEmpty (memberName))
throw new ArgumentNullException (nameof (memberName));
if (opCodes == null)
throw new ArgumentNullException (nameof (opCodes));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentNullException.ThrowIfNull (type);
ArgumentException.ThrowIfNullOrEmpty (memberName);
ArgumentNullException.ThrowIfNull (opCodes);
}
public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFileName, string typeName, string memberName, string[] opCodes)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (string.IsNullOrEmpty (typeName))
throw new ArgumentNullException (nameof (typeName));
if (string.IsNullOrEmpty (memberName))
throw new ArgumentNullException (nameof (memberName));
if (opCodes == null)
throw new ArgumentNullException (nameof (opCodes));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (typeName);
ArgumentException.ThrowIfNullOrEmpty (memberName);
ArgumentNullException.ThrowIfNull (opCodes);
}
}
}

View file

@ -10,14 +10,12 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public ExpectedLocalsSequenceAttribute (string[] types)
{
if (types == null)
throw new ArgumentNullException (nameof (types));
ArgumentNullException.ThrowIfNull (types);
}
public ExpectedLocalsSequenceAttribute (Type[] types)
{
if (types == null)
throw new ArgumentNullException (nameof (types));
ArgumentNullException.ThrowIfNull (types);
}
}
}

View file

@ -11,8 +11,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
public IgnoreTestCaseAttribute (string reason)
{
if (reason == null)
throw new ArgumentNullException (nameof (reason));
ArgumentNullException.ThrowIfNull (reason);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptAllTypesAndMembersInAssemblyAttribute (string assemblyFileName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
}
}
}

View file

@ -11,11 +11,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Delegate, AllowMultiple = true, Inherited = false)]
public class KeptAssemblyAttribute : KeptAttribute
{
public KeptAssemblyAttribute (string fileName)
{
if (string.IsNullOrEmpty (fileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (fileName));
ArgumentException.ThrowIfNullOrEmpty (fileName);
}
}
}

View file

@ -8,17 +8,14 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
[AttributeUsage (AttributeTargets.All, AllowMultiple = true, Inherited = false)]
public class KeptAttributeAttribute : KeptAttribute
{
public KeptAttributeAttribute (string attributeName)
{
if (string.IsNullOrEmpty (attributeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (attributeName));
ArgumentException.ThrowIfNullOrEmpty (attributeName);
}
public KeptAttributeAttribute (Type type)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
ArgumentNullException.ThrowIfNull (type);
}
}
}

View file

@ -10,14 +10,12 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptAttributeOnFixedBufferTypeAttribute (string attributeName)
{
if (string.IsNullOrEmpty (attributeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (attributeName));
ArgumentException.ThrowIfNullOrEmpty (attributeName);
}
public KeptAttributeOnFixedBufferTypeAttribute (Type type)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
ArgumentNullException.ThrowIfNull (type);
}
}
}

View file

@ -10,28 +10,20 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptBaseOnTypeInAssemblyAttribute (string assemblyFileName, Type type, string baseAssemblyFileName, Type baseType)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
ArgumentNullException.ThrowIfNull (type);
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
if (string.IsNullOrEmpty (baseAssemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (baseAssemblyFileName));
if (baseType == null)
throw new ArgumentException ("Value cannot be null or empty.", nameof (baseType));
ArgumentException.ThrowIfNullOrEmpty (baseAssemblyFileName);
ArgumentNullException.ThrowIfNull (baseType);
}
public KeptBaseOnTypeInAssemblyAttribute (string assemblyFileName, string typeName, string baseAssemblyFileName, string baseTypeName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
if (string.IsNullOrEmpty (typeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (typeName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (typeName);
if (string.IsNullOrEmpty (baseAssemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (baseAssemblyFileName));
if (string.IsNullOrEmpty (baseTypeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (baseTypeName));
ArgumentException.ThrowIfNullOrEmpty (baseAssemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (baseTypeName);
}
}
}

View file

@ -10,16 +10,13 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptBaseTypeAttribute (Type baseType)
{
if (baseType == null)
throw new ArgumentNullException (nameof (baseType));
ArgumentNullException.ThrowIfNull (baseType);
}
public KeptBaseTypeAttribute (Type baseType, params object[] typeArguments)
{
if (baseType == null)
throw new ArgumentNullException (nameof (baseType));
if (typeArguments == null)
throw new ArgumentNullException (nameof (typeArguments));
ArgumentNullException.ThrowIfNull (baseType);
ArgumentNullException.ThrowIfNull (typeArguments);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptDelegateCacheFieldAttribute (string uniquePartOfName)
{
if (string.IsNullOrEmpty (uniquePartOfName))
throw new ArgumentNullException (nameof (uniquePartOfName));
ArgumentException.ThrowIfNullOrEmpty (uniquePartOfName);
}
}
}

View file

@ -13,8 +13,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptExportedTypeAttribute (Type type)
{
if (type is null)
throw new ArgumentNullException (nameof (type));
ArgumentNullException.ThrowIfNull (type);
}
}
}

View file

@ -11,16 +11,13 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
public KeptInterfaceAttribute (Type interfaceType)
{
if (interfaceType == null)
throw new ArgumentNullException (nameof (interfaceType));
ArgumentNullException.ThrowIfNull (interfaceType);
}
public KeptInterfaceAttribute (Type interfaceType, params object[] typeArguments)
{
if (interfaceType == null)
throw new ArgumentNullException (nameof (interfaceType));
if (typeArguments == null)
throw new ArgumentNullException (nameof (typeArguments));
ArgumentNullException.ThrowIfNull (interfaceType);
ArgumentNullException.ThrowIfNull (typeArguments);
}
}
}

View file

@ -10,28 +10,20 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, Type type, string interfaceAssemblyFileName, Type interfaceType)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
ArgumentNullException.ThrowIfNull (type);
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
if (string.IsNullOrEmpty (interfaceAssemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceAssemblyFileName));
if (interfaceType == null)
throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceType));
ArgumentException.ThrowIfNullOrEmpty (interfaceAssemblyFileName);
ArgumentNullException.ThrowIfNull (interfaceType);
}
public KeptInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, string typeName, string interfaceAssemblyFileName, string interfaceTypeName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
if (string.IsNullOrEmpty (typeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (typeName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (typeName);
if (string.IsNullOrEmpty (interfaceAssemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceAssemblyFileName));
if (string.IsNullOrEmpty (interfaceTypeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceTypeName));
ArgumentException.ThrowIfNullOrEmpty (interfaceAssemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (interfaceTypeName);
}
}
}

View file

@ -8,11 +8,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Delegate | AttributeTargets.Struct | AttributeTargets.Enum, AllowMultiple = true, Inherited = false)]
public sealed class KeptMemberAttribute : KeptAttribute
{
public KeptMemberAttribute (string name)
{
if (string.IsNullOrEmpty (name))
throw new ArgumentException ("Value cannot be null or empty.", nameof (name));
ArgumentException.ThrowIfNullOrEmpty (name);
}
}
}

View file

@ -11,22 +11,16 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptMemberInAssemblyAttribute (string assemblyFileName, Type type, params string[] memberNames)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (type == null)
throw new ArgumentNullException (nameof (type));
if (memberNames == null)
throw new ArgumentNullException (nameof (memberNames));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentNullException.ThrowIfNull (type);
ArgumentNullException.ThrowIfNull (memberNames);
}
public KeptMemberInAssemblyAttribute (string assemblyFileName, string typeName, params string[] memberNames)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (typeName == null)
throw new ArgumentNullException (nameof (typeName));
if (memberNames == null)
throw new ArgumentNullException (nameof (memberNames));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentNullException.ThrowIfNull (typeName);
ArgumentNullException.ThrowIfNull (memberNames);
}
public string ExpectationAssemblyName { get; set; }

View file

@ -13,8 +13,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptModuleReferenceAttribute (string name)
{
if (string.IsNullOrEmpty (name))
throw new ArgumentException ("Value cannot be null or empty.", nameof (name));
ArgumentException.ThrowIfNullOrEmpty (name);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptPrivateImplementationDetailsAttribute (string methodName)
{
if (string.IsNullOrEmpty (methodName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (methodName));
ArgumentException.ThrowIfNullOrEmpty (methodName);
}
}
}

View file

@ -13,8 +13,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptReferenceAttribute (string name)
{
if (string.IsNullOrEmpty (name))
throw new ArgumentException ("Value cannot be null or empty.", nameof (name));
ArgumentException.ThrowIfNullOrEmpty (name);
}
}
}

View file

@ -10,11 +10,8 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptReferencesInAssemblyAttribute (string assemblyFileName, string[] expectedReferenceAssemblyNames)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (expectedReferenceAssemblyNames == null)
throw new ArgumentNullException (nameof (expectedReferenceAssemblyNames));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentNullException.ThrowIfNull (expectedReferenceAssemblyNames);
}
}
}

View file

@ -13,8 +13,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptResourceAttribute (string name)
{
if (string.IsNullOrEmpty (name))
throw new ArgumentException ("Value cannot be null or empty.", nameof (name));
ArgumentException.ThrowIfNullOrEmpty (name);
}
}
}

View file

@ -13,11 +13,8 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptResourceInAssemblyAttribute (string assemblyFileName, string resourceName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (string.IsNullOrEmpty (resourceName))
throw new ArgumentNullException (nameof (resourceName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (resourceName);
}
}
}

View file

@ -10,14 +10,12 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptSecurityAttribute (string attributeName)
{
if (string.IsNullOrEmpty (attributeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (attributeName));
ArgumentException.ThrowIfNullOrEmpty (attributeName);
}
public KeptSecurityAttribute (Type type)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
ArgumentNullException.ThrowIfNull (type);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptSymbolsAttribute (string assemblyFileName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
}
}
}

View file

@ -10,18 +10,14 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public KeptTypeInAssemblyAttribute (string assemblyFileName, Type type)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
ArgumentNullException.ThrowIfNull (type);
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
}
public KeptTypeInAssemblyAttribute (string assemblyFileName, string typeName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
if (string.IsNullOrEmpty (typeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (typeName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (typeName);
}
}
}

View file

@ -13,8 +13,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public LogContainsAttribute (string message, bool regexMatch = false)
{
if (string.IsNullOrEmpty (message))
throw new ArgumentException ("Value cannot be null or empty.", nameof (message));
ArgumentException.ThrowIfNullOrEmpty (message);
}
/// <summary>

View file

@ -13,8 +13,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public LogDoesNotContainAttribute (string message, bool regexMatch = false)
{
if (string.IsNullOrEmpty (message))
throw new ArgumentException ("Value cannot be null or empty.", nameof (message));
ArgumentException.ThrowIfNullOrEmpty (message);
}
/// <summary>

View file

@ -11,11 +11,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Delegate, AllowMultiple = true, Inherited = false)]
public class RemovedAssemblyAttribute : BaseExpectedLinkedBehaviorAttribute
{
public RemovedAssemblyAttribute (string fileName)
{
if (string.IsNullOrEmpty (fileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (fileName));
ArgumentException.ThrowIfNullOrEmpty (fileName);
}
}
}

View file

@ -9,10 +9,8 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public RemovedAssemblyReferenceAttribute (string assemblyFileName, string assemblyReferenceName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
if (string.IsNullOrEmpty (assemblyReferenceName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyReferenceName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (assemblyReferenceName);
}
}
}

View file

@ -9,10 +9,8 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public RemovedForwarderAttribute (string assemblyFileName, string typeName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
if (string.IsNullOrEmpty (typeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (typeName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (typeName);
}
}
}

View file

@ -10,28 +10,20 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public RemovedInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, Type type, string interfaceAssemblyFileName, Type interfaceType)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
ArgumentNullException.ThrowIfNull (type);
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
if (string.IsNullOrEmpty (interfaceAssemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceAssemblyFileName));
if (interfaceType == null)
throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceType));
ArgumentException.ThrowIfNullOrEmpty (interfaceAssemblyFileName);
ArgumentNullException.ThrowIfNull (interfaceType);
}
public RemovedInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, string typeName, string interfaceAssemblyFileName, string interfaceTypeName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
if (string.IsNullOrEmpty (typeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (typeName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (typeName);
if (string.IsNullOrEmpty (interfaceAssemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceAssemblyFileName));
if (string.IsNullOrEmpty (interfaceTypeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceTypeName));
ArgumentException.ThrowIfNullOrEmpty (interfaceAssemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (interfaceTypeName);
}
}
}

View file

@ -11,22 +11,16 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
public RemovedMemberInAssemblyAttribute (string assemblyFileName, Type type, params string[] memberNames)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (type == null)
throw new ArgumentNullException (nameof (type));
if (memberNames == null)
throw new ArgumentNullException (nameof (memberNames));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentNullException.ThrowIfNull (type);
ArgumentNullException.ThrowIfNull (memberNames);
}
public RemovedMemberInAssemblyAttribute (string assemblyFileName, string typeName, params string[] memberNames)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (typeName == null)
throw new ArgumentNullException (nameof (typeName));
if (memberNames == null)
throw new ArgumentNullException (nameof (memberNames));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentNullException.ThrowIfNull (typeName);
ArgumentNullException.ThrowIfNull (memberNames);
}
}
}

View file

@ -13,11 +13,8 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public RemovedResourceInAssemblyAttribute (string assemblyFileName, string resourceName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentNullException (nameof (assemblyFileName));
if (string.IsNullOrEmpty (resourceName))
throw new ArgumentNullException (nameof (resourceName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (resourceName);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public RemovedSymbolsAttribute (string assemblyFileName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
}
}
}

View file

@ -10,18 +10,14 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public RemovedTypeInAssemblyAttribute (string assemblyFileName, Type type)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
ArgumentNullException.ThrowIfNull (type);
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
}
public RemovedTypeInAssemblyAttribute (string assemblyFileName, string typeName)
{
if (string.IsNullOrEmpty (assemblyFileName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
if (string.IsNullOrEmpty (typeName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (typeName));
ArgumentException.ThrowIfNullOrEmpty (assemblyFileName);
ArgumentException.ThrowIfNullOrEmpty (typeName);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
public TestCaseRequirementsAttribute (TestRunCharacteristics targetFrameworkCharacteristics, string reason)
{
if (reason == null)
throw new ArgumentNullException (nameof (reason));
ArgumentNullException.ThrowIfNull (reason);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public DefineAttribute (string name)
{
if (string.IsNullOrEmpty (name))
throw new ArgumentException ("Value cannot be null or empty.", nameof (name));
ArgumentException.ThrowIfNullOrEmpty (name);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public KeepTypeForwarderOnlyAssembliesAttribute (string value)
{
if (string.IsNullOrEmpty (value))
throw new ArgumentException ("Value cannot be null or empty.", nameof (value));
ArgumentException.ThrowIfNullOrEmpty (value);
}
}
}

View file

@ -8,11 +8,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
[AttributeUsage (AttributeTargets.Class, AllowMultiple = true)]
public class ReferenceAttribute : BaseMetadataAttribute
{
public ReferenceAttribute (string value)
{
if (string.IsNullOrEmpty (value))
throw new ArgumentException ("Value cannot be null or empty.", nameof (value));
ArgumentException.ThrowIfNullOrEmpty (value);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public ReferenceDependencyAttribute (string value)
{
if (string.IsNullOrEmpty (value))
throw new ArgumentException ("Value cannot be null or empty.", nameof (value));
ArgumentException.ThrowIfNullOrEmpty (value);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupCSharpCompilerToUseAttribute (string name)
{
if (string.IsNullOrEmpty (name))
throw new ArgumentNullException (nameof (name));
ArgumentException.ThrowIfNullOrEmpty (name);
}
}
}

View file

@ -13,11 +13,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupCompileAfterAttribute (string outputName, string[] sourceFiles, string[] references = null, string[] defines = null, object[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true, bool removeFromLinkerInput = false)
{
if (sourceFiles == null)
throw new ArgumentNullException (nameof (sourceFiles));
ArgumentNullException.ThrowIfNull (sourceFiles);
if (string.IsNullOrEmpty (outputName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (outputName));
ArgumentException.ThrowIfNullOrEmpty (outputName);
if (resources != null) {
foreach (var res in resources) {

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupCompileArgumentAttribute (string value)
{
if (string.IsNullOrEmpty (value))
throw new ArgumentNullException (nameof (value));
ArgumentException.ThrowIfNullOrEmpty (value);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupCompileAssemblyNameAttribute (string outputName)
{
if (string.IsNullOrEmpty (outputName))
throw new ArgumentNullException (nameof (outputName));
ArgumentException.ThrowIfNullOrEmpty (outputName);
}
}
}

View file

@ -13,11 +13,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupCompileBeforeAttribute (string outputName, string[] sourceFiles, string[] references = null, string[] defines = null, object[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true, bool removeFromLinkerInput = false, string outputSubFolder = null)
{
if (sourceFiles == null)
throw new ArgumentNullException (nameof (sourceFiles));
ArgumentNullException.ThrowIfNull (sourceFiles);
if (string.IsNullOrEmpty (outputName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (outputName));
ArgumentException.ThrowIfNullOrEmpty (outputName);
if (resources != null) {
foreach (var res in resources) {
@ -35,11 +33,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
public SetupCompileBeforeAttribute (string outputName, Type[] typesToIncludeSourceFor, string[] references = null, string[] defines = null, object[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true, bool removeFromLinkerInput = false)
{
if (typesToIncludeSourceFor == null)
throw new ArgumentNullException (nameof (typesToIncludeSourceFor));
ArgumentNullException.ThrowIfNull (typesToIncludeSourceFor);
if (string.IsNullOrEmpty (outputName))
throw new ArgumentException ("Value cannot be null or empty.", nameof (outputName));
ArgumentException.ThrowIfNullOrEmpty (outputName);
if (resources != null) {
foreach (var res in resources) {

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupCompileResourceAttribute (string relativePathToFile, string destinationFileName = null)
{
if (string.IsNullOrEmpty (relativePathToFile))
throw new ArgumentException ("Value cannot be null or empty.", nameof (relativePathToFile));
ArgumentException.ThrowIfNullOrEmpty (relativePathToFile);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupLinkerActionAttribute (string action, string assembly)
{
if (string.IsNullOrEmpty (action))
throw new ArgumentNullException (nameof (action));
ArgumentException.ThrowIfNullOrEmpty (action);
}
}
}

View file

@ -17,8 +17,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupLinkerArgumentAttribute (string flag, params string[] values)
{
if (string.IsNullOrEmpty (flag))
throw new ArgumentNullException (nameof (flag));
ArgumentException.ThrowIfNullOrEmpty (flag);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupLinkerDefaultActionAttribute (string action)
{
if (string.IsNullOrEmpty (action))
throw new ArgumentNullException (nameof (action));
ArgumentException.ThrowIfNullOrEmpty (action);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupLinkerKeepDebugMembersAttribute (string value)
{
if (string.IsNullOrEmpty (value))
throw new ArgumentException ("Value cannot be null or empty.", nameof (value));
ArgumentException.ThrowIfNullOrEmpty (value);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupLinkerLinkSymbolsAttribute (string value)
{
if (string.IsNullOrEmpty (value))
throw new ArgumentException ("Value cannot be null or empty.", nameof (value));
ArgumentException.ThrowIfNullOrEmpty (value);
}
}
}

View file

@ -10,8 +10,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
public SetupLinkerResponseFileAttribute (string relativePathToFile, string destinationFileName = null)
{
if (string.IsNullOrEmpty (relativePathToFile))
throw new ArgumentException ("Value cannot be null or empty.", nameof (relativePathToFile));
ArgumentException.ThrowIfNullOrEmpty (relativePathToFile);
}
}
}

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