Sharpen is a Visual Studio extension that intelligently modernizes your existing C# codebase. It makes your code more expressive, more readable, more robust, and more performant, in one word - sharper.
Sharpen identifies places in your code that will benefit from introducing new C# language features. It helps you to learn new C# features quicker and critically refactor your existing code to modern C#.
Benefits at a Glance
Sharpen helps you to:
Faster Learning of New C# Features
Learn new C# features faster by applying them to your existing codebase.
Sharpen points you to places in real-life production code - your production code! - where you can learn and apply modern C#. This is a far cry from simplified and artificial code samples often used to explain new C# features. Sharpen allows you to learn and understand modern C# in the context of your own code.
Sharpen provides you with meaningful recommendations and considerations for modernizing your code. It relates those recommendations and considerations to particular C# versions and their language features. Recommendations and considerations supported at the moment are listed below, sorted by the language version. Each new version of Sharpen brings additional recommendations and considerations.
Modernizing and Refactoring Code
Modernize your C# code by refactoring it via a single mouse click.
Sharpen will have a preview window that shows how the code looks now and how it will look after the proposed change is applied. That way, you will clearly understand the difference and, at the same time, visually grasp what the language feature is about. You will have the option to accept the proposed change and automatically refactor that piece of code.
Preview is not implemented at the moment. Here is a rough mockup of that upcoming functionality.
Refactoring will not be limited to the preview window only. It will be possible on different scales. E.g. in a single place in code, or in a single file, or a whole project, or solution. Sharpen will give you full control over the scope and nature of the refactorings. Also, it will automatically refactor only direct recommendations. Those are considered as always safe to apply.
This mockup shows applying suggested changes for a specific language feature within all files of a solution.
Until Sharpen built-in refactorings are implemented, you can use the code fixes that come with Visual Studio for some of the recommendations. They are not available for all Sharpen recommendations, but for some, they are, so make sure to take a look if they might exist.
High-Quality Documentation on C# Language at your Fingerprints
Learn C# without leaving Visual Studio by using built-in, high-quality documentation.
Sharpen will bring high-quality C# documentation right at your fingerprints. It will provide its own extensive built-in documentation that explains C# language features in-depth. It will also link to the official MSDN documentation and curated high-quality online blog posts and videos that bring additional insights into particular topics.
Sharpen aims to become a one-stop-shop for everything you ever wanted to know about the design and evolution of C#.
In its current version, Sharpen links C# releases and language features to their official MSDN documentation. Extensive built-in documentation will be available in upcoming versions of Sharpen. (To open the documentation in an external browser, press the CTRL key while clicking on the link.)
Critical Approach to New C# Features
Understand the potential drawbacks of new C# features before using them.
Sharpen imposes a critical view on C# features. It does that by distinguishing between recommendations and considerations. Recommendations are safe and recommended to apply. They will result in a more expressive, more readable, more robust, or more performant code. Recommendations always start with call-for-action verbs like "use," "apply," or "replace." Considerations, on the other hand, ask you to critically assess a particular language feature's usage in a given context. Considerations usually start with the verb "consider."
At the moment, Sharpen's considerations do not provide any explanations. In the upcoming versions, every consideration will come with an explanation. This explanation, together with additional examples, will provide you with enough information to decide if the language feature should be used in that particular case.
Improving Design and Architecture of a Broader Codebase
Recognize potential improvements and redesign and rearchitecture your code on a broader scope.
Sharpen is equipped with intelligent heuristics that recognizes potential code improvements on a broader scope. For example, the "Consider awaiting equivalent asynchronous method and yielding IAsyncEnumerable" recognizes places where asynchronous streams might be a better design choice than returning an
Other examples would be considering:
Consistent Usage of C# Features
Use new C# features consistently over your entire codebase.
Future versions of Sharpen will allow you to configure which recommendations are relevant for you and refine the recommendations using recommendation-specific settings. Storing of such configurations will be possible on different levels, e.g., on a project, or on a solution, or on a machine level, to name just a few possibilities. It will be possible to share Sharpen's configuration among programmers working on the same project by checking it into the source code repository.
Note that defining and storing configurations is not implemented at the moment.
Running Code Analysis
To run Sharpen analysis on a whole solution, go to the "Tools -> Sharpen -> Analyze Solution".
All notable changes to the Sharpen extension are documented in the changelog.
Sharpen is licensed under the MIT license.