Skip to content

ExcludeFromIndagoAttribute

[AttributeUsage(AttributeTargets.Assembly)]
public class ExcludeFromIndagoAttribute : Attribute

ExcludeFromIndagoAttribute is an assembly-level attribute that tells the Indago generator to exclude the entire assembly from compiled type provider resolution. An excluded assembly will not contribute types to any GetAssemblies, GetTypes, or Scan call in other assemblies.

Note: The excluded assembly itself still has access to the compiled type provider — it can call IIndagoProvider methods normally. Only its own types are hidden from resolution in other assemblies that scan it.

Place the attribute in any file within the assembly you want to exclude, using the [assembly:] target:

[assembly: ExcludeFromIndago]

A common convention is to put assembly-level attributes in an AssemblyInfo.cs file or directly in the project’s top-level Program.cs.

  • Test assemblies — prevent test fixture types, fakes, and stubs from appearing in production DI scans when the test project is referenced.
  • Internal implementation assemblies — a helper assembly that should never be scanned by consuming projects.
  • Third-party or generated assemblies — assemblies you reference but do not control, where you want to prevent their types from appearing in a broad FromAssemblies() scan.

This is a build-time decision. The Roslyn generator reads [ExcludeFromIndago] from the assembly metadata during the build. The exclusion is baked into the generated provider — there is no runtime check and no performance cost.

[ExcludeFromIndago] applies at the assembly level and takes precedence over everything else. Types in the excluded assembly will not appear in scan results even if those types carry [ServiceRegistration] or are otherwise matched by a fluent selector.