You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MIGRATION.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,3 +49,7 @@ To make the API more consistent, `RenderComponent` and `SetParametersAndRender`
49
49
50
50
## Removal of `ComponentParameter` and method using them
51
51
Using `ComponentParameter` and factory methods to create them is not recommend in V1 and have now been removed in V2. Instead, use the strongly typed builder pattern that enables you to pass parameters to components you render.
52
+
53
+
## `TestContext` implements `IDisposable` and `IAsyncDisposable`
54
+
The `TestContext` now implements `IDisposable` and `IAsyncDisposable`. In version 1.x, `TestContext` only implemented `IDisposable` and cleaned up asynchronous objects in the synchronous `Dispose` method. This is no longer the case, and asynchronous objects are now cleaned up in the `DisposeAsync` method.
55
+
If you register services into the container that implement `IAsyncDisposable` make sure that the test framework calls the right method.
/// Disposes of the test context resources that are asynchronous, in particular it disposes the <see cref="Services"/>
84
+
/// service provider.s
85
+
/// </summary>
86
+
protectedvirtualasyncValueTaskDisposeAsyncCore()
87
+
{
88
+
if(disposed)
89
+
return;
90
+
91
+
disposed=true;
92
+
93
+
// Ensure the renderer is disposed before all others,
94
+
// otherwise a render cycle may be ongoing and try to access
95
+
// the service provider to perform operations.
96
+
if(bunitRendereris not null)
97
+
{
98
+
awaitbunitRenderer.DisposeAsync();
99
+
}
100
+
101
+
awaitServices.DisposeAsync();
102
+
}
103
+
73
104
/// <summary>
74
105
/// Disposes of the test context resources, in particular it disposes the <see cref="Services"/>
75
-
/// service provider. Any async services registered with the service provider will disposed first,
76
-
/// but their disposal will not be awaited..
106
+
/// service provider.
77
107
/// </summary>
78
108
/// <remarks>
79
109
/// The disposing parameter should be false when called from a finalizer, and true when called from the
80
110
/// <see cref="Dispose()"/> method. In other words, it is true when deterministically called and false when non-deterministically called.
81
111
/// </remarks>
82
112
/// <param name="disposing">Set to true if called from <see cref="Dispose()"/>, false if called from a finalizer.f.</param>
83
-
[SuppressMessage("Reliability","CA2012:Use ValueTasks correctly",Justification="Explicitly ignoring DisposeAsync to avoid breaking changes to API surface.")]
0 commit comments