Skip to content

Commit

Permalink
Use single-line formatting for argument validation
Browse files Browse the repository at this point in the history
  • Loading branch information
stakx committed Mar 29, 2019
1 parent fcf6c63 commit 68e8fef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 36 deletions.
27 changes: 5 additions & 22 deletions src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,8 @@ public MixinData MixinData
/// <exception cref="ArgumentException"><paramref name="delegateType"/> is not a delegate type.</exception>
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);
}
Expand All @@ -158,25 +151,15 @@ public void AddDelegateTypeMixin(Type delegateType)
/// <exception cref="ArgumentNullException"><paramref name="delegate"/> is <see langword="null"/>.</exception>
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);
}
Expand Down
17 changes: 3 additions & 14 deletions src/Castle.Core/DynamicProxy/ProxyUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,9 @@ public static bool TryCreateDelegateToMixin<TDelegate>(object proxy, out TDelega
/// <returns><see langword="true"/> if the method succeeds; otherwise <see langword="false"/>.</returns>
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 =
Expand Down

0 comments on commit 68e8fef

Please sign in to comment.