Skip to content

Conversation

@SadPencil
Copy link
Contributor

@SadPencil SadPencil commented Sep 24, 2025

Introduce File.CreateHardLink and FileSystemInfo.CreateAsHardLink APIs to create hard links, with platform-specific implementations. Add comprehensive tests for hard link creation, behavior, and error cases for both File and FileInfo.

Implements and closes #69030

Introduce `File.CreateHardLink` and `FileSystemInfo.CreateAsHardLink` APIs to create hard links, with platform-specific implementations. Add comprehensive tests for hard link creation, behavior, and error cases for both File and FileInfo.

Implements dotnet#69030
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Sep 24, 2025
@SadPencil
Copy link
Contributor Author

@dotnet-policy-service agree

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 pull request adds hard link creation APIs to .NET, implementing File.CreateHardLink and FileSystemInfo.CreateAsHardLink methods with platform-specific implementations for Windows and Unix systems.

Key changes:

  • Introduce public APIs for creating hard links in both File and FileSystemInfo classes
  • Add platform-specific implementations using Windows Kernel32 and Unix system calls
  • Implement comprehensive test coverage for hard link functionality

Reviewed Changes

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

Show a summary per file
File Description
src/libraries/System.Runtime/ref/System.Runtime.cs Add public API signatures for CreateHardLink methods
src/libraries/System.Private.CoreLib/src/System/IO/File.cs Implement File.CreateHardLink static method
src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs Implement CreateAsHardLink instance method
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs Windows-specific hard link implementation using Kernel32
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs Unix-specific hard link implementation using link system call
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems Add Windows interop reference for CreateHardLink
src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs Add hard link test utilities and capability detection
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Base/HardLinks/BaseHardLinks.FileSystem.cs Base test class with common hard link test scenarios
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/File/HardLinks.cs Tests for File.CreateHardLink API
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileInfo/HardLinks.cs Tests for FileInfo.CreateAsHardLink API
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/System.IO.FileSystem.Tests.csproj Add test files to project compilation

@SadPencil SadPencil requested a review from jkotas September 26, 2025 14:31
@jkotas jkotas requested review from a team and removed request for jkotas September 26, 2025 14:43
@SadPencil
Copy link
Contributor Author

Hi. May I ask the current review status of this PR?

@SadPencil
Copy link
Contributor Author

@adamsitnik Thanks for your review! All review comments have been addressed. However this ConditionalClass comment requires your attention.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

It looks very good, PTAL at my comments regarding test cleanup.

Copy link
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

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

Thanks.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM, big thanks for your contribution @SadPencil !

@adamsitnik adamsitnik merged commit 7df435d into dotnet:main Oct 22, 2025
141 checks passed
@SadPencil SadPencil deleted the feat-io-hardlink branch October 22, 2025 12:04
@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.IO community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: create hardlinks

4 participants