Fix IDE0038
This commit is contained in:
@@ -153,7 +153,7 @@ dotnet_diagnostic.IDE0018.severity = warning
|
||||
# Use pattern matching to avoid 'as' followed by a 'null' check.
|
||||
dotnet_diagnostic.IDE0019.severity = warning
|
||||
|
||||
# Use pattern matching to avoid 'is' check followed by a cast.
|
||||
# Use pattern matching to avoid 'is' check followed by a cast (with variable).
|
||||
dotnet_diagnostic.IDE0020.severity = warning
|
||||
|
||||
# Collection initialization can be simplified.
|
||||
@@ -177,6 +177,9 @@ dotnet_diagnostic.IDE0034.severity = warning
|
||||
# Modifiers are not ordered.
|
||||
dotnet_diagnostic.IDE0036.severity = warning
|
||||
|
||||
# Use pattern matching to avoid 'is' check followed by a cast (without variable).
|
||||
dotnet_diagnostic.IDE0038.severity = warning
|
||||
|
||||
# Use local function instead of lambda.
|
||||
dotnet_diagnostic.IDE0039.severity = warning
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return Bits.GetHashCode(); }
|
||||
|
||||
public bool Equals(CPos other) { return Bits == other.Bits; }
|
||||
public override bool Equals(object obj) { return obj is CPos && Equals((CPos)obj); }
|
||||
public override bool Equals(object obj) { return obj is CPos cell && Equals(cell); }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); }
|
||||
|
||||
public bool Equals(CVec other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is CVec && Equals((CVec)obj); }
|
||||
public override bool Equals(object obj) { return obj is CVec vec && Equals(vec); }
|
||||
|
||||
public override string ToString() { return X + "," + Y; }
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return U.GetHashCode() ^ V.GetHashCode(); }
|
||||
|
||||
public bool Equals(MPos other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is MPos && Equals((MPos)obj); }
|
||||
public override bool Equals(object obj) { return obj is MPos uv && Equals(uv); }
|
||||
|
||||
public MPos Clamp(Rectangle r)
|
||||
{
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return U.GetHashCode() ^ V.GetHashCode(); }
|
||||
|
||||
public bool Equals(PPos other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is PPos && Equals((PPos)obj); }
|
||||
public override bool Equals(object obj) { return obj is PPos puv && Equals(puv); }
|
||||
|
||||
public override string ToString() { return U + "," + V; }
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return M11 ^ M22 ^ M33 ^ M44; }
|
||||
|
||||
public bool Equals(Int32Matrix4x4 other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is Int32Matrix4x4 && Equals((Int32Matrix4x4)obj); }
|
||||
public override bool Equals(object obj) { return obj is Int32Matrix4x4 matrix && Equals(matrix); }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.Primitives
|
||||
public static bool operator !=(LongBitSet<T> me, LongBitSet<T> other) { return !(me == other); }
|
||||
|
||||
public bool Equals(LongBitSet<T> other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is LongBitSet<T> && Equals((LongBitSet<T>)obj); }
|
||||
public override bool Equals(object obj) { return obj is LongBitSet<T> set && Equals(set); }
|
||||
public override int GetHashCode() { return bits.GetHashCode(); }
|
||||
|
||||
public bool IsEmpty => bits == 0;
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); }
|
||||
|
||||
public bool Equals(float2 other) { return this == other; }
|
||||
public override bool Equals(object obj) { return obj is float2 && Equals((float2)obj); }
|
||||
public override bool Equals(object obj) { return obj is float2 vec && Equals(vec); }
|
||||
|
||||
public override string ToString() { return X + "," + Y; }
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); }
|
||||
|
||||
public bool Equals(int2 other) { return this == other; }
|
||||
public override bool Equals(object obj) { return obj is int2 && Equals((int2)obj); }
|
||||
public override bool Equals(object obj) { return obj is int2 vec && Equals(vec); }
|
||||
|
||||
public override string ToString() { return X + "," + Y; }
|
||||
|
||||
|
||||
@@ -109,10 +109,9 @@ namespace OpenRA.Scripting
|
||||
}
|
||||
|
||||
// Translate LuaTable<int, object> -> object[]
|
||||
if (value is LuaTable && t.IsArray)
|
||||
if (value is LuaTable table && t.IsArray)
|
||||
{
|
||||
var innerType = t.GetElementType();
|
||||
var table = (LuaTable)value;
|
||||
var array = Array.CreateInstance(innerType, table.Count);
|
||||
var i = 0;
|
||||
|
||||
@@ -149,23 +148,25 @@ namespace OpenRA.Scripting
|
||||
|
||||
public static LuaValue ToLuaValue(this object obj, ScriptContext context)
|
||||
{
|
||||
if (obj is LuaValue)
|
||||
return (LuaValue)obj;
|
||||
{
|
||||
if (obj is LuaValue v)
|
||||
return v;
|
||||
|
||||
if (obj == null)
|
||||
return LuaNil.Instance;
|
||||
if (obj == null)
|
||||
return LuaNil.Instance;
|
||||
|
||||
if (obj is double)
|
||||
return (double)obj;
|
||||
if (obj is double d)
|
||||
return d;
|
||||
|
||||
if (obj is int)
|
||||
return (int)obj;
|
||||
if (obj is int i)
|
||||
return i;
|
||||
|
||||
if (obj is bool)
|
||||
return (bool)obj;
|
||||
if (obj is bool b)
|
||||
return b;
|
||||
|
||||
if (obj is string)
|
||||
return (string)obj;
|
||||
if (obj is string s)
|
||||
return s;
|
||||
}
|
||||
|
||||
if (obj is IScriptBindable)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return Angle.GetHashCode(); }
|
||||
|
||||
public bool Equals(WAngle other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is WAngle && Equals((WAngle)obj); }
|
||||
public override bool Equals(object obj) { return obj is WAngle angle && Equals(angle); }
|
||||
|
||||
public int Facing => Angle / 4;
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return Length.GetHashCode(); }
|
||||
|
||||
public bool Equals(WDist other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is WDist && Equals((WDist)obj); }
|
||||
public override bool Equals(object obj) { return obj is WDist dist && Equals(dist); }
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return Roll.GetHashCode() ^ Pitch.GetHashCode() ^ Yaw.GetHashCode(); }
|
||||
|
||||
public bool Equals(WRot other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is WRot && Equals((WRot)obj); }
|
||||
public override bool Equals(object obj) { return obj is WRot rot && Equals(rot); }
|
||||
|
||||
public override string ToString() { return Roll + "," + Pitch + "," + Yaw; }
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); }
|
||||
|
||||
public bool Equals(WVec other) { return other == this; }
|
||||
public override bool Equals(object obj) { return obj is WVec && Equals((WVec)obj); }
|
||||
public override bool Equals(object obj) { return obj is WVec vec && Equals(vec); }
|
||||
|
||||
public override string ToString() { return X + "," + Y + "," + Z; }
|
||||
|
||||
|
||||
@@ -637,7 +637,7 @@ namespace OpenRA
|
||||
public override int GetHashCode() { return Actor.GetHashCode() ^ Trait.GetHashCode(); }
|
||||
|
||||
public bool Equals(TraitPair<T> other) { return this == other; }
|
||||
public override bool Equals(object obj) { return obj is TraitPair<T> && Equals((TraitPair<T>)obj); }
|
||||
public override bool Equals(object obj) { return obj is TraitPair<T> pair && Equals(pair); }
|
||||
|
||||
public override string ToString() { return Actor.Info.Name + "->" + Trait.GetType().Name; }
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (palette == null)
|
||||
return r;
|
||||
else
|
||||
return r.Select(a => !a.IsDecoration && a is IPalettedRenderable ? ((IPalettedRenderable)a).WithPalette(palette) : a);
|
||||
return r.Select(a => !a.IsDecoration && a is IPalettedRenderable pr ? pr.WithPalette(palette) : a);
|
||||
}
|
||||
else
|
||||
return SpriteRenderable.None;
|
||||
|
||||
Reference in New Issue
Block a user