<PackageReference Include="System.Runtime.Serialization.Formatters" Version="11.0.0-preview.3.26207.106" />

System.Runtime.Serialization.ObjectIDGenerator

public class ObjectIDGenerator
Generates IDs for objects.

Initializes a new instance of the ObjectIDGenerator class.

public virtual long GetId(object obj, out bool firstTime)

Returns the ID for the specified object, generating a new ID if the specified object has not already been identified by the ObjectIDGenerator.

public virtual long HasId(object obj, out bool firstTime)

Determines whether an object has already been assigned an ID.