Auto Implement an Interface RRS feed

  • Question

  • Hello

    I've got an interface that I auto implement on a class.  See example below.   I can use resharper and the visual studio short cut to implement the interface.  The question is why can't the XML comments and the [SomeCustomAttribute] also get auto added?

    As a result I end up doing a copy and paste.  Is there a fix for this?

        /// <summary>
        /// Example interace
        /// </summary>
        public interface IExample
            /// <summary>
            /// This is method 1
            /// </summary>
            void method1();
            /// <summary>
            /// This is method2
            /// </summary>
            /// <returns>Some Data</returns>
            string method2();

    Thursday, May 31, 2018 8:09 PM

All replies

  • Hi William256,

    Unfortunately, as i know, the comments cannot be auto added. You have to manually add them if needed.


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, June 1, 2018 8:53 AM
  • The comment information is not part of the metadata. Comment information is stored in an XML file that may or may not be co-located with the assembly.

    Yes, it could be modified to do that if the documentation is available. You could use the Provide a suggestion button in VS to recommend this if you'd like. But do note that you don't always want the documentation. 

    As for the attributes, it doesn't make sense in many cases to copy the attribute. Attributes are a type-level feature and just because you implement an interface doesn't mean the attributes applied to the interface's member makes sense for your scenario. It might even cause issues. Most of the time an interface member won't have an attribute anyway since interfaces are contracts and there are no requirements that a contract have any metadata associated with it.

    Michael Taylor

    Friday, June 1, 2018 1:55 PM