{"id":20303692,"url":"https://github.com/mariusz96/formattable-sb","last_synced_at":"2025-06-23T13:34:44.386Z","repository":{"id":60297577,"uuid":"542215339","full_name":"mariusz96/formattable-sb","owner":"mariusz96","description":"A mutable FormattableString class","archived":false,"fork":false,"pushed_at":"2024-11-14T06:36:27.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T03:39:13.652Z","etag":null,"topics":["builder","composite","formattable","formatting","mutable","nuget","string"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/FormattableSb","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/mariusz96.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,"zenodo":null}},"created_at":"2022-09-27T17:44:57.000Z","updated_at":"2024-11-14T06:34:46.000Z","dependencies_parsed_at":"2023-11-15T23:39:35.259Z","dependency_job_id":"0b816813-4061-4e66-b9c9-4448faea1ed6","html_url":"https://github.com/mariusz96/formattable-sb","commit_stats":{"total_commits":63,"total_committers":2,"mean_commits":31.5,"dds":0.2698412698412699,"last_synced_commit":"9ceb44ca9658f0d8687fdea9d6245e606609ca2a"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/mariusz96/formattable-sb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusz96%2Fformattable-sb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusz96%2Fformattable-sb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusz96%2Fformattable-sb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusz96%2Fformattable-sb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mariusz96","download_url":"https://codeload.github.com/mariusz96/formattable-sb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariusz96%2Fformattable-sb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261487286,"owners_count":23166058,"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":["builder","composite","formattable","formatting","mutable","nuget","string"],"created_at":"2024-11-14T16:40:00.980Z","updated_at":"2025-06-23T13:34:39.375Z","avatar_url":"https://github.com/mariusz96.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FormattableSb\nA mutable FormattableString class:\n```cs\nList\u003cDateTime\u003e summerDates = GetSummerDates();\n\nFormattableStringBuilder sqlBuilder = new FormattableStringBuilder()\n    .AppendInterpolated($\"INSERT INTO dbo.VacationDates (Date)\")\n    .AppendLine()\n    .AppendInterpolated($\"VALUES ({summerDates.First()})\");\n\nforeach (DateTime date in summerDates.Skip(1))\n{\n    sqlBuilder\n        .AppendInterpolated($\",\")\n        .AppendLine()\n        .AppendInterpolated($\"({date})\");\n}\n\n// sql.Format:\n// INSERT INTO dbo.VacationDates (Date)\n// VALUES ({0}),\n// ({1}),\n// ({2}),\n// ...\n\n// sql.GetArguments():\n// [\n//   System.DateTime,\n//   System.DateTime,\n//   System.DateTime,\n//   ...\n// ]\nFormattableString sql = sqlBuilder.ToFormattableString();\n```\n```cs\nstatic List\u003cDateTime\u003e GetSummerDates()\n{\n    DateTime startDate = new(2040, 6, 20);\n    DateTime endDate = new(2040, 9, 22);\n\n    List\u003cDateTime\u003e dates = new();\n\n    for (DateTime date = startDate; date \u003c= endDate; date = date.AddDays(1))\n    {\n        dates.Add(date);\n    }\n\n    return dates;\n}\n```\n### With EF Core:\n```cs\nusing VacationingContext context = new();\nint rowsAffected = context.Database.ExecuteSql(sql);\n```\n## Features:\n- Adheres to the C# language specification\n- Can be used when you want to modify a FormattableString\n- Preserves alignment and format strings\n## API:\n### AppendInterpolated:\n```cs\n/// \u003csummary\u003e\n/// Appends the specified interpolated string to the end of the composite format string,\n/// replacing its arguments with placeholders and adding them as objects.\n/// \u003c/summary\u003e\n/// \u003cparam name=\"handler\"\u003eThe interpolated string to append, along with the arguments.\u003c/param\u003e\n/// \u003creturns\u003eA reference to this instance after the append operation has completed.\u003c/returns\u003e\npublic FormattableStringBuilder AppendInterpolated([InterpolatedStringHandlerArgument(\"\")] ref AppendInterpolatedHandler handler)\n```\n### AppendLine:\n```cs\n/// \u003csummary\u003e\n/// Appends the default line terminator to the end of the composite format string.\n/// \u003c/summary\u003e\n/// \u003creturns\u003eA reference to this instance after the append operation has completed.\u003c/returns\u003e\npublic FormattableStringBuilder AppendLine()\n```\n### ToFormattableString:\n```cs\n/// \u003csummary\u003e\n/// Creates a \u003csee cref=\"FormattableString\"/\u003e from this builder.\n/// \u003c/summary\u003e\n/// \u003creturns\u003eThe object that represents the composite format string and its arguments.\u003c/returns\u003e\npublic FormattableString ToFormattableString()\n```\n## Setup:\n- Install FormattableSb via NuGet Package Manager, Package Manager Console or dotnet CLI:\n```\nInstall-Package FormattableSb\n```\n```\ndotnet add package FormattableSb\n```\n## Credits:\n- Thanks to Stephen Toub for the implementation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariusz96%2Fformattable-sb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariusz96%2Fformattable-sb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariusz96%2Fformattable-sb/lists"}