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

use GetValues method instead of GetNames #4828

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ public OpenApiToTypeScriptClientCommand Command
.ToArray();

/// <summary>Gets the list of date time types.</summary>
public TypeScriptDateTimeType[] DateTimeTypes { get; } = Enum.GetNames(typeof(TypeScriptDateTimeType))
.Select(t => (TypeScriptDateTimeType)Enum.Parse(typeof(TypeScriptDateTimeType), t))
.ToArray();
public TypeScriptDateTimeType[] DateTimeTypes { get; } =
(TypeScriptDateTimeType[])Enum.GetValues(typeof(TypeScriptDateTimeType));
Comment on lines +76 to +77
Copy link
Contributor

Choose a reason for hiding this comment

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

One line

Copy link
Contributor

@0liver 0liver Jun 14, 2024

Choose a reason for hiding this comment

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

How about using the generic version Enum.GetValues() ?

Suggested change
public TypeScriptDateTimeType[] DateTimeTypes { get; } =
(TypeScriptDateTimeType[])Enum.GetValues(typeof(TypeScriptDateTimeType));
public TypeScriptDateTimeType[] DateTimeTypes { get; } = Enum.GetValues<TypeScriptDateTimeType>();

Copy link
Collaborator

Choose a reason for hiding this comment

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

It makes very little difference to comment a merged PR, the work has been finished.

Copy link
Contributor Author

@testfirstcoder testfirstcoder Jun 17, 2024

Choose a reason for hiding this comment

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

How about using the generic version Enum.GetValues() ?

According to the documentation the overloaded version of the generic method GetValues is available from the version .NET Core 5.0.

The current framework version of the project NSwagStudio is .NET 4.6.2.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch, @testfirstcoder! 😅


/// <summary>Gets the list of null values.</summary>
public TypeScriptNullValue[] NullValues { get; } = Enum.GetNames(typeof(TypeScriptNullValue))
Expand Down
Loading