Introducing Sharpen – Visual Studio extension for learning modern C# and modernizing your code

Covergrafik zur Sharpen Visual Studio Extension

Learning modern C# and modernizing your C# code turns out not to be easy. In a recent conversation with Bahrudin Hrnjica, MVP for Developer Technologies, he used an interesting expression: “the inflation of C# features”. The expression precisely describes what happened to C# once it switched to the Roslyn compiler. The new infrastructure empowered the compiler team to ship new features quickly. The benefits of that fast paced development are obvious. C# evolves faster than ever, offering us to write code that is:

  • more readable
  • more robust
  • less error-prone
  • more performant

But this fast pace comes with a price. Out of consulting and speaking experience, developers have difficulties catching up with new language concepts and features. Konrad Kokosa in his recent post on Reddit expressed perfectly that difficulty with an image showing the overwhelming number of C# features.

A year ago in a similar Reddit thread I wrote:

“C# evolves very quickly. Developers are not able to catch up with its development pace. It is hard to distinguish between genuinely useful features and syntactic sugar that can only cause headaches.”

In the same thread I announced that I had started working on a Visual Studio Extension called Sharpen. Its noble aim is to “intelligently introduce new C# features into your existing code base”. Even in this early stage almost 8000 downloads on the VS Marketplace shows that Sharpen has potential.

Why I’ve Decided to Develop Sharpen?

The “Why” behind Sharpen is described on the “Why Sharpen” Wiki page:

Sharpen is a result of a strong personal belief and a personal need.

I firmly believe that new C# features improve our code. They make it shorter, simpler, more expressive, more performant, and more readable. I believe developers should actively learn, understand and critically apply new C# features in their everyday work.

I ❤ C#. I love the fact that it evolves and that it evolves quickly. But I keep seeing a problem this fast-paced evolution causes. Developers have difficulties catching up with new language features and concepts.

For the past couple of years, I’ve been giving talks and workshops on new C# features. Year after year I keep noticing a disturbing fact. Developers come to a talk, hear about new features and months after report that they are still not using them in their everyday work. In my experience, the adoption of new C# features is rather slow. There are numerous reasons for that, for sure. One of them is a lack of a clear connection between a new feature and an existing code where that feature can be used. As many other C# evangelists, I tended to use simplified, artificial code samples in my workshops and talks. What I needed and wanted to have was a tool that will point out places in developers’ existing code where they can immediately start applying new C# features. I needed a tool that will help them learn C# quicker and more efficiently, by providing high-quality and easily accessible documentation.

That’s why I’ve started building Sharpen. To help developers efficiently learn and apply new C# features in their everyday coding. And to make my talks and workshops more tangible and more efficient.

In hindsight, everything I wrote back then still holds. In the meanwhile, Sharpen got more than 25 thousand downloads from the Visual Studio marketplace and a lot of encouraging feedback. It is still in an early stage, but it proves to be useful.

What Sharpen Does?

Sharpen uses static code analysis to identify places in existing code that will benefit from introducing new C# language features. It helps programmers to learn new C# features quicker and critically refactor their existing code to modern C#. This video, although being a bit outdated, demonstrates well basic usage of Sharpen:

In its latest version, Sharpen supports C# 8.0 features. It also comes with built in C# documentation. When hovering over the items in the Sharpen Results window, either a “Learn more…” or “What is new in C# <version>?” link will appear:

Sharpen helps you to quicker understand and grasp new C# features by meaningfully connecting them to your existing code base. It also helps you to develop a critical view on the features by distinguishing between the clear recommendations like “Replace switch statement … with switch expression” and suggestions like “Consider replacing switch statement … with switch expression”. In the future suggestions will come with clear tips why to be cautious when applying a new language feature in that particular situation.

In the nearby future Sharpen will provide refactoring as well, allowing you to automatically refactor your code to modern C#. Refactoring is undoubtfully the most requested feature from the community as for example this discussion on GitHub shows.

Giving Sharpen a Try

To give Sharpen a try on your own, simply install it from Visual Studio’s Extensions and Updates dialog.

To learn more about Sharpen, its vision, and currently available features visit its official homepage: https://sharpen.rocks.

Last but not least, let me know what you think. Do you find Sharpen and the idea behind it useful? Are there any features that you will like to see coming soon?