Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix null Action.Title check in ChoiceFactory #1503

Merged
merged 2 commits into from
Mar 26, 2019
Merged

Fix null Action.Title check in ChoiceFactory #1503

merged 2 commits into from
Mar 26, 2019

Conversation

mdrichardson
Copy link
Contributor

@mdrichardson mdrichardson commented Mar 18, 2019

Fixes #1485

Per issue, if a Choice uses something like:

new Choice()
{
    Action = new CardAction()
    {
        Type = "messageBack",
        Value = "myValue",
        Title = "myTitle,
    }
}

instead of simply:

new Choice()
{
    Value = "myValue"
}

...it creates a Object reference not set to an instance of an object exception.

This is because if choice.Action.Title is null, this line:

var l = choice.Action != null && string.IsNullOrEmpty(choice.Action.Title) ? choice.Action.Title.Length : choice.Value.Length;

evaluates to:

var l = true && true = choice.Action.Title.Length

...so it checks for choice.Action.Title.Length when choice.Action.Title is null

@mdrichardson mdrichardson changed the title Fix null title in ChoiceFactory Fix null Action.Title check in ChoiceFactory Mar 18, 2019
Copy link
Contributor

@cleemullins cleemullins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Fix.

However, please add a unit test that:

  1. Fails before your change.
  2. Passes after your change.

@mdrichardson
Copy link
Contributor Author

@cleemullins

Before fix:

image

After:

image

@gabog gabog self-requested a review March 20, 2019 20:47
@gabog gabog self-assigned this Mar 20, 2019
@cleemullins cleemullins merged commit c3e1889 into microsoft:master Mar 26, 2019
@mdrichardson mdrichardson deleted the choiceFactoryNullTitleFix branch April 24, 2019 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants