-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Was getting a mysterious object reference error when using your ToHtmlTable() function. I was able to track it down to HtmlTableGenerater.GetPropertiesByAttrSkipFiliter()
private IList<System.Reflection.PropertyInfo> GetPropertiesByAttrSkipFiliter(Type type) { var props = type.GetPropertiesFromCache(); _customAttributes = CustomAttributeHelper.GetCustomAttributes(type); if (_customAttributes.FirstOrDefault() != null) { **_customAttributes = _customAttributes.Where(attr => attr.Skip == false);** var notSkipAttrsName = _customAttributes.Select(attr => attr.memberInfo.Name); props = props.Where(prop => notSkipAttrsName.Contains(prop.Name)).ToArray(); } return props; }
After some experimentation it seems as though what is causing it is that the class in my collection only has the TableColumn attribute for two out of four properties.
If I remove all instances of TableColumn this function works fine. If I make sure all properties have TableColumn attributes it also works fine. But if some properties do not have a TableColumn attribute I get the exception.
if you change line 178 (the line above) to the following the exception goes away. However only the property that has the attribute ends up in the resulting table.:
_customAttributes = _customAttributes.Where(attr => attr != null && attr.Skip == false);