|
| 1 | +# DelegateDecompiler - GitHub Copilot Instructions |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +DelegateDecompiler is a .NET library that decompiles delegates and method bodies to their lambda representation. It enables computed properties in LINQ queries by translating `[Computed]` attributes into executable expressions that can be processed by Entity Framework and other ORMs. |
| 6 | + |
| 7 | +## Core Components |
| 8 | + |
| 9 | +- **`ComputedAttribute`**: Marks properties/methods for decompilation |
| 10 | +- **`MethodBodyDecompiler`**: Core IL decompilation engine |
| 11 | +- **`DecompileExtensions`**: Public API for decompiling delegates/queries |
| 12 | +- **`Processors/`**: Pluggable processors for different IL opcodes |
| 13 | + |
| 14 | +## Build & Test |
| 15 | + |
| 16 | +```bash |
| 17 | +# Restore packages |
| 18 | +dotnet restore |
| 19 | + |
| 20 | +# Build the solution |
| 21 | +dotnet build --no-restore -c Release -p:DisableGitVersionTask=true |
| 22 | + |
| 23 | +# Run tests |
| 24 | +dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.Tests |
| 25 | +dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.Tests.VB |
| 26 | +dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.EntityFramework.Tests |
| 27 | +dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.EntityFrameworkCore6.Tests |
| 28 | +dotnet test --no-build -c Release -f net8.0 src/DelegateDecompiler.EntityFrameworkCore8.Tests |
| 29 | +dotnet test --no-build -c Release -f net9.0 src/DelegateDecompiler.EntityFrameworkCore9.Tests |
| 30 | +``` |
| 31 | + |
| 32 | +**Development Guidelines:** |
| 33 | +- Use test-first approach when adding new features or fixing bugs |
| 34 | +- Ensure core unit tests pass: `src/DelegateDecompiler.Tests` and `src/DelegateDecompiler.Tests.VB` should have no failures |
| 35 | +- Run unit tests frequently during development to catch regressions early |
| 36 | + |
| 37 | +## Project Structure |
| 38 | + |
| 39 | +``` |
| 40 | +src/ |
| 41 | +├── DelegateDecompiler/ # Core library |
| 42 | +├── DelegateDecompiler.EntityFramework/ # EF 6.x support |
| 43 | +├── DelegateDecompiler.EntityFrameworkCore5/ # EF Core 5+ support |
| 44 | +├── DelegateDecompiler.Tests/ # Core library tests |
| 45 | +└── DelegateDecompiler.EntityFramework*.Tests/ # EF integration tests |
| 46 | +``` |
| 47 | + |
| 48 | +## Usage Example |
| 49 | + |
| 50 | +```csharp |
| 51 | +class Employee |
| 52 | +{ |
| 53 | + [Computed] |
| 54 | + public string FullName => FirstName + " " + LastName; |
| 55 | + public string FirstName { get; set; } |
| 56 | + public string LastName { get; set; } |
| 57 | +} |
| 58 | + |
| 59 | +// Usage in LINQ - decompiles FullName to FirstName + " " + LastName |
| 60 | +var results = employees |
| 61 | + .Where(e => e.FullName == "John Doe") |
| 62 | + .Decompile() |
| 63 | + .ToList(); |
| 64 | +``` |
| 65 | + |
| 66 | +## Development Notes |
| 67 | + |
| 68 | +- **Target Frameworks**: .NET Framework 4.0/4.5, .NET Standard 2.0/2.1, .NET 8.0/9.0 |
| 69 | +- **Key Dependency**: Mono.Reflection for IL reading |
| 70 | +- **Testing**: NUnit with automatic documentation generation for EF tests |
| 71 | +- **Architecture**: Pluggable processor pattern for handling IL opcodes |
| 72 | +- **Performance**: Decompilation results are cached using `ConcurrentDictionary` |
0 commit comments