Skip to content

Commit 0acd750

Browse files
committed
#49 re-virtualized SecureRandom methods
1 parent e975fa7 commit 0acd750

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<Nullable>enable</Nullable>
1010
<TargetFramework>net9.0</TargetFramework>
1111
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
12-
<Version>13.0.0</Version>
12+
<Version>13.0.1</Version>
1313
</PropertyGroup>
1414
</Project>

Spackle/SecureRandom.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using Spackle.Extensions;
2-
using System.Globalization;
1+
using System.Globalization;
32
using System.Numerics;
43
using System.Security.Cryptography;
54
using System.Text;
65

76
namespace Spackle;
87

8+
#pragma warning disable CA1716 // Identifiers should not match keywords
99
/// <summary>
1010
/// Provides random APIs backed by the security of <see cref="RandomNumberGenerator"/>.
1111
/// </summary>
@@ -336,7 +336,7 @@ public int[] GetInt32Values(uint numberOfElements, Range range, ValueGeneration
336336
/// Returns a new random <see cref="int"/> value between 0 (inclusive)
337337
/// and <c>Int32.MaxValue</c> (exclusive).
338338
/// </returns>
339-
public int Next() =>
339+
public virtual int Next() =>
340340
this.Next(int.MaxValue);
341341

342342
/// <summary>
@@ -348,7 +348,7 @@ public int Next() =>
348348
/// and <paramref name="maxValue"/> (exclusive).
349349
/// </returns>
350350
/// <exception cref="ArgumentException">Thrown if <paramref name="maxValue"/> is less than zero.</exception>
351-
public int Next(int maxValue)
351+
public virtual int Next(int maxValue)
352352
{
353353
if (maxValue < 0)
354354
{
@@ -372,7 +372,7 @@ public int Next(int maxValue)
372372
/// <exception cref="ArgumentException">
373373
/// Thrown if <paramref name="maxValue"/> is less than <paramref name="minValue"/>.
374374
/// </exception>
375-
public int Next(int minValue, int maxValue)
375+
public virtual int Next(int minValue, int maxValue)
376376
{
377377
if (maxValue < minValue)
378378
{
@@ -409,18 +409,19 @@ public bool NextBoolean() =>
409409
/// Fills the given buffer with random bits.
410410
/// </summary>
411411
/// <param name="buffer">The buffer to populate.</param>
412-
public void NextBytes(byte[] buffer) =>
412+
public virtual void NextBytes(byte[] buffer) =>
413413
this.Generator.GetBytes(buffer);
414414

415415
/// <summary>
416416
/// Gets a random <see cref="double"/> number.
417417
/// </summary>
418418
/// <returns>A <see cref="double"/> number.</returns>
419-
public double NextDouble() =>
419+
public virtual double NextDouble() =>
420420
this.Next(int.MaxValue) * MaxInt32Inverse;
421421

422422
/// <summary>
423423
/// Gets the underlying <see cref="RandomNumberGenerator"/>.
424424
/// </summary>
425425
public RandomNumberGenerator Generator { get; }
426-
}
426+
}
427+
#pragma warning restore CA1716 // Identifiers should not match keywords

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [13.0.1] - 2024.11.28
9+
10+
### Changed
11+
- Made methods on `SecureRandom` virtual that used to be `override`s (issue [#49](https://github.com/JasonBock/SpackleNet/issues/49))
12+
813
## [13.0.0] - 2024.11.27
914

1015
### Changed

0 commit comments

Comments
 (0)