From 036bad1d7c0fb272c0efee251f7bfd65c06ff9af Mon Sep 17 00:00:00 2001 From: David Eriksson Date: Tue, 28 Oct 2025 09:59:34 +0100 Subject: [PATCH] nullable ParamConverters --- .../ParamConverter/IParamConverter.cs | 3 +-- .../DateTimeEpochParamConverter.cs | 3 +-- .../DateTimeIso8601ParamConverter.cs | 3 +-- .../Implementation/ToStringParamConverter.cs | 20 +++++++++---------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Activout.RestClient/ParamConverter/IParamConverter.cs b/Activout.RestClient/ParamConverter/IParamConverter.cs index 2a4ab11..712fbf8 100644 --- a/Activout.RestClient/ParamConverter/IParamConverter.cs +++ b/Activout.RestClient/ParamConverter/IParamConverter.cs @@ -1,4 +1,3 @@ -#nullable disable using System; using System.Reflection; @@ -7,6 +6,6 @@ namespace Activout.RestClient.ParamConverter public interface IParamConverter { bool CanConvert(Type type, ParameterInfo parameterInfo); - string ToString(object value); + string ToString(object? value); } } \ No newline at end of file diff --git a/Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs b/Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs index e6ee928..6bf1fa3 100644 --- a/Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs +++ b/Activout.RestClient/ParamConverter/Implementation/DateTimeEpochParamConverter.cs @@ -1,4 +1,3 @@ -#nullable disable using System; using System.Reflection; @@ -20,7 +19,7 @@ public bool CanConvert(Type type, ParameterInfo parameterInfo) return type == typeof(DateTime); } - public string ToString(object value) + public string ToString(object? value) { return value == null ? "" : ((DateTime)value).ToUnixTime().ToString(); } diff --git a/Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs b/Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs index 891ec58..400b608 100644 --- a/Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs +++ b/Activout.RestClient/ParamConverter/Implementation/DateTimeIso8601ParamConverter.cs @@ -1,4 +1,3 @@ -#nullable disable using System; using System.Reflection; @@ -11,7 +10,7 @@ public bool CanConvert(Type type, ParameterInfo parameterInfo) return type == typeof(DateTime); } - public string ToString(object value) + public string ToString(object? value) { return value == null ? "" : ((DateTime)value).ToString("o"); } diff --git a/Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs b/Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs index f71858c..e86ccb9 100644 --- a/Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs +++ b/Activout.RestClient/ParamConverter/Implementation/ToStringParamConverter.cs @@ -1,19 +1,17 @@ -#nullable disable using System; using System.Reflection; -namespace Activout.RestClient.ParamConverter.Implementation +namespace Activout.RestClient.ParamConverter.Implementation; + +public class ToStringParamConverter : IParamConverter { - public class ToStringParamConverter : IParamConverter + public bool CanConvert(Type type, ParameterInfo parameterInfo) { - public bool CanConvert(Type type, ParameterInfo parameterInfo) - { - return true; - } + return true; + } - public string ToString(object value) - { - return value == null ? "" : value.ToString(); - } + public string ToString(object? value) + { + return value?.ToString() ?? ""; } } \ No newline at end of file