@@ -40,7 +40,7 @@ internal DisposeScope(DisposeScopeManager disposeScopeManager)
40
40
public IReadOnlyList < IDisposable > DisposablesView {
41
41
get {
42
42
if ( this . _disposeScopeManager is null )
43
- throw new ObjectDisposedException ( "The dispose scope has been disposed." ) ;
43
+ throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
44
44
return Disposables . ToArray ( ) ;
45
45
}
46
46
}
@@ -51,7 +51,7 @@ public IReadOnlyList<IDisposable> DisposablesView {
51
51
public int DisposablesCount {
52
52
get {
53
53
if ( this . _disposeScopeManager is null )
54
- throw new ObjectDisposedException ( "The dispose scope has been disposed." ) ;
54
+ throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
55
55
return Disposables . Count ;
56
56
}
57
57
}
@@ -153,7 +153,7 @@ public void MoveToOther(DisposeScope? scope, params IDisposable[] disposables) =
153
153
public void MoveToOther ( DisposeScope ? scope , IEnumerable < IDisposable > disposables )
154
154
{
155
155
if ( this . _disposeScopeManager is null )
156
- throw new ObjectDisposedException ( "The dispose scope has been disposed." ) ;
156
+ throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
157
157
foreach ( var disposable in disposables ) {
158
158
if ( Disposables . Remove ( disposable ) ) {
159
159
AddToOther ( scope , disposable ) ;
@@ -206,7 +206,7 @@ public T Detach<T>(T disposable) where T : IDisposable
206
206
public void Detach ( IEnumerable < IDisposable > disposables )
207
207
{
208
208
if ( this . _disposeScopeManager is null )
209
- throw new ObjectDisposedException ( "The dispose scope has been disposed." ) ;
209
+ throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
210
210
foreach ( var disposable in disposables ) {
211
211
if ( Disposables . Remove ( disposable ) ) {
212
212
_disposeScopeManager . StatisticsInstance . DetachedFromScopeCount ++ ;
@@ -220,7 +220,7 @@ public void Detach(IEnumerable<IDisposable> disposables)
220
220
public void Attach ( IDisposable disposable )
221
221
{
222
222
if ( this . _disposeScopeManager is null )
223
- throw new ObjectDisposedException ( "The dispose scope has been disposed." ) ;
223
+ throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
224
224
if ( disposable is torch . Tensor tensor ) {
225
225
if ( tensor . OwningDisposeScope == null && ! tensor . IsInvalid ) {
226
226
_disposeScopeManager . StatisticsInstance . DetachedFromScopeCount -- ;
@@ -243,7 +243,7 @@ public void Attach(IDisposable disposable)
243
243
public void DisposeEverythingBut ( IEnumerable < IDisposable > inKeep )
244
244
{
245
245
if ( this . _disposeScopeManager is null )
246
- throw new ObjectDisposedException ( "The dispose scope has been disposed." ) ;
246
+ throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
247
247
// Avoiding multiple enumerations
248
248
var oldList = Disposables ;
249
249
Disposables = inKeep . ToHashSet ( ReferenceEqualityComparer < IDisposable > . Default ) ;
@@ -336,7 +336,7 @@ public void Dispose()
336
336
public void MarkAsDisposed ( IDisposable disposable )
337
337
{
338
338
if ( this . _disposeScopeManager is null )
339
- throw new ObjectDisposedException ( "The dispose scope has been disposed." ) ;
339
+ throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
340
340
_disposeScopeManager . StatisticsInstance . DisposedInScopeCount ++ ;
341
341
Disposables . Remove ( disposable ) ;
342
342
if ( disposable is torch . Tensor tensor ) {
@@ -354,7 +354,7 @@ public void MarkAsDisposed(IDisposable disposable)
354
354
private void AddToOther ( DisposeScope ? scope , IDisposable disposable )
355
355
{
356
356
if ( this . _disposeScopeManager is null )
357
- throw new ObjectDisposedException ( "The dispose scope has been disposed." ) ;
357
+ throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
358
358
if ( scope != null ) {
359
359
scope . Disposables . Add ( disposable ) ;
360
360
} else {
0 commit comments