Take the following class and method:
public class Foo
public Foo Create(string bar) {
return new Foo(bar);
}
So getting "Create" is obvious: nameof(Foo.Create)
Is there any way to get "bar" other than using reflection to read the parameters at run time?
$"{nameof(Person.Name)}:chris, foo:bar"
(i'm in a comment box, this isn't a literal copy & paste but general idea). It's harder to express this relationship between a json property-name & value pair and the relationship to a method's argument's name & type pair. I'm tired of the never ending mapping layers when all i wanted was the direct input. – NefenWithConstructorArgument
taking a reflected string literal parameter name - any change to the method signature, and boom! the bootstrapping breaks. It would have been ideal to have usednameof(Class.Method.Parameter)
instead. – Wien