internal static bool EvaluateParameterHelper(IAttributeInfo traitAttribute) { // Parse the traitAttribute. We make sure it contains two parts: // 1. Type 2. nameof(conditionMemberName) object[] conditionArguments = traitAttribute.GetConstructorArguments().ToArray(); Debug.Assert(conditionArguments.Count() == 2); Type calleeType = null; string[] conditionMemberNames = null; if (ConditionalTestDiscoverer.CheckInputToSkipExecution(conditionArguments, ref calleeType, ref conditionMemberNames)) { return(true); } return(DiscovererHelpers.Evaluate(calleeType, conditionMemberNames)); }
internal static bool EvaluateParameterHelper(IAttributeInfo traitAttribute) { // Parse the traitAttribute. We make sure it contains two parts: // 1. Type 2. nameof(conditionMemberName) object[] conditionArguments = traitAttribute.GetConstructorArguments().ToArray(); Debug.Assert(conditionArguments.Count() == 2); Type calleeType = null; string[] conditionMemberNames = null; if (ConditionalTestDiscoverer.CheckInputToSkipExecution(conditionArguments, ref calleeType, ref conditionMemberNames)) { return(true); } foreach (string entry in conditionMemberNames) { // Null condition member names are silently tolerated. if (string.IsNullOrWhiteSpace(entry)) { continue; } MethodInfo conditionMethodInfo = ConditionalTestDiscoverer.LookupConditionalMethod(calleeType, entry); if (conditionMethodInfo == null) { throw new InvalidOperationException($"Unable to get MethodInfo, please check input for {entry}."); } // If one of the conditions is false, then return the category failing trait. if (!(bool)conditionMethodInfo.Invoke(null, null)) { return(false); } } return(true); }