From 7063017fe26b0ba8a61bac5c639754af57480b8d Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Thu, 3 Oct 2024 00:07:11 +0300 Subject: [PATCH] Use ArgumentNullException.ThrowIfNull when supported (#149) --- src/StronglyTypedIds.Templates/string-full.typedid | 5 +++++ src/StronglyTypedIds/EmbeddedSources.String.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/StronglyTypedIds.Templates/string-full.typedid b/src/StronglyTypedIds.Templates/string-full.typedid index acb39ca66..84bed2f40 100644 --- a/src/StronglyTypedIds.Templates/string-full.typedid +++ b/src/StronglyTypedIds.Templates/string-full.typedid @@ -14,7 +14,12 @@ public PLACEHOLDERID(string value) { +#if NET7_0_OR_GREATER + global::System.ArgumentNullException.ThrowIfNull(value); + Value = value; +#else Value = value ?? throw new global::System.ArgumentNullException(nameof(value)); +#endif } public static readonly PLACEHOLDERID Empty = new PLACEHOLDERID(string.Empty); diff --git a/src/StronglyTypedIds/EmbeddedSources.String.cs b/src/StronglyTypedIds/EmbeddedSources.String.cs index 5852d3ab9..38040afdd 100644 --- a/src/StronglyTypedIds/EmbeddedSources.String.cs +++ b/src/StronglyTypedIds/EmbeddedSources.String.cs @@ -16,7 +16,12 @@ partial struct PLACEHOLDERID : public PLACEHOLDERID(string value) { + #if NET7_0_OR_GREATER + global::System.ArgumentNullException.ThrowIfNull(value); + Value = value; + #else Value = value ?? throw new global::System.ArgumentNullException(nameof(value)); + #endif } public static readonly PLACEHOLDERID Empty = new PLACEHOLDERID(string.Empty);