June 2006 - Posts

A Simple Alternative to VS Add-ins
And probably you know it is based on the super-cool Guidance Automation Extensions (GAX) and Toolkit (GAT). Read Tom's post about what's new and improved in this release.
.NET Regex bug causes application to hang!!!

Note: this entry has moved.

Today I reported a bug on the new Microsoft Connect site (replacement for Product Feedback), which I had in the pipeling for quite a while.

Turns out that if you have a fairly complex regex (like the ones typically used for parsing small custom languages), you can easily kill your application, because the regex engine will hang completely evaluating even fairly small strings. Here's my repro regex:

    static readonly Regex ReferenceExpression = new Regex(@"

            # Matches invalid empty brackets #

            (?<empty>\$\(\)) |

            # Matches a valid argument reference with potencial method calls and indexer accesses #

            (?<reference>\$\(([^\(]+([\(\[][^\)\]]*[\)\]])?)+\)) |

            # Matches opened brackes that are not properly closed #

            (?<opened>\$\([^\)\$\(]*(?!\)))",

        RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);

and this is the string I'm parsing (part of the Mobile Client Software Factory guidance package, which uses these kind of pseudo-MSBuild syntax):

    static void Main(string[] args)

    {

        string hangString = @"DisconnectedAgents\$(CurrentItem.Name)\$(ProxyType.Name)AgentCallback.cs\$(ProxyType.Name)AgentCallbackBase.cs";

 

        Console.WriteLine(ReferenceExpression.IsMatch(hangString));

    }

If a site allows evaluations of arbitrary regex patterns using the .NET engine, they should be careful as this can easily bring the site down.

Please vote the bug if you also think it's critical.

Ajax is no silver bullet. Even Google knows it. Flash is sometimes better.

Note: this entry has moved.

I recently subscribed (with 2 lines of web.config) a couple sites with Google Analytics, which is very cool.

Now, to those who didn't believe my statement from a few days ago, that Ajax was a waste of time if you want to get advanced UIs, even Google knows it. Take a look at this cool visualization of some stats:

GoogleAnalyticsFlash.png

What you cannot see in that static screenshot, is that when you click in one of the legends in a pie chart, the corresponding pie "piece" moves away from the rest, as you can see above in Visits by Source, for google itself. The Geo Map overlay is awesome too.

Guess what's all that. Yes, Flash!!!

I hope Google continues this trend complementing the unbelievable cool Ajax stuff they are doing with things like the Google Spreadsheets:

GoogleSpreadsheets.png

VS2005 XML Editor rocks! Navigating type definitions from instance documents!

Note: this entry has moved.

Today, I was working on some GAX software factory stuff. I just couldn't remember if a particular element I had at hand in an instance document supported xs:anyAttribute or not in the corresponding schema. So I though "how handy it would be if I could press F12 (Go to Definition) and be taken to the schema for it". I tried it:

XmlEditorGoToDefinition.png

Imagine my surprise when I saw:

XmlEditorGoToDefinition2.png

Quite unexpected for me, I was presented with the XSD for the document with the relevant element definition focused under the cursor! Now, the element happens to he a ref to the definition which is somewhere else. So I thought "how handy it would be if I could press F12 and be taken to the definition of that referenced element". I tried it:

XmlEditorGoToDefinition3.png

And I was inmediately taken to:

XmlEditorGoToDefinition4.png

Simply amazing. I didn't know about this feature. What's more, you can use Ctrl+[minus sign] to navigate back, just like you do when you F12 to definitions in any code window.

Impressive job, XML team. Thank again!!!!!!

How to turn on Google Analytics for your site in 2 lines of configuration: a custom IHttpModule

Note: this entry has moved.

Ok, so I got excited with Google Analytics , thanks to Scott Hanselman. So I decided to give it a quick try.

Turns out, you cannot give it a quick try unless you start changing your site's pages to include a piece of script before the </body>... yuck!

I searched the web and found no one who had done the simplest possible thing to have transparent support for Google Analytics on your site without touching a single page: a custom IHttpModule that uses the HttpResponse.Filter property to detect </body> and add the script automatically before sending the buffered output.

If your site is not a high-traffic, performance-sensitive one (i.e. your corporate site/blog/small community site), you may find this little guy useful (note that I only had about 20' to get it working ;-)). Download the module for .NET v.2.0 or the one for .NET 1.1. Configuration is mininal:

<configuration>

    <appSettings>

        <add key="GoogleAnalyticsAccount" value="[Google Analytics Account #]"/>

    </appSettings>

    <connectionStrings/>

    <system.web>

        <compilation debug="true"/>

        <authentication mode="Windows"/>

        <httpModules>

            <add name="GoogleAnalytics" type="Clarius.GoogleAnalyticsModule"/>

        </httpModules>

    </system.web>

</configuration>

 Enjoy!

How to add GAX/GAT recipes to arbitrary VS menus

If you're using the Guidance Automation Toolkit, and you want to know how to add recipes to arbitrary menus within Visual Studio, read the following post: http://clariusconsulting.net/blogs/kzu/archive/2006/06/01/GATMenus.aspx.

It may be useful if you're looking at re-arranging VS context menus to your liking too.

More Posts

Search

Go

This Blog

News

     

      Microsoft MVP Profile

Syndication