/// <summary> /// Verifies that a field correctly exposes a certain parameter of a constructor. /// </summary> /// <param name="field"> /// The field. /// </param> public override void Verify(FieldInfo field) { if (field == null) throw new ArgumentNullException("field"); if (field.IsStatic || field.ReflectedType.IsEnum) return; var fieldInfoElement = field.ToElement(); var parameterInfoElements = GetParameterInfoElements(field.ReflectedType); if (parameterInfoElements.Any(p => this.MemberToParameterComparer.Equals(fieldInfoElement, p))) return; var messageFormat = @"No constructors with an argument that matches the field were found. Declaring type: {0} Reflected type: {1} Field : {2}"; throw new MemberInitializationException( string.Format( CultureInfo.CurrentCulture, messageFormat, field.DeclaringType, field.ReflectedType, fieldInfoElement)); }
/// <summary> /// Verifies that a field does not expose the indirect references through public APIs. /// </summary> /// <param name="field"> /// The field. /// </param> public override void Verify(FieldInfo field) { if (!this.IsExposed(field)) return; this.EnsureDostNotExposeIndirectReferences(field.ToElement()); }