Cysharp / Ulid

Fast .NET C# Implementation of ULID for .NET and Unity.
MIT License
1.33k stars 57 forks source link

different ulid was generated even if randomness parameter was set #3

Closed itn3000 closed 5 years ago

itn3000 commented 5 years ago

Overview

Different ULID was generated even if using Ulid.NewUlid(DateTimeOffset d, ReadOnlySpan<byte> r).

Environment

Steps to reproduce

  1. run following procedure
            var d = DateTime.Parse("1970/1/1 00:00:00Z");
            var r = new byte[10];
            var first = Ulid.NewUlid(d, r);
            var second = Ulid.NewUlid(d, r);
            Console.WriteLine($"first={first.ToString()}, second={second.ToString()}");

Expected

first and second is same value

Actual

first and second are different

Notes

Ulid.NewUlid(DateTimeOffset t, ReadOnlySpan<byte> r) seems to ignore r parameter https://github.com/Cysharp/Ulid/blob/e33f674b1d7c9298038c20fc2479d9b0b13d2a51/src/Ulid/Ulid.cs#L160-L164

neuecc commented 5 years ago

Thank you!!!! I've uploaded 0.1.2.