From 68e8fefa55886a39a625f935a9d30aa355a3e1d0 Mon Sep 17 00:00:00 2001 From: stakx Date: Fri, 29 Mar 2019 14:58:32 +0100 Subject: [PATCH] Use single-line formatting for argument validation --- .../DynamicProxy/ProxyGenerationOptions.cs | 27 ++++--------------- src/Castle.Core/DynamicProxy/ProxyUtil.cs | 17 +++--------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs b/src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs index a68f8a3a90..78918d34c0 100644 --- a/src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs +++ b/src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs @@ -136,15 +136,8 @@ public MixinData MixinData /// is not a delegate type. public void AddDelegateTypeMixin(Type delegateType) { - if (delegateType == null) - { - throw new ArgumentNullException(nameof(delegateType)); - } - - if (!delegateType.IsDelegateType()) - { - throw new ArgumentException("Type must be a delegate type.", nameof(delegateType)); - } + if (delegateType == null) throw new ArgumentNullException(nameof(delegateType)); + if (!delegateType.IsDelegateType()) throw new ArgumentException("Type must be a delegate type.", nameof(delegateType)); AddMixinImpl(delegateType); } @@ -158,25 +151,15 @@ public void AddDelegateTypeMixin(Type delegateType) /// is . public void AddDelegateMixin(Delegate @delegate) { - if (@delegate == null) - { - throw new ArgumentNullException(nameof(@delegate)); - } + if (@delegate == null) throw new ArgumentNullException(nameof(@delegate)); AddMixinImpl(@delegate); } public void AddMixinInstance(object instance) { - if (instance == null) - { - throw new ArgumentNullException("instance"); - } - - if (instance is Type) - { - throw new ArgumentException("You may not mix in types using this method.", nameof(instance)); - } + if (instance == null) throw new ArgumentNullException(nameof(instance)); + if (instance is Type) throw new ArgumentException("You may not mix in types using this method.", nameof(instance)); AddMixinImpl(instance); } diff --git a/src/Castle.Core/DynamicProxy/ProxyUtil.cs b/src/Castle.Core/DynamicProxy/ProxyUtil.cs index b1d215e96b..f47c7f6829 100644 --- a/src/Castle.Core/DynamicProxy/ProxyUtil.cs +++ b/src/Castle.Core/DynamicProxy/ProxyUtil.cs @@ -65,20 +65,9 @@ public static bool TryCreateDelegateToMixin(object proxy, out TDelega /// if the method succeeds; otherwise . public static bool TryCreateDelegateToMixin(object proxy, Type delegateType, out Delegate @delegate) { - if (proxy == null) - { - throw new ArgumentNullException(nameof(proxy)); - } - - if (delegateType == null) - { - throw new ArgumentNullException(nameof(delegateType)); - } - - if (!delegateType.IsDelegateType()) - { - throw new ArgumentException("Type is not a delegate type.", nameof(delegateType)); - } + if (proxy == null) throw new ArgumentNullException(nameof(proxy)); + if (delegateType == null) throw new ArgumentNullException(nameof(delegateType)); + if (!delegateType.IsDelegateType()) throw new ArgumentException("Type is not a delegate type.", nameof(delegateType)); var invokeMethod = delegateType.GetMethod("Invoke"); var proxiedInvokeMethod =