Fix CA1510: Use ArgumentNullException throw helper

This commit is contained in:
Haselnussbomber 2025-10-24 04:30:29 +02:00
parent 753660ebcf
commit 53914e06d5
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
3 changed files with 4 additions and 8 deletions

View file

@ -64,8 +64,7 @@ internal class ManagedLoadContext : AssemblyLoadContext
bool shadowCopyNativeLibraries)
: base(Path.GetFileNameWithoutExtension(mainAssemblyPath), isCollectible)
{
if (resourceProbingPaths == null)
throw new ArgumentNullException(nameof(resourceProbingPaths));
ArgumentNullException.ThrowIfNull(resourceProbingPaths);
this.mainAssemblyPath = mainAssemblyPath ?? throw new ArgumentNullException(nameof(mainAssemblyPath));
this.dependencyResolver = new AssemblyDependencyResolver(mainAssemblyPath);

View file

@ -53,8 +53,7 @@ internal class PluginLoader : IDisposable
/// <returns>A loader.</returns>
public static PluginLoader CreateFromAssemblyFile(string assemblyFile, Action<LoaderConfig> configure)
{
if (configure == null)
throw new ArgumentNullException(nameof(configure));
ArgumentNullException.ThrowIfNull(configure);
var config = new LoaderConfig(assemblyFile);
configure(config);

View file

@ -115,8 +115,7 @@ internal static class ArrayExtensions
if (count < 0 || startIndex > list.Count - count)
throw new ArgumentOutOfRangeException(nameof(count), count, null);
if (match == null)
throw new ArgumentNullException(nameof(match));
ArgumentNullException.ThrowIfNull(match);
var endIndex = startIndex + count;
for (var i = startIndex; i < endIndex; i++)
@ -138,8 +137,7 @@ internal static class ArrayExtensions
/// <inheritdoc cref="List{T}.FindLastIndex(int,int,System.Predicate{T})"/>
public static int FindLastIndex<T>(this IReadOnlyList<T> list, int startIndex, int count, Predicate<T> match)
{
if (match == null)
throw new ArgumentNullException(nameof(match));
ArgumentNullException.ThrowIfNull(match);
if (list.Count == 0)
{