What's the XML file that comes together with a

2020-05-25 07:37发布

问题:

Many .NET assemblies are accompanied with an XML file. For example, System.Web.WebPages.Razor.dll comes together with System.Web.WebPages.Razor.xml that contains the following:

<?xml version="1.0" encoding="utf-8" ?> 
<doc>
   <assembly>
       <name>System.Web.WebPages.Razor</name> 
   </assembly>
   <members>
       <member name="T:System.Web.WebPages.Razor.PreApplicationStartCode" /> 
       <member name="M:System.Web.WebPages.Razor.PreApplicationStartCode.Start" /> 
       <member name="T:System.Web.WebPages.Razor.RazorBuildProvider" /> 
       <member name="M:System.Web.WebPages.Razor.RazorBuildProvider.#ctor" />
        Much more elements follow...
   </members>
</doc>

What's this XML for? Do I need it in runtime?

回答1:

It is the code comments / intellisense file, and is used by the IDE (i.e. Visual Studio), not the runtime - it is where all the extended method / parameter / type descriptions etc come from.

You do not need to deploy it with your binary, but it does no harm either. It is also entirely optional in the IDE - just: intellisense will be less informative to you without it (it will just display te names and types, etc - not the more verbose method descriptions).

In your own library, use the /// syntax to write your own code comments, and enable the XML file generation in project-properties.



回答2:

This is the XML documentation for that assembly. This is only used for Intellisense in VisualStudio. Refer this answer for details.