Shortcut / Helper for deconstructing an object?
Is there currently a shortcut / helper action for deconstructing an object with all the appropriate default variable names?
For example, if I have a class ExampleClass with the following deconstructor:
public void Deconstruct(out string foo, out bool bar, out int bat) { ... }
and a variable of that type named "exampleVariable", is there any quick way to deconstruct that into
var (foo, bar, bat) = exampleVariable;
without having to look up the default deconstructed variable names?
Something like typing "var () = exampleVariable" then pressing ALT+ENTER to get a quick action to fill in the deconstructed variables (possibly with a list of possible deconstructors for classes that have more than one) would be a huge help for classes that deconstruct into a large number of variables.
If nothing like that exists already, does a mechanism exist that would allow building it? Could this be done through an extension or plugin?
Please sign in to leave a comment.
Hello,
Rider provides such actions, please take a look at the following blog post which provides some examples and let me know if you have other questions: Tuples, deconstruction, string interpolation – improved inspections and quick fixes in ReSharper and Rider 2018.3 EAP.