bchavez / bchavez/Bogus

Bogus.Tools.Analyzer When a class contains a property with a byte[], 'default' is output for the RuleFor() instead of Random.Bytes(1)

Open
#562 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
9.7k
Forks
538
PR merge metrics
No merged PRs in 30d

Description

### Bogus NuGet Package

35.6.0

### .NET Version

net 6

### Visual Studio Version

17.10.3

### What operating system are you using?

Windows

### What locale are you using with Bogus?

en_US

### Problem Description

When a class contains a property with a byte[], 'default' is output for the RuleFor() instead of Random.Bytes(1)

### LINQPad Example or Reproduction Steps

```
public class ByteArray
{
public byte[] RowVersion { get; set; }
}

static void BogusAnalyzer()
{
var g = new Faker()
.RuleFor(b => b.RowVersion, f => default);

var o = g.Generate();
}
```

### Expected Behavior

Ideally it should set the RuleFor using the Random.Bytes(1)

```
var g = new Faker()
.RuleFor(b => b.RowVersion, f => f.Random.Bytes(1));
```

### Actual Behavior

Outputs default as the RuleFor()

### Known Workarounds

_No response_

### Could you help with a pull-request?

No

Contributor guide

Open the contributing guide

Research direction

Start at Bogus.Tools.Analyzer and reproduce the provided ByteArray RowVersion example on net 6. Trace how the byte[] property is handled and verify that the generated RuleFor() uses f.Random.Bytes(1) instead of default; the issue provides no named test or source file.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.