libplanet
libplanet copied to clipboard
Currency structure occurs CS0188 error in TargetFramework net6.0 or greater
The detailed message of the CS0188 error is shown below
error CS0188: The 'this' object cannot be used before all of its fields have been assigned.
In the Currency struct constructor, it uses a local method called GetHash to set a value in a field called Hash. This violates the rule described above.
I think the problem would be solved if the field Hash didn't need to be defined, but rather calculated and used as needed.
public Currency(IValue serialized)
{
...
Hash = GetHash(); // CS0188 error
}
https://github.com/planetarium/libplanet/blob/87c5fdffc0d7e81e9694b3ce45b27d66677b6767/Libplanet.Types/Assets/Currency.cs#L246