2) 編譯器生成的緩存類
代碼如下:
using System;
namespace Xianfen.Net.TestDynamic
{
class Program
{
static void Main()
{
dynamic d = 5;
d.ToString();
d.ToString();
}
}
}
反編譯的代碼:
internal class Program
{
// Methods
private static void Main()
{
object d = 5;
if (<Main>o__SiteContainer0.<>p__Site1 == null)
{
<Main>o__SiteContainer0.<>p__Site1 = CallSite<Action<CallSite, object>>.Create(new CSharpInvokeMemberBinder(CSharpCallFlags.None, "ToString", typeof(Program), null, new CSharpArgumentInfo[] { new CSharpArgumentInfo(CSharpArgumentInfoFlags.None, null) }));
}
<Main>o__SiteContainer0.<>p__Site1.Target (<Main>o__SiteContainer0.<>p__Site1, d);
if (<Main>o__SiteContainer0.<>p__Site2 == null)
{
<Main>o__SiteContainer0.<>p__Site2 = CallSite<Action<CallSite, object>>.Create(new CSharpInvokeMemberBinder(CSharpCallFlags.None, "ToString", typeof(Program), null, new CSharpArgumentInfo[] { new CSharpArgumentInfo(CSharpArgumentInfoFlags.None, null) }));
}
<Main>o__SiteContainer0.<>p__Site2.Target (<Main>o__SiteContainer0.<>p__Site2, d);
}
// Nested Types
[CompilerGenerated]
private static class <Main>o__SiteContainer0
{
// FIElds
public static CallSite<Action<CallSite, object>> <>p__Site1;
public static CallSite<Action<CallSite, object>> <>p__Site2;
}
}