Skip to content

Commit f3e7733

Browse files
committed
Update DisposeScope.cs
1 parent 106a74d commit f3e7733

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/TorchSharp/DisposeScope.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal DisposeScope(DisposeScopeManager disposeScopeManager)
4040
public IReadOnlyList<IDisposable> DisposablesView {
4141
get {
4242
if (this._disposeScopeManager is null)
43-
throw new ObjectDisposedException("The dispose scope has been disposed.");
43+
throw new ObjectDisposedException(this.GetType().FullName);
4444
return Disposables.ToArray();
4545
}
4646
}
@@ -51,7 +51,7 @@ public IReadOnlyList<IDisposable> DisposablesView {
5151
public int DisposablesCount {
5252
get {
5353
if (this._disposeScopeManager is null)
54-
throw new ObjectDisposedException("The dispose scope has been disposed.");
54+
throw new ObjectDisposedException(this.GetType().FullName);
5555
return Disposables.Count;
5656
}
5757
}
@@ -153,7 +153,7 @@ public void MoveToOther(DisposeScope? scope, params IDisposable[] disposables) =
153153
public void MoveToOther(DisposeScope? scope, IEnumerable<IDisposable> disposables)
154154
{
155155
if (this._disposeScopeManager is null)
156-
throw new ObjectDisposedException("The dispose scope has been disposed.");
156+
throw new ObjectDisposedException(this.GetType().FullName);
157157
foreach (var disposable in disposables) {
158158
if (Disposables.Remove(disposable)) {
159159
AddToOther(scope, disposable);
@@ -206,7 +206,7 @@ public T Detach<T>(T disposable) where T : IDisposable
206206
public void Detach(IEnumerable<IDisposable> disposables)
207207
{
208208
if (this._disposeScopeManager is null)
209-
throw new ObjectDisposedException("The dispose scope has been disposed.");
209+
throw new ObjectDisposedException(this.GetType().FullName);
210210
foreach (var disposable in disposables) {
211211
if (Disposables.Remove(disposable)) {
212212
_disposeScopeManager.StatisticsInstance.DetachedFromScopeCount++;
@@ -220,7 +220,7 @@ public void Detach(IEnumerable<IDisposable> disposables)
220220
public void Attach(IDisposable disposable)
221221
{
222222
if (this._disposeScopeManager is null)
223-
throw new ObjectDisposedException("The dispose scope has been disposed.");
223+
throw new ObjectDisposedException(this.GetType().FullName);
224224
if (disposable is torch.Tensor tensor) {
225225
if (tensor.OwningDisposeScope == null && !tensor.IsInvalid) {
226226
_disposeScopeManager.StatisticsInstance.DetachedFromScopeCount--;
@@ -243,7 +243,7 @@ public void Attach(IDisposable disposable)
243243
public void DisposeEverythingBut(IEnumerable<IDisposable> inKeep)
244244
{
245245
if (this._disposeScopeManager is null)
246-
throw new ObjectDisposedException("The dispose scope has been disposed.");
246+
throw new ObjectDisposedException(this.GetType().FullName);
247247
// Avoiding multiple enumerations
248248
var oldList = Disposables;
249249
Disposables = inKeep.ToHashSet(ReferenceEqualityComparer<IDisposable>.Default);
@@ -336,7 +336,7 @@ public void Dispose()
336336
public void MarkAsDisposed(IDisposable disposable)
337337
{
338338
if (this._disposeScopeManager is null)
339-
throw new ObjectDisposedException("The dispose scope has been disposed.");
339+
throw new ObjectDisposedException(this.GetType().FullName);
340340
_disposeScopeManager.StatisticsInstance.DisposedInScopeCount++;
341341
Disposables.Remove(disposable);
342342
if (disposable is torch.Tensor tensor) {
@@ -354,7 +354,7 @@ public void MarkAsDisposed(IDisposable disposable)
354354
private void AddToOther(DisposeScope? scope, IDisposable disposable)
355355
{
356356
if (this._disposeScopeManager is null)
357-
throw new ObjectDisposedException("The dispose scope has been disposed.");
357+
throw new ObjectDisposedException(this.GetType().FullName);
358358
if (scope != null) {
359359
scope.Disposables.Add(disposable);
360360
} else {

0 commit comments

Comments
 (0)