Language Extensions

RemObjects C# adds a few features to the standard C# language to make it fit better on all the platforms it supports. We try to keep these extensions to a minimum, and tasteful within the design aesthetics of the C# language.

Where additional keywords are needed, we follow the C/C++/C# convention of prefixing these with two underscores ("__") to avoid conflict with future changes to the C# spec.

Multi-Part Method and Constructor Names

In order to fit in well with the API conventions on the Cocoa platform, RemObjects C# adds support for multi-part method names — essentially the ability for a method's name to be split into separate parts, each followed by a distinct parameter. This feature is available on all platforms, and described in more detail in the Multi-part method names topic.

Not-nullable Types

Similar to the "nullable types" feature in standard C#, reference type variables can be adorned by the ! operator to mark them as "not nullable". See the Nullability topic in the Language Concepts section for more details, and Non-Nullable Types for a more explicit discussion of the C# syntax.

Cocoa-specific Features

RemObjects C# adds the __strong, __weak and __unretained type modifiers to control how the lifetime of Automatic Reference Counted objects is handled on Cocoa. The modifiers are described in the Storage Modifiers topic.

The using __autoreleasepool can be used to manually control ARC auto-release pools, described here.

Finally, __selector() can be used to create a selector instance on Cocoa, for use in functions that take such a selector for callback purposes, and for dynamic dispatch of method calls in the Objective-C runtime environment. This is described here.

Inline Functions

Functions can be marked with the __inline keyword to cause them to be inlined at the call site instead of being generated as separate functions in the executable. See the Inline Functions topic for more details.

Labeled Loop Statements

Labeled Loop Statements allow you more control when writing nested loops, including the ability to break or continue an outer loop from inside a nested one.

Mapped Types

RemObjects C# also has full support for a feature called Mapped Types, which are inlined types useful to create cross-platform wrappers with zero overhead. While you won't often implement your own mapped types, you will likely use existing ones, for example from the Sugar library.

Aspects

Aspects are special attributes that influence how the compiler emits the final executable. In RemObjects C#, they use attributes syntax and the optional __aspect: attribute prefix. Aspects are covered in more detail in their own section, including how to use them and how to create your own.

Global Members

Mostly to fit in better with Cocoa, but available on all platforms, RemObjects C# allows you to both call and define global methods (functions) and variables that are not contained within a class.

C# 6.0 Features

The following features are currently planned and announced by Microsoft for the upcoming C# 6.0 release later in 2015, and are already implemented in RemObjects C#:

Inline Property Initializers

Properties can directly be initialized inline:

public string Name { get; set; } = "No name";

Null-safe Call Operator

The null-safe member access operator "?." can be used to safely access members of potentially null references. Once again, see Nullability for more details.

String x = null;
Int32? len = x?.Length;