Skip to content

Commit 91feef7

Browse files
authored
Fix nullability for enums (#1382)
1 parent b37d7a1 commit 91feef7

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/JoinRpg.Helpers/DisplayAttributeHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static string GetDisplayName([NotNull] this MemberInfo propertyInfo)
3030
/// <summary>
3131
/// Returns name specified by <see cref="DisplayNameAttribute"/> or <see cref="DisplayAttribute"/>
3232
/// </summary>
33-
public static string GetDisplayName([NotNull] this Enum enumValue)
33+
public static string GetDisplayName<TEnum>([NotNull] this TEnum enumValue) where TEnum : notnull, Enum
3434
{
3535
if (enumValue is null)
3636
{

src/JoinRpg.Portal/Views/Shared/DisplayTemplates/ClaimFullStatusView.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
@Html.DisplayFor(model => model.ClaimStatus)
55
@if (Model.ClaimDenialStatus != null && Model.AccessArguments.MasterAccess)
66
{
7-
<text >(@Model.ClaimDenialStatus.GetDisplayName())</text>
7+
<text >(@Model.ClaimDenialStatus?.GetDisplayName())</text>
88
}
99
</text>

src/JoinRpg.Portal/Views/ShowSchedule/_AppointmentPartial.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
slots="@slots"
3333
all-rooms="@(Model.AllRooms.ToString())"
3434
error-mode="@((Model.ErrorType == AppointmentErrorType.Intersection).ToString())"
35-
errors="@(Model.ErrorType.HasValue ? Model.ErrorType.GetDisplayName() : "")">
35+
errors="@(Model.ErrorType.HasValue ? Model.ErrorType?.GetDisplayName() : "")">
3636
<div class="appointment-interior" title="@title">
3737
<div class="appointment-header"><a href="@url" target="@target">@Model.DisplayName</a></div>
3838
@if (Model.ErrorType == AppointmentErrorType.NotLocated)

src/JoinRpg.WebPortal.Models/Exporters/CustomExporter.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ private static ITableColumn BoolColumn(Expression<Func<TRow, bool>> func, string
9191
}
9292

9393
[MustUseReturnValue]
94-
protected ITableColumn EnumColumn(Expression<Func<TRow, Enum>> func)
94+
protected ITableColumn EnumColumn<TEnum>(Expression<Func<TRow, Nullable<TEnum>>> func) where TEnum : struct, Enum
95+
{
96+
var member = func.AsPropertyAccess();
97+
return new TableColumn<string>(member, r => func.Compile()(r)?.GetDisplayName());
98+
}
99+
100+
[MustUseReturnValue]
101+
protected ITableColumn EnumColumn<TEnum>(Expression<Func<TRow, TEnum>> func) where TEnum : struct, Enum
95102
{
96103
var member = func.AsPropertyAccess();
97104
return new TableColumn<string>(member, r => func.Compile()(r).GetDisplayName());

0 commit comments

Comments
 (0)