> ## Documentation Index
> Fetch the complete documentation index at: https://ancplua.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AL0102 - Type.GetType with dynamic name is not AOT-safe

> Prevents static trimming analysis

Source: [Al0102AvoidTypeGetTypeAnalyzer.cs](https://github.com/ANcpLua/ANcpLua.Analyzers/blob/main/src/ANcpLua.Analyzers/Analyzers/Al0102AvoidTypeGetTypeAnalyzer.cs)

## Description

`Type.GetType()` with a dynamically constructed type name prevents the AOT compiler from performing static analysis, potentially trimming required types.

## Bad Code

```csharp theme={null}
var typeName = $"MyApp.{entityName}Repository";
var type = Type.GetType(typeName);
```

## Good Code

```csharp theme={null}
// Use a dictionary or switch for known types
var type = entityName switch
{
    "Order" => typeof(OrderRepository),
    "Product" => typeof(ProductRepository),
    _ => throw new NotSupportedException()
};
```

## Properties

* **Category**: AOT Testing
* **Severity**: Warning
* **Enabled by default**: True
* **Code fix available**: False

## Configuration

```editorconfig theme={null}
dotnet_diagnostic.AL0102.severity = warning
```
