8

On the one hand MSDN says:

The XML doc comments are not metadata; they are not included in the compiled assembly ...

But on the other hand, Intellisense shows them in Visual Studio for .net classes etc. (e.g. if you hover over Int32.)

To avoid misunderstandings: I'm referring to these:

/// <summary>
/// These comments.
/// </summary>
void example()
{
    //Not these.
}
ispiro
  • 26,556
  • 38
  • 136
  • 291
  • possible duplicate of [Stripping out comments from the project files just for the release build](http://stackoverflow.com/questions/4214784/stripping-out-comments-from-the-project-files-just-for-the-release-build) – Ravi Gadag May 02 '13 at 11:37

2 Answers2

13

The XML documentation files are separate from the DLLs for an assembly. They are just UTF8 XML Files. If they happen to be in the same folder as the DLL that they document, then Visual Studio will pick them up.

When you compile, the build process will copy the XML files into the build output folder automatically, if they exist.

None of the contents of the XML documentation ever gets put inside any DLL.

If you look at the framework DLL files (for example in "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0") you will see loads of ".xml" files next to them.

Matthew Watson
  • 104,400
  • 10
  • 158
  • 276
  • Thanks. So what you're saying is that .net dll's have their XML files in their folders? – ispiro May 02 '13 at 11:40
  • OK. Not in the dll. But will it persist as an XML file? – ispiro May 02 '13 at 11:43
  • I assume your answering my first comment. Right? – ispiro May 02 '13 at 11:45
  • @ispiro Yes I was. As for your second question, what do you mean "will it persist"? The XML files will only go away if you delete them. Of course, if you copy all the DLL files to a new folder without copying the XML files too, then the XML files won't be in the new folder (which is kindof obvious). They are just ordinary files. – Matthew Watson May 02 '13 at 11:47
  • a) Thanks for your patience. b) What I mean is - I compile my application and publish it using Visual Studio (ClickOnce) - will an XML be created and published? (I just tried and it doesn't seem to be created. But I'm new to this so I want to make sure.) – ispiro May 02 '13 at 11:50
  • @ispiro No it won't for a ClickOnce app. I assume you don't want to, and you just want to be sure they won't get copied? If you *do* want them copied, there is a way (in which case let me know and I'll explain). The same applies when you're making an installer - they won't get copied unless you explicitly set the installer to copy them. – Matthew Watson May 02 '13 at 11:52
  • Thanks. You are correct in your assumption. And I just found that option (for the opposite of what I want, yes) with the help of a comment below. Thanks again. – ispiro May 02 '13 at 11:54
  • found this and it answered my question of how to get another solution to have Intellisense populated with the XML comments from a compiled assembly brought over from another solution -- thanks!! – Code Jockey Feb 06 '15 at 18:08
5

No these are stripped when you compile your code to IL....Compile your code to a DLL or exe and then use the tool ILDasm to open it. You will notice you comments are not included. You could then decompile your code with a tool like Reflector and again see your comments are gone. ILDasm and Reflector are great tools in general you should become familiar with.

BuDDhaPKT
  • 127
  • 2
  • Thanks. So how come they exist for the .net classes? – ispiro May 02 '13 at 11:36
  • 3
    If you look in the framework folder you have a `.xml` for each `.dll` which is used to present the info – V4Vendetta May 02 '13 at 11:41
  • @V4Vendetta Thanks. So my question becomes - "Will an XML file be created with the dll?" I don't see one being created. But I'm just now hearing about this, so I want to make sure. – ispiro May 02 '13 at 11:44
  • 1
    @ispiro I guess in the project build properties you have an option to generate the documentation xml – V4Vendetta May 02 '13 at 11:48
  • @V4Vendetta Perfect. I see it there. (You can transform this into an answer. Definitely deserves an upvote. Thanks.) – ispiro May 02 '13 at 11:52