[Mono-list] Problems With Array Implementation

Dwivedi , Ajay Kumar AjayKumar.Dwivedi@dresdner-bank.com
Sun, 17 Feb 2002 16:03:36 -0000


hi All,
	Here are some of the problems with Array.cs implementation.

	1. Count Property is declared while it is not a part of the
Specification. (Array is abstract so does not neccesiate its
implementation);
	2. GetUpperBound Property will return wrong values. It returns
"GetLowerBound (dimension) + GetLength (dimension)" which is one more than
the UpperBound.
	3. IsFixedSize and IsReadOnly which are not a part of Spec, but are
Implemented in MS.NET and descibed in MSDN. Shoud we implement them? (Not
sure if we are following the specs strictly or including MS's "extensions")
	4. CreateInstance(Type elementType, int[] lengths, int[]
lowerBounds) requires us to throw a ArgumentNullException when lowerBounds
is Null. But we are assuming null to indicate lowerBounds of zero (all other
variants of CreateInstance call this method with null in the lowerBounds).
	5. Line 236 in Array.cs should be modified (due to correction 2) to
"if (index + length > array.GetUpperBound (0)+1)" or "if (index + length >
array.GetLowerBound (0)+array.GetLength(0))"
	6. In BinarySearch (Array, int, int, object, IComparer) : if value
is null, it should not throw an exception, but (value is IComparable)
results in false and throws ArgumentException.
	7. BinarySearch seems to be implementing Linear search instead .
	8. GetUpperBounds needs to be corrected at a number of places.
	9. In Clear Method, a single array.SetValue(null, index + i); will
do the task. Since all of them are object types and setting an int and bool
to null makes them zero  and false respectively.
	10. IndexOf and LastIndexOf use == operator which compares
references for all except strings and valuetypes. We should use .Equals()
function here.


Referenced Code: Mono Source 16th Feb

Happy Hacking,
Ajay kumar Dwivedi

--
#!!!	If anything can go wrong, _FIX_ it. (To hell with MURPHY)
							  Dwivedi, Ajay
kumar
							(adwiv At Yahoo .
Com)