Deduplicate record stub generation logic

Currently the logic is duplicated between test code & the smart tagger.
I'm trying to unify as best as possible the logic, and only leave boilerplate code (mostly due because of VS API), so that we can better mock the IDE environment.