Skip to content

Commit e3d4f76

Browse files
committed
Null check get enum description
1 parent ec0a381 commit e3d4f76

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("1.0.42.0")]
19-
[assembly: AssemblyFileVersion("1.0.42.0")]
18+
[assembly: AssemblyVersion("1.0.43.0")]
19+
[assembly: AssemblyFileVersion("1.0.43.0")]

Griddly.Mvc/GriddlySettingsResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public static GriddlySettings GetSettings(ControllerContext context, string view
5959
}
6060
catch
6161
{
62+
// TODO: throw exception if it is bad like HttpCompileException
6263
return null;
6364
}
6465
}

Griddly.Mvc/InternalExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ internal static HtmlString GetHtmlView(string value, bool turnUrlsIntoLinks = fa
8080

8181
internal static string ToStringDescription(Enum value)
8282
{
83-
if (value == null)
83+
if (value == null || !Enum.IsDefined(value.GetType(), value))
8484
return null;
8585

8686
return GetEnumDescription(value.GetType().GetField(value.ToString()));
@@ -111,6 +111,9 @@ internal static IEnumerable<SelectListItem> ToSelectListItems<T>()
111111

112112
static string GetEnumDescription(FieldInfo fi)
113113
{
114+
if (fi == null)
115+
return null;
116+
114117
DescriptionAttribute descriptionAttribute = fi.GetCustomAttribute<DescriptionAttribute>();
115118

116119
if (descriptionAttribute != null)

0 commit comments

Comments
 (0)