{"id":37469128,"url":"https://github.com/simulation-tree/unmanaged","last_synced_at":"2026-01-16T07:13:30.772Z","repository":{"id":281751034,"uuid":"784445124","full_name":"simulation-tree/unmanaged","owner":"simulation-tree","description":"The building blocks of native C# projects","archived":false,"fork":false,"pushed_at":"2025-09-24T03:03:09.000Z","size":829,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-24T04:24:04.983Z","etag":null,"topics":["csharp","dotnet","nativeaot"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simulation-tree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-09T21:41:49.000Z","updated_at":"2025-09-24T02:44:18.000Z","dependencies_parsed_at":"2025-03-11T00:31:19.809Z","dependency_job_id":"5029610c-5905-4278-8797-880e6777efcc","html_url":"https://github.com/simulation-tree/unmanaged","commit_stats":null,"previous_names":["simulation-tree/unmanaged"],"tags_count":85,"template":false,"template_full_name":null,"purl":"pkg:github/simulation-tree/unmanaged","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simulation-tree%2Funmanaged","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simulation-tree%2Funmanaged/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simulation-tree%2Funmanaged/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simulation-tree%2Funmanaged/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simulation-tree","download_url":"https://codeload.github.com/simulation-tree/unmanaged/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simulation-tree%2Funmanaged/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["csharp","dotnet","nativeaot"],"created_at":"2026-01-16T07:13:30.327Z","updated_at":"2026-01-16T07:13:30.766Z","avatar_url":"https://github.com/simulation-tree.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unmanaged\n\n[![Test](https://github.com/simulation-tree/unmanaged/actions/workflows/test.yml/badge.svg)](https://github.com/simulation-tree/unmanaged/actions/workflows/test.yml)\n\nLibrary containing primitives for working with native C#.\n\n### Installation\n\nInstall it by cloning it, or referencing through the NuGet package through GitHub's registry ([authentication info](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry#authenticating-to-github-packages)).\n\nFor installing as a Unity package, use this git url to add it:\n```\nhttps://github.com/simulation-tree/unmanaged.git?path=core#unity\n```\n\n### Memory Addresses\n\n`MemoryAddress` instances can point to either heap or stack memory. They can be\nallocated using static methods, in which case they must also be disposed:\n```cs\n//an allocation that is 10 bytes in size\nusing (MemoryAddress allocation = MemoryAddress.Allocate(sizeof(char) * 5))\n{\n    allocation.Write(\"Hello\".AsSpan());\n    Span\u003cchar\u003e text = allocation.AsSpan\u003cchar\u003e();\n}\n\n//an allocation containing a float\nusing (MemoryAddress allocation = MemoryAddress.Create(3.14f))\n{\n    ref float floatValue = ref allocation.Read\u003cfloat\u003e();\n    floatValue *= 2;\n}\n```\n\n### ASCII Text\n\nThe types prefixed with `ASCIIText` store extended ASCII `char` values. \nUseful for when text is known to be short, until a list/array is needed:\n```cs\nASCIIText16 text = new(\"Hello there\");\nSpan\u003cchar\u003e textBuffer = stackalloc char[text.Length];\ntext.CopyTo(textBuffer);\n\n//get utf8 bytes from the text\nSpan\u003cbyte\u003e utf8bytes = stackalloc char[ASCIIText16.Capacity];\nuint bytesCopied = text.CopyTo(utf8bytes);\n\n//get text from utf8 bytes using System.Text.Encoding\nASCIIText1024 textFromBytes = new(utf8bytes.Slice(0, bytesCopied));\nstring systemString = Encoding.UTF8.GetString(textBuffer.Slice(0, length));\nAssert.That(textFromBytes.ToString(), Is.EqualTo(systemString));\n\n//casting to a smaller type\nASCIIText32 textFromBytesButSmaller = textFromBytes;\nAssert.That(textFromBytesButSmaller.ToString(), Is.EqualTo(systemString));\n```\n\n### Text\n\nAccompanying the above is the disposable `Text` type, which is a reference to an arbitrary amount of `char`s values.\nAnd behaves like a `string`:\n```cs\nusing Text builder = new();\nbuilder.Append(\"Hello\");\nbuilder.Append(\" there\");\n\nReadOnlySpan\u003cchar\u003e text = builder.AsSpan();\nConsole.WriteLine(text.ToString());\n```\n\n### Random Generator\n\nCan generate random data and values using the XORshift technique:\n```cs\nusing RandomGenerator random = new();\nint fairDiceRoll = random.NextInt(0, 6);\n```\n\n\u003e The default random seed is based on process ID, current time, and instance index.\n\n### Safety\n\nWhen working with `MemoryAddress` values, there are checks available to ensure\nthat the memory is not accessed after it has been disposed, or accessed out of bounds.\nThis only occurs in debug mode, or with the `#TRACK` directive defined, and only on\nheap allocated memory through the `MemoryAddress` methods.\n\nUltimately, it is the programmer's responsibility for how memory should be managed. Including\nwhen allocations should be disposed, and how they should be accessed.\n\n### Included `default` analyzer\n\nIncluded is an analyzer that emits errors where a disposable struct type is \nbeing created, but then initialized to `default`. Because disposable types \nimply they have a way to properly initialize them:\n```cs\nAllocation allocation = default; //U0001 error\n```\n\nThere is no analysis for `new()` however, because a default constructor with\nvalue types can be by design. Though if not, they can be declared with an \n`[Obsolete(\"\", true)]` attribute with the parameter `true` to disallow it.\n\n### Contributing and direction\n\nThis library is made to provide building blocks for working with native code in C#.\nFor minimizing runtime cost and to expose the efficiency that was always there.\nCommonly putting the author in a position where they need to exercise more control.\n\n\u003e _with great power, comes great responsibility_\n\nContributions that fit this are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimulation-tree%2Funmanaged","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimulation-tree%2Funmanaged","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimulation-tree%2Funmanaged/lists"}