Conversation
… polyfills Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/1b411be0-eb5c-43a7-9fd6-93384627f60a Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…tory(path, UnixFileMode) polyfills and update File.Open to honor UnixCreateMode Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/e7853e0c-e624-4a1d-8215-ca7fe6187d7f Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
… tests Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/bbf75a82-ff27-4368-8aca-8a1c9962d06e Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@Tyrrrz Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/b67e905f-6bff-4949-a2ce-40d33b8a1641 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…edundant guard in UnixFileMode.cs Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/55b0eb9f-c73f-4a5f-97c4-813976de8016 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds functional Unix file-permission polyfills (beyond the existing UnixCreateMode surface area) so older TFMs can use the .NET 7-style APIs for getting/setting modes and creating directories with an initial mode.
Changes:
- Add
UnixFileModeenum polyfill and implementFile.GetUnixFileMode(string)/File.SetUnixFileMode(string, UnixFileMode)viastat/chmodP/Invokes. - Add
Directory.CreateDirectory(string, UnixFileMode)polyfill that creates the directory then applieschmod. - Add/update tests for Unix permission APIs and update
Signatures.md.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Signatures.md | Updates generated signature inventory for the new APIs/types. |
| PolyShim/Net70/UnixFileMode.cs | Adds UnixFileMode enum type polyfill. |
| PolyShim/Net70/File.cs | Implements GetUnixFileMode/SetUnixFileMode using native stat/chmod. |
| PolyShim/Net70/Directory.cs | Adds Directory.CreateDirectory(path, UnixFileMode) polyfill using chmod. |
| PolyShim/Net60/FileStreamOptions.cs | Adds FileStreamOptions type polyfill including UnixCreateMode. |
| PolyShim/Net60/File.cs | Adds File.Open(path, FileStreamOptions) and applies UnixCreateMode via SetUnixFileMode. |
| PolyShim.Tests/Net70/FileTests.cs | Adds a Unix-only test for GetUnixFileMode/SetUnixFileMode. |
| PolyShim.Tests/Net70/DirectoryTests.cs | Adds a Unix-only test for Directory.CreateDirectory(path, UnixFileMode). |
| PolyShim.Tests/Net60/FileTests.cs | Adds tests for File.Open(path, FileStreamOptions) including a UnixCreateMode scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/dfacad4e-5eb6-49ed-a1bf-922e80443e7b Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/9a4d72f3-8085-4fca-bfb4-a74c57fa004a Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…fills .NET 7 API via ConditionalWeakTable) Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/0d511e8d-7d5e-4bc1-ae77-083e9eeb10b2 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR extends PolyShim’s Unix permission support by adding .NET 7-style UnixFileMode APIs and wiring them into existing file/directory creation polyfills so callers can set/read permissions on Unix platforms.
Changes:
- Added
UnixFileModetype polyfill plusFile.GetUnixFileMode(string)/File.SetUnixFileMode(string, UnixFileMode)implementations viastat/chmodP/Invokes. - Added
Directory.CreateDirectory(string, UnixFileMode)polyfill (create +chmod) and updated signatures accordingly. - Updated/added tests for the new Unix permission APIs and
File.Open(string, FileStreamOptions)UnixCreateMode behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Signatures.md | Updates generated signature list and totals to include new Unix permission APIs. |
| PolyShim/Net70/UnixFileMode.cs | Adds the UnixFileMode enum polyfill. |
| PolyShim/Net70/FileStreamOptions.cs | Adds FileStreamOptions.UnixCreateMode via extension member storage. |
| PolyShim/Net70/File.cs | Implements File.GetUnixFileMode/SetUnixFileMode using stat/chmod. |
| PolyShim/Net70/Directory.cs | Adds Directory.CreateDirectory(path, UnixFileMode) and applies mode via chmod. |
| PolyShim/Net60/FileStreamOptions.cs | Adds the FileStreamOptions type polyfill for pre-.NET 6 targets. |
| PolyShim/Net60/File.cs | Implements File.Open(path, FileStreamOptions) and applies UnixCreateMode on create. |
| PolyShim.Tests/Net70/FileTests.cs | Adds Unix-only tests for File.Get/SetUnixFileMode. |
| PolyShim.Tests/Net70/DirectoryTests.cs | Adds Unix-only tests for Directory.CreateDirectory(path, UnixFileMode). |
| PolyShim.Tests/Net60/FileTests.cs | Adds tests for the File.Open(path, FileStreamOptions) polyfill including UnixCreateMode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Extends the Unix file permission polyfills beyond the no-op
FileStreamOptions.UnixCreateModeproperty to include functional implementations of the related .NET 7 APIs.New polyfills
File.GetUnixFileMode(string path)— P/Invoke tostat(Linux) /stat$INODE64(macOS); extractsst_modefrom a raw 256-byte buffer at the platform-specific offset (macOS: offset 4 /uint16; Linux arm64: offset 16 /uint32; Linux x86_64: offset 24 /uint32). ThrowsPlatformNotSupportedExceptionon Windows.File.SetUnixFileMode(string path, UnixFileMode mode)— P/Invoke tochmod. ThrowsPlatformNotSupportedExceptionon Windows.Directory.CreateDirectory(string path, UnixFileMode unixCreateMode)(Net70/Directory.cs, new file) — creates the directory then callschmod. ThrowsPlatformNotSupportedExceptionon Windows.Updated polyfill
File.Open(string, FileStreamOptions)now callsFile.SetUnixFileModewhenUnixCreateModeis set, for modes that can create files (CreateNew,Create,OpenOrCreate,Append). Previously the property was accepted but silently ignored.Not polyfilled
FileStream(FileStreamOptions)constructor — extension constructors aren't supported by the C# extension member syntax.File.Get/SetUnixFileMode(SafeFileHandle, ...)— requires extracting the native fd from the handle across framework generations; out of scope.