Fixes #3207. Prevent usage of KeyType without parameter. #3852
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added an exception to the parameterless constructor for KeyType because it doesn't make sense to use it without a parameter
When KeyType is called without a constructor, the Count member remains uninitialized and when that remains null, it is set to uint.MaxValue which fails the overflow check.
Since the value that a particular KeyType takes on represents an index into a 1 based vector, it cannot be set to zero by zero by default. It always needs to have a valid max value and that needs to be determined by the use case. Therefore, the best approach is to prevents its usage without the parameter.
There seems to be a different but related doc bug that this fix does not address:
The documentation for KeyTypeAttribute says it can be used with uint and ulong. However, during mapping there is an overflow check performed and an exception is thrown if the value is greater than int.MaxValue - 1.
That means, we don't actually support the full range of uint and ulong.
@codemzs / @artidoro Any thoughts on whether we should fix the docs or remove the overflow check?
Fixes #nnnn
in your description to cause GitHub to automatically close the issue(s) when your PR is merged.fixes #3207