Swaggeratr
Swaggeratr copied to clipboard
assembly.DefinedTypes in the FindServiceTypeByPath method of Discoverator.cs can cause a crash
The problem is here:
foreach (Assembly assembly in allAssm)
{
foreach (TypeInfo ti in assembly.DefinedTypes)
{
SwaggeratedAttribute da = ti.GetCustomAttribute<SwaggeratedAttribute>();
if (da != null && da.LocalPath == servicePath)
{
return ti.AsType();
}
}
}
While looping through all assemblies in my local domain one of them happens to have a count of 0 TypeInfo in it's DefinedTypes (I believe that was the problem, otherwise the DefinedTypes property of that assembly is just in a weird state). This ends up crashing the Discoverator. Before "foreach (TypeInfo ti in assembly.DefinedTypes)" there should be some kind of check to see if it'll be possible to loop over the DefinedTypes.
Thanks - I'm still waiting for free time to finish a major cleanup, hopefully I can roll this in too.