StyleCop clean OpenRA.Game

This commit is contained in:
Matthias Mailänder
2015-01-02 15:11:36 +01:00
parent 9dd607c846
commit 44cd174a8d
61 changed files with 628 additions and 581 deletions

View File

@@ -18,19 +18,19 @@ namespace OpenRA.Primitives
{
public ObservableSortedDictionary(IComparer<TKey> comparer)
{
InnerDict = new SortedDictionary<TKey, TValue>(comparer);
innerDict = new SortedDictionary<TKey, TValue>(comparer);
}
public override void Add(TKey key, TValue value)
{
InnerDict.Add(key, value);
innerDict.Add(key, value);
FireOnRefresh();
}
}
public class ObservableDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IObservableCollection
{
protected IDictionary<TKey, TValue> InnerDict;
protected IDictionary<TKey, TValue> innerDict;
public event Action<object> OnAdd = k => { };
public event Action<object> OnRemove = k => { };
@@ -51,18 +51,18 @@ namespace OpenRA.Primitives
public ObservableDictionary(IEqualityComparer<TKey> comparer)
{
InnerDict = new Dictionary<TKey, TValue>(comparer);
innerDict = new Dictionary<TKey, TValue>(comparer);
}
public virtual void Add(TKey key, TValue value)
{
InnerDict.Add(key, value);
innerDict.Add(key, value);
OnAdd(key);
}
public bool Remove(TKey key)
{
var found = InnerDict.Remove(key);
var found = innerDict.Remove(key);
if (found)
OnRemove(key);
return found;
@@ -70,32 +70,32 @@ namespace OpenRA.Primitives
public bool ContainsKey(TKey key)
{
return InnerDict.ContainsKey(key);
return innerDict.ContainsKey(key);
}
public ICollection<TKey> Keys { get { return InnerDict.Keys; } }
public ICollection<TValue> Values { get { return InnerDict.Values; } }
public ICollection<TKey> Keys { get { return innerDict.Keys; } }
public ICollection<TValue> Values { get { return innerDict.Values; } }
public bool TryGetValue(TKey key, out TValue value)
{
return InnerDict.TryGetValue(key, out value);
return innerDict.TryGetValue(key, out value);
}
public TValue this[TKey key]
{
get { return InnerDict[key]; }
set { InnerDict[key] = value; }
get { return innerDict[key]; }
set { innerDict[key] = value; }
}
public void Clear()
{
InnerDict.Clear();
innerDict.Clear();
OnRefresh();
}
public int Count
{
get { return InnerDict.Count; }
get { return innerDict.Count; }
}
public void Add(KeyValuePair<TKey, TValue> item)
@@ -105,17 +105,17 @@ namespace OpenRA.Primitives
public bool Contains(KeyValuePair<TKey, TValue> item)
{
return InnerDict.Contains(item);
return innerDict.Contains(item);
}
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
InnerDict.CopyTo(array, arrayIndex);
innerDict.CopyTo(array, arrayIndex);
}
public bool IsReadOnly
{
get { return InnerDict.IsReadOnly; }
get { return innerDict.IsReadOnly; }
}
public bool Remove(KeyValuePair<TKey, TValue> item)
@@ -125,17 +125,17 @@ namespace OpenRA.Primitives
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return InnerDict.GetEnumerator();
return innerDict.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return InnerDict.GetEnumerator();
return innerDict.GetEnumerator();
}
public IEnumerable ObservedItems
{
get { return InnerDict.Keys; }
get { return innerDict.Keys; }
}
}
}

View File

@@ -24,12 +24,12 @@ namespace OpenRA.Primitives
Second = second;
}
internal static IEqualityComparer<T> tc = EqualityComparer<T>.Default;
internal static IEqualityComparer<U> uc = EqualityComparer<U>.Default;
internal static IEqualityComparer<T> Tcomparer = EqualityComparer<T>.Default;
internal static IEqualityComparer<U> Ucomparer = EqualityComparer<U>.Default;
public static bool operator ==(Pair<T, U> a, Pair<T, U> b)
{
return tc.Equals(a.First, b.First) && uc.Equals(a.Second, b.Second);
return Tcomparer.Equals(a.First, b.First) && Ucomparer.Equals(a.Second, b.Second);
}
public static bool operator !=(Pair<T, U> a, Pair<T, U> b)
@@ -74,7 +74,7 @@ namespace OpenRA.Primitives
static Pair()
{
Pair<char, Color>.uc = new ColorEqualityComparer();
Pair<char, Color>.Ucomparer = new ColorEqualityComparer();
}
// avoid the default crappy one

View File

@@ -9,11 +9,13 @@
#endregion
using System;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Runtime.InteropServices;
namespace OpenRA
{
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
[StructLayout(LayoutKind.Sequential)]
public struct float2
{

View File

@@ -9,14 +9,15 @@
#endregion
using System;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
namespace OpenRA
{
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
public struct int2
{
public int X, Y;
public int2(int x, int y) { this.X = x; this.Y = y; }
public int2(Point p) { X = p.X; Y = p.Y; }
public int2(Size p) { X = p.Width; Y = p.Height; }