Swaggeratr icon indicating copy to clipboard operation
Swaggeratr copied to clipboard

assembly.DefinedTypes in the FindServiceTypeByPath method of Discoverator.cs can cause a crash

Open bezz92 opened this issue 10 years ago • 1 comments

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.

bezz92 avatar Oct 17 '14 18:10 bezz92

Thanks - I'm still waiting for free time to finish a major cleanup, hopefully I can roll this in too.

superstator avatar Oct 17 '14 18:10 superstator