Since reading Robert Martin's book Clean Code I have been inspired to revisit and refactor some of my code to break it down into succinct methods and small specialised classes.Given the need to retrieve the NameAttribute off the Name2 property of the TestObject class below...    public class TestObject    {        public string Name1 { get; set; }        [Name(Address)]        public string Name2 { get; set; }    }I have built a class called PropertyNameAttributeFinder to acheive this.public class PropertyNameAttributeFinder{    #region Fields    private readonly PropertyInfo _property;    private NameAttribute _attributeFound;    #endregion    #region Construtors    /// <summary>    /// Initializes a new instance of the <see cref=PropertyNameAttributeFinder/> class.    /// </summary>    /// <param name=property>The property.</param>    /// <exception cref=System.ArgumentNullException>property</exception>    public PropertyNameAttributeFinder(PropertyInfo property)    {        if (property == null) throw new ArgumentNullException(property);        _property = property;    }    #endregion    #region Public Members    /// <summary>    /// Checks for attribute.    /// </summary>    /// <returns>The current instance for fluid API</returns>    public PropertyNameAttributeFinder CheckForAttribute()    {        SetAttributeIfExists();        return this;    }    /// <summary>    /// Gets a value indicating whether this instance has found an attribute.    /// </summary>    /// <value>    /// <c>true</c> if this instance has found an attribute; otherwise, <c>false</c>.    /// </value>    public bool HasFoundAttribute    {        get { return _attributeFound != null; }    }    /// <summary>    /// Gets the AttributeFound that was found.    /// </summary>    /// <value>    /// The AttributeFound.    /// </value>    public NameAttribute AttributeFound    {        get        {            if (!HasFoundAttribute)            {                throw new InvalidOperationException(No attribute type was found so cannot be returned. Hint: Use HasFoundAttribute first.);            }            return _attributeFound;        }    }    #endregion    #region Private Members    private void SetAttributeIfExists()    {        _attributeFound = _property.GetAttribute<NameAttribute>();    }    #endregion}The class will be used as follows...    [TestMethod]    public void AttributeFound_WhenCalledAfterCheckAttributeAndPropertyDoesHaveAtrribute_ReturnsInstanceOfAttribute()    {        // ARRANGE        Type testType = typeof(TestObject);        PropertyInfo property = testType.GetProperty(Name2);        // ACT        NameAttribute actual = new PropertyNameAttributeFinder(property)            .CheckForAttribute()            .AttributeFound;        // ASSERT        Assert.IsNotNull(actual);    }Can this class be written better to express it's intent in a clearer manner?EDIT:Following request from @Heslacher, here is the code from the extension method called by _property.GetAttribute<NameAttribute>(); in SetAttributeIfExists.    /// <summary>    /// Get an attribute for a property    /// </summary>    /// <typeparam name=T></typeparam>    /// <param name=propertyInfo></param>    /// <returns></returns>    public static T GetAttribute<T>(this PropertyInfo propertyInfo)        where T : Attribute    {        var attribute = propertyInfo.GetCustomAttributes(typeof(T), false).FirstOrDefault();        return (T)attribute;    }Please note: It is not the code in this extension which I want reviewed, but rather the PropertyNameAttributeFinder class and how calling it reads. I.E. doe the public members clearly reveal the intent of the class.
Find attribute on class property
c#;fluent interface