This project has moved and is read-only. For the latest updates, please go here.

CodeBlockComponent - Unexpected behavior

May 12, 2010 at 5:10 PM

We've been using the CodeBlockComponent custom component for quite a while now and just ran across some unexpected behavior. I thought that it was doing an exact match for the name of the #region, but that doesn't always seem to be the case. For instance, we had a #region "BindManager" and a #region "Bind" where the #region "Bind" was listed after the #region "BindManager". When we set the path to the example and specified the region as "Bind", it would actually grab the "BindManager" code since that was listed first. Is this a known issue of sorts? We would not have expected this.

If the following is our Version.cs file containing all our examples, and #region BindLicense is ahead of #region Bind, when we call  <code source="..\Version\ComponentHelp\Examples\ExamplesCS\Version.cs" region="Bind" lang="cs"/>, it actually grabs the "BindLicense" region.

#region BindLicense
//Some code here

#region Bind
//Some code here

We can workaround this now that we know about it, but I wasn't sure if this was the expected behavior.


May 12, 2010 at 8:29 PM

It's probably due to the way the regex is constructed when it tries to find the start of the region.  Most likely it's just finding the first thing that matches "#region Bind" regardless of the trailing characters.  It should probably add a non-word character option to the end to limit it to the match as long as it isn't followed by another word character.  Moving the region with the shorter name ahead of the longer one should work around the problem.