@@ -164,13 +164,17 @@ enumDefinition.StoreTypeSchema is null
164164 /// any release. You should only use it directly in your code with extreme caution and knowing that
165165 /// doing so can result in application failures when updating to a new Entity Framework Core release.
166166 /// </summary>
167- public void Dispose ( )
167+ /// <param name="disposing"><see langword="true"/> when disposed from Dispose(), false when called from DisposeAsync().</param>
168+ protected void Dispose ( bool disposing )
168169 {
169- if ( Interlocked . CompareExchange ( ref _isDisposed , 1 , 0 ) == 0 )
170+ if ( disposing )
170171 {
171- foreach ( var dataSource in _dataSources . Values )
172+ if ( Interlocked . CompareExchange ( ref _isDisposed , 1 , 0 ) == 0 )
172173 {
173- dataSource . Dispose ( ) ;
174+ foreach ( var dataSource in _dataSources . Values )
175+ {
176+ dataSource . Dispose ( ) ;
177+ }
174178 }
175179 }
176180 }
@@ -181,7 +185,19 @@ public void Dispose()
181185 /// any release. You should only use it directly in your code with extreme caution and knowing that
182186 /// doing so can result in application failures when updating to a new Entity Framework Core release.
183187 /// </summary>
184- public async ValueTask DisposeAsync ( )
188+ public void Dispose ( )
189+ {
190+ Dispose ( disposing : true ) ;
191+ GC . SuppressFinalize ( this ) ;
192+ }
193+
194+ /// <summary>
195+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
196+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
197+ /// any release. You should only use it directly in your code with extreme caution and knowing that
198+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
199+ /// </summary>
200+ protected async ValueTask DisposeAsyncCore ( )
185201 {
186202 if ( Interlocked . CompareExchange ( ref _isDisposed , 1 , 0 ) == 0 )
187203 {
@@ -191,4 +207,17 @@ public async ValueTask DisposeAsync()
191207 }
192208 }
193209 }
210+
211+ /// <summary>
212+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
213+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
214+ /// any release. You should only use it directly in your code with extreme caution and knowing that
215+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
216+ /// </summary>
217+ public async ValueTask DisposeAsync ( )
218+ {
219+ await DisposeAsyncCore ( ) . ConfigureAwait ( false ) ;
220+ Dispose ( disposing : false ) ;
221+ GC . SuppressFinalize ( this ) ;
222+ }
194223}
0 commit comments