Fix StyleCop warnings in OpenRA.Game

This commit is contained in:
Hellhake
2015-01-01 23:04:18 +01:00
parent e9989496c4
commit 5a97a4b63b
119 changed files with 547 additions and 529 deletions

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Primitives
public void PerformActions()
{
Action a = () => {};
Action a = () => { };
lock (syncRoot)
{
var t = Game.RunTime;
@@ -39,6 +39,7 @@ namespace OpenRA.Primitives
a = da.Action + a;
}
}
a();
}
}

View File

@@ -32,16 +32,16 @@ namespace OpenRA.Primitives
public static int GetValue(string[] val)
{
return val.Select( a => bits[a] ).Aggregate( 0, (a,b) => a | b );
return val.Select(a => bits[a]).Aggregate(0, (a, b) => a | b);
}
public static IEnumerable<string> GetStrings(int val)
{
for( var i = 0; i < 32; i++ )
for (var i = 0; i < 32; i++)
{
var x = 1 << i;
if ((val & x) != 0)
yield return bits.Single( a => a.Value == x ).Key;
yield return bits.Single(a => a.Value == x).Key;
}
}
}
@@ -58,7 +58,7 @@ namespace OpenRA.Primitives
return BitAllocator<T>.GetStrings(Value).JoinWith(",");
}
public static bool operator ==(Bits<T> me, Bits<T> other) { return (me.Value == other.Value); }
public static bool operator ==(Bits<T> me, Bits<T> other) { return me.Value == other.Value; }
public static bool operator !=(Bits<T> me, Bits<T> other) { return !(me == other); }
public bool Equals(Bits<T> other) { return other == this; }

View File

@@ -40,6 +40,7 @@ namespace OpenRA.Primitives
return result;
}
}
public bool ContainsKey(T key) { return cache.ContainsKey(key); }
public bool TryGetValue(T key, out U value) { return cache.TryGetValue(key, out value); }
public int Count { get { return cache.Count; } }

View File

@@ -18,6 +18,7 @@ namespace OpenRA.Primitives
public class ObservableCollection<T> : Collection<T>, IObservableCollection
{
public event Action<object> OnAdd = k => { };
// TODO Workaround for https://github.com/OpenRA/OpenRA/issues/6101
#pragma warning disable 67
public event Action<object> OnRemove = k => { };

View File

@@ -34,6 +34,7 @@ namespace OpenRA.Primitives
public event Action<object> OnAdd = k => { };
public event Action<object> OnRemove = k => { };
// TODO Workaround for https://github.com/OpenRA/OpenRA/issues/6101
#pragma warning disable 67
public event Action<int> OnRemoveAt = i => { };

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Primitives
static Pair()
{
Pair<char,Color>.uc = new ColorEqualityComparer();
Pair<char, Color>.uc = new ColorEqualityComparer();
}
// avoid the default crappy one

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Primitives
}
}
public bool Empty { get { return (level == 0); } }
public bool Empty { get { return level == 0; } }
T At(int level, int index) { return items[level][index]; }
T Above(int level, int index) { return items[level - 1][index >> 1]; }
@@ -62,7 +62,7 @@ namespace OpenRA.Primitives
return At(lastLevel, lastIndex);
}
public T Peek() { return At(0,0); }
public T Peek() { return At(0, 0); }
public T Pop()
{
if (level == 0 && index == 0)

View File

@@ -20,30 +20,30 @@ namespace OpenRA.Primitives
Dictionary<Type, object> dataSingular = new Dictionary<Type, object>();
Dictionary<Type, List<object>> dataMultiple = new Dictionary<Type, List<object>>();
public void Add( object val )
public void Add(object val)
{
var t = val.GetType();
foreach( var i in t.GetInterfaces() )
InnerAdd( i, val );
foreach( var tt in t.BaseTypes() )
InnerAdd( tt, val );
foreach (var i in t.GetInterfaces())
InnerAdd(i, val);
foreach (var tt in t.BaseTypes())
InnerAdd(tt, val);
}
void InnerAdd( Type t, object val )
void InnerAdd(Type t, object val)
{
List<object> objs;
object obj;
if( dataMultiple.TryGetValue( t, out objs ) )
objs.Add( val );
else if( dataSingular.TryGetValue( t, out obj ) )
if (dataMultiple.TryGetValue(t, out objs))
objs.Add(val);
else if (dataSingular.TryGetValue(t, out obj))
{
dataSingular.Remove( t );
dataMultiple.Add( t, new List<object> { obj, val } );
dataSingular.Remove(t);
dataMultiple.Add(t, new List<object> { obj, val });
}
else
dataSingular.Add( t, val );
dataSingular.Add(t, val);
}
public bool Contains<T>()
@@ -83,12 +83,12 @@ namespace OpenRA.Primitives
List<object> objs;
object obj;
if( dataMultiple.TryGetValue( typeof( T ), out objs ) )
if (dataMultiple.TryGetValue(typeof(T), out objs))
return objs.Cast<T>();
else if( dataSingular.TryGetValue( typeof( T ), out obj ) )
else if (dataSingular.TryGetValue(typeof(T), out obj))
return new T[] { (T)obj };
else
return new T[ 0 ];
return new T[0];
}
public IEnumerator GetEnumerator()
@@ -99,9 +99,9 @@ namespace OpenRA.Primitives
public static class TypeExts
{
public static IEnumerable<Type> BaseTypes( this Type t )
public static IEnumerable<Type> BaseTypes(this Type t)
{
while( t != null )
while (t != null)
{
yield return t;
t = t.BaseType;

View File

@@ -64,11 +64,11 @@ namespace OpenRA
public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); }
public static float2 operator *(float2 b, float a) { return new float2(a * b.X, a * b.Y); }
public static float2 operator *( float2 a, float2 b ) { return new float2( a.X * b.X, a.Y * b.Y ); }
public static float2 operator /( float2 a, float2 b ) { return new float2( a.X / b.X, a.Y / b.Y ); }
public static float2 operator *(float2 a, float2 b) { return new float2(a.X * b.X, a.Y * b.Y); }
public static float2 operator /(float2 a, float2 b) { return new float2(a.X / b.X, a.Y / b.Y); }
public static float2 operator /(float2 a, float b) { return new float2(a.X / b, a.Y / b); }
public static bool operator ==(float2 me, float2 other) { return (me.X == other.X && me.Y == other.Y); }
public static bool operator ==(float2 me, float2 other) { return me.X == other.X && me.Y == other.Y; }
public static bool operator !=(float2 me, float2 other) { return !(me == other); }
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); }