ILCode。反编译后的荒谬陈述

时间:2017-11-16 17:11:01

标签: c# decompiling ildasm

考虑我有以下代码:

try
{
    using (var scope = CreateDependencies())
    {
        ...
    }
}

当我反编译它时:

try
{
    ILifetimeScope scope;
    int num1;
    if ((uint) (num1 - 1) > 2U)
        scope = Host.CreateDependencies();
    try
    {
        ...
    }
    ...
}
....

如果这完全没有意义的话,为什么还有附加?

ILDasm生成的ILCode:

.try
{
    IL_00b8:  ldloc.0
    IL_00b9:  ldc.i4.1
    IL_00ba:  sub
    IL_00bb:  ldc.i4.2
    IL_00bc:  ble.un.s   IL_00ca
    IL_00be:  ldarg.0
    IL_00bf:  ldloc.1
    IL_00c0:  call       instance class [Autofac]Autofac.ILifetimeScope MyApp.Host::CreateDependencies()
    IL_00c5:  stfld      class [Autofac]Autofac.ILifetimeScope MyApp.Host/'<RunAsync>d__7'::'<scope>5__2'
    IL_00ca:  nop
    .try
    {
        ...
    }
    ....
}

0 个答案:

没有答案