8000 Use explicit accessors · attackgithub/pythonnet@61536f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 61536f3

Browse files
committed
Use explicit accessors
1 parent d1241f8 commit 61536f3

26 files changed

+87
-85
lines changed

src/console/pythonconsole.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Reflection;
45
using Python.Runtime;
56

@@ -40,7 +41,7 @@ public static int Main(string[] args)
4041
// (Python.Runtime.dll is included as a resource)
4142
private sealed class AssemblyLoader
4243
{
43-
Dictionary<string, Assembly> loadedAssemblies;
44+
private Dictionary<string, Assembly> loadedAssemblies;
4445

4546
public AssemblyLoader()
4647
{
@@ -57,7 +58,7 @@ public AssemblyLoader()
5758
}
5859

5960
// looks for the assembly from the resources and load it
60-
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
61+
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
6162
{
6263
if (stream != null)
6364
{

src/embed_tests/pylong.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void TearDown()
2727
public void TestToInt64()
2828
{
2929
long largeNumber = 8L * 1024L * 1024L * 1024L; // 8 GB
30-
PyLong pyLargeNumber = new PyLong(largeNumber);
30+
var pyLargeNumber = new PyLong(largeNumber);
3131
Assert.AreEqual(largeNumber, pyLargeNumber.ToInt64());
3232
}
3333
}

src/runtime/assemblymanager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ internal class AssemblyManager
1717
{
1818
// modified from event handlers below, potentially triggered from different .NET threads
1919
// therefore this should be a ConcurrentDictionary
20-
static ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>> namespaces;
21-
//static Dictionary<string, Dictionary<string, string>> generics;
22-
static AssemblyLoadEventHandler lhandler;
23-
static ResolveEventHandler rhandler;
20+
private static ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>> namespaces;
21+
//private static Dictionary<string, Dictionary<string, string>> generics;
22+
private static AssemblyLoadEventHandler lhandler;
23+
private static ResolveEventHandler rhandler;
2424

2525
// updated only under GIL?
26-
static Dictionary<string, int> probed;
26+
private static Dictionary<string, int> probed;
2727

2828
// modified from event handlers below, potentially triggered from different .NET threads
29-
static AssemblyList assemblies;
29+
private static AssemblyList assemblies;
3030
internal static List<string> pypath;
3131

3232
private AssemblyManager()

src/runtime/classmanager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace Python.Runtime
1717
/// </summary>
1818
internal class ClassManager
1919
{
20-
static Dictionary<Type, ClassBase> cache;
21-
static Type dtype;
20+
private static Dictionary<Type, ClassBase> cache;
21+
private static Type dtype;
2222

2323
private ClassManager()
2424
{

src/runtime/codegenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace Python.Runtime
1313
/// </summary>
1414
internal class CodeGenerator
1515
{
16-
AssemblyBuilder aBuilder;
17-
ModuleBuilder mBuilder;
16+
private AssemblyBuilder aBuilder;
17+
private ModuleBuilder mBuilder;
1818

1919
internal CodeGenerator()
2020
{

src/runtime/constructorbinding.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ namespace Python.Runtime
2121
/// </remarks>
2222
internal class ConstructorBinding : ExtensionType
2323
{
24-
Type type; // The managed Type being wrapped in a ClassObject
25-
IntPtr pyTypeHndl; // The python type tells GetInstHandle which Type to create.
26-
ConstructorBinder ctorBinder;
27-
IntPtr repr;
24+
private Type type; // The managed Type being wrapped in a ClassObject
25+
private IntPtr pyTypeHndl; // The python type tells GetInstHandle which Type to create.
26+
private ConstructorBinder ctorBinder;
27+
private IntPtr repr;
2828

2929
public ConstructorBinding(Type type, IntPtr pyTypeHndl, ConstructorBinder ctorBinder)
3030
{
@@ -165,11 +165,11 @@ public static IntPtr tp_repr(IntPtr ob)
165165
/// </remarks>
166166
internal class BoundContructor : ExtensionType
167167
{
168-
Type type; // The managed Type being wrapped in a ClassObject
169-
IntPtr pyTypeHndl; // The python type tells GetInstHandle which Type to create.
170-
ConstructorBinder ctorBinder;
171-
ConstructorInfo ctorInfo;
172-
IntPtr repr;
168+
private Type type; // The managed Type being wrapped in a ClassObject
169+
private IntPtr pyTypeHndl; // The python type tells GetInstHandle which Type to create.
170+
private ConstructorBinder ctorBinder;
171+
private ConstructorInfo ctorInfo;
172+
private IntPtr repr;
173173

174174
public BoundContructor(Type type, IntPtr pyTypeHndl, ConstructorBinder ctorBinder, ConstructorInfo ci)
175175
{

src/runtime/converter.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ private Converter()
1717
{
1818
}
1919

20-
static NumberFormatInfo nfi;
21-
static Type objectType;
22-
static Type stringType;
23-
static Type singleType;
24-
static Type doubleType;
25-
static Type decimalType;
26-
static Type int16Type;
27-
static Type int32Type;
28-
static Type int64Type;
29-
static Type flagsType;
30-
static Type boolType;
31-
static Type typeType;
20+
private static NumberFormatInfo nfi;
21+
private static Type objectType;
22+
private static Type stringType;
23+
private static Type singleType;
24+
private static Type doubleType;
25+
private static Type decimalType;
26+
private static Type int16Type;
27+
private static Type int32Type;
28+
private static Type int64Type;
29+
private static Type flagsType;
30+
private static Type boolType;
31+
private static Type typeType;
3232

3333
static Converter()
3434
{
@@ -415,7 +415,7 @@ internal static bool ToManagedValue(IntPtr value, Type obType,
415415
/// <summary>
416416
/// Convert a Python value to an instance of a primitive managed type.
417417
/// </summary>
418-
static bool ToPrimitive(IntPtr value, Type obType, out Object result, bool setError)
418+
private static bool ToPrimitive(IntPtr value, Type obType, out object result, bool setError)
419419
{
420420
IntPtr overflow = Exceptions.OverflowError;
421421
TypeCode tc = Type.GetTypeCode(obType);
@@ -826,7 +826,7 @@ static void SetConversionError(IntPtr value, Type target)
826826
/// The Python value must support the Python sequence protocol and the
827827
/// items in the sequence must be convertible to the target array type.
828828
/// </summary>
829-
static bool ToArray(IntPtr value, Type obType, out Object result, bool setError)
829+
private static bool ToArray(IntPtr value, Type obType, out object result, bool setError)
830830
{
831831
Type elementType = obType.GetElementType();
832832
int size = Runtime.PySequence_Size(value);
@@ -875,7 +875,7 @@ static bool ToArray(IntPtr value, Type obType, out Object result, bool setError)
875875
/// <summary>
876876
/// Convert a Python value to a correctly typed managed enum instance.
877877
/// </summary>
878-
static bool ToEnum(IntPtr value, Type obType, out Object result, bool setError)
878+
private static bool ToEnum(IntPtr value, Type obType, out object result, bool setError)
879879
{
880880
Type etype = Enum.GetUnderlyingType(obType);
881881
result = null;

src/runtime/delegatemanager.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ namespace Python.Runtime
1111
/// </summary>
1212
internal class DelegateManager
1313
{
14-
Hashtable cache;
15-
Type basetype;
16-
Type listtype;
17-
Type voidtype;
18-
Type typetype;
19-
Type ptrtype;
20-
CodeGenerator codeGenerator;
14+
private Hashtable cache;
15+
private Type basetype;
16+
private Type listtype;
17+
private Type voidtype;
18+
private Type typetype;
19+
private Type ptrtype;
20+
private CodeGenerator codeGenerator;
2121

2222
public DelegateManager()
2323
{
@@ -180,6 +180,7 @@ A possible alternate strategy would be to create custom subclasses
180180
This would be slightly cleaner, but I'm not sure if delegates are
181181
too "special" for this to work. It would be more work, so for now
182182
the 80/20 rule applies :) */
183+
183184
public class Dispatcher
184185
{
185186
public IntPtr target;

src/runtime/delegateobject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Python.Runtime
1010
/// </summary>
1111
internal class DelegateObject : ClassBase
1212
{
13-
MethodBinder binder;
13+
private MethodBinder binder;
1414

1515
internal DelegateObject(Type tp) : base(tp)
1616
{

src/runtime/eventbinding.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace Python.Runtime
77
/// </summary>
88
internal class EventBinding : ExtensionType
99
{
10-
EventObject e;
11-
IntPtr target;
10+
private EventObject e;
11+
private IntPtr target;
1212

1313
public EventBinding(EventObject e, IntPtr target)
1414
{

src/runtime/exceptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ internal static void SetArgsAndCause(IntPtr ob)
171171
/// Shortcut for (pointer == NULL) -&gt; throw PythonException
172172
/// </summary>
173173
/// <param name="pointer">Pointer to a Python object</param>
174-
internal unsafe static void ErrorCheck(IntPtr pointer)
174+
internal static unsafe void ErrorCheck(IntPtr pointer)
175175
{
176176
if (pointer == IntPtr.Zero)
177177
{
@@ -182,7 +182,7 @@ internal unsafe static void ErrorCheck(IntPtr pointer)
182182
/// <summary>
183183
/// Shortcut for (pointer == NULL or ErrorOccurred()) -&gt; throw PythonException
184184
/// </summary>
185-
internal unsafe static void ErrorOccurredCheck(IntPtr pointer)
185+
internal static unsafe void ErrorOccurredCheck(IntPtr pointer)
186186
{
187187
if (pointer == IntPtr.Zero || ErrorOccurred())
188188
{

src/runtime/fieldobject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Python.Runtime
88
/// </summary>
99
internal class FieldObject : ExtensionType
1010
{
11-
FieldInfo info;
11+
private FieldInfo info;
1212

1313
public FieldObject(FieldInfo info)
1414
{

src/runtime/genericutil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Python.Runtime
99
/// </summary>
1010
internal class GenericUtil
1111
{
12-
static Dictionary<string, Dictionary<string, List<string>>> mapping;
12+
private static Dictionary<string, Dictionary<string, List<string>>> mapping;
1313

1414
private GenericUtil()
1515
{

src/runtime/importhook.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ namespace Python.Runtime
88
/// </summary>
99
internal class ImportHook
1010
{
11-
static IntPtr py_import;
12-
static CLRModule root;
13-
static MethodWrapper hook;
14-
static IntPtr py_clr_module;
11+
private static IntPtr py_import;
12+
private static CLRModule root;
13+
private static MethodWrapper hook;
14+
private static IntPtr py_clr_module;
1515

1616
#if PYTHON3
17-
static IntPtr module_def = IntPtr.Zero;
17+
private static IntPtr module_def = IntPtr.Zero;
1818

1919
internal static void InitializeModuleDef()
2020
{
@@ -36,8 +36,8 @@ internal static void Initialize()
3636
// modules (Python doesn't provide a way to emulate packages).
3737
IntPtr dict = Runtime.PyImport_GetModuleDict();
3838

39-
IntPtr mod = Runtime.IsPython3
40-
? Runtime.PyImport_ImportModule("builtins")
39+
IntPtr mod = Runtime.IsPython3
40+
? Runtime.PyImport_ImportModule("builtins")
4141
: Runtime.PyDict_GetItemString(dict, "__builtin__");
4242

4343
py_import = Runtime.PyObject_GetAttrString(mod, "__import__");

src/runtime/interfaceobject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal InterfaceObject(Type tp) : base(tp)
2323
}
2424
}
2525

26-
static Type cc_attr;
26+
private static Type cc_attr;
2727

2828
static InterfaceObject()
2929
{

src/runtime/interop.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ internal class TypeFlags
334334

335335
internal class Interop
336336
{
337-
static ArrayList keepAlive;
338-
static Hashtable pmap;
337+
private static ArrayList keepAlive;
338+
private static Hashtable pmap;
339339

340340
static Interop()
341341
{

src/runtime/iterator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Python.Runtime
99
/// </summary>
1010
internal class Iterator : ExtensionType
1111
{
12-
IEnumerator iter;
12+
private IEnumerator iter;
1313

1414
public Iterator(IEnumerator e)
1515
{

src/runtime/metatype.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Python.Runtime
1010
/// </summary>
1111
internal class MetaType : ManagedType
1212
{
13-
static IntPtr PyCLRMetaType;
13+
private static IntPtr PyCLRMetaType;
1414

1515

1616
/// <summary>
@@ -266,7 +266,7 @@ public static void tp_dealloc(IntPtr tp)
266266
NativeCall.Void_Call_1(op, tp);
267267
}
268268

269-
static IntPtr DoInstanceCheck(IntPtr tp, IntPtr args, bool checkType)
269+
private static IntPtr DoInstanceCheck(IntPtr tp, IntPtr args, bool checkType)
270270
{
271271
var cb = GetManagedObject(tp) as ClassBase;
272272

src/runtime/moduleobject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Python.Runtime
1111
/// </summary>
1212
internal class ModuleObject : ExtensionType
1313
{
14-
Dictionary<string, ManagedType> cache;
14+
private Dictionary<string, ManagedType> cache;
1515
internal string moduleName;
1616
internal IntPtr dict;
1717
protected string _namespace;

src/runtime/nativecall.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ namespace Python.Runtime
2323
/// </summary>
2424
internal class NativeCall
2525
{
26-
static AssemblyBuilder aBuilder;
27-
static ModuleBuilder mBuilder;
26+
private static AssemblyBuilder aBuilder;
27+
private static ModuleBuilder mBuilder;
2828

2929
public static INativeCall Impl;
3030

src/runtime/overload.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace Python.Runtime
99
/// </summary>
1010
internal class OverloadMapper : ExtensionType
1111
{
12-
MethodObject m;
13-
IntPtr target;
12+
private MethodObject m;
13+
private IntPtr target;
1414

1515
public OverloadMapper(MethodObject m, IntPtr target)
1616
{

src/runtime/propertyobject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ namespace Python.Runtime
99
/// </summary>
1010
internal class PropertyObject : ExtensionType
1111
{
12-
PropertyInfo info;
13-
MethodInfo getter;
14-
MethodInfo setter;
12+
private PropertyInfo info;
13+
private MethodInfo getter;
14+
private MethodInfo setter;
1515

1616
[StrongNameIdentityPermission(SecurityAction.Assert)]
1717
public PropertyObject(PropertyInfo md)

src/runtime/runtime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Python.Runtime
77
{
88
[SuppressUnmanagedCodeSecurity]
9-
static class NativeMethods
9+
internal static class NativeMethods
1010
{
1111
#if MONO_LINUX || MONO_OSX
1212
private static int RTLD_NOW = 0x2;

src/runtime/typemanager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace Python.Runtime
1212
/// </summary>
1313
internal class TypeManager
1414
{
15-
static BindingFlags tbFlags;
16-
static Dictionary<Type, IntPtr> cache;
15+
private static BindingFlags tbFlags;
16+
private static Dictionary<Type, IntPtr> cache;
1717

1818
static TypeManager()
1919
{

0 commit comments

Comments
 (0)
0