Wrong values of Kernel32.FileShare.Delete and Kernel32.FileAttributes.PosixSemantics
Mantenedores costumam responder em até 5 dias
Avaliação
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Facilidade para iniciantes
- 83/100
Direção de pesquisa
Abra TruePath/Kernel32.cs e confira as declarações de FileShare.Delete e FileAttributes.PosixSemantics em relação aos valores do Windows informados na issue. Esses membros não são usados atualmente, então confirme se o projeto tem testes ou referências de interop relevantes antes de fazer as duas correções. O trabalho estará concluído quando ambos os valores do enum corresponderem às constantes indicadas e o projeto compilar.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- C#
- Estrelas
- 111
- Forks
- 25
- Merge médio
- 4d 2h
- PRs com merge (30d)
- 8
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de ForNeVeR/TruePath
-
DiskUtils.GetWindowsRealPathByHandle retries GetFinalPathNameByHandle after a hard failure and ignores the required buffer sizeTalvez já em andamento @hamdiakin assumiu há 7 dias. Abertaenhancement help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
ForNeVeR/TruePath#252 · 1 comentário ·
Mantenedores costumam responder em até 5 dias
-
enhancement good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
ForNeVeR/TruePath#165 · 2 comentários ·
Mantenedores costumam responder em até 5 dias
-
bug help wanted
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
Mantenedores costumam responder em até 5 dias
-
enhancement help wanted
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
Mantenedores costumam responder em até 5 dias
-
enhancement help wanted
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
Mantenedores costumam responder em até 5 dias
Todas as issues de ForNeVeR/TruePath
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
Enable "remote"' featureAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
mode_has_nan gives MSVC warning C4702 (unreachable code)Talvez já em andamento @ibmibmibm assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
georgeslegros/stream-deck-pilot#149 ·
Mantenedores costumam responder em até 1 dia
-
enhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
MustacheCase/zanadir#506 ·
Mantenedores costumam responder em até 1 dia