vendredi 1 janvier 2021

Is `GetReferencedAssemblies` a subset of `AppDomain.CurrentDomain.GetAssemblies()`?

I want to test some reflection code I've written.

There's an edge case that would occur if the ReferencedAssemblies were ever not already loaded into the AppDomain, i.e. if the following expression ever returned true:

typeof(MyType).Assembly.GetReferencedAssemblies()
    .Except(AppDomain.CurrentDomain.GetAssemblies().Select(assem => assem.GetName()))
    .Any()

I have 2 questions:

  1. Can that ever return true? (I think "yes", though I'm not certain).
  2. Assuming it can ... then how can I orchestrate that, for the purposes of a unit test?




Aucun commentaire:

Enregistrer un commentaire