2 using System
.Diagnostics
;
3 using System
.Reflection
;
9 public static string TestPassed (bool value) {
10 return value ? "PASSED" : "FAILED";
12 public static string TestFailed (bool value) {
13 return TestPassed (! value);
16 public static int Main () {
17 MethodBase myMethodBase
= MethodBase
.GetCurrentMethod ();
18 MethodBase inlinedMethodBase
= InlinedMethods
.GetCurrentMethod ();
20 Assembly myExecutingAssembly
= Assembly
.GetExecutingAssembly ();
21 Assembly inlinedExecutingAssembly
= InlinedMethods
.GetExecutingAssembly ();
23 Assembly myCallingAssembly
= Assembly
.GetCallingAssembly ();
24 Assembly inlinedCallingAssembly
= InlinedMethods
.CallCallingAssembly ();
26 StackFrame myStackFrame
= new StackFrame ();
27 StackFrame inlinedStackFrame
= InlinedMethods
.GetStackFrame ();
29 string myConstructorCalledFrom
= new CallingAssemblyDependant ().CalledFrom
;
30 string inlinedConstructorCalledFrom
= CallingAssemblyDependant
.CalledFromLibrary ();
32 StaticFlag
.Flag
= true;
33 bool strictFlag
= ResourceStrictFieldInit
.Single
.Flag
;
34 bool relaxedFlag
= ResourceRelaxedFieldInit
.Single
.Flag
;
36 Console
.WriteLine ("[{0}]CurrentMethod: my {1}, inlined {2}, equals {3}",
37 TestFailed (myMethodBase
== inlinedMethodBase
),
38 myMethodBase
.Name
, inlinedMethodBase
.Name
,
39 myMethodBase
== inlinedMethodBase
);
41 Console
.WriteLine ("[{0}]ExecutingAssembly: my {1}, inlined {2}, equals {3}",
42 TestFailed (myExecutingAssembly
== inlinedExecutingAssembly
),
43 myExecutingAssembly
.GetName ().Name
, inlinedExecutingAssembly
.GetName ().Name
,
44 myExecutingAssembly
== inlinedExecutingAssembly
);
46 Console
.WriteLine ("[{0}]CallingAssembly: my {1}, inlined {2}, equals {3}",
47 TestFailed (myCallingAssembly
== inlinedCallingAssembly
),
48 myCallingAssembly
.GetName ().Name
, inlinedCallingAssembly
.GetName ().Name
,
49 myCallingAssembly
== inlinedCallingAssembly
);
51 Console
.WriteLine ("[{0}]StackFrame.GetMethod: my {1}, inlined {2}, equals {3}",
52 TestFailed (myStackFrame
.GetMethod ().Name
== inlinedStackFrame
.GetMethod ().Name
),
53 myStackFrame
.GetMethod ().Name
, inlinedStackFrame
.GetMethod ().Name
,
54 myStackFrame
.GetMethod ().Name
== inlinedStackFrame
.GetMethod ().Name
);
56 Console
.WriteLine ("[{0}]ConstructorCalledFrom: my {1}, inlined {2}, equals {3}",
57 TestFailed (myConstructorCalledFrom
== inlinedConstructorCalledFrom
),
58 myConstructorCalledFrom
, inlinedConstructorCalledFrom
,
59 myConstructorCalledFrom
== inlinedConstructorCalledFrom
);
62 * The relaxedFlag test is broken, the runtime can initialized
63 * to false before the StaticFlag.Flag = true assignment is ran.
67 Console
.WriteLine ("[{0}]strictFlag: {1}, relaxedFlag: {2}",
68 TestFailed ((strictFlag
!= relaxedFlag
)),
69 strictFlag
, relaxedFlag
);
70 if ((myMethodBase
!= inlinedMethodBase
) &&
71 (myExecutingAssembly
!= inlinedExecutingAssembly
) &&
72 (myCallingAssembly
!= inlinedCallingAssembly
) &&
73 (myStackFrame
.GetMethod ().Name
!= inlinedStackFrame
.GetMethod ().Name
) &&
74 (myConstructorCalledFrom
!= inlinedConstructorCalledFrom
) &&
75 (strictFlag
== relaxedFlag
)) {