Skip to content
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

Align enum handling #54

Merged
merged 3 commits into from
Oct 11, 2020
Merged

Align enum handling #54

merged 3 commits into from
Oct 11, 2020

Conversation

devlux
Copy link
Contributor

@devlux devlux commented Oct 9, 2020

fixes #53

/// </summary>
public Func<Type, Enum, string> EnumMemberNameSelector { get; set; } = (type, val) =>
{
var converterType = type.GetCustomAttribute<JsonConverterAttribute>().ConverterType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's just add a null check here -- it would technically be possible for someone to change the UseEnumMemberName func to not check the presence of the JsonConverterAttribute which would make this throw NullReferenceException when dereferencing the return value null from GetCustomAttribute<JsonConverterAttribute>().

var converterType = type.GetCustomAttribute<JsonConverterAttribute>()?.ConverterType;

@m-wild m-wild merged commit 96442d4 into asyncapi:master Oct 11, 2020
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.

align the enum name handling with the behavior of system.text.json
2 participants