question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: properties and constants

See original GitHub issue

Hi, 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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
SteveWilkescommented, May 28, 2019

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

0reactions
SteveWilkescommented, May 27, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Constants vs properties in java
The answer to the question depends on what you want to accomplish. But there is also a misunderstanding in it. Property files.
Read more >
Constants vs public properties for configuration
For configuration options, it is better to use properties (or methods) instead of constants. The reason for this is that configuration ...
Read more >
How to make specific object properties behave like constants
Ever wondered how to prevent your code from mutating object properties whose values should never change? I know what you're probably thinking, ...
Read more >
Properties and Constants
For an instance variable property, there are two different ways for method code in the class itself to refer to the property: %This....
Read more >
Matlab Bug (?) Using Constant Properties in Subclass ...
Hi,. I have a situation where I have an Abstract superclass that declares it's subclasses must implement a Constant property.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found