{"id":21047096,"url":"https://github.com/stakx/typenameformatter","last_synced_at":"2025-10-09T09:13:55.600Z","repository":{"id":55001787,"uuid":"130747685","full_name":"stakx/TypeNameFormatter","owner":"stakx","description":"A small .NET library for formatting type names à la C#.","archived":false,"fork":false,"pushed_at":"2025-04-01T17:57:27.000Z","size":146,"stargazers_count":33,"open_issues_count":4,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-09T09:12:22.825Z","etag":null,"topics":["csharp","dotnet","dotnet-standard","formatter","reflection","types"],"latest_commit_sha":null,"homepage":null,"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/stakx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2018-04-23T19:40:19.000Z","updated_at":"2025-04-01T17:57:31.000Z","dependencies_parsed_at":"2025-08-20T18:32:13.931Z","dependency_job_id":"315fdac5-6350-439a-9f7a-21dc92022656","html_url":"https://github.com/stakx/TypeNameFormatter","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/stakx/TypeNameFormatter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stakx%2FTypeNameFormatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stakx%2FTypeNameFormatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stakx%2FTypeNameFormatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stakx%2FTypeNameFormatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stakx","download_url":"https://codeload.github.com/stakx/TypeNameFormatter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stakx%2FTypeNameFormatter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001115,"owners_count":26083021,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","dotnet-standard","formatter","reflection","types"],"created_at":"2024-11-19T14:35:26.478Z","updated_at":"2025-10-09T09:13:55.583Z","avatar_url":"https://github.com/stakx.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿![TypeNameFormatter](https://github.com/stakx/typenameformatter/raw/main/assets/icon-64x64.png \"TypeNameFormatter\")\n\nTypeNameFormatter is a small .NET library for formatting type names à la C#. \n\n[![NuGet badge](https://img.shields.io/nuget/v/TypeNameFormatter.Sources.svg)](https://www.nuget.org/packages/TypeNameFormatter.Sources \"Package available on NuGet.org\") [![AppVeyor](https://img.shields.io/appveyor/ci/stakx/TypeNameFormatter.svg)](https://ci.appveyor.com/project/stakx/typenameformatter) ![AppVeyor tests](https://img.shields.io/appveyor/tests/stakx/TypeNameFormatter.svg) [![Codecov](https://codecov.io/gh/stakx/TypeNameFormatter/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stakx/TypeNameFormatter/branch/main)\n\n\n## What is this good for?\n\nHave you ever stumbled over the cryptic formatting of `Type` objects?\n\n```csharp\nvar someType = typeof(IEnumerable\u003cint[]\u003e);\n\nConsole.WriteLine(someType);\n// =\u003e System.Collections.Generic.IEnumerable`1[System.Int32[]]\n```\n\nIf you'd rather see something that looks more like a C# type name, then this library might be for you:\n\n```csharp\nusing TypeNameFormatter;\n\nvar someType = typeof(IEnumerable\u003cint[]\u003e);\n\nConsole.WriteLine(someType.GetFormattedName());\n// =\u003e IEnumerable\u003cint[]\u003e\n```\n\nFormatting any `Type` involves more special cases than you might expect (such as generic types, nested types, multi-dimensional and jagged arrays, by-reference and pointer types). This library deals with all of those, so that you don't have to.\n\n\n## How do I use it?\n\nBy importing the `TypeNameFormatter` namespace, the following extension methods become available:\n\n* **`stringBuilder.AppendFormattedName(Type type, [TypeNameFormatOptions options])`**:  \n  Appends a C#-formatted type name to the given `StringBuilder`.\n \n* **`type.GetFormattedName([TypeNameFormatOptions options])`**:  \n  Returns a C#-formatted type name as a string. (This is a convenience method that does exactly the same as the above, using a throw-away `StringBuilder`.)\n\nBoth methods allow you to specify any combination of the following `TypeNameFormatOptions` flags:\n\n* **`Namespaces`**:  \n  Namespaces should be included. (For example, `System.Action` instead of `Action`.)\n\n* **`NoAnonymousTypes`**:\n  Anonymous types should not have their \"display class\" name transformed to a more legible syntax. (For example, `\u003c\u003ef__AnonymousType5\u003cstring, int\u003e` instead of `{string Name, int Count}`.)\n\n* **`NoGenericParameterNames`**:  \n  Parameter names of an open generic type should be omitted. (For example, `IEnumerable\u003c\u003e` instead of `IEnumerable\u003cT\u003e`. Note that this setting does not affect closed generic types; their arguments are always included.)\n\n* **`NoKeywords`**:  \n  Primitive types should not be mapped to their corresponding C# language keywords. (For example, `Int32` instead of `int`.)\n\n* **`NoNullableQuestionMark`**:\n  Nullable types should not be formatted using C# question mark syntax. (For example, `Nullable\u003cint\u003e` instead of `int?`.)\n\n* **`NoTuple`**:\n  Value tuple types should not be formatted using C# tuple syntax. (For example, `ValueTuple\u003cbool, int\u003e` instead of `(bool, int)`.)\n\n\n## But it doesn't format \\\u003csome type\\\u003e correctly!\n\nIf you think you've found a bug, please raise an [issue](https://github.com/stakx/TypeNameFormatter/issues) so it can be looked into. (Make sure to mention the type that doesn't get formatted as expected.)\n\n\n## Alternatives\n\n* If you're targeting the .NET Framework, you can use good old `System.CodeDom` (which isn't particularly fast, however):\n\n   ```csharp\n   using Microsoft.CSharp;\n   using System.CodeDom;\n\n   static string GetFormattedName(this Type type)\n   {\n       using (var provider = new CSharpCodeProvider())\n       {\n           var typeReference = new CodeTypeReference(type);\n           return provider.GetTypeOutput(typeReference);\n       }\n   }\n   ```\n\n* You could perhaps use Microsoft's [.NET Compiler Platform (Roslyn)](https://www.nuget.org/packages/Microsoft.CodeAnalysis \"'Microsoft.CodeAnalysis' package on NuGet\"), but that is a large library that can do much more than is needed.\n\n## Advanced usage\n\n### Configuration knobs for the source code distribution\n\nThe **TypeNameFormatter.Sources** NuGet package comes with a few MSBuild properties that you can set inside your project file (inside a `\u003cPropertyGroup\u003e`):\n\n* **`\u003cTypeNameFormatterInternal\u003e`**:  \n  This property determines the visibility of the types provided by TypeNameFormatter:\n    * If set to `True` (the default), they are declared `internal`.\n    * If set to `False`, they are declared `public`.\n\n* **`\u003cTypeNameFormatterProjectNodeName\u003e`**:  \n  This property determines the name under which TypeNameFormatter's single `.cs` file will appear in e.g. Visual Studio's Solution Explorer:\n    * If set to `TypeNameFormatter.cs` (the default), a hidden linked file by that name will be added to your project's root.\n    * If set to any other relative file path, a visible linked file will be added to your project.\n\nFor example:\n\n```xml\n\u003cProject …\u003e\n  …\n  \u003cPropertyGroup\u003e\n    \u003c!-- Make TypeNameFormatter's types `public` instead of `internal`: --\u003e\n    \u003cTypeNameFormatterInternal\u003eFalse\u003cTypeNameFormatterInternal\u003e\n\n    \u003c!-- Make a linked file `TypeNameFormatter.cs` show up in Solution Explorer\n         under a folder node named `Utilities`: --\u003e\n    \u003cTypeNameFormatterProjectNodeName\u003eUtilities\\TypeNameFormatter.cs\u003c/TypeNameFormatterProjectNodeName\u003e\n  \u003c/PropertyGroup\u003e\n  …\n\u003c/Project\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstakx%2Ftypenameformatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstakx%2Ftypenameformatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstakx%2Ftypenameformatter/lists"}