[Mono-devel-list] Patch for ToUpper/ToLower

Robert Shade rshade at dvsconsulting.com
Sat Apr 24 10:58:21 EDT 2004

Attached are patches for checking if the argument is null in managed
code.  One is for mcs and the other for mono.  My previous patch for
CaseInsensitiveHashCodeProvider still needs to be applied.

I'm not sure if I understand why you want to move the check for the
invariant culture to managed code.  We would have to re-implement
g_unichar_toupper()/g_unichar_tolower in managed code. We seem to have
already done that in Char.ToUpper()/Char.ToLower(), however the glib
implementation seems to take care of some special cases that we don't. 
Wouldn't it be safer to use the glib version?  As for the string, it
doesn't seem like we'd be saving anything by doing the invariant culture
check in managed code.  If we did the Upper/Lower conversion in managed
code, we'd still have to go to unmanaged code to use the indexer or get
it as a char[] to do the actual conversion on each character.


On Sat, 2004-04-24 at 04:47, Andreas Nahr wrote: 
> We should not make the null check in unmanaged code.
> Also the shortcut for invariant code should not be taken to c land (as it is
> currently) - I'll explain in another posting why.
> I've made a patch which is the neccessary C# part for it. Perhaps you could
> make and test the C part (renaming the function and removing the invariant
> shortcut from the Char functions)
> The same thing is true for String (it's even more important there because
> e.g. for String.ToLower() we can guarantee that it never calles with a null)
> Already applied the String one as it is trivial
> A.Nahr
> ----- Original Message ----- 
> From: "Robert Shade" <rshade at dvsconsulting.com>
> To: <mono-devel-list at lists.ximian.com>
> Sent: Saturday, April 24, 2004 12:07 AM
> Subject: [Mono-devel-list] Patch for ToUpper/ToLower
> > According to the documentation, String.ToUpper/ToLower and
> > Char.ToUpper/ToLower should throw an ArgumentNullException if the
> > CultureInfo argument is null.  Attached is a patch to do just that.  My
> > only question is if it would have been better to use
> > MONO_CHECK_ARG_NULL from object.h.  I wasn't sure if that would abort
> > the current function or not.  If if MONO_CHECK_ARG_NULL would be
> > preferred, I can resubmit.  Either way I would need someone to commit
> > this for me as I don't have CVS access.
> >
> > Thanks.
> >
> > Rob
> >
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mcscharicalls.diff
Type: text/x-patch
Size: 2048 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040424/e0f7c6ca/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: monocharicalls.diff
Type: text/x-patch
Size: 1493 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040424/e0f7c6ca/attachment-0001.bin 

More information about the Mono-devel-list mailing list