Skip to content

Conversation

@teo-tsirpanis
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

The EnumUtils.Parse method used to use the non-generic Enum.GetValues method to do its job, which is unsafe and produces AOT warnings.
This PR refactors it to use Enum.IsDefined instead, which does not allocate.
I also added asserts to methods in EnumUtils that ensure we use them with int-sized enums.

@CLAassistant
Copy link

CLAassistant commented Aug 6, 2022

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@antonfirsov antonfirsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

teo-tsirpanis and others added 2 commits August 7, 2022 14:17
The `EnumUtils.Parse` method used to use the non-generic `Enum.GetValues` method to do its job, which is unsafe and produces AOT warnings.
This PR refactors it to use `Enum.IsDefined` instead, which does not allocate.
I also added asserts to methods in `EnumUtils` that ensure we use them with int-sized enums.
@JimBobSquarePants
Copy link
Member

Looks great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants