What are the challenges you face when working across database platforms? Take the survey
Options

Reflector bug report: Incorrect C# for System.Windows.Threading.Dispatcher.get_CurrentDispatcher()

using Reflector 10.3.1.1956 vspro

------------------------------------------------
The IL for "System.Windows.Threading.Dispatcher.get_CurrentDispatcher()" in "WindowsBase,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" is...
------------------------------------------------


.method public hidebysig specialname static class System.Windows.Threading.Dispatcher get_CurrentDispatcher() cil managed<br>{<br>  .maxstack 1<br>  .locals init ([0] class System.Windows.Threading.Dispatcher dispatcher)
<br>  L_0000: call class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread()
  L_0005: call class System.Windows.Threading.Dispatcher System.Windows.Threading.Dispatcher::FromThread(class [mscorlib]System.Threading.Thread)
  L_000a: stloc.0
  L_000b: ldloc.0
  L_000c: brtrue.s L_0014
  L_000e: newobj instance void System.Windows.Threading.Dispatcher::.ctor()
  L_0013: stloc.0
  L_0014: ldloc.0
  L_0015: ret
}


------------------------------------------------
The INCORRECT C# produced by Reflector 10.3.1.1956 is....
------------------------------------------------


public static Dispatcher get_CurrentDispatcher()
{
    Dispatcher dispatcher = FromThread(Thread.CurrentThread);
    return new Dispatcher();
}


------------------------------------------------
The CORRECT C# should be:
------------------------------------------------


public static Dispatcher get_CurrentDispatcher()
{
    Dispatcher dispatcher = FromThread(Thread.CurrentThread);
    if (dispatcher == null)
        dispatcher = new Dispatcher();
    return dispatcher;
}



Please fix it at your leisure.

Sign In or Register to comment.