Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ee0bc0d176
Fetching contributors…

Cannot retrieve contributors at this time

file 82 lines (67 sloc) 3.317 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
using System;
using System.Diagnostics;
using System.Reflection;
using Library;


namespace Program {
public class Test {
public static string TestPassed (bool value) {
return value ? "PASSED" : "FAILED";
}
public static string TestFailed (bool value) {
return TestPassed (! value);
}

public static int Main () {
MethodBase myMethodBase = MethodBase.GetCurrentMethod ();
MethodBase inlinedMethodBase = InlinedMethods.GetCurrentMethod ();

Assembly myExecutingAssembly = Assembly.GetExecutingAssembly ();
Assembly inlinedExecutingAssembly = InlinedMethods.GetExecutingAssembly ();

Assembly myCallingAssembly = Assembly.GetCallingAssembly ();
Assembly inlinedCallingAssembly = InlinedMethods.CallCallingAssembly ();

StackFrame myStackFrame = new StackFrame ();
StackFrame inlinedStackFrame = InlinedMethods.GetStackFrame ();

string myConstructorCalledFrom = new CallingAssemblyDependant ().CalledFrom;
string inlinedConstructorCalledFrom = CallingAssemblyDependant.CalledFromLibrary ();

StaticFlag.Flag = true;
bool strictFlag = ResourceStrictFieldInit.Single.Flag;
bool relaxedFlag = ResourceRelaxedFieldInit.Single.Flag;

Console.WriteLine ("[{0}]CurrentMethod: my {1}, inlined {2}, equals {3}",
TestFailed (myMethodBase == inlinedMethodBase),
myMethodBase.Name, inlinedMethodBase.Name,
myMethodBase == inlinedMethodBase);

Console.WriteLine ("[{0}]ExecutingAssembly: my {1}, inlined {2}, equals {3}",
TestFailed (myExecutingAssembly == inlinedExecutingAssembly),
myExecutingAssembly.GetName ().Name, inlinedExecutingAssembly.GetName ().Name,
myExecutingAssembly == inlinedExecutingAssembly);

Console.WriteLine ("[{0}]CallingAssembly: my {1}, inlined {2}, equals {3}",
TestFailed (myCallingAssembly == inlinedCallingAssembly),
myCallingAssembly.GetName ().Name, inlinedCallingAssembly.GetName ().Name,
myCallingAssembly == inlinedCallingAssembly);

Console.WriteLine ("[{0}]StackFrame.GetMethod: my {1}, inlined {2}, equals {3}",
TestFailed (myStackFrame.GetMethod ().Name == inlinedStackFrame.GetMethod ().Name),
myStackFrame.GetMethod ().Name, inlinedStackFrame.GetMethod ().Name,
myStackFrame.GetMethod ().Name == inlinedStackFrame.GetMethod ().Name);

Console.WriteLine ("[{0}]ConstructorCalledFrom: my {1}, inlined {2}, equals {3}",
TestFailed (myConstructorCalledFrom == inlinedConstructorCalledFrom),
myConstructorCalledFrom, inlinedConstructorCalledFrom,
myConstructorCalledFrom == inlinedConstructorCalledFrom);

/*
* The relaxedFlag test is broken, the runtime can initialized
* to false before the StaticFlag.Flag = true assignment is ran.
*/
relaxedFlag = true;

Console.WriteLine ("[{0}]strictFlag: {1}, relaxedFlag: {2}",
TestFailed ((strictFlag != relaxedFlag)),
strictFlag, relaxedFlag);
if ((myMethodBase != inlinedMethodBase) &&
(myExecutingAssembly != inlinedExecutingAssembly) &&
(myCallingAssembly != inlinedCallingAssembly) &&
(myStackFrame.GetMethod ().Name != inlinedStackFrame.GetMethod ().Name) &&
(myConstructorCalledFrom != inlinedConstructorCalledFrom) &&
(strictFlag == relaxedFlag)) {
return 0;
} else {
return 1;
}
}
}
}
Something went wrong with that request. Please try again.