Skip to content

Conversation

@lucaspimentel
Copy link
Member

@lucaspimentel lucaspimentel commented Nov 25, 2025

Summary

This PR removes the Mono.Unix package dependency that was added in #211. This removes the only external dependency. Furthermore, Mono.Unix nuget package versions are all considered pre-releases (semver), which blocks many users from using dogstatsd-csharp-client.

Changes

  • Remove Mono.Unix dependency
  • Add NativeMethods.cs with direct P/Invoke to libc stat() function
  • Update IFileSystem.TryStat() to use the new implementation instead of Mono.Unix.Native.Syscall.stat()
  • Restore file UnixEndPoint.cs for UDS support (originally from Mono.Unix, was removed in [AGTMETRICS-347]Add cgroup origin detection #211)
  • Misc: set C# language version to latest to enable modern syntax like file-scoped namespaces and nullable reference types

Testing

No user-facing behavior changes aside from removing the Mono.Unix dependency.

  • TODO: All existing tests run and pass.

@lucaspimentel lucaspimentel changed the title Lpimentel/remove mono unix Remove Mono.Unix dependency Nov 25, 2025
@lucaspimentel lucaspimentel changed the title Remove Mono.Unix dependency Remove Mono.Unix dependency Nov 25, 2025
@lucaspimentel lucaspimentel force-pushed the lpimentel/remove-mono-unix branch 2 times, most recently from ab0204a to da222f4 Compare November 26, 2025 05:02
@lucaspimentel lucaspimentel force-pushed the lpimentel/remove-mono-unix branch from da222f4 to 2892d63 Compare November 26, 2025 05:10
@lucaspimentel lucaspimentel marked this pull request as ready for review November 26, 2025 05:44
@lucaspimentel lucaspimentel requested a review from a team as a code owner November 26, 2025 05:44
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +65 to +69
public ulong st_dev; // Device
public ulong st_ino; // File serial number (inode)
public uint st_mode; // File mode
public uint st_nlink; // Link count
public uint st_uid; // User ID of the file's owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fix Linux stat struct size for P/Invoke

On 64‑bit Linux (e.g., ubuntu-latest runners) the native struct stat layout uses 64‑bit st_nlink/st_blksize with a total size of 144 bytes (/usr/include/x86_64-linux-gnu/bits/struct_stat.h), but StatStructLinux declares those fields as 32‑bit and omits the trailing padding, making the managed struct only 128 bytes. The P/Invoke call to stat() therefore writes past the allocated buffer, which can corrupt the stack or return garbage whenever TryStat runs (OriginDetection calls it during startup). The struct definition needs to match the platform layout (e.g., 64‑bit fields or use stat64) to avoid undefined behavior.

Useful? React with 👍 / 👎.

@lucaspimentel lucaspimentel changed the title Remove Mono.Unix dependency [DO NOT MERGE] Remove Mono.Unix dependency Nov 26, 2025
@lucaspimentel lucaspimentel marked this pull request as draft November 26, 2025 16:47
@lucaspimentel
Copy link
Member Author

Closing in favor of #223

@lucaspimentel lucaspimentel deleted the lpimentel/remove-mono-unix branch December 1, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants