Skip to content

Commit 38c8e8f

Browse files
authored
Add CollectionsMarshal.AsBytes(BitArray) (#116308)
* Move BitArray to corelib * Add CollectionsMarshal.AsBytes(BitArray) * Update to use a byte[] backing array
1 parent 40b50b8 commit 38c8e8f

File tree

12 files changed

+1210
-1225
lines changed

12 files changed

+1210
-1225
lines changed

src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Helpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ private static class Diagnostics
6868
}
6969

7070
private static readonly Assembly[] s_compilationAssemblyRefs = new[] {
71-
typeof(BitArray).Assembly,
7271
typeof(ConfigurationBinder).Assembly,
7372
typeof(ConfigurationBuilder).Assembly,
7473
typeof(CultureInfo).Assembly,
@@ -80,6 +79,7 @@ private static class Diagnostics
8079
typeof(IDictionary).Assembly,
8180
typeof(OptionsBuilder<>).Assembly,
8281
typeof(OptionsConfigurationServiceCollectionExtensions).Assembly,
82+
typeof(Stack<>).Assembly,
8383
typeof(Uri).Assembly,
8484
};
8585

src/libraries/System.Collections/ref/System.Collections.cs

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,6 @@
77
#if !BUILDING_CORELIB_REFERENCE
88
namespace System.Collections
99
{
10-
public sealed partial class BitArray : System.Collections.ICollection, System.Collections.IEnumerable, System.ICloneable
11-
{
12-
public BitArray(bool[] values) { }
13-
public BitArray(byte[] bytes) { }
14-
public BitArray(System.Collections.BitArray bits) { }
15-
public BitArray(int length) { }
16-
public BitArray(int length, bool defaultValue) { }
17-
public BitArray(int[] values) { }
18-
public int Count { get { throw null; } }
19-
public bool IsReadOnly { get { throw null; } }
20-
public bool IsSynchronized { get { throw null; } }
21-
public bool this[int index] { get { throw null; } set { } }
22-
public int Length { get { throw null; } set { } }
23-
public object SyncRoot { get { throw null; } }
24-
public System.Collections.BitArray And(System.Collections.BitArray value) { throw null; }
25-
public object Clone() { throw null; }
26-
public void CopyTo(System.Array array, int index) { }
27-
public bool Get(int index) { throw null; }
28-
public System.Collections.IEnumerator GetEnumerator() { throw null; }
29-
public bool HasAllSet() { throw null; }
30-
public bool HasAnySet() { throw null; }
31-
public System.Collections.BitArray LeftShift(int count) { throw null; }
32-
public System.Collections.BitArray Not() { throw null; }
33-
public System.Collections.BitArray Or(System.Collections.BitArray value) { throw null; }
34-
public System.Collections.BitArray RightShift(int count) { throw null; }
35-
public void Set(int index, bool value) { }
36-
public void SetAll(bool value) { }
37-
public System.Collections.BitArray Xor(System.Collections.BitArray value) { throw null; }
38-
}
3910
public static partial class StructuralComparisons
4011
{
4112
public static System.Collections.IComparer StructuralComparer { get { throw null; } }
@@ -584,6 +555,38 @@ void System.Collections.IEnumerator.Reset() { }
584555
}
585556
}
586557
#endif // !BUILDING_CORELIB_REFERENCE
558+
namespace System.Collections
559+
{
560+
public sealed partial class BitArray : System.Collections.ICollection, System.Collections.IEnumerable, System.ICloneable
561+
{
562+
public BitArray(bool[] values) { }
563+
public BitArray(byte[] bytes) { }
564+
public BitArray(System.Collections.BitArray bits) { }
565+
public BitArray(int length) { }
566+
public BitArray(int length, bool defaultValue) { }
567+
public BitArray(int[] values) { }
568+
public int Count { get { throw null; } }
569+
public bool IsReadOnly { get { throw null; } }
570+
public bool IsSynchronized { get { throw null; } }
571+
public bool this[int index] { get { throw null; } set { } }
572+
public int Length { get { throw null; } set { } }
573+
public object SyncRoot { get { throw null; } }
574+
public System.Collections.BitArray And(System.Collections.BitArray value) { throw null; }
575+
public object Clone() { throw null; }
576+
public void CopyTo(System.Array array, int index) { }
577+
public bool Get(int index) { throw null; }
578+
public System.Collections.IEnumerator GetEnumerator() { throw null; }
579+
public bool HasAllSet() { throw null; }
580+
public bool HasAnySet() { throw null; }
581+
public System.Collections.BitArray LeftShift(int count) { throw null; }
582+
public System.Collections.BitArray Not() { throw null; }
583+
public System.Collections.BitArray Or(System.Collections.BitArray value) { throw null; }
584+
public System.Collections.BitArray RightShift(int count) { throw null; }
585+
public void Set(int index, bool value) { }
586+
public void SetAll(bool value) { }
587+
public System.Collections.BitArray Xor(System.Collections.BitArray value) { throw null; }
588+
}
589+
}
587590
namespace System.Collections.Generic
588591
{
589592
public static partial class CollectionExtensions

src/libraries/System.Collections/src/Resources/Strings.resx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@
102102
<data name="NotSupported_ValueCollectionSet" xml:space="preserve">
103103
<value>Mutating a value collection derived from a dictionary is not allowed.</value>
104104
</data>
105-
<data name="Arg_ArrayLengthsDiffer" xml:space="preserve">
106-
<value>Array lengths must be the same.</value>
107-
</data>
108-
<data name="Arg_BitArrayTypeUnsupported" xml:space="preserve">
109-
<value>Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[].</value>
110-
</data>
111105
<data name="Arg_HTCapacityOverflow" xml:space="preserve">
112106
<value>Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table.</value>
113107
</data>
@@ -117,9 +111,6 @@
117111
<data name="Arg_RankMultiDimNotSupported" xml:space="preserve">
118112
<value>Only single dimensional arrays are supported for the requested action.</value>
119113
</data>
120-
<data name="Argument_ArrayTooLarge" xml:space="preserve">
121-
<value>The input array length must not exceed Int32.MaxValue / {0}. Otherwise BitArray.Length would exceed Int32.MaxValue.</value>
122-
</data>
123114
<data name="Argument_IncompatibleArrayType" xml:space="preserve">
124115
<value>Target array type is not compatible with the type of items in the collection.</value>
125116
</data>

src/libraries/System.Collections/src/System.Collections.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<Compile Include="System\Collections\BitArray.cs" />
1413
<Compile Include="System\Collections\ThrowHelper.cs" />
1514
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\DebugViewDictionaryItem.cs" Link="Common\System\Collections\Generic\DebugViewDictionaryItem.cs" />
1615
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ICollectionDebugView.cs" Link="Common\System\Collections\Generic\ICollectionDebugView.cs" />

0 commit comments

Comments
 (0)