Visual Studio - Edit source code located in a database
Posted
by mfeingold
on Stack Overflow
See other posts from Stack Overflow
or by mfeingold
Published on 2009-10-12T17:32:46Z
Indexed on
2010/05/10
19:04 UTC
Read the original article
Hit count: 269
I am building something similar to Server Explorer for Apache CouchDB. One of the things necessary is to be able to edit CouchDB view definitions which in CouchDB are JavaScript functions.
How can I trick Visual Studio into using my object to retrieve and save the content of the JavaScript function but still use the rest of it - I am happy with editor itself and have no intention of writing my own Editor/Language Service, etc. The latter would be much bigger effort than what this project warrants
Edit
After more digging I am still stuck. Here is what I know: IVsUIShellOpenDocument
interface provides a method OpenStandardEditor
which can be used to open the standard Visual Studio editor. As one of the parameters this method takes a Pointer to the IUnknown interface of the document data object. This object is supposed to implement several interfaces described in many places all over the MSDN.
Visual Studio SDK also provides a 'sample' implementation of the document data object VsTextBufferClass
. I can create an instance of this class and when I pass the pointer to the instance to the OpenStandardEditor
I can see my editor and it seems to work ok.
When I try to implement my own class implementing the same interfaces (IVsTextBuffer
, VsTextBuffer
, IVsTextLines
) OpenStandardEditor
method returns success, but VS bombs out on call editor.Show()
with an access violation.
My suspicion is that VsTextBufferClass also implements some other interface(s) but not in C# way but rather in the good old COM way. I just do not know which one(s).
Any thoughts?
© Stack Overflow or respective owner