Optimised ClassAttributeClass a bit more

This commit is contained in:
2026-01-24 22:26:59 +00:00
parent e905c1f7c5
commit 752b440e68

View File

@@ -21,23 +21,10 @@ namespace PashaBibko.Pacore
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
private static void ScanAllAssemblies() private static void ScanAllAssemblies()
{
using (CodeProfiler.Start("Assembly scan"))
{ {
/* Fetches all the class types in all loaded assemblies */ /* Fetches all the class types in all loaded assemblies */
Type[] classes = AppDomain.CurrentDomain.GetAssemblies() // Assembly[] Type[] classes = AppDomain.CurrentDomain.GetAssemblies() // Assembly[]
.SelectMany(assembly => .SelectMany(assembly => assembly.GetTypes()) // IEnumerable<Type>
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException err)
{
return err.Types.Where(t => t != null);
}
}) // IEnumerable<Type>
.Where(type => type.IsClass && !type.IsAbstract) // IEnumerable<Type> .Where(type => type.IsClass && !type.IsAbstract) // IEnumerable<Type>
.ToArray(); .ToArray();
@@ -69,5 +56,4 @@ namespace PashaBibko.Pacore
} }
} }
} }
}
} }