mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-17 14:59:29 +00:00
Introduce .netcore extensions (#11)
* Introduce .netcore extensions Implement ArgumentNullException for .net6 and c#10 * Update pipelines to install .netcore 6 * Update test projects to .net 6.0
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user