mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Fix CA1513: Use ObjectDisposedException.ThrowIf
This commit is contained in:
parent
6bdc785273
commit
fe37da1b94
7 changed files with 10 additions and 22 deletions
|
|
@ -169,9 +169,6 @@ public sealed class AsmHook : IDisposable, IDalamudHook
|
|||
/// </summary>
|
||||
private void CheckDisposed()
|
||||
{
|
||||
if (this.IsDisposed)
|
||||
{
|
||||
throw new ObjectDisposedException(message: "Hook is already disposed", null);
|
||||
}
|
||||
ObjectDisposedException.ThrowIf(this.IsDisposed, this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,10 +242,7 @@ public abstract class Hook<T> : IDalamudHook where T : Delegate
|
|||
/// </summary>
|
||||
protected void CheckDisposed()
|
||||
{
|
||||
if (this.IsDisposed)
|
||||
{
|
||||
throw new ObjectDisposedException(message: "Hook is already disposed", null);
|
||||
}
|
||||
ObjectDisposedException.ThrowIf(this.IsDisposed, this);
|
||||
}
|
||||
|
||||
private static unsafe IntPtr FromImportHelper32(IntPtr baseAddress, ref PeHeader.IMAGE_IMPORT_DESCRIPTOR desc, ref PeHeader.IMAGE_DATA_DIRECTORY dir, string functionName, uint hintOrOrdinal)
|
||||
|
|
|
|||
|
|
@ -398,8 +398,7 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
|
|||
/// </summary>
|
||||
private void CreateFontsTexture()
|
||||
{
|
||||
if (this.device.IsEmpty())
|
||||
throw new ObjectDisposedException(nameof(Dx11Renderer));
|
||||
ObjectDisposedException.ThrowIf(this.device.IsEmpty(), this);
|
||||
|
||||
if (this.fontTextures.Any())
|
||||
return;
|
||||
|
|
@ -479,8 +478,7 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
|
|||
/// </summary>
|
||||
private void EnsureDeviceObjects()
|
||||
{
|
||||
if (this.device.IsEmpty())
|
||||
throw new ObjectDisposedException(nameof(Dx11Renderer));
|
||||
ObjectDisposedException.ThrowIf(this.device.IsEmpty(), this);
|
||||
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
|
|
|
|||
|
|
@ -115,16 +115,14 @@ internal sealed partial class FontAtlasFactory
|
|||
|
||||
public void AddExistingTexture(IDalamudTextureWrap wrap)
|
||||
{
|
||||
if (this.wraps is null)
|
||||
throw new ObjectDisposedException(nameof(FontAtlasBuiltData));
|
||||
ObjectDisposedException.ThrowIf(this.wraps == null, this);
|
||||
|
||||
this.wraps.Add(this.Garbage.Add(wrap));
|
||||
}
|
||||
|
||||
public int AddNewTexture(IDalamudTextureWrap wrap, bool disposeOnError)
|
||||
{
|
||||
if (this.wraps is null)
|
||||
throw new ObjectDisposedException(nameof(FontAtlasBuiltData));
|
||||
ObjectDisposedException.ThrowIf(this.wraps == null, this);
|
||||
|
||||
var handle = wrap.Handle;
|
||||
var index = this.ImTextures.IndexOf(x => x.TexID == handle);
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ internal class LockedImFont : ILockedImFont
|
|||
/// <inheritdoc/>
|
||||
public ILockedImFont NewRef()
|
||||
{
|
||||
if (this.owner is null)
|
||||
throw new ObjectDisposedException(nameof(LockedImFont));
|
||||
ObjectDisposedException.ThrowIf(this.owner == null, this);
|
||||
|
||||
var newRef = new LockedImFont(this.ImFont, this.owner);
|
||||
this.owner.AddRef();
|
||||
|
|
|
|||
|
|
@ -476,8 +476,8 @@ internal abstract class SharedImmediateTexture
|
|||
{
|
||||
var ownerCopy = this.owner;
|
||||
var wrapCopy = this.innerWrap;
|
||||
if (ownerCopy is null || wrapCopy is null)
|
||||
throw new ObjectDisposedException(nameof(RefCountableWrappingTextureWrap));
|
||||
|
||||
ObjectDisposedException.ThrowIf(ownerCopy is null || wrapCopy is null, this);
|
||||
|
||||
ownerCopy.AddRef();
|
||||
return new RefCountableWrappingTextureWrap(wrapCopy, ownerCopy);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ internal class PluginLoader : IDisposable
|
|||
|
||||
private void EnsureNotDisposed()
|
||||
{
|
||||
if (this.disposed)
|
||||
throw new ObjectDisposedException(nameof(PluginLoader));
|
||||
ObjectDisposedException.ThrowIf(this.disposed, this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue