Assembly scanner misses non-referenced types

assemblyscanning

(Charles Solar) #1

I don’t know if this even can be addressed - or if it circumvents the purpose of the assembly scanner but I just found out the scanner’s AssemblyScannerReuslts.Types doesn’t contain all types in all scanned assemblies, only some subset of types. (The rules I can’t figure out - some internal .net stuff I think)

You can see the issue from my repo here: https://github.com/volak/nsb_scanner_issue

Set a breakpoint on ReadLine and check the assembly scanner’s found types vs a simple AppDomain.CurrentDomain.GetAssemblies() types.

I don’t know what the exact purpose of AssemblyScannerReuslts.Types is so maybe its not an issue. But I was initially expecting it to include all types found in assemblies not exempt.


(Sean Feldman) #2

Hi Charles,

The scanner scans for the types that are needed for NServiceBus during runtime (handlers, messages, NServiceBus interface implementations, and such). The repo you’re point to will have a type, Program but it has no NServiceBus related types, therefore it won’t show up in the scanner results.

Is that the question you had or I didn’t understand it?


(Charles Solar) #3

That was my initial impression - but if you look at the contents of results.Types it contains a huge list of virtually all types in the assemblies, except the ones that actually matter like Commands.TestStart, Events.Tested, and Handler (which contains a IHandleMessages)

results.Types contains for instance:

LightInject.FuncTypeExtensions
System.ObjectExtensions
NServiceBus.AuditContext
Particular.Licensing

etc etc


(Daniel Marbach) #4

Hi Charles,

The Types property contains types that matched the assembly scanner criteria and not all types. The assembly scanner scans assemblies and their references and adds them to the list if the assemblies reference NServiceBus.Core. Dynamic assemblies or Microsoft assemblies get excluded by default.

If you are interested in how it works here is a suite of tests that covers the functionality of the assembly scanner

Regards
Daniel