There is at least one visual studio extension to do this (this is one I was able to find quickly):
https://marketplace.visualstudio.com/items?itemName=OmarElabd.ObjectExporter
Later...
The extension I couldn't remember that triggered me to search was this one:
https://marketplace.visualstudio.com/items?itemName=CodeValueLtd.OzCode
Note that the above is a commercial product. Also note that I have used neither!