-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrated Snowflake to inline class #886
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you run ./gradlew apiDump
and commit the result? i want to know how bad it's going to be...
public constructor(value: ULong) { | ||
this.value = value.coerceIn(validValues) | ||
init { | ||
value.coerceIn(validValues) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't do what you'd expect, the coerced value isn't used
there are a few options i can think of
- change coercion to exception
- hide the constructor and do coercion in a pseudo constructor (if that's even possible, i'm not sure)
- give up on limiting snowflakes and allow creating some that might be rejected by discord's api (see Note on valid Snowflake range discord/discord-api-docs#3745)
public val validValues: ULongRange = ULong.MIN_VALUE..Long.MAX_VALUE.toULong() // 0..9223372036854775807 | ||
public val validValues: ULongRange = ULong.MIN_VALUE..ULong.MAX_VALUE // 0..9223372036854775807 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you change this?
/** | ||
* The raw value of this Snowflake as specified by the | ||
* [Discord Developer Documentation](https://discord.com/developers/docs/reference#snowflakes). | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this documentation should be kept
Value(decoder.decodeInline(descriptor).decodeLong().toULong()) | ||
Value(Snowflake(decoder.decodeInline(descriptor).decodeLong().toULong())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be delegated to Snowflake
's serializer instead
Is there an issue already for the problems with mockk? |
I've got wrong. This problem isn't related to inline classes, but to unsigned numbers. mockk/mockk#544 |
the issue you pointed to is now closed, is there any update on this? |
Yes, issue is closed, but it's not released yet |
be60171
to
eeac1bd
Compare
eeac1bd
to
40e43ad
Compare
@lukellmann seems like all works fine with |
Mockk does not yet supported good boxing\unboxing for inline classes. So most equality check related tests are broken