{"id":21534527,"url":"https://github.com/winseros/tostringdotnet","last_synced_at":"2025-08-21T03:09:30.384Z","repository":{"id":81337537,"uuid":"268572096","full_name":"winseros/ToStringDotNet","owner":"winseros","description":"Will help you to avoid handwriting ToString methods for your .NET projects","archived":false,"fork":false,"pushed_at":"2022-06-07T11:09:52.000Z","size":32,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T07:20:43.787Z","etag":null,"topics":["csharp","tostring"],"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/winseros.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-06-01T16:18:58.000Z","updated_at":"2024-05-19T14:28:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"699703a5-6a51-41cb-9d3e-92e166ea2fbf","html_url":"https://github.com/winseros/ToStringDotNet","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/winseros/ToStringDotNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winseros%2FToStringDotNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winseros%2FToStringDotNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winseros%2FToStringDotNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winseros%2FToStringDotNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/winseros","download_url":"https://codeload.github.com/winseros/ToStringDotNet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winseros%2FToStringDotNet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271420143,"owners_count":24756490,"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-08-21T02:00:08.990Z","response_time":74,"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","tostring"],"created_at":"2024-11-24T03:11:06.564Z","updated_at":"2025-08-21T03:09:30.379Z","avatar_url":"https://github.com/winseros.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ToStringDotNet\n\nThe library purpose is to save you from handrwiting `ToString()` method implementations for your objects.\n\nInstead of:\n\n```csharp\nclass MyClass\n{\n    public string MyProperty { get; set; }\n\n    public void ToString()\n    {\n        var sb = new StringBuilder();\n        sb.Append(\"{\\\"MyProperty\\\":\\\"\");\n        sb.Append(this.MyProperty);\n        sb.Append(\"\\\"}\");\n        return sb.ToString();\n    }\n}\n```\n\nYou can write:\n\n```csharp\nclass MyClass\n{\n    [ToString]\n    public string MyProperty { get; set; }\n\n    public void ToString()\n    {\n        return ToStringFormatter.Format(this);\n    }\n}\n```\n\n## How to\n\n### Print an object\n\n```csharp\nclass MyClass\n{\n    [ToString]\n    public string MyProperty1 { get; set; }\n\n    [ToString]\n    public int MyProperty2 { get; set; }\n}\n\n...\n\nvar obj = new MyObject{MyProperty1 = \"p1\", MyProperty2 = 1};\nvar str = ToStringFormatter.Format(obj);\nConsole.WriteLine(str);\n//{\"MyProperty1\":\"p1\",\"MyProperty2\":1}\n```\n\n### Reorder properties\n\n```csharp\nclass MyClass\n{\n    [ToString(1)] //lower priority - goes last\n    public string MyProperty1 { get; set; }\n\n    [ToString(2)] //higher priority - goes first\n    public int MyProperty2 { get; set; }\n}\n\n...\n\nvar obj = new MyObject{MyProperty1 = \"p1\", MyProperty2 = 1};\nvar str = ToStringFormatter.Format(obj);\nConsole.WriteLine(str);\n//{\"MyProperty2\":1,\"MyProperty1\":\"p2\"}\n```\n\n### Exclude inherited properties\n\n```csharp\nclass MyParentClass\n{\n    [ToString]\n    public string MyProperty1 { get; set; }\n}\n\n[ToStringInheritance(ToStringInheritance.NotInherit)]\nclass MyChildClass: MyParentClass\n{\n    [ToString]\n    public string MyProperty2 { get; set; }\n}\n\n...\n\nvar obj = new MyChildClass{MyProperty1 = \"p1\", MyProperty2 = \"p2\"};\nvar str = ToStringFormatter.Format(obj);\nConsole.WriteLine(str);\n//{\"MyProperty2\":\"p2\"}\n```\n\n### More examples\n\nFor more examples see the [ToStringDotNet.Test](./ToStringDotNet.Test) project.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinseros%2Ftostringdotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinseros%2Ftostringdotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinseros%2Ftostringdotnet/lists"}