dotnet-csharp-pattern-mining
Mine .NET platform compatibility and migration code patterns; read-only metrics with autoFix classification
# dotnet-csharp-pattern-mining
Read-only **mining codemod** that detects .NET platform compatibility and migration code patterns in C# source. Each finding includes an `autoFix` classification (`yes`, `partial`, `no`) and a risk level. No files are written to the target repo.
> **Registry:** private. Use the public [`dotnet-migration-assessment-bundle`](../dotnet-migration-assessment-bundle/) to run all miners in one workflow.
## What it does
Scans `.cs` files for legacy platform APIs and migration-sensitive code patterns, including:
| Pattern | Category | Risk |
| ------- | -------- | ---- |
| `BinaryFormatter` | code-pattern | critical |
| `HttpContext.Current` | code-pattern | high |
| `ConfigurationManager` | code-pattern | medium |
| `Thread.Abort` | code-pattern | high |
| `AppDomains` | platform | high |
| `Reflection.Emit` | platform | high |
| `System.Web usage` | platform | high |
| `COM Interop` (DllImport) | platform | high |
| `Registry usage` | platform | high |
| `Windows-only APIs` | platform | medium |
| `Reflection-heavy code` | platform | medium |
| `WCF ServiceContract` | code-pattern | high |
| `WebForms Page` | code-pattern | critical |
| `EF6 DbContext` | code-pattern | high |
| `OWIN IAppBuilder` | code-pattern | high |
| `Web API 2 ApiController` | code-pattern | high |
## Metrics
| Metric | Cardinalities |
| ------ | ------------- |
| `dotnet-csharp-pattern` | `pattern`, `category`, `autoFix`, `risk`, `file`, `line`, `snippet` |
## Run
**Via bundle (recommended):**
```bash
npx codemod@latest workflow run -w codemods/dotnet-migration-assessment/dotnet-migration-assessment-bundle \
-t /path/to/dotnet/repo \
--allow-dirty --no-interactive
```
**Standalone (local monorepo):**
```bash
npx codemod@latest workflow run -w codemods/dotnet-migration-assessment/dotnet-csharp-pattern-mining \
-t /path/to/dotnet/repo \
--allow-dirty --no-interactive
```
## Testing
```bash
npm test
```