Skip to content

Latest commit

 

History

History
284 lines (219 loc) · 30.3 KB

sample-api-reference-zh-cn.md

File metadata and controls

284 lines (219 loc) · 30.3 KB

DocXml.dll .v3.6.0.0 API 文档

Created by mddox on 1/25/2024

所有类型

ReflectionExtensions 类 CommonComments 类 DocXmlReader 类
EnumComments 类 EnumValueComment 类 InheritdocTag 类
MethodComments 类 TypeComments 类 XmlDocId 类
DocXmlReaderExtensions 类 ReflectionSettings 类 TypeCollection 类
TypeInformation 类

ReflectionExtensions 类

命名空间:DocXml.Reflection

Reflection extension methods with supporting properties.

属性

名称 类型 摘要
KnownTypeNames Dictionary<Type, string> A dictionary containing a mapping of type to type names.

方法

名称 返回 摘要
CleanGenericTypeName(string genericTypeName) string Remove the parameter count part of the generic type name.
For example the generic list type name is List`1.
This method leaves only the name part of the type such as List.
If specified string does not contain the number of parameters
part then the same string is returned.
CreateKnownTypeNamesDictionary() Dictionary<Type, string> Create a dictionary of standard value types and a string type.
IsNullable(Type type) bool Checks if the specified type is a nullable value type.
Returns false for object references.
ToNameString(Type type, Func<Type, string> typeNameConverter) string Convert type to the proper type name.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns ValueTuple types without field names.
ToNameString(Type type, Func<Type, Queue<string>, string> typeNameConverter, bool invokeTypeNameConverterForGenericType) string Convert type to the proper type name.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns ValueTuple types without field names.
ToNameString(Type type, Queue<string> tupleFieldNames, Func<Type, Queue<string>, string> typeNameConverter, bool invokeTypeNameConverterForGenericType) string Convert type to the proper type name.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns named tuples with field names like this (Type1 field1, Type2 field2). tupleFieldNames parameter
must be specified with all tuple field names stored in the same order as they are in compiler-generated TupleElementNames attribute.
If you do not know what it is then the better and easier way is to use ToTypeNameString() methods that retrieve field names from attributes.
ToNameStringWithValueTupleNames(Type type, IList<string> tupleNames, Func<Type, Queue<string>, string> typeNameConverter, bool invokeTypeNameConverterForGenericType) string Convert type to the string.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns ValueTuple types with field names like this (Type1 name1, Type2 name2).
ToParametersString(MethodBase methodInfo, Func<Type, Queue<string>, string> typeNameConverter, bool invokeTypeNameConverterForGenericType) string Convert method parameters to the string. If method has no parameters then returned string is ()
If parameters are present then returned string contains parameter names with their type names.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns ValueTuple types with field names like this (Type1 name1, Type2 name2).
ToTypeNameString(ParameterInfo parameterInfo, Func<Type, Queue<string>, string> typeNameConverter, bool invokeTypeNameConverterForGenericType) string Convert method parameter type to the string.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns ValueTuple types with field names like this (Type1 name1, Type2 name2).
ToTypeNameString(MethodInfo methodInfo, Func<Type, Queue<string>, string> typeNameConverter, bool invokeTypeNameConverterForGenericType) string Convert method return value type to the string.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns ValueTuple types with field names like this (Type1 name1, Type2 name2).
ToTypeNameString(PropertyInfo propertyInfo, Func<Type, Queue<string>, string> typeNameConverter, bool invokeTypeNameConverterForGenericType) string Convert property type to the string.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns ValueTuple types with field names like this (Type1 name1, Type2 name2).
ToTypeNameString(FieldInfo fieldInfo, Func<Type, Queue<string>, string> typeNameConverter, bool invokeTypeNameConverterForGenericType) string Convert field type to the string.
Optional typeNameConverter function can convert type names to strings
if type names should be decorated in some way either by converting text to markdown or
HTML links or adding some formatting.

This method returns ValueTuple types with field names like this (Type1 name1, Type2 name2).

CommonComments 类

命名空间:LoxSmoke.DocXml

Base class for comments classes

属性

名称 类型 摘要
Summary string "summary" comment
Remarks string "remarks" comment
Example string "example" comment
Inheritdoc InheritdocTag Inheritdoc tag. Null if missing in comments.
FullCommentText string Full XML comment text

DocXmlReader 类

命名空间:LoxSmoke.DocXml

Helper class that reads XML documentation generated by C# compiler from code comments.

属性

名称 类型 摘要
UnIndentText bool Default value is true.
When it is set to true DocXmlReader removes leading spaces and an empty
lines at the end of the comment.
By default XML comments are indented for human readability but it adds
leading spaces that are not present in source code.
For example here is compiler generated XML documentation with '-'
showing spaces for readability.
----<summary>
----Text
----</summary>
With UnIndentText set to true returned summary text is just "Text"
With UnIndentText set to false returned summary text contains leading spaces
and the trailing empty line "\n----Text\n----"

构造函数

名称 摘要
DocXmlReader(string fileName, bool unindentText) Create reader and use specified XML documentation file
DocXmlReader(XPathDocument xPathDocument, bool unindentText) Create reader for specified xpath document.
DocXmlReader(Func<Assembly, string> assemblyXmlPathFunction, bool unindentText) Open XML documentation files based on assemblies of types. Comment file names
are generated based on assembly names by replacing assembly location with .xml.
DocXmlReader(IEnumerable<Assembly> assemblies, Func<Assembly, string> assemblyXmlPathFunction, bool unindentText) Open XML documentation files based on assemblies of types. Comment file names
are generated based on assembly names by replacing assembly location with .xml.

方法

名称 返回 摘要
GetEnumComments(Type enumType, bool fillValues) EnumComments Get enum type description and comments for enum values. If fillValues
is false and no comments exist for any value then ValueComments list is empty.
GetMemberComment(MemberInfo memberInfo) string Returns Summary comment for specified class member.
GetMemberComments(MemberInfo memberInfo) CommonComments Returns comments for specified class member.
GetMethodComments(MethodBase methodInfo) MethodComments Returns comments for the method or constructor. Returns empty comments object
if comments for method are missing in XML documentation file.
Returned comments tags:
Summary, Remarks, Parameters (if present), Responses (if present), Returns
GetMethodComments(MethodBase methodInfo, bool nullIfNoComment) MethodComments Returns comments for the class method. May return null object is comments for method
are missing in XML documentation file.
Returned comments tags:
Summary, Remarks, Parameters (if present), Responses (if present), Returns
GetTypeComments(Type type) TypeComments Return Summary comments for specified type.
For Delegate types Parameters field may be returned as well.

EnumComments 类

命名空间:LoxSmoke.DocXml

基类:CommonComments

Enum type comments

属性

名称 类型 摘要
ValueComments List<EnumValueComment> "summary" comments of enum values. List contains names, values and
comments for each enum value.
If none of values have any summary comments then this list may be empty.
If at least one value has summary comment then this list contains
all enum values with empty comments for values without comments.
Summary string "summary" comment
Remarks string "remarks" comment
Example string "example" comment
Inheritdoc InheritdocTag Inheritdoc tag. Null if missing in comments.
FullCommentText string Full XML comment text

EnumValueComment 类

命名空间:LoxSmoke.DocXml

基类:CommonComments

Comment of one enum value

属性

名称 类型 摘要
Name string The name of the enum value
Value int Integer value of the enum if enum value fits in signed 32-bit integer.
If value is too big (uint, long or ulong) then returned value is 0.
IsBigValue bool True if enum value is too big to fit in int Value property. Use BigValue property instead.
BigValue BigInteger The value of the enum. This field can handle any enum size.
Summary string "summary" comment
Remarks string "remarks" comment
Example string "example" comment
Inheritdoc InheritdocTag Inheritdoc tag. Null if missing in comments.
FullCommentText string Full XML comment text

方法

名称 返回 摘要
ToString() string Debugging-friendly text.

InheritdocTag 类

命名空间:LoxSmoke.DocXml

Inheritdoc tag with optional cref attribute.

属性

名称 类型 摘要
Cref string Cref attribute value. This value is optional.

MethodComments 类

命名空间:LoxSmoke.DocXml

基类:CommonComments

Method, operator and constructor comments

属性

名称 类型 摘要
Parameters List<(string Name, string Text)> "param" comments of the method. Each item in the list is the tuple
where Item1 is the "name" of the parameter in XML file and
Item2 is the body of the comment.
Returns string "returns" comment of the method.
Responses List<(string Code, string Text)> "response" comments of the method. The list contains tuples where
Item1 is the "code" of the response and
Item1 is the body of the comment.
TypeParameters List<(string Name, string Text)> "typeparam" comments of the method. Each item in the list is the tuple
where Item1 is the "name" of the parameter in XML file and
Item2 is the body of the comment.
Summary string "summary" comment
Remarks string "remarks" comment
Example string "example" comment
Inheritdoc InheritdocTag Inheritdoc tag. Null if missing in comments.
FullCommentText string Full XML comment text

TypeComments 类

命名空间:LoxSmoke.DocXml

基类:CommonComments

Class, Struct or delegate comments

属性

名称 类型 摘要
Parameters List<(string Name, string Text)> This list contains descriptions of delegate type parameters.
For non-delegate types this list is empty.
For delegate types this list contains tuples where
Name is the "name" attribute of "param"
Text is the body of the comment
TypeParameters List<(string Name, string Text)> This list contains description of generic type parameter
Name is the "name" attribute of "typeparam"
Text is the body of the comment
Summary string "summary" comment
Remarks string "remarks" comment
Example string "example" comment
Inheritdoc InheritdocTag Inheritdoc tag. Null if missing in comments.
FullCommentText string Full XML comment text

XmlDocId 类

命名空间:LoxSmoke.DocXml

Class that constructs IDs for XML documentation comments. IDs uniquely identify comments in the XML documentation file.

方法

名称 返回 摘要
EnumValueId(Type enumType, string enumName) string Get XML Id of specified value of the enum type.
EventId(MemberInfo eventInfo) string Get XML Id of event field
FieldId(MemberInfo fieldInfo) string Get XML Id of field
MemberId(MemberInfo memberInfo) string Get XML Id of any member of the type.
MethodId(MethodBase methodInfo) string Get XML Id of a class method
PropertyId(MemberInfo propertyInfo) string Get XML Id of property
TypeId(Type type) string Get XML Id of the type definition.

字段

名称 类型 摘要
MemberPrefix char Type member XML ID prefix.
FieldPrefix char Field name XML ID prefix.
PropertyPrefix char Property name XML ID prefix.
EventPrefix char Event XML ID prefix.
TypePrefix char Type name XML ID prefix.
ConstructorNameID string Part of the constructor XML tag in XML document.

DocXmlReaderExtensions 类

命名空间:LoxSmoke.DocXml.Reflection

DocXmlReader extension methods to retrieve type properties, methods, and fields using reflection information.

方法

名称 返回 摘要
Comments(DocXmlReader reader, IEnumerable<PropertyInfo> propInfos) IEnumerable<(PropertyInfo Info, CommonComments Comments)> Get comments for the collection of properties.
Comments(DocXmlReader reader, IEnumerable<MethodBase> methodInfos) IEnumerable<(MethodBase Info, MethodComments Comments)> Get comments for the collection of methods.
Comments(DocXmlReader reader, IEnumerable<FieldInfo> fieldInfos) IEnumerable<(FieldInfo Info, CommonComments Comments)> Get comments for the collection of fields.

ReflectionSettings 类

命名空间:LoxSmoke.DocXml.Reflection

Settings used by TypeCollection to retrieve reflection info.

属性

名称 类型 摘要
Default ReflectionSettings Default reflection settings.
PropertyFlags BindingFlags Binding flags to use when retrieving properties of the type.
MethodFlags BindingFlags Binding flags to use when retrieving methods of the type.
FieldFlags BindingFlags Binding flags to use when retrieving fields of the type.
NestedTypeFlags BindingFlags Binding flags to use when retrieving nested types of the type.
AssemblyFilter Func<Assembly, bool> Function that checks if specified types of assembly should be added to the set of the
referenced types.
Return true if referenced types of the assembly should be examined.
Return false if assembly types should be ignored.
Default implementation checks if documentation XML file exists for the assembly and if
it does then returns true.
TypeFilter Func<Type, bool> Checks if specified type should be added to the set of referenced types.
Return true if type and types referenced by it should be examined.
Function should return false if type should be ignored.
Default implementation returns true for all types.
PropertyFilter Func<PropertyInfo, bool> Checks if specified property should be added to the list of properties and the
set of referenced types.
Return true if property and types referenced by it should be examined.
Function should return false if property should be ignored.
Default implementation returns true for all properties.
MethodFilter Func<MethodBase, bool> Checks if specified method should be added to the list of methods and the
set of referenced types.
Return true if the method and types referenced by it should be examined.
Function should return false if method should be ignored.
Default implementation returns true for all methods.
FieldFilter Func<FieldInfo, bool> Checks if specified field should be added to the list of fields and the
set of referenced types.
Return true if field and types referenced by it should be examined.
Function should return false if field should be ignored.
Default implementation returns true for all fields.

TypeCollection 类

命名空间:LoxSmoke.DocXml.Reflection

Collection of type information objects.

属性

名称 类型 摘要
Settings ReflectionSettings Reflection settings that should be used when looking for referenced types.
ReferencedTypes Dictionary<Type, TypeInformation> All referenced types.
VisitedPropTypes HashSet<Type> Types that had their data and functions examined.
PendingPropTypes Queue<Type> Types that need to have their properties, methods and fields examined.
CheckAssemblies Dictionary<Assembly, bool> Cached information from ExamineAssemblies call.
Contains the set of assemblies that should be checked or ignored.
IgnoreTypes HashSet<Type> Cached information from the ExamineTypes call.
Contains the set of types that should be ignored.

方法

名称 返回 摘要
ForReferencedTypes(Type type, ReflectionSettings settings) TypeCollection Get all types referenced by the specified type.
Reflection information for the specified type is also returned.
ForReferencedTypes(Assembly assembly, ReflectionSettings settings) TypeCollection Get all types referenced by the types from specified assembly.
ForReferencedTypes(IEnumerable<Assembly> assemblies, ReflectionSettings settings) TypeCollection Get all types referenced by the types from the list of assemblies.
GetReferencedTypes(Type type, ReflectionSettings settings) void Get all types referenced by the specified type.
Reflection information for the specified type is also returned.
GetReferencedTypes(Assembly assembly, ReflectionSettings settings) void Get all types referenced by the types from specified assembly.
GetReferencedTypes(IEnumerable<Assembly> assemblies, ReflectionSettings settings) void Get all types referenced by the types from specified assemblies.
Reflection information for the specified type is also returned.
UnwrapType(Type parentType, Type type) void Recursively "unwrap" the generic type or array. If type is not generic and not an array
then do nothing.

TypeInformation 类

命名空间:LoxSmoke.DocXml.Reflection

Reflection information for the class, its methods, properties and fields.

属性

名称 类型 摘要
Type Type The type that this class describes
ReferencesIn HashSet<Type> Other types referencing this type.
ReferencesOut HashSet<Type> Other types referenced by this type.
Properties List<PropertyInfo> The list of property inforation of the class.
Methods List<MethodBase> The list of method inforation of the class.
Fields List<FieldInfo> The list of field inforation of the class.