···6464 }
6565 catch (TargetInvocationException exc) // During non-await invocations
6666 {
6767- switch (exc.InnerException)
6868- {
6969- case OperationCanceledException _:
7070- // This activator is cancelled - propagate the cancellation as-is (it will be handled silently)
7171- throw exc.InnerException;
7272-7373- case DependencyInjectionException die:
7474- // A nested activator has failed (multiple Invoke() calls) - propagate the original error
7575- throw die;
7676- }
7777-7878- // This activator has failed (single reflection call) - preserve the original stacktrace while notifying of the error
7979- throw new DependencyInjectionException { DispatchInfo = ExceptionDispatchInfo.Capture(exc.InnerException) };
6767+ ExceptionDispatchInfo.Capture(exc.InnerException).Throw();
8068 }
8169 };
8270
-10
osu.Framework/Allocation/DependencyActivator.cs
···55using System.Collections.Concurrent;
66using System.Collections.Generic;
77using System.Reflection;
88-using System.Runtime.ExceptionServices;
98using osu.Framework.Extensions.TypeExtensions;
1010-using osu.Framework.Graphics;
119using osu.Framework.Graphics.Containers;
12101311namespace osu.Framework.Allocation
···155153 : base(modifier, member, $"A property with an attached {nameof(ResolvedAttribute)} must have a private setter.")
156154 {
157155 }
158158- }
159159-160160- /// <summary>
161161- /// Occurs when dependencies dependency injection into a <see cref="Drawable"/> fails.
162162- /// </summary>
163163- internal class DependencyInjectionException : Exception
164164- {
165165- public ExceptionDispatchInfo DispatchInfo;
166156 }
167157168158 internal delegate void InjectDependencyDelegate(object target, IReadOnlyDependencyContainer dependencies);
-2
osu.Framework/Allocation/DependencyContainer.cs
···180180 /// </summary>
181181 /// <typeparam name="T">The type of the instance to inject dependencies into.</typeparam>
182182 /// <param name="instance">The instance to inject dependencies into.</param>
183183- /// <exception cref="DependencyInjectionException">When any user error has occurred.
184184- /// Rethrow <see cref="DependencyInjectionException.DispatchInfo"/> when appropriate to retrieve the original exception.</exception>
185183 /// <exception cref="OperationCanceledException">When the injection process was cancelled.</exception>
186184 public void Inject<T>(T instance)
187185 where T : class
···233233 /// Loads a <see cref="Drawable"/> child. This will not throw in the event of the load being cancelled.
234234 /// </summary>
235235 /// <param name="child">The <see cref="Drawable"/> child to load.</param>
236236- /// <exception cref="DependencyInjectionException">When a user error occurred during dependency injection.</exception>
237236 private void loadChild(Drawable child)
238237 {
239238 try
+2-17
osu.Framework/Platform/GameHost.cs
···297297 // Ensure we maintain a valid size for any children immediately scaling by the window size
298298 Root.Size = Vector2.ComponentMax(Vector2.One, Root.Size);
299299300300- try
301301- {
302302- Root.UpdateSubTree();
303303- }
304304- catch (DependencyInjectionException die)
305305- {
306306- die.DispatchInfo.Throw();
307307- }
308308-300300+ Root.UpdateSubTree();
309301 Root.UpdateSubTreeMasking(Root, Root.ScreenSpaceDrawQuad.AABBFloat);
310302311303 using (var buffer = DrawRoots.Get(UsageType.Write))
···635627636628 game.SetHost(this);
637629638638- try
639639- {
640640- root.Load(SceneGraphClock, Dependencies);
641641- }
642642- catch (DependencyInjectionException die)
643643- {
644644- die.DispatchInfo.Throw();
645645- }
630630+ root.Load(SceneGraphClock, Dependencies);
646631647632 //publish bootstrapped scene graph to all threads.
648633 Root = root;