Table of Contents

AL0010: Type should be partial for source generator support

Types that are targets for source generators should be marked as partial.

When it triggers

// AL0010: The type 'MyHandler' should be partial for source generator support
[LoggerMessage(0, LogLevel.Info, "Processing")]
public class MyHandler { }

Why this matters

Source generators in .NET work by generating additional code for your types. This generated code is placed in a separate file but needs to be part of the same type. The partial keyword enables this by allowing a type to be defined across multiple files.

How to fix

Add the partial modifier:

[LoggerMessage(0, LogLevel.Info, "Processing")]
public partial class MyHandler { }

Configuration

This rule is disabled by default. Enable it if you want to enforce partial types for source generator targets:

[*.cs]
dotnet_diagnostic.AL0010.severity = suggestion