Note
ãã®ããŒãžã«ã¢ã¯ã»ã¹ããã«ã¯ãæ¿èªãå¿ èŠã§ãã ãµã€ã³ã€ã³ãŸãã¯ãã£ã¬ã¯ããªã®å€æŽã詊ãããšãã§ããŸãã
ãã®ããŒãžã«ã¢ã¯ã»ã¹ããã«ã¯ãæ¿èªãå¿ èŠã§ãã ãã£ã¬ã¯ããªã®å€æŽã詊ãããšãã§ããŸãã
æ¬ä»é²ã¯ãåèæ å ±ã§ãã
D.1 å šè¬
C# ã¯ãXML ããã¹ããå«ãã³ã¡ã³ãæ§æã䜿çšããã³ãŒããææžåããã¡ã«ããºã ãããã°ã©ããŒã«æäŸããŸãã ãœãŒã¹ ã³ãŒã ãã¡ã€ã«ã§ã¯ãç¹å®ã®åœ¢åŒã®ã³ã¡ã³ãã䜿çšããŠãããŒã«ã«ãã®ã³ã¡ã³ããšããã®ã³ã¡ã³ãã«å è¡ãããœãŒã¹ ã³ãŒãèŠçŽ ãã XML ãçæããããã«æç€ºã§ããŸãã ãã®ãããªæ§æã䜿çšããã³ã¡ã³ãã¯ãããã¥ã¡ã³ãã³ã¡ã³ããšåŒã°ããŠããŸãã ãããã¯ããŠãŒã¶ãŒå®çŸ©å (ã¯ã©ã¹ãããªã²ãŒããã€ã³ã¿ãŒãã§ã€ã¹ãªã©) ãŸãã¯ã¡ã³ã㌠(ãã£ãŒã«ããã€ãã³ããããããã£ãã¡ãœãããªã©) ã®çŽåã«é 眮ããå¿ èŠããããŸãã XML çæããŒã«ã¯ãããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒãšåŒã°ããŠããŸãã (ãã® Generator 㯠C# ã³ã³ãã€ã©ãŒèªäœã§ããå ŽåããããŸãããããã§ããå¿ èŠã¯ãããŸãã)ãããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒãçæããåºåã¯ãããã¥ã¡ã³ããã¡ã€ã«ãšåŒã°ããŠããŸãã ããã¥ã¡ã³ã ãã¡ã€ã«ã¯ãããã¥ã¡ã³ã ãã¥ãŒã¢ãžã®å ¥åãšããŠäœ¿çšãããŸããããã¥ã¡ã³ã ãã¥ãŒã¢ã¯ãåæ å ±ãšããã«é¢é£ããããã¥ã¡ã³ããäœããã®åœ¢ã§èŠèŠçã«è¡šç€ºããããã®ããŒã«ã§ãã
æºæ ãã C# ã³ã³ãã€ã©ã§ã¯ãããã¥ã¡ã³ã ã³ã¡ã³ãã®æ§æããã§ãã¯ããå¿ èŠã¯ãããŸããããã®ãããªã³ã¡ã³ãã¯åãªãéåžžã®ã³ã¡ã³ãã§ãã ãã ããæºæ ãã C# ã³ã³ãã€ã©ããã®ãããªç¢ºèªã¯å¯èœã§ãã
ãã®ä»æ§ã§ã¯ãããã¥ã¡ã³ã ã³ã¡ã³ãã§äœ¿çšããäžé£ã®æšæºã¿ã°ãææ¡ããŠããŸããããããã®ã¿ã°ã®äœ¿çšã¯å¿ é ã§ã¯ãªããæŽåœ¢åŒã® XML ã®ã«ãŒã«ã«åŸã£ãŠããéããå¿ èŠã«å¿ããŠä»ã®ã¿ã°ã䜿çšããããšãã§ããŸãã CLI ã察象ãšãã C# å®è£ ã®å Žåãããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒãšããã¥ã¡ã³ã ãã¡ã€ã«ã®åœ¢åŒã«é¢ããæ å ±ãæäŸãããŸãã ããã¥ã¡ã³ã ãã¥ãŒã¢ãŒã«é¢ããæ å ±ã¯æäŸãããŠããŸããã
D.2 æŠèŠ
ç¹å®ã®åœ¢åŒã®ã³ã¡ã³ãã䜿çšãããšãããŒã«ã«ãã®ã³ã¡ã³ããšããã«å
è¡ãããœãŒã¹ ã³ãŒãèŠçŽ ãã XML ãçæããããã«æç€ºã§ããŸãã 該åœããã³ã¡ã³ããšããŠã3 ã€ã®ã¹ã©ãã·ã¥ () ããå§ãŸã Single_Line_Comment (///) ãã2 ã€ã®ã¢ã¹ã¿ãªã¹ã¯ () ããå§ãŸã Delimited_Comment (/**) ãªã©ãæããããŸãã ãããã¯ã泚éãä»ãããŠãŒã¶ãŒå®çŸ©åãŸãã¯ã¡ã³ããŒã®çŽåã«é
眮ããå¿
èŠããããŸãã 屿§ã»ã¯ã·ã§ã³ (§23.3) ã¯å®£èšã®äžéšãšèŠãªããããããããã¥ã¡ã³ãã³ã¡ã³ãã¯åãŸãã¯ã¡ã³ããŒã«é©çšããã屿§ã®åã«èšè¿°ããå¿
èŠããããŸãã
説æã®ç®çã§ã2 ã€ã®ææ³èŠåãšããŠããã¥ã¡ã³ã ã³ã¡ã³ãã®åœ¢åŒã次ã«ç€ºããŸã: Single_Line_Doc_Comment ããã³ Delimited_Doc_Commentã ãã ãããããã®èŠåã¯ãC# ææ³ã®äžéšã§ã¯ãªãããããã Single_Line_Comment ããã³ Delimited_Comment Lexer èŠåã®ç¹å®ã®åœ¢åŒã衚ããŠããŸãã
æ§æ :
Single_Line_Doc_Comment
: '///' Input_Character*
;
Delimited_Doc_Comment
: '/**' Delimited_Comment_Section* ASTERISK+ '/'
;
Single_Line_Doc_Comment ã§ã¯ãSingle_Line_Doc_Comment ã«é£æ¥ãã /// ã® æåã®åŸã«ãã¯ã€ãã¹ããŒã¹æåãããå Žåããã®ãã¯ã€ãã¹ããŒã¹æå㯠XML åºåã«å«ãŸããŸããã
Delimited_Doc_Comment ã§ã2 è¡ç®ã®æåã®ãã¯ã€ãã¹ããŒã¹ä»¥å€ã®æåãã¢ã¹ã¿ãªã¹ã¯ã§ãä»»æã®ãã¯ã€ãã¹ããŒã¹æåãšåããã¿ãŒã³ã§ãã¢ã¹ã¿ãªã¹ã¯æåããDelimited_Doc_Comment å ã®åè¡ã®æåã§ç¹°ãè¿ãããŠããå Žåãç¹°ãè¿ãããŠãããã¿ãŒã³ã®æåã¯ãXML åºåã«å«ãŸããŸããã ãã¿ãŒã³ã«ã¯ãã¢ã¹ã¿ãªã¹ã¯æåã®åã ãã§ãªãåŸãã«ã ãã¯ã€ãã¹ããŒã¹æåãå«ããããšãã§ããŸãã
äŸ:
/// <summary>
/// Class <c>Point</c> models a point in a two-dimensional plane.
/// </summary>
public class Point
{
/// <summary>
/// Method <c>Draw</c> renders the point.
/// </summary>
void Draw() {...}
}
ããã¥ã¡ã³ãã³ã¡ã³ãå ã®ããã¹ãã¯ãXML ã®èŠåã«åŸã£ãŠæŽåœ¢åŒã§ããå¿ èŠããããŸã (http://www.w3.org/TR/REC-xml)ã XML ã®åœ¢åŒãæ£ãããªãå Žåã¯èŠåãçæãããããã¥ã¡ã³ã ãã¡ã€ã«ã«ã¯ãšã©ãŒãçºçããããšã瀺ãã³ã¡ã³ããå«ãŸããŸãã
éçºè ã¯ç¬èªã®ã¿ã°ã»ãããèªç±ã«äœæã§ããŸãããæšå¥šãããã»ãã㯠§D.3 ã§å®çŸ©ãããŠããŸãã æšå¥šãããã¿ã°ã®äžéšã«ã¯ç¹å¥ãªæå³ããããŸãã
<param>ã¿ã°ã¯ããã©ã¡ãŒã¿ãŒã®èšè¿°ã«äœ¿çšããŸãã ãã®ãããªã¿ã°ã䜿çšãããå Žåãããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ãæå®ããããã©ã¡ãŒã¿ãŒãååšãããã¹ãŠã®ãã©ã¡ãŒã¿ãŒãããã¥ã¡ã³ã ã³ã¡ã³ãã«èšè¿°ãããŠããããšã確èªããå¿ èŠããããŸãã ãã®ãããªæ€èšŒã倱æããå Žåãããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯èŠåã衚瀺ããŸããcref屿§ã¯ä»»æã®ã¿ã°ã«ã¢ã¿ããã§ããã³ãŒãèŠçŽ ãžã®åç §ãæäŸããŸãã ããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ããã®ã³ãŒãèŠçŽ ãååšããããšã確èªããå¿ èŠããããŸãã ãã®ãããªæ€èšŒã倱æããå Žåãããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯èŠåã衚瀺ããŸããcref屿§ã«èšè¿°ãããååãæ€çŽ¢ããå Žåãããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ããœãŒã¹ ã³ãŒãå ã«è¡šç€ºãããã¹ããŒãã¡ã³ãã䜿çšããŠãåå空éã®å¯èŠæ§ãå°éããå¿ èŠããããŸãã æ±çšçãªã³ãŒãèŠçŽ ã®å Žåãç¡å¹ãª XML ãçæããããããList<T>ãªã©ã®éåžžã®æ±çšæ§æã¯äœ¿çšã§ããŸããã è§æ¬åŒ§ã®ä»£ããã«äžæ¬åŒ§ã䜿çšããããšãã§ããŸã (äŸ:List{T})ããŸããXML ãšã¹ã±ãŒãæ§æã䜿çšããããšãã§ããŸã (äŸ:List<T>)ã<summary>ã¿ã°ã¯ãããã¥ã¡ã³ã ãã¥ãŒã¢ã§åãŸãã¯ã¡ã³ããŒã«é¢ããè¿œå æ å ±ã衚瀺ããããã«äœ¿çšããããšãç®çãšããŠããŸãã<include>ã¿ã°ã«ã¯ãå€éš XML ãã¡ã€ã«ããã®æ å ±ãå«ãŸããŸãã
ããã¥ã¡ã³ã ãã¡ã€ã«ã§ã¯ãåãšã¡ã³ããŒã«é¢ããå®å šãªæ å ±ãæäŸãããªãããšã«æ³šæããŠãã ãã (ããšãã°ãåã®æ å ±ã¯å«ãŸããŸãã)ã åãŸãã¯ã¡ã³ããŒã«é¢ãããã®ãããªæ å ±ãååŸããã«ã¯ãåãŸãã¯ã¡ã³ããŒã®ãªãã¬ã¯ã·ã§ã³ãšçµã¿åãããŠããã¥ã¡ã³ã ãã¡ã€ã«ã䜿çšããå¿ èŠããããŸãã
éšååãéšåã¡ãœãããéšåããããã£ããŸãã¯éšåã€ã³ãã¯ãµãŒã¯è€æ°ã®éšåã§å®£èšã§ããŸããåéšå㯠1 ã€ä»¥äžã®ã³ã³ãã€ã« åäœã«ããããšãã§ããããããã®éšåã«ã¯ 1 ã€ä»¥äžã®ããã¥ã¡ã³ã ã³ã¡ã³ããå«ããããšãã§ããŸãã éšåã¡ãœãããéšåããããã£ããŸãã¯éšåã€ã³ãã¯ãµãŒã«ã¯ãéåžžã"éšå宣èšã®å®çŸ©" ãš "éšå宣èšã®å®è£ " ããããŸãã
éšååã®å Žåããã®åã«çŽæ¥é©çšãããããã¥ã¡ã³ã ã³ã¡ã³ãã¯ããã®åéšåããããã¹ãŠäžç¹å®ã®é åºã§ããã¥ã¡ã³ã ãã¡ã€ã«ã«æžã蟌ãŸããŸãã
éšåã¡ãœãããéšåããããã£ããŸãã¯éšåã€ã³ãã¯ãµãŒã®å Žå:
- å®çŸ©éšå宣èšã«å¯Ÿå¿ããå®è£ éšå宣èšããªãå Žåããã®å®çŸ©éšå宣èšå ã®ãã¹ãŠã®ããã¥ã¡ã³ã ã³ã¡ã³ãã¯ç¡èŠãããŸã (ãã®å®£èšã¯åé€ããããã)ã
- ãã以å€ã®å Žåãå®è£ éšå宣èšã«ããã¥ã¡ã³ã ã³ã¡ã³ããããå Žåã¯ãããããããã¥ã¡ã³ã ãã¡ã€ã«ã«æžã蟌ãŸããå®çŸ©éšå宣èšå ã®ããã¥ã¡ã³ã ã³ã¡ã³ãã¯ç¡èŠãããŸãã
- ãã以å€ã®å Žåãå®çŸ©éšå宣èšå ã®ãã¹ãŠã®ããã¥ã¡ã³ã ã³ã¡ã³ããããã¥ã¡ã³ã ãã¡ã€ã«ã«æžã蟌ãŸããŸãã
D.3 æšå¥šã¿ã°
D.3.1 å šè¬
ããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ãXML ã®ã«ãŒã«ã«åŸã£ãŠæå¹ãªã¿ã°ããã¹ãŠåãå ¥ããŠåŠçããå¿ èŠããããŸãã æ¬¡ã®ã¿ã°ã«ãã£ãŠããŠãŒã¶ãŒ ããã¥ã¡ã³ãã§äžè¬çã«äœ¿çšãããæ©èœãäžããããŸãã (ãã¡ãããä»ã®ã¿ã°ãå¯èœã§ã)ã
| ã¿ã° | é¢é£åç § | ç®ç |
|---|---|---|
<c> |
§D.3.2 | ã³ãŒãã®ãããªãã©ã³ãã§ããã¹ããèšå®ãã |
<code> |
§D.3.3 | 1 è¡ä»¥äžã®ãœãŒã¹ ã³ãŒããŸãã¯ããã°ã©ã åºåãèšå®ãã |
<example> |
§D.3.4 | äŸã瀺ã |
<exception> |
§D.3.5 | ã¡ãœãããã¹ããŒã§ããäŸå€ãèå¥ãã |
<include> |
§D.3.6 | å€éšãã¡ã€ã«ããã® XML ãå«ãã |
<list> |
§D.3.7 | ãªã¹ããããŒãã«ãäœæãã |
<para> |
§D.3.8 | ããã¹ãã«æ§é ã远å ã§ããããã«ãã |
<param> |
§D.3.9 | ã¡ãœãããŸãã¯ã³ã³ã¹ãã©ã¯ã¿ã®ãã©ã¡ãŒã¿ãŒãèšè¿°ãã |
<paramref> |
§D.3.10 | åèªããã©ã¡ãŒã¿åã§ããããšãèå¥ãã |
<permission> |
§D.3.11 | ã¡ã³ããŒã®ã»ãã¥ãªã㣠ã¢ã¯ã»ã¹ãææžåãã |
<remarks> |
§D.3.12 | åã«é¢ããè¿œå æ å ±ãèšè¿°ãã |
<returns> |
§D.3.13 | ã¡ãœããã®æ»ãå€ãèšè¿°ãã |
<see> |
§D.3.14 | ãªã³ã¯ãæå®ãã |
<seealso> |
§D.3.15 | See Also ãšã³ããªãçæãã |
<summary> |
§D.3.16 | åãŸãã¯ã¡ã³ããŒã®åãèšè¿°ãã |
<typeparam> |
§D.3.17 | ãžã§ããªãã¯åãŸãã¯ã¡ã³ããŒã®åãã©ã¡ãŒã¿ãèšè¿°ãã |
<typeparamref> |
§D.3.18 | åèªãåãã©ã¡ãŒã¿åã§ããããšãèå¥ãã |
<value> |
§D.3.19 | ããããã£ãèšè¿°ãã |
D.3.2 <c>
ãã®ã¿ã°ã¯ã説æå
ã®ããã¹ãã®äžéšããã³ãŒã ãããã¯ã«äœ¿çšããããããªç¹æ®ãªãã©ã³ãã§èšå®ããå¿
èŠãããããšã瀺ãã¡ã«ããºã ãæäŸããŸãã å®éã®ã³ãŒãã®è¡ã«ã¯ã<code> (§D.3.3) ã䜿çšããŸãã
æ§æ :
<c>
ããã¹ã</c>
äŸ:
/// <summary>
/// Class <c>Point</c> models a point in a two-dimensional plane.
/// </summary>
public class Point
{
}
D.3.3 <ã³ãŒã>
ãã®ã¿ã°ã¯ããœãŒã¹ ã³ãŒããŸãã¯ããã°ã©ã åºåã® 1 è¡ä»¥äžãç¹æ®ãªãã©ã³ãã§èšå®ããããã«äœ¿çšãããŸãã ãã©ãã£ãã®å°ããªã³ãŒãæçã®å Žåã¯ã<c> (§D.3.2) ã䜿çšããŸãã
æ§æ :
<code>
source code ãŸã㯠program output</code>
äŸ:
public class Point
{
/// <summary>
/// This method changes the point's location by the given x- and y-offsets.
/// <example>
/// For example:
/// <code>
/// Point p = new Point(3,5);
/// p.Translate(-1,3);
/// </code>
/// results in <c>p</c>'s having the value (2,8).
/// </example>
/// </summary>
public void Translate(int dx, int dy)
{
...
}
}
D.3.4 <äŸ>
ãã®ã¿ã°ã䜿çšãããšãã³ã¡ã³ãå
ã«ãµã³ãã« ã³ãŒããæ¿å
¥ããŠãã¡ãœããããã®ä»ã®ã©ã€ãã©ãª ã¡ã³ããŒã®äœ¿ç𿹿³ãæå®ã§ããŸãã ããã«ã¯éåžžãã¿ã° <code> (§D.3.3) ã®äœ¿çšãå«ãŸããŸãã
æ§æ :
<example>
圢容</example>
äŸ:
äŸã«ã€ããŠã¯ã<code> (§D.3.3) ãåç
§ããŠãã ããã
D.3.5 <äŸå€>
ãã®ã¿ã°ã¯ãã¡ãœãããã¹ããŒããäŸå€ãææžåããæ¹æ³ãæäŸããŸãã
æ§æ :
<exception cref="
ã¡ã³ããŒ">圢容</exception>
ã©ã
-
cref="member"ã¯ãã¡ã³ããŒåã§ãã ããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ãæå®ã¡ã³ããŒãæ¢åããŠãããã確èªããããã¥ã¡ã³ã ãã¡ã€ã«ã§ member ã Canonical èŠçŽ åã«å€æããŸãã - description ã¯ãäŸå€ãã¹ããŒãããç¶æ³ã®èª¬æã§ãã
äŸ:
class PrimaryFileFormatCorruptException : System.Exception { ... }
class PrimaryFileLockedOpenException : System.Exception { ... }
public class DataBaseOperations
{
/// <exception cref="PrimaryFileFormatCorruptException">
/// Thrown when the primary file is corrupted.
/// </exception>
/// <exception cref="PrimaryFileLockedOpenException">
/// Thrown when the primary file is already open.
/// </exception>
public static void ReadRecord(int flag)
{
if (flag == 1)
{
throw new PrimaryFileFormatCorruptException();
}
else if (flag == 2)
{
throw new PrimaryFileLockedOpenException();
}
...
}
}
D.3.6 <ã€ã³ã¯ã«ãŒã>
ãã®ã¿ã°ã䜿çšãããšããœãŒã¹ ã³ãŒã ãã¡ã€ã«ã®å€éšã«ãã XML ããã¥ã¡ã³ãããã®æ
å ±ãå«ããããšãã§ããŸãã å€éšãã¡ã€ã«ã¯æ£ãã圢åŒã® XML ããã¥ã¡ã³ãã§ããå¿
èŠãããããã®ããã¥ã¡ã³ãã« XPath åŒãé©çšããããã®ããã¥ã¡ã³ãããã©ã® XML ãå«ããããæå®ãããŸãã
<include> ã¿ã°ã¯ããã®åŸå€éšããã¥ã¡ã³ãããéžæããã XML ã«çœ®ãæããããŸãã
æ§æ:
<include file="
ãã¡ã€ã«å" path="XPath" />
ã©ã
-
file="filename"ã¯ãå€éš XML ãã¡ã€ã«ã®ãã¡ã€ã«åã§ãã ãã¡ã€ã«åã¯ãinclude ã¿ã°ãå«ããã¡ã€ã«ã«å¯ŸããŠçžå¯Ÿçã«è§£éãããŸãã -
path="xpath"ã¯ãå€éš XML ãã¡ã€ã«ã®äžéšã® XML ãéžæãã XPath åŒã§ãã
äŸ:
ãœãŒã¹ ã³ãŒãã«æ¬¡ã®ãããªå®£èšãªã³ã¯ãå«ãŸããŠããå Žå:
/// <include file="docs.xml" path='extradoc/class[@name="IntList"]/*' />
public class IntList { ... }
å€éšãã¡ã€ã«ãdocs.xmlãã®å å®¹ã¯æ¬¡ã®ããã«ãªããŸã:
<?xml version="1.0"?>
<extradoc>
<class name="IntList">
<summary>
Contains a list of integers.
</summary>
</class>
<class name="StringList">
<summary>
Contains a list of strings.
</summary>
</class>
</extradoc>
ãœãŒã¹ã³ãŒãã«æ¬¡ã®å 容ãå«ãŸããŠããå Žåãšåãããã¥ã¡ã³ããåºåãããŸã:
/// <summary>
/// Contains a list of integers.
/// </summary>
public class IntList { ... }
D.3.7 <äžèЧ>
ãã®ã¿ã°ã¯ãé
ç®ã®ãªã¹ããããŒãã«ãäœæããããã«äœ¿çšããŸãã ããŒãã«ãŸãã¯å®çŸ©ãªã¹ãã®èŠåºãè¡ãå®çŸ©ãã <listheader> ãããã¯ãå«ãŸããŸãã (ããŒãã«ãå®çŸ©ãããšãã®ã¿ãèŠåºãã® term ã®å
¥åãæå®ããå¿
èŠããããŸã)ã
ãªã¹ãã®åé
ç®ã¯ã<item> ãããã¯ã§æå®ãããŸãã å®çŸ©ãäœæããéã¯ãterm ãš description ãæå®ããå¿
èŠããããŸãã ãã ããããŒãã«ãç®æ¡æžããªã¹ããŸãã¯çªå·ä»ããªã¹ãã®å Žåã¯ãdescription ã®ã¿æå®ããå¿
èŠããããŸãã
æ§æ :
<list type="bullet" | "number" | "table">
<listheader>
<term>term</term>
<description>description</description>
</listheader>
<item>
<term>term</term>
<description>description</description>
</item>
...
<item>
<term>term</term>
<description>description</description>
</item>
</list>
ã©ã
- term ã¯ãå®çŸ©ããçšèªã§ããã®å®çŸ©ã¯ãdescription ã«ãããŸãã
- description ç®æ¡æžããªã¹ããŸãã¯çªå·ä»ããªã¹ãã®é ç®ãŸãã¯ãterm ã®å®çŸ©ã®ããããã§ãã
äŸ:
public class MyClass
{
/// <summary>Here is an example of a bulleted list:
/// <list type="bullet">
/// <item>
/// <description>Item 1.</description>
/// </item>
/// <item>
/// <description>Item 2.</description>
/// </item>
/// </list>
/// </summary>
public static void Main()
{
...
}
}
D.3.8 <ãã©>
ãã®ã¿ã°ã¯ã<summary> (§D.3.16) ã <returns> (§D.3.13) ãªã©ã®å¥ã®ã¿ã°å
ã§äœ¿çšããããã¹ãã«æ§é ã远å ã§ããããã«ããŸãã
æ§æ :
<para>
ã³ã³ãã³ã</para>
ã©ã
- content ã¯ã段èœã®ããã¹ãã§ãã
äŸ:
public class Point
{
/// <summary>This is the entry point of the Point class testing program.
/// <para>
/// This program tests each method and operator, and
/// is intended to be run after any non-trivial maintenance has
/// been performed on the Point class.
/// </para>
/// </summary>
public static void Main()
{
...
}
}
D.3.9 <ãã©ã¡ãŒã¿>
ãã®ã¿ã°ã¯ãã¡ãœãããã³ã³ãã©ã¯ã¿ãã€ã³ãã¯ãµã®ãã©ã¡ãŒã¿ã説æããããã«äœ¿çšããŸãã
æ§æ :
<param name="
åå">圢容</param>
ã©ã
- name ã¯ããã©ã¡ãŒã¿ãŒã®ååã§ãã
- description ã¯ããã©ã¡ãŒã¿ã®èª¬æã§ãã
äŸ:
public class Point
{
/// <summary>
/// This method changes the point's location to
/// the given coordinates.
/// </summary>
/// <param name="xPosition">the new x-coordinate.</param>
/// <param name="yPosition">the new y-coordinate.</param>
public void Move(int xPosition, int yPosition)
{
...
}
}
D.3.10 <paramref>
ãã®ã¿ã°ã¯ãåèªããã©ã¡ãŒã¿ã§ããããšã瀺ãããã«äœ¿çšããŸãã ããã¥ã¡ã³ã ãã¡ã€ã«ãåŠçããããšã§ãããã€ãã®ç¬èªã®æ¹æ³ã§ãã®ãã©ã¡ãŒã¿ãŒã®æžåŒèšå®ãè¡ãããšãã§ããŸãã
æ§æ :
<paramref name="
åå"/>
ã©ã
- name ã¯ããã©ã¡ãŒã¿ãŒã®ååã§ãã
äŸ:
public class Point
{
/// <summary>This constructor initializes the new Point to
/// (<paramref name="xPosition"/>,<paramref name="yPosition"/>).
/// </summary>
/// <param name="xPosition">the new Point's x-coordinate.</param>
/// <param name="yPosition">the new Point's y-coordinate.</param>
public Point(int xPosition, int yPosition)
{
...
}
}
D.3.11 <èš±å¯>
ãã®ã¿ã°ã¯ãææžåããã¡ã³ããŒã®ã»ãã¥ãªã㣠ã¢ã¯ã»ã·ããªãã£ãèš±å¯ããŸãã
æ§æ :
<permission cref="
ã¡ã³ããŒ">圢容</permission>
ã©ã
- member ã¯ãã¡ã³ããŒåã§ãã ããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ãæå®ã³ãŒãèŠçŽ ãæ¢åããŠãããã確èªããããã¥ã¡ã³ã ãã¡ã€ã«ã§ member ã Canonical èŠçŽ åã«å€æããŸãã
- description ã¡ã³ããŒãžã®ã¢ã¯ã»ã¹ã«é¢ãã説æã§ãã
äŸ:
public class MyClass
{
/// <permission cref="System.Security.PermissionSet">
/// Everyone can access this method.
/// </permission>
public static void Test()
{
...
}
}
D.3.12 <åè>
ãã®ã¿ã°ã¯ãåã«é¢ããè¿œå æ
å ±ãæå®ããããã«äœ¿çšããŸãã
<summary> (§D.3.16) ã䜿çšããŠãåèªäœããã³åã®ã¡ã³ããŒã説æããŸãã
æ§æ :
<remarks>
圢容</remarks>
ã©ã
- description ã¯ãåèã®ããã¹ãã§ãã
äŸ:
/// <summary>
/// Class <c>Point</c> models a point in a two-dimensional plane.
/// </summary>
/// <remarks>
/// Uses polar coordinates
/// </remarks>
public class Point
{
...
}
D.3.13 <æ»ãå€>
ãã®ã¿ã°ã¯ãã¡ãœããã®æ»ãå€ã説æããããã«äœ¿çšããŸãã
æ§æ :
<returns>
圢容</returns>
ã©ã
- description ã¯ãæ»ãå€ã®èª¬æã§ãã
äŸ:
public class Point
{
/// <summary>
/// Report a point's location as a string.
/// </summary>
/// <returns>
/// A string representing a point's location, in the form (x,y),
/// without any leading, trailing, or embedded whitespace.
/// </returns>
public override string ToString() => $"({X},{Y})";
public int X { get; set; }
public int Y { get; set; }
}
D.3.14 <åç §>
ãã®ã¿ã°ã¯ãããã¹ãå
ã§ãªã³ã¯ãæå®ããããšãèš±å¯ããŸãã
<seealso> (§D.3.15) ã䜿çšããŠãSee Also ãµãå¥ã§è¡šç€ºããããã¹ãã瀺ããŸãã
æ§æ :
<see cref="
ã¡ã³ããŒ" href="URLã§ã" langword="ããŒã¯ãŒã" />
ã©ã
- member ã¯ãã¡ã³ããŒåã§ãã ããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ãæå®ã³ãŒãèŠçŽ ãæ¢åããŠãããã確èªããçæãããããã¥ã¡ã³ã ãã¡ã€ã«ã§ member ãèŠçŽ åã«å€æŽããŸãã
- url ã¯ãå€éšãœãŒã¹ãžã®åç §ã§ãã
- langword ã¯äœããã®åœ¢ã§åŒ·èª¿è¡šç€ºããåèªã§ãã
äŸ:
public class Point
{
/// <summary>
/// This method changes the point's location to
/// the given coordinates. <see cref="Translate"/>
/// </summary>
public void Move(int xPosition, int yPosition)
{
...
}
/// <summary>This method changes the point's location by
/// the given x- and y-offsets. <see cref="Move"/>
/// </summary>
public void Translate(int dx, int dy)
{
...
}
}
D.3.15 <é¢é£é ç®>
ãã®ã¿ã°ã䜿çšãããšãSee Also ãµãå¥ã«å¯ŸããŠçæããããšã³ããªãèš±å¯ããŸãã
<see> (§D.3.14) 䜿çšããŠãããã¹ãå
ã§ãªã³ã¯ãæå®ããŸãã
æ§æ :
<seealso cref="
ã¡ã³ããŒ" href="é¢é£URL" />
ã©ã
- member ã¯ãã¡ã³ããŒåã§ãã ããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ãæå®ã³ãŒãèŠçŽ ãæ¢åããŠãããã確èªããçæãããããã¥ã¡ã³ã ãã¡ã€ã«ã§ member ãèŠçŽ åã«å€æŽããŸãã
- url ã¯ãå€éšãœãŒã¹ãžã®åç §ã§ãã
äŸ:
public class Point
{
/// <summary>
/// This method determines whether two Points have the same location.
/// </summary>
/// <seealso cref="operator=="/>
/// <seealso cref="operator!="/>
public override bool Equals(object o)
{
...
}
}
D.3.16 <æŠèŠ>
ãã®ã¿ã°ã¯ãåãŸãã¯åã¡ã³ããŒã説æããããã«äœ¿çšããŸãã
<remarks> (§D.3.12) ã䜿çšããŠåãŸãã¯ã¡ã³ããŒã®è¿œå æ
å ±ãæå®ããŸãã
æ§æ :
<summary>
圢容</summary>
ã©ã
- description ã¯ãåãŸãã¯ã¡ã³ããŒã®æŠèŠã§ãã
äŸ:
public class Point
{
/// <summary>
/// This constructor initializes the new Point to
/// (<paramref name="xPosition"/>,<paramref name="yPosition"/>).
/// </summary>
public Point(int xPosition, int yPosition)
{
...
}
/// <summary>This constructor initializes the new Point to (0,0).</summary>
public Point() : this(0, 0)
{
}
}
D.3.17 <ã¿ã€ããã©ã¡ãŒã¿>
ãã®ã¿ã°ã¯ããžã§ããªãã¯åãŸãã¯ã¡ãœããã®åãã©ã¡ãŒã¿ã説æããããã«äœ¿çšããŸãã
æ§æ :
<typeparam name="
åå">圢容</typeparam>
ã©ã
- name ã¯ãåãã©ã¡ãŒã¿ãŒã®ååã§ãã
- description ã¯ãåãã©ã¡ãŒã¿ã®èª¬æã§ãã
äŸ:
/// <summary>A generic list class.</summary>
/// <typeparam name="T">The type stored by the list.</typeparam>
public class MyList<T>
{
...
}
D.3.18 <åãã©ã¡ãŒã¿åç §>
ãã®ã¿ã°ã¯ãåèªãåãã©ã¡ãŒã¿ã§ããããšã瀺ãããã«äœ¿çšããŸãã ããã¥ã¡ã³ã ãã¡ã€ã«ãåŠçããããšã§ãããã€ãã®ç¬èªã®æ¹æ³ã§ãã®åãã©ã¡ãŒã¿ãŒã®æžåŒèšå®ãè¡ãããšãã§ããŸãã
æ§æ :
<typeparamref name="
åå"/>
ã©ã
- name ã¯ãåãã©ã¡ãŒã¿ãŒã®ååã§ãã
äŸ:
public class MyClass
{
/// <summary>
/// This method fetches data and returns a list of
/// <typeparamref name="T"/>.
/// </summary>
/// <param name="query">query to execute</param>
public List<T> FetchData<T>(string query)
{
...
}
}
D.3.19 <å€>
ãã®ã¿ã°ã䜿çšãããšãããããã£ãèšè¿°ã§ããŸãã
æ§æ :
<value>
ç©ä»¶ã®èª¬æ</value>
ã©ã
- property description ã¯ãããããã£ã®èª¬æã§ãã
äŸ:
public class Point
{
/// <value>Property <c>X</c> represents the point's x-coordinate.</value>
public int X { get; set; }
}
D.4 ããã¥ã¡ã³ã ãã¡ã€ã«ã®åŠç
D.4.1 å šè¬
以äžã®æ å ±ã¯ãCLI ã察象ãšãã C# å®è£ ã察象ãšããŠããŸãã
ããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ãããã¥ã¡ã³ã ã³ã¡ã³ãã§ã¿ã°ä»ãããããœãŒã¹ ã³ãŒãå ã®åèŠçŽ ã«å¯Ÿã㊠ID æååãçæããŸãã ãã® ID æååã¯ãœãŒã¹èŠçŽ ãäžæã«èå¥ããŸãã ããã¥ã¡ã³ã ãã¥ãŒã¢ã¯ãID æååã䜿çšããŠãããã¥ã¡ã³ããé©çšããã察å¿ããé ç®ãèå¥ã§ããŸãã
ããã¥ã¡ã³ã ãã¡ã€ã«ã¯ããœãŒã¹ ã³ãŒãã®éå±€çãªè¡šçŸã§ã¯ãªããåèŠçŽ ã«å¯ŸããŠçæããã ID æååãå«ããã©ãããªãªã¹ãã§ãã
D.4.2 ID æåå圢åŒ
ããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯ã次ã®èŠåã«åºã¥ã㊠ID æååãçæããŸãã
æååã«ç©ºçœã¯é 眮ãããŸããã
æååã®æåã®éšåã¯ãåäžã®æåãšããã«ç¶ãã³ãã³ã«ãã£ãŠãææžåãããŠããã¡ã³ããŒã®çš®é¡ãèå¥ããŸãã æ¬¡ã®çš®é¡ã®ã¡ã³ããŒãå®çŸ©ãããŠããŸãã
æå 説æ E ã€ãã³ã F ãã£ãŒã«ã ãšã ã¡ãœãã (ã³ã³ã¹ãã©ã¯ã¿ããã¡ã€ãã©ã€ã¶ããªãã¬ãŒã¿ãå«ã) N åå空é P ãããã㣠(ã€ã³ãã¯ãµãå«ã) T å (ã¯ã©ã¹ãããªã²ãŒããåæãã€ã³ã¿ãŒãã§ã€ã¹ãæ§é äœãªã©) ! ãšã©ãŒæååãæååã®æ®ãã®éšåã¯ãšã©ãŒã«é¢ããæ å ±ãæäŸããŸãã ããšãã°ãããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ãŒã¯è§£æ±ºã§ããªããªã³ã¯ã®ãšã©ãŒæ å ±ãçæããŸãã æååã® 2 çªç®ã®éšåã¯ãèŠçŽ ã®å®å šä¿®é£Ÿåã§ãåå空éã®ã«ãŒãããå§ãŸããŸãã èŠçŽ ã®ååããããå²ãåãåå空éã¯ããªãªãã§åºåãããŸãã é ç®ã®ååèªäœã«ããªãªããããå Žåã# (U+0023) æåã§çœ®ãæããããŸãã (èŠçŽ åã«ãã®æåãå«ãŸããªãããšãåæãšãªããŸãã) å®å šä¿®é£Ÿåã®ååŒæ°ã¯ãã¡ã³ããŒããžã§ããªã㯠ã€ã³ã¿ãŒãã§ã€ã¹ã®ã¡ã³ããŒãæç€ºçã«å®è£ ããå Žåãããããå²ãã
<ããšã>ããã{ããšã}ãã®æåã«çœ®ãæããããšã«ãã£ãŠãšã³ã³ãŒããããŸããåŒæ°ãæã€ã¡ãœãããšããããã£ã®å Žåã¯ãæ¬åŒ§ã§å²ãŸããåŒæ°ãªã¹ããç¶ããŸãã åŒæ°ããªãå Žåã¯ãæ¬åŒ§ã¯çç¥ãããŸãã åŒæ°ã¯ã³ã³ãã§åºåãããŸãã ååŒæ°ã®ãšã³ã³ãŒãã¯ã次ã®ããã« CLI 眲åãšåãã§ãã
- åŒæ°ã¯ã次ã®ããã«å€æŽãããå®å
šä¿®é£Ÿåã«åºã¥ããããã¥ã¡ã³ãåã§è¡šãããŸãã
- ãžã§ããªãã¯åã衚ãåŒæ°ã«ã¯ã
'ãæåãä»å ããããã®åŸã«åãã©ã¡ãŒã¿ã®æ°ãç¶ããŸãã -
inãoutãŸãã¯ref修食åãããåŒæ°ã«ã¯ãååã®åŸã«@ãç¶ããŸãã å€ãŸãã¯paramsçµç±ã§æž¡ãããåŒæ°ã«ã¯ç¹å¥ãªèšæ³ã¯ãããŸããã - é
åãšããŠã®åŒæ°ã¯ã
[lowerbound:size,⊠ãšããŠè¡šèšãããŸãã,lowerbound:size]ã«ã³ãæ°ã¯ã©ã³ã¯ãã 1 ãåŒããæ°ã§ãããåãã£ã¡ã³ã·ã§ã³ã®äžéãšãµã€ãºã¯ (æ¢ç¥ã®å Žå) 10 鲿°ã§è¡šãããŸãã äžéãŸãã¯ãµã€ãºã®æå®ããªãå Žåã¯çç¥ãããŸãã ç¹å®ã®æ¬¡å ã§äžéããã³ãµã€ãºãçç¥ãããŠããå Žåã¯ãã:ããçç¥ãããŸãã ãžã£ã°é åã¯ã¬ãã«ããšã« 1 ã€ã®ã[]ãã§è¡šãããŸãã 1 次å é åã§ã¯ãäžé ã0 (ããã©ã«ã) ã®å Žåãäžéã¯çç¥ãããŸã (§17.1)ã -
void以å€ã®ãã€ã³ã¿åãæã€åŒæ°ã¯ãååã®åŸã«*ã䜿çšããŠè¡šãããŸããvoidãã€ã³ã¿ã¯System.Voidãšããååã䜿çšããŠè¡šãããŸãã - åã§å®çŸ©ããããžã§ããªãã¯åãã©ã¡ãŒã¿ãåç
§ããåŒæ°ã¯ãã
`ãæåãšããã«ç¶ãåãã©ã¡ãŒã¿ã®ãŒãããŒã¹ã®ã€ã³ããã¯ã¹ã䜿çšããŠãšã³ã³ãŒããããŸãã - ã¡ãœããã§å®çŸ©ããããžã§ããªãã¯åãã©ã¡ãŒã¿ã䜿çšããåŒæ°ã§ã¯ãåã«äœ¿çšãããã
``ãã®ä»£ããã«äºéããã¯ãã£ãã¯ã`ãã䜿çšãããŸãã - æ§ç¯ããããžã§ããªãã¯åãåç
§ããåŒæ°ã¯ããžã§ããªãã¯åã®åŸã«ã
{ãããã®åŸã«ã«ã³ãã§åºåãããååŒæ°ã®ãªã¹ããæåŸã«ã}ãã䜿çšããŠãšã³ã³ãŒããããŸãã
- ãžã§ããªãã¯åã衚ãåŒæ°ã«ã¯ã
- åŒæ°ã¯ã次ã®ããã«å€æŽãããå®å
šä¿®é£Ÿåã«åºã¥ããããã¥ã¡ã³ãåã§è¡šãããŸãã
D.4.3 ID æååã®äŸ
次ã®åäŸã¯ãC# ã³ãŒãã®äžéšãšãããã¥ã¡ã³ã ã³ã¡ã³ããæã€ããšãã§ããåãœãŒã¹èŠçŽ ããçæããã ID æååã瀺ããŠããŸãã
åã¯ãæ±çšæ å ±ãå ããå®å šä¿®é£Ÿåã䜿çšããŠè¡šãããŸãã
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<T>
{
class Helper<U,V> { ... }
}
}
ID:
"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"
ãã£ãŒã«ãã¯ãå®å šä¿®é£Ÿåã§è¡šãããŸãã
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;
}
}
ID:
"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"
ã³ã³ã¹ãã©ã¯ã¿ãŒ
namespace Acme
{
class Widget : IProcess
{
static Widget() { ... }
public Widget() { ... }
public Widget(string s) { ... }
}
}
ID:
"M:Acme.Widget.#cctor"
"M:Acme.Widget.#ctor"
"M:Acme.Widget.#ctor(System.String)"
ãã¡ã€ãã©ã€ã¶ãŒ
namespace Acme
{
class Widget : IProcess
{
~Widget() { ... }
}
}
ID:
"M:Acme.Widget.Finalize"
ã¡ãœãã
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, in int i) { ... }
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<T>
{
public void Test(T t) { ... }
}
class UseList
{
public void Process(MyList<int> list) { ... }
public MyList<T> GetValues<T>(T value) { ... }
}
}
ID:
"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@,System.Int32@)"
"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``1(``0)"
ããããã£ãšã€ã³ãã¯ãµ
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 { ... } }
}
}
ID:
"P:Acme.Widget.Width"
"P:Acme.Widget.Item(System.Int32)"
"P:Acme.Widget.Item(System.String,System.Int32)"
ã€ãã³ã
namespace Acme
{
class Widget : IProcess
{
public event Del AnEvent;
}
}
ID:
"E:Acme.Widget.AnEvent"
åé æŒç®å
namespace Acme
{
class Widget : IProcess
{
public static Widget operator+(Widget x) { ... }
}
}
ID:
"M:Acme.Widget.op_UnaryPlus(Acme.Widget)"
䜿çšãããåé
æŒç®å颿°åã®å®å
šãªã»ããã¯ã op_UnaryPlusã op_UnaryNegationã op_CheckedUnaryNegationã op_LogicalNotã op_OnesComplementã op_Incrementã op_CheckedIncrementã op_Decrementã op_CheckedDecrementã op_Trueãããã³ op_Falseã§ãã
äºé æŒç®å
namespace Acme
{
class Widget : IProcess
{
public static Widget operator+(Widget x1, Widget x2) { ... }
}
}
ID:
"M:Acme.Widget.op_Addition(Acme.Widget,Acme.Widget)"
䜿çšãããäºé
æŒç®å颿°åã®å®å
šãªã»ããã¯æ¬¡ã®ãšããã§ã: op_Additionã op_CheckedAdditionã op_Subtractionã op_CheckedSubtractionã op_Multiplyã op_CheckedMultiplyã op_Divisionã op_CheckedDivisionã op_Modulusã op_BitwiseAndã op_BitwiseOrã op_ExclusiveOrã op_LeftShiftã op_RightShiftã op_UnsignedRightShiftã op_Equalityã op_Inequalityã op_LessThanã op_LessThanOrEqualã op_GreaterThanãããã³ op_GreaterThanOrEqualã
倿æŒç®åã¯ãæ«å°Ÿã«ã~ããä»ãããã®åŸã«æ»ãå€åãç¶ããŸãã 倿æŒç®åã®ãœãŒã¹ãŸãã¯å®å
ã®ããããããžã§ããªãã¯åã®å Žåãã<ãããã³ã">ãæåã¯ããããã{ãããã³ã}ãæåã«çœ®ãæããããŸãã
䜿çšããã倿æŒç®å颿°åã®å®å
šãªã»ããã¯ã op_Explicitã op_CheckedExplicitãããã³ op_Implicitã§ãã
namespace Acme
{
class Widget : IProcess
{
public static explicit operator int(Widget x) { ... }
public static implicit operator long(Widget x) { ... }
}
}
ID:
"M:Acme.Widget.op_Explicit(Acme.Widget)~System.Int32"
"M:Acme.Widget.op_Implicit(Acme.Widget)~System.Int64"
D.5 äŸ
D.5.1 C# ãœãŒã¹ ã³ãŒã
次ã®äŸã¯ãPoint ã¯ã©ã¹ã®ãœãŒã¹ ã³ãŒãã瀺ããŠããŸãã
namespace Graphics
{
/// <summary>
/// Class <c>Point</c> models a point in a two-dimensional plane.
/// </summary>
public class Point
{
/// <value>
/// Property <c>X</c> represents the point's x-coordinate.
/// </value>
public int X { get; set; }
/// <value>
/// Property <c>Y</c> represents the point's y-coordinate.
/// </value>
public int Y { get; set; }
/// <summary>
/// This constructor initializes the new Point to (0,0).
/// </summary>
public Point() : this(0, 0) {}
/// <summary>
/// This constructor initializes the new Point to
/// (<paramref name="xPosition"/>,<paramref name="yPosition"/>).
/// </summary>
/// <param name="xPosition">The new Point's x-coordinate.</param>
/// <param name="yPosition">The new Point's y-coordinate.</param>
public Point(int xPosition, int yPosition)
{
X = xPosition;
Y = yPosition;
}
/// <summary>
/// This method changes the point's location to
/// the given coordinates. <see cref="Translate"/>
/// </summary>
/// <param name="xPosition">The new x-coordinate.</param>
/// <param name="yPosition">The new y-coordinate.</param>
public void Move(int xPosition, int yPosition)
{
X = xPosition;
Y = yPosition;
}
/// <summary>
/// This method changes the point's location by
/// the given x- and y-offsets.
/// <example>For example:
/// <code>
/// Point p = new Point(3, 5);
/// p.Translate(-1, 3);
/// </code>
/// results in <c>p</c>'s having the value (2, 8).
/// <see cref="Move"/>
/// </example>
/// </summary>
/// <param name="dx">The relative x-offset.</param>
/// <param name="dy">The relative y-offset.</param>
public void Translate(int dx, int dy)
{
X += dx;
Y += dy;
}
/// <summary>
/// This method determines whether two Points have the same location.
/// </summary>
/// <param name="o">
/// The object to be compared to the current object.
/// </param>
/// <returns>
/// True if the Points have the same location and they have
/// the exact same type; otherwise, false.
/// </returns>
/// <seealso cref="operator=="/>
/// <seealso cref="operator!="/>
public override bool Equals(object o)
{
if (o == null)
{
return false;
}
if ((object)this == o)
{
return true;
}
if (GetType() == o.GetType())
{
Point p = (Point)o;
return (X == p.X) && (Y == p.Y);
}
return false;
}
/// <summary>
/// This method returns a Point's hashcode.
/// </summary>
/// <returns>
/// The int hashcode.
/// </returns>
public override int GetHashCode()
{
return X + (Y >> 4); // a crude version
}
/// <summary>Report a point's location as a string.</summary>
/// <returns>
/// A string representing a point's location, in the form (x,y),
/// without any leading, training, or embedded whitespace.
/// </returns>
public override string ToString() => $"({X},{Y})";
/// <summary>
/// This operator determines whether two Points have the same location.
/// </summary>
/// <param name="p1">The first Point to be compared.</param>
/// <param name="p2">The second Point to be compared.</param>
/// <returns>
/// True if the Points have the same location and they have
/// the exact same type; otherwise, false.
/// </returns>
/// <seealso cref="Equals"/>
/// <seealso cref="operator!="/>
public static bool operator==(Point p1, Point p2)
{
if ((object)p1 == null || (object)p2 == null)
{
return false;
}
if (p1.GetType() == p2.GetType())
{
return (p1.X == p2.X) && (p1.Y == p2.Y);
}
return false;
}
/// <summary>
/// This operator determines whether two Points have the same location.
/// </summary>
/// <param name="p1">The first Point to be compared.</param>
/// <param name="p2">The second Point to be compared.</param>
/// <returns>
/// True if the Points do not have the same location and the
/// exact same type; otherwise, false.
/// </returns>
/// <seealso cref="Equals"/>
/// <seealso cref="operator=="/>
public static bool operator!=(Point p1, Point p2) => !(p1 == p2);
}
}
D.5.2 çµæã® XML
以äžã¯ãäžèšã«ç€ºããã¯ã©ã¹ Point ã®ãœãŒã¹ ã³ãŒããæå®ãããšãã«ãããããã¥ã¡ã³ã ãžã§ãã¬ãŒã¿ã«ãã£ãŠçæãããåºåã§ãã
<?xml version="1.0"?>
<doc>
<assembly>
<name>Point</name>
</assembly>
<members>
<member name="T:Graphics.Point">
<summary>Class <c>Point</c> models a point in a two-dimensional
plane.
</summary>
</member>
<member name="M:Graphics.Point.#ctor">
<summary>This constructor initializes the new Point to (0, 0).</summary>
</member>
<member name="M:Graphics.Point.#ctor(System.Int32,System.Int32)">
<summary>
This constructor initializes the new Point to
(<paramref name="xPosition"/>,<paramref name="yPosition"/>).
</summary>
<param name="xPosition">The new Point's x-coordinate.</param>
<param name="yPosition">The new Point's y-coordinate.</param>
</member>
<member name="M:Graphics.Point.Move(System.Int32,System.Int32)">
<summary>
This method changes the point's location to
the given coordinates.
<see cref="M:Graphics.Point.Translate(System.Int32,System.Int32)"/>
</summary>
<param name="xPosition">The new x-coordinate.</param>
<param name="yPosition">The new y-coordinate.</param>
</member>
<member name="M:Graphics.Point.Translate(System.Int32,System.Int32)">
<summary>
This method changes the point's location by
the given x- and y-offsets.
<example>For example:
<code>
Point p = new Point(3,5);
p.Translate(-1,3);
</code>
results in <c>p</c>'s having the value (2,8).
</example>
<see cref="M:Graphics.Point.Move(System.Int32,System.Int32)"/>
</summary>
<param name="dx">The relative x-offset.</param>
<param name="dy">The relative y-offset.</param>
</member>
<member name="M:Graphics.Point.Equals(System.Object)">
<summary>
This method determines whether two Points have the same location.
</summary>
<param name="o">
The object to be compared to the current object.
</param>
<returns>
True if the Points have the same location and they have
the exact same type; otherwise, false.
</returns>
<seealso
cref="M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)" />
<seealso
cref="M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)"/>
</member>
<member name="M:Graphics.Point.ToString">
<summary>
Report a point's location as a string.
</summary>
<returns>
A string representing a point's location, in the form (x,y),
without any leading, training, or embedded whitespace.
</returns>
</member>
<member name="M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)">
<summary>
This operator determines whether two Points have the same location.
</summary>
<param name="p1">The first Point to be compared.</param>
<param name="p2">The second Point to be compared.</param>
<returns>
True if the Points have the same location and they have
the exact same type; otherwise, false.
</returns>
<seealso cref="M:Graphics.Point.Equals(System.Object)"/>
<seealso
cref="M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)"/>
</member>
<member
name="M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)">
<summary>
This operator determines whether two Points have the same location.
</summary>
<param name="p1">The first Point to be compared.</param>
<param name="p2">The second Point to be compared.</param>
<returns>
True if the Points do not have the same location and the
exact same type; otherwise, false.
</returns>
<seealso cref="M:Graphics.Point.Equals(System.Object)"/>
<seealso
cref="M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)"/>
</member>
<member name="M:Graphics.Point.Main">
<summary>
This is the entry point of the Point class testing program.
<para>
This program tests each method and operator, and
is intended to be run after any non-trivial maintenance has
been performed on the Point class.
</para>
</summary>
</member>
<member name="P:Graphics.Point.X">
<value>
Property <c>X</c> represents the point's x-coordinate.
</value>
</member>
<member name="P:Graphics.Point.Y">
<value>
Property <c>Y</c> represents the point's y-coordinate.
</value>
</member>
</members>
</doc>
æ å ±ããã¹ãã®æ«å°Ÿã
ECMA C# draft specification