# LS3003: File Does Not Match Its Primary Type

## Intent

LS3003 is a compiler check that reports a C# file whose name does not match the type it holds, which sends every reader searching for code that lives somewhere unexpected. This page states what the rule reports, where the warning sits, and how to align the file with its type.

## Reference

### What the rule enforces

LS3003 enforces [Match C# files and primary types](https://litespec.dev/2.0.0/backend/dotnet/naming.md#match-c-files-and-primary-types) (`litespec/backend/dotnet/naming#match-c-files-and-primary-types`). It runs in all five projects. Its category is `LiteSpec.Style`. It reports a warning and is enabled by default, as the [Analyzers overview](https://litespec.dev/2.0.0/analyzers/README.md) describes.

### What the rule reports

The rule reports a C# file whose single top-level type has a different name, and every type after the first when a file holds several top-level types. A dotted file name such as `Order.Validation.cs` matches the part before the first dot, generic arity is ignored, and partial declarations of the same type count once. Only types directly in the compilation unit or a namespace count; nested types never do. The diagnostic sits on the type name.

### Failing example

In a file named `Order.cs`, this type reports:

```csharp
namespace Shop.Domain.Orders;

public sealed class Customer { }
```

### Passing example

In a file named `Order.cs`, this type passes:

```csharp
namespace Shop.Domain.Orders;

public sealed class Order { }
```

### How to fix

Give the file the name of its one primary top-level type, or split the file so each top-level type has its own file.

## Notes

### What the rule ignores

The rule does not report files with no top-level types. It does not run outside the five projects.
