void CheckReturnType(MethodReference method) { TypeReference rt = method.ReturnType; if (!IsObsolete (rt)) return; string msg = String.Format (CultureInfo.InvariantCulture, "Return type '{0}' is obsolete.", rt); Runner.Report (method, method.IsVisible () ? Severity.High : Severity.Medium, Confidence.Total, msg); }
void CheckMethodCall(MethodDefinition method, Instruction ins, MethodReference call) { if (call == null) return; string msg = null; if (IsObsolete (call)) { msg = String.Format (CultureInfo.InvariantCulture, "Method '{0}' is obsolete.", call); } else { TypeReference type = call.DeclaringType; if (IsObsolete (type)) msg = String.Format (CultureInfo.InvariantCulture, "Type '{0}' is obsolete.", type); } if (msg != null) { Severity severity = call.IsVisible () ? Severity.Medium : Severity.Low; Runner.Report (method, ins, severity, Confidence.High, msg); } }
void CheckParameters(MethodReference method) { foreach (ParameterDefinition p in method.Parameters) { if (IsObsolete (p.ParameterType)) { string msg = String.Format (CultureInfo.InvariantCulture, "Parameter type '{0}' is obsolete.", p.ParameterType); Runner.Report (p, method.IsVisible () ? Severity.High : Severity.Medium, Confidence.Total, msg); } } }
// helper method to avoid calling the same (large) properties more than once -> AvoidRepetitiveCallsToPropertiesRule static bool IsVisible(MethodReference method) { return ((method != null) && method.IsVisible ()); }