Bug: properties and constants
See original GitHub issueHi, I have two issues, but I’m not sure if ReadableExpressions is supposed to generate working C# code or if the idea is to just generate “human readable” code.
In any case, it would be awesome if there was a way to customize how some things are converted.
The two bugs/issues I ran into are:
Properties
obj.X = 5; where X is a property, will become obj.set_X(5);
Well, it’s not really wrong as internally properties are just methods… but it would be cool if there was a setting to get the “expected” format.
Maybe have a setting like ConvertPropertyAccessToDirectSyntax or something like that.
Constants
var formatterExp = Constant(formatterInstance);
Call(formatterExp, deserializeMethod, arg1, arg2, arg3));
becomes:
ReferenceFormatter<MyObject>.Deserialize(arg1, arg2, arg3);
Obviously there’s nothing else that ReadableExpressions could use other than the type name in this case.
But there should be something like a callback where I can customize how a Expression.Constant gets written. Having a simple Func<ConstantExpression, string> customizeConstantToString as a setting would be awesome.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
Ok, v2.3 is now on NuGet!
Property getter- and setter-call translation is now fixed. Calls are translated to property syntax automatically, no need to set a setting
There’s now a
.TranslateConstantsUsing((constantType, constantValue) => )setting.Thanks again for the feedback!
Steve
Hi!
Firstly, thanks very much for the feedback and PR! I’m going to write some tests and make some tweaks and get back to you 😃
Cheers,
Steve