title: PublishTrimmed with Autofac assembly scanning
body: <p>I have <code>&lt;PublishTrimmed&gt;</code> enabled for my C# .NET 6 console app. It uses Autofac to register types. In some cases, I scan the current application for classes implementing an interface like so:</p>
  <pre class="lang-cs prettyprint-override"><code>// Register all types deriving from CliFx's ICommand. These are all of our supported subcommands.
  builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
      .Where(t =&gt; t.IsAssignableTo(typeof(ICommand)));
  </code></pre>
  <p>I get an analysis warning here because <code>RegisterAssemblyTypes()</code> is decorated with the <code>RequiresUnreferencedCode</code> attribute. However, all of my <code>ICommand</code> implementations are still available at run time (determined by running all of the subcommands and seeing the program function).</p>
  <p>I have chosen to suppress this analysis issue using the <code>UnconditionalSuppressMessage</code> attribute on the calling method, but I'd like to understand if I'm doing the right thing. I did read several topics in the MS docs about trimming, but it is still not clear to me how these <code>ICommand</code> subclasses are not getting stripped. Can someone explain to me how I can tell if certain assembly scanning operations for DI purposes are safe for trimming or not? Is it because I'm scanning the &quot;executing assembly&quot; that it is safe?</p>