Skip to content

Commit 4df31bc

Browse files
Copilothazzik
andcommitted
Enhance Copilot instructions with examples, limitations, and troubleshooting
Co-authored-by: hazzik <144791+hazzik@users.noreply.github.com>
1 parent b83d348 commit 4df31bc

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/copilot-instructions.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,23 @@ The EF test projects automatically generate documentation:
149149
- Use `ContinuousIntegrationBuild` for reproducible builds
150150
- Source link enabled for debugging into source
151151

152+
### Performance Considerations
153+
- Decompilation results are cached using `ConcurrentDictionary`
154+
- First-time decompilation has higher cost due to IL analysis
155+
- Consider using automatic decompilation in EF Core for better performance
156+
- Complex computed properties may impact query performance
157+
158+
### Troubleshooting Common Issues
159+
1. **"Method body not found"**: Ensure method has implementation (not abstract/interface)
160+
2. **"Unsupported IL instruction"**: Method contains opcodes not yet supported
161+
3. **"Expression tree too complex"**: Simplify computed property logic
162+
4. **EF translation errors**: Not all expressions translate to SQL - test with simple database queries first
163+
164+
## Security Considerations
165+
- Uses Mono.Reflection for IL reading - ensure trusted assemblies only
166+
- Strong-name signed assemblies for integrity
167+
- Be cautious with computed properties containing sensitive logic
168+
152169
## Testing Specific Guidance
153170

154171
### Entity Framework Test Patterns
@@ -183,4 +200,62 @@ public void TestFeatureName()
183200
- Group related functionality in same test group
184201
- Test failures help identify unsupported scenarios
185202

203+
## Example Usage Patterns
204+
205+
### Basic Computed Property
206+
```csharp
207+
class Employee
208+
{
209+
[Computed]
210+
public string FullName => FirstName + " " + LastName;
211+
public string FirstName { get; set; }
212+
public string LastName { get; set; }
213+
}
214+
215+
// Usage in LINQ
216+
var results = employees
217+
.Where(e => e.FullName == "John Doe")
218+
.Decompile() // Translates FullName to FirstName + " " + LastName
219+
.ToList();
220+
```
221+
222+
### Entity Framework Configuration
223+
```csharp
224+
// EF Core automatic decompilation
225+
public class MyDbContext : DbContext
226+
{
227+
protected override void OnConfiguring(DbContextOptionsBuilder options)
228+
{
229+
options.AddDelegateDecompiler(); // Auto-decompiles all queries
230+
}
231+
}
232+
```
233+
234+
## Known Limitations
235+
236+
### Pattern Matching
237+
- `is ... or ...` patterns may not decompile due to compiler optimizations
238+
- Complex switch expressions might not be supported
239+
- Some compiler-generated code cannot be reliably decompiled
240+
241+
### Unsupported Scenarios
242+
- Async/await in computed properties
243+
- Dynamic expressions
244+
- Some advanced C# language features in method bodies
245+
- Recursive computed properties
246+
247+
## Contribution Guidelines
248+
249+
### When Adding New Processors
250+
1. Implement `IProcessor` interface
251+
2. Handle specific IL opcodes in `ProcessInstruction` method
252+
3. Ensure proper stack management in `ProcessorState`
253+
4. Add comprehensive unit tests covering edge cases
254+
255+
### When Adding Entity Framework Support
256+
1. Create new test project following naming convention
257+
2. Implement test infrastructure similar to existing EF test projects
258+
3. Add tests covering various LINQ scenarios
259+
4. Ensure proper documentation generation
260+
186261
This project requires careful attention to IL decompilation accuracy, Entity Framework compatibility, and comprehensive testing across multiple .NET versions.

0 commit comments

Comments
 (0)