If you don't explicitly specify the culture, it gets picked up from the
current thread.  This can be a very bad thing - number and date formats get
completely screwed up, the default code page changes, and collation
(sorting) and uppercase/lowercase rules change.
Try setting your system locale to Arabic or Japanese and watch what happens.

For things that are culture-neutral, you should use the InvariantCulture
constant.  This ensures, for example, that string comparisons work as
expected and that C# language rules are used to parse and format numbers
(decimal point is a dot, for instance, instead of the comma many European
locales expect) and dates (not everyone uses the Gregorian calendar).

So, not specifying the culture is bad practice because it will almost
definitely break for someone.  If you don't want to specify the culture, you
will need to test comprehensively across multiple cultures.  At minimum,
English, German, Arabic, and Japanese (since these are the languages with
the greatest variations in culture).
Or you could just specify the InvariantCulture and only test once.


John C Barstow

-----Original Message-----
From: Ian MacLean [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 25 February 2003 11:17 p.m.
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [nant-dev] Patch for NullReferenceException error


hmm well the only doc on that I could find is at 
http://www.gotdotnet.com/team/libraries/FxCopRules/GlobalizationRules.aspx
which didn't really convince me that its necessary. Are there issues 
with the way it is now on on other cultures ?
If it does become necessary then I'd prefer to do it everywhere to keep 
the codebase consistent rather than having it in some places and not others.

Ian

> Hi Ian,
> 
> It's just a good programming practice to always specify the culture (FxCop
considers it to be a rule violation when you don't specify the cultureinfo)
> 
> Gert
> 
> ------------------------
>  Ian MacLean <[EMAIL PROTECTED]> wrote:
> ------------------------
>       
> 
>>Gert,
>>I've applied this with some changes. I'm not sure what was behind your 
>>use of the CultureInfo.InvariantCulture constant so I pulled it out. Can 
>>you please explain what it was supposed to be doing ?
>>
>>Ian
>>
>>>Hi,
>>> 
>>>I noticed that you get a NullReferenceException when you try to read the 
>>>value of a registry value name that does not exist using the 
>>>ReadRegistry task. Apparently a ToString() was done first, instead of 
>>>first checking if a value was retrieved.
>>> 
>>>Ian, can you please submit the included patch that will fix this issue.
>>> 
>>>Thanks,
>>> 
>>>Gert
>>
> 




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to