Cider/VS2010 Designer Bug with Binding using escaped entities in StringFormat - by HungryDwarf

Status : 

  External<br /><br />
		This item may be valid but belongs to an external system out of the direct control of this product team.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 782059 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 3/25/2013 11:02:23 AM
Access Restriction Public

Description

(NOTE: This happens in VS2010, not sure if present in VS2012)


If you declare a data binding using the StringFormat argument, and that StringFormat has one of a select number of escaped XML entities, it causes a Designer error/crash.


Ex:
<!-- should show '&Value', but crashes the designer -->
<TextBlock Text="{Binding Path=Value, StringFormat=&#x26;{0}}"/>


Stack Trace shows that it's actually an unhandled exception in the error reporting method for the parser:


System.FormatException
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
   at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlParseContext.ErrorWrapper.ConvertError(Error error, Object[] args)
   at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlParseContext.ReportError(Error error, MarkupErrorMessageCategory category, Int32 offset, Int32 length, Object[] args)
   at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlParseContext.ReportError(Error error, Int32 offset, Int32 length, Object[] args)
   at MS.Internal.Design.Markup.MarkupExtensionParser.HandleError(Int32 start, Error error, Object[] args)
   at MS.Internal.Design.Markup.MarkupExtensionParser.ScanXmlEscapedChar(Int32 current, Char& ch)
   at MS.Internal.Design.Markup.MarkupExtensionParser.NextToken()
   at MS.Internal.Design.Markup.MarkupExtensionParser.Expect(Char token)
   at MS.Internal.Design.Markup.MarkupExtensionParser.ParseNamedArguments(TypeNode type, List`1 arguments)
   at MS.Internal.Design.Markup.MarkupExtensionParser.ParseExtension()
   at MS.Internal.Design.Markup.MarkupExtensionParser.Parse()
   at MS.Internal.Design.Markup.XmlElement.ConvertMarkupExtension(XamlAttribute attribute, XmlItem valueNode, PrefixScope scope, IParseContext context)


(rest of trace omitted)


Note that the following *doesn't* crash the designer, and the designer will show the "expected" visual, but at runtime, the extra escaping causes incorrect behavior:


<!-- works in designer (shows &Value), shows &amp;Value at runtime -->
<TextBlock Text="{Binding Path=Value, StringFormat=&amp;amp;{0}}"/>

Sign in to post a comment.
Posted by Microsoft on 3/25/2013 at 11:47 PM
Hi HungryDwarf, thank you for submitting feedback on Visual Studio and .NET Framework. We'll close this feedback because there is a workaround on this issue. Thanks a lot for sending the workaround.
Posted by Microsoft on 3/25/2013 at 11:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by HungryDwarf on 3/25/2013 at 11:08 AM
I obviously fail at connect-form-entry markup; any benevolent souls in the know willing to edit/format my post?