[Mono-dev] Extract method name from IEnumerator

Marek Safar marek.safar at seznam.cz
Sun Oct 5 07:30:20 EDT 2008


Hello,
>> The method's name is always MoveNext to conform to
>> System.Collections.IEnumerator, but the declaring type of the method
>> will be named after the original method.
>>
>> For example:
>>
>> class Test {
>> 	static IEnumerable<int> Foo ()
>> 	{
>> 		yield return 42;
>> 	}
>> }
>>
>> The enumerator's type will be named `<Foo>c__IteratorN`. The issue is
>> that this name can probably be changed as will by gmcs, but it looks
>> like you can get the method's original name from its generated type
>> name.
>>     
>
> Has the behaviour of this changed? With Mono 1.2.5 I am getting "Test 
> +<>c__CompilerGenerated0
>
>   
Good point. New naming convention is available since Mono 2.0.

>   
>> JB summarized it nicely, you can use name inside <.> as original  
>> method name, there is couple of issue with it though.
>> It may change in the future and it ignores generic method and  
>> method overloads. Therefore if you need better name mapping you  
>> have to use our debug symbol file.
>>     
>
> Are there functions i can call to do a lookup of the function name,  
> should i parse the whole file myself or add some function to mono to  
> do it?
>   
I think Martin has to do exactly same thing, but I am not sure whether 
he exposed it anywhere except in a debugger. It would be better to ask 
him directly.


Marek


More information about the Mono-devel-list mailing list