Skip to content

v2.1.0

Choose a tag to compare

@windischb windischb released this 13 Nov 16:03
· 6 commits to develop since this release
5c95536

What's New

Multiple File Pattern Support for ResilientFileSystemMonitor — Monitor multiple file extensions and patterns simultaneously with a clean, additive API.

✨ Features

Multiple Pattern Monitoring

Monitor multiple file patterns at once — perfect for scenarios like certificate management where you need to watch multiple formats:

var monitor = ResilientFileSystemMonitor
    .Watch(@"C:\certs")
    .WithFilter("*.pfx", "*.p12", "*.cer")  // Watch all certificate formats
    .OnChanged((sender, e) => ReloadCertificate(e.FullPath))
    .Build();

Additive Pattern Building

Build up patterns incrementally across multiple calls:

var monitor = ResilientFileSystemMonitor
    .Watch(@"C:\logs")
    .WithFilter("*.log")        // Add log files
    .WithFilter("*.txt")        // Add text files
    .WithFilter("error-*.json") // Add error JSON files
    .Build();

Pattern Management

Clear and reset patterns when needed:

builder.WithFilter("*.tmp");
builder.ClearFilters();  // Remove all patterns
builder.WithFilter("*.dat", "*.bin");  // Start fresh

🔧 Technical Details

  • Pattern Matching: Uses FileSystemName.MatchesSimpleExpression (same as FileSearcher) for consistency
  • Wildcards: Supports DOS-style wildcards (* for any characters, ? for single character)
  • Performance: Filename-only matching (not full path) for optimal performance
  • Behavior: Multiple WithFilter() calls are additive — patterns accumulate
  • API: params string[] signature supports flexible syntax: .WithFilter("*.pfx", "*.p12") or .WithFilter(["*.pfx", "*.p12"])

📚 Documentation

  • Updated README with multiple pattern examples
  • Comprehensive guide in resilient-file-system-monitor.md
  • Real-world certificate monitoring example in examples.md

🧪 Testing

  • 9 new comprehensive tests for multiple pattern functionality
  • All 117 tests passing across Windows, Linux, and macOS
  • Validation for edge cases (empty arrays, null patterns, whitespace)

🔄 Backward Compatibility

✅ Fully backward compatible — existing code continues to work without changes. This is a non-breaking addition (MINOR version bump per SemVer).

🚀 Future Plans

Multiple patterns lay the groundwork for advanced glob pattern support (e.g., src/**/*.cs) in future releases via an opt-in FilterMode API.


Full Changelog: https://github.com/cocoar-dev/Cocoar.FileSystem/blob/develop/CHANGELOG.md