@@ -31,12 +31,11 @@ private AssemblyManager()
3131 {
3232 }
3333
34- //===================================================================
35- // Initialization performed on startup of the Python runtime. Here we
36- // scan all of the currently loaded assemblies to determine exported
37- // names, and register to be notified of new assembly loads.
38- //===================================================================
39-
34+ /// <summary>
35+ /// Initialization performed on startup of the Python runtime. Here we
36+ /// scan all of the currently loaded assemblies to determine exported
37+ /// names, and register to be notified of new assembly loads.
38+ /// </summary>
4039 internal static void Initialize ( )
4140 {
4241 namespaces = new ConcurrentDictionary < string , ConcurrentDictionary < Assembly , string > > ( ) ;
@@ -69,10 +68,9 @@ internal static void Initialize()
6968 }
7069
7170
72- //===================================================================
73- // Cleanup resources upon shutdown of the Python runtime.
74- //===================================================================
75-
71+ /// <summary>
72+ /// Cleanup resources upon shutdown of the Python runtime.
73+ /// </summary>
7674 internal static void Shutdown ( )
7775 {
7876 AppDomain domain = AppDomain . CurrentDomain ;
@@ -81,14 +79,13 @@ internal static void Shutdown()
8179 }
8280
8381
84- //===================================================================
85- // Event handler for assembly load events. At the time the Python
86- // runtime loads, we scan the app domain to map the assemblies that
87- // are loaded at the time. We also have to register this event handler
88- // so that we can know about assemblies that get loaded after the
89- // Python runtime is initialized.
90- //===================================================================
91-
82+ /// <summary>
83+ /// Event handler for assembly load events. At the time the Python
84+ /// runtime loads, we scan the app domain to map the assemblies that
85+ /// are loaded at the time. We also have to register this event handler
86+ /// so that we can know about assemblies that get loaded after the
87+ /// Python runtime is initialized.
88+ /// </summary>
9289 static void AssemblyLoadHandler ( Object ob , AssemblyLoadEventArgs args )
9390 {
9491 Assembly assembly = args . LoadedAssembly ;
@@ -97,14 +94,13 @@ static void AssemblyLoadHandler(Object ob, AssemblyLoadEventArgs args)
9794 }
9895
9996
100- //===================================================================
101- // Event handler for assembly resolve events. This is needed because
102- // we augment the assembly search path with the PYTHONPATH when we
103- // load an assembly from Python. Because of that, we need to listen
104- // for failed loads, because they might be dependencies of something
105- // we loaded from Python which also needs to be found on PYTHONPATH.
106- //===================================================================
107-
97+ /// <summary>
98+ /// Event handler for assembly resolve events. This is needed because
99+ /// we augment the assembly search path with the PYTHONPATH when we
100+ /// load an assembly from Python. Because of that, we need to listen
101+ /// for failed loads, because they might be dependencies of something
102+ /// we loaded from Python which also needs to be found on PYTHONPATH.
103+ /// </summary>
108104 static Assembly ResolveHandler ( Object ob , ResolveEventArgs args )
109105 {
110106 string name = args . Name . ToLower ( ) ;
@@ -120,19 +116,17 @@ static Assembly ResolveHandler(Object ob, ResolveEventArgs args)
120116 }
121117
122118
123- //===================================================================
124- // We __really__ want to avoid using Python objects or APIs when
125- // probing for assemblies to load, since our ResolveHandler may be
126- // called in contexts where we don't have the Python GIL and can't
127- // even safely try to get it without risking a deadlock ;(
128- //
129- // To work around that, we update a managed copy of sys.path (which
130- // is the main thing we care about) when UpdatePath is called. The
131- // import hook calls this whenever it knows its about to use the
132- // assembly manager, which lets us keep up with changes to sys.path
133- // in a relatively lightweight and low-overhead way.
134- //===================================================================
135-
119+ /// <summary>
120+ /// We __really__ want to avoid using Python objects or APIs when
121+ /// probing for assemblies to load, since our ResolveHandler may be
122+ /// called in contexts where we don't have the Python GIL and can't
123+ /// even safely try to get it without risking a deadlock ;(
124+ /// To work around that, we update a managed copy of sys.path (which
125+ /// is the main thing we care about) when UpdatePath is called. The
126+ /// import hook calls this whenever it knows its about to use the
127+ /// assembly manager, which lets us keep up with changes to sys.path
128+ /// in a relatively lightweight and low-overhead way.
129+ /// </summary>
136130 internal static void UpdatePath ( )
137131 {
138132 IntPtr list = Runtime . PySys_GetObject ( "path" ) ;
@@ -154,12 +148,11 @@ internal static void UpdatePath()
154148 }
155149
156150
157- //===================================================================
158- // Given an assembly name, try to find this assembly file using the
159- // PYTHONPATH. If not found, return null to indicate implicit load
160- // using standard load semantics (app base directory then GAC, etc.)
161- //===================================================================
162-
151+ /// <summary>
152+ /// Given an assembly name, try to find this assembly file using the
153+ /// PYTHONPATH. If not found, return null to indicate implicit load
154+ /// using standard load semantics (app base directory then GAC, etc.)
155+ /// </summary>
163156 public static string FindAssembly ( string name )
164157 {
165158 char sep = Path . DirectorySeparatorChar ;
@@ -193,11 +186,10 @@ public static string FindAssembly(string name)
193186 }
194187
195188
196- //===================================================================
197- // Loads an assembly from the application directory or the GAC
198- // given a simple assembly name. Returns the assembly if loaded.
199- //===================================================================
200-
189+ /// <summary>
190+ /// Loads an assembly from the application directory or the GAC
191+ /// given a simple assembly name. Returns the assembly if loaded.
192+ /// </summary>
201193 public static Assembly LoadAssembly ( string name )
202194 {
203195 Assembly assembly = null ;
@@ -216,10 +208,9 @@ public static Assembly LoadAssembly(string name)
216208 }
217209
218210
219- //===================================================================
220- // Loads an assembly using an augmented search path (the python path).
221- //===================================================================
222-
211+ /// <summary>
212+ /// Loads an assembly using an augmented search path (the python path).
213+ /// </summary>
223214 public static Assembly LoadAssemblyPath ( string name )
224215 {
225216 string path = FindAssembly ( name ) ;
@@ -240,8 +231,10 @@ public static Assembly LoadAssemblyPath(string name)
240231 /// <summary>
241232 /// Loads an assembly using full path.
242233 /// </summary>
243- /// <param name="name"></param>
244- /// <returns></returns>
234+ /// <param name="name">
235+ /// </param>
236+ /// <returns>
237+ /// </returns>
245238 public static Assembly LoadAssemblyFullPath ( string name )
246239 {
247240 Assembly assembly = null ;
@@ -263,10 +256,9 @@ public static Assembly LoadAssemblyFullPath(string name)
263256 return assembly ;
264257 }
265258
266- //===================================================================
267- // Returns an assembly that's already been loaded
268- //===================================================================
269-
259+ /// <summary>
260+ /// Returns an assembly that's already been loaded
261+ /// </summary>
270262 public static Assembly FindLoadedAssembly ( string name )
271263 {
272264 foreach ( Assembly a in assemblies )
@@ -279,18 +271,19 @@ public static Assembly FindLoadedAssembly(string name)
279271 return null ;
280272 }
281273
282- //===================================================================
283- // Given a qualified name of the form A.B.C.D, attempt to load
284- // an assembly named after each of A.B.C.D, A.B.C, A.B, A. This
285- // will only actually probe for the assembly once for each unique
286- // namespace. Returns true if any assemblies were loaded.
287- // TODO item 3 "* Deprecate implicit loading of assemblies":
288- // Set the fromFile flag if the name of the loaded assembly matches
289- // the fully qualified name that was requested if the framework
290- // actually loads an assembly.
291- // Call ONLY for namespaces that HAVE NOT been cached yet.
292- //===================================================================
293-
274+ /// <summary>
275+ /// Given a qualified name of the form A.B.C.D, attempt to load
276+ /// an assembly named after each of A.B.C.D, A.B.C, A.B, A. This
277+ /// will only actually probe for the assembly once for each unique
278+ /// namespace. Returns true if any assemblies were loaded.
279+ /// </summary>
280+ /// <remarks>
281+ /// TODO item 3 "* Deprecate implicit loading of assemblies":
282+ /// Set the fromFile flag if the name of the loaded assembly matches
283+ /// the fully qualified name that was requested if the framework
284+ /// actually loads an assembly.
285+ /// Call ONLY for namespaces that HAVE NOT been cached yet.
286+ /// </remarks>
294287 public static bool LoadImplicit ( string name , bool warn = true )
295288 {
296289 string [ ] names = name . Split ( '.' ) ;
@@ -339,13 +332,12 @@ public static bool LoadImplicit(string name, bool warn = true)
339332 }
340333
341334
342- //===================================================================
343- // Scans an assembly for exported namespaces, adding them to the
344- // mapping of valid namespaces. Note that for a given namespace
345- // a.b.c.d, each of a, a.b, a.b.c and a.b.c.d are considered to
346- // be valid namespaces (to better match Python import semantics).
347- //===================================================================
348-
335+ /// <summary>
336+ /// Scans an assembly for exported namespaces, adding them to the
337+ /// mapping of valid namespaces. Note that for a given namespace
338+ /// a.b.c.d, each of a, a.b, a.b.c and a.b.c.d are considered to
339+ /// be valid namespaces (to better match Python import semantics).
340+ /// </summary>
349341 internal static void ScanAssembly ( Assembly assembly )
350342 {
351343 // A couple of things we want to do here: first, we want to
@@ -390,20 +382,18 @@ public static AssemblyName[] ListAssemblies()
390382 return names . ToArray ( ) ;
391383 }
392384
393- //===================================================================
394- // Returns true if the given qualified name matches a namespace
395- // exported by an assembly loaded in the current app domain.
396- //===================================================================
397-
385+ /// <summary>
386+ /// Returns true if the given qualified name matches a namespace
387+ /// exported by an assembly loaded in the current app domain.
388+ /// </summary>
398389 public static bool IsValidNamespace ( string name )
399390 {
400391 return ! String . IsNullOrEmpty ( name ) && namespaces . ContainsKey ( name ) ;
401392 }
402393
403- //===================================================================
404- // Returns list of assemblies that declare types in a given namespace
405- //===================================================================
406-
394+ /// <summary>
395+ /// Returns list of assemblies that declare types in a given namespace
396+ /// </summary>
407397 public static IEnumerable < Assembly > GetAssemblies ( string nsname )
408398 {
409399 if ( ! namespaces . ContainsKey ( nsname ) )
@@ -412,10 +402,9 @@ public static IEnumerable<Assembly> GetAssemblies(string nsname)
412402 return namespaces [ nsname ] . Keys ;
413403 }
414404
415- //===================================================================
416- // Returns the current list of valid names for the input namespace.
417- //===================================================================
418-
405+ /// <summary>
406+ /// Returns the current list of valid names for the input namespace.
407+ /// </summary>
419408 public static List < string > GetNames ( string nsname )
420409 {
421410 //Dictionary<string, int> seen = new Dictionary<string, int>();
@@ -460,12 +449,11 @@ public static List<string> GetNames(string nsname)
460449 return names ;
461450 }
462451
463- //===================================================================
464- // Returns the System.Type object for a given qualified name,
465- // looking in the currently loaded assemblies for the named
466- // type. Returns null if the named type cannot be found.
467- //===================================================================
468-
452+ /// <summary>
453+ /// Returns the System.Type object for a given qualified name,
454+ /// looking in the currently loaded assemblies for the named
455+ /// type. Returns null if the named type cannot be found.
456+ /// </summary>
469457 public static Type LookupType ( string qname )
470458 {
471459 foreach ( Assembly assembly in assemblies )
@@ -528,8 +516,8 @@ public IEnumerator GetEnumerator()
528516 }
529517
530518 /// <summary>
531- /// Enumerator wrapping around <see cref="AssemblyList._list"/>'s enumerator.
532- /// Acquires and releases a read lock on <see cref="AssemblyList._lock"/> during enumeration
519+ /// Enumerator wrapping around <see cref="AssemblyList._list" />'s enumerator.
520+ /// Acquires and releases a read lock on <see cref="AssemblyList._lock" /> during enumeration
533521 /// </summary>
534522 private class Enumerator : IEnumerator < Assembly >
535523 {
0 commit comments