{"id":16641201,"url":"https://github.com/cmstead/pretty-object","last_synced_at":"2026-04-26T07:35:19.611Z","repository":{"id":72520972,"uuid":"336483802","full_name":"cmstead/pretty-object","owner":"cmstead","description":"A utility for producing a simple string representation of an object in C#","archived":false,"fork":false,"pushed_at":"2021-02-09T00:13:27.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-15T04:08:13.211Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmstead.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":"2021-02-06T07:45:05.000Z","updated_at":"2021-09-12T04:17:16.000Z","dependencies_parsed_at":"2023-02-26T10:15:39.496Z","dependency_job_id":null,"html_url":"https://github.com/cmstead/pretty-object","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cmstead/pretty-object","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Fpretty-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Fpretty-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Fpretty-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Fpretty-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmstead","download_url":"https://codeload.github.com/cmstead/pretty-object/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Fpretty-object/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32289926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T06:26:00.361Z","status":"ssl_error","status_checked_at":"2026-04-26T06:25:58.791Z","response_time":129,"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":[],"created_at":"2024-10-12T07:45:47.487Z","updated_at":"2026-04-26T07:35:19.594Z","avatar_url":"https://github.com/cmstead.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pretty Object #\n\nPretty Object is an object pretty-printer for handling Golden Master test output. Pretty Object, out of the box, will print all accessible fields in an object as a new-line delimited output. You can also provide transformations for any field values which either should be ignored, or might need to be modified, such as DateTime comparisons.\n\n## Usage ##\n\n### Just Printing Object Properties ###\n\nExample with Approvals:\n\n```csharp\n// Don't forget to add a using statement:\n// using PrettyObject;\n\nvar testObject = new TestObject();\n\nvar objectFieldOutput = PrettyPrinter.PrettyPrint(testObject);\n\nApprovals.Verify(objectFieldOutput);\n```\n\nIt can also be used as a mixin:\n\n```csharp\n// Don't forget to add a using statement:\n// using PrettyObject;\n\nvar testObject = new TestObject();\n\nApprovals.Verify(testObject.PrettyPrint(testObject));\n```\n\n### Modifying Properties Before Printing ###\n\nUsing an anonymous object with field name and transformation funcs:\n\n```csharp\nvar testObject = new TestObject();\n\nvar verificationOutput = testObject.PrettyPrint(new\n{\n    StringField = new Func\u003cstring, string\u003e((value)\n        =\u003e ReverseString(value)),\n    IntField = new Func\u003cint, string\u003e((value)\n        =\u003e (value * 2).ToString())\n});\n\nApprovals.Verify(verificationOutput);\n```\n\nUsing a single func (JavaScript JSON.stringify style transformations):\n\n```csharp\nvar testObject = new TestObject();\n\nFunc\u003cstring, object, string\u003e transformStringValue = (name, value) =\u003e\n{\n    switch (name)\n    {\n        case \"StringField\":\n            return ReverseString(value);\n        default:\n            return value.ToNullSafeString();\n    }\n};\n\nvar objectFieldOutput = testObject.PrettyPrint(transformStringValue);\n\nApprovals.Verify(objectFieldOutput);\n```\n\n## Public API ##\n\n- PrettyPrint:\n    - `public string PrettyPrint(this T objectToPrint)`\n    - `public string PrettyPrint(this T objectToPrint, Func\u003cstring, object, object\u003e transformer)`\n    - `public string PrettyPrint(this T objectToPrint, Func\u003cstring, object, string\u003e transformer)`\n    - `public string PrettyPrint(this T objectToPrint, object transformer)`\n        - All properties for the transformer object must be `Func\u003cT, string\u003e`\n- ToNullSafeString:\n    - `public string ToNullSafeString\u003cT\u003e(this T value)`\n- ToStringOrNull:\n    - `public string ToStringOrNull\u003cT\u003e(this T value)`\n\n## Thanks and Contributors ##\n\nBig thanks to [@jason-kerney](https://github.com/jason-kerney) for his contributions!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmstead%2Fpretty-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmstead%2Fpretty-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmstead%2Fpretty-object/lists"}