|
| 1 | +# Copilot Instructions for ManagedCode.Storage |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +ManagedCode.Storage is a universal storage abstraction library that provides a consistent interface for working with multiple cloud blob storage providers including Azure Blob Storage, AWS S3, Google Cloud Storage, and local file system. The library aims to simplify development by providing a single API for all storage operations. |
| 6 | + |
| 7 | +## Project Structure |
| 8 | + |
| 9 | +- **ManagedCode.Storage.Core**: Core abstractions and interfaces (IStorage, BaseStorage, etc.) |
| 10 | +- **Storages/**: Provider-specific implementations |
| 11 | + - `ManagedCode.Storage.Azure`: Azure Blob Storage implementation |
| 12 | + - `ManagedCode.Storage.Aws`: AWS S3 implementation |
| 13 | + - `ManagedCode.Storage.Google`: Google Cloud Storage implementation |
| 14 | + - `ManagedCode.Storage.FileSystem`: Local file system implementation |
| 15 | + - `ManagedCode.Storage.Sftp`: FTP storage implementation |
| 16 | + - `ManagedCode.Storage.Azure.DataLake`: Azure Data Lake implementation |
| 17 | +- **Tests/**: Unit and integration tests |
| 18 | +- **Integrations/**: Additional integrations (SignalR, Client/Server components) |
| 19 | + |
| 20 | +## Technical Context |
| 21 | + |
| 22 | +- **Target Framework**: .NET 9.0 |
| 23 | +- **Language Version**: C# 13 |
| 24 | +- **Architecture**: Provider pattern with unified interfaces |
| 25 | +- **Key Features**: Async/await support, streaming operations, metadata handling, progress reporting |
| 26 | + |
| 27 | +## Development Guidelines |
| 28 | + |
| 29 | +### Code Style & Standards |
| 30 | +- Use nullable reference types (enabled in project) |
| 31 | +- Follow async/await patterns consistently |
| 32 | +- Use ValueTask for performance-critical operations where appropriate |
| 33 | +- Implement proper cancellation token support in all async methods |
| 34 | +- Use ConfigureAwait(false) for library code |
| 35 | +- Follow dependency injection patterns |
| 36 | + |
| 37 | +### Key Interfaces & Patterns |
| 38 | +- `IStorage`: Main storage interface for blob operations |
| 39 | +- `IStorageOptions`: Configuration options for storage providers |
| 40 | +- `BaseStorage`: Base implementation with common functionality |
| 41 | +- All operations should support progress reporting via `IProgress<T>` |
| 42 | +- Use `BlobMetadata` for storing blob metadata |
| 43 | +- Support for streaming operations with `IStreamer` |
| 44 | + |
| 45 | +### Performance Considerations |
| 46 | +- Implement efficient streaming for large files |
| 47 | +- Use memory-efficient approaches for data transfer |
| 48 | +- Cache metadata when appropriate |
| 49 | +- Support parallel operations where beneficial |
| 50 | +- Minimize allocations in hot paths |
| 51 | + |
| 52 | +### Testing Approach |
| 53 | +- Unit tests for core logic |
| 54 | +- Integration tests for provider implementations |
| 55 | +- Use test fakes/mocks for external dependencies |
| 56 | +- Test error scenarios and edge cases |
| 57 | +- Validate async operation behavior |
| 58 | + |
| 59 | +### Provider Implementation Guidelines |
| 60 | +When implementing new storage providers: |
| 61 | +1. Inherit from `BaseStorage` class |
| 62 | +2. Implement all required interface methods |
| 63 | +3. Handle provider-specific errors appropriately |
| 64 | +4. Support all metadata operations |
| 65 | +5. Implement efficient streaming operations |
| 66 | +6. Add comprehensive tests |
| 67 | +7. Document provider-specific limitations or features |
| 68 | + |
| 69 | +### Error Handling |
| 70 | +- Use appropriate exception types for different error scenarios |
| 71 | +- Provide meaningful error messages |
| 72 | +- Handle provider-specific errors and translate to common exceptions |
| 73 | +- Support retry mechanisms where appropriate |
| 74 | + |
| 75 | +### Documentation |
| 76 | +- Document public APIs with XML comments |
| 77 | +- Include usage examples for complex operations |
| 78 | +- Document provider-specific behavior differences |
| 79 | +- Keep README.md updated with supported features |
| 80 | + |
| 81 | +## Common Tasks |
| 82 | + |
| 83 | +### Adding a New Storage Provider |
| 84 | +1. Create new project in `Storages/` folder |
| 85 | +2. Inherit from `BaseStorage` |
| 86 | +3. Implement provider-specific operations |
| 87 | +4. Add configuration options |
| 88 | +5. Create comprehensive tests |
| 89 | +6. Update solution file and documentation |
| 90 | + |
| 91 | +### Implementing New Features |
| 92 | +1. Define interface changes in Core project |
| 93 | +2. Update BaseStorage if needed |
| 94 | +3. Implement in all relevant providers |
| 95 | +4. Add tests for new functionality |
| 96 | +5. Update documentation |
| 97 | + |
| 98 | +### Performance Optimization |
| 99 | +- Profile critical paths |
| 100 | +- Optimize memory allocations |
| 101 | +- Improve streaming performance |
| 102 | +- Cache frequently accessed data |
| 103 | +- Use efficient data structures |
| 104 | + |
| 105 | +## Dependencies & Libraries |
| 106 | +- Provider-specific SDKs (Azure.Storage.Blobs, AWS SDK, Google Cloud Storage) |
| 107 | +- Microsoft.Extensions.* for dependency injection and configuration |
| 108 | +- System.Text.Json for serialization |
| 109 | +- Benchmarking tools for performance testing |
| 110 | + |
| 111 | +## Building & Testing |
| 112 | +- Use `dotnet build` to build the solution |
| 113 | +- Run `dotnet test` for unit tests |
| 114 | +- Integration tests may require cloud provider credentials |
| 115 | +- Use `dotnet pack` to create NuGet packages |
0 commit comments