chr
2026-04-05 fe750b791d5b517cc4e9bc8e99a9a75139a0cfba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Xml.Serialization;
 
namespace OpenTap.Plugins.BasicSteps
{
    public class BasicStepsAnnotator : IAnnotator
    {
        class SweepParamsAnnotation : IMultiSelect, IAvailableValuesAnnotation, IOwnedAnnotation, IStringReadOnlyValueAnnotation, IHideOnMultiSelectAnnotation
        {
            [Display("Select All")]
            class AllItems
            {
                public override string ToString()
                {
                    return "Select All";
                }
            }
 
            static AllItems allItemsSelect = new AllItems();
            static AllItems noItems = new AllItems();
 
            object[] selectedValues;
 
 
            IEnumerable available = Array.Empty<object>();
            public IEnumerable AvailableValues => available;
            List<object> allAvailable = new List<object>();
            public IEnumerable Selected
            {
                get => selectedValues;
                set => selectedValues = value.Cast<object>().ToArray();
            }
 
            public string Value {
                get
                {
                    int count = 0;
                    if(selectedValues != null)
                        count = selectedValues.Count(x => (x is AllItems) == false);
                    return string.Format("{0} selected", count);
                }
            }
            static bool memberCanSweep(IMemberData mem) => false == mem.HasAttribute<UnsweepableAttribute>();
            public void Read(object source)
            {
                if (source is ITestStep == false) return;
                List<object> allItems = new List<object>();
                available = allItems;
 
                Dictionary<IMemberData, object> members = new Dictionary<IMemberData, object>();
                getPropertiesForItem((ITestStep)source, members);
                
                foreach(var member in members)
                {
                    if (!memberCanSweep(member.Key)) 
                        continue;
                    var anot = AnnotationCollection.Create(null, member.Key);
                    var access = anot.Get<ReadOnlyMemberAnnotation>();
                    var rmember = anot.Get<IMemberAnnotation>().Member;
                    if (rmember != null && rmember.Writable)
                    {
                        if (access == null || (!access.IsReadOnly && access.IsVisible))
                        {
                            bool? browsable = rmember.GetAttribute<BrowsableAttribute>()?.Browsable;
                            if (browsable == false) continue;
                            if(browsable == null)
                            {
                                if (rmember.GetAttribute<XmlIgnoreAttribute>() != null)
                                    continue;
                            }
                            allItems.Add(member.Key);
                        }
                    }
                }
 
                foreach(var swe in (source as SweepLoop).SweepParameters)
                {
                    if (swe.Member == null) continue;
                    if (members.TryGetValue(swe.Member, out object value))
                        swe.DefaultValue = value;
                }
 
                var items = (source as SweepLoop).SweepParameters.Select(x => x.Member).Cast<object>().ToList();
                if(items.Count == allItems.Count)
                {
                    items.Insert(0, noItems);
                    allItems.Insert(0, noItems);
                }
                else
                {
                    allItems.Insert(0, allItemsSelect);
                }
                var grp = items.GroupBy(x => x is IMemberData mem ? (mem.GetDisplayAttribute().GetFullName() + mem.TypeDescriptor.Name) : "");
                allAvailable = allItems;
                available = allItems.GroupBy(x => x is IMemberData mem ? (mem.GetDisplayAttribute().GetFullName() + mem.TypeDescriptor.Name) : "")
                    .Select(x => x.FirstOrDefault()).ToArray();
                selectedValues = grp.Select(x => x.FirstOrDefault()).ToArray();
                
            }
 
            void getPropertiesForItem(ITestStep step, Dictionary<IMemberData, object> members)
            {
                if (step is TestPlanReference) return;
                foreach (ITestStep cs in step.ChildTestSteps)
                {
                    foreach(var member in TypeData.GetTypeData(cs).GetMembers())
                    {
                        if (members.ContainsKey(member) == false)
                        {
                            members.Add(member, member.GetValue(cs));
                        }
                    }
                    getPropertiesForItem(cs, members);
                }
            }
 
            public void Write(object source)
            {
                if (selectedValues == null) return;
                var otherMember = annotation.ParentAnnotation.Get<IMembersAnnotation>().Members.FirstOrDefault(x => x.Get<IMemberAnnotation>().Member.Name == nameof(SweepLoop.SweepParameters));
                var sweepPrams = otherMember.Get<IObjectValueAnnotation>().Value as List<SweepParam>;
                var avail = allAvailable.OfType<IMemberData>().ToLookup(x => x.GetDisplayAttribute().GetFullName() + x.TypeDescriptor.Name, x => x);
                HashSet<SweepParam> found = new HashSet<SweepParam>();
                int initCount = sweepPrams.FirstOrDefault()?.Values.Length ?? 0;
                Dictionary<IMemberData, object> members = null;
                
                if (selectedValues.Contains(allItemsSelect))
                    selectedValues = this.AvailableValues.Cast<object>().ToArray();
                if (selectedValues.Contains(noItems) == false && this.AvailableValues.Cast<object>().Contains(noItems))
                    selectedValues = Array.Empty<object>();
 
                var group = selectedValues.OfType<IMemberData>().Select(x => x.GetDisplayAttribute().GetFullName() + x.TypeDescriptor.Name).Distinct();
 
                foreach (var memname in group)
                {
                    var mem = avail[memname];
                    
                    SweepParam existing = null;
 
                    foreach (var smem in mem)
                    {
                        existing = sweepPrams.Find(x => x.Members.Contains(smem));
                    }
                    if(existing == null)
                    {
                        existing = new SweepParam(mem.ToArray());
                        if (members == null)
                        {
                            members = new Dictionary<IMemberData, object>();
                            getPropertiesForItem((ITestStep)source, members);
                        }
                        foreach (var smem in mem)
                        {
                            if (members.TryGetValue(smem, out object val))
                                existing.DefaultValue = val;
                        }
                        sweepPrams.Add(existing);
                    }
                    else
                    {
                        existing.Members = existing.Members.Concat(mem).Distinct().ToArray();
                    }
                    existing.Resize(initCount);
                    found.Add(existing);
                }
                sweepPrams.RemoveIf(x => found.Contains(x) == false);
                (source as SweepLoop)?.sanitizeSweepParams(false);
                otherMember.Read(source);
            }
 
            AnnotationCollection annotation;
 
            public SweepParamsAnnotation(AnnotationCollection annotation)
            {
                this.annotation = annotation;
            }
        }
 
        class SweepRow
        {
            public bool Enabled { get; set; }
            public object[] Values { get;}
            public SweepRow(bool enabled, object[] Values)
            {
                this.Values = Values;
                Enabled = enabled;
            }
        }
 
        class ValueContainerAnnotation : IObjectValueAnnotation
        {            
            public object Value { get; set; }
        }
        class SweepParamsMembers : IMembersAnnotation, IOwnedAnnotation
        {
            List<AnnotationCollection> _members = null;
            public IEnumerable<AnnotationCollection> Members {
                get{
                    if (_members != null) return _members;
                    var step2 = annotation?.ParentAnnotation.Get<SweepParamsAggregation>();
                    var r = step2.RowAnnotations;
 
                    var val = annotation.Get<IObjectValueAnnotation>().Value as SweepRow;
                    
                    var parent = annotation.ParentAnnotation.Source as SweepLoop;
                    var p = parent.SweepParameters;
                    
                    Dictionary<object, AnnotationCollection> annotated = new Dictionary<object, AnnotationCollection>();
                    foreach (var elems in r.Values)
                    {
                        var elem = elems[0];
                        if (annotated.ContainsKey(elem)) continue;
                        annotated[elem] = AnnotationCollection.Annotate(elem);
                    }
                    var allsteps = r.Select(x => annotated[x.Value[0]].AnnotateMember(x.Key)).ToArray();
                    var allMembers = allsteps;
                    
                    List<AnnotationCollection> lst = new List<AnnotationCollection>(p.Count);
                    var members = r.Keys.ToHashSet();
                    var subSet = allMembers.Where(x => members.Contains(x.Get<IMemberAnnotation>()?.Member)).ToArray();
                    var enabled = annotation.Get<IMembersAnnotation>(@from: this).Members.FirstOrDefault(x => x.Get<IMemberAnnotation>().Member.Name == "Enabled");
                    lst.Add(enabled);
                    for(int i = 0; i < p.Count; i++)
                    {
                        var p2 = p[i].Member;
                        var sub = subSet.FirstOrDefault(x => x.Get<IMemberAnnotation>().Member == p2);
                        if (sub == null)
                            continue;
                        // Sweep loop does not support EnabledIf.
                        var enabledif = sub.FirstOrDefault(x => x.GetType().Name.Contains("EnabledIfAnnotation"));
                        if(enabledif != null)
                            sub.Remove(enabledif);
                        var v = new ValueContainerAnnotation { Value = val.Values[i]};
                        // This is a bit complicated..
                        // we have to make sure that the ValueAnnotation is put very early in the chain. 
                        sub.Insert(sub.IndexWhen(x => x is IObjectValueAnnotation) + 1, v);
                        
                        lst.Add(sub);
                    }
                    
                    return (_members = lst);
                }
 
            }
 
            AnnotationCollection annotation;
            public SweepParamsMembers(AnnotationCollection annotation)
            {
                this.annotation = annotation;
            }
 
            public void Read(object source)
            {
                if (_members != null)
                    _members.ForEach(x => x.Read(source));
            }
 
            public void Write(object source)
            {
                if (_members == null) return;
                var src = source as SweepRow;
                int index = 0;
                foreach (var member in _members)
                {
                    member.Write(source);
                    if (index > 0)
                    {
                        src.Values[index - 1] = member.Get<IObjectValueAnnotation>().Value;
                    }
                    else
                    {
                        src.Enabled = (bool)member.Get<IObjectValueAnnotation>().Value;
                    }
 
                    index += 1;
                }
                
            }
        }
 
        class SweepParamsAggregation : ICollectionAnnotation, IOwnedAnnotation, IStringReadOnlyValueAnnotation, IAccessAnnotation, IHideOnMultiSelectAnnotation
        { 
            
            AnnotationCollection annotation;
            public SweepParamsAggregation(AnnotationCollection annotation)
            {
                this.annotation = annotation;
            }
 
            Dictionary<IMemberData, List<object>> rowAnnotations = new Dictionary<IMemberData, List<object>>();
 
            public Dictionary<IMemberData, List<object>> RowAnnotations
            {
                get
                {
                    if (rowAnnotations.Count == 0)
                    {
                        var steps = sweep.RecursivelyGetChildSteps(TestStepSearch.All).ToArray();
                        var properties = steps.Select(x => TypeData.GetTypeData(x).GetMembers()).ToArray();
                        rowAnnotations = new Dictionary<IMemberData, List<object>>();
                        var swparams = annotation.Get<IObjectValueAnnotation>().Value as List<SweepParam>;
                        foreach (var param in swparams)
                        {
                            if(param.Member != null)
                                rowAnnotations.Add(param.Member, new List<object>());
                        }
 
                        for (int i = 0; i < properties.Length; i++)
                        {
                            foreach(var property in properties[i])
                            {
                                if (rowAnnotations.ContainsKey(property) == false)
                                    continue;
 
                                rowAnnotations[property].Add(steps[i]);
                            }
                        }
 
                    }
                    return rowAnnotations;
                }
            }
 
            IEnumerable<AnnotationCollection> annotatedElements;
 
            public IEnumerable<AnnotationCollection> AnnotatedElements
            {
                get
                {
                    
                    if (annotatedElements == null)
                    {
                        if (sweep == null) return Enumerable.Empty<AnnotationCollection>();
                        List<AnnotationCollection> lst = new List<AnnotationCollection>();
                        for (int i = 0; i < sweep.EnabledRows.Length; i++)
                            lst.Add(annotateIndex(i));
 
                        annotatedElements = lst;
                    }
                    
                    return annotatedElements;
                }
                set => annotatedElements = value.ToArray();
            }
 
            public string Value => $"Sweep rows: {sweep?.EnabledRows.Length ?? 0}";
 
            public bool IsReadOnly => (annotation.Get<IObjectValueAnnotation>()?.Value as List<SweepParam>) == null;
 
            public bool IsVisible => true;
 
            public AnnotationCollection NewElement()
            {
                return annotateIndex(-1);
            }
 
            AnnotationCollection annotateIndex(int index = -1)
            {
                var sparams = sweep.SweepParameters;
                SweepRow row;
                if (index == -1 || index >= sweep.EnabledRows.Length)
                    row = new SweepRow(true, sparams.Select(x => x.Values.DefaultIfEmpty(x.DefaultValue).LastOrDefault()).ToArray());
                else
                    row = new SweepRow(sweep.EnabledRows[index], sparams.Select(x => x.Values[index]).ToArray());
                return this.annotation.AnnotateSub(TypeData.GetTypeData(row),row);
            }
 
            SweepLoop sweep;
            
            public void Read(object source)
            {
                sweep = annotation.ParentAnnotation.Get<IObjectValueAnnotation>()?.Value as SweepLoop;
                annotatedElements = null;
                rowAnnotations.Clear();
            }
 
            public void Write(object source)
            {
                IList lst = (IList)annotatedElements;
                if (lst == null) return;
                
                var sweepParams = sweep.SweepParameters;
                var count = lst.Count;
                foreach(var param in sweepParams)
                    param.Resize(count);
                sweep.EnabledRows = new bool[count];
 
                int index = 0;
                foreach(AnnotationCollection a in lst)
                {
                    a.Write();
                    var row = a.Get<IObjectValueAnnotation>().Value as SweepRow;
                    sweep.EnabledRows[index] = row.Enabled;
                    for (int i = 0; i < row.Values.Length; i++)
                    {
                        sweepParams[i].Values[index] = cloneIfPossible(row.Values[i], sweep);
                    }
 
                    index += 1;
                }
                
                sweep.sanitizeSweepParams(log: false); // update size of EnabledRows.
            }
            TapSerializer tapSerializer;
            object cloneIfPossible(object value, object context)
            {
                if (value == null) return null;
                if (StringConvertProvider.TryGetString(value, out string result))
                {
                    if (StringConvertProvider.TryFromString(result, TypeData.GetTypeData(value), context, out object result2))
                    {
                        return result2;
                    }
                }
                if(tapSerializer == null) tapSerializer = new TapSerializer();
                try
                {
                    return tapSerializer.DeserializeFromString(tapSerializer.SerializeToString(value),
                               TypeData.GetTypeData(value)) ?? value;
                }
                catch
                {
                    return value;
                }
            }
        }
 
        class SweepRangeMembersAnnotation : IMultiSelect, IAvailableValuesAnnotation, IOwnedAnnotation, IStringReadOnlyValueAnnotation, IAccessAnnotation, IHideOnMultiSelectAnnotation
        {
            object[] selectedValues = Array.Empty<object>();
 
            IEnumerable available = Array.Empty<object>();
            public IEnumerable AvailableValues => available;
 
            public IEnumerable Selected
            {
                get => selectedValues;
                set => selectedValues = value.Cast<object>().ToArray();
            }
            public string Value => string.Format("{0} selected", selectedValues?.Count() ?? 0);
 
            public bool IsReadOnly { get; private set; }
 
            public bool IsVisible => true;
 
            public void Read(object source)
            {
                if (source is ITestStep == false)
                {
                    IsReadOnly = true;
                    return;
                }
                
                List<object> allItems = new List<object>();
                available = allItems;
 
                Dictionary<IMemberData, object> members = SweepLoopRange.GetPropertiesForItems((ITestStep)source);
                foreach (var member in members)
                {
                    var anot = AnnotationCollection.Create(null, member.Key);
                    var access = anot.Get<ReadOnlyMemberAnnotation>();
                    var rmember = anot.Get<IMemberAnnotation>().Member;
                    if (rmember != null)
                    {
                        if (access == null || (!access.IsReadOnly && access.IsVisible))
                        {
                            bool? browsable = rmember.GetAttribute<BrowsableAttribute>()?.Browsable;
                            if (browsable == false) continue;
                            if (browsable == null)
                            {
                                if (rmember.GetAttribute<XmlIgnoreAttribute>() != null)
                                    continue;
                            }
                            allItems.Add(member.Key);
                        }
                    }
                }
 
                Selected = (source as SweepLoopRange).SweepProperties.ToArray();
            }
            
 
 
            public void Write(object source)
            {
                if (IsReadOnly) return;
                
                HashSet<IMemberData> found = new HashSet<IMemberData>();
                foreach (var _mem in selectedValues)
                {
                    var mem = (IMemberData)_mem;
                    found.Add(mem);
                }
                fac.Get<IObjectValueAnnotation>().Value = found.ToList();
            }
 
            AnnotationCollection fac;
 
            public SweepRangeMembersAnnotation(AnnotationCollection fac)
            {
                this.fac = fac;
            }
        }
 
        public double Priority => 5;
 
        class ConvertToSequenceAnnotation : IMethodAnnotation, IMergedMethodAnnotation
        {
            readonly AnnotationCollection annotation;
            public ConvertToSequenceAnnotation(AnnotationCollection annotation)
            {
                this.annotation = annotation;
            }
 
            public void Invoke()
            {
                // only ask for confirmation the first time.
                // if the user click cancel just stop.
                bool userShouldConfirm = true;
                foreach (var step in (ITestStep[])annotation.Source)
                {
                    bool userClickedProceed = ((TestPlanReference)step).ConvertToSequence(userShouldConfirm, true);
                    if (!userClickedProceed)
                        break;
 
                    userShouldConfirm = false;
                }
            }
        }
 
        class SweepUnitAttribute : UnitAttribute, IOwnedAnnotation
        {
            readonly SweepParameterRangeStep step;
            public void Update()
            {
                var unit = GetUnit();
                if (unit == null)
                {
                    Unit = "";
                    PreScaling = 1;
                    StringFormat = "";
                    UseRanges = true;
                }
                else
                {
                    Unit = unit.Unit;
                    PreScaling = unit.PreScaling;
                    StringFormat = unit.StringFormat;
                    UseRanges = unit.UseRanges;
                    UseEngineeringPrefix = unit.UseEngineeringPrefix;
                }
            }
 
 
            public SweepUnitAttribute(SweepParameterRangeStep step) : base("")
            {
                this.step = step;
            }
 
            public void Read(object source)
            {
                Update();
            }
            public void Write(object source)
            {
 
            }
 
            internal UnitAttribute GetUnit()
            {
                UnitAttribute unit = null;
                foreach (var member in step.SelectedMembers)
                {
                    if (member.GetAttribute<UnitAttribute>() is UnitAttribute unit2)
                    {
                        if (unit == null)
                            unit = unit2;
                        else
                        {
                            if (unit.Unit != unit2.Unit)
                            {
                                return null;
                            }
                            if (unit.PreScaling != unit2.PreScaling)
                                return null;
                            if (unit.StringFormat != unit2.StringFormat)
                                return null;
 
                        }
                    }
                    else
                    {
                        return null;
                    }
                }
                return unit;
 
            }
 
        }
 
        public void Annotate(AnnotationCollection annotation)
        {
            if (annotation.Get<IMemberAnnotation>()?.Member is IMemberData mem)
            {
                if (mem.Name == nameof(TestPlanReference.ConvertToSequence)
                    && annotation.Get<IMergedValueAnnotation>() != null
                    && mem.DeclaringType.DescendsTo(typeof(TestPlanReference)))
                {
                    // multi-select: remove the default method handler and use this new way.
                    annotation.RemoveType<IMethodAnnotation>();
                    annotation.Add(new ConvertToSequenceAnnotation(annotation));
                }
 
                if (annotation.Source is SweepParameterRangeStep step &&
                    (mem.Name == nameof(SweepParameterRangeStep.SweepStart)
                    || mem.Name == nameof(SweepParameterRangeStep.SweepStop)
                    || mem.Name == nameof(SweepParameterRangeStep.SweepStep)))
                {
                    annotation.Add(new SweepUnitAttribute(step));
                }
 
                if (mem.GetAttribute<HideOnMultiSelectAttribute>() is HideOnMultiSelectAttribute attr)
                    annotation.Add(attr);
                
                if (mem.TypeDescriptor is TypeData cst)
                {
                    if (mem.DeclaringType.DescendsTo(typeof(SweepLoop)))
                    {
                        if (cst.DescendsTo(typeof(IEnumerable)))
                        {
                            var elem = cst.Type.GetEnumerableElementType();
                            if (elem == typeof(IMemberData))
                                annotation.Add(new SweepParamsAnnotation(annotation));
                            if (elem == typeof(SweepParam))
                                annotation.Add(new SweepParamsAggregation(annotation));
                        }
                    }
                    else if (mem.DeclaringType.DescendsTo(typeof(SweepLoopRange)))
                    {
                        if (cst.DescendsTo(typeof(IEnumerable)))
                        {
                            var elem = cst.Type.GetEnumerableElementType();
                            if (elem == typeof(IMemberData))
                            {
                                annotation.Add(new SweepRangeMembersAnnotation(annotation));
                            }
                        }
                    }
                }
                
                if (mem is IParameterMemberData && mem.DeclaringType.DescendsTo(typeof(ISelectedParameters)))
                {
                    // If the member is a forwarded member on a loopTestStep, it should not be editable because the value
                    // is controlled in the sweep, however it should still be shown.
                    annotation.Add(new DisabledLoopMemberAnnotation(annotation, mem));
                }
                
                {
                    // logic to disable parameterizing parameters that are selected by 
                    // a sweep loop (ISelectedParameters implementor).
                    if (annotation.Source is ITestStepMenuModel model)
                    {
                        // ISelectedParameter implementing steps.
                        var steps = model.Source.OfType<ISelectedParameters>().ToArray();
                        if (steps.Length > 0)
                        {
                            var iconName = annotation.Get<IIconAnnotation>()?.IconName;
                            if ( iconName == IconNames.Parameterize || 
                                 iconName == IconNames.ParameterizeOnParent|| 
                                 iconName == IconNames.ParameterizeOnTestPlan)
                            {
                                if(steps.Any(x => x.SelectedParameters.Contains(model.Member)))
                                {
                                    annotation.Add(new DisabledLoopMemberAnnotation(steps, model.Member));
                                }
                            }
                        }
                    } 
                }
            }
 
            if (annotation.Get<IReflectionAnnotation>()?.ReflectionInfo is TypeData type && type.Type == typeof(SweepRow))
                annotation.Add(new SweepParamsMembers(annotation));
        }
        class DisabledLoopMemberAnnotation : IEnabledAnnotation
        {
            readonly AnnotationCollection annotation;
            readonly IMemberData member;
            readonly ISelectedParameters[] steps;
            public DisabledLoopMemberAnnotation(AnnotationCollection annotation, IMemberData member)
            {
                this.annotation = annotation;
                this.member = member;
            }
            public DisabledLoopMemberAnnotation(ISelectedParameters[] steps, IMemberData member)
            {
                this.member = member;
                this.steps = steps;
            }
 
            public bool IsEnabled
            {
                get
                { 
                    if (annotation?.Source is ISelectedParameters sw && sw.SelectedParameters.Contains(member))
                        return false;
                    if (steps?.Any(x => x.SelectedParameters.Contains(member)) == true)
                        return false;
                    return true;
                }
            }
        }
    }
 
    /// <summary> This attribute indicates that a property should not be accessible for multi-selecting.</summary>
    internal class HideOnMultiSelectAttribute : Attribute, IHideOnMultiSelectAnnotation
    {
        
    }
}