Reflector IL to C# Bug

I was watching Entity Framework code when I found this code:

switch (this.<>1__state)
{
    case 3:
    case 4:
        break;

    default:
        return;
        try
        {
        }
        finally
        {
            this.d__0.<>m__Finally6();" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://System.Data.Entity:3.5.0.0:b77a5c561934e089/System.Data.EntityModel.SchemaObjectModel.EntityContainerAssociationSet.d__0/<>m__Finally6()"><>m__Finally6();
        }
        break;
}

Very strange. It was the same with VB.Net. So I watched IL and I undestood that Reflector has a bug.

Indeed the IL was next:

L_0023: ldfld int32 System.Data.EntityModel.SchemaObjectModel.EntityContainerAssociationSet/<get_Ends>d__0::<>1__state
L_0028: stloc.1
L_0029: ldloc.1
L_002a: ldc.i4.3
L_002b: sub
L_002c: switch (L_003a, L_003a)
L_0039: ret
L_003a: leave.s L_0043
L_003c: ldarg.0
L_003d: call instance void System.Data.EntityModel.SchemaObjectModel.EntityContainerAssociationSet/<get_Ends>d__0::<>m__Finally6()
L_0042: endfinally
L_0043: ret
.try L_003a to L_003c finally handler L_003c to L_0043

So C# code should be:

switch (this.<>1__state)
{
    case 3:
    case 4:
        try
        {
        }
        finally
        {
            this.d__0.<>m__Finally6();" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://System.Data.Entity:3.5.0.0:b77a5c561934e089/System.Data.EntityModel.SchemaObjectModel.EntityContainerAssociationSet.d__0/<>m__Finally6()"><>m__Finally6();
        }
        break;
    default:
        return;
}

Published Wednesday, June 04, 2008 12:05 PM by Matthieu MEZIL
Filed under: , , , ,

Leave a Comment

(required) 
(required) 
(optional)
(required)