Skip to content

Latest commit

 

History

History
166 lines (111 loc) · 12.3 KB

README.md

File metadata and controls

166 lines (111 loc) · 12.3 KB

Sharpen

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.

Twitter Visual Studio Marketplace Version AppVeyor GitHub release License

TL; DR

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#.

Sharpen in action

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.

C# 8.0

C# 8.0 recommendations and considerations

C# 7.1

C# 7.1 recommendations and considerations

C# 7.0

C# 7.0 recommendations and considerations

C# 6.0

C# 6.0 recommendations and considerations

C# 5.0

C# 5.0 recommendations and considerations

C# 3.0

C# 3.0 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.

Sharpen preview window

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.

Applying Sharpen's recommendations

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.

Refactoring code by using Visual Studio code fixes

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.)

High-Quality Documentation on C# Language at your Fingerprints

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."

Sharpen's recommendations and considerations

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.

An explanation for a Sharpen consideration

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 IEnumerable<T>. Accepting such consideration impacts and improves the code on a broader scope. It means rearchitecting and redesigning a larger portion of the codebase rather than simply refactoring an isolated piece of code.

Consider awaiting equivalent asynchronous method and yielding IAsyncEnumerable

Other examples would be considering:

  • to rearchitecture legacy asynchronous programming patterns like, e.g. IAsyncResult pattern, to the Task-based Asynchronous Pattern and async and await.
  • to rearchitecture mutable Data Transfer Objects to C# 9.0 records.

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.

Installing Sharpen

You can install Sharpen directly from Visual Studio by using Extensions dialog or you can download it from the Visual Studio Marketplace.

Installing Sharpen from Visual Studio

Running Code Analysis

To run Sharpen analysis on a whole solution, go to the "Tools -> Sharpen -> Analyze Solution".
To run an analysis on the currently edited file, use the "Analyze with Sharpen" context menu option on the file context menu.
To run an analysis on an arbitrary scope, use the "Analyze with Sharpen" context menu option after selecting nodes in the Solution Explorer.

Running Sharpen code analysis

Contributing

Sharpen is a volunteer effort. Covering the whole C# evolution is a humongous task that cannot be carried out by a few people. So pitch in and join the development! :-) Before contributing, please make sure to read the contribution guidelines.

Release Notes

All notable changes to the Sharpen extension are documented in the changelog.

License

Sharpen is licensed under the MIT license.