Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do xml comments persist in release mode?

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.
}
like image 667
ispiro Avatar asked May 02 '13 11:05

ispiro


People also ask

What is the advantage of using XML comments?

XML comments help speed development by providing IntelliSense on custom methods and other code constructs.

Which is the proper commenting method for XML?

The syntax for adding XML comments in your code is triple slashes /// followed by one of the supported XML tags. There's IntelliSense support for writing documentation comments that also provides a template comment on entering the third slash in the triple slash.

How do you put a comment in an XML file?

Syntax. An XML comment should be written as: <! -- Write your comment-->

What sequence of characters indicates the start of an XML style documentation comment in C# code?

The use of XML doc comments requires delimiters that indicate where a documentation comment begins and ends. You use the following delimiters with the XML documentation tags: /// Single-line delimiter: The documentation examples and C# project templates use this form.


2 Answers

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.

like image 105
Matthew Watson Avatar answered Sep 25 '22 21:09

Matthew Watson


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.

like image 42
BuDDhaPKT Avatar answered Sep 22 '22 21:09

BuDDhaPKT