@@ -4286,6 +4286,7 @@ bool CLR_RT_Assembly::FindTypeDef(const char *typeName, const char *nameSpace, C
42864286 const CLR_RECORD_TYPEDEF *target = GetTypeDef (0 );
42874287 int tblSize = tablesSize[TBL_TypeDef];
42884288 bool isNestedType = false ;
4289+ std::string extractedNamespace;
42894290
42904291 // Check if typeName contains '/'
42914292 const char *slashPos = strchr (typeName, ' /' );
@@ -4296,10 +4297,19 @@ bool CLR_RT_Assembly::FindTypeDef(const char *typeName, const char *nameSpace, C
42964297
42974298 // Extract the enclosed type name from the '/' backwards to the '.' before
42984299 const char *dotPos = strrchr (typeName, ' .' );
4299- std::string enclosedTypeName (dotPos + 1 , slashPos) ;
4300+ std::string enclosedTypeName;
43004301
4301- // Extract the namespace from the beginning of the string to that '.'
4302- std::string extractedNamespace (typeName, dotPos - typeName);
4302+ if (dotPos != nullptr )
4303+ {
4304+ enclosedTypeName.assign (dotPos + 1 , slashPos);
4305+ // Extract the namespace from the beginning of the string to that '.'
4306+ extractedNamespace.assign (typeName, dotPos - typeName);
4307+ }
4308+ else
4309+ {
4310+ enclosedTypeName.assign (typeName, slashPos);
4311+ extractedNamespace.clear ();
4312+ }
43034313
43044314 // Use the extracted values for further processing
43054315 typeName = extractedTypeName;
@@ -4319,7 +4329,9 @@ bool CLR_RT_Assembly::FindTypeDef(const char *typeName, const char *nameSpace, C
43194329 const char *szNameSpace = GetString (target->nameSpace );
43204330 const char *szName = GetString (target->name );
43214331
4322- if (!strcmp (szName, typeName) && !strcmp (szNameSpace, nameSpace))
4332+ // for nested types, there is no namespace encoded in the type
4333+ // looking at the type name only, does look a bit flaky but it will have to work for now
4334+ if (!strcmp (szName, typeName))
43234335 {
43244336 index.Set (assemblyIndex, i);
43254337 return true ;
0 commit comments