Learn about Slice modules.

A module is a naming scope for Slice types. It allows you to define and reference different Slice types with the same name, provided they are in different scopes (modules).

Slice uses :: as its scope resolution operator.

For example:

module AnimalKingdom
compact struct Lion { ... } // in module AnimalKingdom
module Game
interface Lion {
getModel() -> AnimalKingdom::Lion

You can split the definitions within the same module into multiple Slice files.

A module can have sub-modules, sub-sub-modules etc. at any depth. Each level is separated by ::. For example:

module Res::Vacation
// definitions in the Vacation sub-module...

A Slice module is mapped to a C# namespace with the same name converted to Pascal case.

You can customize this mapping with the cs::namespace attribute and remap the module to the specified namespace. This attribute accepts a single string argument: the name of the C# namespace.

For example:

module Res::Vacation
namespace Reservation.Bundles;

Was this page helpful?