Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing the first option when use List<T> in FormFlow,BotFramework

I write a FormFlow demo by review the guidelines https://docs.botframework.com/en-us/csharp/builder/sdkreference/forms.html, it work well. In the demo "Simple Sandwich Bot" , Sandwich.cs , there are enum:

public List Toppings;

public List Sauce;

public enum ToppingOptions
{
    Avocado, BananaPeppers, Cucumbers, GreenBellPeppers, Jalapenos,
    Lettuce, Olives, Pickles, RedOnion, Spinach, Tomatoes
};

public enum SauceOptions
{
    ChipotleSouthwest, HoneyMustard, LightMayonnaise, RegularMayonnaise,
    Mustard, Oil, Pepper, Ranch, SweetOnion, Vinegar
};

when the code is running, and to choice ToppingOptions and SauceOptions, the first option is missing.Is this a bug? a picture to show the result

like image 224
cherish Avatar asked May 16 '26 06:05

cherish


1 Answers

First of all, in the example they declare the list as a 'ToppingOptions' value, use List<ToppingOptions> instead of List only, if it doesn't work still, try to change the first value of the enums and set it = 1, and keep the others like that

public enum ToppingOptions
{
    Avocado = 1, BananaPeppers, Cucumbers, GreenBellPeppers, Jalapenos,
    Lettuce, Olives, Pickles, RedOnion, Spinach, Tomatoes
};

public enum SauceOptions
{
    ChipotleSouthwest = 1, HoneyMustard, LightMayonnaise, RegularMayonnaise,
    Mustard, Oil, Pepper, Ranch, SweetOnion, Vinegar
};

As you said in the comment, the guidlines is describe:"If a field is based on an enum and it is not nullable, then the 0 value in the enum is considered to be null and you should start your enumeration at 1."

like image 178
Dr. Roggia Avatar answered May 18 '26 18:05

Dr. Roggia