public void ProcessExceptionTypes(string excTypeFile) { string[] excTypes = File.ReadAllLines(excTypeFile); DefineTracker defineTracker = new DefineTracker(defineConstants, Log, excTypeFile); foreach (string def in excTypes) { if (defineTracker.ProcessLine(def) || !defineTracker.IsActiveSection) { continue; } // E.g., DEFINE_EXCEPTION(g_InteropNS, MarshalDirectiveException, false, COR_E_MARSHALDIRECTIVE) if (def.StartsWith("DEFINE_EXCEPTION(")) { char[] separators = { ',', '(', ')', ' ', '\t' }; string[] defElements = def.Split(separators, StringSplitOptions.RemoveEmptyEntries); string classId = null; string classNamespace = defElements[1]; // g_InteropNS string className = defElements[2]; // MarshalDirectiveException AddClass(classNamespace, className, classId); AddMethod(".ctor", classId, classNamespace, className); } } }
public void ProcessCoreTypes(string corTypeFile) { string[] corTypes = File.ReadAllLines(corTypeFile); DefineTracker defineTracker = new DefineTracker(defineConstants, Log, corTypeFile); foreach (string def in corTypes) { if (defineTracker.ProcessLine(def) || !defineTracker.IsActiveSection) { continue; } // E.g., TYPEINFO(ELEMENT_TYPE_VOID, "System", "Void", 0, TYPE_GC_NONE, false, true, false, false, false) // 0x01 if (def.StartsWith("TYPEINFO(")) { char[] separators = { ',', '(', ')', '"', ' ', '\t' }; string[] defElements = def.Split(separators, StringSplitOptions.RemoveEmptyEntries); string classId = null; string classNamespace = defElements[2]; // System string className = defElements[3]; // Void AddClass(classNamespace, className, classId); } } }
void ProcessMscorlib(string typeFile) { string[] types = File.ReadAllLines(typeFile); DefineTracker defineTracker = new DefineTracker(defineConstants, Log, typeFile); string classId; foreach (string def in types) { if (defineTracker.ProcessLine(def) || !defineTracker.IsActiveSection) { continue; } string[] defElements = null; if (def.StartsWith("DEFINE_") || def.StartsWith("// DEFINE_")) { char[] separators = { ',', '(', ')', ' ', '\t', '/' }; defElements = def.Split(separators, StringSplitOptions.RemoveEmptyEntries); } if (def.StartsWith("DEFINE_CLASS(") || def.StartsWith("// DEFINE_CLASS(")) { // E.g., DEFINE_CLASS(APP_DOMAIN, System, AppDomain) classId = defElements[1]; // APP_DOMAIN string classNamespace = defElements[2]; // System string className = defElements[3]; // AppDomain AddClass(classNamespace, className, classId); } else if (def.StartsWith("DEFINE_CLASS_U(")) { // E.g., DEFINE_CLASS_U(System, AppDomain, AppDomainBaseObject) string classNamespace = defElements[1]; // System string className = defElements[2]; // AppDomain classId = defElements[3]; // AppDomainBaseObject // For these classes the sizes of managed and unmanaged classes and field offsets // are compared so we need to preserve all fields. const bool keepAllFields = true; AddClass(classNamespace, className, classId, keepAllFields); } else if (def.StartsWith("DEFINE_FIELD(")) { // E.g., DEFINE_FIELD(ACCESS_VIOLATION_EXCEPTION, IP, _ip) classId = defElements[1]; // ACCESS_VIOLATION_EXCEPTION string fieldName = defElements[3]; // _ip AddField(fieldName, classId); } else if (def.StartsWith("DEFINE_METHOD(")) { // E.g., DEFINE_METHOD(APP_DOMAIN, ON_ASSEMBLY_LOAD, OnAssemblyLoadEvent, IM_Assembly_RetVoid) string methodName = defElements[3]; // OnAssemblyLoadEvent classId = defElements[1]; // APP_DOMAIN AddMethod(methodName, classId); } else if (def.StartsWith("DEFINE_PROPERTY(") || def.StartsWith("DEFINE_STATIC_PROPERTY(")) { // E.g., DEFINE_PROPERTY(ARRAY, LENGTH, Length, Int) // or DEFINE_STATIC_PROPERTY(THREAD, CURRENT_THREAD, CurrentThread, Thread) string propertyName = defElements[3]; // Length or CurrentThread classId = defElements[1]; // ARRAY or THREAD AddMethod("get_" + propertyName, classId); } else if (def.StartsWith("DEFINE_SET_PROPERTY(")) { // E.g., DEFINE_SET_PROPERTY(THREAD, UI_CULTURE, CurrentUICulture, CultureInfo) string propertyName = defElements[3]; // CurrentUICulture classId = defElements[1]; // THREAD AddMethod("get_" + propertyName, classId); AddMethod("set_" + propertyName, classId); } } }