From 40742142d3926e9967fda73348a73d42887b75f6 Mon Sep 17 00:00:00 2001 From: Dan Stelljes Date: Mon, 11 Sep 2023 08:48:42 -0500 Subject: [PATCH] Use built-in `NullabilityInfoContext` when available --- src/Chr.Avro/Abstract/RecordSchemaBuilderCase.cs | 3 ++- src/Chr.Avro/Infrastructure/NullabilityInfo.cs | 2 ++ src/Chr.Avro/Infrastructure/NullabilityInfoContext.cs | 2 ++ src/Chr.Avro/Infrastructure/NullabilityState.cs | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Chr.Avro/Abstract/RecordSchemaBuilderCase.cs b/src/Chr.Avro/Abstract/RecordSchemaBuilderCase.cs index 968699b2d..633694240 100644 --- a/src/Chr.Avro/Abstract/RecordSchemaBuilderCase.cs +++ b/src/Chr.Avro/Abstract/RecordSchemaBuilderCase.cs @@ -9,10 +9,11 @@ namespace Chr.Avro.Abstract using System.Runtime.Serialization; using System.Text.RegularExpressions; using Chr.Avro.Infrastructure; + #if !NET6_0_OR_GREATER using NullabilityInfoContext = Chr.Avro.Infrastructure.NullabilityInfoContext; using NullabilityState = Chr.Avro.Infrastructure.NullabilityState; using NullabilityInfo = Chr.Avro.Infrastructure.NullabilityInfo; - + #endif /// /// Implements a case that matches any non-array or non-primitive diff --git a/src/Chr.Avro/Infrastructure/NullabilityInfo.cs b/src/Chr.Avro/Infrastructure/NullabilityInfo.cs index 379866cc0..2f4ea2401 100644 --- a/src/Chr.Avro/Infrastructure/NullabilityInfo.cs +++ b/src/Chr.Avro/Infrastructure/NullabilityInfo.cs @@ -1,3 +1,4 @@ +#if !NET6_0_OR_GREATER namespace Chr.Avro.Infrastructure { using System; @@ -70,3 +71,4 @@ internal NullabilityInfo( public NullabilityInfo[] GenericTypeArguments { get; } } } +#endif diff --git a/src/Chr.Avro/Infrastructure/NullabilityInfoContext.cs b/src/Chr.Avro/Infrastructure/NullabilityInfoContext.cs index 461a56f0e..e64d21879 100644 --- a/src/Chr.Avro/Infrastructure/NullabilityInfoContext.cs +++ b/src/Chr.Avro/Infrastructure/NullabilityInfoContext.cs @@ -1,3 +1,4 @@ +#if !NET6_0_OR_GREATER namespace Chr.Avro.Infrastructure { using System; @@ -572,3 +573,4 @@ public bool ParseNullableState(int index, ref NullabilityState state) } } } +#endif diff --git a/src/Chr.Avro/Infrastructure/NullabilityState.cs b/src/Chr.Avro/Infrastructure/NullabilityState.cs index 1f16f316d..1b83737a6 100644 --- a/src/Chr.Avro/Infrastructure/NullabilityState.cs +++ b/src/Chr.Avro/Infrastructure/NullabilityState.cs @@ -1,3 +1,4 @@ +#if !NET6_0_OR_GREATER namespace Chr.Avro.Infrastructure { /// @@ -26,3 +27,4 @@ internal enum NullabilityState Nullable, } } +#endif