Skip to content

Conversation

@caesay
Copy link
Member

@caesay caesay commented Aug 16, 2025

No description provided.

@caesay caesay requested a review from Copilot August 16, 2025 15:46
Copy link

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 modernizes the symbolic link handling implementation by removing the dependency on NCode.ReparsePoints and implementing native Windows symlink functionality. The changes consolidate symlink operations into platform-specific implementations while maintaining compatibility across multiple .NET versions.

Key changes:

  • Replaces NCode.ReparsePoints dependency with native Windows P/Invoke implementation
  • Consolidates file and directory symlink creation into a unified method
  • Adds comprehensive test coverage for various symlink scenarios and edge cases

Reviewed Changes

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

File Description
test/Velopack.Tests/SymbolicLinkTests.cs Adds extensive test coverage for symlink operations, error handling, and cross-platform compatibility
src/lib-csharp/Util/SymbolicLink.cs Refactors main symlink logic to use unified creation method and removes NCode dependency
src/lib-csharp/Util/SymbolicLink.Windows.cs Implements native Windows symlink operations using P/Invoke with reparse point handling
src/lib-csharp/Util/SymbolicLink.Unix.cs Extracts Unix-specific symlink operations with EINTR signal handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

}

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes);
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The P/Invoke declaration for CreateHardLink should be moved to a separate platform-specific file or at least grouped with other Windows-specific code, rather than being embedded in the test class.

Suggested change
static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes);
// Windows-specific interop methods
internal static class WindowsInterop
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes);
}

Copilot uses AI. Check for mistakes.
{
if (!PInvokeWindowsCreateSymlink(linkPath, target, mode)) {
var errorCode = Marshal.GetLastWin32Error();
throw new InvalidOperationException($"Error creating symlink: {errorCode}", new Win32Exception());
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The error message includes the error code but doesn't include the actual Win32Exception message. Consider using new Win32Exception(errorCode) to get the descriptive error message, or include both the code and description in the message.

Suggested change
throw new InvalidOperationException($"Error creating symlink: {errorCode}", new Win32Exception());
var win32Ex = new Win32Exception(errorCode);
throw new InvalidOperationException($"Error creating symlink: {errorCode} - {win32Ex.Message}", win32Ex);

Copilot uses AI. Check for mistakes.
@caesay caesay merged commit 78e6b6f into develop Aug 17, 2025
58 checks passed
@caesay caesay deleted the cs/symlink branch August 17, 2025 10:38
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.

2 participants