Wrong values of Kernel32.FileShare.Delete and Kernel32.FileAttributes.PosixSemantics
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
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ả
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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ForNeVeR/TruePath
-
enhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ForNeVeR/TruePath#240 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ForNeVeR/TruePath#165 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation help wanted
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue help wanted
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 57/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement help wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ForNeVeR/TruePath
Issue tương tự
-
bug priority: P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Parameterless constructor is not a must-provided by user when a struct has a field initializerĐang mở:watch: Not Triaged dotnet-csharp/svc fundamentals/subsvc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
files-community/Files#19047 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100