Fix CA2263
This commit is contained in:
committed by
Pavel Penev
parent
332ab244a7
commit
e2296ad2d1
@@ -1043,6 +1043,9 @@ dotnet_diagnostic.CA2251.severity = warning
|
||||
# Ensure ThreadStatic is only used with static fields.
|
||||
dotnet_diagnostic.CA2259.severity = suggestion # TODO: Change to warning once using .NET 7 or later.
|
||||
|
||||
# Prefer generic overload when type is known.
|
||||
dotnet_diagnostic.CA2263.severity = none # TODO: Change to warning once mono is dropped.
|
||||
|
||||
# Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull'.
|
||||
dotnet_diagnostic.CA2264.severity = warning
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
public const int SheetCount = 8;
|
||||
static readonly string[] SheetIndexToTextureName = Exts.MakeArray(SheetCount, i => $"Texture{i}");
|
||||
static readonly int UintSize = Marshal.SizeOf(typeof(uint));
|
||||
static readonly int UintSize = Marshal.SizeOf<uint>();
|
||||
|
||||
readonly Renderer renderer;
|
||||
readonly IShader shader;
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace OpenRA
|
||||
|
||||
public virtual void Initialize(MiniYaml yaml)
|
||||
{
|
||||
Initialize((T)FieldLoader.GetValue(nameof(value), typeof(T), yaml.Value));
|
||||
Initialize(FieldLoader.GetValue<T>(nameof(value), yaml.Value));
|
||||
}
|
||||
|
||||
public virtual void Initialize(T value)
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common
|
||||
|
||||
public void Initialize(MiniYaml yaml)
|
||||
{
|
||||
Initialize((int)FieldLoader.GetValue(nameof(value), typeof(int), yaml.Value));
|
||||
Initialize(FieldLoader.GetValue<int>(nameof(value), yaml.Value));
|
||||
}
|
||||
|
||||
public void Initialize(int value)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Platforms.Default
|
||||
if (surface == IntPtr.Zero)
|
||||
throw new InvalidDataException($"Failed to create surface: {SDL.SDL_GetError()}");
|
||||
|
||||
var sur = (SDL.SDL_Surface)Marshal.PtrToStructure(surface, typeof(SDL.SDL_Surface));
|
||||
var sur = Marshal.PtrToStructure<SDL.SDL_Surface>(surface);
|
||||
Marshal.Copy(data, 0, sur.pixels, data.Length);
|
||||
|
||||
// This call very occasionally fails on Windows, but often works when retried.
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Platforms.Default
|
||||
sealed class VertexBuffer<T> : ThreadAffine, IDisposable, IVertexBuffer<T>
|
||||
where T : struct
|
||||
{
|
||||
static readonly int VertexSize = Marshal.SizeOf(typeof(T));
|
||||
static readonly int VertexSize = Marshal.SizeOf<T>();
|
||||
uint buffer;
|
||||
bool disposed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user