Home > Net >  How to test if all functions in my project are commented with <summary>
How to test if all functions in my project are commented with <summary>

Time:06-01

I'm using jetbrains-rider / C#. I want to test and find out if all my functions are fully commented like

    /// <summary>
    /// Add a and b
    /// </summary>
    /// <param name="a">a int</param>
    /// <param name="b">another int</param>
    /// <returns>sum of a and b</returns>
    public int Add(int a, int b);

Rider will give out a warning if param name does not match only if the summary comments exist. What I want is if a function is not coming with a corresponding summary, rider will gives out warnings. Or I can somehow inspect the code to give out a NG list.

How can I achieve this?

CodePudding user response:

You can configure it to give a Hint, Suggestion, Warning, or Error. The inspection tool is probably configured by default to enable the warning but Rider won't show them unless you turn on XML Documentation generation.

  1. Open the project's Properties
  2. For each Configuration, enable the Generate option
  3. Accept the default file location or set your own

enter image description here

Once that's applied, you should see a warning. If a warning is enough, you're done. If you want to turn it on for private code or want to change the inspection severity or if it wasn't already enabled...

  1. Open the Rider Settings
  2. Go to Editor -> Inspection Settings -> Inspection Severity -> C#
  3. Search using "xml"
  4. Find the inspections you want to add and/or edit
  5. Click Save

enter image description here

You can use Dynamic Code Analysis and the Problems tab to see if any are breaking the rule. Just make sure your view options on the tab includes the level you set for it (Warning/Error).

enter image description here

  • Related