Cannot update annotations

I have a problem that make me crazy. I’m writing a funcion to update a teststep after editing. I use DelayStep as example. I change time from default 0,1 to 3 then serialize all parameters with a json string to my function (json is necessary for the web transmission).
Then deserialize to a dictionary key, value; select the step in testplan by GuiId and then update all values.
Finally I call annotations?.Write()
If I recall the step (last row) no modification found.
Where I’m wrong?
Thanks in advance for help.

        public void UpdateStep(string json_step) 
            var dict = (Dictionary<string, object>)JsonConvert.DeserializeObject(json_step, typeof(Dictionary<string,object>));
            var id = dict["GuiId"].ToString();
            var step = testPlan.Steps.GetStep(Guid.Parse(id));
            var annotations = AnnotationCollection.Annotate(step);
            var members = annotations?.Get<IMembersAnnotation>()?.Members?.ToList();
            foreach (var x in members)
                var name = x.Get<IDisplayAnnotation>().Name.ToString();
                    var value = dict[name];
                    x.Get<IObjectValueAnnotation>().Value = value;
                catch (Exception ex)

            step = testPlan.Steps.GetStep(Guid.Parse(id));
            //guiUserInterface.queryIsRunning = false;

I have two ideas:

  1. There seems to be a spelling error in dict[“GuiId”]? Ah unless you mean Gui ID and not guid?

  2. or maybe this:

var value = dict[name]; // I think value is a string
 x.Get<IObjectValueAnnotation>().Value = value; // this actually expects a Double

Maybe you could try this:

x.Get<INumberValueAnnotation>().Value = value; // this supports converting strings to numbers and numbers to strings.

Thanks Rolf,

the problem was that “value” is always a string and not all members of annotations are string.
I modified the routine of annotation update, using


to have the type of members…
How Do I cast “value” if I know datattype, directly?

The output of routine (StepDelay as example) is:

Set : Time Delay - 3 - System.Double
Set : Verdict - NotSet - OpenTap.Verdict
Set : Enabled - True - System.Boolean
Set : Step Name - Delay - System.String
Set : TypeName - Basic Steps \ Delay - System.String
Set : Error - - System.String
Set : Break Conditions - Inherit - OpenTap.BreakCondition
Set : Description - Waits a user defined amount of time before continuing. - System.String

Thanks for help

       public void SetAnnotations(ITestStep step, Dictionary<string, object> dict)
            var annotations = AnnotationCollection.Annotate(step);
            var members = annotations?.Get<IMembersAnnotation>()?.Members.ToList();
            foreach (var m in members)
                var name = m.Get<IDisplayAnnotation>().Name.ToString();
                var value = dict[name];
                var strtypedata = m.Get<IReflectionAnnotation>().ReflectionInfo.ToString();
                m.Get<IObjectValueAnnotation>().Value = value;
                Console.WriteLine($"Set : {name} - {value} - {strtypedata}");