public void Analyzer_ReturnsValidNumberOfAnnotations_GivenConstraints(string methodName, int expectedContracts)
        {
            // analyze method
            MethodInfo method = this.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
            MethodAnalysis analysis = new MethodAnalyzer().AnalyzeMethod(method, false, emitWarnings: false);

            // assert
            Assert.AreEqual(expectedContracts, analysis.ParameterPreconditions.Length + analysis.ReturnValuePreconditions.Length);
            Assert.AreEqual(expectedContracts > 0, analysis.HasContract);
        }
            private void Analyze(AMethodDecl method)
            {
                MethodAnalyzer analyzer = new MethodAnalyzer(method, Methods, data);
                method.GetBlock().Apply(this);
                Methods[method] = analyzer.SafeData;

                /*  List of safe variables after each statement
                 *      While statements need a list for first statement in the while, and a list for first statement after the while
                 *          Also need to account for break and continue statments
                 *      If statements need a list for then then branch, and one for the else branch.
                 *
                 *  CFG:
                 *  Join(v):
                 *      First, set safeList = intersection(pred(stm))
                 *      Parse through expression, do the folloing in the order you get out of nodes
                 *          pointerLvalue: If unsafe, make a test, and restart check ///NO, its an iterative build. do this after
                 *          delete: clear safeList, safeIfTrue and safeIfFalse
                 *          p == null: if p is a pointer, add p to a safeIfTrue list
                 *          p != null: if p is a pointer, add p to a safeIfFalse list
                 *          !<exp>: swap safeIfTrue and safeIfFalse lists
                 *          <exp> || <exp>: intersection between left and right safeIfTrue list
                 *          <exp> && <exp>: intersection between left and right safeIfFalse list
                 *
                 *          if stm:         thenList = safeList U safeIfTrue
                 *                          afterList = safeList U safeIfFalse
                 *          if-else stm:    thenList = safeList U safeIfTrue
                 *                          elseList = safeList U safeIfFalse
                 *          while stm:      thenList = safeList U safeIfTrue
                 *
                 *
                 * Problem: if something is safe before a while, it currently can't become safe in the while, since it will not initially be safe at the end of the while.
                 *
                 *
                 *
                 * -------------------------------
                 *
                 * List of unsafe variables after each CFG node.
                 *
                 * Preprocess step: List of all used variables (Base: Field/Local, Others:Pointer/StructField)
                 *
                 * All those variables are unsafe before first statment
                 *
                 *
                 * Join(v):
                 *
                 *
                 */
            }
			internal override void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
			{
				LocalBuilder local = ilgen.DeclareLocal(DeclaringType.TypeAsTBD);
				ilgen.Emit(OpCodes.Ldloc, local);
				ilgen.Emit(OpCodes.Box, DeclaringType.TypeAsTBD);
			}
			internal override void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
			{
				TypeWrapper targetType = ma == null ? null : ma.GetStackTypeWrapper(opcodeIndex, 0);
				if (targetType == null || targetType.IsInterface)
				{
					MethodInfo createDelegate = Types.Delegate.GetMethod("CreateDelegate", new Type[] { Types.Type, Types.Object, Types.String });
					LocalBuilder targetObj = ilgen.DeclareLocal(Types.Object);
					ilgen.Emit(OpCodes.Stloc, targetObj);
					ilgen.Emit(OpCodes.Ldtoken, delegateConstructor.DeclaringType);
					ilgen.Emit(OpCodes.Call, Types.Type.GetMethod("GetTypeFromHandle", new Type[] { Types.RuntimeTypeHandle }));
					ilgen.Emit(OpCodes.Ldloc, targetObj);
					ilgen.Emit(OpCodes.Ldstr, "Invoke");
					ilgen.Emit(OpCodes.Call, createDelegate);
					ilgen.Emit(OpCodes.Castclass, delegateConstructor.DeclaringType);
				}
				else
				{
					ilgen.Emit(OpCodes.Dup);
					// we know that a DelegateInnerClassTypeWrapper has only one method
					Debug.Assert(iface.GetMethods().Length == 1);
					MethodWrapper mw = targetType.GetMethodWrapper("Invoke", iface.GetMethods()[0].Signature, true);
					// TODO linking here is not safe
					mw.Link();
					ilgen.Emit(OpCodes.Ldvirtftn, (MethodInfo)mw.GetMethod());
					ilgen.Emit(OpCodes.Newobj, delegateConstructor);
				}
			}
		internal virtual void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
		{
			throw new InvalidOperationException();
		}
		internal sealed override void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
		{
			AssertLinked();
			PreEmit(ilgen);
			NewobjImpl(ilgen);
			if(DeclaringType.IsNonPrimitiveValueType)
			{
				DeclaringType.EmitBox(ilgen);
			}
		}
			internal override void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
			{
				DoEmit(ilgen);
			}
 public PropertiesDependencieAnalyzer()
 {
     this.methodAnalyzer = new MethodAnalyzer( this );
 }
				internal override void EmitNewobj(CodeEmitter ilgen, MethodAnalyzer ma, int opcodeIndex)
				{
					if(mbHelper != null)
					{
						ilgen.Emit(OpCodes.Call, mbHelper);
					}
					else
					{
						ilgen.Emit(OpCodes.Newobj, (ConstructorInfo)GetMethod());
					}
				}