Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#241 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@ElectLive 已经在做这个了。

开始于 2026年10月18日。

  • #243 来自 @ElectLive —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
83/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
csharp
领域
backend

调研方向

打开TruePath/Kernel32.cs,并将FileShare.Delete和FileAttributes.PosixSemantics的声明与 issue 中给出的 Windows 值进行核对。这些成员目前未使用,因此在进行两处更正之前,请确认项目是否有相关的 interop 测试或引用。两项 enum 值都与给出的常量一致且项目构建成功,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
C#
星标
107
派生
22
平均合并
3 天 2 小时
30 天内合并 PR
13

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ForNeVeR/TruePath 的其他 Issue

查看 ForNeVeR/TruePath 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。