VS11 Developer Preview bug: textRanges of EditPoint.FindPattern returns incorrect values for second occurrence

This is another issue caused by the VS 11 and the new Find feature with .NET regular expressions change that has been acknowledged and closed as fixed (supposedly in the next build):

Add-Ins: textRanges of EditPoint.FindPattern returns incorrect values for second occurrence
https://connect.microsoft.com/VisualStudio/feedback/details/712348/add-ins-textranges-of-editpoint-findpattern-returns-incorrect-values-for-second-ocurrence

VS11 Developer Preview issue: EditPoint.ReplacePattern in add-in causes COMException 0x800A00B9

The VS 11 and the new Find feature with .NET regular expressions change not only affects the EditPoint.FindPattern method, it also affects the EditPoint.ReplacePattern method.

I have found an issue that I reported to Microsoft Connect as a bug but it has been closed as “Not reproducible”. Anyone can reproduce it and post a comment?:

Microsoft Connect Bug Report: EditPoint.ReplacePattern in add-in causes COMException 0x800A00B9
https://connect.microsoft.com/VisualStudio/feedback/details/712582/editpoint-replacepattern-in-add-in-causes-comexception-0x800a00b9#details

Update (Jan 14): Microsoft closed this bug report indicating that was fixed in the next build

Update (Mar 3): certainly it has been fixed in VS 11 Beta, released three days ago.

VS 11 and the new Find feature with .NET regular expressions

When Microsoft released Visual Studio .NET and the .NET Framework 1.0 back in 2002, one of the quirks of the IDE was that while the .NET Framework has one syntax for regular expressions, the Find dialog has another syntax for them. This has been so for ten years and five Visual Studio releases (2002, 2003, 2005, 2008 and 2010), but finally in VS 11 the IDE will use the .NET Framework syntax for regular expressions, and wildcards support will be removed.

This has two consequences for developers extending Visual Studio, either with macros or with add-ins using the EnvDTE.EditPoint.FindPattern(pattern, vsFindOptionsValue, …) method of the automation model:

  • In VS 11 the vsFindOptionsWildcards value is no longer supported. You need to use regular expressions now.
  • In VS 11 the vsFindOptionsRegularExpression value now refers to .NET regular expressions, not to VS.NET regular expressions. That is, likely you need to change the pattern value for the FindPattern method to work the same in VS 2010 and VS 11.