I am working on a custom language service extension for VS2012/13. Code files of the language contain both designer markup and source code, whereby the designer markup is stored at the beginning of the file. The language service provides two logical views; one for the code and a designer. Now, the problem is that I want to hide the designer code from the code editor view - and I thought implementing it using projection is the way to go, but the Visual Studio SDK does neither contain any examples nor a good explanation on how to implement such functionality (outlining is not an option in that case, because it does not really hide the code).
I tried to implement it using an elision buffer. I created two snapshot-spans (which do not overlap) and created an IElisionBuffer instance using IProjectionBufferFactoryService. Once I have the buffer instance I call the ModifySpans-method to elide the first span. Finally I call SetDataBuffer on an IEditorAdaptersFactory to connect the buffer with the view...
This has the visual effect of hiding the designer markup from the view, but when I try to edit the code in the editor view, Visual Studio throws an InvalidOperationException (Shim buffer length mismatch) and an ArgumentOutOfRangeException (Specified argument was out of the range of valid values), which can´t be handled by my editor factory. As long as I do not elide the first span, editing code works as expected... so I think some mapping is required, but I don´t know how to implement it.
I would like to get information on how to use IProjectionBuffer/IElisionBuffer, IProjectionBufferFactory, IBufferGraph and all relevant types correctly, in order to create a solid implementation...