[Mono-dev] [Patch] AssemblyName ctor

Ben Maurer bmaurer at ximian.com
Fri Aug 19 11:13:45 EDT 2005


> Hey,
>
> The patch attached implements the new AssemblyName ctor without using
> internal calls. Could anybody review it?

+                int GetCharNumericValue (char c)
+                {
+                        if (c >= (char)0x30 && c <= (char)0x3B)
+                                return c - 0x30; // 0-9
+                        if (c >= (char)0x61 && c <= (char)0x66)
+                                return c - 0x57; // a-f

1) Why not use '0' rather than (char)0x30
2) What about uppercase hex?

+                                } catch {
+                                        throw new FileLoadException ("The
assembly name is invalid.");
+                                }

It might be helpful to say catch (Exception e) { throw FileLoadException
(..., e) }, so that the developer gets a possibly helpful message.

+                        for (int i = 0; i < parts.Length; i++) {

foreach (string s in parts);

+  if (String.Compare (parts [i], 0, "Version=", 0, 8, true,
CultureInfo.InvariantCulture) == 0)
+                                                version = new Version
(parts [i].Substring (8, parts [i].Length - 8));

If Version= (or any other thing) occurs twice, what happens?

NUnit tests?

-- Ben





More information about the Mono-devel-list mailing list