OpenTK coding guidelines
-
Add licensing information to the top of each code file. The following snippet is enough:
#region --- License --- /* This source file is released under the MIT license. See License.txt for more information. * Coded by [...] and [...]. */ #endregion
- Document all public methods! It is much easier to document something when you write it, than later on.
-
Use regions wherever it makes sense. Using directives, interface methods, functions (but not docs) and fields/properties are good candidates.
Format regions like this: #region --- Region Name ---
- Limit lines to no more than 120 characters.
-
Place opening and closing braces on new lines:
private void Foo() { }
-
Break up long parameter lists. Write:
public IGLContextWindows( IntPtr handle, ColorDepth color, ColorDepth accum, int depthBits, int stencilBits, int auxBits, bool stereo, bool doublebuffer ) { }
instead of:
public IGLContextWindows(IntPtr handle, ColorDepth color, ColorDepth accum, [...])
- Indent using 4 spaces. No tabs!
- Place a space between if/while/for/foreach and the opening parenthesis, but not between a function name and the opening parenthesis.
if (foo) { } void Func() { }
- Case classes, structs, public methods, public fields/properties LikeThis. Case private members likeThis. Do not forget to add the private modifier!
- Use comments! They exist for a reason.
Last, but not least, you may freely disregard any of these ;-) Just don't forget the comments and the license information.

