CodiceFiscale generator is not deterministic
- Dominant language
- C#
- Stars
- 9.7k
- Forks
- 538
- PR merge metrics
- No merged PRs in 30d
Description
### Bogus NuGet Package
35.6.5
### .NET Version
.NET 10
### Visual Studio Version
_No response_
### What operating system are you using?
Windows
### What locale are you using with Bogus?
it
### Problem Description
Given a static seed CodiceFiscale should generate a deterministic code, like other generators, but it doesn't. It depends on GetHashCode(), which itself is not deterministic.
### LINQPad Example or Reproduction Steps
```csharp
public sealed class Player
{
public required Guid Id { get; set; }
public required string FirstName { get; set; }
public required string LastName { get; set; }
public required string TaxCode { get; set; }
}
Randomizer.Seed = new Random(9612867);
var testPlayers = new Faker("it")
.StrictMode(true)
.RuleFor(x => x.Id, f => f.Random.Guid())
.RuleFor(x => x.FirstName, f => f.Name.FirstName())
.RuleFor(x => x.LastName, f => f.Name.LastName())
.RuleFor(x => x.TaxCode, f => f.Person.CodiceFiscale());
var players = testPlayers.Generate(2);
```
### Expected Behavior
Every time I run the test using this code it should produce the exact same codes.
### Actual Behavior
Every run Bogus generates a different codes.
### Known Workarounds
_No response_
### Could you help with a pull-request?
Yes
Contributor guide
Research direction
Start from the CodiceFiscale generator and inspect how it uses GetHashCode(), then run the provided LINQPad example twice with the static seed to reproduce the differing tax codes. Done means the same generated players receive identical CodiceFiscale values across runs while preserving the other generator behavior.
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
- 35/100