-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complex objects property expansion #57
Comments
Looking at this, I wonder if my generator should attempt to generate the partial methods instead (including passing on the I'm not sure if that's possible or not, but I'll have a play around and see. If not, then I'll look into support. |
Seems it's not supported, as you can set in which order source generators should be executed. That's not a must. Feel free to close issue, as in theory developer can always define custom class with array field and overried ToString. |
I checked the same after you posted the issue - it's something I'd like to investigate anyway; I can see the value. I'll have a think about it. |
BTW, I've not run your sample yet, but I'm assuming the complex object is just ToString'd, so the title of the issue is actually about property expansion? |
@kieronlanning yes, it's basically about property expansion. As I've said even now you can work with it by overriding ToString. The problem comes when you need to use object from 3rd party library. However, you can always create custom object and map it 1:1 to existing and override ToString. That's what I did actually 😃 |
My initial thoughts are: If the
|
Background
When a complex object is submitted as an array/class, it's not logged properly, as the logger message by default calls ToString() on the object.
Repdocution
You can reproduce the issue from this branch
https://github.com/purview-dev/purview-telemetry-sourcegenerator/compare/main...unsafePtr:purview-telemetry-sourcegenerator:complex-object-reproduce?expand=1
Solution
One way is to use always records instead of class for the logging since ToString is overrided for them. However, if an array/list/dictionary is submitted, it won't take any effect. Since .net8, there has been a
LogProperties
attribute, but it seems it doesn't take any effect when added.The text was updated successfully, but these errors were encountered: