1 The class libraries are grouped together in the assemblies they belong.
3 Each directory here represents an assembly, and inside each directory we
4 divide the code based on the namespace they implement.
6 In addition, each assembly directory contains a Test directory that holds the
7 NUnit tests for that assembly.
9 We use a new build system which is described by various README files
12 The build process typically builds an assembly, but in some cases it
13 also builds special versions of the assemblies intended to be used for
16 * Missing implementation bits
18 If you implement a class and you are missing implementation bits,
19 please use the attribute [MonoTODO]. This attribute can be used
20 to programatically generate our status web pages:
25 throw new NotImplementedException ();
28 Ideally, write a human description of the reason why there is
29 a MonoTODO, this will be useful in the future for our
30 automated tools that can assist in developers porting their
33 Do not use MonoTODO attributes for reminding yourself of
34 internal changes that must be done. Use FIXMEs or other kinds
35 of comments in the source code for that purpose, and if the
36 problem requires to be followed up on, file a bug.
38 * Supporting .NET 1.2, .NET 1.1 and .NET 1.0 builds
40 The defines NET_1_1 and NET_2_0 are used to include
41 features. When NET_2_0 is defined, it also implies that the
44 To have code which is only available in an old version, use ONLY_1_0,
49 If there is a bug in your implementation tag the problem by using
50 the word "FIXME" in the code, together with a description of the
53 Do not use XXX or obscure descriptions, because otherwise people
54 will not be able to understand what you mean.
56 * Tagging Problematic specs.
58 If the documentation and the Microsoft implementation do
59 differ (you wrote a test case to prove this), I suggest that you edit
60 the file `mcs/class/doc/API-notes' so we can keep track of these problems
61 and submit our comments to ECMA or Microsoft and seek clarification.
63 Sometimes the documentation might be buggy, and sometimes the implementation
64 might be buggy. Lets try to identify and pinpoint which one
67 Sometimes the specification will be lame (consider Version.ToString (fieldCount)
68 where there is no way of knowing how many fields are available, making the API
69 not only stupid, but leading to unreliable code).
71 In those cases, use the keyword "LAMESPEC".
74 * Coding considerations and style.
76 In order to keep the code consistent, please use the following
77 conventions. From here on `good' and `bad' are used to attribute
78 things that would make the coding style match, or not match. It is not
79 a judgement call on your coding abilities, but more of a style and
80 look call. Please try to follow these guidelines to ensure prettiness.
82 Use 8 space tabs for writing your code (hopefully we can keep
83 this consistent). If you are modifying someone else's code, try
84 to keep the coding style similar.
86 Since we are using 8-space tabs, you might want to consider the Linus
87 Torvals trick to reduce code nesting. Many times in a loop, you will
88 find yourself doing a test, and if the test is true, you will nest.
89 Many times this can be changed. Example:
92 for (i = 0; i < 10; i++) {
98 This take precious space, instead write it like this:
100 for (i = 0; i < 10; i++) {
108 * Use a space before an opening parenthesis when calling
109 functions, or indexing, like this:
114 * Do not put a space after the opening parenthesis and the
117 good: method (a); array [10];
119 bad: method ( a ); array[ 10 ];
121 * Inside a code block, put the opening brace on the same line
137 * Avoid using unecessary open/close braces, vertical space
149 * When defining a method, use the C style for brace placement,
150 that means, use a new line for the brace, like this:
161 * Properties and indexers are an exception, keep the
162 brace on the same line as the property declaration.
163 Rationale: this makes it visually
164 simple to distinguish them.
181 Notice how the accessor "get" also keeps its brace on the same
184 For very small properties, you can compress things:
188 get { return value; }
192 * Use white space in expressions liberally, except in the presence
197 if (a + 5 > method (blah () + 4))
200 if (a+5>method(blah()+4))
202 * For any new files, please use a descriptive introduction, like
206 // System.Comment.cs: Handles comments in System files.
209 // Juan Perez (juan@address.com)
211 // (C) 2002 Address, Inc (http://www.address.com)
214 * If you are modyfing someone else's code, and your contribution
215 is significant, please add yourself to the Authors list.
217 * Switch statements have the case at the same indentation as the
227 * Argument names should use the camel casing for
228 identifiers, like this:
231 void Method (string myArgument)
234 void Method (string lpstrArgument)
235 void Method (string my_string)
237 * Empty methods: They should have the body of code using two
238 lines, in consistency with the rest:
246 void EmptyMethod () {}
251 * Line length: The line length for C# source code is 134 columns.
254 If your function declaration arguments go beyond
255 this point, please align your arguments to match the
256 opening brace, like this:
258 void Function (int arg, string argb,
263 When invoking functions, the rule is different, the
264 arguments are not aligned with the previous
265 argument, instead they begin at the tabbed position,
270 MethodCall ("Very long string that will force",
271 "Next argument on the 8-tab pos",
272 "Just like this one")
276 Here are a couple of examples:
280 bool Method (int argument_1, int argument_2)
282 if (argument_1 == argument_2)
283 throw new Exception (Locale.GetText ("They are equal!");
285 if (argument_1 < argument_2) {
286 if (argument_1 * 3 > 4)
293 // This sample helps keep your sanity while using 8-spaces for tabs
295 VeryLongIdentifierWhichTakesManyArguments (
296 Argument1, Argument2, Argument3,
311 void AnotherMethod ()