Skip to content

Turn Null Checks Off #2316

@chrispepper1989

Description

@chrispepper1989

Hi,

Our code broke when updating to 6.1.0 from 6.0.2 and I am pretty sure the reason is this change:
#2115

We map from a Nullable bool to a class and originally it invoked the following:

 public QuestionState(bool? asBool) : this(StateFromNullBool(asBool))
        {
            
        }

Where we set an internal enum based on the setting of the bool:

       public static QuestionStates StateFromNullBool(bool? asBool)
        {
   
            if (asBool == null)
            {
                return QuestionStates.Na;
            }

            return asBool.Value ? QuestionStates.Yes : QuestionStates.No;
        }

However now, I think due to the change above, it never goes into that constructor, when the bool is null, instead it appears to be setting the Question State itself to null. Which we don't want, is there any way we can override this behavior?

-Thanks, Chris

Source/destination types

// Put your source/destination types here

Mapping configuration

// Mapper.Initialize or just the CreateMap snippet 

Version: x.y.z

Expected behavior

Actual behavior

Steps to reproduce

// Your calls to Mapper.Map or ProjectTo here, with source/destination objects constructed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions