Skip to content

Instantly share code, notes, and snippets.



Last active Oct 4, 2019
What would you like to do?
exploring C# 8
public static IArgumentMatcher? Create(Expression arg) => arg switch
MethodCallExpression call when call.Method.DeclaringType == typeof(Arg) => call.Method.Name switch
nameof(Arg.Ignore) => (IArgumentMatcher)new IgnoreArgument(),
nameof(Arg.Where) => new LambdaArgument(call.Arguments.Single()),
_ => throw new InvalidOperationException()
_ => null
public static IArgumentMatcher Create(Expression arg)
if (arg is MethodCallExpression call && call.Method.DeclaringType == typeof(Arg))
switch (call.Method.Name)
case "Ignore":
return new IgnoreArgument();
case "Equals":
return new EqualsArgument(call.Arguments[0]);
throw new NotImplementedException();
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.