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) bool shadowCopyNativeLibraries)
: base(Path.GetFileNameWithoutExtension(mainAssemblyPath), isCollectible) : base(Path.GetFileNameWithoutExtension(mainAssemblyPath), isCollectible)
{ {
if (resourceProbingPaths == null) ArgumentNullException.ThrowIfNull(resourceProbingPaths);
throw new ArgumentNullException(nameof(resourceProbingPaths));
this.mainAssemblyPath = mainAssemblyPath ?? throw new ArgumentNullException(nameof(mainAssemblyPath)); this.mainAssemblyPath = mainAssemblyPath ?? throw new ArgumentNullException(nameof(mainAssemblyPath));
this.dependencyResolver = new AssemblyDependencyResolver(mainAssemblyPath); this.dependencyResolver = new AssemblyDependencyResolver(mainAssemblyPath);

View file

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

View file

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