Skip to content

Commit

Permalink
Add warnings for ref values. Fixes #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Apr 24, 2019
1 parent 649123b commit f99c946
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Berrysoft.Unsafe/ByReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Berrysoft.Unsafe
private readonly void* _ptr;
/// <summary>
/// Initialize a <see cref="ByReference{T}"/> with a <typeparamref name="T"/> reference.
/// Note: the storage of value should be pinned.
/// </summary>
/// <param name="value">The reference.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
1 change: 1 addition & 0 deletions src/Berrysoft.Unsafe/Pointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public Pointer(IntPtr ptr)
}
/// <summary>
/// Initialize a <see cref="Pointer{T}"/> with a <typeparamref name="T"/> reference.
/// Note: the storage of value should be pinned.
/// </summary>
/// <param name="ptr">The reference.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
3 changes: 3 additions & 0 deletions src/Berrysoft.Unsafe/UnsafeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public unsafe static class UnsafeMethods
public static int GetSize<T>() => SizeOf<T>();
/// <summary>
/// Get a <see cref="Pointer{T}"/> with a <typeparamref name="T"/> reference.
/// Note: the storage of value should be pinned.
/// </summary>
/// <typeparam name="T">Type of the pointer pointed to.</typeparam>
/// <param name="value">The reference.</param>
Expand Down Expand Up @@ -47,6 +48,7 @@ public static Pointer<char> PointerOf(string str)
}
/// <summary>
/// Get a <see cref="Unsafe.ByReference{T}"/> with a <typeparamref name="T"/> reference.
/// Note: the storage of value should be pinned.
/// </summary>
/// <typeparam name="T">Type of the pointer pointed to.</typeparam>
/// <param name="value">The reference.</param>
Expand All @@ -55,6 +57,7 @@ public static Pointer<char> PointerOf(string str)
public static ByReference<T> ByReference<T>(ref T value) => new ByReference<T>(ref value);
/// <summary>
/// Get a <see cref="Unsafe.ByReference{T}"/> with a readonly <typeparamref name="T"/> reference.
/// Note: the storage of value should be pinned.
/// </summary>
/// <typeparam name="T">Type of the pointer pointed to.</typeparam>
/// <param name="value">The reference.</param>
Expand Down

0 comments on commit f99c946

Please sign in to comment.