mirror of
https://github.com/sbroenne/mcp-server-excel.git
synced 2026-09-19 07:53:08 +08:00
7fe8e9fe51
* Improve Core Integration Tests with State Verification - Add actual Excel state verification to 195+ integration tests - SheetCommands: Verify worksheets created/deleted/renamed via list operations - PowerQuery: Verify load configuration changes and worksheet creation - TableCommands: Verify sort operations with data read-back validation - ParameterCommands: Verify parameter creation/deletion via list operations - FileCommands: Verify Excel workbook structure validation - DataModelCommands: Verify measure deletion via list operations All tests now verify actual Excel state changes, not just API success. Ensures operations actually work in Excel COM interop environment. Fixes comprehensive test reliability and prevents false positives. * Follow-up improvements to Core Integration Test infrastructure - Add COM leak detection script (check-com-leaks.ps1) - Enhance ConnectionCommands with better error handling and type conversion - Improve FileCommands with proper COM cleanup patterns - Update PowerQueryCommands with enhanced query loading logic - Refactor TableCommands DataModel integration for better reliability - Enhance ConnectionHelpers with improved property handling - Update PowerQueryHelpers with better connection string management - Add DataModelLoadingIssueTests for edge case validation - Update critical rules documentation with new COM leak prevention These changes support the improved test verification patterns and ensure reliable Excel COM interop operations across all commands. --------- Co-authored-by: Stefan Broenner <stefan.broenner@microsoft.comm>
44 lines
1.6 KiB
PowerShell
44 lines
1.6 KiB
PowerShell
# COM Object Leak Detection Script
|
|
# Run this before every commit to catch COM leaks
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "🔍 Scanning for COM object leaks..." -ForegroundColor Yellow
|
|
|
|
$leakFiles = @()
|
|
$cleanFiles = @()
|
|
|
|
Get-ChildItem -Path "src" -Recurse -Filter "*.cs" | ForEach-Object {
|
|
$content = Get-Content $_.FullName -Raw
|
|
$hasDynamic = $content -match "dynamic\s+\w+\s*=.*\."
|
|
$hasRelease = $content -match "ComUtilities\.Release"
|
|
$isSessionFile = $_.FullName -match "ExcelBatch\.cs|ExcelSession\.cs"
|
|
|
|
if ($hasDynamic -and -not $hasRelease -and -not $isSessionFile) {
|
|
$leakFiles += $_
|
|
Write-Host "❌ $($_.FullName.Replace((Get-Location).Path + '\', '')) - HAS COM objects but NO cleanup" -ForegroundColor Red
|
|
} elseif ($hasDynamic -and $hasRelease) {
|
|
$cleanFiles += $_
|
|
Write-Host "✅ $($_.FullName.Replace((Get-Location).Path + '\', '')) - Proper COM cleanup" -ForegroundColor Green
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "📊 Summary:" -ForegroundColor Cyan
|
|
Write-Host " ✅ Clean files: $($cleanFiles.Count)" -ForegroundColor Green
|
|
Write-Host " ❌ Leak files: $($leakFiles.Count)" -ForegroundColor Red
|
|
|
|
if ($leakFiles.Count -gt 0) {
|
|
Write-Host ""
|
|
Write-Host "🚨 COM OBJECT LEAKS DETECTED!" -ForegroundColor Red
|
|
Write-Host "Fix these files before committing:" -ForegroundColor Red
|
|
$leakFiles | ForEach-Object {
|
|
Write-Host " - $($_.FullName.Replace((Get-Location).Path + '\', ''))" -ForegroundColor Red
|
|
}
|
|
exit 1
|
|
} else {
|
|
Write-Host ""
|
|
Write-Host "🎉 No COM object leaks detected!" -ForegroundColor Green
|
|
exit 0
|
|
}
|