Use throw helpers in more places, add ObjectDisposedExceptionExtensions

このコミットが含まれているのは:
Sergio Pedri committed 2023-02-26 14:06:07 +01:00
1 親 19eab4d7af
コミット c35b2d9394
9ファイル変更
+97 -130

検索条件に一致するファイルはありません

+1 -14
ファイルの表示
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.InteropServices;
using ABI.Microsoft.Graphics.Canvas;
@@ -69,10 +68,7 @@ unsafe partial class CanvasEffect
{
lock (this.lockObject)
{
if (this.isDisposed)
{
ThrowObjectDisposedException();
}
default(ObjectDisposedException).ThrowIf(this.isDisposed, this);
this.canvasImage ??= CreateCanvasImage();
@@ -99,13 +95,4 @@ unsafe partial class CanvasEffect
canvasImageUnknown.CopyTo(canvasImageInterop).Assert();
}
/// <summary>
/// Throws a new <see cref="ObjectDisposedException"/>.
/// </summary>
[DoesNotReturn]
public void ThrowObjectDisposedException()
{
throw new ObjectDisposedException(ToString(), "The current effect has been disposed and can no longer be used.");
}
}
@@ -108,30 +108,30 @@ partial class PixelShaderEffect<T>
bool ICollection.IsSynchronized => true;
/// <inheritdoc/>
object ICollection.SyncRoot => throw new NotSupportedException("ICollection.SyncRoot is not supported for ResourceTextureManagerCollection.");
object ICollection.SyncRoot => default(NotSupportedException).Throw<object>();
/// <inheritdoc/>
void ICollection<D2D1ResourceTextureManager?>.Add(D2D1ResourceTextureManager? item)
{
throw new NotSupportedException("ICollection<T>.Add is not supported for ResourceTextureManagerCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
int IList.Add(object value)
{
throw new NotSupportedException("IList.Add is not supported for ResourceTextureManagerCollection.");
return default(NotSupportedException).Throw<int>();
}
/// <inheritdoc/>
void ICollection<D2D1ResourceTextureManager?>.Clear()
{
throw new NotSupportedException("ICollection<T>.Clear is not supported for ResourceTextureManagerCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
void IList.Clear()
{
throw new NotSupportedException("IList.Clear is not supported for ResourceTextureManagerCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
@@ -185,37 +185,37 @@ partial class PixelShaderEffect<T>
/// <inheritdoc/>
void IList<D2D1ResourceTextureManager?>.Insert(int index, D2D1ResourceTextureManager? item)
{
throw new NotSupportedException("IList<T>.Insert is not supported for ResourceTextureManagerCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
void IList.Insert(int index, object value)
{
throw new NotSupportedException("IList.Insert is not supported for ResourceTextureManagerCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
bool ICollection<D2D1ResourceTextureManager?>.Remove(D2D1ResourceTextureManager? item)
{
throw new NotSupportedException("ICollection<T>.Remove is not supported for ResourceTextureManagerCollection.");
return default(NotSupportedException).Throw<bool>();
}
/// <inheritdoc/>
void IList.Remove(object value)
{
throw new NotSupportedException("IList.Remove is not supported for ResourceTextureManagerCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
void IList<D2D1ResourceTextureManager?>.RemoveAt(int index)
{
throw new NotSupportedException("IList<T>.RemoveAt is not supported for ResourceTextureManagerCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
void IList.RemoveAt(int index)
{
throw new NotSupportedException("IList.RemoveAt is not supported for ResourceTextureManagerCollection.");
default(NotSupportedException).Throw();
}
/// <summary>
+11 -11
ファイルの表示
@@ -94,30 +94,30 @@ partial class PixelShaderEffect<T>
bool ICollection.IsSynchronized => true;
/// <inheritdoc/>
object ICollection.SyncRoot => throw new NotSupportedException("ICollection.SyncRoot is not supported for SourceCollection.");
object ICollection.SyncRoot => default(NotSupportedException).Throw<object>();
/// <inheritdoc/>
void ICollection<IGraphicsEffectSource?>.Add(IGraphicsEffectSource? item)
{
throw new NotSupportedException("ICollection<T>.Add is not supported for SourceCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
int IList.Add(object value)
{
throw new NotSupportedException("IList.Add is not supported for SourceCollection.");
return default(NotSupportedException).Throw<int>();
}
/// <inheritdoc/>
void ICollection<IGraphicsEffectSource?>.Clear()
{
throw new NotSupportedException("ICollection<T>.Clear is not supported for SourceCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
void IList.Clear()
{
throw new NotSupportedException("IList.Clear is not supported for SourceCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
@@ -171,37 +171,37 @@ partial class PixelShaderEffect<T>
/// <inheritdoc/>
void IList<IGraphicsEffectSource?>.Insert(int index, IGraphicsEffectSource? item)
{
throw new NotSupportedException("IList<T>.Insert is not supported for SourceCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
void IList.Insert(int index, object value)
{
throw new NotSupportedException("IList.Insert is not supported for SourceCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
bool ICollection<IGraphicsEffectSource?>.Remove(IGraphicsEffectSource? item)
{
throw new NotSupportedException("ICollection<T>.Remove is not supported for SourceCollection.");
return default(NotSupportedException).Throw<bool>();
}
/// <inheritdoc/>
void IList.Remove(object value)
{
throw new NotSupportedException("IList.Remove is not supported for SourceCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
void IList<IGraphicsEffectSource?>.RemoveAt(int index)
{
throw new NotSupportedException("IList<T>.RemoveAt is not supported for SourceCollection.");
default(NotSupportedException).Throw();
}
/// <inheritdoc/>
void IList.RemoveAt(int index)
{
throw new NotSupportedException("IList.RemoveAt is not supported for SourceCollection.");
default(NotSupportedException).Throw();
}
/// <summary>