2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-06-30 19:03:42 -04:00

Add .editorconfig and apply formatting

This commit is contained in:
2023-08-27 15:20:26 +01:00
parent d1f0b9fd91
commit 696955463f
32 changed files with 7217 additions and 7194 deletions

View File

@ -30,41 +30,40 @@ using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace Raylib_cs.Tests
namespace Raylib_cs.Tests;
public static class BlittableHelper
{
public static class BlittableHelper
public static bool IsBlittable<T>()
{
public static bool IsBlittable<T>()
{
return IsBlittableCache<T>.VALUE;
}
return IsBlittableCache<T>.VALUE;
}
public static bool IsBlittable(this Type type)
public static bool IsBlittable(this Type type)
{
if (type == typeof(decimal))
{
if (type == typeof(decimal))
{
return false;
}
if (type.IsArray)
{
var elementType = type.GetElementType();
return elementType != null && elementType.IsValueType && IsBlittable(elementType);
}
try
{
var instance = FormatterServices.GetUninitializedObject(type);
GCHandle.Alloc(instance, GCHandleType.Pinned).Free();
return true;
}
catch
{
return false;
}
return false;
}
private static class IsBlittableCache<T>
if (type.IsArray)
{
public static readonly bool VALUE = IsBlittable(typeof(T));
var elementType = type.GetElementType();
return elementType != null && elementType.IsValueType && IsBlittable(elementType);
}
try
{
var instance = FormatterServices.GetUninitializedObject(type);
GCHandle.Alloc(instance, GCHandleType.Pinned).Free();
return true;
}
catch
{
return false;
}
}
private static class IsBlittableCache<T>
{
public static readonly bool VALUE = IsBlittable(typeof(T));
}
}

View File

@ -1,46 +1,45 @@
using System;
using Xunit;
namespace Raylib_cs.Tests
{
public class RaylibTests
{
private unsafe void CheckType<T>() where T : unmanaged
{
Assert.True(BlittableHelper.IsBlittable<T>());
}
namespace Raylib_cs.Tests;
[Fact]
public void CheckTypes()
{
CheckType<Color>();
CheckType<Rectangle>();
CheckType<Image>();
CheckType<Texture2D>();
CheckType<RenderTexture2D>();
CheckType<NPatchInfo>();
CheckType<GlyphInfo>();
CheckType<Font>();
CheckType<Camera2D>();
CheckType<Camera3D>();
CheckType<Mesh>();
CheckType<Shader>();
CheckType<MaterialMap>();
CheckType<Material>();
CheckType<Transform>();
CheckType<BoneInfo>();
CheckType<Model>();
CheckType<ModelAnimation>();
CheckType<Ray>();
CheckType<RayCollision>();
CheckType<BoundingBox>();
CheckType<Wave>();
CheckType<AudioStream>();
CheckType<Sound>();
CheckType<Music>();
CheckType<VrDeviceInfo>();
CheckType<VrStereoConfig>();
CheckType<RenderBatch>();
}
public class RaylibTests
{
private unsafe void CheckType<T>() where T : unmanaged
{
Assert.True(BlittableHelper.IsBlittable<T>());
}
[Fact]
public void CheckTypes()
{
CheckType<Color>();
CheckType<Rectangle>();
CheckType<Image>();
CheckType<Texture2D>();
CheckType<RenderTexture2D>();
CheckType<NPatchInfo>();
CheckType<GlyphInfo>();
CheckType<Font>();
CheckType<Camera2D>();
CheckType<Camera3D>();
CheckType<Mesh>();
CheckType<Shader>();
CheckType<MaterialMap>();
CheckType<Material>();
CheckType<Transform>();
CheckType<BoneInfo>();
CheckType<Model>();
CheckType<ModelAnimation>();
CheckType<Ray>();
CheckType<RayCollision>();
CheckType<BoundingBox>();
CheckType<Wave>();
CheckType<AudioStream>();
CheckType<Sound>();
CheckType<Music>();
CheckType<VrDeviceInfo>();
CheckType<VrStereoConfig>();
CheckType<RenderBatch>();
}
}