From 0d3b82477ecbf7128340b6725a79413427c68748 Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Tue, 27 Dec 2022 20:27:11 +0100 Subject: Use new ArgumentNullException and ObjectDisposedException throw-helper API (#4163) --- ARMeilleure/Common/AddressTable.cs | 15 +++------------ ARMeilleure/Common/Counter.cs | 5 +---- ARMeilleure/Common/EntryTable.cs | 15 +++------------ 3 files changed, 7 insertions(+), 28 deletions(-) (limited to 'ARMeilleure/Common') diff --git a/ARMeilleure/Common/AddressTable.cs b/ARMeilleure/Common/AddressTable.cs index 7cb83fdd..9db2d00d 100644 --- a/ARMeilleure/Common/AddressTable.cs +++ b/ARMeilleure/Common/AddressTable.cs @@ -80,10 +80,7 @@ namespace ARMeilleure.Common { get { - if (_disposed) - { - throw new ObjectDisposedException(null); - } + ObjectDisposedException.ThrowIf(_disposed, this); lock (_pages) { @@ -100,10 +97,7 @@ namespace ARMeilleure.Common /// Length of is less than 2 public AddressTable(Level[] levels) { - if (levels == null) - { - throw new ArgumentNullException(nameof(levels)); - } + ArgumentNullException.ThrowIfNull(levels); if (levels.Length < 2) { @@ -141,10 +135,7 @@ namespace ARMeilleure.Common /// is not mapped public ref TEntry GetValue(ulong address) { - if (_disposed) - { - throw new ObjectDisposedException(null); - } + ObjectDisposedException.ThrowIf(_disposed, this); if (!IsValid(address)) { diff --git a/ARMeilleure/Common/Counter.cs b/ARMeilleure/Common/Counter.cs index 4b0627c1..d7210d15 100644 --- a/ARMeilleure/Common/Counter.cs +++ b/ARMeilleure/Common/Counter.cs @@ -49,10 +49,7 @@ namespace ARMeilleure.Common { get { - if (_disposed) - { - throw new ObjectDisposedException(null); - } + ObjectDisposedException.ThrowIf(_disposed, this); return ref _countTable.GetValue(_index); } diff --git a/ARMeilleure/Common/EntryTable.cs b/ARMeilleure/Common/EntryTable.cs index f3f3ce28..6f205797 100644 --- a/ARMeilleure/Common/EntryTable.cs +++ b/ARMeilleure/Common/EntryTable.cs @@ -53,10 +53,7 @@ namespace ARMeilleure.Common /// instance was disposed public int Allocate() { - if (_disposed) - { - throw new ObjectDisposedException(null); - } + ObjectDisposedException.ThrowIf(_disposed, this); lock (_allocated) { @@ -83,10 +80,7 @@ namespace ARMeilleure.Common /// instance was disposed public void Free(int index) { - if (_disposed) - { - throw new ObjectDisposedException(null); - } + ObjectDisposedException.ThrowIf(_disposed, this); lock (_allocated) { @@ -108,10 +102,7 @@ namespace ARMeilleure.Common /// Entry at is not allocated public ref TEntry GetValue(int index) { - if (_disposed) - { - throw new ObjectDisposedException(null); - } + ObjectDisposedException.ThrowIf(_disposed, this); lock (_allocated) { -- cgit v1.2.3