Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 12, 2025

Summary

This PR adds a static constructor to the TemporaryFiles class that automatically calls DeleteAllPreviouslyUsed() when the class is first accessed.

Changes Made

  • Added static constructor to TemporaryFiles class at csharp/Platform.IO/TemporaryFiles.cs:21-24
  • Static constructor calls DeleteAllPreviouslyUsed() method to clean up temporary files from previous runs
  • Includes bilingual documentation (English/Russian) following project conventions

Benefits

  • Automatic cleanup: Temporary files from previous application runs are automatically cleaned up when the class is first loaded
  • Zero configuration: No additional setup required - cleanup happens transparently
  • Resource management: Prevents accumulation of unused temporary files over time

Implementation Details

The static constructor is triggered automatically when:

  • TemporaryFiles.UseNew() is called for the first time
  • Any static member of TemporaryFiles is accessed
  • A TemporaryFile instance is created (which calls TemporaryFiles.UseNew())

This ensures that cleanup happens exactly once per application run, at the earliest possible moment when temporary file functionality is needed.

Test Plan

  • ✅ Project builds successfully with no errors
  • ✅ Existing unit tests pass (2/2 tests passing)
  • ✅ Integration test with TemporaryFile class works correctly
  • ✅ Static constructor follows C# language specifications

Fixes

Fixes #85

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #85
@konard konard self-assigned this Sep 12, 2025
- Adds static constructor that calls DeleteAllPreviouslyUsed()
- Ensures automatic cleanup of temporary files from previous runs
- Static constructor is called when the class is first accessed
- Includes bilingual documentation (English/Russian)

Fixes #85

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] This method should be called in the static constructor of TemporaryFiles class Add static constructor to TemporaryFiles class Sep 12, 2025
@konard konard marked this pull request as ready for review September 12, 2025 19:34
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

This method should be called in the static constructor of TemporaryFiles class

2 participants