Skip to content

Add CollectionsMarshal.AsBytes(BitArray) #116308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -68,7 +68,6 @@ private static class Diagnostics
}

private static readonly Assembly[] s_compilationAssemblyRefs = new[] {
typeof(BitArray).Assembly,
typeof(ConfigurationBinder).Assembly,
typeof(ConfigurationBuilder).Assembly,
typeof(CultureInfo).Assembly,
@@ -80,6 +79,7 @@ private static class Diagnostics
typeof(IDictionary).Assembly,
typeof(OptionsBuilder<>).Assembly,
typeof(OptionsConfigurationServiceCollectionExtensions).Assembly,
typeof(Stack<>).Assembly,
typeof(Uri).Assembly,
};

61 changes: 32 additions & 29 deletions src/libraries/System.Collections/ref/System.Collections.cs
Original file line number Diff line number Diff line change
@@ -7,35 +7,6 @@
#if !BUILDING_CORELIB_REFERENCE
namespace System.Collections
{
public sealed partial class BitArray : System.Collections.ICollection, System.Collections.IEnumerable, System.ICloneable
{
public BitArray(bool[] values) { }
public BitArray(byte[] bytes) { }
public BitArray(System.Collections.BitArray bits) { }
public BitArray(int length) { }
public BitArray(int length, bool defaultValue) { }
public BitArray(int[] values) { }
public int Count { get { throw null; } }
public bool IsReadOnly { get { throw null; } }
public bool IsSynchronized { get { throw null; } }
public bool this[int index] { get { throw null; } set { } }
public int Length { get { throw null; } set { } }
public object SyncRoot { get { throw null; } }
public System.Collections.BitArray And(System.Collections.BitArray value) { throw null; }
public object Clone() { throw null; }
public void CopyTo(System.Array array, int index) { }
public bool Get(int index) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
public bool HasAllSet() { throw null; }
public bool HasAnySet() { throw null; }
public System.Collections.BitArray LeftShift(int count) { throw null; }
public System.Collections.BitArray Not() { throw null; }
public System.Collections.BitArray Or(System.Collections.BitArray value) { throw null; }
public System.Collections.BitArray RightShift(int count) { throw null; }
public void Set(int index, bool value) { }
public void SetAll(bool value) { }
public System.Collections.BitArray Xor(System.Collections.BitArray value) { throw null; }
}
public static partial class StructuralComparisons
{
public static System.Collections.IComparer StructuralComparer { get { throw null; } }
@@ -584,6 +555,38 @@ void System.Collections.IEnumerator.Reset() { }
}
}
#endif // !BUILDING_CORELIB_REFERENCE
namespace System.Collections
{
public sealed partial class BitArray : System.Collections.ICollection, System.Collections.IEnumerable, System.ICloneable
{
public BitArray(bool[] values) { }
public BitArray(byte[] bytes) { }
public BitArray(System.Collections.BitArray bits) { }
public BitArray(int length) { }
public BitArray(int length, bool defaultValue) { }
public BitArray(int[] values) { }
public int Count { get { throw null; } }
public bool IsReadOnly { get { throw null; } }
public bool IsSynchronized { get { throw null; } }
public bool this[int index] { get { throw null; } set { } }
public int Length { get { throw null; } set { } }
public object SyncRoot { get { throw null; } }
public System.Collections.BitArray And(System.Collections.BitArray value) { throw null; }
public object Clone() { throw null; }
public void CopyTo(System.Array array, int index) { }
public bool Get(int index) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
public bool HasAllSet() { throw null; }
public bool HasAnySet() { throw null; }
public System.Collections.BitArray LeftShift(int count) { throw null; }
public System.Collections.BitArray Not() { throw null; }
public System.Collections.BitArray Or(System.Collections.BitArray value) { throw null; }
public System.Collections.BitArray RightShift(int count) { throw null; }
public void Set(int index, bool value) { }
public void SetAll(bool value) { }
public System.Collections.BitArray Xor(System.Collections.BitArray value) { throw null; }
}
}
namespace System.Collections.Generic
{
public static partial class CollectionExtensions
9 changes: 0 additions & 9 deletions src/libraries/System.Collections/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
@@ -102,12 +102,6 @@
<data name="NotSupported_ValueCollectionSet" xml:space="preserve">
<value>Mutating a value collection derived from a dictionary is not allowed.</value>
</data>
<data name="Arg_ArrayLengthsDiffer" xml:space="preserve">
<value>Array lengths must be the same.</value>
</data>
<data name="Arg_BitArrayTypeUnsupported" xml:space="preserve">
<value>Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[].</value>
</data>
<data name="Arg_HTCapacityOverflow" xml:space="preserve">
<value>Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table.</value>
</data>
@@ -117,9 +111,6 @@
<data name="Arg_RankMultiDimNotSupported" xml:space="preserve">
<value>Only single dimensional arrays are supported for the requested action.</value>
</data>
<data name="Argument_ArrayTooLarge" xml:space="preserve">
<value>The input array length must not exceed Int32.MaxValue / {0}. Otherwise BitArray.Length would exceed Int32.MaxValue.</value>
</data>
<data name="Argument_IncompatibleArrayType" xml:space="preserve">
<value>Target array type is not compatible with the type of items in the collection.</value>
</data>
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="System\Collections\BitArray.cs" />
<Compile Include="System\Collections\ThrowHelper.cs" />
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\DebugViewDictionaryItem.cs" Link="Common\System\Collections\Generic\DebugViewDictionaryItem.cs" />
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ICollectionDebugView.cs" Link="Common\System\Collections\Generic\ICollectionDebugView.cs" />
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.