Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#241 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@ElectLive ci sta già lavorando.

Dal 18/10/2026.

  • #243 di @ElectLive — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
83/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Apri TruePath/Kernel32.cs e confronta le dichiarazioni di FileShare.Delete e FileAttributes.PosixSemantics con i valori di Windows indicati nell’issue. Questi membri al momento non sono usati, quindi verifica se il progetto contiene test o riferimenti di interop pertinenti prima di apportare le due correzioni. Il lavoro è completato quando entrambi i valori dell’enum corrispondono alle costanti indicate e il progetto viene compilato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
C#
Stelle
109
Fork
26
Merge medio
5g 11h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ForNeVeR/TruePath

Tutte le issue di ForNeVeR/TruePath

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.