IronRuby > Frequently Asked Questions > What rules should I follow when contributing code to the project?

What rules should I follow when contributing code to the project?

Table of contents
No headers
  1. Use .NET Framework conventions for all identifiers (see http://msdn2.microsoft.com/en-us/library/ms229002.aspx). There is no specific guideline for naming private fields in this document; we prefix field names with underscores (e.g. private string _fooBar). If you're not sure about some convention try to find out in the rest of the IronRuby code or ask in the list.

  2. Use /*!*/ for method parameters and instance fields that should never be null. See http://research.microsoft.com/specsharp for details on Spec# annotations.
  3. Do not use public fields (Base::algorithm, buffer). Use properties if it is necessary to expose the field or private/internal visibility otherwise. Also use readonly if the field is not mutated after the object is constructed.
  4. You don't need to declare Call_Foo methods in order to invoke a dynamic site unless the invocation is somehow more complex (involves some conversions etc.)
  5. Please test for corner cases, eg whether the methods accept null arguments etc. Mark the parameters appropriately ([NotNull] attribute, /*!*/ etc.), add precondition checks. Here's an example:

  

[RubyMethod("*")]
public static RubyArray/*!*/ Repetition(IList/*!*/ self, int repeat) {
   if (repeat < 0) {
      throw RubyExceptions.CreateArgumentError("negative argument");
   }
   ...
}
Tag page
You must login to post a comment.