mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-16 14:39:28 +00:00
0a30872781
* Introduce .netcore extensions Implement ArgumentNullException for .net6 and c#10 * Update pipelines to install .netcore 6 * Update test projects to .net 6.0
23 lines
520 B
C#
23 lines
520 B
C#
using System.Runtime.CompilerServices;
|
|
|
|
namespace System.Core.Extensions;
|
|
|
|
public static class ObjectExtensions
|
|
{
|
|
public static T ThrowIfNull<T>([ValidatedNotNull] this T obj, [CallerArgumentExpression("obj")] string? paramName = null)
|
|
where T : class
|
|
{
|
|
if (obj is null)
|
|
{
|
|
throw new ArgumentNullException(paramName);
|
|
}
|
|
|
|
return obj;
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Parameter)]
|
|
sealed class ValidatedNotNullAttribute : Attribute
|
|
{
|
|
}
|
|
}
|