Video: Writing Custom FxCop Rules

I have uploaded to this site a 68 minute video of the Writing Custom FxCop Rules (190Mb) presentation that I gave at VBUG at the annual VBUG Conference in Reading in October 2006. Sincere thanks to Christian Mitchell of VBUG for making this available to me. The slides for this presentation are also available for download here. The video itself is a combination of slides, demos and even live footage of me (there had to be a downside) explaining how to write rules. The version I have uploaded has a low bit rate to keep the size small (ish) so if VBUG make this available then you might prefer a version with a higher bit rate.

As there isn’t much information available on this subject I hope you find this video useful. Almost all of the information is still correct as I write this post (July 2007) but obviously you can replace the code name "Atlas" with "Microsoft ASP.NET AJAX". In addition be aware that this presentation was given before the release of Visual Studio 2005 Service Pack 1 and the comments about using Web Deployment Projects although still correct have been superceded by using the Web Application Projects that were resurrected from Visual Studio 2003.

You can download the FxCop rules that I talk about in this presentation on the .NET Internationalization site here. And if you still feel like you don’t have enough information about writing FxCop rules you can read Chapter 13 of .NET Internationalization entitled "Testing Internationalization Using FxCop".

Technorati Tags: FxCop, Writing Custom FxCop Rules, Internationalization, VBUG, VBUG Conference

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Tuesday, July 31, 2007 at 11:45 PM
Categories: Miscellaneous - Technical
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Displaying Currencies In Your Local Format

Here’s a globalization problem that was put to me recently: how to display a foreign currency in your local format ?

For example if I have a value 123,456.78 and my application is using the en-GB (English (United Kingdom)) culture then this value will display as "£123,456.78". This is correct if the value itself refers to UK Pounds but it is completely incorrect if it refers to US Dollars. If the value refers to US Dollars you could simply display the value using the "English (United States)" culture:-

123456.78.ToString("C", new CultureInfo("en-US"))

This displays "$123,456.78". The double.ToString method accepts an IFormatProvider parameter and extracts the NumberFormatInfo from the CultureInfo object that we pass.

This works in this example but only because the number and currency formatting rules for en-US are the same as for en-GB. If you use a culture with different formatting rules to that of your users then the resulting string will be confusing. For example the correct display of the same value using Hungarian Forints in Hungary is "123 546,78 Ft" but this will give rise to confusion for a reader who uses English (United Kingdom) or English (United States) formatting. What is needed is a way of displaying a foreign currency in a format that the local user will understand.

One solution is the simple DisplayCurrency class below. The static GetNumberFormatInfo method returns a NumberFormatInfo object that is a combination of the currency’s NumberFormatInfo object and the CurrentCulture’s NumberFormatInfo object.

public class DisplayCurrency
{
public static NumberFormatInfo GetNumberFormatInfo(CultureInfo currencyCultureInfo)
{
return GetNumberFormatInfo(currencyCultureInfo, CultureInfo.CurrentCulture);
}
public static NumberFormatInfo GetNumberFormatInfo(CultureInfo currencyCultureInfo, CultureInfo displayCultureInfo)
{
NumberFormatInfo combinedNfi = (NumberFormatInfo)displayCultureInfo.NumberFormat.Clone();
NumberFormatInfo currencyNfi = currencyCultureInfo.NumberFormat;
if (currencyNfi.NumberDecimalDigits > combinedNfi.NumberDecimalDigits)
// increase the decimals to accomodate the target’s decimals
combinedNfi.NumberDecimalDigits = currencyNfi.NumberDecimalDigits;

combinedNfi.CurrencySymbol = currencyNfi.CurrencySymbol;
return combinedNfi;
}
}

The combination is minimalistic in that the new NumberFormatInfo object merely borrows the CurrencySymbol from the currency’s NumberFormatInfo object. In addition it checks the currency’s NumberDecimalDigits and increases the new NumberDecimalDigits if it is lower. This is to ensure that a currency that normally contains decimals does not have its decimals incorrectly truncated. So for example displaying "€123,456.78" when the user’s culture is "ja-JP" (Japanese (Japan)) should not truncate to "€123,456" simply because the Japanese Yen does not have decimals.

Here are the results for a few example cultures:-

hu-HU,Hungarian (Hungary), Hungarian Forint, -123 456,78 Ft, -Ft123,456.78
it-CH,Italian (Switzerland), Swiss Franc, SFr.-123’456.78, -SFr.123,456.78
ms-BN,Malay (Brunei Darussalam), Brunei Dollar, ($123.457), -$123,456.78
fr-CA,French (Canada), Canadian Dollar, (123 456,78 $), -$123,456.78

The solution is not without its problems, however. Like many globalization solutions it makes assumptions about the consumer of the information. In this case it assumes that the user is unfamiliar with the original currency. In the case of the Estonian Kroon, the Malaysian Ringgit and the Guatemalan Quetzal this may well be true. In these examples the solution helpfully displays the currency using formatting that the user is familiar with.<

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Sunday, July 29, 2007 at 4:45 PM
Categories: Internationalization
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Review: "I Wasn’t Prepared For That" Training Aid

I recently had the chance to look at the "I Wasn’t Prepared For That" training aid from Video Arts. This is a DVD/booklet package that is designed to help people give better presentations so as I have an interest in this I thought I would take a look. The package includes a DVD, an 57 page A4 booklet and a CD containing all of the pages in the booklet as PDF or Word DOC files. The DVD is a ~30 minute sketch of characters played by Dawn French and Robert Lindsey. The sketch is about a presentation novice who is required to give two presentations and how Robert Lindsey helps her on her way to better presentations.

On the plus side Dawn French and Robert Lindsey are quite watchable. That’s it. Here endeth the plus side. It’s all minus-side from here, I’m afraid. The sketch is clearly designed for the hard of thinking and is almost wholly insulting to the intelligence. The information content is minimal and can be summed up in the following advice: prepare properly, tell’em, tell’em and tell’em again, make your points with bullet points, talk to the audience (and not to the carpet) and use humour. The sketch itself ends on the worst final line of a production since King Kong and I defy anyone not to groan out loud at it.

The booklet is designed to allow a group leader to allow a group to watch the video and discuss each chapter and it highlights relevant points in the video. Given that the video content is almost devoid of any actual information it is a feat of genious that the booklet extends to 57 pages.

Perhaps the funiest part of "I Wasn’t Prepared For That" is the extortionate (and I am tempted to say that I am using this word literally) price. I have seen the price range from $850 (USD) to £1299 (UK pounds). Maybe this is where the product name comes from but if I paid £8.50 for this I would feel I’d been ripped off. Do yourself a favour and find much better information than this for free on the ’net.

For the record I give it 0 stars out of 5.

Technorati tags: Presentations, Presentation Skills, Video Arts, I Wasn’t Prepared For That

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Thursday, July 26, 2007 at 7:03 PM
Categories: Miscellaneous - Other
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

WPF Training

Great news! Patrick Long of Charteris plc will be providing The .NET Developer Network with a one day Windows Presentation Foundation training course. The cost is approximately £100 and is available to members of the .NET Developer Network. The date is Wednesday 31st October 2007 and the training will be held in the north of Bristol. We have capacity for 10 attendees on this course and I would expect all of the places to go quickly. Here’s what you need to know:-

  • This offer is open to .NET Developer Network members (priority will be given to members who have attended at least one meeting)

  • You must be able to bring your own laptop

  • The laptop must be configured with .NET Framework 3.0 (WPF) and Visual Studio 2005 Extensions

  • You must be able to bring a cheque made payable to Charteris plc

  • The price does not include lunch or refreshments
The course is a 1 day version of the 3 day training course that Pat has been giving away for free recently. Pat will cover as many of the subjects on the course as time allows. You can download his course in 5 installments:-

At this time The .NET Developer Network is not accepting registrations. Instead if you are interested please answer the WPF Training Survey at http://www.dotnetdevnet.com/Surveys/tabid/59/Default.aspx (you could also fill out the other surveys at the same time if you have not already done so).

Technorati Tags: The .NET Developer Network, DotNetDevNet, Patrick Long, WPF, Training

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Wednesday, July 25, 2007 at 9:09 PM
Categories: Events
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

SQLBits Community Day

Saturday 6th October 2007 sees the first SQLBits Community Day, a day of SQL modelled on DDD. SQLBits is a free event by the SQL community for the SQL community. If you have SQL skills and want to share them with the community then, just like DDD, you can submit your sessions for consideration.

Technorati Tags: SQLBits

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Wednesday, July 25, 2007 at 8:50 PM
Categories: Events
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

MIX:UK 07 Registration Is Open

MIX:UK 07 registration opened today. MIX:UK 07 will be held at the Congress Centre in London on 11th and 12th September 2007. Contrary to expectations the early bird price is £199 and the full price is £299. All sessions will be recorded and available for download.

Technorati Tags: MIXUK07, MIXUK, MIX

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Wednesday, July 25, 2007 at 8:45 PM
Categories: Events
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

What’s In The MVP Award ?

Recently I was awarded MVP status. The MVP Program attempts to recognise people in the industry who have made a difference to the community by contributing their expertise. This is an excellent goal but in my opinion the MVP Program suffers from a lack of transparency. With this in mind I thought I would start sharing more information about what this program means. I’m starting with something very simple: the gift that is sent to MVPs when they are awarded MVP status. Note that there are many other (considerable) benefits to being an MVP but this post is simply about what’s in the box that Microsoft sends to you.

We’ll start with the box itself:-

This picture shows the box complete with the outer, shiney sleeve. Remove the sleeve and you’re just left with the box itself:-

Inside the box is a professional certificate:-

On opening the box you can see messages from Steve Ballmer and Rich Kaplan congratulating you on your award:-

The booklet on the left tells you all about the MVP Program. There is an MVP badge on the top right and a brown MVP box that opens up like this:-

The box contains an MVP pen/light pen, an MVP post-it notepad, an MVP credit card wallet, an MVP 1GB USB stick/keyring and an MVP badge.

Currently rated 3.3 by 6 people

  • Currently 3.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Friday, July 20, 2007 at 10:22 AM
Categories: MVP
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (8) | Post RSSRSS comment feed

Script Resource Viewer

This post describes the Script Resource Viewer, a tool that I have written to help developers understand and debug problems with the WebResource and ScriptResource HTTP Handlers. You can download the Script Resource Viewer on the .NET Internationalization site’s download page here.

If you have written ASP.NET AJAX applications and added ScriptReferences to the ScriptManager to refer to embedded JavaScript resources then you will have seen references to WebResource and ScriptResource in the generated page’s source at runtime. Here are the references from a simple web application:-

script src="/WebResource.axd?d=xzGDNKJs2hXyJqyidRG7rw2&t=633197888003670000" type="text/javascript"

script src="/ScriptResource.axd?d=cw0uZacoMljB_qHR-taqzzVXRZfsZdED8KtIdT8S4lxFp4FZiYkg1XMRiHm-
asNXbF50agKpU_mlwC_4UD1LjTtZIb8n0Iwtdp5j00hh_IM1&t=633200995411179848" type="text/javascript"

script src="/ScriptResource.axd?d=cw0uZacoMljB_qHR-taqzzVXRZfsZdED8KtIdT8S4lxFp4FZiYkg1XMRiHm-asNXbF50agKpU_mlwC_4UD1LjbQaIEzjJXk-
4Bu42FIEg4o1&t=633200995411179848" type="text/javascript"

script src="/ScriptResource.axd?d=Eayesv7vnHyEzSx83kYu3sZw_Ff6xhZWa9dVaMiOEVbTzulF5yuG_e_a0C
C6RS_16wJy1E10ZcWsesSXhTHQ2uyvpOmBnccO9vh7FSD3sP3P1nOe8f8kwq9qjkbsrs2H0&t=633203771948586000" type="text/javascript"

The src attribute of these script elements points to the WebResource and ScriptResource HTTP handlers and pass in two parameters: d (data) and t (time). Whereas the t parameter is simply a number of ticks and represents the time of the assembly file from which the resource was drawn the d parameter is not nearly so easy to understand because it is encrypted. Enter the Script Resource Viewer.


The first thing you will notice about the Script Resource Viewer is that it is as ugly as sin. I admit it - it’s the kind of ugly that frightens small children. I think it’s fair to say that my talents lie more on the functionality side of software development than the aesthetically pleasing user interfaces side of software development.

The second thing that you will notice is that there is a big box where you can paste in a WebResource or ScriptResource from one of your pages. I have pasted in the fourth line from examples above and clicked on the Decrypt button. (If the Script Resource Viewer fails at this point the most likely explanation is that you are attempting to decrypt a string generated by one version of the ASP.NET AJAX Framework on a machine with a different version of the ASP.NET AJAX Framework. Try rebuilding generating a fresh page on the same machine and using the WebResource or ScriptResource from that page).


The Decrypt button decrypts the d and t parameters and breaks them down into recognisable fragments. In this example you can see that the first character is Z (indicating that the result should be returned GZipped), the second parameter is the assembly name (AJAXWebEnabledApplicationI18N1), the third parameter is the fully qualifed resource name to retrieve from the assembly (AJAXWebEnabledApplicationI18N1.DisplayFunctions.js) and the fourth parameter is the culture to return the resource for (fr, i.e. French).

The "Show Resource Uri" button rebuilds a URI from the value in the "Server Uri" field and the decrypted d and t parameters. However, there is an all-important difference between the original URI passed to ScriptResource and the rebuilt URI (apart from the Server Uri prefix). The first character of the d parameter is a u and not a Z. The difference means that the ScriptResource will return unzipped script instead of GZipped script. Th

Currently rated 3.3 by 31 people

  • Currently 3.258065/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Wednesday, July 18, 2007 at 10:37 PM
Categories: AJAX
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

VBUG Elections

If you’re a member of VBUG it’s time to cast your vote. VBUG are holding elections for the new Chair and Vice-Chair of VBUG. The post will be held for the next 2 years. You can vote once for the Chair and once for the Vice-Chair and given that there are only two candidates for each that shouldn’t be too difficult:-

  • Andy Westgarth - Chairman

  • George Gallagher - Chairman

  • Phil Pursglove - Vice Chair

  • Tim Leung - Vice Chair
Send an email to Christian Mitchell at VBUG before Tuesday 31st July and you will be able to influence the next two years of VBUG.

Technorati Tags: VBUG, Andy Westgarth, George Gallagher, Phil Pursglove, Tim Leung

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Tuesday, July 17, 2007 at 7:36 AM
Categories: Miscellaneous - Other
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Microsoft Office: Live Preview - For One Day Only (Tuesday 17th July)

Last month Microsoft tried an experiment with MSN and Office Live: they turned the MSN site into Microsoft Office Word 2007 and let everyone try Live Preview for a day. They’re doing it again. Tuesday 17th July 2007. Only. Until next time.

Technorati Tags: MSN, Office, Word, Live, Live Preview

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Monday, July 16, 2007 at 10:48 PM
Categories: Miscellaneous - Other
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed