Scott Hanselman

Keynote thought

June 7, '05 Comments [4] Posted in
Sponsored By

Microsoft needs to hire me as a consultant to tech executives to make their font sizes bigger in VS.NET. How anyone thinks Courier New 12 is an appropriate font for a 4,000 person keynote is beyond me.

I know I've been a Lucida Console person, but I'm digging a new Longhorn font called Consolas. Its brilliant. Watch for it soon. Its better than Lucida, hinted for LCD and high-res displays and has dec specific features like ProFont. I love it, and I'll be using it in my talk at 10:45am today.
Scott Hanselman - Corillian Corp
scott@corillian.com
--------------------------
Sent from my BlackBerry Wireless Handheld

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Update on the dasBlog Turkish-I bug and a reminder to me on Globalization

June 5, '05 Comments [5] Posted in ASP.NET | DasBlog | Internationalization | Bugs
Sponsored By

I had blogged earlier about a bug in dasBlog that affected Turkish users. When a Turkish browser reported an HTTP Accept-Language header indicating Turkish as the preferred language, no blog posts would show up.  As fix, I suggested that users change their blog templates, but I knew that wasn't an appropriate fix.

For background, here's what an Accept-Language header looks like. This user would prefer Turkish, but would take English as their second choice.

GET /DasBlog/default.aspx HTTP/1.1
Accept-Language: tr,en-us;q=0.5
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Tablet PC 1.7; .NET CLR 2.0.50215)

Why would the browser affect the underlying engine you say? Here's some background before I show you how I fixed the bug. Typically globalized ASP.NET applications set the current thread's Culture and UICulture to a specific culture based on the user's preferences. 

For example:

CultureInfo Turkey = CultureInfo.CreateSpecificCulture("tr");
Thread.CurrentThread.CurrentCulture = Turkey;
           
Thread.CurrentThread.CurrentUICulture = Turkey;

Why two properties? From the MSDN Documentation:

The CurrentCulture property's default value is the system's User Locale, which is set in the Regional Options control panel. The CurrentUICulture property's default value is the system's UI Language, which is the language of your system UI. On Windows 2000 and Windows XP MultiLanguage Edition, the CurrentUICulture defaults to the current user UI language settings.

The CurrentUICulture is used by the ResourceManager to look up resources like strings at run time. The CurrentCulture is set per-thread also, but is used for formatting dates, times, currencies and string manipulation methods.

Earlier I blogged that I suspected a problem with the Reflection method we were using to invoke Macros in dasBlog. We were passed in "items" from a dasBlog tempate and were looking for a property called "Items." We used a reflection method like this:

MemberInfo[] members = subexObject.GetType().FindMembers(

    MemberTypes.Field|MemberTypes.Method|MemberTypes.Property,

    BindingFlags.IgnoreCase|BindingFlags.Instance|BindingFlags.Public,

    new MemberFilter(this.IsMemberEligibleForMacroCall), subex.Trim() );

if ( members.Length == 0 )

{

    throw new MissingMemberException(subexObject.GetType().FullName,subex.Trim());

}

Notice that we're indicating via the BindingFlags.IgnoreCase flag that we want the FindMembers() method to handle the case-insensitivity issue for us. My initial thought was that they must be doing something wrong inside. I mentioned this to Michael Kaplan, but he said there was a big push to fix "Turkish-I" bugs in the 1.1 timeframe. However, he said he'd look at the problem and see if it would need to be fixed if I had a simple repro to prove it was still a problem in 2.0. At this point, I started thinking that it's probably NOT Microsoft, but as I started writing a small repro as a separate project, I was thinking, we (dasBlog) MUST be doing something wrong, otherwise how have the Turks been doing reflection all this time? They'd have run into this before. I googled and couldn't find any Turks suffering the slings and arrows of reflection.

I went back and looked at the code again with fresh eyes. Then I noticed (brain fart here):

MemberInfo[] members = subexObject.GetType().FindMembers(

    MemberTypes.Field|MemberTypes.Method|MemberTypes.Property,

    BindingFlags.IgnoreCase|BindingFlags.Instance|BindingFlags.Public,

    new MemberFilter(this.IsMemberEligibleForMacroCall), subex.Trim() );

if ( members.Length == 0 )

{

    throw new MissingMemberException(

        subexObject.GetType().FullName,subex.Trim());

}

I had been glossing over that. We are/were passing in a delegate for filtering. That method looked like this:

private bool IsMemberEligibleForMacroCall(MemberInfo m, object filterCriteria )

{

    return String.Compare(m.Name,(string)filterCriteria,true)==0;

}

Doh! That's a culture-sensitive string compare. We were comparing the MemberInfo that we got back from the reflection call with the string we knew we needed. Even though the Reflection call to FindMembers succeeded, we were filtering out our method with a bad compare.

Here's where the lesson comes in (and this had bitten me before, so I was kicking myself).

Scott's Rule Number 0x5F: Think about your string compares and their context. Make sure you've expressed your true intent correctly.

Here is the fixed method. It'll be in the next dasBlog point release and won't require anyone to change their templates.

private bool IsMemberEligibleForMacroCall(MemberInfo m, object filterCriteria )

{

    //This has to be case-insensitive and culture-invariant or

    // "Item" and "item" won't match if the current culture is Turk

    return String.Compare(m.Name,(string)filterCriteria, true, System.Globalization.CultureInfo.InvariantCulture) == 0;

}

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Hotel Rwanda

June 4, '05 Comments [5] Posted in Movies | Africa
Sponsored By

Just finished watching Hotel Rwanda. Great film, Cheadle was clearly deserving of an Oscar. Everyone should see it. The core story was powerful and what Paul Rusesabagina did was amazing.

That said, a few things struck me as odd or of note.

The movie opens with Yvonna Chaka Chaka singing her remix of Umqombothi (a song I've got in my car). This is a South African song about a specific kind of beer. Then one of the main characters, a Tutsi, tries to sing along with this Zulu song inserting Kinyarwandan words. I do have to plead ignorance to whether or not Zulu pop music is listened to in Rwanda, but it did strike my wife and I as odd. That said, it is a song about beer and Paul continually uses beer to bribe the locals and the General, so it does fit thematically, but there's precious few Anglophones who would notice the parallel.

Additonally None of the main characters speaks a word of Kinyarwanda or French, even when they are alone, which also smacks as a little ingenuine. Also, a scene at the end includes a large billboard with the names and pictures of the missing children. Their names seem to be primarily composed of South African Zulu names, like Vusi or Ntombi. I know that there are Bantu influences on Rwandan culture, but I don't know how far it extends. The Bantu influence is thought to extend througout much of southern Africa. However, I figure that since the movie was filmed in South Africa that the prop folks just used the local names.

I'd be interested in a native or ex-pat Rwandan's point of view on these points. I need to dig more deeply into this stuff.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Rory and Scott Fruit Roll-Up

June 2, '05 Comments [0] Posted in TechEd | Speaking
Sponsored By

Rory and I have a few ideas about videos to shoot while we're at TechEd, but we'll have to see as I'll be doing a session, a BoF and a GrokTalk. Until we figure something out, TechEdBloggers is running an extensive retrospective on our poor-man's promotional videos with commentary from Leonard Maltin about the far-reaching significance we had on the genre. Actually, they've just listed them all in one place.

If you haven't yet been subjected to these, this is another opportunity to avoid them, because they're really special. Short bus special.

Now playing: Akon - Locked Up

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

The preliminary Grok Talk schedule is up...

June 1, '05 Comments [0] Posted in TechEd | Speaking
Sponsored By

The preliminary GrokTalk schedule for TechEd 2005 is up with RSS just for the schedule here. Included also is a lovely map.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.