Skip to content

Commit

Permalink
Add xml doc comments to all public APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
BeanCheeseBurrito committed Aug 25, 2023
1 parent e7815eb commit b9ed4f1
Show file tree
Hide file tree
Showing 45 changed files with 3,580 additions and 92 deletions.
34 changes: 33 additions & 1 deletion src/Flecs.NET/Collections/UnsafeArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,32 @@

namespace Flecs.NET.Collections
{
/// <summary>
/// Unsafe array.
/// </summary>
/// <typeparam name="T"></typeparam>
public unsafe struct UnsafeArray<T> : IDisposable
{
/// <summary>
/// Data storage for the array.
/// </summary>
public void* Data { get; private set; }

/// <summary>
/// The length of the array.
/// </summary>
public int Length { get; }

/// <summary>
/// Represents whether or not the array is null.
/// </summary>
public readonly bool IsNull => Data == null;

/// <summary>
/// Creates an unsafe array with the provided length.
/// </summary>
/// <param name="length"></param>
/// <param name="isZeroed"></param>
public UnsafeArray(int length, bool isZeroed = true)
{
if (isZeroed)
Expand All @@ -21,12 +40,22 @@ public UnsafeArray(int length, bool isZeroed = true)
Length = length;
}

/// <summary>
/// Creates an unsafe array from the provided pointer and length.
/// </summary>
/// <param name="data"></param>
/// <param name="length"></param>
public UnsafeArray(void* data, int length)
{
Data = data;
Length = length;
}

/// <summary>
/// Grabs a managed reference to an object at the specified index.
/// </summary>
/// <param name="index"></param>
/// <exception cref="ArgumentException"></exception>
public readonly ref T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -39,6 +68,9 @@ public readonly ref T this[int index]
}
}

/// <summary>
/// Disposes the unsafe array and cleans up resources.
/// </summary>
public void Dispose()
{
if (Data == null)
Expand All @@ -48,4 +80,4 @@ public void Dispose()
Data = null;
}
}
}
}
40 changes: 39 additions & 1 deletion src/Flecs.NET/Collections/UnsafeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,41 @@

namespace Flecs.NET.Collections
{
/// <summary>
/// Unsafe list.
/// </summary>
/// <typeparam name="T"></typeparam>
public unsafe struct UnsafeList<T> : IDisposable
{
/// <summary>
/// Data storage for the unsafe list.
/// </summary>
public void* Data { get; private set; }

/// <summary>
/// The capacity of the unsafe list.
/// </summary>
public int Capacity { get; private set; }

/// <summary>
/// The current count of the unsafe list.
/// </summary>
public int Count { get; private set; }

/// <summary>
/// Represents whether or not the unsafe list is null.
/// </summary>
public readonly bool IsNull => Data == null;

/// <summary>
/// Represents whether or not the unsafe list stores a managed type.
/// </summary>
public readonly bool IsManaged => RuntimeHelpers.IsReferenceOrContainsReferences<T>();

/// <summary>
/// Creates an unsafe list with the specified capacity.
/// </summary>
/// <param name="capacity"></param>
public UnsafeList(int capacity)
{
if (capacity <= 0)
Expand All @@ -27,6 +53,11 @@ public UnsafeList(int capacity)
Count = 0;
}

/// <summary>
/// Gets a managed reference to the object at the specified index.
/// </summary>
/// <param name="index"></param>
/// <exception cref="ArgumentException"></exception>
public readonly ref T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -39,6 +70,10 @@ public readonly ref T this[int index]
}
}

/// <summary>
/// Adds an item to the unsafe list.
/// </summary>
/// <param name="item"></param>
public void Add(T item)
{
if (Count == Capacity)
Expand All @@ -51,6 +86,9 @@ public void Add(T item)
Managed.SetTypeRef(Data, item, Count++);
}

/// <summary>
/// Disposes the unsafe list and frees resources.
/// </summary>
public void Dispose()
{
if (Data == null)
Expand All @@ -64,4 +102,4 @@ public void Dispose()
Data = null;
}
}
}
}
3 changes: 3 additions & 0 deletions src/Flecs.NET/Core/Alert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Flecs.NET.Core
{
/// <summary>
/// A wrapper for an alert.
/// </summary>
public unsafe struct Alert
{
private Entity _entity;
Expand Down
3 changes: 3 additions & 0 deletions src/Flecs.NET/Core/AlertBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Flecs.NET.Core
{
/// <summary>
/// A wrapper around ecs_alert_desc_t.
/// </summary>
public unsafe struct AlertBuilder : IDisposable
{
private ecs_world_t* _world;
Expand Down
3 changes: 3 additions & 0 deletions src/Flecs.NET/Core/AppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Flecs.NET.Core
{
/// <summary>
/// A wrapper around ecs_app_desc_t.
/// </summary>
public unsafe struct AppBuilder : IDisposable

Check warning on line 11 in src/Flecs.NET/Core/AppBuilder.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

AppBuilder should override Equals (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1815)

Check warning on line 11 in src/Flecs.NET/Core/AppBuilder.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

AppBuilder should override the equality (==) and inequality (!=) operators (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1815)
{
private ecs_world_t* _world;
Expand Down
4 changes: 3 additions & 1 deletion src/Flecs.NET/Core/BindingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

namespace Flecs.NET.Core
{
// TODO: Add disposable functions to context structs
/// <summary>
/// A static class holding methods and types for binding contexts.
/// </summary>
public static unsafe class BindingContext
{
#if NET5_0_OR_GREATER
Expand Down
4 changes: 4 additions & 0 deletions src/Flecs.NET/Core/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

namespace Flecs.NET.Core
{
/// <summary>
/// A wrapper around table columns.
/// </summary>
/// <typeparam name="T"></typeparam>
public readonly unsafe struct Column<T> : IEquatable<Column<T>>
{
/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Flecs.NET/Core/Ecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Flecs.NET.Core
{
/// <summary>
/// A static class for storing ECS related types, delegates, and methods.
/// </summary>
public static unsafe class Ecs
{
/// <summary>
Expand Down
Loading

0 comments on commit b9ed4f1

Please sign in to comment.