-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06f2189
commit df1887d
Showing
5 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
**API count: 296** | ||
**API count: 297** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// <auto-generated /> | ||
#pragma warning disable | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Link = System.ComponentModel.DescriptionAttribute; | ||
|
||
static partial class Polyfill | ||
{ | ||
#if (NETSTANDARD || NETFRAMEWORK || NETCOREAPP2_0) && FeatureMemory | ||
/// <summary> | ||
/// Fills the elements of a specified span of bytes with random numbers. | ||
/// </summary> | ||
/// <param name="index">The array to be filled with random numbers.</param> | ||
/// <remarks>Each element of the span of bytes is set to a random number greater than or equal to 0 and less than or equal to <see cref="byte.MaxValue"/>.</remarks> | ||
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.random.nextbytes#system-random-nextbytes(system-span((system-byte)))")] | ||
public static void NextBytes( | ||
this Random target, | ||
Span<byte> buffer) | ||
{ | ||
var array = new byte[buffer.Length]; | ||
target.NextBytes(array); | ||
array.CopyTo(buffer); | ||
} | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
partial class PolyfillTests | ||
{ | ||
#if FeatureMemory | ||
[Test] | ||
public void RandomNextBytesSpan() | ||
{ | ||
// Create a new instance of Random | ||
var random = new Random(); | ||
|
||
// Create a span of bytes | ||
Span<byte> buffer = new byte[10]; | ||
|
||
// Fill the span with random bytes | ||
random.NextBytes(buffer); | ||
|
||
// Assert that the span is filled with random bytes | ||
Assert.IsTrue(buffer.ToArray().Any(b => b != 0)); | ||
} | ||
#endif | ||
} |