Skip to content

Conversation

@Tyrrrz
Copy link
Owner

@Tyrrrz Tyrrrz commented Nov 16, 2025

No description provided.

Copilot AI review requested due to automatic review settings November 16, 2025 17:30
@Tyrrrz Tyrrrz added the enhancement New feature or request label Nov 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a polyfill implementation for the File.Move(string, string, bool) overload that was introduced in .NET Core 3.0, allowing the method to be used in earlier framework versions. The polyfill enables file moving with an overwrite parameter to control whether existing destination files should be replaced.

  • Implements File.Move with overwrite parameter using File.Copy followed by File.Delete
  • Adds conditional compilation for .NET Framework, .NET Standard, and .NET Core versions prior to 3.0
  • Includes test coverage for scenarios where the destination exists and doesn't exist (both with overwrite=true)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
PolyShim/NetCore30/File.cs Adds polyfill implementation of File.Move with overwrite parameter using Copy+Delete pattern
PolyShim.Tests/NetCore30/FileTests.cs Adds unit tests for the new File.Move overload covering overwrite scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to +24
File.Delete(sourceFileName);
}
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The polyfill implementation is not atomic and could leave the file in both locations if File.Delete fails after File.Copy succeeds. Consider wrapping the delete in a try-catch and handling potential failures, or document this limitation. The standard File.Move is atomic on most filesystems.

Suggested change
File.Delete(sourceFileName);
}
// WARNING: This polyfill is not atomic. If File.Delete fails after File.Copy succeeds,
// the file may exist in both locations. The standard File.Move is atomic on most filesystems.
try
{
File.Delete(sourceFileName);
}
catch (IOException ex)
{
// Optionally, handle or log the error here.
// For now, rethrow to preserve original behavior.
throw;
}

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +38
catch
{
// Ignore
}
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generic catch clause.

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +68
catch
{
// Ignore
}
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generic catch clause.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (c3d1446) to head (d13ef4f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@     Coverage Diff      @@
##   master   #41   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants