LinqToXsdCore
LinqToXsdCore copied to clipboard
Missing null check in a ToXTypedElement of XTypedServices.cs
In line 36 of XTypedServices.cs there is missing a check for whether xe is null for ToXTypedElement.
Null is checked in other ToXTypedElement methods but is missing in this one. For example, a check for null is in line 75:
public static T ToXTypedElement<T>(XElement xe) where T : XTypedElement
{
if (xe == null)
{
return null;
}
T xoSubType = GetAnnotation<T>(xe);
Such a check should be added to line 36:
public static XTypedElement ToXTypedElement(XElement xe, ILinqToXsdTypeManager typeManager, Type rootType,
Type contentType)
{
XTypedElement rootElement = GetAnnotation(rootType, xe);
So that it is like this:
public static XTypedElement ToXTypedElement(XElement xe, ILinqToXsdTypeManager typeManager, Type rootType,
Type contentType)
{
if (xe == null)
{
return null;
}
XTypedElement rootElement = GetAnnotation(rootType, xe);