Skip to content

Getting started (C#)

Supported Runtimes

  • .NET Framework 4.7.2
  • .NET Framework 4.8
  • .NET Core 3.1
  • .NET 5+

Install the Runtime

To install the Bebop .NET runtime you can use the following commands:

dotnet add package bebop
PackageNuGet StableDownloads

Install the Compiler Tools

To install the Bebop Compiler tools you can use the following command:

dotnet add package bebop-tools
PackageNuGet StableDownloads

Configuring the Compiler Tools

Inside of your project file add a new ItemGroup

<Bebop Include="**/*.bop" OutputDir="./Models/" OutputFile="IpcModels.g.cs" Namespace="RainwayIPC.Models" />

When the <Bebop> item group is present in your project all schemas that match the provided Include path are compiled in accordance with the output parameters defined whenever you build your project (meaning that schema changes reflect immediately in your project.)

Any issues encountered while compiling your schemas can now also be inspected from the error list.

Using Bebop Mirroring

Mirroring is a Bebop feature supported by the .NET runtime implementation that allows for records to be access and handled dynamically. For instance, you can define a class as a RecordHandler and bind it’s methods to be invoked whenever a record of a certain type is decoded.

It takes advantage of the opcode decorator to determine which method to invoke.

public class ExampleHandler
public async Task HandleChat(object state, ChatMessage chat)

Arbitrary data can then be decoded dynamically by leveraging the records opcode, and the method bound to it is fired.

// fired when a message is received from the network.
public void OnMessage(byte[] data) {
// decodes our network messages
var networkMessage = NetworkMessage.Decode(data);
// decodes and invokes the handler (if any) for the decoded record
// if the record is ChatMessage then HandleChat is invoked..
BebopMirror.HandleRecord(networkMessage.IncomingRecordData, networkMessage.IncomingOpcode, stateObject);