Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C-sharp language specification.2004.pdf
Скачиваний:
14
Добавлен:
23.08.2013
Размер:
2.55 Mб
Скачать

Annex E Documentation Comments

1/// <value>

2/// The point's x-coordinate.

3/// </value>

4public int X

5{

6

get { return x; }

7set { x = value; }

8}

9E.3 Processing the documentation file

10The following information is intended for C# implementations targeting the CLI.

11The documentation generator generates an ID string for each element in the source code that is tagged with a

12documentation comment. This ID string uniquely identifies a source element. A documentation viewer can

13use an ID string to identify the corresponding metadata/reflection item to which the documentation applies.

14The documentation file is not a hierarchical representation of the source code; rather, it is a flat list with a

15generated ID string for each element.

16E.3.1 ID string format

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

18No white space is placed in the string.

19The first part of the string identifies the kind of member being documented, via a single character

20followed by a colon. The following kinds of members are defined:

21

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.

 

 

22

23The second part of the string is the fully qualified name of the element, starting at the root of the

24namespace. The name of the element, its enclosing type(s), and namespace are separated by periods. If

25the name of the item itself has periods, they are replaced by the NUMBER SIGN # (U+0023). (It is

26assumed that no element has this character in its name.)

27For methods and properties with arguments, the argument list follows, enclosed in parentheses. For

28those without arguments, the parentheses are omitted. The arguments are separated by commas. The

29encoding of each argument is the same as a CLI signature, as follows: Arguments are represented by

30their fully qualified name. For example, int becomes System.Int32, string becomes

31System.String, object becomes System.Object, and so on. Arguments having the out or ref

32modifier have an @ following their type name. Arguments passed by value or via params have no

33special notation. Arguments that are arrays are represented as [ lowerbound : size , , lowerbound :

34size ] where the number of commas is the rank less one, and the lower bounds and size of each

35dimension, if known, are represented in decimal. If a lower bound or size is not specified, it is omitted.

36If the lower bound and size for a particular dimension are omitted, the “:” is omitted as well. Jagged

37arrays are represented by one “[]” per level. Arguments that have pointer types other than void are

519

C# LANGUAGE SPECIFICATION

1represented using a * following the type name. A void pointer is represented using a type name of

2System.Void.

3E.3.2 ID string examples

4The following examples each show a fragment of C# code, along with the ID string produced from each

5source element capable of having a documentation comment:

6Types are represented using their fully qualified name.

7enum Color { Red, Blue, Green }

8namespace Acme

9{

10

interface IProcess { … }

11

struct ValueType { … }

12

class Widget: IProcess

13

{

14

public class NestedClass { … }

15

public interface IMenuItem { … }

16

public delegate void Del(int i);

17

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

18}

19}

20"T:Color"

21"T:Acme.IProcess"

22"T:Acme.ValueType"

23"T:Acme.Widget"

24"T:Acme.Widget.NestedClass"

25"T:Acme.Widget.IMenuItem"

26"T:Acme.Widget.Del"

27"T:Acme.Widget.Direction"

28Fields are represented by their fully qualified name.

29namespace Acme

30{

31

struct ValueType

32

{

33

private int total;

34

}

35

class Widget: IProcess

36

{

37

public class NestedClass

38

{

39

private int value;

40

}

41

private string message;

42

private static Color defaultColor;

43

private const double PI = 3.14159;

44

protected readonly double monthlyAverage;

45

private long[] array1;

46

private Widget[,] array2;

47

private unsafe int *pCount;

48

private unsafe float **ppValues;

49}

50}

520

Annex E Documentation Comments

1"F:Acme.ValueType.total"

2"F:Acme.Widget.NestedClass.value"

3"F:Acme.Widget.message"

4"F:Acme.Widget.defaultColor"

5"F:Acme.Widget.PI"

6"F:Acme.Widget.monthlyAverage"

7"F:Acme.Widget.array1"

8"F:Acme.Widget.array2"

9"F:Acme.Widget.pCount"

10"F:Acme.Widget.ppValues"

11Constructors.

12namespace Acme

13{

14

class Widget: IProcess

15

{

16

static Widget() { … }

17

public Widget() { … }

18

public Widget(string s) { … }

19}

20}

21"M:Acme.Widget.#cctor"

22"M:Acme.Widget.#ctor"

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

24Destructors.

25namespace Acme

26{

27

class Widget: IProcess

28

{

29

~Widget() { … }

30}

31}

32"M:Acme.Widget.Finalize"

33Methods.

34namespace Acme

35{

36

struct ValueType

37

{

38

public void M(int i) { … }

39

}

40

class Widget: IProcess

41

{

42

public class NestedClass

43

{

44

public void M(int i) { … }

45

}

46

public static void M0() { … }

47

public void M1(char c, out float f, ref ValueType v) { … }

48

public void M2(short[] x1, int[,] x2, long[][] x3) { … }

49

public void M3(long[][] x3, Widget[][,,] x4) { … }

50

public unsafe void M4(char *pc, Color **pf) { … }

51

public unsafe void M5(void *pv, double *[][,] pd) { … }

52

public void M6(int i, params object[] args) { … }

53}

54}

521

C# LANGUAGE SPECIFICATION

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

2"M:Acme.Widget.NestedClass.M(System.Int32)"

3"M:Acme.Widget.M0"

4"M:Acme.Widget.M1(System.Char,System.Single@,Acme.ValueType@)"

5"M:Acme.Widget.M2(System.Int16[],System.Int32[0:,0:],System.Int64[][])"

6"M:Acme.Widget.M3(System.Int64[][],Acme.Widget[0:,0:,0:][])"

7"M:Acme.Widget.M4(System.Char*,Color**)"

8"M:Acme.Widget.M5(System.Void*,System.Double*[0:,0:][])"

9"M:Acme.Widget.M6(System.Int32,System.Object[])"

10Properties and indexers.

11namespace Acme

12{

13

class Widget: IProcess

14

{

15

public int Width {get { … } set { … }}

16

public int this[int i] {get { … } set { … }}

17

public int this[string s, int i] {get { … } set { … }}

18}

19}

20"P:Acme.Widget.Width"

21"P:Acme.Widget.Item(System.Int32)"

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

23Events

24namespace Acme

25{

26

class Widget: IProcess

27

{

28

public event Del AnEvent;

29}

30}

31"E:Acme.Widget.AnEvent"

32Unary operators.

33namespace Acme

34{

35

class Widget: IProcess

36

{

37

public static Widget operator+(Widget x) { … }

38}

39}

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

41The complete set of unary operator function names used is as follows: op_UnaryPlus,

42op_UnaryNegation, op_LogicalNot, op_OnesComplement, op_Increment,

43op_Decrement, op_True, and op_False.

44Binary operators.

45namespace Acme

46{

47

class Widget: IProcess

48

{

49

public static Widget operator+(Widget x1, Widget x2) { return x1; }

50}

51}

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

53The complete set of binary operator function names used is as follows: op_Addition,

54op_Subtraction, op_Multiply, op_Division, op_Modulus, op_BitwiseAnd,

55op_BitwiseOr, op_ExclusiveOr, op_LeftShift, op_RightShift, op_Equality,

56op_Inequality, op_LessThan, op_LessThanOrEqual, op_GreaterThan, and

57op_GreaterThanOrEqual.

522

Соседние файлы в предмете Электротехника