Open Beau-Gosse-dev opened 1 month ago
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs
. You & others like you are the reason all of this works! So thank you & happy coding! 🚀
Thanks for opening this. We added StringEnum<TEnum>
in 2.0.0
as a safer way to parse enums, so users didn't get broken when new enum values started to be returned from the GitHub API.
I can't get your reproduction to work, but I do get a warning in my IDE of
Implicit conversion of
Octokit.Webhooks.Models.UserType.Bot
fromUserType
toStringEnum<UserType>
Which makes sense if you're hitting this line
I can't quite figure out why you're getting different results though, as StringEnum<TEnum>
is a record
, and record equality is defined as:
For records, value equality means that two variables of a record type are equal if the types match and all property and field values compare equal.
Could you maybe try pullRequestEvent?.Sender?.Type.Value
to directly get the UserType
enum and avoid the implicit conversion. Or pullRequestEvent?.Sender?.Type.TryParse(out var senderType)
if you want to guard against potentially new user enum values.
Okay, we can probably just use .Value
Thanks for looking into it.
You're welcome. I'll keep this open for now to see if I can repro your original issue.
What happened?
After upgrading
Octokit.Webhooks
from1.5.1
to2.2.3
we noticed a test start failing. However it wouldn't fail when debugging. We narrowed it down to something about the way StringEnum is working.Checking a
PullRequestEvent
->Sender
->Type
againstOctokit.Webhooks.Models.UserType.Bot
was previously correctly returningtrue
, but now returnsfalse
. But if debugging, or if using the sender type before the check, the check returns true again. (Such as printing the value to console)Reproduction
test data:
Versions
upgrading
Octokit.Webhooks
from1.5.1
to2.2.3
Relevant log output
No response
Code of Conduct