microsoft / VSSDK-Extensibility-Samples

Samples for building your own Visual Studio extensions
http://aka.ms/extendvs
MIT License
1.22k stars 452 forks source link

WPFDesigner_XML - no xml declaration casues FormatBuffer exception #20

Open dazinator opened 8 years ago

dazinator commented 8 years ago

I have attempted to use WPFDesigner_XML sample to create my own editor.

Edit as per below comment: However for some reason I can't fathom, I have noticed that when the xml file does not have an xml declaration at the top, then the method that Format's the buffer, and specifically the call to ReformatSpan throw's an exception Value does not fall within the expected range

image

How do we work around the xml file not having an xml declaration?

dazinator commented 8 years ago

I have just found out how to reproduce this issue easily. Simply remove the xml declaration from the top of the file contents, so in the .vstemplate file remove this line:

<?xml version="1.0" encoding="utf-8"?>

You will now start getting the above exception in the FormatBuffer call..