From bd25a1dca7315c94d35eab21ccc2fc2131f0bdf1 Mon Sep 17 00:00:00 2001 From: Rafael Sliveira Cordeiro Date: Wed, 7 Nov 2018 19:28:24 -0800 Subject: [PATCH] Add Checks to ArgumentNullException --- Slapper.AutoMapper/Slapper.AutoMapper.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Slapper.AutoMapper/Slapper.AutoMapper.cs b/Slapper.AutoMapper/Slapper.AutoMapper.cs index 52feb4d..c19cb5f 100644 --- a/Slapper.AutoMapper/Slapper.AutoMapper.cs +++ b/Slapper.AutoMapper/Slapper.AutoMapper.cs @@ -84,6 +84,8 @@ public static T MapDynamic( object dynamicObject, bool keepCache = true) /// Exception that is thrown when the cannot be converted to an IDictionary of type string and object. public static object MapDynamic(Type type, object dynamicObject, bool keepCache = true) { + if (type == null) throw new ArgumentNullException(nameof(type)); + if (dynamicObject == null) { return type.IsValueType ? Activator.CreateInstance(type) : null; @@ -128,6 +130,8 @@ public static IEnumerable MapDynamic( IEnumerable dynamicListOfPro /// Exception that is thrown when the cannot be converted to an IDictionary of type string and object. public static IEnumerable MapDynamic(Type type, IEnumerable dynamicListOfProperties, bool keepCache = true) { + if (type == null) throw new ArgumentNullException(nameof(type)); + if (dynamicListOfProperties == null) return new List(); @@ -169,6 +173,8 @@ public static T Map( IDictionary listOfProperties, bool keepC /// The specified Type public static object Map(Type type, IDictionary listOfProperties, bool keepCache = true) { + if (type == null) throw new ArgumentNullException(nameof(type)); + var propertiesList = new List> { listOfProperties }; return Map(type, propertiesList, keepCache).FirstOrDefault(); @@ -201,6 +207,8 @@ public static IEnumerable Map( IEnumerable> li /// List of specified Type public static IEnumerable Map(Type type, IEnumerable> listOfProperties, bool keepCache = true) { + if (type == null) throw new ArgumentNullException(nameof(type)); + var instanceCache = new Dictionary(); foreach (var properties in listOfProperties)