@@ -36,13 +36,6 @@ public sealed class AnimationSet : DependencyObjectCollection
3636 /// </summary>
3737 public event EventHandler ? Completed ;
3838
39- /// <summary>
40- /// An interface representing a node in an <see cref="AnimationSet"/> instance.
41- /// </summary>
42- public interface INode
43- {
44- }
45-
4639 /// <summary>
4740 /// Gets or sets a value indicating whether top level animation nodes in this collection are invoked
4841 /// sequentially. This applies to both <see cref="AnimationScope"/> nodes (which will still trigger
@@ -124,7 +117,7 @@ public async Task StartAsync(UIElement element, CancellationToken token)
124117
125118 if ( IsSequential )
126119 {
127- foreach ( INode node in this )
120+ foreach ( object node in this )
128121 {
129122 if ( node is ITimeline timeline )
130123 {
@@ -151,6 +144,10 @@ public async Task StartAsync(UIElement element, CancellationToken token)
151144 break ;
152145 }
153146 }
147+ else
148+ {
149+ ThrowArgumentException ( ) ;
150+ }
154151
155152 // This should in theory only be necessary in the timeline branch, but doing this check
156153 // after running activities too help guard against 3rd party activities that might not
@@ -165,7 +162,7 @@ public async Task StartAsync(UIElement element, CancellationToken token)
165162 {
166163 var builder = AnimationBuilder . Create ( ) ;
167164
168- foreach ( INode node in this )
165+ foreach ( object node in this )
169166 {
170167 switch ( node )
171168 {
@@ -175,13 +172,18 @@ public async Task StartAsync(UIElement element, CancellationToken token)
175172 case IActivity activity :
176173 _ = activity . InvokeAsync ( element , token ) ;
177174 break ;
175+ default :
176+ ThrowArgumentException ( ) ;
177+ break ;
178178 }
179179 }
180180
181181 await builder . StartAsync ( element , token ) ;
182182 }
183183
184184 Completed ? . Invoke ( this , EventArgs . Empty ) ;
185+
186+ static void ThrowArgumentException ( ) => throw new ArgumentException ( $ "An animation set can only contain nodes implementing either ITimeline or IActivity") ;
185187 }
186188
187189 /// <summary>
0 commit comments