LinqToXsdCore icon indicating copy to clipboard operation
LinqToXsdCore copied to clipboard

Missing null check in a ToXTypedElement of XTypedServices.cs

Open ttjorvi opened this issue 3 years ago • 0 comments

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);

ttjorvi avatar Apr 06 '22 09:04 ttjorvi