8

I've searched and only found questions from people who want to suppress this warning such as Visual Studio Disabling Missing XML Comment Warning, or how to show it for only certain types of member, or how to add it to private members.

However for me this warning has never shown, in any of my copies of Visual Studio... and I want it to. I didn't even know the warning existed until today. I like to document my code, and want to know I've not missed any places.

Using the link above I've gone through the suggestions for disabling it in the accepted answer and checked none of those have already been done without my knowledge or without me remembering.

However this is happening (or not happening) in all copies of Visual Studio I have used in recent years, VS2013 Pro and VS2013 Express and VS2015 Community. And is the same across many projects, including ones I started myself from scratch and ones I have inherited from other developers.

Is there something I need to do to enable it in these versions? I'm confused as to why I'm not seeing it.

Community
  • 1
  • 1
RosieC
  • 649
  • 2
  • 11
  • 27

2 Answers2

10

You have to ask Visual Studio to output an XML documentation file as part of the build process to get those warnings.

Without that setting, Visual Studio will ignore those XML comments, except inside the same solution. Visual Studio will show documentation in intellisense and on mouseover in your code if the documentation is also part of the same solution but it will not complain about missing or incorrect items.

The setting you're looking for is in the project properties:

Visual Studio Project Settings for XML documentation file

Note that this setting is changed per build-configuration, so you should enable it for both DEBUG and RELEASE if you want the warnings for both build configurations.

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
  • That's brilliant, exactly what I was looking for! Well sort of, I now have 1140 warnings in a pretty small project. But hey... I want it documented properly! I take it you have to ship the XML file with your binary if you want other developers consuming your complied assembly to see them, is that right? – RosieC Nov 16 '15 at 13:04
  • 1
    @RosieC Yes, that's right. Also, you can use [SandCastle](https://github.com/EWSoftware/SHFB) to produce a help file from the XML files. – Matthew Watson Nov 16 '15 at 13:19
  • Thanks, I'll take a look. – RosieC Nov 16 '15 at 13:26
  • Note that if you use @Ayushmatis solution with the `GenerateDocumentationFile` tag it works for all build configurations. – Ykok Dec 11 '20 at 14:47
4

Use the Directory.build.props file at the root of the solution to set this property on for all projects in a solution. That way you can switch it on for all projects simultaneously via one line. Add this line :

 <GenerateDocumentationFile>true</GenerateDocumentationFile>

in the following section of the Directory.Build.props:

<Project>
  <PropertyGroup>    
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>  
</Project>
Ayushmati
  • 1,455
  • 1
  • 13
  • 15