public RuleResult CheckMethod (MethodDefinition method) { if (!method.IsTest ()) return RuleResult.DoesNotApply; if (!method.IsPublic) Runner.Report (method, Severity.Critical, Confidence.High); return Runner.CurrentRuleResult; }
public RuleResult CheckMethod (MethodDefinition method) { reportCounter = 0; if (!method.HasBody || !method.IsTest ()) return RuleResult.DoesNotApply; if (!OpCodeBitmask.Calls.Intersect (OpCodeEngine.GetBitmask (method))) return RuleResult.DoesNotApply; foreach (Instruction instruction in method.Body.Instructions) { if (instruction.OpCode.FlowControl != FlowControl.Call) continue; MethodReference m = (instruction.Operand as MethodReference); if (m == null || m.DeclaringType.FullName != "NUnit.Framework.Assert" || exceptions.Contains (m.Name)) continue; bool foundMessage = false; if (m.HasParameters) { MethodDefinition resolvedMethod = m.Resolve (); if (resolvedMethod == null) continue; foreach (ParameterDefinition parameter in resolvedMethod.Parameters) { if (parameter.ParameterType.FullName == "System.String" && parameter.Name == "message") { foundMessage = true; break; } } } if (!foundMessage) DelayedReport (new Defect (this, method, method, instruction, Severity.Medium, Confidence.High)); } return Runner.CurrentRuleResult; }