Wrong values of Kernel32.FileShare.Delete and Kernel32.FileAttributes.PosixSemantics
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
TruePath/Kernel32.csを開き、FileShare.DeleteとFileAttributes.PosixSemanticsの宣言を、issueに記載されたWindowsの値と照合してください。これらのメンバーは現在使われていないため、2つの修正を行う前に、プロジェクトに関連するinteropテストや参照があるか確認してください。両方のenum値が指定された定数と一致し、プロジェクトがビルドできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C#
- スター
- 107
- フォーク
- 22
- 平均マージ
- 3日 2時間
- マージ済み PR(30日)
- 13
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ForNeVeR/TruePath のほかの issue
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ForNeVeR/TruePath#240 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ForNeVeR/TruePath#165 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
documentation help wanted
難易度 3/5 1〜2日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
bug good first issue help wanted
難易度 3/5 半日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
enhancement help wanted
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
ForNeVeR/TruePath の issue をすべて見る
似ている issue
-
Backend enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
dimitar-radenkov/Pointframe#271 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
qew21/Genshin-Subtitles#45 ·
-
bug priority: P2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
space-wizards/RobustToolbox#7158 ·
メンテナーはふだん 1 日以内に返信