Permalink
Browse files

Yet more FxCop happiness

  • Loading branch information...
dmiller committed Aug 9, 2011
1 parent 360cc95 commit a0750884f2da5d12fc7c37cf609d7f3159a9d7ef
@@ -168,7 +168,6 @@ public object Eval()
_var.bindRoot(_init.Eval());
if (_meta != null)
{
- IPersistentMap metaMap = (IPersistentMap)_meta.Eval();
if (_initProvided || true) // includesExplicitMetadata((MapExpr)_meta))
_var.setMeta((IPersistentMap)_meta.Eval());
}
@@ -126,18 +126,18 @@ private Expression RewriteCallSite(CallSite site, TypeGen tg)
_fieldInits.Add(init);
- Type t = init.Type;
- if (t.IsGenericType)
- {
- Type[] args = t.GetGenericArguments()[0].GetGenericArguments(); ;
- // skip the first one, it is the site.
- for (int k = 1; k < args.Length; k++)
- {
- Type p = args[k];
- //if (!p.Assembly.GetName().Name.Equals("mscorlib") && !p.Assembly.GetName().Name.Equals("Clojure"))
- // Console.WriteLine("Found {0}", p.ToString());
- }
- }
+ //Type t = init.Type;
+ //if (t.IsGenericType)
+ //{
+ // Type[] args = t.GetGenericArguments()[0].GetGenericArguments(); ;
+ // // skip the first one, it is the site.
+ // for (int k = 1; k < args.Length; k++)
+ // {
+ // Type p = args[k];
+ // //if (!p.Assembly.GetName().Name.Equals("mscorlib") && !p.Assembly.GetName().Name.Equals("Clojure"))
+ // // Console.WriteLine("Found {0}", p.ToString());
+ // }
+ //}
// rewrite the node...
return Expression.Field(null, fb);
@@ -82,7 +82,6 @@ public Expr Parse(ParserContext pcon, object form)
{
PropertyInfo pinfo = null;
FieldInfo finfo = null;
- MethodInfo minfo = null;
Symbol sym = (RT.third(sform) is Keyword) ? ((Keyword)RT.third(sform)).Symbol : (Symbol)RT.third(sform);
string fieldName = Compiler.munge(sym.Name);
@@ -96,7 +95,7 @@ public Expr Parse(ParserContext pcon, object form)
return new StaticFieldExpr(source, spanMap, tag, t, fieldName, finfo);
if ((pinfo = Reflector.GetProperty(t, fieldName, true)) != null)
return new StaticPropertyExpr(source, spanMap, tag, t, fieldName, pinfo);
- if ((minfo = Reflector.GetArityZeroMethod(t, fieldName, true)) != null)
+ if (Reflector.GetArityZeroMethod(t, fieldName, true) != null)
return new StaticMethodExpr(source, spanMap, tag, t, fieldName, null, new List<HostArg>());
throw new MissingMemberException(t.Name, fieldName);
}
@@ -107,7 +106,7 @@ public Expr Parse(ParserContext pcon, object form)
return new InstanceFieldExpr(source, spanMap, tag, instance, fieldName, finfo);
if ((pinfo = Reflector.GetProperty(instanceType, fieldName, false)) != null)
return new InstancePropertyExpr(source, spanMap, tag, instance, fieldName, pinfo);
- if ((minfo = Reflector.GetArityZeroMethod(instanceType, fieldName, false)) != null)
+ if (Reflector.GetArityZeroMethod(instanceType, fieldName, false) != null)
return new InstanceMethodExpr(source, spanMap, tag, instance, fieldName, null, new List<HostArg>());
if (pcon.IsAssignContext)
return new InstanceFieldExpr(source, spanMap, tag, instance, fieldName, null); // same as InstancePropertyExpr when last arg is null
@@ -244,7 +243,10 @@ internal static List<HostArg> ParseArgs(ParserContext pcon, ISeq argSeq)
#region MaybePrimitiveExpr
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2119:SealMethodsThatSatisfyPrivateInterfaces")]
public abstract bool CanEmitPrimitive { get; }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2119:SealMethodsThatSatisfyPrivateInterfaces")]
public abstract Expression GenCodeUnboxed(RHC rhc, ObjExpr objx, GenContext context);
#endregion
@@ -302,7 +302,7 @@ private Expression GenProtoLight(RHC rhc, ObjExpr objx, GenContext context, Expr
ParameterExpression targetParam = Expression.Parameter(typeof(Object), "target");
ParameterExpression targetTypeParam = Expression.Parameter(typeof(Type), "targetType");
ParameterExpression vpfnParam = Expression.Parameter(typeof(AFunction), "vpfn");
- ParameterExpression thisParam = objx.ThisParam;
+ //ParameterExpression thisParam = objx.ThisParam;
Expression targetParamAssign = Expression.Assign(targetParam, Compiler.MaybeBox(e.GenCode(RHC.Expression,objx,context)));
Expression targetTypeParamAssign =
@@ -377,7 +377,7 @@ private Expression GenerateComplexCall(ObjExpr objx, GenContext context)
#endif
ParameterExpression sbParam = Expression.Parameter(sbType, String.Format("__sb_{0}", sbParams.Count));
- ConstructorInfo[] cinfos = sbType.GetConstructors();
+ //ConstructorInfo[] cinfos = sbType.GetConstructors();
Expression sbInit1 =
Expression.Assign(
sbParam,
@@ -550,7 +550,7 @@ private void GenerateKeywordCallsites(TypeBuilder baseTB)
for (int i = 0; i < _keywordCallsites.count(); i++)
{
- Keyword k = (Keyword)_keywordCallsites.nth(i);
+ //Keyword k = (Keyword)_keywordCallsites.nth(i);
string siteName = SiteNameStatic(i);
string thunkName = ThunkNameStatic(i);
FieldBuilder fb1 = baseTB.DefineField(siteName, typeof(KeywordLookupSite), FieldAttributes.FamORAssem | FieldAttributes.Static);
@@ -1216,7 +1216,7 @@ private ConstructorBuilder GenerateConstructor(TypeBuilder fnTB, Type baseType)
for (ISeq s = RT.keys(_closes); s != null; s = s.next(), a++)
{
- LocalBinding lb = (LocalBinding)s.first();
+ //LocalBinding lb = (LocalBinding)s.first();
FieldBuilder fb = _closedOverFields[a];
gen.EmitLoadArg(0); // gen.Emit(OpCodes.Ldarg_0);
@@ -116,7 +116,7 @@ public Expr Parse(ParserContext pcon, object frm)
Expr finallyExpr = null;
bool caught = false;
- int retLocal = Compiler.GetAndIncLocalNum();
+ //int retLocal = Compiler.GetAndIncLocalNum();
//int finallyLocal = Compiler.GetAndIncLocalNum();
for (ISeq fs = form.next(); fs != null; fs = fs.next())
@@ -1293,7 +1293,7 @@ internal static object Compile(TextReader rdr, string sourceDirectory, string so
//Java version: LINE_BEFORE.set(lntr.LineNumber);
}
- Type exprType = exprTB.CreateType();
+ exprTB.CreateType();
// Need to put the loader init in its own type because we can't generate calls on the MethodBuilders
// until after their types have been closed.
@@ -742,7 +742,7 @@ private static void GetAllMethods(Type type, HashSet<MethodSignature> considered
static Dictionary<string,List<MethodSignature>> ComputeOverloads(List<MethodSignature> sigs)
{
- HashSet<String> overloadNames = new HashSet<string>();
+ //HashSet<String> overloadNames = new HashSet<string>();
Dictionary<string,List<MethodSignature>> name2SigMap = new Dictionary<string,List<MethodSignature>>();
foreach (MethodSignature sig in sigs)
@@ -21,6 +21,7 @@ namespace clojure.lang
/// <summary>
/// Provides a basic implementation of <see cref="IPersistentVector">IPersistentVector</see> functionality.
/// </summary>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1708:IdentifiersShouldDifferByMoreThanCase")]
[Serializable]
public abstract class APersistentVector: AFn, IPersistentVector, IList, IComparable, IList<Object>, IComparable<Object>
@@ -62,6 +62,7 @@ public TValue Remove(TKey key)
}
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public TValue[] Values
{
get
@@ -136,12 +136,12 @@ public override string ToString()
/// <returns><value>true</value> if equal; <value>false</value> otherwise.</returns>
public override bool Equals(object obj)
{
- if ( obj == this )
+ if ( ReferenceEquals(this,obj) )
return true;
Keyword keyword = obj as Keyword;
- if (keyword == null)
+ if (ReferenceEquals(keyword,null))
return false;
return _sym.Equals(keyword.Symbol);
@@ -248,7 +248,59 @@ public sealed override object invoke(object arg1, object notFound)
/// <returns>neg,zero,pos for &lt; = &gt;</returns>
public int CompareTo(object obj)
{
- return _sym.CompareTo(((Keyword)obj)._sym);
+ Keyword k = obj as Keyword;
+ if (ReferenceEquals(k,null))
+ throw new ArgumentException("Cannot compare to null or non-Keyword", "obj");
+
+ return _sym.CompareTo(k._sym);
+ }
+
+ #endregion
+
+ #region Operator overloads
+
+ public static bool operator ==(Keyword k1, Keyword k2)
+ {
+ if (ReferenceEquals(k1, k2))
+ return true;
+
+ if (ReferenceEquals(k1, null)||ReferenceEquals(k2,null))
+ return false;
+
+ return k1.CompareTo(k2) == 0;
+ }
+
+ public static bool operator !=(Keyword k1, Keyword k2)
+ {
+ if (ReferenceEquals(k1, k2))
+ return false;
+
+ if (ReferenceEquals(k1, null) || ReferenceEquals(k2,null))
+ return true;
+
+ return k1.CompareTo(k2) != 0;
+ }
+
+ public static bool operator <(Keyword k1, Keyword k2)
+ {
+ if (ReferenceEquals(k1, k2))
+ return false;
+
+ if (ReferenceEquals(k1, null))
+ throw new ArgumentNullException("k1");
+
+ return k1.CompareTo(k2) < 0;
+ }
+
+ public static bool operator >(Keyword k1, Keyword k2)
+ {
+ if (ReferenceEquals(k1, k2))
+ return false;
+
+ if (ReferenceEquals(k1, null))
+ throw new ArgumentNullException("k1");
+
+ return k1.CompareTo(k2) > 0;
}
#endregion
@@ -89,6 +89,7 @@ public IDictionary map
Entry _mre = null;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "table")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public object[] table
{
get { return _table; }
@@ -494,8 +494,7 @@ class NamespaceSerializationHelper : IObjectReference
public object GetRealObject(StreamingContext context)
{
- string name = (String)context.Context;
- return Namespace.findOrCreate(_name);
+ return Namespace.findOrCreate(_name);
}
#endregion
@@ -42,6 +42,7 @@ public AtomicReference<Thread> Edit
readonly object[] _array;
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public object[] Array
{
get { return _array; }
@@ -21,6 +21,7 @@ namespace clojure.lang
/// <summary>
/// Represents a rational number.
/// </summary>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes")]
[Serializable]
public sealed class Ratio: IComparable, IConvertible
{
View
@@ -685,7 +685,68 @@ public int CompareTo(Ref other)
return _id.CompareTo(other._id);
}
- #endregion
-
+ #endregion
+
+ #region object overrides
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(this, obj))
+ return true;
+
+ Ref r = obj as Ref;
+ if (r == null)
+ return false;
+
+ return _id == r._id;
+ }
+
+ public override int GetHashCode()
+ {
+ return _id.GetHashCode();
+ }
+ #endregion
+
+ #region operator overrides
+
+ public static bool operator ==(Ref x, Ref y)
+ {
+ if (ReferenceEquals(x, y))
+ return true;
+
+ if ((object)x == null)
+ return false;
+
+ return x.CompareTo(y) == 0;
+ }
+
+ public static bool operator !=(Ref x, Ref y)
+ {
+ return !(x == y);
+ }
+
+ public static bool operator <(Ref x, Ref y)
+ {
+ if (ReferenceEquals(x, y))
+ return false;
+
+ if ( ReferenceEquals(x,null) )
+ throw new ArgumentException("Cannot compare null","x");
+
+ return x.CompareTo(y) < 0;
+ }
+
+ public static bool operator >(Ref x, Ref y)
+ {
+ if (ReferenceEquals(x, y))
+ return false;
+
+ if ( ReferenceEquals(x,null) )
+ throw new ArgumentException("Cannot compare null","x");
+
+ return x.CompareTo(y) > 0;
+ }
+
+ #endregion
}
}
Oops, something went wrong.

0 comments on commit a075088

Please sign in to comment.