Language Specification Version 0 Notice


Processing the documentation file



Download 3.2 Mb.
Page82/85
Date29.01.2017
Size3.2 Mb.
#10878
1   ...   77   78   79   80   81   82   83   84   85

Processing the documentation file


The documentation generator generates an ID string for each element in the source code that is tagged with a documentation comment. This ID string uniquely identifies a source element. A documentation viewer can use an ID string to identify the corresponding metadata/reflection item to which the documentation applies.

The documentation file is not a hierarchical representation of the source code; rather, it is a flat list with a generated ID string for each element.


      1. ID string format


The documentation generator observes the following rules when it generates the ID strings:

  • No white space is placed in the string.

  • The first part of the string identifies the kind of member being documented, via a single character followed by a colon. The following kinds of members are defined:




Character

Description

E

Event

F

Field

M

Method (including constructors, destructors, and operators)

N

Namespace

P

Property (including indexers)

T

Type (such as class, delegate, enum, interface, and struct)

!

Error string; the rest of the string provides information about the error. For example, the documentation generator generates error information for links that cannot be resolved.




  • The second part of the string is the fully qualified name of the element, starting at the root of the namespace. The name of the element, its enclosing type(s), and namespace are separated by periods. If the name of the item itself has periods, they are replaced by # (U+0023) characters. (It is assumed that no element has this character in its name.)

  • For methods and properties with arguments, the argument list follows, enclosed in parentheses. For those without arguments, the parentheses are omitted. The arguments are separated by commas. The encoding of each argument is the same as a CLI signature, as follows:

    Arguments that represent generic types have an appended “’” character followed by the number of type parameters

    Arguments having the out or ref modifier have an @ following their type name. Arguments passed by value or via params have no special notation.

    Arguments that are arrays are represented as [ lowerbound : size , … , lowerbound : size ] where the number of commas is the rank less one, and the lower bounds and size of each dimension, if known, are represented in decimal. If a lower bound or size is not specified, it is omitted. If the lower bound and size for a particular dimension are omitted, the “:” is omitted as well. Jagged arrays are represented by one “[]” per level.

    Arguments that have pointer types other than void are represented using a * following the type name. A void pointer is represented using a type name of System.Void.

    Arguments that refer to generic type parameters defined on types are encoded using the “`” character followed by the zero-based index of the type parameter.

    Arguments that use generic type parameters defined in methods use a double-backtick “``” instead of the “`” used for types.

    Arguments that refer to constructed generic types are encoded using the generic type, followed by “{“, followed by a comma-separated list of type arguments, followed by “}”.

      1. ID string examples


The following examples each show a fragment of C# code, along with the ID string produced from each source element capable of having a documentation comment:

  • Types are represented using their fully qualified name, augmented with generic information:

enum Color { Red, Blue, Green }

namespace Acme


{
interface IProcess {...}

struct ValueType {...}

class Widget: IProcess
{
public class NestedClass {...}

public interface IMenuItem {...}

public delegate void Del(int i);

public enum Direction { North, South, East, West }


}

class MyList


{
class Helper {...}
}
}

"T:Color"


"T:Acme.IProcess"
"T:Acme.ValueType"
"T:Acme.Widget"
"T:Acme.Widget.NestedClass"
"T:Acme.Widget.IMenuItem"
"T:Acme.Widget.Del"
"T:Acme.Widget.Direction"
”T:Acme.MyList`1”
”T:Acme.MyList`1.Helper`2”

  • Fields are represented by their fully qualified name:

namespace Acme
{
struct ValueType
{
private int total;
}

class Widget: IProcess


{
public class NestedClass
{
private int value;
}

private string message;


private static Color defaultColor;
private const double PI = 3.14159;
protected readonly double monthlyAverage;
private long[] array1;
private Widget[,] array2;
private unsafe int *pCount;
private unsafe float **ppValues;
}
}

"F:Acme.ValueType.total"


"F:Acme.Widget.NestedClass.value"
"F:Acme.Widget.message"
"F:Acme.Widget.defaultColor"
"F:Acme.Widget.PI"
"F:Acme.Widget.monthlyAverage"
"F:Acme.Widget.array1"
"F:Acme.Widget.array2"
"F:Acme.Widget.pCount"
"F:Acme.Widget.ppValues"

  • Constructors.

namespace Acme
{
class Widget: IProcess
{
static Widget() {...}

public Widget() {...}

public Widget(string s) {...}
}
}

"M:Acme.Widget.#cctor"


"M:Acme.Widget.#ctor"
"M:Acme.Widget.#ctor(System.String)"

  • Destructors.

namespace Acme
{
class Widget: IProcess
{
~Widget() {...}
}
}

"M:Acme.Widget.Finalize"



  • Methods.

namespace Acme
{
struct ValueType
{
public void M(int i) {...}
}

class Widget: IProcess


{
public class NestedClass
{
public void M(int i) {...}
}

public static void M0() {...}


public void M1(char c, out float f, ref ValueType v) {...}
public void M2(short[] x1, int[,] x2, long[][] x3) {...}
public void M3(long[][] x3, Widget[][,,] x4) {...}
public unsafe void M4(char *pc, Color **pf) {...}
public unsafe void M5(void *pv, double *[][,] pd) {...}
public void M6(int i, params object[] args) {...}
}

class MyList


{
public void Test(T t) { }
}

class UseList


{
public void Process(MyList list) { }
public MyList GetValues(T inputValue) { return null; }
}
}

"M:Acme.ValueType.M(System.Int32)"


"M:Acme.Widget.NestedClass.M(System.Int32)"
"M:Acme.Widget.M0"
"M:Acme.Widget.M1(System.Char,System.Single@,Acme.ValueType@)"
"M:Acme.Widget.M2(System.Int16[],System.Int32[0:,0:],System.Int64[][])"
"M:Acme.Widget.M3(System.Int64[][],Acme.Widget[0:,0:,0:][])"
"M:Acme.Widget.M4(System.Char*,Color**)"
"M:Acme.Widget.M5(System.Void*,System.Double*[0:,0:][])"
"M:Acme.Widget.M6(System.Int32,System.Object[])"
”M:Acme.MyList`1.Test(`0)”
”M:Acme.UseList.Process(Acme.MyList{System.Int32})”
”M:Acme.UseList.GetValues``(``0)”

  • Properties and indexers.

namespace Acme
{
class Widget: IProcess
{
public int Width { get {...} set {...} }
public int this[int i] { get {...} set {...} }
public int this[string s, int i] { get {...} set {...} }
}
}

"P:Acme.Widget.Width"


"P:Acme.Widget.Item(System.Int32)"
"P:Acme.Widget.Item(System.String,System.Int32)"

  • Events.

namespace Acme
{
class Widget: IProcess
{
public event Del AnEvent;
}
}

"E:Acme.Widget.AnEvent"



  • Unary operators.

namespace Acme
{
class Widget: IProcess
{
public static Widget operator+(Widget x) {...}
}
}

"M:Acme.Widget.op_UnaryPlus(Acme.Widget)"

The complete set of unary operator function names used is as follows: op_UnaryPlus, op_UnaryNegation, op_LogicalNot, op_OnesComplement, op_Increment, op_Decrement, op_True, and op_False.


  • Binary operators.

namespace Acme
{
class Widget: IProcess
{
public static Widget operator+(Widget x1, Widget x2) {...}
}
}

"M:Acme.Widget.op_Addition(Acme.Widget,Acme.Widget)"

The complete set of binary operator function names used is as follows: op_Addition, op_Subtraction, op_Multiply, op_Division, op_Modulus, op_BitwiseAnd, op_BitwiseOr, op_ExclusiveOr, op_LeftShift, op_RightShift, op_Equality, op_Inequality, op_LessThan, op_LessThanOrEqual, op_GreaterThan, and op_GreaterThanOrEqual.


  • Conversion operators have a trailing “~” followed by the return type.

namespace Acme
{
class Widget: IProcess
{
public static explicit operator int(Widget x) {...}
public static implicit operator long(Widget x) {...}
}
}

"M:Acme.Widget.op_Explicit(Acme.Widget)~System.Int32"


"M:Acme.Widget.op_Implicit(Acme.Widget)~System.Int64"


    1. Download 3.2 Mb.

      Share with your friends:
1   ...   77   78   79   80   81   82   83   84   85




The database is protected by copyright ©ininet.org 2024
send message

    Main page