Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.15.8" />
<PackageVersion Include="DiffPlex" Version="1.9.0" />
<PackageVersion Include="GodotSharp" Version="4.7.1" />
<PackageVersion Include="MessagePack" Version="3.1.7" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.11" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.29" />
Expand Down
2 changes: 2 additions & 0 deletions Nerdbank.MessagePack.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Project Path="src/Nerdbank.MessagePack.Analyzers.CodeFixes/Nerdbank.MessagePack.Analyzers.CodeFixes.csproj" />
<Project Path="src/Nerdbank.MessagePack.Analyzers/Nerdbank.MessagePack.Analyzers.csproj" />
<Project Path="src/Nerdbank.MessagePack.AspNetCoreMvcFormatter/Nerdbank.MessagePack.AspNetCoreMvcFormatter.csproj" Id="b1fb3f7e-01df-48c3-b606-2083a6ae3607" />
<Project Path="src/Nerdbank.MessagePack.Godot/Nerdbank.MessagePack.Godot.csproj" />
<Project Path="src/Nerdbank.MessagePack.SignalR/Nerdbank.MessagePack.SignalR.csproj" />
<Project Path="src/Nerdbank.MessagePack/Nerdbank.MessagePack.csproj" />
</Folder>
Expand All @@ -50,6 +51,7 @@
<Project Path="test/Benchmarks/Benchmarks.csproj" />
<Project Path="test/Nerdbank.MessagePack.Analyzers.Tests/Nerdbank.MessagePack.Analyzers.Tests.csproj" />
<Project Path="test/Nerdbank.MessagePack.AspNetCoreMvcFormatter.Tests/Nerdbank.MessagePack.AspNetCoreMvcFormatter.Tests.csproj" Id="0b1a3684-c54e-40ba-8648-88cd8c6d6093" />
<Project Path="test/Nerdbank.MessagePack.Godot.Tests/Nerdbank.MessagePack.Godot.Tests.csproj" />
<Project Path="test/Nerdbank.MessagePack.SignalR.Tests/Nerdbank.MessagePack.SignalR.Tests.csproj" />
<Project Path="test/Nerdbank.MessagePack.Tests/Nerdbank.MessagePack.Tests.csproj" />
<Project Path="test/Nerdbank.MessagePack.TUnit/Nerdbank.MessagePack.TUnit.csproj">
Expand Down
1 change: 1 addition & 0 deletions docfx/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"files": [
"Nerdbank.MessagePack/*.csproj",
"Nerdbank.MessagePack.AspNetCoreMvcFormatter/*.csproj",
"Nerdbank.MessagePack.Godot/*.csproj",
"Nerdbank.MessagePack.SignalR/*.csproj"
]
}
Expand Down
52 changes: 52 additions & 0 deletions docfx/docs/godot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Godot support

The `Nerdbank.MessagePack.Godot` package adds compact MessagePack converters for common Godot Engine value types.
It supports Godot projects targeting .NET 8 or later and is compatible with Native AOT.

## Installation

Install the `Nerdbank.MessagePack.Godot` NuGet package.

## Configuration

Configure each <xref:Nerdbank.MessagePack.MessagePackSerializer> instance that serializes Godot values with <xref:Nerdbank.MessagePack.Godot.GodotMessagePackSerializerExtensions.WithGodotConverters*>:

```cs
using Godot;
using Nerdbank.MessagePack;
using Nerdbank.MessagePack.Godot;
using PolyType;

[GenerateShapeFor<Vector3>]
internal partial class GodotShapes;

MessagePackSerializer serializer = new MessagePackSerializer().WithGodotConverters();
Vector3 position = new(1.5f, 2f, -4f);
byte[] bytes = serializer.Serialize<Vector3, GodotShapes>(position);
Vector3 roundTripped = serializer.Deserialize<Vector3, GodotShapes>(bytes);
```

When a Godot value is a member of your own serializable type, apply <xref:PolyType.GenerateShapeAttribute> to that type as usual.
The package's converters are then selected automatically for the Godot members.

## Supported types

The package supports these Godot value types:

* `Godot.Aabb`
* `Godot.Basis`
* `Godot.Color`
* `Godot.Plane`
* `Godot.Projection`
* `Godot.Quaternion`
* `Godot.Rect2` and `Godot.Rect2I`
* `Godot.Transform2D` and `Godot.Transform3D`
* `Godot.Vector2`, `Godot.Vector2I`, `Godot.Vector3`, `Godot.Vector3I`, `Godot.Vector4`, and `Godot.Vector4I`

Godot nodes, resources, variants, and collection types are not included. Serialize application-owned types that refer to them instead.

## MessagePack-CSharp migration

Each supported value is encoded as a positional MessagePack array in the same field order used by the `MessagePackGodot` package.
Existing payloads written by that package can therefore be read after switching to Nerdbank.MessagePack, and new payloads retain that wire format.
The converters ignore additional array elements when reading, allowing a future version to append values without breaking older readers.
1 change: 1 addition & 0 deletions docfx/docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ items:
href: security.md
- href: structural-equality.md
- href: unity.md
- href: godot.md
- name: Type shapes
href: type-shapes.md
- href: fsharp.md
Expand Down
Loading
Loading