Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Wrong values of Kernel32.FileShare.Delete and Kernel32.FileAttributes.PosixSemantics

Đang mở Phù hợp với người mới
#241 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@ElectLive đang làm issue này rồi.

Từ ngày 18/10/2026.

  • #243 của @ElectLive — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
83/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend

Hướng nghiên cứu

Mở TruePath/Kernel32.cs và đối chiếu các khai báo của FileShare.Delete và FileAttributes.PosixSemantics với các giá trị Windows được nêu trong issue. Các thành viên này hiện không được sử dụng, vì vậy hãy xác nhận xem dự án có các bài kiểm thử hoặc tham chiếu interop liên quan hay không trước khi thực hiện hai chỉnh sửa. Công việc hoàn tất khi cả hai giá trị enum khớp với các hằng số đã nêu và dự án build thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug good first issue help wanted

Two members of the Win32 interop enums in Kernel32.cs have values that don't match the Windows headers:

Member Current value Correct value
FileShare.Delete 0x03 (that is Read | Write) 0x04 (FILE_SHARE_DELETE)
FileAttributes.PosixSemantics 0x0100000 (seven digits, 0x100000) 0x01000000 (FILE_FLAG_POSIX_SEMANTICS)

As written, PosixSemantics has the same value as OpenNoRecall (0x00100000, line 96).

Neither member is used anywhere right now (only FileShare.Read is), so nothing is broken today. But passing either one to CreateFile would silently request different behavior from the one intended: FileShare.Delete would grant read and write sharing instead of delete sharing, and PosixSemantics would request FILE_FLAG_OPEN_NO_RECALL instead.

Repro (the enums are internal, hence the reflection):

var k32 = typeof(AbsolutePath).Assembly.GetType("TruePath.Kernel32")!;
uint Get(string type, string name) =>
    Convert.ToUInt32(Enum.Parse(k32.GetNestedType(type, BindingFlags.NonPublic)!, name));

Console.WriteLine($"0x{Get("FileShare", "Delete"):X}");                  // 3, expected 4
Console.WriteLine($"0x{Get("FileAttributes", "PosixSemantics"):X}");     // 100000, expected 1000000

All the other constants in the file (FileAttributes, FileAccess, FileShare, the FSCTL_*/IOCTL_* codes, the reparse tags) match the Windows headers.

Recommendations

  • Fix the two values.
  • Prefer not to hand-roll these declarations at all: either delete the unused members, or generate the interop with CsWin32, which takes the values from the official metadata.
Ngôn ngữ chính
C#
Star
107
Fork
22
Merge trung bình
3 ngày 2 giờ
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ForNeVeR/TruePath

Tất cả issue của ForNeVeR/TruePath

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.