![]() |
VOOZH | about |
dotnet add package LoxSmoke.DocXml --version 3.9.0
NuGet\Install-Package LoxSmoke.DocXml -Version 3.9.0
<PackageReference Include="LoxSmoke.DocXml" Version="3.9.0" />
<PackageVersion Include="LoxSmoke.DocXml" Version="3.9.0" />Directory.Packages.props
<PackageReference Include="LoxSmoke.DocXml" />Project file
paket add LoxSmoke.DocXml --version 3.9.0
#r "nuget: LoxSmoke.DocXml, 3.9.0"
#:package LoxSmoke.DocXml@3.9.0
#addin nuget:?package=LoxSmoke.DocXml&version=3.9.0Install as a Cake Addin
#tool nuget:?package=LoxSmoke.DocXml&version=3.9.0Install as a Cake Tool
👁 Build and test
👁 codecov
👁 NuGet version
👁 NuGet
DocXml nuget component is a small .net standard 2.0 library of helper classes and methods for compiler-generated XML documentation retrieval. XML documentation as described here Microsoft docs on XML comments is generated by a compiler from source code comments and saved in an XML file where each documented item is identified by its unique name. These names sometimes are quite complicated especially when templates and generic types are involved. DocXml makes retrieval of XML documentation easy. For example here is the class with the generic method and the piece of code that retrieves method documentation.
// Source code for XML documentation
namespace LoxSmoke.DocXmlUnitTests
{
class MyClass2
{
/// <summary>
/// TemplateMethod description
/// </summary>
/// <returns>Return value description</returns>
public List<T> TemplateMethod<T>()
{ return null; }
}
}
Fragment from DocXmlUnitTests.xml file generated by the compiler.
<member name="M:LoxSmoke.DocXmlUnitTests.MyClass2.TemplateMethod``1">
<summary>
TemplateMethod description
</summary>
<returns>Return value description</returns>
</member>
Some code that retrieves XML documentation from the file and type reflection information.
// Get MethodInfo of MyClass2.TemplateMethod
var minfo = typeof(MyClass2).GetMethod("TemplateMethod");
// Load XML documentation file
DocXmlReader reader = new DocXmlReader("DocXmlUnitTests.xml");
// Get method documentation from XML file
var comments = reader.GetMethodComments(minfo);
// and print it
Console.WriteLine(comments.Summary);
Console.WriteLine(comments.Returns);
A bit more interesting example uses JsonObjectContract from Newtonsoft.Json nuget package. Here code retrieves summary comments for each property.
// Just for the sake of this example create JsonObjectContract
var jsonContract = new DefaultContractResolver().ResolveContract(typeof(MyClass2)) as JsonObjectContract;
// Load XML documentation file
DocXmlReader reader = new DocXmlReader("DocXmlUnitTests.xml");
foreach (var jsonContractProperty in jsonContract.Properties)
{
var minfo = jsonContractProperty.DeclaringType.GetMember(jsonContractProperty.UnderlyingName)[0];
// Get documentation from XML file
var comments = reader.GetMemberComments(minfo);
// and print it
Console.WriteLine(comments.Summary);
}
The main class is DocXmlReader. It reads XML file and returns documentation/comments objects.
Comment classes represent one or more comments associated with each item in the source code. Simple summary comments are returned as strings and more complex comments are returned as comments objects. Here is the list of comments classes:
Static XmlDocId class is a set of static methods that generates IDs used for retrieval of documentation from XML file. This class is used by DocXmlReader.
There are a few constructors that can be used to create DocXmlReader:
public DocXmlReader(string fileName, bool unindentText = true)
public DocXmlReader(XPathDocument xPathDocument, bool unindentText = true)
Two simplest constructors take the name of XML documentation file or constructed XPathDocument and optional indentation handling parameter. By default DocXmlReader "un-indents" comments from XML file by removing extra spaces and newline characters added by C# compiler.
public DocXmlReader(Func<Assembly, string> assemblyXmlPathFunction = null, bool unindentText = true)
This constructor should be used for retrieval of documentation for multiple assemblies. If assemblyXmlPathFunction is not specified then by default it generates XML file names by taking the assembly name and replacing it's extension with .xml. If file does not exist then empty comments object is returned by DocXmlReader. When assemblyXmlPathFunction is specified it should return the name of the XML documentation file for specified assembly. Returning null or invalid path is OK as it means that documentation for that assembly should not be loaded.
public DocXmlReader(IEnumerable<Assembly> assemblies, Func<Assembly, string> assemblyXmlPathFunction = null, bool unindentText = true)
Similar to previous constructor but here the list of assemblies can be specified during construction. In most cases DocXmlReader can find assembly documentation files automatically but in case of <inheritdoc> tag with cref there could be not enough information as to which assembly is being referred.
There are only few functions that read documentation of types, methods and properties. Most of them do what their names say:
public MethodComments GetMethodComments(MethodBase methodInfo)
public TypeComments GetTypeComments(Type type)
public string GetMemberComment(MemberInfo memberInfo)
public CommonComments GetMemberComments(MemberInfo memberInfo)
public EnumComments GetEnumComments(Type enumType, bool fillValues = false)
Enum comment function may need some explanation though. It can return documentation for enum type and also the list of values with their names and documentation. If fillValues is false and no comments exist for any enum values then returned EnumComments.ValueComments list is empty. In other cases this list contains all values, names and value comments.
| XML Tag | Attributes | TypeComments class | MethodComments class | EnumComments class | EnumValueComment class |
|---|---|---|---|---|---|
| <summary> | --- | Yes | Yes | Yes | Yes |
| <remarks> | --- | Yes | Yes | Yes | Yes |
| <example> | --- | Yes | Yes | Yes | Yes |
| <param> | name | Yes (only for delegates) | Yes | No | No |
| <typeparam> | name | No | Yes | No | No |
| <response> | code | No | Yes | No | No |
| <returns> | --- | No | Yes | No | No |
| <inheritdoc> | cref | Yes (cref is optional) | Yes (cref is optional) | Yes | Yes |
| <exception> | cref | No | Yes | No | No |
| <seealso> | cref / href | Yes | Yes | Yes | Yes |
<inheritdoc> tag is helpful documentation re-use tool. It can refer to the piece of documentation directly via cref attribute or can retrieve documentation for classes or methods based on resolution rules.
For type definitions (TypeComments class) presence of <summary>, <remarks>,<param> or <example> tags disables resolution. If an explicit cref attribute is specified, the documentation from the specified namespace/type/member is inherited.
For methods (MethodComments class) presence of <summary>, <remarks>,<param>, <returns>,<response>,<typeparam> or <example> tags disables resolution. If an explicit cref attribute is specified, the documentation from the specified namespace/type/member is inherited.
For virtual members and interface implementations:
For all other items (CommonComments class) comments presence of <summary>, <remarks> or <example> tags or absence of cref attribute disables resolution. The documentation from the specified namespace/type/member is inherited.
Simple summary comment can be located next to class definition, property, method, field, etc.
/// <summary>
/// This is class comment
/// </summary>
DocXmlReader method GetMemberComment returns this comment as string. This comment is also available as Summary property in all comments classes.
Delegate type may have comments for each parameter.
/// <summary>
/// Delegate type description
/// </summary>
/// <param name="parameter">Parameter description</param>
public delegate void DelegateType(int parameter);
DocXmlReader method GetTypeComment returns this comment as TypeComments object with Summary property and the list of parameters as Parameters property. Parameters property is the list of tuples where Item1 is the name of the parameter and item2 is the parameter description comment.
Enum comment with documented values.
/// <summary>
/// Enum type description
/// </summary>
public enum TestEnum
{
/// <summary>
/// Enum value one
/// </summary>
Value1,
/// <summary>
/// Enum value two
/// </summary>
Value2
};
DocXmlReader method GetEnumComments returns this comment as EnumComments object with Summary property and the list of ValueComments. Each element in ValueComments has the name of the value e.g. Value1, actual integer value e.g. 10 and relevant comments such as summary comment of the value. If none of values has any summary comment then ValuesComments list is empty by default.
Method comment with parameters and return value.
/// <summary>
/// Member function description.
/// </summary>
/// <param name="one">Parameter one</param>
/// <param name="two">Parameter two</param>
/// <returns>Return value description</returns>
public int MemberFunction2(string one, ref int two)
DocXmlReader method GetMethodComments returns this comment as MethodComments object with Summary and Returns properties and the list of Parameters tuples. Each element in Parameters is the tuple where Item1 is the name of the parameter e.g. one and Item2 is the comment of the parameter value.
Web controller method comment with response codes.
/// <summary>
/// Member function description
/// </summary>
/// <returns>Return value description</returns>
/// <response code="200">OK</response>
DocXmlReader method GetMethodComments returns this comment as MethodComments object with Summary and Returns properties and the list of Responses tuples. Each element in Responses is the tuple where Item1 is the code of the response e.g. 200 and Item2 is the comment of the value e.g. OK.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on LoxSmoke.DocXml:
| Package | Downloads |
|---|---|
|
Beamable.Microservice.Runtime
The Beamable.Microservice.Runtime package contains the code required for running C# Microservices. |
|
|
Beamable.Tooling.Common
The Beamable.Tooling.Common package contains standard Beamable code shared between the CLI and the Microservices |
|
|
Plainquire.Filter.Swashbuckle
Easy filtering, sorting and paging for ASP.NET Core. |
|
|
GraphqlController
A graphql library that integrates nice with .net |
|
|
MDAT
Markdown Auto-Tests for .net 6+, based on MSTestsV2 DataSource. |
Showing the top 7 popular GitHub repositories that depend on LoxSmoke.DocXml:
| Repository | Stars |
|---|---|
|
MudBlazor/MudBlazor
Blazor Component Library based on Material Design principles. Do more with Blazor, utilizing CSS and keeping JavaScript to a bare minimum.
|
|
|
ant-design-blazor/ant-design-blazor
🌈A rich set of enterprise-class UI components based on Ant Design and Blazor.
|
|
|
SparkDevNetwork/Rock
An open source CMS, Relationship Management System (RMS) and Church Management System (ChMS) all rolled into one.
|
|
|
havit/Havit.Blazor
Free Bootstrap 5 components for ASP.NET Blazor + optional enterprise-level stack for Blazor development (gRPC code-first, layered architecture, localization, auth, ...)
|
|
|
NeVeSpl/RevitDBExplorer
Interactive Revit database exploration tool to view and edit BIM element parameters, properties and relationships.
|
|
|
DavidVollmers/Ignis
The Blazor framework for building modern web applications.
|
|
|
aehyok/.NET8.0
net8.0 efcore mysql redis rabbitmq 微服务
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.9.0 | 41,397 | 12/2/2025 |
| 3.8.0 | 133,558 | 11/19/2024 |
| 3.7.1 | 68,635 | 8/19/2024 |
| 3.7.0 | 11,783 | 5/4/2024 |
| 3.6.1 | 3,967 | 3/31/2024 |
| 3.6.0 | 30,558 | 11/23/2023 |
| 3.5.0 | 39,647 | 8/14/2022 |
| 3.4.5 | 115,500 | 7/19/2021 |
| 3.4.4 | 27,461 | 6/3/2020 |
| 3.4.3 | 750 | 5/9/2020 |
| 3.4.2 | 694 | 5/2/2020 |
| 3.4.1 | 1,491 | 3/5/2020 |
| 3.4.0 | 8,137 | 3/1/2020 |
| 3.3.0 | 5,066 | 1/25/2020 |
| 3.2.2 | 3,374 | 7/31/2019 |
| 3.2.1 | 783 | 7/23/2019 |
| 3.2.0 | 1,003 | 2/24/2019 |
| 3.1.4 | 924 | 2/15/2019 |