// Keeps a list of module builders. We used this to do lookups
// on the modulebuilder using GetType -- needed for arrays
// </remarks>
- static ModuleBuilder [] modules;
+
+ // This is changed from list of ModuleBuilders
+ // to list of Modules for getting addmodule
+ // compiler option working
+ // Anirban - 13.07.2004
+
+ static System.Reflection.Module [] modules;
// <remarks>
// This is the type_cache from the assemblies to avoid
/// <summary>
/// Registers a module builder to lookup types from
/// </summary>
- public static void AddModule (ModuleBuilder mb)
+ public static void AddModule (System.Reflection.Module mb)
{
int top = modules != null ? modules.Length : 0;
- ModuleBuilder [] n = new ModuleBuilder [top + 1];
+ System.Reflection.Module [] n = new System.Reflection.Module [top + 1];
if (modules != null)
modules.CopyTo (n, 0);
modules = n;
}
-
private class StandardModule {
public readonly string Namespace;
public readonly string Name;
if (standardModules != null)
standardModules.CopyTo (n, 0);
- n [top] = new StandardModule(module.Namespace.Name, module.Name) ;
+ string name = module.Name;
+ int split = name.LastIndexOf('.');
+ if (split > 0)
+ name = name.Substring(split+1);
+ n [top] = new StandardModule(module.Namespace.Name, name);
+ // Console.WriteLine("Standard Module added: " + n [top]);
standardModules = n;
}
///
private static void AddStandardModule(Type type)
{
- int top = standardModules != null ? standardModules.Length : 0;
- StandardModule [] n = new StandardModule [top + 1];
+ object[] attributes = type.GetCustomAttributes(false);
+ for (int i = 0; i < attributes.Length; i ++) {
+ if (attributes[i].ToString() == "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute") {
+ int top = standardModules != null ? standardModules.Length : 0;
+ StandardModule [] n = new StandardModule [top + 1];
- if (standardModules != null)
- standardModules.CopyTo (n, 0);
- n [top] = new StandardModule(type.Namespace, type.Name) ;
- standardModules = n;
+ if (standardModules != null)
+ standardModules.CopyTo (n, 0);
+ n [top] = new StandardModule(type.Namespace, type.Name) ;
+ standardModules = n;
+ return;
+ }
+ }
}
//
//
//
- public static Type[] GetPertinentStandardModules(string[] namespaces)
+ public static Type[] GetPertinentStandardModules(params string[] namespaces)
{
ArrayList list = new ArrayList();
foreach(string Namespace in namespaces)
{
- for(int i = 0; i < standardModules.Length; i++)
- if (standardModules[i].Namespace == Namespace)
- list.Add(LookupType(standardModules[i].ToString()));
+ for(int i = 0; i < standardModules.Length; i++) {
+ if (standardModules[i].Namespace == Namespace) {
+ string name = standardModules[i].ToString();
+ Type t = LookupType(name);
+ if (t == null) {
+ System.Console.WriteLine("Could not find standard module '" + name + "'");
+ }
+ else {
+ list.Add(t);
+ }
+ }
+ }
}
return (Type[])list.ToArray(typeof(Type));
}
return t;
}
- foreach (ModuleBuilder mb in modules) {
+ foreach (System.Reflection.Module mb in modules) {
t = mb.GetType (name, false, true);
if (t != null){
return t;
{
CaseInsensitiveHashtable namespaces = new CaseInsensitiveHashtable ();
- foreach (Assembly a in assemblies){
- foreach (Type t in a.GetTypes ()){
+ foreach (Assembly a in assemblies) {
+ foreach (Type t in a.GetTypes ()) {
string ns = t.Namespace;
if (namespaces.Contains (ns))
}
}
- foreach (ModuleBuilder mb in modules){
- foreach (Type t in mb.GetTypes ()){
+ foreach (System.Reflection.Module mb in modules) {
+ foreach (Type t in mb.GetTypes ()) {
string ns = t.Namespace;
if (namespaces.Contains (ns))
namespaces [ns] = ns;
}
}
+
return namespaces;
}
return (MethodInfo) de.Second;
} else
- return pi.GetSetMethod ();
+ return pi.GetSetMethod (true);
}
static public MethodInfo GetPropertySetter (PropertyInfo pi)
return (MethodInfo) de.First;
} else
- return pi.GetGetMethod ();
+ return pi.GetGetMethod (true);
}
/// <summary>
ArrayList method_list = null;
Type current_type = queried_type;
+ if (queried_type == null)
+ throw new ArgumentNullException("queried_type");
bool searching = (original_bf & BindingFlags.DeclaredOnly) == 0;
bool private_ok;
bool always_ok_flag = false;
closure_queried_type = current_type;
Timer.StopTimer (TimerType.MemberLookup);
-bf |= BindingFlags.IgnoreCase;
+ bf |= BindingFlags.IgnoreCase;
list = MemberLookup_FindMembers (current_type, mt, bf, name, out used_cache);
Timer.StartTimer (TimerType.MemberLookup);