Prevent possible null reference exception

* Prevent possible null referrence exception in `SelectItems.GetItems()`
* Other Minor changes
pull/1841/head
Eduardo Caceres 6 years ago
parent 0b1c6b1fa6
commit e15deea282

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@ -130,7 +130,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
if (!selectItems.Any(si => si.Selected))
{
var itemToBeSelected = selectItems.FirstOrDefault(si => si.Value.ToString() == selectedValue);
var itemToBeSelected = selectItems.FirstOrDefault(si => si.Value == selectedValue);
if (itemToBeSelected != null)
{

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc.Rendering;
@ -23,16 +23,16 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
while (properties.Count == 0)
{
explorer = explorer.Container;
properties = explorer.Container.Properties.Where(p => p.Metadata.PropertyName.Equals(ItemsListPropertyName)).ToList();
if (explorer.Container == null)
{
return null;
}
properties = explorer.Container.Properties.Where(p => p.Metadata.PropertyName.Equals(ItemsListPropertyName)).ToList();
}
var selectItems = (properties.First().Model as IEnumerable<SelectListItem>).ToList();
return selectItems;
}
}

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -42,9 +42,9 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
{
var errorInfo = CreateErrorInfoWithoutCode(exception);
if (exception is IHasErrorCode)
if (exception is IHasErrorCode hasErrorCodeException)
{
errorInfo.Code = (exception as IHasErrorCode).Code;
errorInfo.Code = hasErrorCodeException.Code;
}
return errorInfo;

@ -24,7 +24,7 @@ namespace Volo.Abp.Threading
public static bool IsTaskOrTaskOfT([NotNull] this Type type)
{
return type == typeof(Task) || type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Task<>);
return type == typeof(Task) || (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Task<>));
}
/// <summary>

Loading…
Cancel
Save