Skip to content

Commit

Permalink
fix: CRD column generation for non-nullable Types (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic authored Oct 23, 2024
1 parent 277d669 commit 56969a5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/KubeUI/ViewModels/ResourceListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1523,12 +1523,21 @@ private static Expression<Func<T, string>> TransformToFuncOfString(Expression ex
}
else
{
Expression bodyAsString;

// Convert the body of the original expression to return a string
var bodyAsString = Expression.Condition(
Expression.Equal(expression, Expression.Constant(null, expression.Type)),
Expression.Constant(string.Empty),
Expression.Call(expression, nameof(object.ToString), Type.EmptyTypes)
);
if (Nullable.GetUnderlyingType(expression.Type) != null)
{
bodyAsString = Expression.Condition(
Expression.Equal(expression, Expression.Constant(null, expression.Type)),
Expression.Constant(string.Empty),
Expression.Call(expression, nameof(object.ToString), Type.EmptyTypes)
);
}
else
{
bodyAsString = Expression.Call(expression, nameof(object.ToString), Type.EmptyTypes);
}

// Create a new lambda expression
return Expression.Lambda<Func<T, string>>(bodyAsString, parameters);
Expand Down

0 comments on commit 56969a5

Please sign in to comment.