From 37435301e29afba636480a0b9a6491d5c1f9e6ea Mon Sep 17 00:00:00 2001 From: Luciana Regina Lino Date: Mon, 17 Jun 2024 10:50:01 -0300 Subject: [PATCH] wip(Liquid.Core): Update Liquid framework for net8 - fixes sonar issues. --- src/Liquid.Core/Extensions/ObjectExtension.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Liquid.Core/Extensions/ObjectExtension.cs b/src/Liquid.Core/Extensions/ObjectExtension.cs index 2675fe2..0bd33aa 100644 --- a/src/Liquid.Core/Extensions/ObjectExtension.cs +++ b/src/Liquid.Core/Extensions/ObjectExtension.cs @@ -238,8 +238,8 @@ public static byte[] ToJsonBytes(this object source, JsonSerializerOptions optio /// Couldn't find field {fieldName} in type {objType.FullName} public static object GetFieldValue(this object obj, string fieldName) { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); + ArgumentNullException.ThrowIfNull(obj); + Type objType = obj.GetType(); var fieldInfo = TypeUtils.GetFieldInfo(objType, fieldName); if (fieldInfo == null) @@ -258,8 +258,8 @@ public static object GetFieldValue(this object obj, string fieldName) /// Couldn't find field {fieldName} in type {objType.FullName} public static void SetFieldValue(this object obj, string fieldName, object val) { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); + ArgumentNullException.ThrowIfNull(obj); + Type objType = obj.GetType(); var fieldInfo = TypeUtils.GetFieldInfo(objType, fieldName); if (fieldInfo == null) @@ -278,8 +278,8 @@ public static void SetFieldValue(this object obj, string fieldName, object val) /// Couldn't find property {propertyName} in type {objType.FullName} public static object GetPropertyValue(this object obj, string propertyName) { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); + ArgumentNullException.ThrowIfNull(obj); + Type objType = obj.GetType(); var propertyInfo = TypeUtils.GetPropertyInfo(objType, propertyName); if (propertyInfo == null) @@ -298,8 +298,8 @@ public static object GetPropertyValue(this object obj, string propertyName) /// Couldn't find property {propertyName} in type {objType.FullName} public static void SetPropertyValue(this object obj, string propertyName, object val) { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); + ArgumentNullException.ThrowIfNull(obj); + Type objType = obj.GetType(); var propertyInfo = TypeUtils.GetPropertyInfo(objType, propertyName); if (propertyInfo == null)