Search code examples
c#.net-coreresharpersystem.reflectionrider

Retrieval of types from all assemblies in .net core solution in Rider/ReSharper


We were using this code in a .NET core test project to get all of our relevant (in solution) assemblies, which we can use to get all their types:

List<Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().FullName.StartsWith("Company.Name")).ToList();

This works on Windows via dotnet test or the visual studio test explorer, but on Mac on rider or the resharper test explorer it only returns the test assembly, which only includes the types specified in the test project.

It's been changed to recurse over Assembly.GetReferencedAssemblies(), which works as desired. I was wondering: What is the difference between the two platforms test runners, and is there a simpler solution than Assembly.GetReferencedAssemblies()?


Solution

  • The assemblies aren't loaded by design in order to match the regular dotnet assembly loading behaviour