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
{

0 commit comments

Comments
 (0)