Comment the interface, implementation or both?

后端 未结 9 1272
萌比男神i
萌比男神i 2020-12-13 03:08

I imagine that we all (when we can be bothered!) comment our interfaces. e.g.

/// 
/// Foo Interface
/// 
public interface Fo         


        
相关标签:
9条回答
  • 2020-12-13 03:54

    I created a tool that post-processes the XML documentation files to add support for the <inheritdoc/> tag.

    While it doesn't help with Intellisense in source code, it does allow the modified XML documentation files to be included in a NuGet package and therefore works with Intellisense in referenced NuGet packages.

    It's at www.inheritdoc.io (free version available).

    0 讨论(0)
  • 2020-12-13 03:58

    If you use the GhostDoc addin, it updates the implementation with the comment from the interface when you right click and select "Document This" on the method.

    0 讨论(0)
  • 2020-12-13 03:58

    C# usage:

    Interface can look like this:

        /// <summary>
        /// Helper class to access various properties for the current site.
        /// </summary>
        public interface ISiteHelper
        {
            /// <summary>
            /// Gets the site id of the current site
            /// </summary>
            /// <returns>The site id.</returns>
            int GetSiteID();
        }
    }
    

    Implementation can look like this:

    /// <inheritdoc />
    public class SiteHelper: ISiteHelper
    {
        /// <inheritdoc />
        public int GetSiteID()
        {
            return CommonRepository.GetSiteID();
        }
    }
    
    0 讨论(0)
提交回复
热议问题