{"id":18276184,"url":"https://github.com/kokoabim/vscode-csharpen","last_synced_at":"2026-03-09T02:32:02.200Z","repository":{"id":235268785,"uuid":"790411379","full_name":"kokoabim/vscode-csharpen","owner":"kokoabim","description":"Sharpen (organize) C# files by ordering, sorting and regionalizing symbols","archived":false,"fork":false,"pushed_at":"2025-06-28T19:26:46.000Z","size":1004,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-27T21:21:13.588Z","etag":null,"topics":["csharp","formatter","vscode-extension"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/kokoabim.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":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-22T20:39:44.000Z","updated_at":"2025-06-28T19:26:50.000Z","dependencies_parsed_at":"2024-04-22T22:03:30.045Z","dependency_job_id":"ffc98980-7167-4c65-b437-fcaf0dbf70d6","html_url":"https://github.com/kokoabim/vscode-csharpen","commit_stats":null,"previous_names":["kokoabim/vscode-csharpen"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/kokoabim/vscode-csharpen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokoabim%2Fvscode-csharpen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokoabim%2Fvscode-csharpen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokoabim%2Fvscode-csharpen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokoabim%2Fvscode-csharpen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kokoabim","download_url":"https://codeload.github.com/kokoabim/vscode-csharpen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokoabim%2Fvscode-csharpen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30280852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:23:26.802Z","status":"ssl_error","status_checked_at":"2026-03-09T02:22:46.175Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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","formatter","vscode-extension"],"created_at":"2024-11-05T12:15:12.124Z","updated_at":"2026-03-09T02:32:02.182Z","avatar_url":"https://github.com/kokoabim.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    \u003cp\u003e\u003cimg src=\"https://github.com/kokoabim/vscode-csharpen/blob/main/images/extension-512.png?raw=true\" alt=\"logo\" width=\"240\"\u003e\u003c/p\u003e\n    \u003cp\u003eCSharpen\u003c/p\u003e\n\u003c/h1\u003e\n\u003ch3 align=\"center\"\u003eC# File Organizer\u003c/h3\u003e\n\u003cp align=\"center\"\u003eOrder, sort and regionalize symbols by access level, name and type, and other features to keep your C# files \u003cspan style=\"font-weight:bold;font-style:italic;\"\u003esharp\u003c/span\u003e.\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003ca href=\"https://marketplace.visualstudio.com/items?itemName=spencerjames.csharpen\"\u003e\u003cimg src=\"https://vsmarketplacebadges.dev/version/spencerjames.csharpen.svg?label=CSharpen\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n# Features\n\n-   Order, sort and regionalize symbols by access level, name and type.\n-   Remove unused `using` directives.\n-   Remove unused package references (NuGet) of one or more projects in a solution.\n-   Perform Quick Fixes.\n-   Apply coding styles.\n-   Rename symbols by convention.\n-   Regionalize interface implementations.\n-   Output File Diagnostics and Quick Fixes.\n\n### Keyboard shortcut\n\n-   Current file: **⇧**+**⌥**+**⌘**+**f** on macOS, **shift**+**alt**+**logo**+**f** on Windows/Linux\n-   Tip: Think Format Document command, which is **⇧**+**⌥**+**f** on macOS or **shift**+**alt**+**f** on Windows/Linux, but add **⌘** on macOS or **logo** on Windows/Linux.\n\n### Commands\n\n-   Current file: \"Sharpen Document\" (`kokoabim.csharpen.sharpen-file`)\n-   Project files: \"Sharpen All Files In Project...\" (`kokoabim.csharpen.sharpen-project-files`)\n\nSee Features -\u003e Commands for more.\n\n# Remove Unused Package References\n\nRemove unused package references (NuGet) from one or more projects. For all C# files of the projects being processed, unused `using` directives will be removed and, if enabled, the file will be _sharpened_ (setting: `csharpen.sharpenFilesWhenRemovingUnusedReferences`).\n\nCommand: \"Remove Unused References Of Project...\" (`kokoabim.csharpen.remove-unused-references`)\n\n### Known Issue\n\nIt is possible that _used_ `using` directives are removed. This is due to VS Code incorrectly indicating that a `using` directive is not used (by way of its `vscode.languages.getDiagnostics(Uri):Diagnostic[]` API). The setting `csharpen.delayBeforeRemovingUnusedUsingDirectives` adds a delay after showing the file in the editor which may help with this issue though adds time to the overall process.\n\nNote: If this occurs, use the Quick Fix to re-edd the `using` directive. (**⌘**+**.** on macOS or **ctrl**+**.** on Windows/Linux)\n\n# Remove Unused Using Directives\n\nRemove unused `using` directives (either when _sharpening_ a file, removing unused package references or using a standalone command).\n\nStand-alone command: \"Remove Unused Using Declarations\" (`kokoabim.csharpen.remove-unused-usings`)\n\nNote: Append to the `using` directive line with `// csharpen: do-not-remove` comment to prevent it from being removed. This is useful for `using` directives that are (seemed to be) not used because of preprocessor directives controlling conditional compilation or not used in code but are required by tooling.\n\n# Perform Quick Fixes\n\nBased on configurable Quick Fix title patterns, performs all matched Quick Fixes for the current file. Can be invoked by command (`Perform Quick Fixes`) or when _sharpening_ a file by setting `csharpen.performQuickFixesOnSharpen` to `true` (`false` by default). Whether enabled or not, not invoked when processing all project files.\n\nSee settings for default patterns. More default patterns can be added in future releases.\n\n# Coding Styles\n\nApply coding styles using a command (\"Apply Coding Styles\") or when _sharpening_ (by setting `csharpen.codingStylesEnabled` to `true`).\n\n### Current Coding Styles\n\n| Setting                                               | Description                                                                                                                              |\n| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |\n| `csharpen.convertNonPrivateFieldsToProperties`        | Convert non-private fields to properties. Preserves value assignment (if any).                                                           |\n| `csharpen.useLanguageKeywordsInsteadOfFrameworkTypes` | Change BCL/Framework types to language keywords on return and member types. Example: `System.String` to `string`, `Int32` to `int`, etc. |\n\nIndividual rules can be disabled in settings. By default all rules are enabled.\n\n### Future Coding Styles\n\nOn subsequent releases, additional rules will be added.\n\n# Symbol Renaming\n\nBased on configurable logic and patterns, symbols can be renamed on _sharpen_. The renaming operation uses VS Code's built-in rename functionality thus all references in other files are renamed as well.\n\nAn example use case (and a default setting): All methods that (1) include a member modifier of `async`, (2) have a return type of `Task` or `ValueTask` (with or without generic type arguments) and (3) the symbol name does _not_ end with `Async` are renamed to _have_ a suffix of `Async`.\n\nSee settings: `csharpen.symbolRenamingEnabled` and `csharpen.symbolRenaming`.\n\n# Regionalize by Access Modifier and Type\n\nRegionalize symbols by access modifier and/or type on _sharpen_. Customizable in settings.\n\n# Regionalize Interface Implementations\n\nRegionalize interface implementations by grouping them together within regions on _sharpen_.\n\nSupported interface implementations:\n\n-   `IAsyncDisposable`, `IDisposable`\n-   `ICloneable`\n-   `ICollection`, `ICollection\u003cT\u003e`\n-   `IComparable`, `IComparable\u003cT\u003e`\n-   `IConvertible`\n-   `IEnumerable`, `IEnumerable\u003cT\u003e`\n-   `IEqualityComparer\u003cT\u003e`\n-   `IEquatable\u003cT\u003e`\n-   `IFormattable`\n-   `IList`, `IList\u003cT\u003e`\n\nInterface implementations grouped by the interface name (without generic type argument list) because of the implementation size:\n\n-   `IAsyncDisposable`, `IDisposable`\n-   `ICollection`, `ICollection\u003cT\u003e`\n-   `IConvertible`\n-   `IList`, `IList\u003cT\u003e`\n\nInterface implementations grouped in a shared `interfaces` region:\n\n-   `ICloneable`\n-   `IComparable`, `IComparable\u003cT\u003e`\n-   `IEnumerable`, `IEnumerable\u003cT\u003e`\n-   `IEqualityComparer\u003cT\u003e`,\n-   `IEquatable\u003cT\u003e`\n-   `IFormattable`\n\nNotes:\n\n-   [Explicit interface implementations](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/interfaces/explicit-interface-implementation) _are_ detected and supported.\n-   With `IDisposable` and `IAsyncDisposable` the finalizer (i.e. destructor) and possible `/^_?(is)?disposed$/i` (RegExp pattern) boolean instance field are also moved to the region.\n\n# Output File Diagnostics and Quick Fixes\n\nOutput File Diagnostics and Quick Fixes to output panel. This includes language-specific diagnostics (e.g. syntax, semantic, compiler error/warning) and what Quick Fixes are available.\n\nCommands:\n\n-   Current file: \"Output File Diagnostics\" (`kokoabim.csharpen.output-file-diagnostics`)\n-   Project files: \"Output File Diagnostics For All Files In Project...\" (`kokoabim.csharpen.output-file-diagnostics-for-project-files`)\n\n# Requirements\n\n-   _Uh..._ a C# file. 🤷🏼‍♂️\n\n# Special Handling\n\nThe following symbols are specially handled. They are not supported in the settings but are always ordered/sorted in the following:\n\n-   `using` directives:\n    -   sorted alphabetically\n    -   placed at top\n    -   unused `using` directives are removed (setting `csharpen.removeUnusedUsingsOnSharpen`)\n-   `namespace` declarations:\n    -   sorted alphabetically\n    -   placed after `using` directives\n    -   if one exists, converted to a file-scoped namespace (setting `csharpen.enforceFileScopedNamespaces`)\n\n# Known Issues / Limitations\n\n## Program.cs\n\nA `Program.cs` file must contain a `Program` class with a static `Main` method. Top-level statements are not supported. A default file filter is provided to detect this.\n\n## Undo/Redo\n\nUndo/redo _is_ supported but because a Format Document command is performed prior-to and after organizing a file, an undo/redo may need to be repeated for each operation. Annoying, I know. 😒\n\n## Preprocessor Directives\n\nFirst off, within methods, property bodies and enums, preprocessor directives are left alone and preserved.\n\nBut... on the namespace level and within types (i.e. wrapped around members), there are considerations to be aware of.\n\n1. `#pragma` directives before and after a single type or member _**should**_ be preserved.\n2. `#if` and `#endif` directives before and after a single type or member _**should**_ be preserved.\n3. `#region` and `#endregion` directives are _**not**_ preserved. These are entirely stripped out.\n4. Default file filters are provided to detect and ignore files with `#else` and `#elif` directives. If a file is _sharpened_ with these directives outside of methods, property bodies and enums, there are unexpected results. Though, if the directives exist within methods, property bodies and enums, it should be ok. The default file filters have `confirmOnDeny` set to `true` to provide ability to conveniently continue _sharpening_ when detected and you _**know**_ what you're doing.\n\nNote: All _sharpening_ modifications can always be undone.\n\n# In-Depth Language Specification\n\nIf you're curious, the [C# specification grammar](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/grammar) was referenced when writing this extension to increase the accuracy of parsing and organizing C# files. You may find it interesting to see how the language is defined. I did. 🤓\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkokoabim%2Fvscode-csharpen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkokoabim%2Fvscode-csharpen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkokoabim%2Fvscode-csharpen/lists"}