Annotate enumerators and extension helpers for versioned variants

This commit is contained in:
Marek Lemańczyk committed 2025-07-14 22:43:28 +02:00
1 parent 1e64c71af3
commit 3d37c1391f
8 files changed
+25

No files matched your search

@@ -7,6 +7,8 @@ namespace Recyclable.Collections
public partial class RecyclableList<T>
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: confirm if enumerator should implement a versioned interface for generated types
public struct Enumerator : IEnumerator<T>
{
private static readonly bool _isReferenceType = !typeof(T).IsValueType;
@@ -3,6 +3,7 @@ using System.Runtime.CompilerServices;
namespace Recyclable.Collections
{
[VersionedCollectionsGenerator.GenerateVersioned]
public static class RecyclableListExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -6,9 +6,12 @@ namespace Recyclable.Collections
{
public partial class RecyclableList<T> : IRecyclableVersionedList<T>
{
[VersionedCollectionsGenerator.CloneForVersioned]
VersionedEnumerator IRecyclableVersionedList<T>.GetEnumerator() => new(this);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: confirm if enumerator should implement a versioned interface for generated types
public struct VersionedEnumerator : IEnumerator<T>
{
private int _currentItemIndex;
+6
View File
@@ -364,12 +364,18 @@ namespace Recyclable.Collections
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: review if returned enumerator type should change for versioned list
public Enumerator GetEnumerator() => new(this);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: review if returned enumerator type should change for versioned list
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(this);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: review if returned enumerator type should change for versioned list
IEnumerator<T> IEnumerable<T>.GetEnumerator() => new Enumerator(this);
public void Dispose()
@@ -5,6 +5,8 @@ namespace Recyclable.Collections
{
public partial class RecyclableLongList<T>
{
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: confirm if enumerator should implement a versioned interface for generated types
public struct Enumerator : IEnumerator<T>
{
#nullable disable
@@ -3,6 +3,7 @@ using System.Runtime.CompilerServices;
namespace Recyclable.Collections
{
[VersionedCollectionsGenerator.GenerateVersioned]
public static class RecyclableLongListExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -5,9 +5,13 @@ namespace Recyclable.Collections
{
public partial class RecyclableLongList<T> : IRecyclableVersionedLongList<T>
{
[VersionedCollectionsGenerator.CloneForVersioned]
public VersionedEnumerator GetVersionedEnumerator() => new(this);
[VersionedCollectionsGenerator.CloneForVersioned]
VersionedEnumerator IRecyclableVersionedLongList<T>.GetEnumerator() => new(this);
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: confirm if enumerator should implement a versioned interface for generated types
public struct VersionedEnumerator : IEnumerator<T>
{
#nullable disable
@@ -372,8 +372,14 @@ namespace Recyclable.Collections
public void CopyTo(T[] array, int arrayIndex) => Helpers.CopyTo(_memoryBlocks, 0, _blockSize, _longCount, array, arrayIndex);
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: review if returned enumerator type should change for versioned list
public Enumerator GetEnumerator() => new(this);
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: review if returned enumerator type should change for versioned list
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(this);
[VersionedCollectionsGenerator.CloneForVersioned]
// TODO: review if returned enumerator type should change for versioned list
IEnumerator<T> IEnumerable<T>.GetEnumerator() => new Enumerator(this);
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]