Integration with VS to display introduced elements in partial classes

I can use compile-time generated elements from my run-time code by marking a class as partial, but I still get all sorts of disconcerting red squigglies when I do so and don't get to benefit from any Intellisense regarding the types of anything I introduce. I don't know to what degree you have control over this, but it'd be amazing to be able to attach an aspect to a class, mark the class as partial and then utilize the introduced members as though they were part of the code I'm typing right there. Take this first screenshot example where the _elements field is introduced by the InsertProperty aspect typed according to the type passed into the TargetType attribute. It works and when running the program I get the line added there, but t's not clear from eyeballing the class that this would work without explicitly trying it. Getting the visual confirmation that the IDE thinks it should work right without it citing all these errors (screenshot #2) would be a huge help.
No description
No description
5 Replies
Whit
Whit•2y ago
That said, being able to use partials is HUGE for an aspect I'm writing right now. Having to introduce all the methods to utilize the introoduced fields was increasingly looking nightmarish, and this will drastically simplify that effort. I read the note at the bottom of the docs as suggesting that if I part the type partial, the IDE might not report errors, so this might not be a feature request so much as a bug report. VS 17.5.5 (until I see that 17.6 issues are definitely fixed)
Gael Fraiteur
Gael Fraiteur•2y ago
If the class is partial and the code compiles and you don't "see" the introduced declarations in the editor, this is a bug. Unfortunately this is terribly difficult to diagnose. - If you can, isolate the bug in a repro project - Otherwise, enable logging for the RoslynAnalysisService process as described in https://doc.metalama.net/conceptual/configuration/creating-logs
Whit
Whit•2y ago
I can put this in a repro - assembled a tiny project to test out the partial bit. Writing up another maybe question right now and then I'll pivot back here. With luck, it'll click what I'm doing wrong while I type this up and I'll never even need to ask 🙂 Sample project available at https://github.com/WhitWaldo/metalama-support-052823
Whit
Whit•2y ago
And bug report filed on Github: https://github.com/postsharp/Metalama/issues/138
GitHub
Bug report: Not seeing introduced declarations in editor of class m...
I opened a thread about this on Discord titled "Integration with VS to display introduced elements in partial classes", but I thought I'd file a bug report here as well since Discord ...
Gael Fraiteur
Gael Fraiteur•2y ago
Thanks. I will close this conversation and follow up on GitHub.
Want results from more Discord servers?
Add your server