From a31a4eb3ca111a9f426779c4ff188cfc4f3959a2 Mon Sep 17 00:00:00 2001
From: Samuel Gido <132026917+samgido@users.noreply.github.com>
Date: Tue, 17 Feb 2026 15:09:17 -0600
Subject: [PATCH] Update structure types to record structs (#326)
---
Raylib-cs/types/BoundingBox.cs | 2 +-
Raylib-cs/types/Camera2D.cs | 2 +-
Raylib-cs/types/Camera3D.cs | 2 +-
Raylib-cs/types/Color.cs | 7 +------
Raylib-cs/types/Ray.cs | 4 ++--
Raylib-cs/types/Rectangle.cs | 7 +------
Raylib-cs/types/Transform.cs | 2 +-
7 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/Raylib-cs/types/BoundingBox.cs b/Raylib-cs/types/BoundingBox.cs
index 3e12bc3..f31283a 100644
--- a/Raylib-cs/types/BoundingBox.cs
+++ b/Raylib-cs/types/BoundingBox.cs
@@ -5,7 +5,7 @@ namespace Raylib_cs;
/// Bounding box type
[StructLayout(LayoutKind.Sequential)]
-public partial struct BoundingBox
+public partial record struct BoundingBox
{
///
/// Minimum vertex box-corner
diff --git a/Raylib-cs/types/Camera2D.cs b/Raylib-cs/types/Camera2D.cs
index 7902111..2ff018f 100644
--- a/Raylib-cs/types/Camera2D.cs
+++ b/Raylib-cs/types/Camera2D.cs
@@ -7,7 +7,7 @@ namespace Raylib_cs;
/// Camera2D, defines position/orientation in 2d space
///
[StructLayout(LayoutKind.Sequential)]
-public struct Camera2D
+public record struct Camera2D
{
///
/// Camera offset (displacement from target)
diff --git a/Raylib-cs/types/Camera3D.cs b/Raylib-cs/types/Camera3D.cs
index b9065d9..ef5dd20 100644
--- a/Raylib-cs/types/Camera3D.cs
+++ b/Raylib-cs/types/Camera3D.cs
@@ -28,7 +28,7 @@ public enum CameraProjection
/// Camera3D, defines position/orientation in 3d space
///
[StructLayout(LayoutKind.Sequential)]
-public struct Camera3D
+public record struct Camera3D
{
///
/// Camera position
diff --git a/Raylib-cs/types/Color.cs b/Raylib-cs/types/Color.cs
index da678d1..b3cb2e7 100644
--- a/Raylib-cs/types/Color.cs
+++ b/Raylib-cs/types/Color.cs
@@ -7,7 +7,7 @@ namespace Raylib_cs;
/// Color type, RGBA (32bit)
///
[StructLayout(LayoutKind.Sequential)]
-public struct Color
+public record struct Color
{
public byte R;
public byte G;
@@ -221,9 +221,4 @@ public struct Color
{
return (byte)(a + (b - a) * t);
}
-
- public readonly override string ToString()
- {
- return $"{{R:{R} G:{G} B:{B} A:{A}}}";
- }
}
diff --git a/Raylib-cs/types/Ray.cs b/Raylib-cs/types/Ray.cs
index 23b47ee..5cb04ae 100644
--- a/Raylib-cs/types/Ray.cs
+++ b/Raylib-cs/types/Ray.cs
@@ -7,7 +7,7 @@ namespace Raylib_cs;
/// Ray, ray for raycasting
///
[StructLayout(LayoutKind.Sequential)]
-public struct Ray
+public record struct Ray
{
///
/// Ray position (origin)
@@ -30,7 +30,7 @@ public struct Ray
/// Raycast hit information
///
[StructLayout(LayoutKind.Sequential)]
-public struct RayCollision
+public record struct RayCollision
{
///
/// Did the ray hit something?
diff --git a/Raylib-cs/types/Rectangle.cs b/Raylib-cs/types/Rectangle.cs
index d78275b..bc88220 100644
--- a/Raylib-cs/types/Rectangle.cs
+++ b/Raylib-cs/types/Rectangle.cs
@@ -7,7 +7,7 @@ namespace Raylib_cs;
/// Rectangle type
///
[StructLayout(LayoutKind.Sequential)]
-public struct Rectangle
+public record struct Rectangle
{
public float X;
public float Y;
@@ -106,9 +106,4 @@ public struct Rectangle
Width -= shrink * 2.0f;
Height -= shrink * 2.0f;
}
-
- public readonly override string ToString()
- {
- return $"{{X:{X} Y:{Y} Width:{Width} Height:{Height}}}";
- }
}
diff --git a/Raylib-cs/types/Transform.cs b/Raylib-cs/types/Transform.cs
index 10b15ab..248a9ad 100644
--- a/Raylib-cs/types/Transform.cs
+++ b/Raylib-cs/types/Transform.cs
@@ -7,7 +7,7 @@ namespace Raylib_cs;
/// Transform, vertex transformation data
///
[StructLayout(LayoutKind.Sequential)]
-public struct Transform
+public record struct Transform
{
///
/// Translation