/** Goes through all methods and adds an implicit cost for those beginning with "set" (assuming * to test the {@code baseMethod}'s class, you need to be able to call the setters for initialization. */ private void addSetterInjection(MethodInfo baseMethod, TestabilityVisitor.CostRecordingFrame frame) { foreach (MethodInfo setter in baseMethod.GetSiblingSetters()) { frame.applyImplicitCost(setter, Reason.IMPLICIT_SETTER); } }
/** Adds an implicit cost to all non-static methods for calling the constructor. (Because to test * any instance method, you must be able to instantiate the class.) Also marks parameters * injectable for the constructor with the most non-primitive parameters. */ private void addConstructorCost(MethodInfo method, TestabilityVisitor.CostRecordingFrame frame) { MethodInfo constructor = method.ClassInfo.GetConstructorWithMostNonPrimitiveParameters(); if (constructor != null) { frame.applyImplicitCost(constructor, Reason.IMPLICIT_CONSTRUCTOR); } }
/** Includes the cost of all static initialization blocks, as well as static field assignments. */ private void addStaticInitializationCost(MethodInfo baseMethod, TestabilityVisitor.CostRecordingFrame frame) { if (baseMethod.IsStaticConstructor()) { return; } foreach (var method in baseMethod.ClassInfo.GetMethods()) { //if (method.Name.StartsWith("<clinit>")) if (method.Name.StartsWith(".cctor")) { // TODO, different way to represent constructor method, by sunlw frame.applyImplicitCost(method, Reason.IMPLICIT_STATIC_INIT); } } }