{"id":26675611,"url":"https://github.com/linkdata/csharp-variadic-args","last_synced_at":"2025-07-09T04:34:27.917Z","repository":{"id":81889171,"uuid":"72754904","full_name":"linkdata/CSharp-variadic-args","owner":"linkdata","description":"Performant ways of emulating C's VARARGS using P/Invoke or unsafe C#","archived":false,"fork":false,"pushed_at":"2016-11-07T13:09:23.000Z","size":13,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T03:18:50.278Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linkdata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-11-03T14:41:43.000Z","updated_at":"2016-11-03T14:52:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e65c11c-480c-43e0-aac8-be304033e5e3","html_url":"https://github.com/linkdata/CSharp-variadic-args","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/linkdata/CSharp-variadic-args","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2FCSharp-variadic-args","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2FCSharp-variadic-args/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2FCSharp-variadic-args/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2FCSharp-variadic-args/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkdata","download_url":"https://codeload.github.com/linkdata/CSharp-variadic-args/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2FCSharp-variadic-args/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264394593,"owners_count":23601335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-26T03:18:52.585Z","updated_at":"2025-07-09T04:34:27.912Z","avatar_url":"https://github.com/linkdata.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSharp-variadic-args\nPerformant ways of emulating C's VARARGS using P/Invoke or unsafe C#\n\nProvides two sample implementations for passing varidic arguments from C# to native (C).\n\nBoth implementations will pin pointer types (`byte[]` and `string`) for the duration of the native call. The `unsafe` implementation runs faster only because it can use `stackalloc` and avoiding to copy the `VarArg` structure that the safe version uses.\n\n```\n3205 calls/millisecond for SAFE \"OnlyValueTypes\"\n4918 calls/millisecond for UNSAFE \"OnlyValueTypes\"\n2209 calls/millisecond for SAFE \"OnlyValueTypesAndString\"\n2952 calls/millisecond for UNSAFE \"OnlyValueTypesAndString\"\n1617 calls/millisecond for SAFE \"AllTypes\"\n1944 calls/millisecond for UNSAFE \"AllTypes\"\n```\n\nAn interesting note here is that in some cases, pinning strings and buffers isn't the most performant way of passing these values. In the case of a slow native call, pinning objects will degrade GC performance and may cause erratic performance in multithreaded applications. In these situations, it's better to rely on P/Invoke or to use unmanaged memory allocations and make copies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdata%2Fcsharp-variadic-args","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkdata%2Fcsharp-variadic-args","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdata%2Fcsharp-variadic-args/lists"}