[Mono-dev] Possible bug in Enumerable.cs?

anidotnet anidotnet at gmail.com
Mon Sep 6 06:14:06 EDT 2010


I have the following function to remove a particular character from a string

public static string Remove(this string strA, char target)
{
	char[] charArr = strA.ToCharArray();
        var targetArr = new List<char>();	
	targetArr.AddRange(
                        charArr.Where(
                            character =>
                           
!character.ToString(CultureInfo.InvariantCulture).Equals(
                               
target.ToString(CultureInfo.InvariantCulture), 
				StringComparison.InvariantCultureIgnoreCase)));
	return new string(targetArr.ToArray());
}

using this function in .Net framework gives rise to

"Hello World".Remove('l')  ---> Heo Word

but Mono throws the following exception

System.InvalidProgramException: Invalid IL code in (wrapper delegate-invoke)
System.Func`2<char, bool>:invoke_bool__this___char (char): IL_004d:
castclass 0x00000007



  at
System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1D`1[System.Char].MoveNext
() [0x00059] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.7\mcs\class\System.Core\System.Linq\Enumerable.cs:2305 

  at System.Collections.Generic.List`1[System.Char].AddEnumerable
(IEnumerable`1 enumerable) [0x0001a] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.7\mcs\class\corlib\System.Collections.Generic\List.cs:125 

  at System.Collections.Generic.List`1[System.Char].AddRange (IEnumerable`1
collection) [0x00020] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.7\mcs\class\corlib\System.Collections.Generic\List.cs:139 

  at AbstractClass.Extensions.StringExtensions.Remove (System.String strA,
Char target) [0x000de] in
C:\Docs\Quasar\Quasar.Core\Extensions\StringExtensions.cs:263 

  at QuasarDemo.Tests.ExtensionTest.RunStringTest () [0x00000] in <filename
unknown>:0 

  at QuasarDemo.Tests.ExtensionTest.Run () [0x00000] in <filename unknown>:0 

  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
(object,object[],System.Exception&)

  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x000d0] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.7\mcs\class\corlib\System.Reflection\MonoMethod.cs:213 



Why? Is it a bug or something else?

---------------------------

Regards,

Anindya Chatterjee
http://abstractclass.org

-- 
View this message in context: http://mono.1490590.n4.nabble.com/Possible-bug-in-Enumerable-cs-tp2528154p2528154.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list