CxXmlDoc

Description

sealed class Tinman.Core.Cx.XmlDoc.CxXmlDoc

Derived from

CxNode abstract

Represents the documentation comment of a type declaration, a member declaration or an enumeration item.

A Code-X compliant documentation comment is a standard CSharp XmlDoc comment, with additional syntactic and semantic rules and concepts. The syntax of a Code-X documentation comment (not including the leading '/// ') is defined by the following Grammar:

#               := ws | lb ;
root            := xmldoc ;

!xmldoc         := summary remarks? type-param* param* (returns | value)? exception*
                   see-also* keep* ;

!exception      := '<exception' 'cref' '=' '"' name '"' '>' body
                   '</exception>' ;
!keep           := '<keep' 'cref' '=' '"' ref '"' '/>' ;
!param          := '<param' 'name' '=' '"' id '"' '>' contract? body \ '['
                   '</param>' ;
!remarks        := '<remarks>' body '</remarks>' ;
!returns        := '<returns>' contract? body '</returns>' ;
!see-also       := '<seealso' 'cref' '=' '"' ref '"' '/>' ;
!summary        := '<summary>' body '</summary>' ;
!type-param     := '<typeparam' 'name' '=' '"' id '"' '>' body '</typeparam>' ;
!value          := '<value>' contract? body '</value>' ;

body            := para+ | body-item+ ;
body-item       := text | see | c | list | code | br | param-ref | type-param-ref ;
!list           := '<list' 'type' '=' list-type '>' list-item+ '</list>' ;
list-item       := '<item>' body '</item>' ;
!para           := '<para>' body-item+ '</para>' ;
!ref            := name ref-arguments? ('.' ref-member)? ref-signature? ;
ref-signature   := '(' (type .. ',')? ')' ;
see             := ws-ast? '<see' 'cref' '=' '"' ref '"' '/>' ;

ref-member      := id ref-arguments? ;

!param-ref      := ws-ast? '<paramref' 'name' '=' '"' id '"' '/>' ;
ref-arguments   := '{' (id .. ',') '}' ;
!type-param-ref := ws-ast? '<typeparamref' 'name' '=' '"' id '"' '/>' ;

c               := ws-ast? '<c>' text+ '</c>' ;
code            := '<code>' ws* lb line+ '</code>' ;

br              := '<br/>' ws* lb ;
line            := ws* ~(lb | '</code>')* lb ;
text            := (]\t\n\r &<[ | entity)+ ;
ws-ast          := (ws | lb)+ ;

entity          := '&' ('amp' | 'lt' | 'gt') ';' ;
lb              := '\r' '\n'? | '\n' ;
list-type       := '"bullet"' | '"number"' ;
ws              := '\t' | ' ' ;

The following external rules are used:

To obtain a CxXmlDoc from source code, use the FromSource method.

Public / Constructors

Cx​Xml​Doc


public constructor CxXmlDoc → (8)

summary in : CxXmlDocBody

[not-null]
See Summary.

remarks opt : CxXmlDocBody = null

See Remarks.

typeParameters opt : IBagConst<CxXmlDocTypeParameter> = null

The list of type parameters or null for an empty list. See TypeParameters.

parameters opt : IBagConst<CxXmlDocParameter> = null

The list of parameters or null for an empty list. See Parameters.

value opt : CxXmlDocValue = null

See Value.

exceptions opt : IBagConst<CxXmlDocException> = null

The list of thrown exceptions or null for an empty list. See Exceptions.

seeAlso opt : IBagConst<CxXmlDocSeeAlso> = null

The list of documentation links or null for an empty list. See SeeAlso.

keep opt : IBagConst<CxXmlDocReference> = null

The list of keep directives or null for an empty list. See Keep.

Creates a new instance of CxXmlDoc.

From​Source


public static method FromSource → (1)

source in : string

[not-null]
The documentation comment text.

returns → CxXmlDoc

The parsed Code-X documentation comment.

Parses the given Code-X documentation comment.

ValidatingException

If the syntax of source in is invalid.

Public / Attributes

Exceptions


[Constant]
public attribute Exceptions → (get)

value : IVectorConst<CxXmlDocException>

[not-null]
The exception sections.

Returns the exception sections.

Keep


[Constant]
public attribute Keep → (get)

value : IVector<CxXmlDocReference>

[not-null]
The keep sections.

Returns the custom keep sections.

When the Code-X workflow performs source code minification and obfuscation, usually some code elements must not be removed or their names must not be changed, because they are referenced by native code (see CxStatementCode).

The // [*] line-comment suffix may be used to keep a local variable in a statement block (see CxStatementVariable):

int thisMayBeRenamed;
int thisWillBeKept; // [*]

The _keep name suffix may also be used to keep local variables:

for (int current_keep = 0; ...) { ... }
foreach (var current_keep in ...) { ... }

At member or type scope, the custom XmlDoc element keep may be used to keep the referenced code element:

/// <summary>
///   A member with a keep rule.
/// </summary>
/// <keep cref="SomeType.SomeMethod(int)"/>
void SomeMember() { ... }

By using the [Keep] attribute, the annotated type, member or parameter will be kept:

[Keep]
class SomeType { ... }
...
[Keep]
void SomeMember() { ... }
...
void Member([Keep] someParameter) { ... }

In order to maximize the effectiveness of source code minification and obfuscation, the rules for keeping code elements should be applied according to the following best-practice:

  1. Use // [*] for keeping local variables, because this is the most compact syntax. If not applicable, use the _keep name suffix.

  2. Use the custom XmlDoc tag <keep cref="…​"/>, because this will trigger the keep rule only if the enclosing type or member is actually included in the final output.

  3. Use the [Keep] attribute for method parameters if a parameter shall be kept for the whole method. This will trigger the keep rule only if the enclosing member is actually included in the final output.

  4. Use the [Keep] attribute on a member, if it shall be kept if the enclosing type is actually included in the final output. This is generally true for members with private visibility. The enclosing type may still be discarded, though.

  5. Use the [Keep] attribute on a type, if it shall be kept. Individual type members may still be discarded, though.

Parameters


[Constant]
public attribute Parameters → (get)

value : IVectorConst<CxXmlDocParameter>

[not-null]
The param sections

Returns the param sections.

Remarks


[Constant]
public attribute Remarks → (get)

value : CxXmlDocBody

The remarks section.

Returns the remarks section.

See​Also


[Constant]
public attribute SeeAlso → (get)

value : IVectorConst<CxXmlDocSeeAlso>

[not-null]
The seealso sections

Returns the seealso sections.

Summary


[Constant]
public attribute Summary → (get)

value : CxXmlDocBody

[not-null]
The summary section.

Returns the summary section.

Type​Parameters


[Constant]
public attribute TypeParameters → (get)

value : IVectorConst<CxXmlDocTypeParameter>

[not-null]
The typeparam sections.

Returns the typeparam sections.

Value


[Constant]
public attribute Value → (get)

value : CxXmlDocValue

The returns resp. value section.

Returns the returns resp. value section.

See also

CxMemberProperty