Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Yet again more FxCop happiness

  • Loading branch information...
commit 354d4da7b04fbb42c1e3e7800c369fedfa285759 1 parent a075088
@dmiller dmiller authored
View
2  Clojure/Clojure/CljCompiler/Ast/InvokeExpr.cs
@@ -75,7 +75,7 @@ public InvokeExpr(string source, IPersistentMap spanMap, Symbol tag, Expr fexpr,
}
String mname = Compiler.munge(mmapVal.Symbol.ToString());
- List<MethodBase> methods = Reflector.GetMethods(_protocolOn, mname, null, args.count() - 1, false);
+ IList<MethodBase> methods = Reflector.GetMethods(_protocolOn, mname, null, args.count() - 1, false);
if (methods.Count != 1)
throw new ArgumentException(String.Format("No single method: {0} of interface: {1} found for function: {2} of protocol: {3}",
mname, _protocolOn.FullName, fvar.Symbol, pvar.Symbol));
View
26 Clojure/Clojure/Lib/Future.cs
@@ -22,7 +22,7 @@ namespace clojure.lang
/// <summary>
/// Implements IDeref and java.util.concurrent.Future, like the proxy in JVM clojure core.
/// </summary>
- public class Future : IDeref, IBlockingDeref, IPending
+ public class Future : IDeref, IBlockingDeref, IPending, IDisposable
{
#region Data
@@ -31,6 +31,7 @@ public class Future : IDeref, IBlockingDeref, IPending
object _value;
Exception _error;
bool _cancelled;
+ bool _disposed = false;
#endregion
@@ -149,6 +150,29 @@ public object deref(long ms, object timeoutValue)
}
#endregion
+
+ #region IDisposable
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ _started.Dispose();
+ }
+
+ _disposed = true;
+ }
+ }
+
+ #endregion
}
[Serializable]
View
2  Clojure/Clojure/Lib/LispReader.cs
@@ -289,7 +289,7 @@ static int readUnicodeChar(PushbackTextReader r, int initch, int radix, int leng
#region Other
- public static List<Object> ReadDelimitedList(char delim, PushbackTextReader r, bool isRecursive)
+ static List<Object> ReadDelimitedList(char delim, PushbackTextReader r, bool isRecursive)
{
LineNumberingTextReader lntr = r as LineNumberingTextReader;
int firstLine = lntr != null ? lntr.LineNumber : -1;
View
39 Clojure/Clojure/Lib/MapEnumerator.cs
@@ -13,6 +13,8 @@
**/
using System.Collections;
+using System;
+using System.Collections.Generic;
namespace clojure.lang
{
@@ -27,7 +29,7 @@ namespace clojure.lang
/// This converts an <see cref="IMapEntry">IMapEntry</see> to a DictionaryEntry.
/// </para>
/// </remarks>
- public sealed class MapEnumerator : IDictionaryEnumerator
+ public sealed class MapEnumerator : IDictionaryEnumerator, IDisposable, IEnumerator, IEnumerator<IMapEntry>
{
#region Data
@@ -52,6 +54,8 @@ private object CurrentVal
get { return ((IMapEntry)_seqEnum.Current).val(); }
}
+ bool _disposed = false;
+
#endregion
#region C-tor
@@ -97,12 +101,17 @@ public object Value
#region IEnumerator Members
+ public IMapEntry Current
+ {
+ get { return (IMapEntry)_seqEnum.Current; }
+ }
+
/// <summary>
/// The current entry.
/// </summary>
- public object Current
+ object IEnumerator.Current
{
- get { return Entry; }
+ get { return _seqEnum.Current; }
}
/// <summary>
@@ -123,5 +132,29 @@ public void Reset()
}
#endregion
+
+ #region IDisposable
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ if ( _seqEnum != null )
+ _seqEnum.Dispose();
+ }
+
+ _disposed = true;
+ }
+ }
+
+ #endregion
}
}
View
1  Clojure/Clojure/Lib/RT.cs
@@ -264,6 +264,7 @@ public static class RT
#region Some misc. goodies
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")]
public static readonly object[] EmptyObjectArray = new Object[] { };
static RTProperties _versionProperties = new RTProperties();
View
30 Clojure/Clojure/Lib/Ref.cs
@@ -20,7 +20,7 @@ namespace clojure.lang
/// <summary>
/// Represents a reference.
/// </summary>
- public class Ref : ARef, IFn, IComparable<Ref>, IRef
+ public class Ref : ARef, IFn, IComparable<Ref>, IRef, IDisposable
{
#region Nested classes
@@ -242,7 +242,9 @@ public Ref setMaxHistory(int maxHistory)
/// <summary>
/// Used to generate unique ids.
/// </summary>
- static readonly AtomicLong _ids = new AtomicLong();
+ static readonly AtomicLong _ids = new AtomicLong();
+
+ bool _disposed = false;
#endregion
@@ -748,5 +750,29 @@ public override int GetHashCode()
}
#endregion
+
+ #region IDisposable
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ if ( _lock != null )
+ _lock.Dispose();
+ }
+
+ _disposed = true;
+ }
+ }
+
+ #endregion
}
}
View
34 Clojure/Clojure/Runtime/Reflector.cs
@@ -140,22 +140,22 @@ public static object GetInstanceFieldOrProperty(object target, string fieldName)
#region Method lookup
- public static MethodInfo GetMatchingMethod(IPersistentMap spanMap, Type targetType, List<HostArg> args, string methodName, List<Type> typeArgs)
+ public static MethodInfo GetMatchingMethod(IPersistentMap spanMap, Type targetType, IList<HostArg> args, string methodName, IList<Type> typeArgs)
{
- List<MethodBase> methods = GetMethods(targetType, methodName, typeArgs, args.Count, true);
+ IList<MethodBase> methods = GetMethods(targetType, methodName, typeArgs, args.Count, true);
MethodBase method = GetMatchingMethodAux(targetType, args, methods, methodName, true);
MaybeReflectionWarn(spanMap, method, methodName);
return (MethodInfo)method;
}
- public static MethodInfo GetMatchingMethod(IPersistentMap spanMap, Expr target, List<HostArg> args, string methodName, List<Type> typeArgs)
+ public static MethodInfo GetMatchingMethod(IPersistentMap spanMap, Expr target, IList<HostArg> args, string methodName, IList<Type> typeArgs)
{
MethodBase method = null;
if (target.HasClrType)
{
Type targetType = target.ClrType;
- List<MethodBase> methods = GetMethods(targetType, methodName, typeArgs, args.Count, false);
+ IList<MethodBase> methods = GetMethods(targetType, methodName, typeArgs, args.Count, false);
method = GetMatchingMethodAux(targetType, args, methods, methodName, false);
}
@@ -163,7 +163,7 @@ public static MethodInfo GetMatchingMethod(IPersistentMap spanMap, Expr target,
return (MethodInfo)method;
}
- internal static List<MethodBase> GetMethods(Type targetType, string methodName, List<Type> typeArgs, int arity, bool getStatics)
+ internal static IList<MethodBase> GetMethods(Type targetType, string methodName, IList<Type> typeArgs, int arity, bool getStatics)
{
BindingFlags flags = BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod;
flags |= getStatics ? BindingFlags.Static : BindingFlags.Instance;
@@ -187,7 +187,7 @@ IEnumerable<MethodInfo> einfos
}
- private static List<MethodBase> GetInterfaceMethods(Type targetType, string methodName, List<Type> typeArgs, int arity)
+ private static List<MethodBase> GetInterfaceMethods(Type targetType, string methodName, IList<Type> typeArgs, int arity)
{
BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod;
@@ -213,9 +213,9 @@ IEnumerable<MethodInfo> einfo
- internal static ConstructorInfo GetMatchingConstructor(IPersistentMap spanMap, Type targetType, List<HostArg> args, out int ctorCount)
+ internal static ConstructorInfo GetMatchingConstructor(IPersistentMap spanMap, Type targetType, IList<HostArg> args, out int ctorCount)
{
- List<MethodBase> methods = Reflector.GetConstructors(targetType, args.Count);
+ IList<MethodBase> methods = Reflector.GetConstructors(targetType, args.Count);
ctorCount = methods.Count;
MethodBase method = GetMatchingMethodAux(targetType, args, methods, "_ctor", true);
@@ -223,7 +223,7 @@ internal static ConstructorInfo GetMatchingConstructor(IPersistentMap spanMap, T
return (ConstructorInfo)method;
}
- private static MethodBase GetMatchingMethodAux(Type targetType, List<HostArg> args, List<MethodBase> methods, string methodName, bool isStatic)
+ private static MethodBase GetMatchingMethodAux(Type targetType, IList<HostArg> args, IList<MethodBase> methods, string methodName, bool isStatic)
{
int argCount = args.Count;
@@ -275,7 +275,7 @@ private static MethodBase GetMatchingMethodAux(Type targetType, List<HostArg> ar
}
- private static MethodBase GetMatchingMethodAux(Type targetType, object[] actualArgs, List<MethodBase> methods, string methodName, bool isStatic)
+ private static MethodBase GetMatchingMethodAux(Type targetType, object[] actualArgs, IList<MethodBase> methods, string methodName, bool isStatic)
{
int argCount = actualArgs.Length;
@@ -303,7 +303,7 @@ private static MethodBase GetMatchingMethodAux(Type targetType, object[] actualA
}
- private static List<MethodBase> GetConstructors(Type targetType, int arity)
+ private static IList<MethodBase> GetConstructors(Type targetType, int arity)
{
IEnumerable<ConstructorInfo> cinfos
= targetType.GetConstructors(BindingFlags.Public | BindingFlags.Instance).Where(info => info.GetParameters().Length == arity);
@@ -348,7 +348,7 @@ public static MethodInfo GetArityZeroMethod(Type t, string name, bool getStatics
#region Method calling
- public static object CallInstanceMethod(string methodName, List<Type> typeArgs, object target, params object[] args)
+ public static object CallInstanceMethod(string methodName, IList<Type> typeArgs, object target, params object[] args)
{
if (args.Length == 0)
{
@@ -363,7 +363,7 @@ public static object CallInstanceMethod(string methodName, List<Type> typeArgs,
return p.GetValue(target, null);
}
- List<MethodBase> methods = GetMethods(target.GetType(), methodName, typeArgs, args.Length, false);
+ IList<MethodBase> methods = GetMethods(target.GetType(), methodName, typeArgs, args.Length, false);
MethodBase method = GetMatchingMethodAux(target.GetType(), args, methods, methodName, false);
if (method == null)
@@ -380,7 +380,7 @@ public static object CallInstanceMethod(string methodName, List<Type> typeArgs,
//return target.GetType().InvokeMember(methodName, flags, Type.DefaultBinder, target, args);
}
- public static object CallStaticMethod(string methodName, List<Type> typeArgs, Type t, params object[] args)
+ public static object CallStaticMethod(string methodName, IList<Type> typeArgs, Type t, params object[] args)
{
if (args.Length == 0)
{
@@ -393,7 +393,7 @@ public static object CallStaticMethod(string methodName, List<Type> typeArgs, Ty
return p.GetValue(t, null);
}
- List<MethodBase> methods = GetMethods(t, methodName, typeArgs, args.Length, true);
+ IList<MethodBase> methods = GetMethods(t, methodName, typeArgs, args.Length, true);
MethodBase method = GetMatchingMethodAux(t, args, methods, methodName, true);
if (method == null)
@@ -464,12 +464,12 @@ public static Object InvokeStaticMethod(Type t, String methodName, Object[] args
{
if (methodName.Equals("new"))
return InvokeConstructor(t, args);
- List<MethodBase> methods = GetMethods(t, methodName, null, args.Length, true);
+ IList<MethodBase> methods = GetMethods(t, methodName, null, args.Length, true);
return InvokeMatchingMethod(methodName, methods, t, null, args);
}
- private static object InvokeMatchingMethod(string methodName, List<MethodBase> infos, Type t, object target, object[] args)
+ private static object InvokeMatchingMethod(string methodName, IList<MethodBase> infos, Type t, object target, object[] args)
{
Type targetType = t ?? target.GetType();
Please sign in to comment.
Something went wrong with that request. Please try again.