Skip to content

Type Exclusions

You can prevent specific types or entire namespaces from appearing in the generated TypeScript output by declaring ExcludeType or ExcludeNamespace item groups.

Exclusions apply to:

  • Commands and queries (excluded types are not generated as proxy classes)
  • Types collected transitively from command/query properties
  • All types collected in library mode

Use ExcludeType with the fully qualified C# type name (namespace + class name):

<ItemGroup>
<ExcludeType TypeName="MyApp.Internal.SecretPayload" />
<ExcludeType TypeName="MyApp.Infrastructure.InfrastructureContext" />
</ItemGroup>

Use ExcludeNamespace with a glob pattern. The * wildcard matches any sequence of characters:

<ItemGroup>
<!-- All types whose namespace starts with MyApp.Internal -->
<ExcludeNamespace Namespace="MyApp.Internal*" />
<!-- All types whose namespace starts with MyApp.Tests -->
<ExcludeNamespace Namespace="MyApp.Tests*" />
</ItemGroup>
PatternMatches
MyApp.Internal*Any namespace that begins with MyApp.Internal
MyApp.*.InternalAny namespace matching that structure exactly (e.g. MyApp.Foo.Internal)
MyApp.InternalThe exact namespace MyApp.Internal only

The * wildcard matches any sequence of characters including ., so MyApp* matches MyApp, MyApp.Features, MyApp.Features.Auth, etc.

You can freely mix ExcludeType and ExcludeNamespace in the same item group:

<ItemGroup>
<ExcludeType TypeName="MyApp.Features.Auth.InternalToken" />
<ExcludeNamespace Namespace="MyApp.Internal*" />
<ExcludeNamespace Namespace="MyApp.Tests*" />
</ItemGroup>

Pass one or more --exclude-type and/or --exclude-namespace flags:

Terminal window
proxygenerator assembly.dll output-path \
--exclude-type=MyApp.Internal.SecretPayload \
--exclude-namespace=MyApp.Tests*