diff --git a/README.md b/README.md
index 3eed920..d849c0b 100644
--- a/README.md
+++ b/README.md
@@ -45,6 +45,7 @@ foreach (ref readonly HeavyStruct s in view)
{
...
}
+
```
## Changelog
@@ -68,4 +69,6 @@ foreach (ref readonly HeavyStruct s in view)
Bug reports and contributions are welcome.
## License
-This package is released as open source under the **MIT License**. See the [LICENSE](LICENSE) file for more details.
+This package is released as open source under the **MIT License**.
+
+See the [LICENSE](LICENSE) file for more details.
diff --git a/Ramstack.Structures.Tests/Collections/ArrayViewExtensionsTests.cs b/Ramstack.Structures.Tests/Collections/ArrayViewExtensionsTests.cs
index 9ee94c8..07652b1 100644
--- a/Ramstack.Structures.Tests/Collections/ArrayViewExtensionsTests.cs
+++ b/Ramstack.Structures.Tests/Collections/ArrayViewExtensionsTests.cs
@@ -1,4 +1,4 @@
-namespace Ramstack.Collections;
+namespace Ramstack.Collections;
[TestFixture]
public class ArrayViewExtensionsTests
diff --git a/Ramstack.Structures.Tests/Collections/ArrayViewTests.cs b/Ramstack.Structures.Tests/Collections/ArrayViewTests.cs
index efe3eed..6f048a6 100644
--- a/Ramstack.Structures.Tests/Collections/ArrayViewTests.cs
+++ b/Ramstack.Structures.Tests/Collections/ArrayViewTests.cs
@@ -1,6 +1,4 @@
using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
namespace Ramstack.Collections;
diff --git a/Ramstack.Structures.Tests/Collections/ReadOnlyArrayTests.cs b/Ramstack.Structures.Tests/Collections/ReadOnlyArrayTests.cs
index 0b37164..bd8c74a 100644
--- a/Ramstack.Structures.Tests/Collections/ReadOnlyArrayTests.cs
+++ b/Ramstack.Structures.Tests/Collections/ReadOnlyArrayTests.cs
@@ -1,7 +1,4 @@
using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
namespace Ramstack.Collections;
diff --git a/Ramstack.Structures.Tests/Ramstack.Structures.Tests.csproj b/Ramstack.Structures.Tests/Ramstack.Structures.Tests.csproj
index 36812f6..543a7b6 100644
--- a/Ramstack.Structures.Tests/Ramstack.Structures.Tests.csproj
+++ b/Ramstack.Structures.Tests/Ramstack.Structures.Tests.csproj
@@ -12,12 +12,18 @@
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/Ramstack.Structures.Tests/Text/StringViewComparerTests.cs b/Ramstack.Structures.Tests/Text/StringViewComparerTests.cs
index b0241fc..d1db449 100644
--- a/Ramstack.Structures.Tests/Text/StringViewComparerTests.cs
+++ b/Ramstack.Structures.Tests/Text/StringViewComparerTests.cs
@@ -1,5 +1,3 @@
-using System.Globalization;
-
namespace Ramstack.Text;
[TestFixture]
diff --git a/Ramstack.Structures.Tests/Text/StringViewTests.cs b/Ramstack.Structures.Tests/Text/StringViewTests.cs
index e9d5232..9451e12 100644
--- a/Ramstack.Structures.Tests/Text/StringViewTests.cs
+++ b/Ramstack.Structures.Tests/Text/StringViewTests.cs
@@ -1,7 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Runtime.CompilerServices;
-
namespace Ramstack.Text;
[TestFixture]
diff --git a/Ramstack.Structures/Collections/ArrayViewDebugView.cs b/Ramstack.Structures/Collections/ArrayViewDebugView.cs
index a2680d1..a85533b 100644
--- a/Ramstack.Structures/Collections/ArrayViewDebugView.cs
+++ b/Ramstack.Structures/Collections/ArrayViewDebugView.cs
@@ -1,5 +1,3 @@
-using System.Diagnostics;
-
namespace Ramstack.Collections;
///
diff --git a/Ramstack.Structures/Collections/ArrayViewExtensions.cs b/Ramstack.Structures/Collections/ArrayViewExtensions.cs
index cfcc314..4229728 100644
--- a/Ramstack.Structures/Collections/ArrayViewExtensions.cs
+++ b/Ramstack.Structures/Collections/ArrayViewExtensions.cs
@@ -1,5 +1,3 @@
-using System.Runtime.CompilerServices;
-
namespace Ramstack.Collections;
///
@@ -150,10 +148,10 @@ public static ArrayView AsView(this List? list)
{
if (list is not null)
{
- var count = list.Count;
var array = ListAccessor.GetBuffer(list);
+ var count = Math.Min(list.Count, array.Length);
- return new ArrayView(array, 0, Math.Min(count, array.Length));
+ return new ArrayView(array, 0, count);
}
return ArrayView.Empty;
diff --git a/Ramstack.Structures/Collections/ArrayView`1.cs b/Ramstack.Structures/Collections/ArrayView`1.cs
index 259eb79..54ac6cc 100644
--- a/Ramstack.Structures/Collections/ArrayView`1.cs
+++ b/Ramstack.Structures/Collections/ArrayView`1.cs
@@ -1,8 +1,5 @@
using System.Collections;
using System.Collections.Immutable;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using Ramstack.Internal;
diff --git a/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs b/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs
index 5da1490..d001951 100644
--- a/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs
+++ b/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
-using System.Runtime.InteropServices;
namespace Ramstack.Collections;
diff --git a/Ramstack.Structures/Collections/ReadOnlyArray.cs b/Ramstack.Structures/Collections/ReadOnlyArray.cs
index 0e30102..763614e 100644
--- a/Ramstack.Structures/Collections/ReadOnlyArray.cs
+++ b/Ramstack.Structures/Collections/ReadOnlyArray.cs
@@ -1,5 +1,3 @@
-using JetBrains.Annotations;
-
namespace Ramstack.Collections;
///
diff --git a/Ramstack.Structures/Collections/ReadOnlyArrayExtensions.Linq.cs b/Ramstack.Structures/Collections/ReadOnlyArrayExtensions.Linq.cs
index 701058b..46a65f2 100644
--- a/Ramstack.Structures/Collections/ReadOnlyArrayExtensions.Linq.cs
+++ b/Ramstack.Structures/Collections/ReadOnlyArrayExtensions.Linq.cs
@@ -1,7 +1,3 @@
-using System.Runtime.CompilerServices;
-
-using JetBrains.Annotations;
-
namespace Ramstack.Collections;
public static partial class ReadOnlyArrayExtensions
diff --git a/Ramstack.Structures/Collections/ReadOnlyArrayExtensions.cs b/Ramstack.Structures/Collections/ReadOnlyArrayExtensions.cs
index 3d36571..9e7b85f 100644
--- a/Ramstack.Structures/Collections/ReadOnlyArrayExtensions.cs
+++ b/Ramstack.Structures/Collections/ReadOnlyArrayExtensions.cs
@@ -1,8 +1,4 @@
using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-
-using JetBrains.Annotations;
namespace Ramstack.Collections;
diff --git a/Ramstack.Structures/Collections/ReadOnlyArray`1.cs b/Ramstack.Structures/Collections/ReadOnlyArray`1.cs
index 5cf79e0..54281f3 100644
--- a/Ramstack.Structures/Collections/ReadOnlyArray`1.cs
+++ b/Ramstack.Structures/Collections/ReadOnlyArray`1.cs
@@ -1,9 +1,5 @@
using System.Collections;
using System.Collections.Immutable;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
namespace Ramstack.Collections;
@@ -105,8 +101,10 @@ public ReadOnlyArray(T item1, T item2, T item3, T item4) =>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlyArray(ReadOnlySpan items)
{
+ //
// Avoid address exposure in cases where the destination local does not actually end up escaping in any way.
// https://github.com/dotnet/runtime/pull/102808
+ //
// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
if (items.Length != 0)
@@ -306,8 +304,10 @@ public static explicit operator ReadOnlyArray(T[]? array) =>
/// A read-only array.
///
public static implicit operator ReadOnlyArray(ImmutableArray array) =>
+ //
// https://github.com/dotnet/runtime/issues/83141#issuecomment-1460324087
// Unsafe.As, ReadOnlyArray>(ref array);
+ //
new(ImmutableCollectionsMarshal.AsArray(array)!);
///
@@ -318,8 +318,6 @@ public static implicit operator ReadOnlyArray(ImmutableArray array) =>
/// A read-only array.
///
public static implicit operator ImmutableArray(ReadOnlyArray array) =>
- // https://github.com/dotnet/runtime/issues/83141#issuecomment-1460324087
- // Unsafe.As, ImmutableArray>(ref array);
ImmutableCollectionsMarshal.AsImmutableArray(array.Inner);
///
diff --git a/Ramstack.Structures/Internal/JitHelpers.cs b/Ramstack.Structures/Internal/JitHelpers.cs
index 5674f71..7fc3c8f 100644
--- a/Ramstack.Structures/Internal/JitHelpers.cs
+++ b/Ramstack.Structures/Internal/JitHelpers.cs
@@ -1,6 +1,3 @@
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
namespace Ramstack.Internal;
///
diff --git a/Ramstack.Structures/Internal/ThrowHelper.cs b/Ramstack.Structures/Internal/ThrowHelper.cs
index 30490be..38336fa 100644
--- a/Ramstack.Structures/Internal/ThrowHelper.cs
+++ b/Ramstack.Structures/Internal/ThrowHelper.cs
@@ -1,5 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
-
namespace Ramstack.Internal;
internal static class ThrowHelper
diff --git a/Ramstack.Structures/Ramstack.Structures.csproj b/Ramstack.Structures/Ramstack.Structures.csproj
index ffa5aaf..21264a8 100644
--- a/Ramstack.Structures/Ramstack.Structures.csproj
+++ b/Ramstack.Structures/Ramstack.Structures.csproj
@@ -39,12 +39,22 @@ Ramstack.Collections.ReadOnlyArray<T>
true
+
+
+
+
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/Ramstack.Structures/Text/StringView.cs b/Ramstack.Structures/Text/StringView.cs
index 93a714c..a3c0fd6 100644
--- a/Ramstack.Structures/Text/StringView.cs
+++ b/Ramstack.Structures/Text/StringView.cs
@@ -1,9 +1,4 @@
using System.Collections;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
using Ramstack.Internal;
namespace Ramstack.Text;
diff --git a/Ramstack.Structures/Text/StringViewComparer.cs b/Ramstack.Structures/Text/StringViewComparer.cs
index 74e7d33..b03c365 100644
--- a/Ramstack.Structures/Text/StringViewComparer.cs
+++ b/Ramstack.Structures/Text/StringViewComparer.cs
@@ -1,5 +1,3 @@
-using System.Globalization;
-
namespace Ramstack.Text;
///